I've been diving into V8's JIT compiler and I'm curious about how it optimizes JavaScript functions. I understand that factors like function usage frequency and type stability play a role in optimization, but I'm wondering if there's a way to actually see which functions are being optimized or potentially de-optimized.
2 Answers
I heard that there are flags to check for inlined and not inlined functions in Node.js. Not too sure about the compiled functions though; maybe there are flags for functions that are just generally optimized?
Not exactly sure how granular you can get, but there are several `--v8` flags you can pass when running Node.js to get some insight into the optimization details. Check out the official Node.js docs for more on that.
Exactly! Using those flags can really help you understand what's happening under the hood.
Good to know! I found that using `--allow-natives-syntax` lets you access a ton of native V8 methods like `%GetOptimizationStatus(fn)` which can give you more info about how functions are optimized.