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

Unified Diff: test/mjsunit/regress/regress-smi-math-floor-round.js

Issue 22623007: Fix smi-based math floor. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Better field names Created 7 years, 4 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-instructions.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/regress/regress-smi-math-floor-round.js
diff --git a/test/mjsunit/regress/regress-int32-truncation.js b/test/mjsunit/regress/regress-smi-math-floor-round.js
similarity index 72%
copy from test/mjsunit/regress/regress-int32-truncation.js
copy to test/mjsunit/regress/regress-smi-math-floor-round.js
index dec4ac1195a6c4928d84eac8cc8dc9496bf66600..7c033a3bd05b7561d9cdff8e24be8358d648341d 100644
--- a/test/mjsunit/regress/regress-int32-truncation.js
+++ b/test/mjsunit/regress/regress-smi-math-floor-round.js
@@ -27,35 +27,41 @@
// Flags: --allow-natives-syntax
-function f(i, b) {
- var a = 0;
- if (b) {
- var c = 1 << i;
- a = c + c;
- }
- var x = a >> 3;
- return a;
+
+function f(o) {
+ return Math.floor(o.x_smi) + 1;
}
-f(1, false);
-f(1, true);
+assertEquals(2, f({x_smi:1}));
+assertEquals(2, f({x_smi:1}));
%OptimizeFunctionOnNextCall(f);
-assertEquals((1 << 30) * 2, f(30, true));
+assertEquals(2, f({x_smi:1}));
+function f2(o) {
+ return Math.floor(o.x_tagged) + 1;
+}
-var global = 1;
+var o = {x_tagged:{}};
+o.x_tagged = 1.4;
+assertEquals(2, f2(o));
+assertEquals(2, f2(o));
+%OptimizeFunctionOnNextCall(f2);
+assertEquals(2, f2(o));
-function f2(b) {
- var a = 0;
- if (b) {
- a = global;
- }
- var x = a >> 3;
- return a;
+function f3(o) {
+ return Math.round(o.x_smi) + 1;
}
-f2(false);
-f2(true);
-%OptimizeFunctionOnNextCall(f2);
-global = 2.5;
-assertEquals(global, f2(true));
+assertEquals(2, f3({x_smi:1}));
+assertEquals(2, f3({x_smi:1}));
+%OptimizeFunctionOnNextCall(f3);
+assertEquals(2, f3({x_smi:1}));
+
+function f4(o) {
+ return Math.round(o.x_tagged) + 1;
+}
+
+assertEquals(2, f4(o));
+assertEquals(2, f4(o));
+%OptimizeFunctionOnNextCall(f4);
+assertEquals(2, f4(o));
« no previous file with comments | « src/hydrogen-instructions.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698