Index: test/mjsunit/assert-opt-and-deopt.js |
diff --git a/test/mjsunit/assert-opt-and-deopt.js b/test/mjsunit/assert-opt-and-deopt.js |
index c4f15cec0805b42c72085f3a0ff17455b290ce6b..19502f3354c5c5a2c85b1ca8cb93d64561693b31 100644 |
--- a/test/mjsunit/assert-opt-and-deopt.js |
+++ b/test/mjsunit/assert-opt-and-deopt.js |
@@ -44,6 +44,18 @@ |
} |
/** |
+ * The possible optimization states of a function. Must be in sync with the |
+ * return values of Runtime_GetOptimizationStatus() in runtime.cc! |
+ * @enum {int} |
+ */ |
+OptTracker.OptimizationState = { |
+ YES: 1, |
+ NO: 2, |
+ ALWAYS: 3, |
+ NEVER: 4 |
+}; |
+ |
+/** |
* Always call this at the beginning of your test, once for each function |
* that you later want to track de/optimizations for. It is necessary because |
* tests are sometimes executed several times in a row, and you want to |
@@ -82,10 +94,12 @@ |
if (this.DisableAsserts_(func)) { |
return; |
} |
- var opt_status = %GetOptimizationStatus(func); |
- assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0); |
- assertEquals(expect_optimized, |
- (opt_status & V8OptimizationStatus.kOptimized) !== 0); |
+ var raw_optimized = %GetOptimizationStatus(func); |
+ if (expect_optimized) { |
+ assertEquals(OptTracker.OptimizationState.YES, raw_optimized); |
+ } else { |
+ assertEquals(OptTracker.OptimizationState.NO, raw_optimized); |
+ } |
} |
/** |
@@ -105,8 +119,7 @@ |
*/ |
OptTracker.prototype.GetDeoptCount_ = function(func) { |
var count = this.GetOptCount_(func); |
- var opt_status = %GetOptimizationStatus(func); |
- if ((opt_status & V8OptimizationStatus.kOptimized) !== 0) { |
+ if (%GetOptimizationStatus(func) == OptTracker.OptimizationState.YES) { |
count -= 1; |
} |
return count; |
@@ -116,9 +129,15 @@ |
* @private |
*/ |
OptTracker.prototype.DisableAsserts_ = function(func) { |
- var opt_status = %GetOptimizationStatus(func); |
- return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0 || |
- (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0; |
+ switch(%GetOptimizationStatus(func)) { |
+ case OptTracker.OptimizationState.YES: |
+ case OptTracker.OptimizationState.NO: |
+ return false; |
+ case OptTracker.OptimizationState.ALWAYS: |
+ case OptTracker.OptimizationState.NEVER: |
+ return true; |
+ } |
+ return true; |
} |
// (End of class OptTracker.) |