Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8364670

[JVMCI] Extend JVMCI to express fixed binding

XMLWordPrintable

    • Icon: Enhancement Enhancement
    • Resolution: Unresolved
    • Icon: P4 P4
    • tbd
    • 26
    • hotspot
    • Cause Known
    • generic
    • generic

      In normal execution we must have an invoke bytecode to emit a normal virtual or static call since that bytecode information is used to perform the lookup of the method to be called.
      JDK-8072008 added the ability for the relocation information to directly specify the method to be invoked, see [2] and [3]
      This feature has the following two cases:
      - Directly call a resolved method handle e.g. see [4].
      - Valhalla binds a method if it performs the substitutability check [11] or it is an opt call with a value class receiver e.g. coming from an interface call [12]. Value class receivers can be scalarized (instead of passing an oop, we pass the field values). Hotspot patches the call based on the type of the receiver oop. As an oop no longer exists we need to attach the method as additional information.

      As we have no JVMCI support to bind a method at the moment, for the first point bullet Graal has to convert a resolved method handle back to the original call site if it was not inlined, see [10]. But we want to simply bind the call site to invoke that was resolved as well. For Valhalla we hardcoded this behaviour in the installer for the moment being see [5].

      The following changes are necessary in JVMCI:
      - In Call.java [6], add a boolean field that indicates if the call should be bound.
      - In HotSpotCompiledCodeStream.java [7], write out the new field to the stream to have access to it in the installer. This field can then be set e.g. [8].
      - In the JVMCI installers [9], extract the information from the stream and attach it to the site. Needs to be done for other target architectures as well.

      [2] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/x86_64.ad#L1880
      [3] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/machnode.hpp#L968
      [4] https://github.com/openjdk/jdk/blob/master/src/hotspot/share/opto/callGenerator.cpp#L267
      [5] https://github.com/MichaelHaas99/valhalla/blob/mh/GR-57655/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp#L184
      [6] https://github.com/openjdk/jdk/blob/master/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/code/site/Call.java
      [7] https://github.com/openjdk/jdk/blob/master/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotCompiledCodeStream.java#L759
      [8] https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/code/CompilationResult.java#L517
      [9] https://github.com/openjdk/jdk/blob/master/src/hotspot/cpu/x86/jvmciCodeInstaller_x86.cpp#L177
      [10] https://github.com/oracle/graal/blob/master/compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/replacements/nodes/ResolvedMethodHandleCallTargetNode.java
      [11] https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/opto/parse2.cpp#L2304
      [12] https://github.com/openjdk/valhalla/blob/lworld/src/hotspot/share/opto/graphKit.cpp#L1941

            mhaas Michael Haas
            mhaas Michael Haas
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

              Created:
              Updated: