Skip to content

Commit

Permalink
Use block's frame name if called inside a block
Browse files Browse the repository at this point in the history
This mimics the JIT's logic to do the same when loading the
"frameName" and is necessary to avoid regressing __method__
behavior inside peculiar contexts (like define_method or eval).
  • Loading branch information
headius committed Mar 28, 2024
1 parent e5fa72a commit f7dbc18
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ public ExitableReturn interpret(ThreadContext context, Block block, IRubyObject
break;
case CALL_OP:
if (profile) Profiler.updateCallSite(instr, interpreterContext.getScope(), scopeVersion);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name, block);
break;
case RET_OP:
processReturnOp(context, block, instr, operation, currDynScope, temp, self, currScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel
break;
case CALL_OP:
if (profile) Profiler.updateCallSite(instr, interpreterContext.getScope(), scopeVersion);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name, block);
break;
case RET_OP:
return processReturnOp(context, block, instr, operation, currDynScope, temp, self, currScope);
Expand Down Expand Up @@ -287,7 +287,7 @@ protected static void receiveArg(ThreadContext context, Instr i, Operation opera
}
}

protected static void processCall(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, StaticScope currScope, Object[] temp, IRubyObject self, String name) {
protected static void processCall(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, StaticScope currScope, Object[] temp, IRubyObject self, String frameName, Block selfBlock) {
Object result;

switch(operation) {
Expand Down Expand Up @@ -360,7 +360,7 @@ protected static void processCall(ThreadContext context, Instr instr, Operation
instr.interpret(context, currScope, currDynScope, self, temp);
break;
case FRAME_NAME_CALL:
setResult(temp, currDynScope, instr, ((FrameNameCallInstr) instr).getFrameName(context, self, name));
setResult(temp, currDynScope, instr, ((FrameNameCallInstr) instr).getFrameName(context, self, selfBlock == null ? frameName : selfBlock.getBinding().getFrame().getName()));
break;
case CALL:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ public IRubyObject interpret(ThreadContext context, Block block, IRubyObject sel
break;
case CALL_OP:
if (profile) Profiler.updateCallSite(instr, interpreterContext.getScope(), scopeVersion);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name, block);
break;
case RET_OP:
return processReturnOp(context, block, instr, operation, currDynScope, temp, self, currScope);
Expand Down

0 comments on commit f7dbc18

Please sign in to comment.