[inferbo] Add model for `Collection.toArray`

Reviewed By: skcho

Differential Revision: D19098336

fbshipit-source-id: d60b04e4b
master
Ezgi Çiçek 5 years ago committed by Facebook Github Bot
parent 5bdd70e8f0
commit be1fda72a8

@ -1193,6 +1193,7 @@ module Call = struct
; -"__new" <>$ capt_exp $+...$--> malloc ~can_be_zero:true ; -"__new" <>$ capt_exp $+...$--> malloc ~can_be_zero:true
; -"__new_array" <>$ capt_exp $+...$--> malloc ~can_be_zero:true ; -"__new_array" <>$ capt_exp $+...$--> malloc ~can_be_zero:true
; +PatternMatch.implements_arrays &:: "asList" <>$ capt_exp $!--> create_copy_array ; +PatternMatch.implements_arrays &:: "asList" <>$ capt_exp $!--> create_copy_array
; +PatternMatch.implements_collection &:: "toArray" <>$ capt_exp $+...$--> create_copy_array
; +PatternMatch.implements_arrays &:: "copyOf" <>$ capt_exp $+ capt_exp ; +PatternMatch.implements_arrays &:: "copyOf" <>$ capt_exp $+ capt_exp
$+...$--> Collection.copyOf $+...$--> Collection.copyOf
; -"__placement_new" <>$ capt_exp $+ capt_arg $+? capt_arg $!--> placement_new ; -"__placement_new" <>$ capt_exp $+ capt_arg $+? capt_arg $!--> placement_new

@ -87,4 +87,8 @@ public class Array {
String[] r2 = gen_and_iter_types(y); String[] r2 = gen_and_iter_types(y);
for (int i = 0; i < r2.length; i++) {} // should not be infinite execution time for (int i = 0; i < r2.length; i++) {} // should not be infinite execution time
} }
void toArray_linear(java.util.ArrayList<String> list) {
for (int i = 0; i < list.toArray().length; i++) {}
}
} }

@ -15,6 +15,7 @@ codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.gen_and_iter_types(int):java.lang.String[], 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + 5 ⋅ length, O(length), degree = 1,{length},Loop at line 76] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.gen_and_iter_types(int):java.lang.String[], 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + 5 ⋅ length, O(length), degree = 1,{length},Loop at line 76]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.init_array_linear():void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2564, O(1), degree = 0] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.init_array_linear():void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2564, O(1), degree = 0]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.sort_array_nlogn(int):void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + size × log(size), O(size × log(size)), degree = 1 + 1⋅log,{size},Modeled call to Arrays.sort,{size},Modeled call to Arrays.sort] codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.sort_array_nlogn(int):void, 2, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + size × log(size), O(size × log(size)), degree = 1 + 1⋅log,{size},Modeled call to Arrays.sort,{size},Modeled call to Arrays.sort]
codetoanalyze/java/performance/Array.java, codetoanalyze.java.performance.Array.toArray_linear(java.util.ArrayList):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + 6 ⋅ list.length + 3 ⋅ (list.length + 1), O(list.length), degree = 1,{list.length + 1},Loop at line 92,{list.length},Loop at line 92]
codetoanalyze/java/performance/ArrayCost.java, ArrayCost.ArrayCost(int[]):void, 5, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + 5 ⋅ mag.length, O(mag.length), degree = 1,{mag.length},Loop at line 15] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.ArrayCost(int[]):void, 5, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 5 + 5 ⋅ mag.length, O(mag.length), degree = 1,{mag.length},Loop at line 15]
codetoanalyze/java/performance/ArrayCost.java, ArrayCost.isPowOfTwo_FP(int):boolean, 4, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 883, O(1), degree = 0] codetoanalyze/java/performance/ArrayCost.java, ArrayCost.isPowOfTwo_FP(int):boolean, 4, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 883, O(1), degree = 0]
codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.arraylist_add3_overrun_bad():void, 5, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Length trace>,Array declaration,Through,Through,Through,Array access: Offset added: 4 Size: 3] codetoanalyze/java/performance/ArrayListTest.java, ArrayListTest.arraylist_add3_overrun_bad():void, 5, BUFFER_OVERRUN_L1, no_bucket, ERROR, [<Length trace>,Array declaration,Through,Through,Through,Array access: Offset added: 4 Size: 3]

Loading…
Cancel
Save