3 ms·
Wow, the function overwriting trick is really great. WebKit is likely to inline the no-op function in the third and fourth optimizing tiers, so if the rare thi
by pizlonator 10y ago
Wow, the function overwriting trick is really great. WebKit is likely to inline the no-op function in the third and fourth optimizing tiers, so if the rare thing does not happen, the no-op hook call is basically free. Cool!
I wasn't aware that function object allocation was such a big deal. It's a big deal if the function is used as a constructor, but other than that, function objects are some of the cheapest objects we allocate, at least in WebKit. Also, WebKit's fourth tier will eliminate nested function allocations if all of the calls to those functions are inlined. From helping with that work, I know that the cost of function allocation is small because even in the best case, the speed-ups from this optimization weren't earth-shattering.