Skip to content

Commit

Permalink
Showing 2 changed files with 13 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -34,6 +34,10 @@ public class InterpretedIRMethod extends DynamicMethod implements IRMethodArgs,

protected final IRScope method;

// For synthetic methods and for module/class bodies we do not want these added to
// our backtraces.
private boolean isSynthetic;

private static class DynamicMethodBox {
public DynamicMethod actualMethod;
public int callCount = 0;
@@ -49,6 +53,11 @@ public InterpretedIRMethod(IRScope method, Visibility visibility, RubyModule imp
if (!implementationClass.getRuntime().getInstanceConfig().getCompileMode().shouldJIT()) {
this.box.callCount = -1;
}
isSynthetic = method instanceof IRModuleBody;
}

public boolean isSynthetic() {
return isSynthetic;
}

public IRScope getIRMethod() {
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Original file line number Diff line number Diff line change
@@ -689,14 +689,15 @@ public static IRubyObject INTERPRET_BLOCK(ThreadContext context, IRubyObject sel
public static IRubyObject INTERPRET_METHOD(ThreadContext context, InterpretedIRMethod method,
IRubyObject self, String name, IRubyObject[] args, Block block) {
InterpreterContext ic = method.ensureInstrsReady();
boolean syntheticMethod = name == null || name.equals("");
// FIXME: Consider synthetic methods/module/class bodies to use different method type to eliminate this check
boolean isSynthetic = method.isSynthetic();

try {
if (!syntheticMethod) ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
if (!isSynthetic) ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

return interpret(context, self, ic, method.getVisibility(), method.getImplementationClass(), name, args, block, null);
} finally {
if (!syntheticMethod) ThreadContext.popBacktrace(context);
if (!isSynthetic) ThreadContext.popBacktrace(context);
}
}

0 comments on commit de35267

Please sign in to comment.