Clean up mjsunit/array-bounds-check-removal

Review URL: https://codereview.chromium.org/12317142

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@13750 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 6f8f8223
...@@ -52,13 +52,13 @@ test_do_not_assert_on_non_int32(v,"a"); ...@@ -52,13 +52,13 @@ test_do_not_assert_on_non_int32(v,"a");
%OptimizeFunctionOnNextCall(test_do_not_assert_on_non_int32); %OptimizeFunctionOnNextCall(test_do_not_assert_on_non_int32);
test_do_not_assert_on_non_int32(v,0); 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 + 1] = 1;
a[base + 4] = 2; a[base + 4] = 2;
a[base + 3] = 3; a[base + 3] = 3;
a[base + 2] = 4; a[base + 2] = 4;
a[base + 4] = base + 4; a[base + 4] = base + 4;
if (cond) { if (condition) {
a[base + 1] = 1; a[base + 1] = 1;
a[base + 2] = 2; a[base + 2] = 2;
a[base + 2] = 3; a[base + 2] = 3;
...@@ -73,8 +73,8 @@ function test_base(base,cond) { ...@@ -73,8 +73,8 @@ function test_base(base,cond) {
} }
} }
function check_test_base(base,cond) { function check_test_base(a, base, condition) {
if (cond) { if (condition) {
assertEquals(1, a[base + 1]); assertEquals(1, a[base + 1]);
assertEquals(4, a[base + 2]); assertEquals(4, a[base + 2]);
assertEquals(base + 4, a[base + 4]); assertEquals(base + 4, a[base + 4]);
...@@ -87,6 +87,37 @@ function check_test_base(base,cond) { ...@@ -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) { function test_minus(base,cond) {
a[base - 1] = 1; a[base - 1] = 1;
a[base - 2] = 2; a[base - 2] = 2;
...@@ -122,16 +153,6 @@ function check_test_minus(base,cond) { ...@@ -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(5,true);
test_minus(6,true); test_minus(6,true);
%OptimizeFunctionOnNextCall(test_minus); %OptimizeFunctionOnNextCall(test_minus);
...@@ -140,30 +161,7 @@ check_test_minus(7,true); ...@@ -140,30 +161,7 @@ check_test_minus(7,true);
test_minus(7,false); test_minus(7,false);
check_test_minus(7,false); check_test_minus(7,false);
// Optimization status: // Specific test on negative offsets.
// 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
var short_a = new Array(100); var short_a = new Array(100);
for (var i = 0; i < short_a.length; i++) short_a[i] = 0; for (var i = 0; i < short_a.length; i++) short_a[i] = 0;
function short_test(a, i) { function short_test(a, i) {
...@@ -174,7 +172,7 @@ short_test(short_a, 50); ...@@ -174,7 +172,7 @@ short_test(short_a, 50);
short_test(short_a, 50); short_test(short_a, 50);
%OptimizeFunctionOnNextCall(short_test); %OptimizeFunctionOnNextCall(short_test);
short_a.length = 10; short_a.length = 10;
short_test(a, 0); short_test(short_a, 0);
assertTrue(%GetOptimizationStatus(short_test) != 1); assertTrue(%GetOptimizationStatus(short_test) != 1);
...@@ -203,4 +201,3 @@ assertEquals(12, result_phi); ...@@ -203,4 +201,3 @@ assertEquals(12, result_phi);
gc(); gc();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment