Skip to content

Commit ed854dc

Browse files
committed
address comments
1 parent bf00079 commit ed854dc

File tree

6 files changed

+21
-19
lines changed

6 files changed

+21
-19
lines changed

compiler/src/jdk.graal.compiler.hotspot.jdk23.test/src/jdk/graal/compiler/hotspot/jdk23/test/SharedExceptionHandlerLoopTest.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,8 @@
3232

3333
import org.junit.Test;
3434

35-
import jdk.graal.compiler.core.test.CustomizedBytecodePatternTest;
35+
import jdk.graal.compiler.core.test.CustomizedBytecodePattern;
36+
import jdk.graal.compiler.core.test.GraalCompilerTest;
3637
import jdk.vm.ci.meta.ResolvedJavaMethod;
3738

3839
/**
@@ -41,7 +42,7 @@
4142
* Java code, but the Kotlin compiler can produce such patterns when compiling coroutines. See
4243
* {@link #generateClass} for the Java source code from which the modified bytecode is derived.
4344
*/
44-
public class SharedExceptionHandlerLoopTest extends CustomizedBytecodePatternTest {
45+
public class SharedExceptionHandlerLoopTest extends GraalCompilerTest implements CustomizedBytecodePattern {
4546

4647
@Test
4748
public void test() throws ClassNotFoundException {
@@ -114,13 +115,13 @@ public String toString() {
114115
* </pre>
115116
*/
116117
@Override
117-
protected byte[] generateClass(String internalClassName) {
118+
public byte[] generateClass(String internalClassName) {
118119
MethodTypeDesc getMethodTypeDesc = MethodTypeDesc.of(ConstantDescs.CD_Object, ConstantDescs.CD_Object, ConstantDescs.CD_Object);
119120

120121
ClassDesc thisClass = ClassDesc.of(internalClassName.replace('/', '.'));
121122
return ClassFile.of().build(thisClass, classBuilder -> classBuilder
122123
// @formatter:off
123-
.withMethod("testMethod", getMethodTypeDesc, ACC_PUBLIC | ACC_STATIC, methodBuilder -> methodBuilder.withCode(codeBuilder -> {
124+
.withMethod("testMethod", getMethodTypeDesc, ACC_PUBLIC_STATIC, methodBuilder -> methodBuilder.withCode(codeBuilder -> {
124125
Label start = codeBuilder.newLabel();
125126
Label loopExcEnd = codeBuilder.newLabel();
126127
Label loopNPEHandler = codeBuilder.newLabel();
@@ -160,8 +161,4 @@ protected byte[] generateClass(String internalClassName) {
160161
})));
161162
// @formatter:on
162163
}
163-
164-
public static ClassDesc cd(Class<?> klass) {
165-
return klass.describeConstable().orElseThrow();
166-
}
167164
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/DynamicConstantTest.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -133,18 +133,18 @@ private void generate(CodeBuilder b) {
133133
// Example: int DynamicConstantTest.getIntBSM(MethodHandles.Lookup l, String name,
134134
// Class<?> type)
135135
String sig = "(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/Class;)" + desc;
136-
var condy = DynamicConstantDesc.ofNamed(MethodHandleDesc.of(Kind.STATIC, outerClass, getter + "BSM", sig), "consnt", type);
136+
var condy = DynamicConstantDesc.ofNamed(MethodHandleDesc.of(Kind.STATIC, outerClass, getter + "BSM", sig), "const", type);
137137
b.ldc(condy).return_(TypeKind.from(type));
138138
} else if (condyType == CondyType.CALL_INDIRECT_BSM) {
139139
// Example: int DynamicConstantTest.getInt()
140-
var condy = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE, "consnt", type, MethodHandleDesc.of(Kind.STATIC, outerClass, getter, "()" + desc));
140+
var condy = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE, "const", type, MethodHandleDesc.of(Kind.STATIC, outerClass, getter, "()" + desc));
141141
b.ldc(condy).return_(TypeKind.from(type));
142142
} else {
143143
assert condyType == CondyType.CALL_INDIRECT_WITH_ARGS_BSM;
144144
// Example: int DynamicConstantTest.getInt()
145-
var condy1 = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE, "consnt1", type, MethodHandleDesc.of(Kind.STATIC, outerClass, getter, "()" + desc));
145+
var condy1 = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE, "const1", type, MethodHandleDesc.of(Kind.STATIC, outerClass, getter, "()" + desc));
146146
// Example: int DynamicConstantTest.getInt(int v1, int v2)
147-
var condy2 = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE, "consnt2", type, MethodHandleDesc.of(Kind.STATIC, outerClass, getter, "(" + desc + desc + ")" + desc), condy1,
147+
var condy2 = DynamicConstantDesc.ofNamed(ConstantDescs.BSM_INVOKE, "const2", type, MethodHandleDesc.of(Kind.STATIC, outerClass, getter, "(" + desc + desc + ")" + desc), condy1,
148148
condy1);
149149
b.ldc(condy2).return_(TypeKind.from(type));
150150
}

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/ExceptionHandlerReachabilityTest.java

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,36 +98,37 @@ public void test() {
9898
@Override
9999
public byte[] generateClass(String className) {
100100
ClassDesc classSharedExceptionHandlerClass = cd(SharedExceptionHandlerClass.class);
101+
MethodTypeDesc mtdII = MethodTypeDesc.of(CD_int, CD_int);
101102

102103
return ClassFile.of().build(ClassDesc.of(className), classBuilder -> classBuilder
103-
.withMethodBody("sharedExceptionHandlerMethod", MethodTypeDesc.of(CD_int, CD_int), ACC_PUBLIC_STATIC, b -> {
104+
.withMethodBody("sharedExceptionHandlerMethod", mtdII, ACC_PUBLIC_STATIC, b -> {
104105
Label handlerEx1 = b.newLabel();
105106
b
106107
.iload(0)
107108
.istore(1)
108109
.trying(tryBlock -> {
109110
tryBlock
110111
.iload(1)
111-
.invokestatic(classSharedExceptionHandlerClass, "foo", MethodTypeDesc.of(CD_int, CD_int))
112+
.invokestatic(classSharedExceptionHandlerClass, "foo", mtdII)
112113
.istore(1);
113114
}, catchBuilder -> catchBuilder.catching(cd(IllegalArgumentException.class), catchBlock -> {
114115
catchBlock
115116
.labelBinding(handlerEx1)
116117
.iload(1)
117-
.invokestatic(classSharedExceptionHandlerClass, "baz", MethodTypeDesc.of(CD_int, CD_int))
118+
.invokestatic(classSharedExceptionHandlerClass, "baz", mtdII)
118119
.istore(1)
119120
.iload(1)
120121
.ireturn();
121122
}))
122123
.trying(tryBlock -> {
123124
tryBlock
124125
.iload(1)
125-
.invokestatic(classSharedExceptionHandlerClass, "bar", MethodTypeDesc.of(CD_int, CD_int))
126+
.invokestatic(classSharedExceptionHandlerClass, "bar", mtdII)
126127
.istore(1);
127128
}, catchBuilder -> catchBuilder.catching(cd(NumberFormatException.class), catchBlock -> {
128129
catchBlock
129130
.iload(1)
130-
.invokestatic(classSharedExceptionHandlerClass, "doSomething", MethodTypeDesc.of(CD_int, CD_int))
131+
.invokestatic(classSharedExceptionHandlerClass, "doSomething", mtdII)
131132
.istore(1)
132133
.goto_(handlerEx1);
133134
}))

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/core/test/UnbalancedLockingTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ private static void createIrreducibleMethod(ClassDesc thisClass, CodeBuilder b)
136136
b
137137
.iload(0)
138138
.bipush(12)
139-
.ifThenElse(Opcode.IF_ICMPGE,
139+
.ifThenElse(Opcode.IF_ICMPGT,
140140
thenBlock -> thenBlock.aload(2).astore(6),
141141
elseBlock -> elseBlock.aload(3).astore(6))
142142
.iconst_0()

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/jtt/backend/LargeConstantSectionTest.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ protected Class<?> findClass(String name) throws ClassNotFoundException {
117117

118118
for (int i = 0; i < cases.size(); i++) {
119119
b.labelBinding(cases.get(i).target())
120-
.ldc(Long.valueOf(0xF0F0F0F0F0L + i))
120+
.ldc(Long.valueOf(LARGE_CONSTANT + i))
121121
.lreturn();
122122
}
123123

compiler/src/jdk.graal.compiler.test/src/jdk/graal/compiler/replacements/test/DeoptimizeOnExceptionTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,8 @@ public void test2() throws ReflectiveOperationException {
103103
}
104104

105105
public static void methodB() {
106+
// Application code to be compiled. No need to use
107+
// GraalCompilerTest.getRandomInstance()
106108
Random r = new Random(System.currentTimeMillis());
107109
while (r.nextFloat() > .03f) {
108110
// Empty
@@ -112,6 +114,8 @@ public static void methodB() {
112114
}
113115

114116
public static void methodA() {
117+
// Application code to be compiled. No need to use
118+
// GraalCompilerTest.getRandomInstance()
115119
Random r = new Random(System.currentTimeMillis());
116120
while (r.nextDouble() > .05) {
117121
// Empty

0 commit comments

Comments
 (0)