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

Unified Diff: test/mjsunit/assert-opt-and-deopt.js

Issue 2654733004: [tests] Make assertOptimized()/assertUnoptimized() great again. (Closed)
Patch Set: Rebasing for relanding Created 3 years, 11 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/assert-opt-and-deopt.js
diff --git a/test/mjsunit/assert-opt-and-deopt.js b/test/mjsunit/assert-opt-and-deopt.js
index 19502f3354c5c5a2c85b1ca8cb93d64561693b31..c4f15cec0805b42c72085f3a0ff17455b290ce6b 100644
--- a/test/mjsunit/assert-opt-and-deopt.js
+++ b/test/mjsunit/assert-opt-and-deopt.js
@@ -44,18 +44,6 @@ function OptTracker() {
}
/**
- * 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
@@ -94,12 +82,10 @@ OptTracker.prototype.AssertIsOptimized = function(func, expect_optimized) {
if (this.DisableAsserts_(func)) {
return;
}
- var raw_optimized = %GetOptimizationStatus(func);
- if (expect_optimized) {
- assertEquals(OptTracker.OptimizationState.YES, raw_optimized);
- } else {
- assertEquals(OptTracker.OptimizationState.NO, raw_optimized);
- }
+ var opt_status = %GetOptimizationStatus(func);
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0);
+ assertEquals(expect_optimized,
+ (opt_status & V8OptimizationStatus.kOptimized) !== 0);
}
/**
@@ -119,7 +105,8 @@ OptTracker.prototype.GetOptCount_ = function(func) {
*/
OptTracker.prototype.GetDeoptCount_ = function(func) {
var count = this.GetOptCount_(func);
- if (%GetOptimizationStatus(func) == OptTracker.OptimizationState.YES) {
+ var opt_status = %GetOptimizationStatus(func);
+ if ((opt_status & V8OptimizationStatus.kOptimized) !== 0) {
count -= 1;
}
return count;
@@ -129,15 +116,9 @@ OptTracker.prototype.GetDeoptCount_ = function(func) {
* @private
*/
OptTracker.prototype.DisableAsserts_ = function(func) {
- 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;
+ var opt_status = %GetOptimizationStatus(func);
+ return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0 ||
+ (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0;
}
// (End of class OptTracker.)

Powered by Google App Engine
This is Rietveld 408576698