Skip to content

Commit

Permalink
Remove wonky name check to compensate for module/class bodies sharing…
Browse files Browse the repository at this point in the history
… InterpretedIRMethod.

Possibly provide state for real synthetic methods when we add them.
  • Loading branch information
enebo committed Oct 21, 2014
1 parent eafe2d7 commit de35267
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
Expand Up @@ -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;
Expand All @@ -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() {
Expand Down
7 changes: 4 additions & 3 deletions core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
Expand Up @@ -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);
}
}

Expand Down

0 comments on commit de35267

Please sign in to comment.