@@ -135,10 +135,16 @@ public abstract static class CallNode extends AlwaysInlinedMethodNode {
135
135
protected Object call (Frame callerFrame , RubyMethod method , Object [] rubyArgs , RootCallTarget target ,
136
136
@ Cached CallInternalMethodNode callInternalMethodNode ) {
137
137
final InternalMethod internalMethod = method .method ;
138
- final Object [] newArgs = RubyArguments .repack (rubyArgs , method .receiver );
138
+ final Object receiver = method .receiver ;
139
+ return callBoundMethod (callerFrame , internalMethod , receiver , rubyArgs , callInternalMethodNode );
140
+ }
141
+
142
+ static Object callBoundMethod (Frame frame , InternalMethod internalMethod , Object receiver ,
143
+ Object [] callerRubyArgs , CallInternalMethodNode callInternalMethodNode ) {
144
+ final Object [] newArgs = RubyArguments .repack (callerRubyArgs , receiver );
139
145
RubyArguments .setMethod (newArgs , internalMethod );
140
146
assert RubyArguments .assertFrameArguments (newArgs );
141
- return callInternalMethodNode .execute (callerFrame , internalMethod , method . receiver , newArgs , null );
147
+ return callInternalMethodNode .execute (frame , internalMethod , receiver , newArgs , null );
142
148
}
143
149
}
144
150
@@ -327,13 +333,13 @@ protected RootCallTarget methodCallTarget(InternalMethod method) {
327
333
final SourceSection sourceSection = method .getSharedMethodInfo ().getSourceSection ();
328
334
final RubyRootNode methodRootNode = RubyRootNode .of (method .getCallTarget ());
329
335
330
- final SetReceiverNode setReceiverNode = new SetReceiverNode (method );
336
+ var callWithRubyMethodReceiverNode = new CallWithRubyMethodReceiverNode (method );
331
337
final RubyLambdaRootNode wrapRootNode = new RubyLambdaRootNode (
332
338
getLanguage (),
333
339
sourceSection ,
334
340
methodRootNode .getFrameDescriptor (),
335
341
method .getSharedMethodInfo (),
336
- setReceiverNode ,
342
+ callWithRubyMethodReceiverNode ,
337
343
methodRootNode .getSplit (),
338
344
methodRootNode .returnID ,
339
345
BreakID .INVALID ,
@@ -345,22 +351,19 @@ protected int getCacheLimit() {
345
351
return getLanguage ().options .METHOD_TO_PROC_CACHE ;
346
352
}
347
353
348
- }
349
-
350
- private static class SetReceiverNode extends RubyContextSourceNode {
351
- private final InternalMethod method ;
352
- @ Child private CallInternalMethodNode callInternalMethodNode = CallInternalMethodNode .create ();
354
+ private static class CallWithRubyMethodReceiverNode extends RubyContextSourceNode {
355
+ private final InternalMethod method ;
356
+ @ Child private CallInternalMethodNode callInternalMethodNode = CallInternalMethodNode .create ();
353
357
354
- public SetReceiverNode (InternalMethod method ) {
355
- this .method = method ;
356
- }
358
+ public CallWithRubyMethodReceiverNode (InternalMethod method ) {
359
+ this .method = method ;
360
+ }
357
361
358
- @ Override
359
- public Object execute (VirtualFrame frame ) {
360
- final Object originalBoundMethodReceiver = RubyArguments .getSelf (RubyArguments .getDeclarationFrame (frame ));
361
- Object [] rubyArgs = RubyArguments .repack (frame .getArguments (), originalBoundMethodReceiver );
362
- RubyArguments .setMethod (rubyArgs , method );
363
- return callInternalMethodNode .execute (frame , method , originalBoundMethodReceiver , rubyArgs , null );
362
+ @ Override
363
+ public Object execute (VirtualFrame frame ) {
364
+ final Object receiver = RubyArguments .getSelf (RubyArguments .getDeclarationFrame (frame ));
365
+ return CallNode .callBoundMethod (frame , method , receiver , frame .getArguments (), callInternalMethodNode );
366
+ }
364
367
}
365
368
}
366
369
0 commit comments