[cost] Add model: NSKeyedUnarchiver.decodeObjectForKey:

Reviewed By: ezgicicek

Differential Revision: D24417784

fbshipit-source-id: f440ba018
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent b3c74c4152
commit dbc33aa427

@ -832,7 +832,7 @@ module AbstractCollection (Lang : Lang) = struct
let get_collection_internal_array_locs coll_id mem = let get_collection_internal_array_locs coll_id mem =
let coll = Dom.Mem.find (Loc.of_id coll_id) mem in let coll = Dom.Mem.find (Loc.of_id coll_id) mem in
Dom.Val.get_pow_loc coll |> PowLoc.append_field ~fn:Lang.collection_internal_array_field Dom.Val.get_all_locs coll |> PowLoc.append_field ~fn:Lang.collection_internal_array_field
let get_collection_internal_elements_locs coll_id mem = let get_collection_internal_elements_locs coll_id mem =
@ -1022,12 +1022,17 @@ module AbstractCollection (Lang : Lang) = struct
{exec; check= check_index ~last_included:false coll_id index_exp} {exec; check= check_index ~last_included:false coll_id index_exp}
let get_at_index coll_id index_exp = let get_any_index coll_id =
let exec _model_env ~ret:(ret_id, _) mem = let exec _model_env ~ret:(ret_id, _) mem =
let locs = get_collection_internal_elements_locs coll_id mem in let locs = get_collection_internal_elements_locs coll_id mem in
let v = Dom.Mem.find_set locs mem in let v = Dom.Mem.find_set locs mem in
model_by_value v ret_id mem model_by_value v ret_id mem
in in
{exec; check= no_check}
let get_at_index coll_id index_exp =
let {exec} = get_any_index coll_id in
{exec; check= check_index ~last_included:false coll_id index_exp} {exec; check= check_index ~last_included:false coll_id index_exp}
end end
@ -1708,6 +1713,8 @@ module Call = struct
$--> NSCollection.new_collection_by_add_all $--> NSCollection.new_collection_by_add_all
; +PatternMatch.ObjectiveC.implements "NSEnumerator" ; +PatternMatch.ObjectiveC.implements "NSEnumerator"
&:: "nextObject" <>$ capt_exp $--> NSCollection.next_object &:: "nextObject" <>$ capt_exp $--> NSCollection.next_object
; +PatternMatch.ObjectiveC.implements "NSKeyedUnarchiver"
&:: "decodeObjectForKey:" $ capt_var_exn $+...$--> NSCollection.get_any_index
; +PatternMatch.ObjectiveC.implements "NSMutableArray" ; +PatternMatch.ObjectiveC.implements "NSMutableArray"
&:: "initWithCapacity:" <>$ capt_var_exn $+ capt_exp &:: "initWithCapacity:" <>$ capt_var_exn $+ capt_exp
$--> NSCollection.new_collection_of_size $--> NSCollection.new_collection_of_size

@ -0,0 +1,13 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
void decode_object_for_key_linear(NSKeyedUnarchiver* keyed_unarchiver) {
id v = [keyed_unarchiver decodeObjectForKey:@"key"];
for (int i = 0; i < v; i++) {
}
}

@ -45,6 +45,7 @@ codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_literal_constan
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear, 7 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear, 7 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSInteger.m, nsinteger_value_linear, 3 + 3 ⋅ integer + 2 ⋅ (1+max(0, integer)), OnUIThread:false, [{1+max(0, integer)},Loop,{integer},Loop] codetoanalyze/objc/performance/NSInteger.m, nsinteger_value_linear, 3 + 3 ⋅ integer + 2 ⋅ (1+max(0, integer)), OnUIThread:false, [{1+max(0, integer)},Loop,{integer},Loop]
codetoanalyze/objc/performance/NSInteger.m, nsnumber_number_with_int_integer_value_constant, 34, OnUIThread:false, [] codetoanalyze/objc/performance/NSInteger.m, nsnumber_number_with_int_integer_value_constant, 34, OnUIThread:false, []
codetoanalyze/objc/performance/NSKeyedUnarchiver.m, decode_object_for_key_linear, 9 + 3 ⋅ keyed_unarchiver->elements[*].ub + 2 ⋅ (1+max(0, keyed_unarchiver->elements[*].ub)), OnUIThread:false, [{1+max(0, keyed_unarchiver->elements[*].ub)},Loop,{keyed_unarchiver->elements[*].ub},Loop]
codetoanalyze/objc/performance/NSMutableArray.m, nsarray_new_constant, 9, OnUIThread:false, [] codetoanalyze/objc/performance/NSMutableArray.m, nsarray_new_constant, 9, OnUIThread:false, []
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_add_all_constant, 23, OnUIThread:false, [] codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_add_all_constant, 23, OnUIThread:false, []
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_add_in_loop_constant, 152, OnUIThread:false, [] codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_add_in_loop_constant, 152, OnUIThread:false, []

Loading…
Cancel
Save