attempts to determine future runtime characteristics. For example, if a function is executing several thousand times with the same arguments, it is optimized.
prevents a different call signature, variable type, object definition, from appearing in the future. The compiler tries to find hot functions it can make assumptions about.
quickly, but what if we’re wrong? If V8 turns out to be wrong about the future, it must de-optimize a previously optimized function. Too many deoptimizations on a function? V8 stops trying — deoptimization hell
objects. - Try to not add properties after object creation - Try not to delete properties - Try to add properties in the same order. This allows V8 to share maps
} // Make first pass to gather type information square(3); // Ask that the next call of #square trigger an optimization attempt; %OptimizeFunctionOnNextCall(square); // Call again... square(3);