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

Unified Diff: test/mjsunit/mjsunit.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
« no previous file with comments | « test/mjsunit/es6/array-iterator-turbo.js ('k') | test/mjsunit/regress/regress-2132.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/mjsunit/mjsunit.js
diff --git a/test/mjsunit/mjsunit.js b/test/mjsunit/mjsunit.js
index 88d4d3677c4edc84fc2e9128737083cb246a64bb..ad8c511bc85fdcd6770360b886e7dfd2c7e1e243 100644
--- a/test/mjsunit/mjsunit.js
+++ b/test/mjsunit/mjsunit.js
@@ -120,6 +120,38 @@ var assertContains;
// Assert that a string matches a given regex.
var assertMatches;
+// These bits must be in sync with bits defined in Runtime_GetOptimizationStatus
+var V8OptimizationStatus = {
+ kIsFunction: 1 << 0,
+ kNeverOptimize: 1 << 1,
+ kAlwaysOptimize: 1 << 2,
+ kMaybeDeopted: 1 << 3,
+ kOptimized: 1 << 4,
+ kTurboFanned: 1 << 5,
+ kInterpreted: 1 << 6
+};
+
+// Returns true if --no-crankshaft mode is on.
+var isNeverOptimize;
+
+// Returns true if --always-opt mode is on.
+var isAlwaysOptimize;
+
+// Returns true if given function in interpreted.
+var isInterpreted;
+
+// Returns true if given function is compiled by a base-line compiler.
+var isBaselined;
+
+// Returns true if given function is optimized.
+var isOptimized;
+
+// Returns true if given function is compiled by Crankshaft.
+var isCrankshafted;
+
+// Returns true if given function is compiled by TurboFan.
+var isTurboFanned;
+
(function () { // Scope for utility functions.
@@ -462,12 +494,81 @@ var assertMatches;
assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
- assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt);
+ var opt_status = OptimizationStatus(fun, sync_opt);
+ // Tests that use assertOptimized() do not make sense if --always-opt
+ // option is provided. Such tests must add --no-always-opt to flags comment.
+ assertFalse((opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0,
+ "test does not make sense with --always-opt");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
+ assertFalse((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt);
}
assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
if (sync_opt === undefined) sync_opt = "";
- assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt);
+ var opt_status = OptimizationStatus(fun, sync_opt);
+ // Tests that use assertOptimized() do not make sense if --no-crankshaft
+ // option is provided. Such tests must add --crankshaft to flags comment.
+ assertFalse((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0,
+ "test does not make sense with --no-crankshaft");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
+ if ((opt_status & V8OptimizationStatus.kMaybeDeopted) !== 0) {
Igor Sheludko 2017/01/27 09:33:06 This case is new.
Michael Starzinger 2017/01/27 10:10:24 Acknowledged.
+ // When --deopt-every-n-times flag is specified it's no longer guaranteed
+ // that particular function is still optimized, so keep running the test
+ // to stress test the deoptimizer.
+ return;
+ }
+ assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt);
+ }
+
+ isNeverOptimize = function isNeverOptimize() {
+ var opt_status = OptimizationStatus(undefined, "");
+ return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0;
+ }
+
+ isAlwaysOptimize = function isAlwaysOptimize() {
+ var opt_status = OptimizationStatus(undefined, "");
+ return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0;
+ }
+
+ isInterpreted = function isInterpreted(fun) {
+ var opt_status = OptimizationStatus(fun, "");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
+ "not a function");
+ return (opt_status & V8OptimizationStatus.kOptimized) === 0 &&
+ (opt_status & V8OptimizationStatus.kInterpreted) !== 0;
+ }
+
+ // NOTE: This predicate also returns true for functions that have never
+ // been compiled (i.e. that have LazyCompile stub as a code).
+ isBaselined = function isBaselined(fun) {
+ var opt_status = OptimizationStatus(fun, "");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
+ "not a function");
+ return (opt_status & V8OptimizationStatus.kOptimized) === 0 &&
+ (opt_status & V8OptimizationStatus.kInterpreted) === 0;
+ }
+
+ isOptimized = function isOptimized(fun) {
+ var opt_status = OptimizationStatus(fun, "");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
+ "not a function");
+ return (opt_status & V8OptimizationStatus.kOptimized) !== 0;
+ }
+
+ isCrankshafted = function isCrankshafted(fun) {
+ var opt_status = OptimizationStatus(fun, "");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
+ "not a function");
+ return (opt_status & V8OptimizationStatus.kOptimized) !== 0 &&
+ (opt_status & V8OptimizationStatus.kTurboFanned) === 0;
+ }
+
+ isTurboFanned = function isTurboFanned(fun) {
+ var opt_status = OptimizationStatus(fun, "");
+ assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
+ "not a function");
+ return (opt_status & V8OptimizationStatus.kOptimized) !== 0 &&
+ (opt_status & V8OptimizationStatus.kTurboFanned) !== 0;
}
})();
« no previous file with comments | « test/mjsunit/es6/array-iterator-turbo.js ('k') | test/mjsunit/regress/regress-2132.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698