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

Side by Side Diff: test/mjsunit/mjsunit.js

Issue 2655223003: Revert of [tests] Make assertOptimized()/assertUnoptimized() great again. (Closed)
Patch Set: 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 unified diff | Download patch
« no previous file with comments | « test/mjsunit/keyed-load-with-symbol-key.js ('k') | test/mjsunit/never-optimize.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 // Only works with --allow-natives-syntax. 113 // Only works with --allow-natives-syntax.
114 var assertOptimized; 114 var assertOptimized;
115 var assertUnoptimized; 115 var assertUnoptimized;
116 116
117 // Assert that a string contains another expected substring. 117 // Assert that a string contains another expected substring.
118 var assertContains; 118 var assertContains;
119 119
120 // Assert that a string matches a given regex. 120 // Assert that a string matches a given regex.
121 var assertMatches; 121 var assertMatches;
122 122
123 // These bits must be in sync with bits defined in Runtime_GetOptimizationStatus
124 var V8OptimizationStatus = {
125 kIsFunction: 1 << 0,
126 kNeverOptimize: 1 << 1,
127 kAlwaysOptimize: 1 << 2,
128 kMaybeDeopted: 1 << 3,
129 kOptimized: 1 << 4,
130 kTurboFanned: 1 << 5,
131 kInterpreted: 1 << 6
132 };
133
134 // Returns true if --no-crankshaft mode is on.
135 var isNeverOptimize;
136
137 // Returns true if --always-opt mode is on.
138 var isAlwaysOptimize;
139
140 // Returns true if given function in interpreted.
141 var isInterpreted;
142
143 // Returns true if given function is compiled by a base-line compiler.
144 var isBaselined;
145
146 // Returns true if given function is optimized.
147 var isOptimized;
148
149 // Returns true if given function is compiled by Crankshaft.
150 var isCrankshafted;
151
152 // Returns true if given function is compiled by TurboFan.
153 var isTurboFanned;
154
155 123
156 (function () { // Scope for utility functions. 124 (function () { // Scope for utility functions.
157 125
158 var ObjectPrototypeToString = Object.prototype.toString; 126 var ObjectPrototypeToString = Object.prototype.toString;
159 var NumberPrototypeValueOf = Number.prototype.valueOf; 127 var NumberPrototypeValueOf = Number.prototype.valueOf;
160 var BooleanPrototypeValueOf = Boolean.prototype.valueOf; 128 var BooleanPrototypeValueOf = Boolean.prototype.valueOf;
161 var StringPrototypeValueOf = String.prototype.valueOf; 129 var StringPrototypeValueOf = String.prototype.valueOf;
162 var DatePrototypeValueOf = Date.prototype.valueOf; 130 var DatePrototypeValueOf = Date.prototype.valueOf;
163 var RegExpPrototypeToString = RegExp.prototype.toString; 131 var RegExpPrototypeToString = RegExp.prototype.toString;
164 var ArrayPrototypeMap = Array.prototype.map; 132 var ArrayPrototypeMap = Array.prototype.map;
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 "fun", "sync", "return %GetOptimizationStatus(fun, sync);"); 455 "fun", "sync", "return %GetOptimizationStatus(fun, sync);");
488 } catch (e) { 456 } catch (e) {
489 throw new Error("natives syntax not allowed"); 457 throw new Error("natives syntax not allowed");
490 } 458 }
491 } 459 }
492 return OptimizationStatusImpl(fun, sync_opt); 460 return OptimizationStatusImpl(fun, sync_opt);
493 } 461 }
494 462
495 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { 463 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) {
496 if (sync_opt === undefined) sync_opt = ""; 464 if (sync_opt === undefined) sync_opt = "";
497 var opt_status = OptimizationStatus(fun, sync_opt); 465 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt);
498 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
499 assertFalse((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt);
500 } 466 }
501 467
502 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { 468 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) {
503 if (sync_opt === undefined) sync_opt = ""; 469 if (sync_opt === undefined) sync_opt = "";
504 var opt_status = OptimizationStatus(fun, sync_opt); 470 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt);
505 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt);
506 if ((opt_status & V8OptimizationStatus.kNeverOptimize) !== 0) {
507 // TODO(ishell): every test that calls %OptimizeFunctionOnNextCall()
508 // does not make sense when --no-crankshaft option is provided.
509 return;
510 }
511 assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt);
512 }
513
514 isNeverOptimize = function isNeverOptimize() {
515 var opt_status = OptimizationStatus(undefined, "");
516 return (opt_status & V8OptimizationStatus.kNeverOptimize) !== 0;
517 }
518
519 isAlwaysOptimize = function isAlwaysOptimize() {
520 var opt_status = OptimizationStatus(undefined, "");
521 return (opt_status & V8OptimizationStatus.kAlwaysOptimize) !== 0;
522 }
523
524 isInterpreted = function isInterpreted(fun) {
525 var opt_status = OptimizationStatus(fun, "");
526 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
527 "not a function");
528 return (opt_status & V8OptimizationStatus.kOptimized) === 0 &&
529 (opt_status & V8OptimizationStatus.kInterpreted) !== 0;
530 }
531
532 // NOTE: This predicate also returns true for functions that have never
533 // been compiled (i.e. that have LazyCompile stub as a code).
534 isBaselined = function isBaselined(fun) {
535 var opt_status = OptimizationStatus(fun, "");
536 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
537 "not a function");
538 return (opt_status & V8OptimizationStatus.kOptimized) === 0 &&
539 (opt_status & V8OptimizationStatus.kInterpreted) === 0;
540 }
541
542 isOptimized = function isOptimized(fun) {
543 var opt_status = OptimizationStatus(fun, "");
544 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
545 "not a function");
546 return (opt_status & V8OptimizationStatus.kOptimized) !== 0;
547 }
548
549 isCrankshafted = function isCrankshafted(fun) {
550 var opt_status = OptimizationStatus(fun, "");
551 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
552 "not a function");
553 return (opt_status & V8OptimizationStatus.kOptimized) !== 0 &&
554 (opt_status & V8OptimizationStatus.kTurboFanned) === 0;
555 }
556
557 isTurboFanned = function isTurboFanned(fun) {
558 var opt_status = OptimizationStatus(fun, "");
559 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0,
560 "not a function");
561 return (opt_status & V8OptimizationStatus.kOptimized) !== 0 &&
562 (opt_status & V8OptimizationStatus.kTurboFanned) !== 0;
563 } 471 }
564 472
565 })(); 473 })();
OLDNEW
« no previous file with comments | « test/mjsunit/keyed-load-with-symbol-key.js ('k') | test/mjsunit/never-optimize.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698