Index: test/mjsunit/mjsunit.js |
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js |
index 25d7c004326ce3df03ebe83edb2f0becd5336bba..83449cc1e692e8d0754e49ac8d4122ea39662186 100644 |
--- a/test/mjsunit/mjsunit.js |
+++ b/test/mjsunit/mjsunit.js |
@@ -99,6 +99,14 @@ var assertInstanceof; |
// Assert that this code is never executed (i.e., always fails if executed). |
var assertUnreachable; |
+// Assert that the function code is (not) optimized. If "no sync" is passed |
+// as second argument, we do not wait for the parallel optimization thread to |
+// finish when polling for optimization status. |
+// Only works with --allow-natives-syntax. |
+var assertOptimized; |
+var assertUnoptimized; |
+ |
+ |
(function () { // Scope for utility functions. |
function classOf(object) { |
@@ -353,5 +361,26 @@ var assertUnreachable; |
throw new MjsUnitAssertionError(message); |
}; |
+ |
+ var OptimizationStatus; |
+ try { |
+ OptimizationStatus = |
+ new Function("fun", "sync", "return %GetOptimizationStatus(fun, sync);"); |
+ } catch (e) { |
+ OptimizationStatus = function() { |
+ throw new Error("natives syntax not allowed"); |
+ } |
+ } |
+ |
+ assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { |
+ if (sync_opt === undefined) sync_opt = ""; |
+ assertTrue(OptimizationStatus(fun, sync_opt) != 1, name_opt); |
+ } |
+ |
+ assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
+ if (sync_opt === undefined) sync_opt = ""; |
+ assertTrue(OptimizationStatus(fun, sync_opt) != 2, name_opt); |
+ } |
+ |
})(); |