Skip to content

Commit 6e12262

Browse files
author
Michael Haas
committed
Refactoring.
1 parent 49329cc commit 6e12262

File tree

1 file changed

+17
-16
lines changed

1 file changed

+17
-16
lines changed

compiler/src/jdk.graal.compiler/src/jdk/graal/compiler/hotspot/nodes/InvokeJavaMethodNode.java

Lines changed: 17 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,11 @@ public class InvokeJavaMethodNode extends DeoptimizingFixedWithNextNode implemen
6767
* {@link InvokeJavaMethodNode} creation. See
6868
* {@code HotSpotTruffleSafepointLoweringSnippet#pollSnippet} for usage details.
6969
*/
70-
public static final class MethodWrapper {
70+
public static final class MethodReference {
7171
private final String name;
7272
private ResolvedJavaMethod targetMethod;
7373

74-
public MethodWrapper(String name) {
74+
public MethodReference(String name) {
7575
this.name = name;
7676
}
7777

@@ -84,7 +84,7 @@ public String getName() {
8484
}
8585
}
8686

87-
public static final MethodWrapper TRUFFLE_SAFEPOINT = new MethodWrapper("HotSpotThreadLocalHandshake.doHandshake");
87+
public static final MethodReference TRUFFLE_SAFEPOINT = new MethodReference("HotSpotThreadLocalHandshake.doHandshake");
8888

8989
@Input protected NodeInputList<ValueNode> arguments;
9090

@@ -93,7 +93,7 @@ public String getName() {
9393
private ResolvedJavaMethod targetMethod;
9494
private final CallTargetNode.InvokeKind invokeKind;
9595
private final StampPair returnStamp;
96-
private MethodWrapper methodWrapper;
96+
private MethodReference methodReference;
9797

9898
@SuppressWarnings("this-escape")
9999
protected InvokeJavaMethodNode(NodeClass<? extends InvokeJavaMethodNode> c, ResolvedJavaMethod targetMethod, ResolvedJavaMethod callerMethod,
@@ -108,7 +108,7 @@ protected InvokeJavaMethodNode(NodeClass<? extends InvokeJavaMethodNode> c, Reso
108108
}
109109

110110
@SuppressWarnings("unused")
111-
public static InvokeJavaMethodNode create(MethodWrapper wrapper, ResolvedJavaMethod callerMethod, int bci, ValueNode... args) {
111+
public static InvokeJavaMethodNode create(MethodReference wrapper, ResolvedJavaMethod callerMethod, int bci, ValueNode... args) {
112112
verifyTargetMethod(wrapper.targetMethod);
113113
ResolvedJavaMethod targetMethod = wrapper.targetMethod;
114114
JavaKind returnKind = targetMethod.getSignature().getReturnKind();
@@ -123,8 +123,10 @@ public static InvokeJavaMethodNode create(GraphBuilderContext b, ResolvedJavaMet
123123
return create(b, targetMethod, b.getMethod(), returnStamp, bci, args);
124124
}
125125

126-
private static InvokeJavaMethodNode create(GraphBuilderContext b, Stamp returnStamp, int bci, ValueNode... args) {
127-
return create(b, null, b.getMethod(), StampPair.createSingle(returnStamp), bci, args);
126+
private static InvokeJavaMethodNode createWithoutTargetMethod(GraphBuilderContext b, MethodReference method, Stamp returnStamp, int bci, ValueNode... args) {
127+
InvokeJavaMethodNode invoke = create(b, null, b.getMethod(), StampPair.createSingle(returnStamp), bci, args);
128+
invoke.methodReference = method;
129+
return invoke;
128130
}
129131

130132
private static InvokeJavaMethodNode create(GraphBuilderContext b, ResolvedJavaMethod targetMethod, ResolvedJavaMethod callerMethod,
@@ -186,7 +188,7 @@ public String toString(Verbosity verbosity) {
186188
sb.append(super.toString(verbosity));
187189
sb.append("#");
188190
if (targetMethod == null) {
189-
sb.append(methodWrapper.getName());
191+
sb.append(methodReference.getName());
190192
} else {
191193
sb.append(targetMethod.format("%h.%n"));
192194
}
@@ -198,15 +200,14 @@ public String toString(Verbosity verbosity) {
198200
@Override
199201
public Map<Object, Object> getDebugProperties(Map<Object, Object> map) {
200202
Map<Object, Object> debugProperties = super.getDebugProperties(map);
201-
debugProperties.put("targetMethod", targetMethod == null ? methodWrapper.getName() : targetMethod.format("%h.%n"));
203+
debugProperties.put("targetMethod", targetMethod == null ? methodReference.getName() : targetMethod.format("%h.%n"));
202204
return debugProperties;
203205
}
204206

205-
public static boolean intrinsify(GraphBuilderContext b, @InjectedNodeParameter Stamp returnStamp, MethodWrapper method, ValueNode... args) {
207+
public static boolean intrinsify(GraphBuilderContext b, @InjectedNodeParameter Stamp returnStamp, MethodReference method, ValueNode... args) {
206208
GraphBuilderContext nonIntrinsicAncestor = b.getNonIntrinsicAncestor();
207209
int bci = nonIntrinsicAncestor == null ? BytecodeFrame.UNKNOWN_BCI : b.bci();
208-
InvokeJavaMethodNode invoke = InvokeJavaMethodNode.create(b, returnStamp, bci, args);
209-
invoke.methodWrapper = method;
210+
InvokeJavaMethodNode invoke = InvokeJavaMethodNode.createWithoutTargetMethod(b, method, returnStamp, bci, args);
210211
JavaKind returnKind = returnStamp.getStackKind();
211212
if (returnKind == JavaKind.Void) {
212213
b.add(invoke);
@@ -218,10 +219,10 @@ public static boolean intrinsify(GraphBuilderContext b, @InjectedNodeParameter S
218219

219220
/**
220221
* Calls a static Java method with one argument and no return value. The target method has to be
221-
* set in the {@link MethodWrapper}, otherwise the node cannot be lowered.
222+
* set in the {@link MethodReference}, otherwise the node cannot be lowered.
222223
*/
223224
@NodeIntrinsic
224-
public static native void invoke(@ConstantNodeParameter MethodWrapper method, Object arg1);
225+
public static native void invoke(@ConstantNodeParameter MethodReference method, Object arg1);
225226

226227
@SuppressWarnings("try")
227228
public Invoke replaceWithInvoke() {
@@ -247,8 +248,8 @@ public InvokeNode createInvoke(StructuredGraph graph) {
247248
public void lower(LoweringTool tool) {
248249
if (graph().getGuardsStage().areFrameStatesAtDeopts()) {
249250
if (targetMethod == null) {
250-
GraalError.guarantee(methodWrapper != null, "method wrapper shouldn't be null");
251-
setTargetMethod(methodWrapper.targetMethod);
251+
GraalError.guarantee(methodReference != null, "method reference shouldn't be null");
252+
setTargetMethod(methodReference.targetMethod);
252253
}
253254
Invoke invoke = replaceWithInvoke();
254255
assert invoke.asNode().verify();

0 commit comments

Comments
 (0)