Index: test/mjsunit/array-literal-feedback.js |
diff --git a/test/mjsunit/regress/regress-crbug-245480.js b/test/mjsunit/array-literal-feedback.js |
similarity index 75% |
copy from test/mjsunit/regress/regress-crbug-245480.js |
copy to test/mjsunit/array-literal-feedback.js |
index 4769486403cc43c39b243b499c763eadaaed9578..8cc617e93f1df0bbe86b77becff1a614ad44903e 100644 |
--- a/test/mjsunit/regress/regress-crbug-245480.js |
+++ b/test/mjsunit/array-literal-feedback.js |
@@ -44,47 +44,32 @@ if (support_smi_only_arrays) { |
print("Tests do NOT include smi-only arrays."); |
} |
-function isHoley(obj) { |
- if (%HasFastHoleyElements(obj)) return true; |
- return false; |
-} |
- |
-function assertHoley(obj, name_opt) { |
- assertEquals(true, isHoley(obj), name_opt); |
-} |
- |
-function assertNotHoley(obj, name_opt) { |
- assertEquals(false, isHoley(obj), name_opt); |
-} |
- |
if (support_smi_only_arrays) { |
- function create_array(arg) { |
- return new Array(arg); |
+ |
+ function get_literal(x) { |
+ var literal = [1, 2, x]; |
+ return literal; |
} |
- obj = create_array(0); |
- assertNotHoley(obj); |
- create_array(0); |
- %OptimizeFunctionOnNextCall(create_array); |
- obj = create_array(10); |
- assertHoley(obj); |
-} |
+ get_literal(3); |
+ get_literal(3); |
+ %OptimizeFunctionOnNextCall(get_literal); |
+ a = get_literal(3); |
+ assertTrue(2 != %GetOptimizationStatus(get_literal)); |
+ assertTrue(%HasFastSmiElements(a)); |
+ a[0] = 3.5; |
-// The code below would assert in debug or crash in release |
-function f(length) { |
- return new Array(length) |
-} |
+ // We should have transitioned the boilerplate array to double, and |
+ // crankshafted code should de-opt on the unexpected elements kind |
+ b = get_literal(3); |
+ assertTrue(%HasFastDoubleElements(b)); |
+ assertEquals([1, 2, 3], b); |
+ assertTrue(1 != %GetOptimizationStatus(get_literal)); |
-f(0); |
-f(0); |
-%OptimizeFunctionOnNextCall(f); |
-var a = f(10); |
- |
-function g(a) { |
- return a[0]; |
+ // Optimize again |
+ get_literal(3); |
+ %OptimizeFunctionOnNextCall(get_literal); |
+ b = get_literal(3); |
+ assertTrue(%HasFastDoubleElements(b)); |
+ assertTrue(2 != %GetOptimizationStatus(get_literal)); |
} |
- |
-var b = [0]; |
-g(b); |
-g(b); |
-assertEquals(undefined, g(a)); |