Optimizing invokedynamic

Christian Thalinger, John R. Rose · 2010

In order to support the needs of non-Java languages, the JSR 292 Expert Group has designed a new bytecode "invokedynamic" which allows JVM bytecodes to contain call sites with pluggable, user-defined behavior. The bytecode is accompanied by a new data type called a "method handle" that reifies the pluggable behavior, in the form of a functional value. The authors have been building the JSR 292 Reference Implementation on top of Oracle's HotSpot JVM. This paper describes their implementation tactics. Interesting subtopics include connecting the novel features of JSR 292 to classic HotSpot optimizations, creating new code optimization techniques for HotSpot in support of JSR 292, using Java (along with HotSpot's customary C++) as an implementation language for method handles, using internally-generated bytecodes as an intermediate language for "freezing" dynamic call sites before optimization, and designing specialized "adapter" calling sequences which match callers and callees of differing type descriptors.

Read the paper · More papers on PaperTik