loading...
 This Article 
   
 Share 
   
 Bibliographic References 
   
 Add to: 
 
Digg
Furl
Spurl
Blink
Simpy
Google
Del.icio.us
Y!MyWeb
 
 Search 
   
International Symposium on Code Generation and Optimization (CGO'05)
Context Threading: A Flexible and Efficient Dispatch Technique for Virtual Machine Interpreters
San Jose, California
March 20-March 23
ISBN: 0-7695-2298-X
Marc Berndl, University of Toronto
Benjamin Vitale, University of Toronto
Mathew Zaleski, University of Toronto
Angela Demke Brown, University of Toronto
Direct-threaded interpreters use indirect branches to dispatch bytecodes, but deeply-pipelined architectures rely on branch prediction for performance. Due to the poor correlation between the virtual program's control flow and the hardware program counter, which we call the context problem, direct threading's indirect branches are poorly predicted by the hardware, limiting performance. Our dispatch technique, context threading, improves branch prediction and performance by aligning hardware and virtual machine state. Linear virtual instructions are dispatched with native calls and returns, aligning the hardware and virtual PC. Thus, sequential control flow is predicted by the hardware return stack. We convert virtual branching instructions to native branches, mobilizing the hardware's branch prediction resources. We evaluate the impact of context threading on both branch prediction and performance using interpreters for Java and OCaml on the Pentium and PowerPC architectures. On the Pentium IV, our technique reduces mean mispredicted branches by 95%. On the PowerPC, it reduces mean branch stall cycles by 75% for OCaml and 82% for Java. Due to reduced branch hazards, context threading reduces mean execution time by 25% for Java and by 19% and 37% for OCaml on the P4 and PPC970, respectively. We also combine context threading with a conservative inlining technique and find its performance comparable to that of selective inlining.
Citation:
Marc Berndl, Benjamin Vitale, Mathew Zaleski, Angela Demke Brown, "Context Threading: A Flexible and Efficient Dispatch Technique for Virtual Machine Interpreters," cgo, pp.15-26, International Symposium on Code Generation and Optimization (CGO'05), 2005
Usage of this product signifies your acceptance of the Terms of Use.