Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1508)

Unified Diff: test/mjsunit/compiler/load-elimination-global.js

Issue 27148004: Implement global load elimination based on flow engine. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add a nested loop to the global load elimination test case. Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/hydrogen-load-elimination.cc ('k') | test/mjsunit/compiler/load-elimination-osr.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/compiler/load-elimination-global.js
diff --git a/test/mjsunit/compiler/load-elimination.js b/test/mjsunit/compiler/load-elimination-global.js
similarity index 62%
copy from test/mjsunit/compiler/load-elimination.js
copy to test/mjsunit/compiler/load-elimination-global.js
index e019508c65ebdc9eb08e03979f81b70633f55319..9caaa9f71874b9c8b8f48b3d60bb4bcf2c1bbf75 100644
--- a/test/mjsunit/compiler/load-elimination.js
+++ b/test/mjsunit/compiler/load-elimination-global.js
@@ -27,7 +27,12 @@
// Flags: --allow-natives-syntax --load-elimination
-// Test local load elimination of redundant loads and stores.
+// Test global load elimination of redundant loads and stores.
+
+var X = true; // For forcing branches.
+X = false;
+X = true;
+X = false;
function B(x, y) {
this.x = x;
@@ -37,33 +42,92 @@ function B(x, y) {
function test_load() {
var a = new B(1, 2);
- return a.x + a.x + a.x + a.x;
+ var f = a.x + a.x;
+ if (false) ;
+ return f + a.x + a.x;
+}
+
+function test_load2() {
+ var a = new B(1, 2);
+ var f = a.x + a.x;
+ if (true) ;
+ return f + a.x + a.x;
}
function test_store_load() {
var a = new B(1, 2);
a.x = 4;
- var f = a.x;
- a.x = 5;
- var g = a.x;
- a.x = 6;
- var h = a.x;
- a.x = 7;
- return f + g + h + a.x;
+ var b = X ? a.x : a.x;
+ return b + a.x;
+}
+
+function test_store_load2() {
+ var a = new B(1, 2);
+ var c = 6;
+ if (X) a.x = c;
+ else a.x = c;
+ return a.x + a.x;
}
function test_nonaliasing_store1() {
var a = new B(2, 3), b = new B(3, 4);
+ if (X) ;
b.x = 4;
+ if (X) ;
var f = a.x;
+ if (X) ;
b.x = 5;
+ if (X) ;
var g = a.x;
+ if (X) ;
b.x = 6;
+ if (X) ;
var h = a.x;
+ if (X) ;
b.x = 7;
+ if (X) ;
return f + g + h + a.x;
}
+function test_loop(x) {
+ var a = new B(2, 3);
+ var v = a.x;
+ var total = v;
+ var i = 0;
+ while (i++ < 10) {
+ total = a.x;
+ a.y = 4;
+ }
+ return total;
+}
+
+function test_loop2(x) {
+ var a = new B(2, 3);
+ var v = a.x;
+ var total = v;
+ var i = 0;
+ while (i++ < 10) {
+ total = a.x; // a.x not affected by loop
+ a.y = 4;
+
+ var j = 0;
+ while (j++ < 10) {
+ total = a.x; // a.x not affected by loop
+ a.y = 5;
+ }
+
+ total = a.x;
+ a.y = 6;
+
+ j = 0;
+ while (j++ < 10) {
+ total = a.x; // a.x not affected by loop
+ a.y = 7;
+ }
+ }
+ return total;
+}
+
function killall() {
try { } catch(e) { }
}
@@ -72,35 +136,61 @@ function killall() {
function test_store_load_kill() {
var a = new B(1, 2);
+ if (X) ;
a.x = 4;
+ if (X) ;
var f = a.x;
+ if (X) ;
a.x = 5;
+ if (X) ;
var g = a.x;
+ if (X) ;
killall();
+ if (X) ;
a.x = 6;
+ if (X) ;
var h = a.x;
+ if (X) ;
a.x = 7;
+ if (X) ;
return f + g + h + a.x;
}
function test_store_store() {
var a = new B(6, 7);
+ if (X) ;
a.x = 7;
+ if (X) ;
a.x = 7;
+ if (X) ;
a.x = 7;
+ if (X) ;
a.x = 7;
+ if (X) ;
return a.x;
}
function test(x, f) {
+ X = true;
+ assertEquals(x, f());
+ assertEquals(x, f());
+ X = false;
assertEquals(x, f());
assertEquals(x, f());
+ X = true;
%OptimizeFunctionOnNextCall(f);
assertEquals(x, f());
+ assertEquals(x, f());
+ X = false;
+ assertEquals(x, f());
+ assertEquals(x, f());
}
test(4, test_load);
-test(22, test_store_load);
+test(8, test_store_load);
+test(12, test_store_load2);
test(8, test_nonaliasing_store1);
test(22, test_store_load_kill);
test(7, test_store_store);
+test(2, test_loop);
+test(2, test_loop2);
« no previous file with comments | « src/hydrogen-load-elimination.cc ('k') | test/mjsunit/compiler/load-elimination-osr.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698