Really great! Some notes that popped out for me are that to always cache the .length property for any array or arguments: function doesntLeakArguments() { var args = new Array(arguments.length); for(var i = 0; i becomes: function doesntLeakArguments() { var len = arguments.length; var args = new Array(len); for(var i = 0; i And also, if you've got a switch statement with more than 128 cases, you've probably got bigge…
Huge switches are common in the inner loop of emulators and interpreters. They tend to end up with a 256-case switch to handle the next byte in the instruction stream.
V8 Optimization Killers
11–20 of 88 posts
Re: V8 Optimization Killers
#12Re: V8 Optimization Killers
#13Re: V8 Optimization Killers
#14Re: V8 Optimization Killers
#15here says: http://www.2ality.com/2013/04/check-undefined.html void 0 is safe.
Re: V8 Optimization Killers
#16Earlier quoted context omitted.
I'm really sick of these recent JavaScript performance related posts that only talk about V8.
I think the general idea is that asm.js is both well understood and not something a human should ever generate, so why would anyone but a transpiler writer care?
Re: V8 Optimization Killers
#17Is it probable that SpiderMonkey and other engines suffer from forms of this deoptimization hell when rendering? And would it be a safe guess that whatever mod_pagespeed does to a page's javascript resources is less likely to result in this hell than these other tools? Thanks.
Re: V8 Optimization Killers
#18Title should probably be "V8 Optimization Killers".
I'm really sick of these recent JavaScript performance related posts that only talk about V8.
Re: V8 Optimization Killers
#19Earlier quoted context omitted.
Huge switches are common in the inner loop of emulators and interpreters. They tend to end up with a 256-case switch to handle the next byte in the instruction stream.
I understand that use case, but in my opinion it would be much cleaner (and speculating faster) to have an 256-slot array...and routing with opcodes[byte.charCodeAt(0)](); or something similar.
In the Javascript world, "Your Mileage May Vary" truly is a motto.
Re: V8 Optimization Killers
#20Title should probably be "V8 Optimization Killers".
I'm really sick of these recent JavaScript performance related posts that only talk about V8.