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

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: Addressed review comments. Created 6 years, 11 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
Index: test/mjsunit/compiler/store-elimination.js
diff --git a/test/mjsunit/compiler/load-elimination-params.js b/test/mjsunit/compiler/store-elimination.js
similarity index 59%
copy from test/mjsunit/compiler/load-elimination-params.js
copy to test/mjsunit/compiler/store-elimination.js
index 13a4a8596d6061226b631816ca2e9fff461a015a..1806ed963f360192684886edc818ed44963f2198 100644
--- a/test/mjsunit/compiler/load-elimination-params.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,37 +35,60 @@ function B(x, y) {
return this;
}
-function test_params1(a, b) {
- var i = a.x;
- var j = a.x;
- var k = b.x;
- var l = b.x;
- return i + j + k + l;
+function test_store_store() {
+ var a = new B(1, 2);
+ a.x = 3; // eliminatable.
+ a.x = 4;
+ return a.x;
}
-assertEquals(14, test_params1(new B(3, 4), new B(4, 5)));
-assertEquals(110, test_params1(new B(11, 7), new B(44, 8)));
+function test_store_load_store1() {
+ var a = new B(6, 7);
+ a.x = 3; // eliminatable.
+ var r = a.y;
+ a.x = 4;
+ return r;
+}
+
+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;
+}
-%OptimizeFunctionOnNextCall(test_params1);
+function test_store_call_store() {
+ var a = new B(2, 9);
+ a.x = 3; // not eliminatable.
+ killall();
+ a.x = 4;
+ return a.y;
+}
-assertEquals(6, test_params1(new B(1, 7), new B(2, 8)));
+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;
+ return a.y;
+}
-function test_params2(a, b) {
- var o = new B(a + 1, b);
- o.x = a;
- var i = o.x;
- o.x = a;
- var j = o.x;
- o.x = b;
- var k = o.x;
- o.x = b;
- var l = o.x;
- return i + j + k + l;
+function killall() {
+ try { } catch(e) { }
}
-assertEquals(14, test_params2(3, 4));
-assertEquals(110, test_params2(11, 44));
+%NeverOptimizeFunction(killall);
-%OptimizeFunctionOnNextCall(test_params2);
+function test(x, f) {
+ assertEquals(x, f());
+ assertEquals(x, f());
+ %OptimizeFunctionOnNextCall(f);
+ assertEquals(x, f());
+}
-assertEquals(6, test_params2(1, 2));
+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