Skip to content

Commit

Permalink
Merge pull request jruby#8230 from headius/more_frame_name_fixes
Browse files Browse the repository at this point in the history
More frame name fixes
  • Loading branch information
headius authored May 8, 2024
2 parents 06053e4 + f66bd9f commit 95e8b15
Show file tree
Hide file tree
Showing 10 changed files with 21 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ protected IRubyObject callInternal(ThreadContext context, RubyModule clazz) {
ensureInstrsReady();

switch (getIRScope().getScopeType()) {
case MODULE_BODY: return Interpreter.INTERPRET_MODULE(context, getIRScope(), clazz);
case CLASS_BODY: return Interpreter.INTERPRET_CLASS(context, getIRScope(), clazz);
case METACLASS_BODY: return Interpreter.INTERPRET_METACLASS(context, getIRScope(), clazz, getVisibility());
case MODULE_BODY: return Interpreter.INTERPRET_MODULE(context, getIRScope(), clazz, name);
case CLASS_BODY: return Interpreter.INTERPRET_CLASS(context, getIRScope(), clazz, name);
case METACLASS_BODY: return Interpreter.INTERPRET_METACLASS(context, getIRScope(), clazz, name, getVisibility());
default: throw new RuntimeException("invalid body method type: " + getIRScope());
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco
RubyModule clazz = IRRuntimeHelpers.newRubyClassFromIR(context, body.getId(), body.getStaticScope(),
superClass, container, body.maybeUsingRefinements());

return Interpreter.INTERPRET_CLASS(context, body, clazz);
return Interpreter.INTERPRET_CLASS(context, body, clazz, body.getId());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco
RubyModule clazz = IRRuntimeHelpers.newRubyModuleFromIR(context, body.getId(), body.getStaticScope(), container, body.maybeUsingRefinements());


return Interpreter.INTERPRET_MODULE(context, body, clazz);
return Interpreter.INTERPRET_MODULE(context, body, clazz, body.getId());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,6 @@ public IRubyObject getFrameName(ThreadContext context, IRubyObject self, String
return frameNameSite.call(context, self, self);
}

if (compositeName == null) return context.nil;

return callee ?
RubySymbol.newCalleeSymbolFromCompound(context.runtime, compositeName):
RubySymbol.newMethodSymbolFromCompound(context.runtime, compositeName);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,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, block);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name);
break;
case RET_OP:
processReturnOp(context, block, instr, operation, currDynScope, temp, self, currScope);
Expand Down
14 changes: 7 additions & 7 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
Expand Up @@ -126,16 +126,16 @@ public static IRubyObject INTERPRET_BLOCK(ThreadContext context, Block block, IR
}
}

public static IRubyObject INTERPRET_CLASS(ThreadContext context, IRScope body, RubyModule clazz) {
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, null, null, Block.NULL_BLOCK);
public static IRubyObject INTERPRET_CLASS(ThreadContext context, IRScope body, RubyModule clazz, String name) {
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, name, null, Block.NULL_BLOCK);
}

public static IRubyObject INTERPRET_MODULE(ThreadContext context, IRScope body, RubyModule clazz) {
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, null, null, Block.NULL_BLOCK);
public static IRubyObject INTERPRET_MODULE(ThreadContext context, IRScope body, RubyModule clazz, String name) {
return interpretFrameScope(context, null, body, clazz, null, Visibility.PUBLIC, clazz, name, null, Block.NULL_BLOCK);
}

public static IRubyObject INTERPRET_METACLASS(ThreadContext context, IRScope body, RubyModule clazz, Visibility visibility) {
return interpretFrameScope(context, null, body, clazz, context.getCurrentScope(), visibility, clazz, null, null, Block.NULL_BLOCK);
public static IRubyObject INTERPRET_METACLASS(ThreadContext context, IRScope body, RubyModule clazz, String name, Visibility visibility) {
return interpretFrameScope(context, null, body, clazz, context.getCurrentScope(), visibility, clazz, name, null, Block.NULL_BLOCK);
}

public static IRubyObject INTERPRET_METHOD(ThreadContext context, IRScope body, RubyModule implClass,
Expand Down Expand Up @@ -268,7 +268,7 @@ public static IRubyObject evalWithBinding(ThreadContext context, IRubyObject sel
Frame lastFrame = context.preEvalWithBinding(binding);
try {
return evalCommon(context, evalScope, self, src, binding.getFile(),
binding.getLine(), binding.getFrame().getName(), binding.getFrame().getBlock(), EvalType.BINDING_EVAL, bindingGiven);
binding.getLine(), binding.getMethod(), binding.getFrame().getBlock(), EvalType.BINDING_EVAL, bindingGiven);
} finally {
context.postEvalWithBinding(binding, lastFrame);
}
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, block);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name);
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 frameName, Block selfBlock) {
protected static void processCall(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, StaticScope currScope, Object[] temp, IRubyObject self, String name) {
Object result;

switch(operation) {
Expand Down Expand Up @@ -360,9 +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, selfBlock == null ? frameName : IRRuntimeHelpers.getFrameNameFromBlock(selfBlock)));
setResult(temp, currDynScope, instr, ((FrameNameCallInstr) instr).getFrameName(context, self, name));
break;
case CALL:
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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, block);
processCall(context, instr, operation, currDynScope, currScope, temp, self, name);
break;
case RET_OP:
return processReturnOp(context, block, instr, operation, currDynScope, temp, self, currScope);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1925,7 +1925,7 @@ public static void defCompiledInstanceMethod(ThreadContext context, MethodHandle
public static IRubyObject invokeModuleBody(ThreadContext context, DynamicMethod method) {
RubyModule implClass = method.getImplementationClass();

return method.call(context, implClass, implClass, null, Block.NULL_BLOCK);
return method.call(context, implClass, implClass, "", Block.NULL_BLOCK);
}

@JIT
Expand Down
11 changes: 3 additions & 8 deletions core/src/main/java/org/jruby/ir/targets/indy/FrameNameSite.java
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.jruby.ir.targets.indy;

import com.headius.invokebinder.Binder;
import org.jruby.RubyNil;
import org.jruby.RubySymbol;
import org.jruby.runtime.Helpers;
import org.jruby.runtime.ThreadContext;
Expand Down Expand Up @@ -59,7 +58,7 @@ public IRubyObject frameNameFallback(String name, ThreadContext context, IRubyOb
if (entry.method.isBuiltin()) {
target = Binder.from(type())
.permute(2)
.append(context.runtime.getSymbolTable(), context.nil)
.append(context.runtime.getSymbolTable())
.prepend(this)
.invokeVirtualQuiet(methodName);
} else {
Expand All @@ -73,18 +72,14 @@ public IRubyObject frameNameFallback(String name, ThreadContext context, IRubyOb
return (IRubyObject) target.invokeExact(context, self, frameName);
}

public IRubyObject __callee__(String frameName, RubySymbol.SymbolTable symbolTable, RubyNil nil) {
if (frameName == null) return nil;

public IRubyObject __callee__(String frameName, RubySymbol.SymbolTable symbolTable) {
if (frameName.charAt(0) != '\0') {
return getSimpleName(frameName, symbolTable);
}
return symbolTable.getCalleeSymbolFromCompound(frameName);
}

public IRubyObject __method__(String frameName, RubySymbol.SymbolTable symbolTable, RubyNil nil) {
if (frameName == null) return nil;

public IRubyObject __method__(String frameName, RubySymbol.SymbolTable symbolTable) {
if (frameName.charAt(0) != '\0') {
return getSimpleName(frameName, symbolTable);
}
Expand Down

0 comments on commit 95e8b15

Please sign in to comment.