8289687: [JVMCI] bug in HotSpotResolvedJavaMethodImpl.equals
Reviewed-by: kvn
This commit is contained in:
parent
77c3bbf105
commit
c45d613faa
@ -500,29 +500,29 @@ final class CompilerToVM {
|
||||
* @throws JVMCIError if there is something wrong with the compiled code or the associated
|
||||
* metadata.
|
||||
*/
|
||||
int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, long failedSpeculationsAddress, byte[] speculations) {
|
||||
int codeInstallFlags = getInstallCodeFlags();
|
||||
boolean withComments = (codeInstallFlags & 0x0001) != 0;
|
||||
boolean withMethods = (codeInstallFlags & 0x0002) != 0;
|
||||
boolean withTypeInfo;
|
||||
if ((codeInstallFlags & 0x0004) != 0 && HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.isDefault) {
|
||||
withTypeInfo = true;
|
||||
} else {
|
||||
withTypeInfo = HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.getBoolean();
|
||||
}
|
||||
try (HotSpotCompiledCodeStream stream = new HotSpotCompiledCodeStream(compiledCode, withTypeInfo, withComments, withMethods)) {
|
||||
return installCode0(stream.headChunk, stream.timeNS, withTypeInfo, compiledCode, stream.objectPool, code, failedSpeculationsAddress, speculations);
|
||||
}
|
||||
int installCode(HotSpotCompiledCode compiledCode, InstalledCode code, long failedSpeculationsAddress, byte[] speculations) {
|
||||
int codeInstallFlags = getInstallCodeFlags();
|
||||
boolean withComments = (codeInstallFlags & 0x0001) != 0;
|
||||
boolean withMethods = (codeInstallFlags & 0x0002) != 0;
|
||||
boolean withTypeInfo;
|
||||
if ((codeInstallFlags & 0x0004) != 0 && HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.isDefault) {
|
||||
withTypeInfo = true;
|
||||
} else {
|
||||
withTypeInfo = HotSpotJVMCIRuntime.Option.CodeSerializationTypeInfo.getBoolean();
|
||||
}
|
||||
try (HotSpotCompiledCodeStream stream = new HotSpotCompiledCodeStream(compiledCode, withTypeInfo, withComments, withMethods)) {
|
||||
return installCode0(stream.headChunk, stream.timeNS, withTypeInfo, compiledCode, stream.objectPool, code, failedSpeculationsAddress, speculations);
|
||||
}
|
||||
}
|
||||
|
||||
native int installCode0(long compiledCodeBuffer,
|
||||
long serializationNS,
|
||||
boolean withTypeInfo,
|
||||
HotSpotCompiledCode compiledCode,
|
||||
Object[] objectPool,
|
||||
InstalledCode code,
|
||||
long failedSpeculationsAddress,
|
||||
byte[] speculations);
|
||||
native int installCode0(long compiledCodeBuffer,
|
||||
long serializationNS,
|
||||
boolean withTypeInfo,
|
||||
HotSpotCompiledCode compiledCode,
|
||||
Object[] objectPool,
|
||||
InstalledCode code,
|
||||
long failedSpeculationsAddress,
|
||||
byte[] speculations);
|
||||
|
||||
/**
|
||||
* Gets flags specifying optional parts of code info. Only if a flag is set, will the
|
||||
|
@ -166,7 +166,7 @@ final class HotSpotResolvedJavaMethodImpl extends HotSpotMethod implements HotSp
|
||||
}
|
||||
if (obj instanceof HotSpotResolvedJavaMethodImpl) {
|
||||
HotSpotResolvedJavaMethodImpl that = (HotSpotResolvedJavaMethodImpl) obj;
|
||||
return getMethodPointer() == getMethodPointer();
|
||||
return that.getMethodPointer() == getMethodPointer();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -67,6 +67,17 @@ public class TestResolvedJavaField extends FieldUniverse {
|
||||
public TestResolvedJavaField() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
for (ResolvedJavaField f : fields.values()) {
|
||||
for (ResolvedJavaField that : fields.values()) {
|
||||
boolean expect = f == that;
|
||||
boolean actual = f.equals(that);
|
||||
assertEquals(expect, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModifiersTest() {
|
||||
for (Map.Entry<Field, ResolvedJavaField> e : fields.entrySet()) {
|
||||
|
@ -25,7 +25,6 @@
|
||||
* @test
|
||||
* @requires vm.jvmci
|
||||
* @library ../../../../../
|
||||
* @ignore 8249621
|
||||
* @modules jdk.internal.vm.ci/jdk.vm.ci.meta
|
||||
* jdk.internal.vm.ci/jdk.vm.ci.runtime
|
||||
* java.base/jdk.internal.misc
|
||||
@ -109,6 +108,17 @@ public class TestResolvedJavaMethod extends MethodUniverse {
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
for (ResolvedJavaMethod m : methods.values()) {
|
||||
for (ResolvedJavaMethod that : methods.values()) {
|
||||
boolean expect = m == that;
|
||||
boolean actual = m.equals(that);
|
||||
assertEquals(expect, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getModifiersTest() {
|
||||
for (Map.Entry<Method, ResolvedJavaMethod> e : methods.entrySet()) {
|
||||
@ -209,14 +219,20 @@ public class TestResolvedJavaMethod extends MethodUniverse {
|
||||
}
|
||||
for (Map.Entry<Constructor<?>, ResolvedJavaMethod> e : constructors.entrySet()) {
|
||||
ResolvedJavaMethod m = e.getValue();
|
||||
assertEquals(m.canBeStaticallyBound(), canBeStaticallyBound(e.getKey()));
|
||||
boolean expect = m.canBeStaticallyBound();
|
||||
boolean actual = canBeStaticallyBound(e.getKey());
|
||||
assertEquals(m.toString(), expect, actual);
|
||||
}
|
||||
}
|
||||
|
||||
private static boolean canBeStaticallyBound(Member method) {
|
||||
int modifiers = method.getModifiers();
|
||||
return (Modifier.isFinal(modifiers) || Modifier.isPrivate(modifiers) || Modifier.isStatic(modifiers) || Modifier.isFinal(method.getDeclaringClass().getModifiers())) &&
|
||||
!Modifier.isAbstract(modifiers);
|
||||
return (Modifier.isFinal(modifiers) ||
|
||||
Modifier.isPrivate(modifiers) ||
|
||||
Modifier.isStatic(modifiers) ||
|
||||
method instanceof Constructor ||
|
||||
Modifier.isFinal(method.getDeclaringClass().getModifiers())) &&
|
||||
!Modifier.isAbstract(modifiers);
|
||||
}
|
||||
|
||||
private static String methodWithExceptionHandlers(String p1, Object o2) {
|
||||
@ -256,7 +272,8 @@ public class TestResolvedJavaMethod extends MethodUniverse {
|
||||
StackTraceElement expected = e.getStackTrace()[0];
|
||||
ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("nullPointerExceptionOnFirstLine", Object.class, String.class));
|
||||
StackTraceElement actual = method.asStackTraceElement(0);
|
||||
assertEquals(expected, actual);
|
||||
// JVMCI StackTraceElements omit the class loader and module info
|
||||
assertEquals(expected.toString(), actual.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -91,6 +91,17 @@ public class TestResolvedJavaType extends TypeUniverse {
|
||||
public TestResolvedJavaType() {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void equalsTest() {
|
||||
for (ResolvedJavaType t : javaTypes) {
|
||||
for (ResolvedJavaType that : javaTypes) {
|
||||
boolean expect = t == that;
|
||||
boolean actual = t.equals(that);
|
||||
assertEquals(expect, actual);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private static Class<? extends Annotation> findPolymorphicSignatureClass() {
|
||||
Class<? extends Annotation> signaturePolyAnnotation = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user