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

Unified Diff: test/mjsunit/unary-minus-deopt.js

Issue 21782002: Replaced unary negation by multiplication with -1. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: rebased Created 7 years, 5 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/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/unary-minus-deopt.js
diff --git a/test/mjsunit/omit-constant-mapcheck.js b/test/mjsunit/unary-minus-deopt.js
similarity index 67%
copy from test/mjsunit/omit-constant-mapcheck.js
copy to test/mjsunit/unary-minus-deopt.js
index ae6308f215e40ae22b9e9328c5f4e4ec3d0f3843..367ef75c8363af02b9446e4860022d12b8039e54 100644
--- a/test/mjsunit/omit-constant-mapcheck.js
+++ b/test/mjsunit/unary-minus-deopt.js
@@ -27,44 +27,29 @@
// Flags: --allow-natives-syntax
-var g1 = { a:1 }
-
-function load() {
- return g1.a;
-}
-
-assertEquals(1, load());
-assertEquals(1, load());
-%OptimizeFunctionOnNextCall(load);
-assertEquals(1, load());
-delete g1.a;
-assertEquals(undefined, load());
-
-var g2 = { a:2 }
-
-function load2() {
- return g2.a;
-}
-
-assertEquals(2, load2());
-assertEquals(2, load2());
-%OptimizeFunctionOnNextCall(load2);
-assertEquals(2, load2());
-g2.b = 10;
-g2.a = 5;
-assertEquals(5, load2());
-
-var g3 = { a:2, b:9, c:1 }
-
-function store(v) {
- g3.a = v;
- return g3.a;
+// This is a boiled-down example happening in the Epic Citadel demo:
+// After deopting, the multiplication for unary minus stayed in Smi
+// mode instead of going to double mode, leading to deopt loops.
+
+function unaryMinusTest(x) {
+ var g = (1 << x) | 0;
+ // Optimized code will contain a LMulI with -1 as right operand.
+ return (g & -g) - 1 | 0;
}
-assertEquals(5, store(5));
-assertEquals(8, store(8));
-%OptimizeFunctionOnNextCall(store);
-assertEquals(10, store(10));
-delete g3.c;
-store(7);
-assertEquals({a:7, b:9}, g3);
+unaryMinusTest(3);
+unaryMinusTest(3);
+%OptimizeFunctionOnNextCall(unaryMinusTest);
+unaryMinusTest(3);
+assertOptimized(unaryMinusTest);
+
+// Deopt on kMinInt
+unaryMinusTest(31);
+// The following is normally true, but not with --stress-opt. :-/
+// assertUnoptimized(unaryMinusTest);
+
+// We should have learned something from the deopt.
+unaryMinusTest(31);
+%OptimizeFunctionOnNextCall(unaryMinusTest);
+unaryMinusTest(31);
+assertOptimized(unaryMinusTest);
« no previous file with comments | « src/x64/full-codegen-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698