Skip to content

Commit

Permalink
Showing 10 changed files with 67 additions and 59 deletions.
Original file line number Diff line number Diff line change
@@ -69,7 +69,7 @@ private IRubyObject INTERPRET_CLASS(InterpreterContext ic, ThreadContext context
private IRubyObject interpretWithBacktrace(InterpreterContext ic, ThreadContext context, IRubyObject self, String name, Block block) {
try {
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
return ic.engine.interpret(context, self, ic, getImplementationClass().getMethodLocation(), name, block, null);
return ic.engine.interpret(context, null, self, ic, getImplementationClass().getMethodLocation(), name, block);
} finally {
ThreadContext.popBacktrace(context);
}
Original file line number Diff line number Diff line change
@@ -115,11 +115,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} finally {
post(ic, context);
}
@@ -144,11 +144,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} finally {
post(ic, context);
}
@@ -172,11 +172,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} finally {
post(ic, context);
}
@@ -200,11 +200,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} finally {
post(ic, context);
}
@@ -228,11 +228,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} else {
try {
pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} finally {
post(ic, context);
}
Original file line number Diff line number Diff line change
@@ -120,11 +120,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, args, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, args, block);
} finally {
this.post(ic, context);
}
@@ -155,11 +155,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, block);
} finally {
this.post(ic, context);
}
@@ -190,11 +190,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, block);
} finally {
this.post(ic, context);
}
@@ -225,11 +225,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, block);
} finally {
this.post(ic, context);
}
@@ -260,11 +260,11 @@ private IRubyObject INTERPRET_METHOD(ThreadContext context, InterpreterContext i
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());

if (ic.hasExplicitCallProtocol()) {
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} else {
try {
this.pre(ic, context, self, name, block, implClass);
return ic.engine.interpret(context, self, ic, implClass, name, arg1, arg2, arg3, block, null);
return ic.engine.interpret(context, null, self, ic, implClass, name, arg1, arg2, arg3, block);
} finally {
this.post(ic, context);
}
Original file line number Diff line number Diff line change
@@ -32,12 +32,13 @@
*/
public class BodyInterpreterEngine extends InterpreterEngine {
@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
@@ -213,7 +214,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
}

@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject[] args, Block blockArg, Block.Type blockType) {
return interpret(context, self, interpreterContext, implClass, name, blockArg, blockType);
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject[] args, Block blockArg) {
return interpret(context, block, self, interpreterContext, implClass, name, blockArg);
}
}
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
@@ -99,27 +99,27 @@ public static IRubyObject INTERPRET_ROOT(ThreadContext context, IRubyObject self
InterpreterContext ic, RubyModule clazz, String name) {
try {
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
return ic.engine.interpret(context, self, ic, clazz, name, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK, null);
return ic.engine.interpret(context, null, self, ic, clazz, name, IRubyObject.NULL_ARRAY, Block.NULL_BLOCK);
} finally {
ThreadContext.popBacktrace(context);
}
}

public static IRubyObject INTERPRET_EVAL(ThreadContext context, IRubyObject self,
InterpreterContext ic, RubyModule clazz, IRubyObject[] args, String name, Block blockArg, Block.Type blockType) {
InterpreterContext ic, RubyModule clazz, IRubyObject[] args, String name, Block blockArg) {
try {
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
return ic.engine.interpret(context, self, ic, clazz, name, args, blockArg, blockType);
return ic.engine.interpret(context, null, self, ic, clazz, name, args, blockArg);
} finally {
ThreadContext.popBacktrace(context);
}
}

public static IRubyObject INTERPRET_BLOCK(ThreadContext context, IRubyObject self,
InterpreterContext ic, IRubyObject[] args, String name, Block blockArg, Block.Type blockType) {
public static IRubyObject INTERPRET_BLOCK(ThreadContext context, Block block, IRubyObject self,
InterpreterContext ic, IRubyObject[] args, String name, Block blockArg) {
try {
ThreadContext.pushBacktrace(context, name, ic.getFileName(), context.getLine());
return ic.engine.interpret(context, self, ic, null, name, args, blockArg, blockType);
return ic.engine.interpret(context, block, self, ic, null, name, args, blockArg);
} finally {
ThreadContext.popBacktrace(context);
}
@@ -164,7 +164,7 @@ private static IRubyObject evalCommon(ThreadContext context, DynamicScope evalSc

runBeginBlocks(ic.getBeginBlocks(), context, self, ss, null);

return Interpreter.INTERPRET_EVAL(context, self, ic, ic.getStaticScope().getModule(), IRubyObject.NULL_ARRAY, name, blockArg, null);
return Interpreter.INTERPRET_EVAL(context, self, ic, ic.getStaticScope().getModule(), IRubyObject.NULL_ARRAY, name, blockArg);
} finally {
evalScope.clearEvalType();
context.popScope();
35 changes: 18 additions & 17 deletions core/src/main/java/org/jruby/ir/interpreter/InterpreterEngine.java
Original file line number Diff line number Diff line change
@@ -71,39 +71,39 @@
*/
public class InterpreterEngine {

public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, Block blockArg, Block.Type blockType) {
return interpret(context, self, interpreterContext, implClass, name, IRubyObject.NULL_ARRAY, blockArg, blockType);
String name, Block blockArg) {
return interpret(context, block, self, interpreterContext, implClass, name, IRubyObject.NULL_ARRAY, blockArg);
}

public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject arg1, Block blockArg, Block.Type blockType) {
return interpret(context, self, interpreterContext, implClass, name, new IRubyObject[] {arg1}, blockArg, blockType);
String name, IRubyObject arg1, Block blockArg) {
return interpret(context, block, self, interpreterContext, implClass, name, new IRubyObject[] {arg1}, blockArg);
}

public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject arg1, IRubyObject arg2, Block blockArg, Block.Type blockType) {
return interpret(context, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2}, blockArg, blockType);
String name, IRubyObject arg1, IRubyObject arg2, Block blockArg) {
return interpret(context, block, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2}, blockArg);
}

public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block blockArg, Block.Type blockType) {
return interpret(context, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2, arg3}, blockArg, blockType);
String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block blockArg) {
return interpret(context, block, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2, arg3}, blockArg);
}

public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, Block blockArg, Block.Type blockType) {
return interpret(context, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2, arg3, arg4}, blockArg, blockType);
String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, Block blockArg) {
return interpret(context, block, self, interpreterContext, implClass, name, new IRubyObject[] {arg1, arg2, arg3, arg4}, blockArg);
}

public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject[] args, Block blockArg, Block.Type blockType) {
String name, IRubyObject[] args, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
double[] floats = interpreterContext.allocateTemporaryFloatVariables();
@@ -112,6 +112,7 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self,
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

if (interpreterContext.receivesKeywordArguments()) IRRuntimeHelpers.frobnicateKwargsArgument(context, interpreterContext.getRequiredArgsCount(), args);

Original file line number Diff line number Diff line change
@@ -68,18 +68,19 @@ public class SimpleMethodInterpreterEngine extends InterpreterEngine {
put(Operation.CONST_MISSING, true);
}};
@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, Block blockArg) {
// Just use any interp since it will contain no recvs
return interpret(context, self, interpreterContext, implClass, name, (IRubyObject) null, blockArg, blockType);
return interpret(context, block, self, interpreterContext, implClass, name, (IRubyObject) null, blockArg);
}

@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
@@ -268,12 +269,13 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
}

@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, IRubyObject arg2, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, IRubyObject arg2, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
@@ -469,12 +471,13 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
}

@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
@@ -671,12 +674,13 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
}

@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject arg1, IRubyObject arg2, IRubyObject arg3, IRubyObject arg4, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
@@ -874,12 +878,13 @@ public IRubyObject interpret(ThreadContext context, IRubyObject self, Interprete
}

@Override
public IRubyObject interpret(ThreadContext context, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject[] args, Block blockArg, Block.Type blockType) {
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self, InterpreterContext interpreterContext, RubyModule implClass, String name, IRubyObject[] args, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

StaticScope currScope = interpreterContext.getStaticScope();
DynamicScope currDynScope = context.getCurrentScope();
Original file line number Diff line number Diff line change
@@ -30,14 +30,15 @@
* This interpreter is meant to interpret the instructions generated directly from IRBuild.
*/
public class StartupInterpreterEngine extends InterpreterEngine {
public IRubyObject interpret(ThreadContext context, IRubyObject self,
public IRubyObject interpret(ThreadContext context, Block block, IRubyObject self,
InterpreterContext interpreterContext, RubyModule implClass,
String name, IRubyObject[] args, Block blockArg, Block.Type blockType) {
String name, IRubyObject[] args, Block blockArg) {
Instr[] instrs = interpreterContext.getInstructions();
Object[] temp = interpreterContext.allocateTemporaryVariables();
int n = instrs.length;
int ipc = 0;
Object exception = null;
Block.Type blockType = block == null ? null : block.type;

if (interpreterContext.receivesKeywordArguments()) IRRuntimeHelpers.frobnicateKwargsArgument(context, interpreterContext.getRequiredArgsCount(), args);

Original file line number Diff line number Diff line change
@@ -114,7 +114,7 @@ protected IRubyObject commonYieldPath(ThreadContext context, Block block, IRubyO
this.evalType.set(EvalType.NONE);

try {
return Interpreter.INTERPRET_BLOCK(context, self, ic, args, binding.getMethod(), blockArg, block.type);
return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, binding.getMethod(), blockArg);
}
finally {
// IMPORTANT: Do not clear eval-type in case this is reused in bindings!
Original file line number Diff line number Diff line change
@@ -133,7 +133,7 @@ protected IRubyObject commonYieldPath(ThreadContext context, Block block, IRubyO
this.evalType.set(EvalType.NONE);

try {
return Interpreter.INTERPRET_BLOCK(context, self, ic, args, binding.getMethod(), blockArg, block.type);
return Interpreter.INTERPRET_BLOCK(context, block, self, ic, args, binding.getMethod(), blockArg);
}
finally {
// IMPORTANT: Do not clear eval-type in case this is reused in bindings!

0 comments on commit 6f62dda

Please sign in to comment.