Created
September 23, 2019 16:13
-
-
Save shqld/6268496ffeed619961444518f8ad17b9 to your computer and use it in GitHub Desktop.
Get V8 optimization status
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/v8/v8/blob/master/test/mjsunit/mjsunit.js#L162-L178 | |
const statuses = { | |
IsFunction: 1 << 0, | |
NeverOptimize: 1 << 1, | |
AlwaysOptimize: 1 << 2, | |
MaybeDeopted: 1 << 3, | |
Optimized: 1 << 4, | |
TurboFanned: 1 << 5, | |
Interpreted: 1 << 6, | |
MarkedForOptimization: 1 << 7, | |
MarkedForConcurrentOptimization: 1 << 8, | |
OptimizingConcurrently: 1 << 9, | |
IsExecuting: 1 << 10, | |
TopmostFrameIsTurboFanned: 1 << 11, | |
LiteMode: 1 << 12, | |
MarkedForDeoptimization: 1 << 13, | |
} | |
const getStatus = (fn) => { | |
const status = %GetOptimizationStatus(fn) | |
return Object.entries(statuses).filter(([, value]) => status & value).map(([key]) => key) | |
} | |
const printStatus = (fn) => console.log(fn.name + ':', getStatus(fn).join(', ')) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment