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

Unified Diff: test/mjsunit/never-optimize.js

Issue 18214005: Added %NeverOptimize runtime call that can disable optimizations for a method for tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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
Index: test/mjsunit/never-optimize.js
diff --git a/test/mjsunit/regress/regress-int32-truncation.js b/test/mjsunit/never-optimize.js
similarity index 68%
copy from test/mjsunit/regress/regress-int32-truncation.js
copy to test/mjsunit/never-optimize.js
index dec4ac1195a6c4928d84eac8cc8dc9496bf66600..30fc220930765aeaff1e2df9f49e5e6997e95364 100644
--- a/test/mjsunit/regress/regress-int32-truncation.js
+++ b/test/mjsunit/never-optimize.js
@@ -27,35 +27,42 @@
// 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 o1() {
}
-f(1, false);
-f(1, true);
-%OptimizeFunctionOnNextCall(f);
-assertEquals((1 << 30) * 2, f(30, true));
+if (%GetOptimizationStatus(o1) != 4) {
+ // 4 == optimization disabled.
+ o1(); o1();
+ %OptimizeFunctionOnNextCall(o1);
+ o1();
+ // check that the given function was optimized.
+ var o1_status = %GetOptimizationStatus(o1);
+ assertTrue(o1_status == 1 // optimized
+ || o1_status == 3 // optimized (always opt)
+ || o1_status == 5); // lazy recompile requested
-var global = 1;
+ // Test the %NeverOptimize runtime call.
+ function u1() {
+ %NeverOptimize();
+ }
-function f2(b) {
- var a = 0;
- if (b) {
- a = global;
+ function u2() {
}
- var x = a >> 3;
- return a;
-}
-f2(false);
-f2(true);
-%OptimizeFunctionOnNextCall(f2);
-global = 2.5;
-assertEquals(global, f2(true));
+ u1(); u1();
+ u2(); u2();
+
+ %NeverOptimize(u2);
+
+ %OptimizeFunctionOnNextCall(u1);
+ %OptimizeFunctionOnNextCall(u2);
+
+ u1(); u1();
+ u2(); u2();
+
+ // 2 => not optimized.
+ assertEquals(2, %GetOptimizationStatus(u1));
+ assertEquals(2, %GetOptimizationStatus(u2));
+
+}

Powered by Google App Engine
This is Rietveld 408576698