performance of OO dispatch in inner loops

Brendan Eich brendan at
Fri Mar 21 13:45:37 PDT 2008

On Mar 21, 2008, at 1:31 PM, David Teller wrote:

> I may be wrong but I have the feeling that the works you quote use
> type-feedback and that type-feedback only optimizes [single] method
> dispatch. ES4 has multi-methods, which are harder to optimize, plus
> there are plenty of other checks that may be optimized away which are
> related to typing but not to method dispatch, say pattern-matching,
> "wrap", etc. In addition, iirc, type-feedback only works after the  
> first
> execution of code, so it is not necessarily useful when objects are
> re-created at each execution of the body of a loop, etc.

You really should read the papers, and Andreas Gal's blog. Runtime  
types are only one of many kinds of information available to runtime  
optimizers. Tracing loops allows hoisting and even allocation  
elimination, using escape analysis. Common sub-expression elimination  
can consider trace-invariant expressions. One can guard all sorts of  
on-trace assumptions and compensate to the interpretr, re-tracing  
other hot paths. It's not just about types.

Having written this, there are open issues with tree folding to avoid  
proliferation of paths in the trace tree. Again, see http:// for more.


More information about the Es4-discuss mailing list