-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8312235: [JVMCI] ConstantPool should not force eager resolution #14927
Changes from all commits
a8e7ead
54c5404
4621c13
2952db0
543d9af
5ada646
1ca9ab6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -637,6 +637,11 @@ JavaConstant getStaticFieldConstantValue(int cpi) { | |
|
||
@Override | ||
public Object lookupConstant(int cpi) { | ||
return lookupConstant(cpi, true); | ||
} | ||
|
||
@Override | ||
public Object lookupConstant(int cpi, boolean resolve) { | ||
final JvmConstant tag = getTagAt(cpi); | ||
switch (tag.name) { | ||
case "Integer": | ||
|
@@ -658,17 +663,18 @@ public Object lookupConstant(int cpi) { | |
* "pseudo strings" (arbitrary live objects) patched into a String entry. Such | ||
* entries do not have a symbol in the constant pool slot. | ||
*/ | ||
return compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); | ||
return compilerToVM().lookupConstantInPool(this, cpi, true); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is true because it's always safe to do so? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't really know what these "pseudo strings" are. In any case, I don't think resolving them involves calling any Java code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sounds good. It's not currently causing any problems and we can investigate further if we start restricting when we |
||
case "MethodHandle": | ||
case "MethodHandleInError": | ||
case "MethodType": | ||
case "MethodTypeInError": | ||
case "Dynamic": | ||
case "DynamicInError": | ||
return compilerToVM().resolvePossiblyCachedConstantInPool(this, cpi); | ||
return compilerToVM().lookupConstantInPool(this, cpi, resolve); | ||
default: | ||
throw new JVMCIError("Unknown constant pool tag %s", tag); | ||
} | ||
|
||
} | ||
|
||
@Override | ||
|
@@ -822,7 +828,7 @@ public int rawIndexToConstantPoolIndex(int rawIndex, int opcode) { | |
if (opcode != Bytecodes.INVOKEDYNAMIC) { | ||
throw new IllegalArgumentException("expected INVOKEDYNAMIC at " + rawIndex + ", got " + opcode); | ||
} | ||
return compilerToVM().resolveInvokeDynamicInPool(this, rawIndex); | ||
return compilerToVM().decodeIndyIndexToCPIndex(this, rawIndex, false); | ||
} | ||
if (opcode == Bytecodes.INVOKEDYNAMIC) { | ||
throw new IllegalArgumentException("unexpected INVOKEDYNAMIC at " + rawIndex); | ||
|
@@ -856,7 +862,7 @@ public void loadReferencedType(int cpi, int opcode, boolean initialize) { | |
if (!isInvokedynamicIndex(cpi)) { | ||
throw new IllegalArgumentException("must use invokedynamic index but got " + cpi); | ||
} | ||
index = compilerToVM().resolveInvokeDynamicInPool(this, cpi); | ||
index = compilerToVM().decodeIndyIndexToCPIndex(this, cpi, true); | ||
break; | ||
} | ||
case Bytecodes.GETSTATIC: | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should there be some sort of exception or error checking here or in the caller? If the constant can't be found it either isn't resolved or the index is invalid, correct?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The error checking is already done by the call to
getTagAt
inHotSpotConstantPool.lookupConstant(int cpi, boolean resolve)
.I'll add more javadoc to clarify when a null is returned.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Note that the javadoc of
lookupConstantInPool
already states: