Skip to content

Commit 4302ab9

Browse files
committed
Frame name for module/class bodies should be null
There's no super and __method__ should return nil inside module and class bodies, so we pass null to indicate this.
1 parent f7dbc18 commit 4302ab9

File tree

6 files changed

+14
-7
lines changed

6 files changed

+14
-7
lines changed

core/src/main/java/org/jruby/internal/runtime/methods/InterpretedIRBodyMethod.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ private IRubyObject INTERPRET_CLASS(InterpreterContext ic, ThreadContext context
7171
private IRubyObject interpretWithBacktrace(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block) {
7272
try {
7373
ThreadContext.pushBacktrace(context, name, ic.getFileName(), ic.getLine());
74-
return ic.getEngine().interpret(context, null, self, ic, getImplementationClass().getMethodLocation(), name, block);
74+
return ic.getEngine().interpret(context, null, self, ic, getImplementationClass().getMethodLocation(), null, block);
7575
} finally {
7676
ThreadContext.popBacktrace(context);
7777
}

core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ private IRubyObject INTERPRET_CLASS(ThreadContext context, RubyModule clazz) {
8686

8787
try {
8888
ThreadContext.pushBacktrace(context, id, ic.getFileName(), ic.getLine());
89-
return ic.getEngine().interpret(context, null, clazz, ic, clazz.getMethodLocation(), id, Block.NULL_BLOCK);
89+
return ic.getEngine().interpret(context, null, clazz, ic, clazz.getMethodLocation(), null, Block.NULL_BLOCK);
9090
} finally {
9191
body.cleanupAfterExecution();
9292
if (!hasExplicitCallProtocol) post(ic, context);

core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ private IRubyObject INTERPRET_MODULE(ThreadContext context, RubyModule clazz) {
7777

7878
try {
7979
ThreadContext.pushBacktrace(context, id, ic.getFileName(), ic.getLine());
80-
return ic.getEngine().interpret(context, null, clazz, ic, clazz.getMethodLocation(), id, Block.NULL_BLOCK);
80+
return ic.getEngine().interpret(context, null, clazz, ic, clazz.getMethodLocation(), null, Block.NULL_BLOCK);
8181
} finally {
8282
body.cleanupAfterExecution();
8383
if (!hasExplicitCallProtocol) post(ic, context);

core/src/main/java/org/jruby/ir/instructions/FrameNameCallInstr.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ public IRubyObject getFrameName(ThreadContext context, IRubyObject self, String
5656
return frameNameSite.call(context, self, self);
5757
}
5858

59+
if (compositeName == null) return context.nil;
60+
5961
return callee ?
6062
RubySymbol.newCalleeSymbolFromCompound(context.runtime, compositeName):
6163
RubySymbol.newMethodSymbolFromCompound(context.runtime, compositeName);

core/src/main/java/org/jruby/ir/runtime/IRRuntimeHelpers.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1964,7 +1964,7 @@ public static void defCompiledInstanceMethod(ThreadContext context, MethodHandle
19641964
public static IRubyObject invokeModuleBody(ThreadContext context, DynamicMethod method) {
19651965
RubyModule implClass = method.getImplementationClass();
19661966

1967-
return method.call(context, implClass, implClass, "", Block.NULL_BLOCK);
1967+
return method.call(context, implClass, implClass, null, Block.NULL_BLOCK);
19681968
}
19691969

19701970
@JIT

core/src/main/java/org/jruby/ir/targets/indy/FrameNameSite.java

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.jruby.ir.targets.indy;
22

33
import com.headius.invokebinder.Binder;
4+
import org.jruby.RubyNil;
45
import org.jruby.RubySymbol;
56
import org.jruby.runtime.Helpers;
67
import org.jruby.runtime.ThreadContext;
@@ -58,7 +59,7 @@ public IRubyObject frameNameFallback(String name, ThreadContext context, IRubyOb
5859
if (entry.method.isBuiltin()) {
5960
target = Binder.from(type())
6061
.permute(2)
61-
.append(context.runtime.getSymbolTable())
62+
.append(context.runtime.getSymbolTable(), context.nil)
6263
.prepend(this)
6364
.invokeVirtualQuiet(methodName);
6465
} else {
@@ -72,14 +73,18 @@ public IRubyObject frameNameFallback(String name, ThreadContext context, IRubyOb
7273
return (IRubyObject) target.invokeExact(context, self, frameName);
7374
}
7475

75-
public IRubyObject __callee__(String frameName, RubySymbol.SymbolTable symbolTable) {
76+
public IRubyObject __callee__(String frameName, RubySymbol.SymbolTable symbolTable, RubyNil nil) {
77+
if (frameName == null) return nil;
78+
7679
if (frameName.charAt(0) != '\0') {
7780
return getSimpleName(frameName, symbolTable);
7881
}
7982
return symbolTable.getCalleeSymbolFromCompound(frameName);
8083
}
8184

82-
public IRubyObject __method__(String frameName, RubySymbol.SymbolTable symbolTable) {
85+
public IRubyObject __method__(String frameName, RubySymbol.SymbolTable symbolTable, RubyNil nil) {
86+
if (frameName == null) return nil;
87+
8388
if (frameName.charAt(0) != '\0') {
8489
return getSimpleName(frameName, symbolTable);
8590
}

0 commit comments

Comments
 (0)