Skip to content

Commit 284f7ed

Browse files
author
Nicolas Laurent
committed
refactor CallInternalMethodNode#createCall
1 parent 31b5b56 commit 284f7ed

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

src/main/java/org/truffleruby/language/dispatch/DispatchNode.java

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
package org.truffleruby.language.dispatch;
1111

1212
import com.oracle.truffle.api.CompilerDirectives;
13+
import com.oracle.truffle.api.RootCallTarget;
1314
import com.oracle.truffle.api.frame.MaterializedFrame;
1415
import com.oracle.truffle.api.frame.VirtualFrame;
1516
import com.oracle.truffle.api.interop.TruffleObject;
@@ -199,17 +200,19 @@ protected RubySymbol nameToSymbol(String methodName) {
199200

200201
/** This will be called from the {@link CallInternalMethodNode} child whenever it creates a new
201202
* {@link DirectCallNode}. */
202-
public final void applySplittingInliningStrategy(InternalMethod method, DirectCallNode callNode) {
203+
public final void applySplittingInliningStrategy(RootCallTarget callTarget, String methodName,
204+
DirectCallNode callNode) {
205+
203206

204207
final Options options = getContext().getOptions();
205208

206209
// The way that #method_missing is used is usually as an indirection to call some other method, and possibly to
207210
// modify the arguments. In both cases, but especially the latter, it makes a lot of sense to manually clone the
208211
// call target and to inline it.
209-
final boolean isMethodMissing = method.getName().equals("method_missing");
212+
final boolean isMethodMissing = methodName.equals("method_missing");
210213

211214
if (callNode.isCallTargetCloningAllowed() &&
212-
(((RubyRootNode) method.getCallTarget().getRootNode()).shouldAlwaysClone() ||
215+
(((RubyRootNode) callTarget.getRootNode()).shouldAlwaysClone() ||
213216
isMethodMissing && options.METHODMISSING_ALWAYS_CLONE)) {
214217
callNode.cloneCallTarget();
215218
}

src/main/java/org/truffleruby/language/methods/CallInternalMethodNode.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public static CallInternalMethodNode create() {
4040
protected Object callMethodCached(InternalMethod method, Object[] frameArguments,
4141
@Cached("method.getCallTarget()") RootCallTarget cachedCallTarget,
4242
@Cached("method") InternalMethod cachedMethod,
43-
@Cached("createCall(cachedMethod, cachedCallTarget)") DirectCallNode callNode) {
43+
@Cached("createCall(cachedMethod.getName(), cachedCallTarget)") DirectCallNode callNode) {
4444
return callNode.call(frameArguments);
4545
}
4646

@@ -58,11 +58,11 @@ protected int getCacheLimit() {
5858
return RubyLanguage.getCurrentContext().getOptions().DISPATCH_CACHE;
5959
}
6060

61-
protected DirectCallNode createCall(InternalMethod method, RootCallTarget callTarget) {
61+
protected DirectCallNode createCall(String methodName, RootCallTarget callTarget) {
6262
DirectCallNode callNode = DirectCallNode.create(callTarget);
6363
final DispatchNode dispatch = NodeUtil.findParent(this, DispatchNode.class);
6464
if (dispatch != null) {
65-
dispatch.applySplittingInliningStrategy(method, callNode);
65+
dispatch.applySplittingInliningStrategy(callTarget, methodName, callNode);
6666
}
6767
return callNode;
6868
}

0 commit comments

Comments
 (0)