[cost] Add Iterator.next model

Summary:
It adds `Iterator.next` model.

Depends on D16804808

Reviewed By: ezgicicek

Differential Revision: D16807279

fbshipit-source-id: 7d9d7ae73
master
Sungkeun Cho 5 years ago committed by Facebook Github Bot
parent de3f97136e
commit 9c49841ebb

@ -927,6 +927,15 @@ module Collection = struct
{exec; check= no_check}
let next iterator =
let exec {integer_type_widths} ~ret:(id, _) mem =
let traces = Sem.eval integer_type_widths iterator mem |> Dom.Val.get_traces in
let locs = eval_collection_internal_array_locs iterator mem in
model_by_value (Dom.Val.of_pow_loc ~traces locs) id mem
in
{exec; check= no_check}
let addAll coll_id coll_to_add =
let exec model_env ~ret mem =
let to_add_length = eval_collection_length coll_to_add mem |> Dom.Val.get_itv in
@ -1193,6 +1202,7 @@ module Call = struct
; +PatternMatch.implements_map &:: "putAll" <>$ capt_var_exn $+ capt_exp
$--> Collection.putAll
; +PatternMatch.implements_iterator &:: "hasNext" <>$ capt_exp $!--> Collection.hasNext
; +PatternMatch.implements_iterator &:: "next" <>$ capt_exp $!--> Collection.next
; +PatternMatch.implements_list &:: "subList" <>$ any_arg $+ capt_exp $+ capt_exp
$--> Collection.subList
; +PatternMatch.implements_collection

@ -62,7 +62,7 @@ codetoanalyze/java/performance/CantHandle.java, CantHandle.square_root_variant_F
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.ensure_call(CollectionTest$MyCollection):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 11 + 5 ⋅ list.length, O(list.length), degree = 1,{list.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_call_quad(int,CollectionTest$MyCollection):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 4 + 18 ⋅ list.length + 5 ⋅ list.length × list.length + 3 ⋅ (list.length + 1), O(list.length × list.length), degree = 2,{list.length + 1},Loop at line 48,{list.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{list.length},Loop at line 48]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + 5 ⋅ list.length, O(list.length), degree = 1,{list.length},Loop at line 17]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_mycollection_quad_FN(java.util.concurrent.ConcurrentLinkedQueue):void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 4 + 18 ⋅ mSubscribers.length + 5 ⋅ mSubscribers.length × Iterator.next().length.ub + 3 ⋅ (mSubscribers.length + 1), O(mSubscribers.length × Iterator.next().length.ub), degree = 2,{mSubscribers.length + 1},Loop at line 29,{Iterator.next().length.ub},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{mSubscribers.length},Loop at line 29]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_mycollection_quad_FN(java.util.concurrent.ConcurrentLinkedQueue):void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 4 + 18 ⋅ mSubscribers.length + 5 ⋅ mSubscribers.length × mSubscribers.*.length.ub + 3 ⋅ (mSubscribers.length + 1), O(mSubscribers.length × mSubscribers.*.length.ub), degree = 2,{mSubscribers.length + 1},Loop at line 29,{mSubscribers.*.length.ub},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{mSubscribers.length},Loop at line 29]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.iterate_over_some_java_collection(java.util.concurrent.ConcurrentLinkedQueue):void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 4 + 8 ⋅ mSubscribers.length + 3 ⋅ (mSubscribers.length + 1), O(mSubscribers.length), degree = 1,{mSubscribers.length + 1},Loop at line 22,{mSubscribers.length},Loop at line 22]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.loop_over_call(int,CollectionTest$MyCollection):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + 15 ⋅ size + 5 ⋅ size × list.length, O(size × list.length), degree = 2,{list.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{size},Loop at line 41]
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.nested_iterator_qubic(int,CollectionTest$MyCollection,CollectionTest$MyCollection):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 4 + 13 ⋅ list1.length + 5 ⋅ list1.length × list1.length × list2.length + 5 ⋅ list1.length × list1.length × list2.length + 28 ⋅ list1.length × list2.length + 3 ⋅ list1.length × (list2.length + 1) + 3 ⋅ (list1.length + 1), O(list1.length × list1.length × list2.length), degree = 3,{list1.length + 1},Loop at line 55,{list2.length + 1},Loop at line 56,{list2.length},Loop at line 56,{list2.length},Loop at line 56,{list1.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{list2.length},Loop at line 56,{list1.length},call to void CollectionTest.iterate_over_mycollection(CollectionTest$MyCollection),Loop at line 17,{list1.length},Loop at line 55]

Loading…
Cancel
Save