performance of OO dispatch in inner loops

ToolmakerSteve98 toolmakersteve98 at
Fri Mar 21 04:17:47 PDT 2008

was [Re: Any discussion of "compact" subset for mobile devices?]

"Brendan Eich" wrote:
> Why do you believe static typing is necessary for performance? Just
> curious.

I woke up in the middle of night, remembering one detail we hit in 1992. 
Advanced OO programming styles lead to inner loops that contain (potentially 
subclassed) method dispatches. THAT'S the bottleneck, not the speed of 
arithmetic computations. Doesn't JIT well, because each "inner loop" (code 
bottleneck involving repetition) is a cooperative effort between multiple 
objects, any one of which might show up as a different subclass in the next 
loop iteration.

Not awake enough right now to think through whether more modern JITs 
(tracing) successfully unravel this case. If so, then it is a matter of 
careful cache design. If not, then I think this is where static typing (or 
more precisely, constructing an object knowing that it has given interfaces; 
in theory this could be done for dynamically typed objects if you can 
determine at construction that it satisfies the interface) makes possible 
higher performance execution than dynamic typing.


More information about the Es4-discuss mailing list