42
42
import org .truffleruby .language .LexicalScope ;
43
43
import org .truffleruby .language .Nil ;
44
44
import org .truffleruby .language .NotProvided ;
45
+ import org .truffleruby .language .RubyBaseNode ;
45
46
import org .truffleruby .language .RubyDynamicObject ;
46
47
import org .truffleruby .language .RubyGuards ;
47
48
import org .truffleruby .language .RubyNode ;
48
49
import org .truffleruby .language .RubySourceNode ;
49
50
import org .truffleruby .language .Visibility ;
51
+ import org .truffleruby .language .arguments .ArgumentsDescriptor ;
52
+ import org .truffleruby .language .arguments .EmptyArgumentsDescriptor ;
50
53
import org .truffleruby .language .arguments .RubyArguments ;
51
54
import org .truffleruby .language .control .RaiseException ;
52
55
import org .truffleruby .language .dispatch .DispatchNode ;
@@ -324,7 +327,7 @@ public abstract static class InstanceEvalNode extends AlwaysInlinedMethodNode {
324
327
325
328
@ Specialization (guards = "isBlockProvided(rubyArgs)" )
326
329
protected Object evalWithBlock (Frame callerFrame , Object self , Object [] rubyArgs , RootCallTarget target ,
327
- @ Cached ( allowUncached = true ) InstanceExecNode instanceExecNode ,
330
+ @ Cached InstanceExecBlockNode instanceExecNode ,
328
331
@ Cached BranchProfile errorProfile ) {
329
332
final int count = RubyArguments .getPositionalArgumentsCount (rubyArgs , false );
330
333
@@ -334,7 +337,7 @@ protected Object evalWithBlock(Frame callerFrame, Object self, Object[] rubyArgs
334
337
}
335
338
336
339
final Object block = RubyArguments .getBlock (rubyArgs );
337
- return instanceExecNode .executeInstanceExec ( callerFrame . materialize () , self , new Object []{ self },
340
+ return instanceExecNode .execute ( EmptyArgumentsDescriptor . INSTANCE , self , new Object []{ self },
338
341
(RubyProc ) block );
339
342
}
340
343
@@ -440,6 +443,25 @@ protected Object instanceExec(Object receiver, Object[] arguments, Nil block) {
440
443
441
444
}
442
445
446
+ @ GenerateUncached
447
+ public abstract static class InstanceExecBlockNode extends RubyBaseNode {
448
+
449
+ public abstract Object execute (ArgumentsDescriptor descriptor , Object self , Object [] args , RubyProc block );
450
+
451
+ @ Specialization
452
+ protected Object instanceExec (ArgumentsDescriptor descriptor , Object self , Object [] arguments , RubyProc block ,
453
+ @ Cached CallBlockNode callBlockNode ) {
454
+ final DeclarationContext declarationContext = new DeclarationContext (
455
+ Visibility .PUBLIC ,
456
+ new SingletonClassOfSelfDefaultDefinee (self ),
457
+ block .declarationContext .getRefinements ());
458
+
459
+ return callBlockNode .executeCallBlock (
460
+ declarationContext , block , self , nil , descriptor , arguments , null );
461
+ }
462
+
463
+ }
464
+
443
465
@ CoreMethod (names = "method_missing" , needsBlock = true , rest = true , optional = 1 , visibility = Visibility .PRIVATE ,
444
466
split = Split .NEVER )
445
467
public abstract static class MethodMissingNode extends CoreMethodArrayArgumentsNode {
0 commit comments