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

[JVMCI] ConstantPool should not force eager resolution

XMLWordPrintable

    • 9
    • b09

      The existing jdk.vm.ci.meta.ConstantPool.lookupConstant(int cpi) method forces eager resolving of constants. For DynamicConstant and MethodHandle, this can mean invoking bootstrap methods, something that should not be done during JIT compilation. To avoid this eager resolution, an overloaded version of this method is required:

      /**
       * Looks up a constant at the specified index.
       *
       * If {@code resolve == false} and the denoted constant is of type
       * {@code JVM_CONSTANT_Dynamic}, {@code JVM_CONSTANT_MethodHandle} or
       * {@code JVM_CONSTANT_MethodType} and it's not yet resolved then
       * {@code null} is returned.
       *
       * @param cpi the constant pool index
       * @return the {@code Constant} or {@code JavaType} instance representing the constant pool entry
       */
      Object lookupConstant(int cpi, boolean resolve);

      Likewise, jdk.vm.ci.meta.ConstantPool.lookupBootstrapMethodInvocation(int rawCpi, int opcode) invokes the associated bootstrap method. It should not.

            dnsimon Douglas Simon
            dnsimon Douglas Simon
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: