what can we expect from invokeExact()

Garcia Gutierrez Miguel Alfredo miguelalfredo.garcia at epfl.ch
Mon May 7 05:57:23 PDT 2012


Hi,

Right now the Scala compiler doesn't rely on invokedynamic but some brainstorming is underway as sketched next. Any Graal-specific insights are welcome.

Two sources of slowdown for us are:

  (a) "The Inlining Problem" as described by Cliff Clik [1]

  (b) "datatype-agnostic bytecode" (think of arithmetic on boxed primitives and you'll be pretty close, the primitives don't change in any given invocation as they can in JavaScript, but can change across invocations)

Regarding the first problem, a candidate solution involves emitting code to pass a MethodHandler object rather than a scala.Function object: the invokeExact() would hopefully be inlined , all while avoiding autoboxing (because the signature for the invokeExact() refers to primitive types if any).

For (b) again MethodHandler, as described at
  - https://groups.google.com/d/msg/jvm-languages/eEp3Z8tS8wo/KDJVFz6ZFm0J

The approach "sketched" above has the HUGE HUGE HUGE advantage that no separate compilation scheme would be needed for Graal, or at most a few annotations that Graal could understand to optimize beyond what traditional HotSpot does (and yet get respectable performance from non-Graal HotSpot).

Questions:

  (Q1) Without hints, "inlining" a MH invokeExact() gets reduced to an invokevirtual on the target method, right? But that target method itself is not "inlined"? Or is it?

  (Q2) Tracing. We've read the paper "Trace-based compilation for the Java HotSpot virtual machine" [2] and wonder how Graal goes about it (for example, regarding "The Inlining Problem")

regards,

Miguel
http://lampwww.epfl.ch/~magarcia/ScalaCompilerCornerReloaded<http://lampwww.epfl.ch/%7Emagarcia/ScalaCompilerCornerReloaded>


[1] http://www.azulsystems.com/blog/cliff/2011-04-04-fixing-the-inlining-problem

[2] Trace-based compilation for the Java HotSpot virtual machine
    Christian Häubl, Hanspeter Mössenböck
    http://dl.acm.org/citation.cfm?id=2093176&CFID=81110431&CFTOKEN=26096476


--
Miguel Garcia
Swiss Federal Institute of Technology
EPFL - IC - LAMP1 - INR 328 - Station 14
CH-1015 Lausanne - Switzerland
http://lamp.epfl.ch/~magarcia/




More information about the graal-dev mailing list