[cost] fix iterator for constant array

Summary:
Fix the FP when iterating through constant collection.

facebook
This fix is a hack for now.

Reviewed By: ezgicicek, skcho

Differential Revision: D23241338

fbshipit-source-id: e2e0c05f8
master
Qianyi Shu 4 years ago committed by Facebook GitHub Bot
parent b4f23ab599
commit 9a3bfa67c7

@ -231,6 +231,13 @@ module Loc = struct
false
let is_objc_iterator_offset = function
| BoField.Field {fn} ->
Fieldname.equal fn BoField.objc_iterator_offset
| _ ->
false
let is_frontend_tmp = function
| BoField.Prim (Var x) ->
not (Var.appears_in_source_code x)
@ -354,7 +361,8 @@ module Loc = struct
false
| BoField.Prim (Allocsite allocsite) ->
Allocsite.represents_multiple_values allocsite
| BoField.Field _ as x when is_c_strlen x || is_java_collection_internal_array x ->
| BoField.Field _ as x
when is_c_strlen x || is_java_collection_internal_array x || is_objc_iterator_offset x ->
false
| BoField.Field {prefix= l} ->
represents_multiple_values l

@ -168,7 +168,7 @@ void nsarray_next_object_linear(NSArray* array) {
}
}
void nsarray_next_object_constant_FP() {
void nsarray_next_object_constant() {
NSArray* array = @[ @1, @2 ];
for (id item in array) {
}

@ -19,7 +19,7 @@ codetoanalyze/objc/performance/NSArray.m, nsarray_init_with_objects_constant, 39
codetoanalyze/objc/performance/NSArray.m, nsarray_is_equal_to_array_linear, 4 + array1->elements.length.ub, OnUIThread:false, [{array1->elements.length.ub},Modeled call to NSArray.isEqualToArray:]
codetoanalyze/objc/performance/NSArray.m, nsarray_iterate_linear, 6 + 4 ⋅ array->elements.length.ub + 4 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_last_object_constant, 4, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_next_object_constant_FP, , OnUIThread:false, [Unbounded loop,Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_next_object_constant, 25, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_next_object_linear, 5 + array->elements.length.ub + 4 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_object_at_indexed_constant, 34, OnUIThread:false, []
codetoanalyze/objc/performance/NSArray.m, nsarray_sort_using_descriptors_constant, 34, OnUIThread:false, []

@ -1,7 +1,6 @@
codetoanalyze/objc/performance/NSArray.m, nsarray_empty_array_constant, 3, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/NSArray.m, nsarray_enumerator_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop]
codetoanalyze/objc/performance/NSArray.m, nsarray_init_constant, 3, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/objc/performance/NSArray.m, nsarray_next_object_constant_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear_FP, 2, INTEGER_OVERFLOW_U5, no_bucket, ERROR, [<LHS trace>,Unknown value from: NSDictionary.initWithDictionary:,Binary operation: ([0, +oo] + 1):signed32]
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_add_in_loop_constant_FP, 0, INFINITE_EXECUTION_TIME, no_bucket, ERROR, [Unbounded loop,Loop]

Loading…
Cancel
Save