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

Unified Diff: test/mjsunit/compiler/store-elimination.js

Issue 100253004: First implementation of store elimination. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 7 years 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
Index: test/mjsunit/compiler/store-elimination.js
diff --git a/test/mjsunit/compiler/load-elimination.js b/test/mjsunit/compiler/store-elimination.js
similarity index 70%
copy from test/mjsunit/compiler/load-elimination.js
copy to test/mjsunit/compiler/store-elimination.js
index e019508c65ebdc9eb08e03979f81b70633f55319..1806ed963f360192684886edc818ed44963f2198 100644
--- a/test/mjsunit/compiler/load-elimination.js
+++ b/test/mjsunit/compiler/store-elimination.js
@@ -25,9 +25,9 @@
// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-// Flags: --allow-natives-syntax --load-elimination
+// Flags: --allow-natives-syntax --store-elimination
-// Test local load elimination of redundant loads and stores.
+// Test local elimination of unobservable stores.
function B(x, y) {
this.x = x;
@@ -35,63 +35,51 @@ function B(x, y) {
return this;
}
-function test_load() {
+function test_store_store() {
var a = new B(1, 2);
- return a.x + a.x + a.x + a.x;
+ a.x = 3; // eliminatable.
+ a.x = 4;
+ return a.x;
}
-function test_store_load() {
- var a = new B(1, 2);
+function test_store_load_store1() {
+ var a = new B(6, 7);
+ a.x = 3; // eliminatable.
+ var r = a.y;
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;
+ return r;
}
-function test_nonaliasing_store1() {
- var a = new B(2, 3), b = new B(3, 4);
- b.x = 4;
- var f = a.x;
- b.x = 5;
- var g = a.x;
- b.x = 6;
- var h = a.x;
- b.x = 7;
- return f + g + h + a.x;
+function test_store_load_store2() {
+ var a = new B(6, 8);
+ a.x = 3; // not eliminatable, unless next load is eliminated.
+ var r = a.x;
+ a.x = 4;
+ return r;
}
-function killall() {
- try { } catch(e) { }
+function test_store_call_store() {
+ var a = new B(2, 9);
+ a.x = 3; // not eliminatable.
+ killall();
+ a.x = 4;
+ return a.y;
}
-%NeverOptimizeFunction(killall);
-
-function test_store_load_kill() {
- var a = new B(1, 2);
+function test_store_deopt_store() {
+ var a = new B(2, 1);
+ a.x = 3; // not eliminatable (implicit ValueOf following)
+ var c = a + 2;
a.x = 4;
- var f = a.x;
- a.x = 5;
- var g = a.x;
- killall();
- a.x = 6;
- var h = a.x;
- a.x = 7;
- return f + g + h + a.x;
+ return a.y;
}
-function test_store_store() {
- var a = new B(6, 7);
- a.x = 7;
- a.x = 7;
- a.x = 7;
- a.x = 7;
- return a.x;
+function killall() {
+ try { } catch(e) { }
}
+%NeverOptimizeFunction(killall);
+
function test(x, f) {
assertEquals(x, f());
assertEquals(x, f());
@@ -99,8 +87,8 @@ function test(x, f) {
assertEquals(x, f());
}
-test(4, test_load);
-test(22, test_store_load);
-test(8, test_nonaliasing_store1);
-test(22, test_store_load_kill);
-test(7, test_store_store);
+test(4, test_store_store);
+test(7, test_store_load_store1);
+test(3, test_store_load_store2);
+test(9, test_store_call_store);
+test(1, test_store_deopt_store);

Powered by Google App Engine
This is Rietveld 408576698