Skip to content

Instantly share code, notes, and snippets.

@headius
Created July 6, 2014 05:20
Show Gist options
  • Save headius/fad70bf08a1ebc96dc68 to your computer and use it in GitHub Desktop.
Save headius/fad70bf08a1ebc96dc68 to your computer and use it in GitHub Desktop.
Patch to use a pooled Object[] in IR interpreter in JRuby
diff --git a/core/src/main/java/org/jruby/ir/IRScriptBody.java b/core/src/main/java/org/jruby/ir/IRScriptBody.java
index bdbd656..bc59880 100644
--- a/core/src/main/java/org/jruby/ir/IRScriptBody.java
+++ b/core/src/main/java/org/jruby/ir/IRScriptBody.java
@@ -108,9 +108,9 @@ public class IRScriptBody extends IRScope {
context.preMethodScopeOnly(currModule, scope);
context.setCurrentVisibility(Visibility.PRIVATE);
- Interpreter.runBeginEndBlocks(getBeginBlocks(), context, self, null);
+ Interpreter.runBeginEndBlocks(getBeginBlocks(), context, self, null, -1);
retVal = Interpreter.INTERPRET_ROOT(context, self, this, currModule, name);
- Interpreter.runBeginEndBlocks(getEndBlocks(), context, self, null);
+ Interpreter.runBeginEndBlocks(getEndBlocks(), context, self, null, -1);
Interpreter.dumpStats();
} catch (IRBreakJump bj) {
diff --git a/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java b/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
index 694212a..353dd0e 100644
--- a/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
@@ -53,9 +53,9 @@ public class AliasInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- String newNameString = getNewName().retrieve(context, self, currDynScope, temp).toString();
- String oldNameString = getOldName().retrieve(context, self, currDynScope, temp).toString();
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ String newNameString = getNewName().retrieve(context, self, currDynScope, temp, tempStart).toString();
+ String oldNameString = getOldName().retrieve(context, self, currDynScope, temp, tempStart).toString();
IRRuntimeHelpers.defineAlias(context, self, currDynScope, newNameString, oldNameString);
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java b/core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java
index ff27132..e6e709a 100644
--- a/core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java
@@ -43,9 +43,9 @@ public class AttrAssignInstr extends NoResultCallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
- IRubyObject[] values = prepareArguments(context, self, getCallArgs(), dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
+ IRubyObject[] values = prepareArguments(context, self, getCallArgs(), dynamicScope, temp, tempStart);
CallType callType = self == object ? CallType.FUNCTIONAL : CallType.NORMAL;
Helpers.invoke(context, object, getMethodAddr().getName(), values, callType, Block.NULL_BLOCK);
diff --git a/core/src/main/java/org/jruby/ir/instructions/BEQInstr.java b/core/src/main/java/org/jruby/ir/instructions/BEQInstr.java
index d4b72e7..9c0e2fe 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BEQInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BEQInstr.java
@@ -32,9 +32,9 @@ public class BEQInstr extends TwoOperandBranchInstr implements FixedArityInstr {
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
- Object value2 = getArg2().retrieve(context, self, currDynScope, temp);
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ Object value1 = getArg1().retrieve(context, self, currDynScope, temp, tempStart);
+ Object value2 = getArg2().retrieve(context, self, currDynScope, temp, tempStart);
return ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue() ? getJumpTarget().getTargetPC() : ipc;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BFalseInstr.java b/core/src/main/java/org/jruby/ir/instructions/BFalseInstr.java
index 59a09bf..34ce953 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BFalseInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BFalseInstr.java
@@ -29,8 +29,8 @@ public class BFalseInstr extends OneOperandBranchInstr implements FixedArityInst
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ Object value1 = getArg1().retrieve(context, self, currDynScope, temp, tempStart);
return !((IRubyObject)value1).isTrue() ? getJumpTarget().getTargetPC() : ipc;
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BNEInstr.java b/core/src/main/java/org/jruby/ir/instructions/BNEInstr.java
index 8fe40bf..b0a5aa9 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BNEInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BNEInstr.java
@@ -30,9 +30,9 @@ public class BNEInstr extends TwoOperandBranchInstr implements FixedArityInstr {
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
- Object value2 = getArg2().retrieve(context, self, currDynScope, temp);
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ Object value1 = getArg1().retrieve(context, self, currDynScope, temp, tempStart);
+ Object value2 = getArg2().retrieve(context, self, currDynScope, temp, tempStart);
boolean eql = getArg2() == context.getRuntime().getIRManager().getNil() || getArg2() == UndefinedValue.UNDEFINED ?
value1 == value2 : ((IRubyObject) value1).op_equal(context, (IRubyObject)value2).isTrue();
return !eql ? getJumpTarget().getTargetPC() : ipc;
diff --git a/core/src/main/java/org/jruby/ir/instructions/BNilInstr.java b/core/src/main/java/org/jruby/ir/instructions/BNilInstr.java
index 0759106..4409559 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BNilInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BNilInstr.java
@@ -25,8 +25,8 @@ public class BNilInstr extends OneOperandBranchInstr implements FixedArityInstr
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ Object value1 = getArg1().retrieve(context, self, currDynScope, temp, tempStart);
return value1 == context.nil ? getJumpTarget().getTargetPC() : ipc;
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BTrueInstr.java b/core/src/main/java/org/jruby/ir/instructions/BTrueInstr.java
index ece09d7..f6a81df 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BTrueInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BTrueInstr.java
@@ -29,8 +29,8 @@ public class BTrueInstr extends OneOperandBranchInstr implements FixedArityInstr
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ Object value1 = getArg1().retrieve(context, self, currDynScope, temp, tempStart);
return ((IRubyObject)value1).isTrue() ? getJumpTarget().getTargetPC() : ipc;
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BUndefInstr.java b/core/src/main/java/org/jruby/ir/instructions/BUndefInstr.java
index 0836eb3..5a0e0fa 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BUndefInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BUndefInstr.java
@@ -21,8 +21,8 @@ public class BUndefInstr extends OneOperandBranchInstr implements FixedArityIns
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- Object value1 = getArg1().retrieve(context, self, currDynScope, temp);
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ Object value1 = getArg1().retrieve(context, self, currDynScope, temp, tempStart);
return value1 == UndefinedValue.UNDEFINED ? getJumpTarget().getTargetPC() : ipc;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BacktickInstr.java b/core/src/main/java/org/jruby/ir/instructions/BacktickInstr.java
index 1d208b1..82c3268 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BacktickInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BacktickInstr.java
@@ -73,11 +73,11 @@ public class BacktickInstr extends Instr implements ResultInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
RubyString newString = context.runtime.newString();
for (Operand p: pieces) {
- RubyBasicObject piece = (RubyBasicObject) p.retrieve(context, self, currDynScope, temp);
+ RubyBasicObject piece = (RubyBasicObject) p.retrieve(context, self, currDynScope, temp, tempStart);
newString.append((piece instanceof RubyString) ? (RubyString) piece : piece.to_s());
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BlockGivenInstr.java b/core/src/main/java/org/jruby/ir/instructions/BlockGivenInstr.java
index caf2d96..46447c9 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BlockGivenInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BlockGivenInstr.java
@@ -55,8 +55,8 @@ public class BlockGivenInstr extends Instr implements ResultInstr, FixedArityIns
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- Object blk = (Object) blockArg.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ Object blk = (Object) blockArg.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.isBlockGiven(context, blk);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BuildCompoundArrayInstr.java b/core/src/main/java/org/jruby/ir/instructions/BuildCompoundArrayInstr.java
index 1874bd6..c9910cf 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BuildCompoundArrayInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BuildCompoundArrayInstr.java
@@ -79,9 +79,9 @@ public class BuildCompoundArrayInstr extends Instr implements ResultInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject v1 = (IRubyObject)a1.retrieve(context, self, currDynScope, temp);
- IRubyObject v2 = (IRubyObject)a2.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject v1 = (IRubyObject)a1.retrieve(context, self, currDynScope, temp, tempStart);
+ IRubyObject v2 = (IRubyObject)a2.retrieve(context, self, currDynScope, temp, tempStart);
return isArgsPush ? Helpers.argsPush((RubyArray) v1, v2) : Helpers.argsCat(v1, v2);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/BuildLambdaInstr.java b/core/src/main/java/org/jruby/ir/instructions/BuildLambdaInstr.java
index f9f769a..309dec1 100644
--- a/core/src/main/java/org/jruby/ir/instructions/BuildLambdaInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/BuildLambdaInstr.java
@@ -74,7 +74,7 @@ public class BuildLambdaInstr extends Instr implements ResultInstr, FixedArityIn
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
// SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well?
//
// JRUBY-5686: do this before executing so first time sets cref module
@@ -84,7 +84,7 @@ public class BuildLambdaInstr extends Instr implements ResultInstr, FixedArityIn
// ENEBO: Now can live nil be passed as block reference?
// SSS FIXME: Should we do the same %self retrieval as in the case of WrappedIRClosure? Or are lambdas special??
return RubyProc.newProc(context.runtime,
- (Block) (body == null ? context.runtime.getIRManager().getNil() : getLambdaBody()).retrieve(context, self, currDynScope, temp),
+ (Block) (body == null ? context.runtime.getIRManager().getNil() : getLambdaBody()).retrieve(context, self, currDynScope, temp, tempStart),
Block.Type.LAMBDA, position);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/CallBase.java b/core/src/main/java/org/jruby/ir/instructions/CallBase.java
index 24a806b..a37c8df 100644
--- a/core/src/main/java/org/jruby/ir/instructions/CallBase.java
+++ b/core/src/main/java/org/jruby/ir/instructions/CallBase.java
@@ -386,38 +386,38 @@ public abstract class CallBase extends Instr implements Specializeable, ClosureA
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
- IRubyObject[] values = prepareArguments(context, self, arguments, dynamicScope, temp);
- Block preparedBlock = prepareBlock(context, self, dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
+ IRubyObject[] values = prepareArguments(context, self, arguments, dynamicScope, temp, tempStart);
+ Block preparedBlock = prepareBlock(context, self, dynamicScope, temp, tempStart);
return callSite.call(context, self, object, values, preparedBlock);
}
- protected IRubyObject[] prepareArguments(ThreadContext context, IRubyObject self, Operand[] arguments, DynamicScope dynamicScope, Object[] temp) {
+ protected IRubyObject[] prepareArguments(ThreadContext context, IRubyObject self, Operand[] arguments, DynamicScope dynamicScope, Object[] temp, int tempStart) {
return containsArgSplat ?
- prepareArgumentsComplex(context, self, arguments, dynamicScope, temp) :
- prepareArgumentsSimple(context, self, arguments, dynamicScope, temp);
+ prepareArgumentsComplex(context, self, arguments, dynamicScope, temp, tempStart) :
+ prepareArgumentsSimple(context, self, arguments, dynamicScope, temp, tempStart);
}
- protected IRubyObject[] prepareArgumentsSimple(ThreadContext context, IRubyObject self, Operand[] args, DynamicScope currDynScope, Object[] temp) {
+ protected IRubyObject[] prepareArgumentsSimple(ThreadContext context, IRubyObject self, Operand[] args, DynamicScope currDynScope, Object[] temp, int tempStart) {
IRubyObject[] newArgs = new IRubyObject[args.length];
for (int i = 0; i < args.length; i++) {
- newArgs[i] = (IRubyObject) args[i].retrieve(context, self, currDynScope, temp);
+ newArgs[i] = (IRubyObject) args[i].retrieve(context, self, currDynScope, temp, tempStart);
}
return newArgs;
}
- protected IRubyObject[] prepareArgumentsComplex(ThreadContext context, IRubyObject self, Operand[] args, DynamicScope currDynScope, Object[] temp) {
+ protected IRubyObject[] prepareArgumentsComplex(ThreadContext context, IRubyObject self, Operand[] args, DynamicScope currDynScope, Object[] temp, int tempStart) {
// SSS: For regular calls, IR builder never introduces splats except as the first argument
// But when zsuper is converted to SuperInstr with known args, splats can appear anywhere
// in the list. So, this looping handles both these scenarios, although if we wanted to
// optimize for CallInstr which has splats only in the first position, we could do that.
List<IRubyObject> argList = new ArrayList<IRubyObject>();
for (Operand arg : args) {
- IRubyObject rArg = (IRubyObject) arg.retrieve(context, self, currDynScope, temp);
+ IRubyObject rArg = (IRubyObject) arg.retrieve(context, self, currDynScope, temp, tempStart);
if (arg instanceof Splat) {
argList.addAll(Arrays.asList(((RubyArray) rArg).toJavaArray()));
} else {
@@ -428,10 +428,10 @@ public abstract class CallBase extends Instr implements Specializeable, ClosureA
return argList.toArray(new IRubyObject[argList.size()]);
}
- public Block prepareBlock(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Block prepareBlock(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
if (closure == null) return Block.NULL_BLOCK;
- return IRRuntimeHelpers.getBlockFromObject(context, closure.retrieve(context, self, currDynScope, temp));
+ return IRRuntimeHelpers.getBlockFromObject(context, closure.retrieve(context, self, currDynScope, temp, tempStart));
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/CheckArgsArrayArityInstr.java b/core/src/main/java/org/jruby/ir/instructions/CheckArgsArrayArityInstr.java
index e220b93..3e3d1f0 100644
--- a/core/src/main/java/org/jruby/ir/instructions/CheckArgsArrayArityInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/CheckArgsArrayArityInstr.java
@@ -53,8 +53,8 @@ public class CheckArgsArrayArityInstr extends Instr implements FixedArityInstr
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- RubyArray args = (RubyArray) argsArray.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ RubyArray args = (RubyArray) argsArray.retrieve(context, self, currDynScope, temp, tempStart);
Helpers.irCheckArgsArrayArity(context, args, required, opt, rest);
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/ClassSuperInstr.java b/core/src/main/java/org/jruby/ir/instructions/ClassSuperInstr.java
index c86f79f..c77b0c9 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ClassSuperInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ClassSuperInstr.java
@@ -44,11 +44,11 @@ public class ClassSuperInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp);
- Block block = prepareBlock(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp, tempStart);
+ Block block = prepareBlock(context, self, currDynScope, temp, tempStart);
String methodName = methAddr.getName();
- RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currDynScope, temp);
+ RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currDynScope, temp, tempStart);
RubyClass superClass = definingModule.getMetaClass().getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE;
Object rVal = method.isUndefined() ? Helpers.callMethodMissing(context, self, method.getVisibility(), methodName, CallType.SUPER, args, block)
diff --git a/core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java b/core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java
index 4b2ce61..22a8e90 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java
@@ -54,8 +54,8 @@ public class ConstMissingInstr extends CallInstr implements ResultInstr, FixedAr
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- RubyModule module = (RubyModule) receiver.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ RubyModule module = (RubyModule) receiver.retrieve(context, self, currDynScope, temp, tempStart);
return module.callMethod(context, "const_missing", context.runtime.fastNewSymbol(missingConst));
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java b/core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java
index 8b5c45d..e5556d4 100644
--- a/core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java
@@ -68,14 +68,14 @@ public class DefineClassInstr extends Instr implements ResultInstr, FixedArityIn
return new DefineClassInstr(ii.getRenamedVariable(result), this.newIRClassBody, container.cloneForInlining(ii), superClass.cloneForInlining(ii));
}
- private RubyModule newClass(ThreadContext context, IRubyObject self, RubyModule classContainer, DynamicScope currDynScope, Object[] temp) {
+ private RubyModule newClass(ThreadContext context, IRubyObject self, RubyModule classContainer, DynamicScope currDynScope, Object[] temp, int tempStart) {
if (newIRClassBody instanceof IRMetaClassBody) return classContainer.getMetaClass();
RubyClass sc;
if (superClass == UndefinedValue.UNDEFINED) {
sc = null;
} else {
- Object o = superClass.retrieve(context, self, currDynScope, temp);
+ Object o = superClass.retrieve(context, self, currDynScope, temp, tempStart);
RubyClass.checkInheritable((IRubyObject) o);
@@ -86,14 +86,14 @@ public class DefineClassInstr extends Instr implements ResultInstr, FixedArityIn
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- Object rubyContainer = container.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ Object rubyContainer = container.retrieve(context, self, currDynScope, temp, tempStart);
if (!(rubyContainer instanceof RubyModule)) {
throw context.runtime.newTypeError("no outer class/module");
}
- RubyModule newRubyClass = newClass(context, self, (RubyModule) rubyContainer, currDynScope, temp);
+ RubyModule newRubyClass = newClass(context, self, (RubyModule) rubyContainer, currDynScope, temp, tempStart);
newIRClassBody.getStaticScope().setModule(newRubyClass);
return new InterpretedIRMethod(newIRClassBody, Visibility.PUBLIC, newRubyClass);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/DefineClassMethodInstr.java b/core/src/main/java/org/jruby/ir/instructions/DefineClassMethodInstr.java
index 99d3348..73b9190 100644
--- a/core/src/main/java/org/jruby/ir/instructions/DefineClassMethodInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/DefineClassMethodInstr.java
@@ -60,10 +60,10 @@ public class DefineClassMethodInstr extends Instr implements FixedArityInstr {
// SSS FIXME: Go through this and DefineInstanceMethodInstr.interpret, clean up, extract common code
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
String name = method.getName();
Ruby runtime = context.runtime;
- IRubyObject obj = (IRubyObject) container.retrieve(context, self, currDynScope, temp);
+ IRubyObject obj = (IRubyObject) container.retrieve(context, self, currDynScope, temp, tempStart);
if (obj instanceof RubyFixnum || obj instanceof RubySymbol) {
throw runtime.newTypeError("can't define singleton method \"" + name + "\" for " + obj.getMetaClass().getBaseName());
diff --git a/core/src/main/java/org/jruby/ir/instructions/DefineInstanceMethodInstr.java b/core/src/main/java/org/jruby/ir/instructions/DefineInstanceMethodInstr.java
index 3839bfe..0cb65d9 100644
--- a/core/src/main/java/org/jruby/ir/instructions/DefineInstanceMethodInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/DefineInstanceMethodInstr.java
@@ -56,7 +56,7 @@ public class DefineInstanceMethodInstr extends Instr implements FixedArityInstr
// SSS FIXME: Go through this and DefineClassMethodInstr.interpret, clean up, extract common code
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
Ruby runtime = context.runtime;
RubyModule clazz = IRRuntimeHelpers.findInstanceMethodContainer(context, currDynScope, self);
diff --git a/core/src/main/java/org/jruby/ir/instructions/DefineMetaClassInstr.java b/core/src/main/java/org/jruby/ir/instructions/DefineMetaClassInstr.java
index 2a1f22f..a28a406 100644
--- a/core/src/main/java/org/jruby/ir/instructions/DefineMetaClassInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/DefineMetaClassInstr.java
@@ -76,9 +76,9 @@ public class DefineMetaClassInstr extends Instr implements ResultInstr, FixedAri
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
Ruby runtime = context.runtime;
- IRubyObject obj = (IRubyObject)object.retrieve(context, self, currDynScope, temp);
+ IRubyObject obj = (IRubyObject)object.retrieve(context, self, currDynScope, temp, tempStart);
RubyClass singletonClass = Helpers.getSingletonClass(runtime, obj);
metaClassBody.getStaticScope().setModule(singletonClass);
diff --git a/core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java b/core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java
index 2de3659..d3f374d 100644
--- a/core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java
@@ -62,8 +62,8 @@ public class DefineModuleInstr extends Instr implements ResultInstr, FixedArityI
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- Object rubyContainer = container.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ Object rubyContainer = container.retrieve(context, self, currDynScope, temp, tempStart);
if (!(rubyContainer instanceof RubyModule)) {
throw context.runtime.newTypeError("no outer class/module");
diff --git a/core/src/main/java/org/jruby/ir/instructions/EQQInstr.java b/core/src/main/java/org/jruby/ir/instructions/EQQInstr.java
index 49d9d8d..3a6c2af 100644
--- a/core/src/main/java/org/jruby/ir/instructions/EQQInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/EQQInstr.java
@@ -69,9 +69,9 @@ public class EQQInstr extends Instr implements ResultInstr, FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject receiver = (IRubyObject) arg1.retrieve(context, self, currDynScope, temp);
- IRubyObject value = (IRubyObject) arg2.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject receiver = (IRubyObject) arg1.retrieve(context, self, currDynScope, temp, tempStart);
+ IRubyObject value = (IRubyObject) arg2.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.isEQQ(context, receiver, value);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/GVarAliasInstr.java b/core/src/main/java/org/jruby/ir/instructions/GVarAliasInstr.java
index 55333eb..cf698ba 100644
--- a/core/src/main/java/org/jruby/ir/instructions/GVarAliasInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/GVarAliasInstr.java
@@ -51,9 +51,9 @@ public class GVarAliasInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- String newNameString = newName.retrieve(context, self, currDynScope, temp).toString();
- String oldNameString = oldName.retrieve(context, self, currDynScope, temp).toString();
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ String newNameString = newName.retrieve(context, self, currDynScope, temp, tempStart).toString();
+ String oldNameString = oldName.retrieve(context, self, currDynScope, temp, tempStart).toString();
context.runtime.getGlobalVariables().alias(newNameString, oldNameString);
return null;
diff --git a/core/src/main/java/org/jruby/ir/instructions/GetClassVarContainerModuleInstr.java b/core/src/main/java/org/jruby/ir/instructions/GetClassVarContainerModuleInstr.java
index 39abb9a..1fa60b1 100644
--- a/core/src/main/java/org/jruby/ir/instructions/GetClassVarContainerModuleInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/GetClassVarContainerModuleInstr.java
@@ -75,12 +75,12 @@ public class GetClassVarContainerModuleInstr extends Instr implements ResultInst
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- StaticScope scope = (StaticScope) startingScope.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ StaticScope scope = (StaticScope) startingScope.retrieve(context, self, currDynScope, temp, tempStart);
IRubyObject arg =
object == null ?
null :
- (IRubyObject) object.retrieve(context, self, currDynScope, temp);
+ (IRubyObject) object.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.getModuleFromScope(context, scope, arg);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/GetClassVariableInstr.java b/core/src/main/java/org/jruby/ir/instructions/GetClassVariableInstr.java
index c540f98..80f6750 100644
--- a/core/src/main/java/org/jruby/ir/instructions/GetClassVariableInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/GetClassVariableInstr.java
@@ -22,8 +22,8 @@ public class GetClassVariableInstr extends GetInstr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- return ((RubyModule) getSource().retrieve(context, self, currDynScope, temp)).getClassVar(getRef());
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ return ((RubyModule) getSource().retrieve(context, self, currDynScope, temp, tempStart)).getClassVar(getRef());
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/instructions/GetEncodingInstr.java b/core/src/main/java/org/jruby/ir/instructions/GetEncodingInstr.java
index 7f41ff1..b892c0c 100644
--- a/core/src/main/java/org/jruby/ir/instructions/GetEncodingInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/GetEncodingInstr.java
@@ -50,7 +50,7 @@ public class GetEncodingInstr extends Instr implements ResultInstr, FixedArityIn
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
return context.runtime.getEncodingService().getEncoding(encoding);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/GetGlobalVariableInstr.java b/core/src/main/java/org/jruby/ir/instructions/GetGlobalVariableInstr.java
index 78a4c02..fd6b7fc 100644
--- a/core/src/main/java/org/jruby/ir/instructions/GetGlobalVariableInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/GetGlobalVariableInstr.java
@@ -45,8 +45,8 @@ public class GetGlobalVariableInstr extends GetInstr implements FixedArityInstr
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- return getSource().retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ return getSource().retrieve(context, self, currDynScope, temp, tempStart);
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/instructions/InheritanceSearchConstInstr.java b/core/src/main/java/org/jruby/ir/instructions/InheritanceSearchConstInstr.java
index 85b0a1e..1781304 100644
--- a/core/src/main/java/org/jruby/ir/instructions/InheritanceSearchConstInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/InheritanceSearchConstInstr.java
@@ -93,9 +93,9 @@ public class InheritanceSearchConstInstr extends Instr implements ResultInstr, F
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
Ruby runtime = context.runtime;
- Object cmVal = currentModule.retrieve(context, self, currDynScope, temp);
+ Object cmVal = currentModule.retrieve(context, self, currDynScope, temp, tempStart);
RubyModule module;
if (cmVal instanceof RubyModule) {
module = (RubyModule) cmVal;
diff --git a/core/src/main/java/org/jruby/ir/instructions/InstanceSuperInstr.java b/core/src/main/java/org/jruby/ir/instructions/InstanceSuperInstr.java
index 6d5b6a5..bd221c2 100644
--- a/core/src/main/java/org/jruby/ir/instructions/InstanceSuperInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/InstanceSuperInstr.java
@@ -44,11 +44,11 @@ public class InstanceSuperInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp);
- Block block = prepareBlock(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp, tempStart);
+ Block block = prepareBlock(context, self, currDynScope, temp, tempStart);
String methodName = methAddr.getName();
- RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currDynScope, temp);
+ RubyModule definingModule = (RubyModule) getDefiningModule().retrieve(context, self, currDynScope, temp, tempStart);
RubyClass superClass = definingModule.getSuperClass();
DynamicMethod method = superClass != null ? superClass.searchMethod(methodName) : UndefinedMethod.INSTANCE;
Object rVal = method.isUndefined() ? Helpers.callMethodMissing(context, self, method.getVisibility(), methodName, CallType.SUPER, args, block)
diff --git a/core/src/main/java/org/jruby/ir/instructions/Instr.java b/core/src/main/java/org/jruby/ir/instructions/Instr.java
index ce179f5..f409d40 100644
--- a/core/src/main/java/org/jruby/ir/instructions/Instr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/Instr.java
@@ -200,12 +200,12 @@ public abstract class Instr {
}
@Interp
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
throw new RuntimeException(this.getClass().getSimpleName() + " should not be directly interpreted");
}
@Interp
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
throw new RuntimeException(this.getClass().getSimpleName() + " should not be directly interpreted");
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/LexicalSearchConstInstr.java b/core/src/main/java/org/jruby/ir/instructions/LexicalSearchConstInstr.java
index 98f58d9..92acb00 100644
--- a/core/src/main/java/org/jruby/ir/instructions/LexicalSearchConstInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/LexicalSearchConstInstr.java
@@ -80,8 +80,8 @@ public class LexicalSearchConstInstr extends Instr implements ResultInstr, Fixed
return new LexicalSearchConstInstr(ii.getRenamedVariable(result), definingScope.cloneForInlining(ii), constName);
}
- private Object cache(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Ruby runtime, Object constant) {
- StaticScope staticScope = (StaticScope) definingScope.retrieve(context, self, currDynScope, temp);
+ private Object cache(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, Ruby runtime, Object constant) {
+ StaticScope staticScope = (StaticScope) definingScope.retrieve(context, self, currDynScope, temp, tempStart);
RubyModule object = runtime.getObject();
// SSS FIXME: IRManager objects dont have a static-scope yet, so this hack of looking up the module right away
// This IR needs fixing!
@@ -101,10 +101,10 @@ public class LexicalSearchConstInstr extends Instr implements ResultInstr, Fixed
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
Ruby runtime = context.runtime;
Object constant = cachedConstant; // Store to temp so it does null out on us mid-stream
- if (!isCached(runtime, constant)) constant = cache(context, currDynScope, self, temp, runtime, constant);
+ if (!isCached(runtime, constant)) constant = cache(context, currDynScope, self, temp, tempStart, runtime, constant);
return constant;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/LoadLocalVarInstr.java b/core/src/main/java/org/jruby/ir/instructions/LoadLocalVarInstr.java
index 828f584..fd83426 100644
--- a/core/src/main/java/org/jruby/ir/instructions/LoadLocalVarInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/LoadLocalVarInstr.java
@@ -65,8 +65,8 @@ public class LoadLocalVarInstr extends Instr implements ResultInstr, FixedArityI
@Interp
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- return lvar.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ return lvar.retrieve(context, self, currDynScope, temp, tempStart);
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/instructions/Match2Instr.java b/core/src/main/java/org/jruby/ir/instructions/Match2Instr.java
index 8eb091d..4d35930 100644
--- a/core/src/main/java/org/jruby/ir/instructions/Match2Instr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/Match2Instr.java
@@ -79,9 +79,9 @@ public class Match2Instr extends Instr implements ResultInstr, FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- RubyRegexp regexp = (RubyRegexp) receiver.retrieve(context, self, currDynScope, temp);
- IRubyObject argValue = (IRubyObject) arg.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ RubyRegexp regexp = (RubyRegexp) receiver.retrieve(context, self, currDynScope, temp, tempStart);
+ IRubyObject argValue = (IRubyObject) arg.retrieve(context, self, currDynScope, temp, tempStart);
return regexp.op_match19(context, argValue);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/Match3Instr.java b/core/src/main/java/org/jruby/ir/instructions/Match3Instr.java
index cb9b311..f16ac11 100644
--- a/core/src/main/java/org/jruby/ir/instructions/Match3Instr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/Match3Instr.java
@@ -78,9 +78,9 @@ public class Match3Instr extends Instr implements ResultInstr, FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- RubyRegexp regexp = (RubyRegexp) receiver.retrieve(context, self, currDynScope, temp);
- IRubyObject argValue = (IRubyObject) arg.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ RubyRegexp regexp = (RubyRegexp) receiver.retrieve(context, self, currDynScope, temp, tempStart);
+ IRubyObject argValue = (IRubyObject) arg.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.match3(context, regexp, argValue);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/MatchInstr.java b/core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
index 4a0df9c..502bfc4 100644
--- a/core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
@@ -69,8 +69,8 @@ public class MatchInstr extends Instr implements ResultInstr, FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- RubyRegexp regexp = (RubyRegexp) receiver.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ RubyRegexp regexp = (RubyRegexp) receiver.retrieve(context, self, currDynScope, temp, tempStart);
return regexp.op_match2_19(context);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/MethodLookupInstr.java b/core/src/main/java/org/jruby/ir/instructions/MethodLookupInstr.java
index 52ce0bd..11f3b61 100644
--- a/core/src/main/java/org/jruby/ir/instructions/MethodLookupInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/MethodLookupInstr.java
@@ -64,8 +64,8 @@ public class MethodLookupInstr extends Instr implements ResultInstr, FixedArityI
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- return methodHandle.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ return methodHandle.retrieve(context, self, currDynScope, temp, tempStart);
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/instructions/ModuleVersionGuardInstr.java b/core/src/main/java/org/jruby/ir/instructions/ModuleVersionGuardInstr.java
index f739593..fad86d4 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ModuleVersionGuardInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ModuleVersionGuardInstr.java
@@ -77,8 +77,8 @@ public class ModuleVersionGuardInstr extends Instr implements FixedArityInstr {
return new ModuleVersionGuardInstr(module, expectedVersion, candidateObj.cloneForInlining(ii), ii.getRenamedLabel(failurePathLabel));
}
- private boolean versionMatches(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject receiver = (IRubyObject) candidateObj.retrieve(context, self, currDynScope, temp);
+ private boolean versionMatches(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject receiver = (IRubyObject) candidateObj.retrieve(context, self, currDynScope, temp, tempStart);
// if (module.getGeneration() != expectedVersion) ... replace this instr with a direct jump
//
// SSS FIXME: This is not always correct. Implementation class is not always receiver.getMetaClass()
@@ -88,8 +88,8 @@ public class ModuleVersionGuardInstr extends Instr implements FixedArityInstr {
}
@Override
- public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int ipc) {
- return versionMatches(context, currDynScope, self, temp) ? ipc : getFailurePathLabel().getTargetPC();
+ public int interpretAndGetNewIPC(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, int ipc) {
+ return versionMatches(context, currDynScope, self, temp, tempStart) ? ipc : getFailurePathLabel().getTargetPC();
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/instructions/NopInstr.java b/core/src/main/java/org/jruby/ir/instructions/NopInstr.java
index a33db00..d5962ab 100644
--- a/core/src/main/java/org/jruby/ir/instructions/NopInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/NopInstr.java
@@ -32,7 +32,7 @@ public class NopInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/OptArgMultipleAsgnInstr.java b/core/src/main/java/org/jruby/ir/instructions/OptArgMultipleAsgnInstr.java
index 8d99e78..e137a4c 100644
--- a/core/src/main/java/org/jruby/ir/instructions/OptArgMultipleAsgnInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/OptArgMultipleAsgnInstr.java
@@ -45,9 +45,9 @@ public class OptArgMultipleAsgnInstr extends MultipleAsgnBase implements FixedAr
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
// ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this?
- RubyArray rubyArray = (RubyArray) array.retrieve(context, self, currDynScope, temp);
+ RubyArray rubyArray = (RubyArray) array.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.extractOptionalArgument(rubyArray, minArgsLength, index);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/ProcessModuleBodyInstr.java b/core/src/main/java/org/jruby/ir/instructions/ProcessModuleBodyInstr.java
index e17dd34..0f6511e 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ProcessModuleBodyInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ProcessModuleBodyInstr.java
@@ -63,10 +63,10 @@ public class ProcessModuleBodyInstr extends Instr implements ResultInstr, FixedA
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- InterpretedIRMethod bodyMethod = (InterpretedIRMethod)moduleBody.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ InterpretedIRMethod bodyMethod = (InterpretedIRMethod)moduleBody.retrieve(context, self, currDynScope, temp, tempStart);
RubyModule implClass = bodyMethod.getImplementationClass();
- Object blk = block.retrieve(context, self, currDynScope, temp);
+ Object blk = block.retrieve(context, self, currDynScope, temp, tempStart);
if (blk instanceof RubyProc) blk = ((RubyProc)blk).getBlock();
if (blk instanceof RubyNil) blk = Block.NULL_BLOCK;
return bodyMethod.call(context, implClass, implClass, null, new IRubyObject[]{}, (Block)blk);
diff --git a/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java b/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java
index d958d3b..136c897 100644
--- a/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/PutClassVariableInstr.java
@@ -21,9 +21,9 @@ public class PutClassVariableInstr extends PutInstr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp);
- RubyModule module = (RubyModule) getTarget().retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp, tempStart);
+ RubyModule module = (RubyModule) getTarget().retrieve(context, self, currDynScope, temp, tempStart);
assert module != null : "MODULE should always be something";
diff --git a/core/src/main/java/org/jruby/ir/instructions/PutConstInstr.java b/core/src/main/java/org/jruby/ir/instructions/PutConstInstr.java
index 9ff67de..4b1a525 100644
--- a/core/src/main/java/org/jruby/ir/instructions/PutConstInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/PutConstInstr.java
@@ -20,9 +20,9 @@ public class PutConstInstr extends PutInstr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp);
- RubyModule module = (RubyModule) getTarget().retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp, tempStart);
+ RubyModule module = (RubyModule) getTarget().retrieve(context, self, currDynScope, temp, tempStart);
assert module != null : "MODULE should always be something";
diff --git a/core/src/main/java/org/jruby/ir/instructions/PutFieldInstr.java b/core/src/main/java/org/jruby/ir/instructions/PutFieldInstr.java
index c170f13..03a4f6a 100644
--- a/core/src/main/java/org/jruby/ir/instructions/PutFieldInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/PutFieldInstr.java
@@ -20,15 +20,15 @@ public class PutFieldInstr extends PutInstr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) getTarget().retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) getTarget().retrieve(context, self, currDynScope, temp, tempStart);
// FIXME: Why getRealClass? Document
RubyClass clazz = object.getMetaClass().getRealClass();
// FIXME: Should add this as a field for instruction
clazz.getVariableAccessorForWrite(getRef()).set(object,
- getValue().retrieve(context, self, currDynScope, temp));
+ getValue().retrieve(context, self, currDynScope, temp, tempStart));
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/PutGlobalVarInstr.java b/core/src/main/java/org/jruby/ir/instructions/PutGlobalVarInstr.java
index 223d28d..cf43d6c 100644
--- a/core/src/main/java/org/jruby/ir/instructions/PutGlobalVarInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/PutGlobalVarInstr.java
@@ -39,9 +39,9 @@ public class PutGlobalVarInstr extends PutInstr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
GlobalVariable target = (GlobalVariable)getTarget();
- IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp);
+ IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currDynScope, temp, tempStart);
context.runtime.getGlobalVariables().set(target.getName(), value);
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/RaiseArgumentErrorInstr.java b/core/src/main/java/org/jruby/ir/instructions/RaiseArgumentErrorInstr.java
index 72c2170..7669ba7 100644
--- a/core/src/main/java/org/jruby/ir/instructions/RaiseArgumentErrorInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/RaiseArgumentErrorInstr.java
@@ -57,7 +57,7 @@ public class RaiseArgumentErrorInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
Arity.raiseArgumentError(context.runtime, numArgs, required, required + opt);
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/RaiseRequiredKeywordArgumentError.java b/core/src/main/java/org/jruby/ir/instructions/RaiseRequiredKeywordArgumentError.java
index 38ee108..f986fa6 100644
--- a/core/src/main/java/org/jruby/ir/instructions/RaiseRequiredKeywordArgumentError.java
+++ b/core/src/main/java/org/jruby/ir/instructions/RaiseRequiredKeywordArgumentError.java
@@ -25,7 +25,7 @@ public class RaiseRequiredKeywordArgumentError extends Instr implements FixedAri
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
throw context.runtime.newArgumentError("missing keyword: " + name);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/ReqdArgMultipleAsgnInstr.java b/core/src/main/java/org/jruby/ir/instructions/ReqdArgMultipleAsgnInstr.java
index 468e0f8..b79c2b0 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ReqdArgMultipleAsgnInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ReqdArgMultipleAsgnInstr.java
@@ -63,9 +63,9 @@ public class ReqdArgMultipleAsgnInstr extends MultipleAsgnBase implements FixedA
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
// ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this?
- RubyArray rubyArray = (RubyArray) array.retrieve(context, self, currDynScope, temp);
+ RubyArray rubyArray = (RubyArray) array.retrieve(context, self, currDynScope, temp, tempStart);
int i = Helpers.irReqdArgMultipleAsgnIndex(rubyArray.getLength(), preArgsCount, index, postArgsCount);
return i == -1 ? context.nil : rubyArray.entry(i);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/RescueEQQInstr.java b/core/src/main/java/org/jruby/ir/instructions/RescueEQQInstr.java
index 4e9c5e4..ee3d461 100644
--- a/core/src/main/java/org/jruby/ir/instructions/RescueEQQInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/RescueEQQInstr.java
@@ -73,9 +73,9 @@ public class RescueEQQInstr extends Instr implements ResultInstr, FixedArityInst
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject excType = (IRubyObject) arg1.retrieve(context, self, currDynScope, temp);
- Object excObj = arg2.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject excType = (IRubyObject) arg1.retrieve(context, self, currDynScope, temp, tempStart);
+ Object excObj = arg2.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.isExceptionHandled(context, excType, excObj);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/RestArgMultipleAsgnInstr.java b/core/src/main/java/org/jruby/ir/instructions/RestArgMultipleAsgnInstr.java
index 799d040..2258f29 100644
--- a/core/src/main/java/org/jruby/ir/instructions/RestArgMultipleAsgnInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/RestArgMultipleAsgnInstr.java
@@ -49,9 +49,9 @@ public class RestArgMultipleAsgnInstr extends MultipleAsgnBase implements FixedA
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
// ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this?
- RubyArray rubyArray = (RubyArray) array.retrieve(context, self, currDynScope, temp);
+ RubyArray rubyArray = (RubyArray) array.retrieve(context, self, currDynScope, temp, tempStart);
Object val;
int n = rubyArray.getLength();
diff --git a/core/src/main/java/org/jruby/ir/instructions/RuntimeHelperCall.java b/core/src/main/java/org/jruby/ir/instructions/RuntimeHelperCall.java
index c9b309b..6273257 100644
--- a/core/src/main/java/org/jruby/ir/instructions/RuntimeHelperCall.java
+++ b/core/src/main/java/org/jruby/ir/instructions/RuntimeHelperCall.java
@@ -15,8 +15,6 @@ import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
-import org.jruby.parser.IRStaticScope;
-
import java.util.Map;
public class RuntimeHelperCall extends Instr implements ResultInstr {
@@ -84,28 +82,28 @@ public class RuntimeHelperCall extends Instr implements ResultInstr {
return (getResult() == null ? "" : (getResult() + " = ")) + getOperation() + "(" + helperMethod + ", " + Arrays.toString(args) + ")";
}
- public IRubyObject callHelper(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, Block.Type blockType) {
+ public IRubyObject callHelper(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart, Block.Type blockType) {
IRStaticScope scope = (IRStaticScope) currDynScope.getStaticScope();
switch (helperMethod) {
case HANDLE_PROPAGATE_BREAK:
return IRRuntimeHelpers.handlePropagatedBreak(context, currDynScope,
- args[0].retrieve(context, self, currDynScope, temp), blockType);
+ args[0].retrieve(context, self, currDynScope, temp, tempStart), blockType);
case HANDLE_NONLOCAL_RETURN:
return IRRuntimeHelpers.handleNonlocalReturn(scope, currDynScope,
- args[0].retrieve(context, self, currDynScope, temp), blockType);
+ args[0].retrieve(context, self, currDynScope, temp, tempStart), blockType);
case HANDLE_BREAK_AND_RETURNS_IN_LAMBDA:
return IRRuntimeHelpers.handleBreakAndReturnsInLambdas(context, scope, currDynScope,
- args[0].retrieve(context, self, currDynScope, temp), blockType);
+ args[0].retrieve(context, self, currDynScope, temp, tempStart), blockType);
case IS_DEFINED_BACKREF:
return IRRuntimeHelpers.isDefinedBackref(context);
case IS_DEFINED_CALL:
return IRRuntimeHelpers.isDefinedCall(context, self,
- (IRubyObject) args[0].retrieve(context, self, currDynScope, temp),
+ (IRubyObject) args[0].retrieve(context, self, currDynScope, temp, tempStart),
((StringLiteral) args[1]).getString());
case IS_DEFINED_CONSTANT_OR_METHOD:
return IRRuntimeHelpers.isDefinedConstantOrMethod(context,
- (IRubyObject) args[0].retrieve(context, self, currDynScope, temp),
+ (IRubyObject) args[0].retrieve(context, self, currDynScope, temp, tempStart),
((StringLiteral) args[1]).getString());
case IS_DEFINED_NTH_REF:
return IRRuntimeHelpers.isDefinedNthRef(context, (int) ((Fixnum) args[0]).getValue());
@@ -113,24 +111,24 @@ public class RuntimeHelperCall extends Instr implements ResultInstr {
return IRRuntimeHelpers.isDefinedGlobal(context, ((StringLiteral) args[0]).getString());
case IS_DEFINED_INSTANCE_VAR:
return IRRuntimeHelpers.isDefinedInstanceVar(context,
- (IRubyObject) args[0].retrieve(context, self, currDynScope, temp),
+ (IRubyObject) args[0].retrieve(context, self, currDynScope, temp, tempStart),
((StringLiteral) args[1]).getString());
case IS_DEFINED_CLASS_VAR:
return IRRuntimeHelpers.isDefinedClassVar(context,
- (RubyModule) args[0].retrieve(context, self, currDynScope, temp),
+ (RubyModule) args[0].retrieve(context, self, currDynScope, temp, tempStart),
((StringLiteral) args[1]).getString());
case IS_DEFINED_SUPER:
return IRRuntimeHelpers.isDefinedSuper(context,
- (IRubyObject) args[0].retrieve(context, self, currDynScope, temp));
+ (IRubyObject) args[0].retrieve(context, self, currDynScope, temp, tempStart));
case IS_DEFINED_METHOD:
return IRRuntimeHelpers.isDefinedMethod(context,
- (IRubyObject) args[0].retrieve(context, self, currDynScope, temp),
+ (IRubyObject) args[0].retrieve(context, self, currDynScope, temp, tempStart),
((StringLiteral) args[1]).getString(),
((Boolean) args[2]).isTrue());
case MERGE_KWARGS:
return IRRuntimeHelpers.mergeKeywordArguments(context,
- (IRubyObject) args[0].retrieve(context, self, currDynScope, temp),
- (IRubyObject) args[1].retrieve(context, self, currDynScope, temp));
+ (IRubyObject) args[0].retrieve(context, self, currDynScope, temp, tempStart),
+ (IRubyObject) args[1].retrieve(context, self, currDynScope, temp, tempStart));
}
throw new RuntimeException("Unknown IR runtime helper method: " + helperMethod + "; INSTR: " + this);
diff --git a/core/src/main/java/org/jruby/ir/instructions/SearchConstInstr.java b/core/src/main/java/org/jruby/ir/instructions/SearchConstInstr.java
index 20c73e9..c101587 100644
--- a/core/src/main/java/org/jruby/ir/instructions/SearchConstInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/SearchConstInstr.java
@@ -74,11 +74,11 @@ public class SearchConstInstr extends Instr implements ResultInstr, FixedArityIn
return super.toString() + "(" + constName + ", " + startingScope + ", no-private-consts=" + noPrivateConsts + ")";
}
- public Object cache(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object cache(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
// Lexical lookup
Ruby runtime = context.getRuntime();
RubyModule object = runtime.getObject();
- StaticScope staticScope = (StaticScope) startingScope.retrieve(context, self, currDynScope, temp);
+ StaticScope staticScope = (StaticScope) startingScope.retrieve(context, self, currDynScope, temp, tempStart);
Object constant = (staticScope == null) ? object.getConstant(constName) : staticScope.getConstantInner(constName);
// Inheritance lookup
@@ -110,9 +110,9 @@ public class SearchConstInstr extends Instr implements ResultInstr, FixedArityIn
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
Object constant = cachedConstant; // Store to temp so it does null out on us mid-stream
- if (!isCached(context, constant)) constant = cache(context, currDynScope, self, temp);
+ if (!isCached(context, constant)) constant = cache(context, currDynScope, self, temp, tempStart);
return constant;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/SetCapturedVarInstr.java b/core/src/main/java/org/jruby/ir/instructions/SetCapturedVarInstr.java
index 07fb3a5..461ac34 100644
--- a/core/src/main/java/org/jruby/ir/instructions/SetCapturedVarInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/SetCapturedVarInstr.java
@@ -62,8 +62,8 @@ public class SetCapturedVarInstr extends Instr implements ResultInstr, FixedArit
@Interp
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject matchRes = (IRubyObject)match2Result.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject matchRes = (IRubyObject)match2Result.retrieve(context, self, currDynScope, temp, tempStart);
Object val;
if (matchRes.isNil()) {
val = context.nil;
diff --git a/core/src/main/java/org/jruby/ir/instructions/StoreLocalVarInstr.java b/core/src/main/java/org/jruby/ir/instructions/StoreLocalVarInstr.java
index 24262b7..aa61422 100644
--- a/core/src/main/java/org/jruby/ir/instructions/StoreLocalVarInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/StoreLocalVarInstr.java
@@ -60,8 +60,8 @@ public class StoreLocalVarInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- Object varValue = value.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ Object varValue = value.retrieve(context, self, currDynScope, temp, tempStart);
currDynScope.setValue((IRubyObject)varValue, lvar.getLocation(), lvar.getScopeDepth());
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/ThrowExceptionInstr.java b/core/src/main/java/org/jruby/ir/instructions/ThrowExceptionInstr.java
index 17ab9b5..b5d8ce5 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ThrowExceptionInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ThrowExceptionInstr.java
@@ -49,12 +49,12 @@ public class ThrowExceptionInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
if (exceptionArg instanceof IRException) {
throw ((IRException) exceptionArg).getException(context.runtime);
}
- Object excObj = exceptionArg.retrieve(context, self, currDynScope, temp);
+ Object excObj = exceptionArg.retrieve(context, self, currDynScope, temp, tempStart);
if (excObj instanceof IRubyObject) {
RubyKernel.raise(context, context.runtime.getKernel(), new IRubyObject[] {(IRubyObject)excObj}, Block.NULL_BLOCK);
diff --git a/core/src/main/java/org/jruby/ir/instructions/ToAryInstr.java b/core/src/main/java/org/jruby/ir/instructions/ToAryInstr.java
index 08944c2..9e49fbe 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ToAryInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ToAryInstr.java
@@ -78,8 +78,8 @@ public class ToAryInstr extends Instr implements ResultInstr, FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- Object receiver = array.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ Object receiver = array.retrieve(context, self, currDynScope, temp, tempStart);
return Helpers.irToAry(context, (IRubyObject)receiver);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/UndefMethodInstr.java b/core/src/main/java/org/jruby/ir/instructions/UndefMethodInstr.java
index e43334d..e5e7235 100644
--- a/core/src/main/java/org/jruby/ir/instructions/UndefMethodInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/UndefMethodInstr.java
@@ -66,9 +66,9 @@ public class UndefMethodInstr extends Instr implements ResultInstr, FixedArityIn
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
RubyModule module = IRRuntimeHelpers.findInstanceMethodContainer(context, currDynScope, self);
- Object nameArg = methodName.retrieve(context, self, currDynScope, temp);
+ Object nameArg = methodName.retrieve(context, self, currDynScope, temp, tempStart);
String name = (nameArg instanceof String) ? (String) nameArg : nameArg.toString();
module.undef(context, name);
return context.runtime.getNil();
diff --git a/core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java b/core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java
index cb0a1af..c06f3b7 100644
--- a/core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java
@@ -40,9 +40,9 @@ public class UnresolvedSuperInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp);
- Block block = prepareBlock(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject[] args = prepareArguments(context, self, getCallArgs(), currDynScope, temp, tempStart);
+ Block block = prepareBlock(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.unresolvedSuper(context, self, args, block);
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/YieldInstr.java b/core/src/main/java/org/jruby/ir/instructions/YieldInstr.java
index dd5c569..35b4b60 100644
--- a/core/src/main/java/org/jruby/ir/instructions/YieldInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/YieldInstr.java
@@ -84,12 +84,12 @@ public class YieldInstr extends Instr implements ResultInstr, FixedArityInstr {
@Interp
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- Object blk = blockArg.retrieve(context, self, currDynScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ Object blk = blockArg.retrieve(context, self, currDynScope, temp, tempStart);
if (yieldArg == UndefinedValue.UNDEFINED) {
return IRRuntimeHelpers.yieldSpecific(context, blk);
} else {
- IRubyObject yieldVal = (IRubyObject)yieldArg.retrieve(context, self, currDynScope, temp);
+ IRubyObject yieldVal = (IRubyObject)yieldArg.retrieve(context, self, currDynScope, temp, tempStart);
return IRRuntimeHelpers.yield(context, blk, yieldVal, unwrapArray);
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/ZSuperInstr.java b/core/src/main/java/org/jruby/ir/instructions/ZSuperInstr.java
index f908dfc..6c1353e 100644
--- a/core/src/main/java/org/jruby/ir/instructions/ZSuperInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/ZSuperInstr.java
@@ -45,16 +45,16 @@ public class ZSuperInstr extends UnresolvedSuperInstr {
}
@Override
- protected IRubyObject[] prepareArguments(ThreadContext context, IRubyObject self, Operand[] arguments, DynamicScope dynamicScope, Object[] temp) {
+ protected IRubyObject[] prepareArguments(ThreadContext context, IRubyObject self, Operand[] arguments, DynamicScope dynamicScope, Object[] temp, int tempStart) {
// Unlike calls, zsuper args are known only at interpret time, not at constructor time.
// So, we cannot use the cached containsArgSplat field from CallBase
return containsArgSplat(arguments) ?
- prepareArgumentsComplex(context, self, arguments, dynamicScope, temp) :
- prepareArgumentsSimple(context, self, arguments, dynamicScope, temp);
+ prepareArgumentsComplex(context, self, arguments, dynamicScope, temp, tempStart) :
+ prepareArgumentsSimple(context, self, arguments, dynamicScope, temp, tempStart);
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
DynamicScope argsDynScope = currDynScope;
// Find args that need to be passed into super
@@ -72,10 +72,10 @@ public class ZSuperInstr extends UnresolvedSuperInstr {
}
// Prepare args -- but look up in 'argsDynScope', not 'currDynScope'
- IRubyObject[] args = prepareArguments(context, self, superArgs, argsDynScope, temp);
+ IRubyObject[] args = prepareArguments(context, self, superArgs, argsDynScope, temp, tempStart);
// Prepare block -- fetching from the frame stack, if necessary
- Block block = prepareBlock(context, self, currDynScope, temp);
+ Block block = prepareBlock(context, self, currDynScope, temp, tempStart);
if (block == null || !block.isGiven()) block = context.getFrameBlock();
return IRRuntimeHelpers.unresolvedSuper(context, self, args, block);
diff --git a/core/src/main/java/org/jruby/ir/instructions/defined/GetErrorInfoInstr.java b/core/src/main/java/org/jruby/ir/instructions/defined/GetErrorInfoInstr.java
index 08ee1dd..618100a 100644
--- a/core/src/main/java/org/jruby/ir/instructions/defined/GetErrorInfoInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/defined/GetErrorInfoInstr.java
@@ -42,7 +42,7 @@ public class GetErrorInfoInstr extends Instr implements ResultInstr, FixedArityI
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
return context.getErrorInfo();
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/defined/RestoreErrorInfoInstr.java b/core/src/main/java/org/jruby/ir/instructions/defined/RestoreErrorInfoInstr.java
index be710c7..3a64a02 100644
--- a/core/src/main/java/org/jruby/ir/instructions/defined/RestoreErrorInfoInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/defined/RestoreErrorInfoInstr.java
@@ -46,8 +46,8 @@ public class RestoreErrorInfoInstr extends Instr implements FixedArityInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
- context.setErrorInfo((IRubyObject) arg.retrieve(context, self, currDynScope, temp));
+ public Object interpret(ThreadContext context, DynamicScope currDynScope, IRubyObject self, Object[] temp, int tempStart) {
+ context.setErrorInfo((IRubyObject) arg.retrieve(context, self, currDynScope, temp, tempStart));
return null;
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/specialized/OneArgOperandAttrAssignInstr.java b/core/src/main/java/org/jruby/ir/instructions/specialized/OneArgOperandAttrAssignInstr.java
index 68f4f8f..e9b8214 100644
--- a/core/src/main/java/org/jruby/ir/instructions/specialized/OneArgOperandAttrAssignInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/specialized/OneArgOperandAttrAssignInstr.java
@@ -20,10 +20,10 @@ public class OneArgOperandAttrAssignInstr extends AttrAssignInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
Operand[] args = getCallArgs();
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
- IRubyObject value = (IRubyObject) args[0].retrieve(context, self, dynamicScope, temp);
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
+ IRubyObject value = (IRubyObject) args[0].retrieve(context, self, dynamicScope, temp, tempStart);
CallType callType = self == object ? CallType.FUNCTIONAL : CallType.NORMAL;
Helpers.invoke(context, object, getMethodAddr().getName(), value, callType, Block.NULL_BLOCK);
diff --git a/core/src/main/java/org/jruby/ir/instructions/specialized/OneFixnumArgNoBlockCallInstr.java b/core/src/main/java/org/jruby/ir/instructions/specialized/OneFixnumArgNoBlockCallInstr.java
index 4c1a696..4beae94 100644
--- a/core/src/main/java/org/jruby/ir/instructions/specialized/OneFixnumArgNoBlockCallInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/specialized/OneFixnumArgNoBlockCallInstr.java
@@ -33,8 +33,8 @@ public class OneFixnumArgNoBlockCallInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
return getCallSite().call(context, self, object, fixNum);
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgBlockCallInstr.java b/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgBlockCallInstr.java
index 617a421..30afa4f 100644
--- a/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgBlockCallInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgBlockCallInstr.java
@@ -27,10 +27,10 @@ public class OneOperandArgBlockCallInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
- IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, dynamicScope, temp);
- Block preparedBlock = prepareBlock(context, self, dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
+ IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, dynamicScope, temp, tempStart);
+ Block preparedBlock = prepareBlock(context, self, dynamicScope, temp, tempStart);
return getCallSite().call(context, self, object, arg1, preparedBlock);
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockCallInstr.java b/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockCallInstr.java
index 1ffa125..af9c285 100644
--- a/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockCallInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockCallInstr.java
@@ -26,9 +26,9 @@ public class OneOperandArgNoBlockCallInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
- IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
+ IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, dynamicScope, temp, tempStart);
return getCallSite().call(context, self, object, arg1);
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockNoResultCallInstr.java b/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockNoResultCallInstr.java
index eeacf22..59f2daf 100644
--- a/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockNoResultCallInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockNoResultCallInstr.java
@@ -26,9 +26,9 @@ public class OneOperandArgNoBlockNoResultCallInstr extends NoResultCallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
- IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
+ IRubyObject arg1 = (IRubyObject) getCallArgs()[0].retrieve(context, self, dynamicScope, temp, tempStart);
return getCallSite().call(context, self, object, arg1);
}
}
diff --git a/core/src/main/java/org/jruby/ir/instructions/specialized/ZeroOperandArgNoBlockCallInstr.java b/core/src/main/java/org/jruby/ir/instructions/specialized/ZeroOperandArgNoBlockCallInstr.java
index fc46792..d9015c4 100644
--- a/core/src/main/java/org/jruby/ir/instructions/specialized/ZeroOperandArgNoBlockCallInstr.java
+++ b/core/src/main/java/org/jruby/ir/instructions/specialized/ZeroOperandArgNoBlockCallInstr.java
@@ -22,8 +22,8 @@ public class ZeroOperandArgNoBlockCallInstr extends CallInstr {
}
@Override
- public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
- IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp);
+ public Object interpret(ThreadContext context, DynamicScope dynamicScope, IRubyObject self, Object[] temp, int tempStart) {
+ IRubyObject object = (IRubyObject) receiver.retrieve(context, self, dynamicScope, temp, tempStart);
return getCallSite().call(context, self, object);
}
diff --git a/core/src/main/java/org/jruby/ir/interpreter/Interpreter.java b/core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
index fe9c2f5..40792ec 100644
--- a/core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
+++ b/core/src/main/java/org/jruby/ir/interpreter/Interpreter.java
@@ -155,9 +155,9 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
((IRStaticScope)evalScript.getStaticScope()).setIRScope(evalScript);
s.growIfNeeded();
- runBeginEndBlocks(evalScript.getBeginBlocks(), context, self, null); // FIXME: No temp vars yet right?
+ runBeginEndBlocks(evalScript.getBeginBlocks(), context, self, null, -1); // FIXME: No temp vars yet right?
rv = evalScript.call(context, self, evalScript.getStaticScope().getModule(), s, block, backtraceName);
- runBeginEndBlocks(evalScript.getEndBlocks(), context, self, null); // FIXME: No temp vars right?
+ runBeginEndBlocks(evalScript.getEndBlocks(), context, self, null, -1); // FIXME: No temp vars right?
} finally {
s.clearEvalType();
context.popScope();
@@ -173,13 +173,13 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
return interpretCommonEval(runtime, file, lineNumber, backtraceName, (RootNode)node, self, block, EvalType.BINDING_EVAL);
}
- public static void runBeginEndBlocks(List<IRClosure> beBlocks, ThreadContext context, IRubyObject self, Object[] temp) {
+ public static void runBeginEndBlocks(List<IRClosure> beBlocks, ThreadContext context, IRubyObject self, Object[] temp, int tempStart) {
if (beBlocks == null) return;
for (IRClosure b: beBlocks) {
// SSS FIXME: Should I piggyback on WrappedIRClosure.retrieve or just copy that code here?
b.prepareForInterpretation(false);
- Block blk = (Block)(new WrappedIRClosure(b.getSelf(), b)).retrieve(context, self, context.getCurrentScope(), temp);
+ Block blk = (Block)(new WrappedIRClosure(b.getSelf(), b)).retrieve(context, self, context.getCurrentScope(), temp, tempStart);
blk.yield(context, null);
}
}
@@ -189,7 +189,7 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
return ((IRScriptBody)scope).interpret(runtime.getCurrentContext(), self);
}
- private static void setResult(Object[] temp, DynamicScope currDynScope, Variable resultVar, Object result) {
+ private static void setResult(Object[] temp, int tempStart, DynamicScope currDynScope, Variable resultVar, Object result) {
if (resultVar instanceof TemporaryVariable) {
// Unboxed Java primitives (float/double/int/long) don't come here because result is an Object
// So, it is safe to use offset directly without any correction as long as IRScope uses
@@ -197,32 +197,32 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
// * one for LOCAL, BOOLEAN, CURRENT_SCOPE, CURRENT_MODULE, CLOSURE tmpvars
// * one for FIXNUM
// * one for FLOAT
- temp[((TemporaryLocalVariable)resultVar).offset] = result;
+ temp[tempStart + ((TemporaryLocalVariable)resultVar).offset] = result;
} else {
LocalVariable lv = (LocalVariable)resultVar;
currDynScope.setValue((IRubyObject)result, lv.getLocation(), lv.getScopeDepth());
}
}
- private static void setResult(Object[] temp, DynamicScope currDynScope, Instr instr, Object result) {
+ private static void setResult(Object[] temp, int tempStart, DynamicScope currDynScope, Instr instr, Object result) {
if (instr instanceof ResultInstr) {
- setResult(temp, currDynScope, ((ResultInstr) instr).getResult(), result);
+ setResult(temp, tempStart, currDynScope, ((ResultInstr) instr).getResult(), result);
}
}
- private static Object retrieveOp(Operand r, ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ private static Object retrieveOp(Operand r, ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
Object res;
if (r instanceof Self) {
return self;
} else if (r instanceof TemporaryLocalVariable) {
- res = temp[((TemporaryLocalVariable)r).offset];
+ res = temp[tempStart + ((TemporaryLocalVariable)r).offset];
return res == null ? context.nil : res;
} else if (r instanceof LocalVariable) {
LocalVariable lv = (LocalVariable)r;
res = currDynScope.getValue(lv.getLocation(), lv.getScopeDepth());
return res == null ? context.nil : res;
} else {
- return r.retrieve(context, self, currDynScope, temp);
+ return r.retrieve(context, self, currDynScope, temp, tempStart);
}
}
@@ -277,7 +277,7 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
booleans[var.offset] = val;
}
- private static void intepretIntOp(AluInstr instr, Operation op, ThreadContext context, long[] fixnums, boolean[] booleans, Object[] temp) {
+ private static void intepretIntOp(AluInstr instr, Operation op, ThreadContext context, long[] fixnums, boolean[] booleans, Object[] temp, int tempstart) {
TemporaryLocalVariable dst = (TemporaryLocalVariable)instr.getResult();
long i1 = getFixnumArg(fixnums, instr.getArg1());
long i2 = getFixnumArg(fixnums, instr.getArg2());
@@ -298,7 +298,7 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
}
}
- private static void interpretFloatOp(AluInstr instr, Operation op, ThreadContext context, double[] floats, boolean[] booleans, Object[] temp) {
+ private static void interpretFloatOp(AluInstr instr, Operation op, ThreadContext context, double[] floats, boolean[] booleans, Object[] temp, int tempstart) {
TemporaryLocalVariable dst = (TemporaryLocalVariable)instr.getResult();
double a1 = getFloatArg(floats, instr.getArg1());
double a2 = getFloatArg(floats, instr.getArg2());
@@ -314,92 +314,92 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
}
}
- private static void receiveArg(ThreadContext context, Instr i, Operation operation, IRubyObject[] args, boolean acceptsKeywordArgument, DynamicScope currDynScope, Object[] temp, Object exception, Block block) {
+ private static void receiveArg(ThreadContext context, Instr i, Operation operation, IRubyObject[] args, boolean acceptsKeywordArgument, DynamicScope currDynScope, Object[] temp, int tempStart, Object exception, Block block) {
Object result;
ResultInstr instr = (ResultInstr)i;
switch(operation) {
case RECV_PRE_REQD_ARG:
int argIndex = ((ReceivePreReqdArgInstr)instr).getArgIndex();
result = argIndex < args.length ? args[argIndex] : context.nil; // SSS FIXME: This check is only required for closures, not methods
- setResult(temp, currDynScope, instr.getResult(), result);
+ setResult(temp, tempStart, currDynScope, instr.getResult(), result);
return;
case RECV_CLOSURE:
result = IRRuntimeHelpers.newProc(context.runtime, block);
- setResult(temp, currDynScope, instr.getResult(), result);
+ setResult(temp, tempStart, currDynScope, instr.getResult(), result);
return;
case RECV_POST_REQD_ARG:
result = ((ReceivePostReqdArgInstr)instr).receivePostReqdArg(args, acceptsKeywordArgument);
// For blocks, missing arg translates to nil
- setResult(temp, currDynScope, instr.getResult(), result == null ? context.nil : result);
+ setResult(temp, tempStart, currDynScope, instr.getResult(), result == null ? context.nil : result);
return;
case RECV_RUBY_EXC:
- setResult(temp, currDynScope, instr.getResult(), IRRuntimeHelpers.unwrapRubyException(exception));
+ setResult(temp, tempStart, currDynScope, instr.getResult(), IRRuntimeHelpers.unwrapRubyException(exception));
return;
case RECV_JRUBY_EXC:
- setResult(temp, currDynScope, instr.getResult(), exception);
+ setResult(temp, tempStart, currDynScope, instr.getResult(), exception);
return;
default:
result = ((ReceiveArgBase)instr).receiveArg(context, args, acceptsKeywordArgument);
- setResult(temp, currDynScope, instr.getResult(), result);
+ setResult(temp, tempStart, currDynScope, instr.getResult(), result);
return;
}
}
- private static void processCall(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, Object[] temp, IRubyObject self) {
+ private static void processCall(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, Object[] temp, int tempStart, IRubyObject self) {
Object result;
switch(operation) {
case CALL_1F: {
OneFixnumArgNoBlockCallInstr call = (OneFixnumArgNoBlockCallInstr)instr;
- IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp);
+ IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp, tempStart);
result = call.getCallSite().call(context, self, r, call.getFixnumArg());
- setResult(temp, currDynScope, call.getResult(), result);
+ setResult(temp, tempStart, currDynScope, call.getResult(), result);
break;
}
case CALL_1O: {
OneOperandArgNoBlockCallInstr call = (OneOperandArgNoBlockCallInstr)instr;
- IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp);
- IRubyObject o = (IRubyObject)call.getArg1().retrieve(context, self, currDynScope, temp);
+ IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp, tempStart);
+ IRubyObject o = (IRubyObject)call.getArg1().retrieve(context, self, currDynScope, temp, tempStart);
result = call.getCallSite().call(context, self, r, o);
- setResult(temp, currDynScope, call.getResult(), result);
+ setResult(temp, tempStart, currDynScope, call.getResult(), result);
break;
}
case CALL_1OB: {
OneOperandArgBlockCallInstr call = (OneOperandArgBlockCallInstr)instr;
- IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp);
- IRubyObject o = (IRubyObject)call.getArg1().retrieve(context, self, currDynScope, temp);
- Block preparedBlock = call.prepareBlock(context, self, currDynScope, temp);
+ IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp, tempStart);
+ IRubyObject o = (IRubyObject)call.getArg1().retrieve(context, self, currDynScope, temp, tempStart);
+ Block preparedBlock = call.prepareBlock(context, self, currDynScope, temp, tempStart);
result = call.getCallSite().call(context, self, r, o, preparedBlock);
- setResult(temp, currDynScope, call.getResult(), result);
+ setResult(temp, tempStart, currDynScope, call.getResult(), result);
break;
}
case CALL_0O: {
ZeroOperandArgNoBlockCallInstr call = (ZeroOperandArgNoBlockCallInstr)instr;
- IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp);
+ IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp, tempStart);
result = call.getCallSite().call(context, self, r);
- setResult(temp, currDynScope, call.getResult(), result);
+ setResult(temp, tempStart, currDynScope, call.getResult(), result);
break;
}
case NORESULT_CALL_1O: {
OneOperandArgNoBlockNoResultCallInstr call = (OneOperandArgNoBlockNoResultCallInstr)instr;
- IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp);
- IRubyObject o = (IRubyObject)call.getArg1().retrieve(context, self, currDynScope, temp);
+ IRubyObject r = (IRubyObject)retrieveOp(call.getReceiver(), context, self, currDynScope, temp, tempStart);
+ IRubyObject o = (IRubyObject)call.getArg1().retrieve(context, self, currDynScope, temp, tempStart);
call.getCallSite().call(context, self, r, o);
break;
}
case NORESULT_CALL:
- instr.interpret(context, currDynScope, self, temp);
+ instr.interpret(context, currDynScope, self, temp, tempStart);
break;
case CALL:
default:
- result = instr.interpret(context, currDynScope, self, temp);
- setResult(temp, currDynScope, instr, result);
+ result = instr.interpret(context, currDynScope, self, temp, tempStart);
+ setResult(temp, tempStart, currDynScope, instr, result);
break;
}
}
private static void processBookKeepingOp(ThreadContext context, Instr instr, Operation operation, IRScope scope,
String name, IRubyObject[] args, IRubyObject self, Block block,
- RubyModule implClass, Visibility visibility, Object[] temp, DynamicScope currDynamicScope) {
+ RubyModule implClass, Visibility visibility, Object[] temp, int tempStart, DynamicScope currDynamicScope) {
switch(operation) {
case PUSH_FRAME:
context.preMethodFrameAndClass(implClass, name, self, block, scope.getStaticScope());
@@ -438,16 +438,16 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
}
}
- private static IRubyObject processReturnOp(ThreadContext context, Instr instr, Operation operation, IRScope scope, DynamicScope currDynScope, Object[] temp, IRubyObject self, Block.Type blockType)
+ private static IRubyObject processReturnOp(ThreadContext context, Instr instr, Operation operation, IRScope scope, DynamicScope currDynScope, Object[] temp, int tempStart, IRubyObject self, Block.Type blockType)
{
switch(operation) {
// --------- Return flavored instructions --------
case RETURN: {
- return (IRubyObject)retrieveOp(((ReturnBase)instr).getReturnValue(), context, self, currDynScope, temp);
+ return (IRubyObject)retrieveOp(((ReturnBase)instr).getReturnValue(), context, self, currDynScope, temp, tempStart);
}
case BREAK: {
BreakInstr bi = (BreakInstr)instr;
- IRubyObject rv = (IRubyObject)bi.getReturnValue().retrieve(context, self, currDynScope, temp);
+ IRubyObject rv = (IRubyObject)bi.getReturnValue().retrieve(context, self, currDynScope, temp, tempStart);
// This also handles breaks in lambdas -- by converting them to a return
//
// This assumes that scopes with break instr. have a frame / dynamic scope
@@ -457,7 +457,7 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
}
case NONLOCAL_RETURN: {
NonlocalReturnInstr ri = (NonlocalReturnInstr)instr;
- IRubyObject rv = (IRubyObject)retrieveOp(ri.getReturnValue(), context, self, currDynScope, temp);
+ IRubyObject rv = (IRubyObject)retrieveOp(ri.getReturnValue(), context, self, currDynScope, temp, tempStart);
// If not in a lambda, check if this was a non-local return
if (!IRRuntimeHelpers.inLambda(blockType)) {
IRRuntimeHelpers.initiateNonLocalReturn(context, currDynScope, ri.maybeLambda, rv);
@@ -468,7 +468,7 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
return null;
}
- private static void processOtherOp(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, Object[] temp, IRubyObject self, Block.Type blockType, double[] floats, long[] fixnums, boolean[] booleans)
+ private static void processOtherOp(ThreadContext context, Instr instr, Operation operation, DynamicScope currDynScope, Object[] temp, int tempStart, IRubyObject self, Block.Type blockType, double[] floats, long[] fixnums, boolean[] booleans)
{
Object result;
switch(operation) {
@@ -481,14 +481,14 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
} else if (res instanceof TemporaryFixnumVariable) {
setFixnumVar(fixnums, (TemporaryFixnumVariable)res, getFixnumArg(fixnums, src));
} else {
- setResult(temp, currDynScope, res, retrieveOp(src, context, self, currDynScope, temp));
+ setResult(temp, tempStart, currDynScope, res, retrieveOp(src, context, self, currDynScope, temp, tempStart));
}
break;
}
case GET_FIELD: {
GetFieldInstr gfi = (GetFieldInstr)instr;
- IRubyObject object = (IRubyObject)gfi.getSource().retrieve(context, self, currDynScope, temp);
+ IRubyObject object = (IRubyObject)gfi.getSource().retrieve(context, self, currDynScope, temp, tempStart);
VariableAccessor a = gfi.getAccessor(object);
result = a == null ? null : (IRubyObject)a.get(object);
if (result == null) {
@@ -497,46 +497,46 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
}
result = context.nil;
}
- setResult(temp, currDynScope, gfi.getResult(), result);
+ setResult(temp, tempStart, currDynScope, gfi.getResult(), result);
break;
}
case SEARCH_CONST: {
SearchConstInstr sci = (SearchConstInstr)instr;
result = sci.getCachedConst();
- if (!sci.isCached(context, result)) result = sci.cache(context, currDynScope, self, temp);
- setResult(temp, currDynScope, sci.getResult(), result);
+ if (!sci.isCached(context, result)) result = sci.cache(context, currDynScope, self, temp, tempStart);
+ setResult(temp, tempStart, currDynScope, sci.getResult(), result);
break;
}
case RUNTIME_HELPER: {
RuntimeHelperCall rhc = (RuntimeHelperCall)instr;
- result = rhc.callHelper(context, currDynScope, self, temp, blockType);
- setResult(temp, currDynScope, rhc.getResult(), result);
+ result = rhc.callHelper(context, currDynScope, self, temp, tempStart, blockType);
+ setResult(temp, tempStart, currDynScope, rhc.getResult(), result);
break;
}
case BOX_FLOAT: {
RubyFloat f = context.runtime.newFloat(getFloatArg(floats, ((BoxFloatInstr)instr).getValue()));
- setResult(temp, currDynScope, ((BoxInstr)instr).getResult(), f);
+ setResult(temp, tempStart, currDynScope, ((BoxInstr)instr).getResult(), f);
break;
}
case BOX_FIXNUM: {
RubyFixnum f = context.runtime.newFixnum(getFixnumArg(fixnums, ((BoxFixnumInstr) instr).getValue()));
- setResult(temp, currDynScope, ((BoxInstr)instr).getResult(), f);
+ setResult(temp, tempStart, currDynScope, ((BoxInstr)instr).getResult(), f);
break;
}
case BOX_BOOLEAN: {
RubyBoolean f = context.runtime.newBoolean(getBooleanArg(booleans, ((BoxBooleanInstr) instr).getValue()));
- setResult(temp, currDynScope, ((BoxInstr)instr).getResult(), f);
+ setResult(temp, tempStart, currDynScope, ((BoxInstr)instr).getResult(), f);
break;
}
case UNBOX_FLOAT: {
UnboxInstr ui = (UnboxInstr)instr;
- Object val = retrieveOp(ui.getValue(), context, self, currDynScope, temp);
+ Object val = retrieveOp(ui.getValue(), context, self, currDynScope, temp, tempStart);
if (val instanceof RubyFloat) {
floats[((TemporaryLocalVariable)ui.getResult()).offset] = ((RubyFloat)val).getValue();
} else {
@@ -547,7 +547,7 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
case UNBOX_FIXNUM: {
UnboxInstr ui = (UnboxInstr)instr;
- Object val = retrieveOp(ui.getValue(), context, self, currDynScope, temp);
+ Object val = retrieveOp(ui.getValue(), context, self, currDynScope, temp, tempStart);
if (val instanceof RubyFloat) {
fixnums[((TemporaryLocalVariable)ui.getResult()).offset] = ((RubyFloat)val).getLongValue();
} else {
@@ -558,8 +558,8 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
// ---------- All the rest ---------
default:
- result = instr.interpret(context, currDynScope, self, temp);
- setResult(temp, currDynScope, instr, result);
+ result = instr.interpret(context, currDynScope, self, temp, tempStart);
+ setResult(temp, tempStart, currDynScope, instr, result);
break;
}
}
@@ -571,7 +571,8 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
Map<Integer, Integer> rescueMap = scope.getRescueMap();
int numTempVars = scope.getTemporaryVariablesCount();
- Object[] temp = numTempVars > 0 ? new Object[numTempVars] : null;
+ int tempStart = context.reserveTempvars(numTempVars);
+ Object[] temp = context.tempvars();
int numFloatVars = scope.getFloatVariablesCount();
int numFixnumVars = scope.getFixnumVariablesCount();
int numBooleanVars = scope.getBooleanVariablesCount();
@@ -583,87 +584,92 @@ public class Interpreter extends IRTranslator<IRubyObject, IRubyObject> {
Object exception = null;
DynamicScope currDynScope = context.getCurrentScope();
- // Init profiling this scope
- boolean debug = IRRuntimeHelpers.isDebug();
- boolean profile = IRRuntimeHelpers.inProfileMode();
- Integer scopeVersion = profile ? Profiler.initProfiling(scope) : 0;
- boolean acceptsKeywordArgument = scope.receivesKeywordArgs();
-
- // Enter the looooop!
- while (ipc < n) {
- Instr instr = instrs[ipc];
- ipc++;
- Operation operation = instr.getOperation();
- if (debug) {
- LOG.info("I: {}", instr);
- interpInstrsCount++;
- } else if (profile) {
- Profiler.instrTick(operation);
- interpInstrsCount++;
- }
+ try {
- try {
- switch (operation.opClass) {
- case INT_OP:
- intepretIntOp((AluInstr)instr, operation, context, fixnums, booleans, temp);
- break;
- case FLOAT_OP:
- interpretFloatOp((AluInstr)instr, operation, context, floats, booleans, temp);
- break;
- case ARG_OP:
- receiveArg(context, instr, operation, args, acceptsKeywordArgument, currDynScope, temp, exception, block);
- break;
- case CALL_OP:
- if (profile) Profiler.updateCallSite(instr, scope, scopeVersion);
- processCall(context, instr, operation, currDynScope, temp, self);
- break;
- case RET_OP:
- return processReturnOp(context, instr, operation, scope, currDynScope, temp, self, blockType);
- case BRANCH_OP:
- switch (operation) {
- case JUMP: ipc = ((JumpInstr)instr).getJumpTarget().getTargetPC(); break;
- default: ipc = instr.interpretAndGetNewIPC(context, currDynScope, self, temp, ipc); break;
- }
- break;
- case BOOK_KEEPING_OP:
- if (operation == Operation.PUSH_BINDING) {
- // SSS NOTE: Method/module scopes only!
- //
- // Blocks are a headache -- so, these instrs. are only added to IRMethods.
- // Blocks have more complicated logic for pushing a dynamic scope (see InterpretedIRBlockBody)
- if (scope instanceof IRMetaClassBody) {
- // Add a parent-link to current dynscope to support non-local returns cheaply
- // This doesn't affect variable scoping since local variables will all have
- // the right scope depth.
- currDynScope = DynamicScope.newDynamicScope(scope.getStaticScope(), context.getCurrentScope());
+ // Init profiling this scope
+ boolean debug = IRRuntimeHelpers.isDebug();
+ boolean profile = IRRuntimeHelpers.inProfileMode();
+ Integer scopeVersion = profile ? Profiler.initProfiling(scope) : 0;
+ boolean acceptsKeywordArgument = scope.receivesKeywordArgs();
+
+ // Enter the looooop!
+ while (ipc < n) {
+ Instr instr = instrs[ipc];
+ ipc++;
+ Operation operation = instr.getOperation();
+ if (debug) {
+ LOG.info("I: {}", instr);
+ interpInstrsCount++;
+ } else if (profile) {
+ Profiler.instrTick(operation);
+ interpInstrsCount++;
+ }
+
+ try {
+ switch (operation.opClass) {
+ case INT_OP:
+ intepretIntOp((AluInstr)instr, operation, context, fixnums, booleans, temp, tempStart);
+ break;
+ case FLOAT_OP:
+ interpretFloatOp((AluInstr)instr, operation, context, floats, booleans, temp, tempStart);
+ break;
+ case ARG_OP:
+ receiveArg(context, instr, operation, args, acceptsKeywordArgument, currDynScope, temp, tempStart, exception, block);
+ break;
+ case CALL_OP:
+ if (profile) Profiler.updateCallSite(instr, scope, scopeVersion);
+ processCall(context, instr, operation, currDynScope, temp, tempStart, self);
+ break;
+ case RET_OP:
+ return processReturnOp(context, instr, operation, scope, currDynScope, temp, tempStart, self, blockType);
+ case BRANCH_OP:
+ switch (operation) {
+ case JUMP: ipc = ((JumpInstr)instr).getJumpTarget().getTargetPC(); break;
+ default: ipc = instr.interpretAndGetNewIPC(context, currDynScope, self, temp, tempStart, ipc); break;
+ }
+ break;
+ case BOOK_KEEPING_OP:
+ if (operation == Operation.PUSH_BINDING) {
+ // SSS NOTE: Method/module scopes only!
+ //
+ // Blocks are a headache -- so, these instrs. are only added to IRMethods.
+ // Blocks have more complicated logic for pushing a dynamic scope (see InterpretedIRBlockBody)
+ if (scope instanceof IRMetaClassBody) {
+ // Add a parent-link to current dynscope to support non-local returns cheaply
+ // This doesn't affect variable scoping since local variables will all have
+ // the right scope depth.
+ currDynScope = DynamicScope.newDynamicScope(scope.getStaticScope(), context.getCurrentScope());
+ } else {
+ currDynScope = DynamicScope.newDynamicScope(scope.getStaticScope());
+ }
+ context.pushScope(currDynScope);
} else {
- currDynScope = DynamicScope.newDynamicScope(scope.getStaticScope());
+ processBookKeepingOp(context, instr, operation, scope, name, args, self, block, implClass, visibility, temp, tempStart, currDynScope);
}
- context.pushScope(currDynScope);
+ break;
+ case OTHER_OP:
+ processOtherOp(context, instr, operation, currDynScope, temp, tempStart, self, blockType, floats, fixnums, booleans);
+ break;
+ }
+ } catch (Throwable t) {
+ if (debug) LOG.info("in scope: " + scope + ", caught Java throwable: " + t + "; excepting instr: " + instr);
+ ipc = rescueMap.get(instr.getIPC());
+ if (debug) LOG.info("ipc for rescuer: " + ipc);
+
+ if (ipc == -1) {
+ Helpers.throwException(t);
} else {
- processBookKeepingOp(context, instr, operation, scope, name, args, self, block, implClass, visibility, temp, currDynScope);
+ exception = t;
}
- break;
- case OTHER_OP:
- processOtherOp(context, instr, operation, currDynScope, temp, self, blockType, floats, fixnums, booleans);
- break;
- }
- } catch (Throwable t) {
- if (debug) LOG.info("in scope: " + scope + ", caught Java throwable: " + t + "; excepting instr: " + instr);
- ipc = rescueMap.get(instr.getIPC());
- if (debug) LOG.info("ipc for rescuer: " + ipc);
-
- if (ipc == -1) {
- Helpers.throwException(t);
- } else {
- exception = t;
}
}
- }
- // Control should never get here!
- // SSS FIXME: But looks like BEGIN/END blocks get here -- needs fixing
- return null;
+ // Control should never get here!
+ // SSS FIXME: But looks like BEGIN/END blocks get here -- needs fixing
+ return null;
+ } finally {
+ context.releaseTempvars(numTempVars);
+ }
}
public static IRubyObject INTERPRET_ROOT(ThreadContext context, IRubyObject self,
diff --git a/core/src/main/java/org/jruby/ir/operands/Array.java b/core/src/main/java/org/jruby/ir/operands/Array.java
index c6be133..f77a52d 100644
--- a/core/src/main/java/org/jruby/ir/operands/Array.java
+++ b/core/src/main/java/org/jruby/ir/operands/Array.java
@@ -94,11 +94,11 @@ public class Array extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
IRubyObject[] elements = new IRubyObject[elts.length];
for (int i = 0; i < elements.length; i++) {
- elements[i] = (IRubyObject) elts[i].retrieve(context, self, currDynScope, temp);
+ elements[i] = (IRubyObject) elts[i].retrieve(context, self, currDynScope, temp, tempStart);
}
return context.runtime.newArray(elements);
diff --git a/core/src/main/java/org/jruby/ir/operands/AsString.java b/core/src/main/java/org/jruby/ir/operands/AsString.java
index 6b287de..cd05767 100644
--- a/core/src/main/java/org/jruby/ir/operands/AsString.java
+++ b/core/src/main/java/org/jruby/ir/operands/AsString.java
@@ -20,8 +20,8 @@ public class AsString extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
- return ((IRubyObject)source.retrieve(context, self, currDynScope, temp)).asString();
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
+ return ((IRubyObject)source.retrieve(context, self, currDynScope, temp, tempStart)).asString();
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/operands/Backref.java b/core/src/main/java/org/jruby/ir/operands/Backref.java
index 2f7fd1f..980d9bc 100644
--- a/core/src/main/java/org/jruby/ir/operands/Backref.java
+++ b/core/src/main/java/org/jruby/ir/operands/Backref.java
@@ -18,7 +18,7 @@ public class Backref extends Reference {
type = t;
}
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
IRubyObject backref = context.getBackRef();
switch (type) {
diff --git a/core/src/main/java/org/jruby/ir/operands/CompoundString.java b/core/src/main/java/org/jruby/ir/operands/CompoundString.java
index 1574aca..e8fc337 100644
--- a/core/src/main/java/org/jruby/ir/operands/CompoundString.java
+++ b/core/src/main/java/org/jruby/ir/operands/CompoundString.java
@@ -1,7 +1,6 @@
package org.jruby.ir.operands;
import org.jcodings.Encoding;
-import org.jruby.Ruby;
import org.jruby.RubyString;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.transformations.inlining.InlinerInfo;
@@ -81,11 +80,11 @@ public class CompoundString extends Operand {
}
// SSS FIXME: Buggy?
- String retrieveJavaString(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ String retrieveJavaString(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
StringBuilder buf = new StringBuilder();
for (Operand p : pieces) {
- buf.append(p.retrieve(context, self, currDynScope, temp));
+ buf.append(p.retrieve(context, self, currDynScope, temp, tempStart));
}
return buf.toString();
@@ -95,17 +94,17 @@ public class CompoundString extends Operand {
return str.bytelist.getEncoding() == encoding;
}
- public RubyString[] retrievePieces(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public RubyString[] retrievePieces(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
RubyString[] strings = new RubyString[pieces.size()];
int i = 0;
for (Operand p : pieces) {
- strings[i++] = (RubyString)p.retrieve(context, self, currDynScope, temp);
+ strings[i++] = (RubyString)p.retrieve(context, self, currDynScope, temp, tempStart);
}
return strings;
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
// SSS FIXME: Doesn't work in all cases. See example below
//
// s = "x\234\355\301\001\001\000\000\000\200\220\376\257\356\b\n#{"\000" * 31}\030\200\000\000\001"
@@ -120,7 +119,7 @@ public class CompoundString extends Operand {
if ((p instanceof StringLiteral) && (isSameEncoding((StringLiteral)p))) {
str.getByteList().append(((StringLiteral)p).bytelist);
} else {
- IRubyObject pval = (IRubyObject)p.retrieve(context, self, currDynScope, temp);
+ IRubyObject pval = (IRubyObject)p.retrieve(context, self, currDynScope, temp, tempStart);
str.append19(pval);
}
}
diff --git a/core/src/main/java/org/jruby/ir/operands/ConstantStringLiteral.java b/core/src/main/java/org/jruby/ir/operands/ConstantStringLiteral.java
index bf00143..9136d0a 100644
--- a/core/src/main/java/org/jruby/ir/operands/ConstantStringLiteral.java
+++ b/core/src/main/java/org/jruby/ir/operands/ConstantStringLiteral.java
@@ -14,8 +14,8 @@ public class ConstantStringLiteral extends StringLiteral {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
- RubyString string = (RubyString) super.retrieve(context, self, currDynScope, temp);
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
+ RubyString string = (RubyString) super.retrieve(context, self, currDynScope, temp, tempStart);
return context.runtime.freezeAndDedupString(string);
}
diff --git a/core/src/main/java/org/jruby/ir/operands/CurrentScope.java b/core/src/main/java/org/jruby/ir/operands/CurrentScope.java
index f2e5025..226b83e 100644
--- a/core/src/main/java/org/jruby/ir/operands/CurrentScope.java
+++ b/core/src/main/java/org/jruby/ir/operands/CurrentScope.java
@@ -47,7 +47,7 @@ public class CurrentScope extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return scope.getStaticScope();
}
diff --git a/core/src/main/java/org/jruby/ir/operands/DynamicSymbol.java b/core/src/main/java/org/jruby/ir/operands/DynamicSymbol.java
index 18ffe14..ff39929 100644
--- a/core/src/main/java/org/jruby/ir/operands/DynamicSymbol.java
+++ b/core/src/main/java/org/jruby/ir/operands/DynamicSymbol.java
@@ -41,8 +41,8 @@ public class DynamicSymbol extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
- return context.runtime.newSymbol(((IRubyObject) symbolName.retrieve(context, self, currDynScope, temp)).asJavaString());
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
+ return context.runtime.newSymbol(((IRubyObject) symbolName.retrieve(context, self, currDynScope, temp, tempStart)).asJavaString());
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/operands/GlobalVariable.java b/core/src/main/java/org/jruby/ir/operands/GlobalVariable.java
index 06432e5..ac171de 100644
--- a/core/src/main/java/org/jruby/ir/operands/GlobalVariable.java
+++ b/core/src/main/java/org/jruby/ir/operands/GlobalVariable.java
@@ -20,7 +20,7 @@ public class GlobalVariable extends Reference {
@Interp
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return context.runtime.getGlobalVariables().get(getName());
}
diff --git a/core/src/main/java/org/jruby/ir/operands/Hash.java b/core/src/main/java/org/jruby/ir/operands/Hash.java
index b9701ed..833ea35 100644
--- a/core/src/main/java/org/jruby/ir/operands/Hash.java
+++ b/core/src/main/java/org/jruby/ir/operands/Hash.java
@@ -75,15 +75,15 @@ public class Hash extends Operand {
@Override
public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope,
- Object[] temp) {
+ Object[] temp, int tempStart) {
Ruby runtime = context.runtime;
RubyHash hash = RubyHash.newHash(runtime);
for (KeyValuePair<Operand, Operand> pair : pairs) {
IRubyObject key = (IRubyObject) pair.getKey().retrieve(context, self, currDynScope,
- temp);
+ temp, tempStart);
IRubyObject value = (IRubyObject) pair.getValue().retrieve(context, self, currDynScope,
- temp);
+ temp, tempStart);
hash.fastASetCheckString(runtime, key, value);
}
diff --git a/core/src/main/java/org/jruby/ir/operands/ImmutableLiteral.java b/core/src/main/java/org/jruby/ir/operands/ImmutableLiteral.java
index 2eb4e49..59fbd1a 100644
--- a/core/src/main/java/org/jruby/ir/operands/ImmutableLiteral.java
+++ b/core/src/main/java/org/jruby/ir/operands/ImmutableLiteral.java
@@ -79,7 +79,7 @@ public abstract class ImmutableLiteral extends Operand {
* assume the cost of constructing literals which may never be used.
*/
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return cachedObject(context);
}
}
diff --git a/core/src/main/java/org/jruby/ir/operands/LocalVariable.java b/core/src/main/java/org/jruby/ir/operands/LocalVariable.java
index f97b6c3..c924668 100644
--- a/core/src/main/java/org/jruby/ir/operands/LocalVariable.java
+++ b/core/src/main/java/org/jruby/ir/operands/LocalVariable.java
@@ -72,7 +72,7 @@ public class LocalVariable extends Variable implements DepthCloneable {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
IRubyObject value = currDynScope.getValue(offset, scopeDepth);
if (value == null) value = context.nil;
return value;
diff --git a/core/src/main/java/org/jruby/ir/operands/MethAddr.java b/core/src/main/java/org/jruby/ir/operands/MethAddr.java
index f55e724..c9f3283 100644
--- a/core/src/main/java/org/jruby/ir/operands/MethAddr.java
+++ b/core/src/main/java/org/jruby/ir/operands/MethAddr.java
@@ -27,7 +27,7 @@ public class MethAddr extends Reference {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return getName();
}
diff --git a/core/src/main/java/org/jruby/ir/operands/MethodHandle.java b/core/src/main/java/org/jruby/ir/operands/MethodHandle.java
index 5db13cb..ee58a35 100644
--- a/core/src/main/java/org/jruby/ir/operands/MethodHandle.java
+++ b/core/src/main/java/org/jruby/ir/operands/MethodHandle.java
@@ -84,13 +84,13 @@ public class MethodHandle extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
- receiverObj = (IRubyObject)receiver.retrieve(context, self, currDynScope, temp);
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
+ receiverObj = (IRubyObject)receiver.retrieve(context, self, currDynScope, temp, tempStart);
if (methodName instanceof MethAddr) {
resolvedMethodName = ((MethAddr)methodName).getName();
} else {
- IRubyObject mnameObj = (IRubyObject)methodName.retrieve(context, self, currDynScope, temp);
+ IRubyObject mnameObj = (IRubyObject)methodName.retrieve(context, self, currDynScope, temp, tempStart);
// SSS FIXME: If this is not a ruby string or a symbol, then this is an error in the source code!
// Raise an exception and throw an error. This should not be an assert.
diff --git a/core/src/main/java/org/jruby/ir/operands/NthRef.java b/core/src/main/java/org/jruby/ir/operands/NthRef.java
index 928ae2d..60c67c5 100644
--- a/core/src/main/java/org/jruby/ir/operands/NthRef.java
+++ b/core/src/main/java/org/jruby/ir/operands/NthRef.java
@@ -19,7 +19,7 @@ public class NthRef extends Reference {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return IRRuntimeHelpers.nthMatch(context, matchNumber);
}
diff --git a/core/src/main/java/org/jruby/ir/operands/ObjectClass.java b/core/src/main/java/org/jruby/ir/operands/ObjectClass.java
index b8d3d14..cb4d129 100644
--- a/core/src/main/java/org/jruby/ir/operands/ObjectClass.java
+++ b/core/src/main/java/org/jruby/ir/operands/ObjectClass.java
@@ -34,7 +34,7 @@ public class ObjectClass extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return context.runtime.getObject();
}
diff --git a/core/src/main/java/org/jruby/ir/operands/Operand.java b/core/src/main/java/org/jruby/ir/operands/Operand.java
index ee78106..e9e1d60 100644
--- a/core/src/main/java/org/jruby/ir/operands/Operand.java
+++ b/core/src/main/java/org/jruby/ir/operands/Operand.java
@@ -82,7 +82,7 @@ public abstract class Operand {
public abstract Operand cloneForInlining(InlinerInfo ii);
@Interp
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
throw new RuntimeException(this.getClass().getSimpleName() + " should not be directly retrieved.");
}
diff --git a/core/src/main/java/org/jruby/ir/operands/Range.java b/core/src/main/java/org/jruby/ir/operands/Range.java
index e726a6b..fd6269c 100644
--- a/core/src/main/java/org/jruby/ir/operands/Range.java
+++ b/core/src/main/java/org/jruby/ir/operands/Range.java
@@ -72,10 +72,10 @@ public class Range extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return RubyRange.newRange(context.runtime, context,
- (IRubyObject) begin.retrieve(context, self, currDynScope, temp),
- (IRubyObject) end.retrieve(context, self, currDynScope, temp), exclusive);
+ (IRubyObject) begin.retrieve(context, self, currDynScope, temp, tempStart),
+ (IRubyObject) end.retrieve(context, self, currDynScope, temp, tempStart), exclusive);
}
@Override
diff --git a/core/src/main/java/org/jruby/ir/operands/Regexp.java b/core/src/main/java/org/jruby/ir/operands/Regexp.java
index 6ae0953..480d410 100644
--- a/core/src/main/java/org/jruby/ir/operands/Regexp.java
+++ b/core/src/main/java/org/jruby/ir/operands/Regexp.java
@@ -61,17 +61,17 @@ public class Regexp extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
// FIXME (from RegexpNode.java): 1.9 should care about internal or external encoding and not kcode.
// If we have a constant regexp string or if the regexp patterns asks for caching, cache the regexp
if ((!regexp.hasKnownValue() && !options.isOnce()) || (rubyRegexp == null) || context.runtime.getKCode() != rubyRegexp.getKCode()) {
RubyRegexp re;
if (regexp instanceof CompoundString) {
- RubyString[] pieces = ((CompoundString)regexp).retrievePieces(context, self, currDynScope, temp);
+ RubyString[] pieces = ((CompoundString)regexp).retrievePieces(context, self, currDynScope, temp, tempStart);
RubyString pattern = RubyRegexp.preprocessDRegexp(context.runtime, pieces, options);
re = RubyRegexp.newDRegexp(context.runtime, pattern, options);
} else {
- RubyString pattern = (RubyString) regexp.retrieve(context, self, currDynScope, temp);
+ RubyString pattern = (RubyString) regexp.retrieve(context, self, currDynScope, temp, tempStart);
re = RubyRegexp.newRegexp(context.runtime, pattern.getByteList(), options);
}
re.setLiteral();
diff --git a/core/src/main/java/org/jruby/ir/operands/SValue.java b/core/src/main/java/org/jruby/ir/operands/SValue.java
index 0e36304..b955b7f 100644
--- a/core/src/main/java/org/jruby/ir/operands/SValue.java
+++ b/core/src/main/java/org/jruby/ir/operands/SValue.java
@@ -66,8 +66,8 @@ public class SValue extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
- Object val = array.retrieve(context, self, currDynScope, temp);
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
+ Object val = array.retrieve(context, self, currDynScope, temp, tempStart);
return (val instanceof RubyArray) ? val : context.runtime.getNil();
}
diff --git a/core/src/main/java/org/jruby/ir/operands/ScopeModule.java b/core/src/main/java/org/jruby/ir/operands/ScopeModule.java
index 425de7d..cc614a8 100644
--- a/core/src/main/java/org/jruby/ir/operands/ScopeModule.java
+++ b/core/src/main/java/org/jruby/ir/operands/ScopeModule.java
@@ -57,7 +57,7 @@ public class ScopeModule extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
StaticScope staticScope = scope.getStaticScope();
return staticScope != null ? staticScope.getModule() : context.runtime.getClass(scope.getName());
}
diff --git a/core/src/main/java/org/jruby/ir/operands/Self.java b/core/src/main/java/org/jruby/ir/operands/Self.java
index 1c2f289..558cd0c 100644
--- a/core/src/main/java/org/jruby/ir/operands/Self.java
+++ b/core/src/main/java/org/jruby/ir/operands/Self.java
@@ -24,7 +24,7 @@ public class Self extends LocalVariable {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return self;
}
diff --git a/core/src/main/java/org/jruby/ir/operands/Splat.java b/core/src/main/java/org/jruby/ir/operands/Splat.java
index a4947d3..cd2ef82 100644
--- a/core/src/main/java/org/jruby/ir/operands/Splat.java
+++ b/core/src/main/java/org/jruby/ir/operands/Splat.java
@@ -72,8 +72,8 @@ public class Splat extends Operand implements DepthCloneable {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
- IRubyObject arrayVal = (IRubyObject) array.retrieve(context, self, currDynScope, temp);
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
+ IRubyObject arrayVal = (IRubyObject) array.retrieve(context, self, currDynScope, temp, tempStart);
// SSS FIXME: Some way to specialize this code?
return Helpers.irSplat(context, arrayVal);
}
diff --git a/core/src/main/java/org/jruby/ir/operands/StringLiteral.java b/core/src/main/java/org/jruby/ir/operands/StringLiteral.java
index 84e4cdb..0f56935 100644
--- a/core/src/main/java/org/jruby/ir/operands/StringLiteral.java
+++ b/core/src/main/java/org/jruby/ir/operands/StringLiteral.java
@@ -80,7 +80,7 @@ public class StringLiteral extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
// SSS FIXME: AST interpreter passes in a coderange argument.
return RubyString.newStringShared(context.runtime, bytelist);
}
diff --git a/core/src/main/java/org/jruby/ir/operands/Symbol.java b/core/src/main/java/org/jruby/ir/operands/Symbol.java
index b263f68..d73310a 100644
--- a/core/src/main/java/org/jruby/ir/operands/Symbol.java
+++ b/core/src/main/java/org/jruby/ir/operands/Symbol.java
@@ -16,7 +16,7 @@ public class Symbol extends Reference {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return context.runtime.newSymbol(getName());
}
diff --git a/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java b/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java
index 9bcf915..42eb4ad 100644
--- a/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java
+++ b/core/src/main/java/org/jruby/ir/operands/TemporaryLocalVariable.java
@@ -50,7 +50,7 @@ public class TemporaryLocalVariable extends TemporaryVariable {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
// SSS FIXME: When AddLocalVarLoadStoreInstructions pass is not enabled, we don't need this check.
// We only need these because Ruby code can have local vars used before being defined.
//
@@ -63,7 +63,7 @@ public class TemporaryLocalVariable extends TemporaryVariable {
// both here and in DynamicScope var lookups. To be done later.
//
// I dont like this at all. This feels ugly!
- Object o = temp[offset];
+ Object o = temp[tempStart + offset];
return o == null ? context.nil : o;
}
diff --git a/core/src/main/java/org/jruby/ir/operands/UndefinedValue.java b/core/src/main/java/org/jruby/ir/operands/UndefinedValue.java
index dc83048..5eb8e68 100644
--- a/core/src/main/java/org/jruby/ir/operands/UndefinedValue.java
+++ b/core/src/main/java/org/jruby/ir/operands/UndefinedValue.java
@@ -49,7 +49,7 @@ public class UndefinedValue extends Operand implements IRubyObject {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
return this;
}
diff --git a/core/src/main/java/org/jruby/ir/operands/UnexecutableNil.java b/core/src/main/java/org/jruby/ir/operands/UnexecutableNil.java
index 92b07ad..ddfc0ab 100644
--- a/core/src/main/java/org/jruby/ir/operands/UnexecutableNil.java
+++ b/core/src/main/java/org/jruby/ir/operands/UnexecutableNil.java
@@ -24,7 +24,7 @@ public class UnexecutableNil extends Nil {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
throw new RuntimeException(this.getClass().getSimpleName() + " should not be directly interpreted");
}
diff --git a/core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java b/core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java
index 5fbaf0d..f80a084 100644
--- a/core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java
+++ b/core/src/main/java/org/jruby/ir/operands/WrappedIRClosure.java
@@ -59,14 +59,14 @@ public class WrappedIRClosure extends Operand {
}
@Override
- public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp) {
+ public Object retrieve(ThreadContext context, IRubyObject self, DynamicScope currDynScope, Object[] temp, int tempStart) {
BlockBody body = closure.getBlockBody();
closure.getStaticScope().determineModule();
// In non-inlining scenarios, this.self will always be %self.
// However, in inlined scenarios, this.self will be the self in the original scope where the closure
// was present before inlining.
- IRubyObject selfVal = (this.self instanceof Self) ? self : (IRubyObject)this.self.retrieve(context, self, currDynScope, temp);
+ IRubyObject selfVal = (this.self instanceof Self) ? self : (IRubyObject)this.self.retrieve(context, self, currDynScope, temp, tempStart);
Binding binding = context.currentBinding(selfVal, currDynScope);
return new Block(body, binding);
diff --git a/core/src/main/java/org/jruby/runtime/ThreadContext.java b/core/src/main/java/org/jruby/runtime/ThreadContext.java
index d6c920b..50466d4 100644
--- a/core/src/main/java/org/jruby/runtime/ThreadContext.java
+++ b/core/src/main/java/org/jruby/runtime/ThreadContext.java
@@ -117,6 +117,30 @@ public final class ThreadContext {
private static final Continuation[] EMPTY_CATCHTARGET_STACK = new Continuation[0];
private Continuation[] catchStack = EMPTY_CATCHTARGET_STACK;
private int catchIndex = -1;
+
+ private Object[] tempvars = new Object[100000];
+ private int tempvarsStart = 0;
+
+ public int reserveTempvars(int count) {
+ if (tempvarsStart + count > tempvars.length) {
+ throw new RuntimeException("out of tempvar space");
+ }
+ int start = tempvarsStart;
+ tempvarsStart += count;
+ return start;
+ }
+
+ public void releaseTempvars(int count) {
+ if (tempvarsStart - count < 0) {
+ throw new RuntimeException("assymetrical tempvars release");
+ }
+
+ tempvarsStart -= count;
+ }
+
+ public Object[] tempvars() {
+ return tempvars;
+ }
private boolean isProfiling = false;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment