OLD | NEW |
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 Loading... |
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 }; |
123 | 133 |
124 (function () { // Scope for utility functions. | 134 (function () { // Scope for utility functions. |
125 | 135 |
126 var ObjectPrototypeToString = Object.prototype.toString; | 136 var ObjectPrototypeToString = Object.prototype.toString; |
127 var NumberPrototypeValueOf = Number.prototype.valueOf; | 137 var NumberPrototypeValueOf = Number.prototype.valueOf; |
128 var BooleanPrototypeValueOf = Boolean.prototype.valueOf; | 138 var BooleanPrototypeValueOf = Boolean.prototype.valueOf; |
129 var StringPrototypeValueOf = String.prototype.valueOf; | 139 var StringPrototypeValueOf = String.prototype.valueOf; |
130 var DatePrototypeValueOf = Date.prototype.valueOf; | 140 var DatePrototypeValueOf = Date.prototype.valueOf; |
131 var RegExpPrototypeToString = RegExp.prototype.toString; | 141 var RegExpPrototypeToString = RegExp.prototype.toString; |
132 var ArrayPrototypeMap = Array.prototype.map; | 142 var ArrayPrototypeMap = Array.prototype.map; |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
455 "fun", "sync", "return %GetOptimizationStatus(fun, sync);"); | 465 "fun", "sync", "return %GetOptimizationStatus(fun, sync);"); |
456 } catch (e) { | 466 } catch (e) { |
457 throw new Error("natives syntax not allowed"); | 467 throw new Error("natives syntax not allowed"); |
458 } | 468 } |
459 } | 469 } |
460 return OptimizationStatusImpl(fun, sync_opt); | 470 return OptimizationStatusImpl(fun, sync_opt); |
461 } | 471 } |
462 | 472 |
463 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { | 473 assertUnoptimized = function assertUnoptimized(fun, sync_opt, name_opt) { |
464 if (sync_opt === undefined) sync_opt = ""; | 474 if (sync_opt === undefined) sync_opt = ""; |
465 assertTrue(OptimizationStatus(fun, sync_opt) !== 1, name_opt); | 475 var opt_status = OptimizationStatus(fun, sync_opt); |
| 476 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt); |
| 477 assertFalse((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); |
466 } | 478 } |
467 | 479 |
468 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { | 480 assertOptimized = function assertOptimized(fun, sync_opt, name_opt) { |
469 if (sync_opt === undefined) sync_opt = ""; | 481 if (sync_opt === undefined) sync_opt = ""; |
470 assertTrue(OptimizationStatus(fun, sync_opt) !== 2, name_opt); | 482 var opt_status = OptimizationStatus(fun, sync_opt); |
| 483 assertTrue((opt_status & V8OptimizationStatus.kIsFunction) !== 0, name_opt); |
| 484 assertTrue((opt_status & V8OptimizationStatus.kOptimized) !== 0, name_opt); |
471 } | 485 } |
472 | 486 |
473 })(); | 487 })(); |
OLD | NEW |