Index: test/mjsunit/array-bounds-check-removal.js |
diff --git a/test/mjsunit/array-bounds-check-removal.js b/test/mjsunit/array-bounds-check-removal.js |
index 7a7cb304def2d79879770cb2f27232f08406d94f..10e11f09c224324316a96f831ebbba0d263fee94 100644 |
--- a/test/mjsunit/array-bounds-check-removal.js |
+++ b/test/mjsunit/array-bounds-check-removal.js |
@@ -52,13 +52,13 @@ test_do_not_assert_on_non_int32(v,"a"); |
%OptimizeFunctionOnNextCall(test_do_not_assert_on_non_int32); |
test_do_not_assert_on_non_int32(v,0); |
-function test_base(base,cond) { |
+function test_base(a, base, condition) { |
a[base + 1] = 1; |
a[base + 4] = 2; |
a[base + 3] = 3; |
a[base + 2] = 4; |
a[base + 4] = base + 4; |
- if (cond) { |
+ if (condition) { |
a[base + 1] = 1; |
a[base + 2] = 2; |
a[base + 2] = 3; |
@@ -73,8 +73,8 @@ function test_base(base,cond) { |
} |
} |
-function check_test_base(base,cond) { |
- if (cond) { |
+function check_test_base(a, base, condition) { |
+ if (condition) { |
assertEquals(1, a[base + 1]); |
assertEquals(4, a[base + 2]); |
assertEquals(base + 4, a[base + 4]); |
@@ -87,6 +87,37 @@ function check_test_base(base,cond) { |
} |
+test_base(a, 1, true); |
+test_base(a, 2, true); |
+test_base(a, 1, false); |
+test_base(a, 2, false); |
+%OptimizeFunctionOnNextCall(test_base); |
+test_base(a, 3, true); |
+check_test_base(a, 3, true); |
+test_base(a, 3, false); |
+check_test_base(a, 3, false); |
+ |
+// Test that we deopt on failed bounds checks. |
+var dictionary_map_array = new Int32Array(128); |
+test_base(dictionary_map_array, 5, true); |
+test_base(dictionary_map_array, 6, true); |
+test_base(dictionary_map_array, 5, false); |
+test_base(dictionary_map_array, 6, false); |
+%OptimizeFunctionOnNextCall(test_base); |
+test_base(dictionary_map_array, -2, true); |
+assertTrue(%GetOptimizationStatus(test_base) != 1); |
+ |
+// Forget about the dictionary_map_array's map. |
+%ClearFunctionTypeFeedback(test_base); |
+ |
+test_base(a, 5, true); |
+test_base(a, 6, true); |
+test_base(a, 5, false); |
+test_base(a, 6, false); |
+%OptimizeFunctionOnNextCall(test_base); |
+test_base(a, 2048, true); |
+assertTrue(%GetOptimizationStatus(test_base) != 1); |
+ |
function test_minus(base,cond) { |
a[base - 1] = 1; |
a[base - 2] = 2; |
@@ -122,16 +153,6 @@ function check_test_minus(base,cond) { |
} |
} |
-test_base(1,true); |
-test_base(2,true); |
-test_base(1,false); |
-test_base(2,false); |
-%OptimizeFunctionOnNextCall(test_base); |
-test_base(3,true); |
-check_test_base(3,true); |
-test_base(3,false); |
-check_test_base(3,false); |
- |
test_minus(5,true); |
test_minus(6,true); |
%OptimizeFunctionOnNextCall(test_minus); |
@@ -140,30 +161,7 @@ check_test_minus(7,true); |
test_minus(7,false); |
check_test_minus(7,false); |
-// Optimization status: |
-// YES: 1 |
-// NO: 2 |
-// ALWAYS: 3 |
-// NEVER: 4 |
- |
-// Test that we still deopt on failed bound checks |
-test_base(5,true); |
-test_base(6,true); |
-test_base(5,false); |
-test_base(6,false); |
-%OptimizeFunctionOnNextCall(test_base); |
-test_base(-2,true); |
-assertTrue(%GetOptimizationStatus(test_base) != 1); |
- |
-test_base(5,true); |
-test_base(6,true); |
-test_base(5,false); |
-test_base(6,false); |
-%OptimizeFunctionOnNextCall(test_base); |
-test_base(2048,true); |
-assertTrue(%GetOptimizationStatus(test_base) != 1); |
- |
-// Specific test on negative offsets |
+// Specific test on negative offsets. |
var short_a = new Array(100); |
for (var i = 0; i < short_a.length; i++) short_a[i] = 0; |
function short_test(a, i) { |
@@ -174,7 +172,7 @@ short_test(short_a, 50); |
short_test(short_a, 50); |
%OptimizeFunctionOnNextCall(short_test); |
short_a.length = 10; |
-short_test(a, 0); |
+short_test(short_a, 0); |
assertTrue(%GetOptimizationStatus(short_test) != 1); |
@@ -203,4 +201,3 @@ assertEquals(12, result_phi); |
gc(); |
- |