Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 245279f914e9
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 4da20e12d9e6
Choose a head ref
  • 2 commits
  • 80 files changed
  • 1 contributor

Commits on Mar 10, 2015

  1. Copy the full SHA
    eb31ee4 View commit details
  2. Copy the full SHA
    4da20e1 View commit details
Showing with 644 additions and 624 deletions.
  1. +9 −0 core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
  2. +1 −0 core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java
  3. +7 −0 core/src/main/java/org/jruby/ir/instructions/BacktickInstr.java
  4. +7 −0 core/src/main/java/org/jruby/ir/instructions/BlockGivenInstr.java
  5. +8 −0 core/src/main/java/org/jruby/ir/instructions/BreakInstr.java
  6. +9 −0 core/src/main/java/org/jruby/ir/instructions/BuildCompoundArrayInstr.java
  7. +8 −0 core/src/main/java/org/jruby/ir/instructions/BuildCompoundStringInstr.java
  8. +8 −0 core/src/main/java/org/jruby/ir/instructions/BuildDynRegExpInstr.java
  9. +9 −0 core/src/main/java/org/jruby/ir/instructions/BuildLambdaInstr.java
  10. +9 −0 core/src/main/java/org/jruby/ir/instructions/BuildRangeInstr.java
  11. +7 −0 core/src/main/java/org/jruby/ir/instructions/BuildSplatInstr.java
  12. +24 −0 core/src/main/java/org/jruby/ir/instructions/CallBase.java
  13. +8 −0 core/src/main/java/org/jruby/ir/instructions/CallInstr.java
  14. +10 −0 core/src/main/java/org/jruby/ir/instructions/CheckArgsArrayArityInstr.java
  15. +10 −0 core/src/main/java/org/jruby/ir/instructions/CheckArityInstr.java
  16. +7 −0 core/src/main/java/org/jruby/ir/instructions/CheckForLJEInstr.java
  17. +8 −0 core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java
  18. +7 −0 core/src/main/java/org/jruby/ir/instructions/CopyInstr.java
  19. +9 −0 core/src/main/java/org/jruby/ir/instructions/DefineClassInstr.java
  20. +8 −0 core/src/main/java/org/jruby/ir/instructions/DefineClassMethodInstr.java
  21. +7 −0 core/src/main/java/org/jruby/ir/instructions/DefineInstanceMethodInstr.java
  22. +8 −0 core/src/main/java/org/jruby/ir/instructions/DefineMetaClassInstr.java
  23. +8 −0 core/src/main/java/org/jruby/ir/instructions/DefineModuleInstr.java
  24. +8 −0 core/src/main/java/org/jruby/ir/instructions/EQQInstr.java
  25. +7 −0 core/src/main/java/org/jruby/ir/instructions/ExceptionRegionStartMarkerInstr.java
  26. +8 −0 core/src/main/java/org/jruby/ir/instructions/GVarAliasInstr.java
  27. +8 −0 core/src/main/java/org/jruby/ir/instructions/GetClassVarContainerModuleInstr.java
  28. +1 −0 core/src/main/java/org/jruby/ir/instructions/GetClassVariableInstr.java
  29. +7 −0 core/src/main/java/org/jruby/ir/instructions/GetEncodingInstr.java
  30. +16 −5 core/src/main/java/org/jruby/ir/instructions/GetGlobalVariableInstr.java
  31. +8 −0 core/src/main/java/org/jruby/ir/instructions/GetInstr.java
  32. +9 −0 core/src/main/java/org/jruby/ir/instructions/InheritanceSearchConstInstr.java
  33. +7 −0 core/src/main/java/org/jruby/ir/instructions/Instr.java
  34. +6 −0 core/src/main/java/org/jruby/ir/instructions/JumpInstr.java
  35. +7 −0 core/src/main/java/org/jruby/ir/instructions/LabelInstr.java
  36. +8 −0 core/src/main/java/org/jruby/ir/instructions/LexicalSearchConstInstr.java
  37. +7 −0 core/src/main/java/org/jruby/ir/instructions/LineNumberInstr.java
  38. +8 −0 core/src/main/java/org/jruby/ir/instructions/LoadLocalVarInstr.java
  39. +8 −0 core/src/main/java/org/jruby/ir/instructions/Match2Instr.java
  40. +8 −0 core/src/main/java/org/jruby/ir/instructions/Match3Instr.java
  41. +7 −0 core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
  42. +9 −0 core/src/main/java/org/jruby/ir/instructions/NoResultCallInstr.java
  43. +8 −0 core/src/main/java/org/jruby/ir/instructions/NonlocalReturnInstr.java
  44. +8 −0 core/src/main/java/org/jruby/ir/instructions/OneOperandBranchInstr.java
  45. +9 −0 core/src/main/java/org/jruby/ir/instructions/OptArgMultipleAsgnInstr.java
  46. +8 −0 core/src/main/java/org/jruby/ir/instructions/ProcessModuleBodyInstr.java
  47. +22 −6 core/src/main/java/org/jruby/ir/instructions/PutGlobalVarInstr.java
  48. +9 −0 core/src/main/java/org/jruby/ir/instructions/PutInstr.java
  49. +10 −0 core/src/main/java/org/jruby/ir/instructions/RaiseArgumentErrorInstr.java
  50. +7 −0 core/src/main/java/org/jruby/ir/instructions/RaiseRequiredKeywordArgumentError.java
  51. +8 −0 core/src/main/java/org/jruby/ir/instructions/ReceiveKeywordArgInstr.java
  52. +7 −0 core/src/main/java/org/jruby/ir/instructions/ReceiveKeywordRestArgInstr.java
  53. +9 −0 core/src/main/java/org/jruby/ir/instructions/ReceiveOptArgInstr.java
  54. +9 −0 core/src/main/java/org/jruby/ir/instructions/ReceivePostReqdArgInstr.java
  55. +7 −0 core/src/main/java/org/jruby/ir/instructions/ReceivePreReqdArgInstr.java
  56. +8 −0 core/src/main/java/org/jruby/ir/instructions/ReceiveRestArgInstr.java
  57. +8 −0 core/src/main/java/org/jruby/ir/instructions/RecordEndBlockInstr.java
  58. +9 −1 core/src/main/java/org/jruby/ir/instructions/ReifyClosureInstr.java
  59. +10 −0 core/src/main/java/org/jruby/ir/instructions/ReqdArgMultipleAsgnInstr.java
  60. +8 −0 core/src/main/java/org/jruby/ir/instructions/RescueEQQInstr.java
  61. +10 −0 core/src/main/java/org/jruby/ir/instructions/RestArgMultipleAsgnInstr.java
  62. +8 −0 core/src/main/java/org/jruby/ir/instructions/ResultBaseInstr.java
  63. +7 −0 core/src/main/java/org/jruby/ir/instructions/ReturnInstr.java
  64. +8 −0 core/src/main/java/org/jruby/ir/instructions/RuntimeHelperCall.java
  65. +9 −0 core/src/main/java/org/jruby/ir/instructions/SearchConstInstr.java
  66. +8 −0 core/src/main/java/org/jruby/ir/instructions/SetCapturedVarInstr.java
  67. +9 −0 core/src/main/java/org/jruby/ir/instructions/StoreLocalVarInstr.java
  68. +7 −0 core/src/main/java/org/jruby/ir/instructions/ThreadPollInstr.java
  69. +7 −0 core/src/main/java/org/jruby/ir/instructions/ThrowExceptionInstr.java
  70. +7 −0 core/src/main/java/org/jruby/ir/instructions/ToAryInstr.java
  71. +10 −0 core/src/main/java/org/jruby/ir/instructions/TraceInstr.java
  72. +9 −0 core/src/main/java/org/jruby/ir/instructions/TwoOperandBranchInstr.java
  73. +7 −0 core/src/main/java/org/jruby/ir/instructions/UndefMethodInstr.java
  74. +9 −0 core/src/main/java/org/jruby/ir/instructions/YieldInstr.java
  75. +7 −0 core/src/main/java/org/jruby/ir/instructions/defined/RestoreErrorInfoInstr.java
  76. +4 −0 core/src/main/java/org/jruby/ir/persistence/IRWriterAnalzer.java
  77. +1 −0 core/src/main/java/org/jruby/ir/persistence/IRWriterEncoder.java
  78. +9 −3 core/src/main/java/org/jruby/ir/persistence/IRWriterFile.java
  79. +0 −606 core/src/main/java/org/jruby/ir/persistence/InstrEncoderMap.java
  80. +1 −3 core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/AliasInstr.java
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -26,6 +27,14 @@ public boolean computeScopeFlags(IRScope scope) {
return true;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getNewName());
e.encode(getOldName());
}

@Override
public Instr clone(CloneInfo ii) {
return new AliasInstr(getNewName().cloneForInlining(ii), getOldName().cloneForInlining(ii));
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.specialized.OneArgOperandAttrAssignInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.*;
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -31,6 +32,12 @@ public Instr clone(CloneInfo ii) {
return new BacktickInstr(ii.getRenamedVariable(result), cloneOperands(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getPieces());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyString newString = context.runtime.newString();
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -29,6 +30,12 @@ public Instr clone(CloneInfo ii) {
return new BlockGivenInstr(ii.getRenamedVariable(result), getBlockArg().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBlockArg());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Object blk = getBlockArg().retrieve(context, self, currScope, currDynScope, temp);
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/BreakInstr.java
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.StringLiteral;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
@@ -95,6 +96,13 @@ public Instr clone(CloneInfo info) {
}
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReturnValue());
e.encode(getScopeName());
}

@Override
public void visit(IRVisitor visitor) {
visitor.BreakInstr(this);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -42,6 +43,14 @@ public Instr clone(CloneInfo ii) {
getAppendedArg().cloneForInlining(ii), isArgsPush);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getAppendingArg());
e.encode(getAppendedArg());
e.encode(isArgsPush());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject v1 = (IRubyObject)getAppendingArg().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.StringLiteral;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -44,6 +45,13 @@ public boolean isSameEncodingAndCodeRange(RubyString str, StringLiteral newStr)
return newStr.bytelist.getEncoding() == encoding && newStr.getCodeRange() == str.getCodeRange();
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(encoding == null ? "" : encoding.toString());
e.encode(getPieces());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
ByteList bytes = new ByteList();
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -58,6 +59,13 @@ private RubyString[] retrievePieces(ThreadContext context, IRubyObject self, Sta
return strings;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getPieces());
e.encode(getOptions().toEmbeddedOptions());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// FIXME (from RegexpNode.java): 1.9 should care about internal or external encoding and not kcode.
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.lexer.yacc.ISourcePosition;
import org.jruby.parser.StaticScope;
@@ -53,6 +54,14 @@ public Operand getClosureArg() {
return operands[0];
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getLambdaBody());
e.encode(getPosition().getFile());
e.encode(getPosition().getLine());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// SSS FIXME: Copied this from ast/LambdaNode ... Is this required here as well?
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -48,6 +49,14 @@ public Instr clone(CloneInfo ii) {
getEnd().cloneForInlining(ii), exclusive);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBegin());
e.encode(getEnd());
e.encode(isExclusive());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
return RubyRange.newRange(context,
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -32,6 +33,12 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco
(IRubyObject) getArray().retrieve(context, self, currScope, currDynScope, temp));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArray());
}

@Override
public void visit(IRVisitor visitor) {
visitor.BuildSplatInstr(this);
24 changes: 24 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CallBase.java
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.*;
import org.jruby.ir.operands.Float;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -54,6 +55,29 @@ protected CallBase(Operation op, CallType callType, String name, Operand receive
procNew = false;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getCallType().ordinal());
e.encode(getName());
e.encode(getReceiver());
e.encode(calculateArity(getCallArgs(), hasClosure));

for (Operand arg: getCallArgs()) {
e.encode(arg);
}

if (hasClosure) e.encode(getClosureArg(null));

}

// FIXME: Convert this to some Signature/Arity method
// -0 is not possible so we add 1 to arguments with closure so we get a valid negative value.
private int calculateArity(Operand[] arguments, boolean hasClosure) {
return hasClosure ? -1*(arguments.length + 1) : arguments.length;
}

private static Operand[] getOperands(Operand receiver, Operand[] arguments, Operand closure) {
return buildAllArgs(receiver, arguments, closure);
}
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CallInstr.java
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import org.jruby.ir.instructions.specialized.ZeroOperandArgNoBlockCallInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.CallType;

@@ -64,6 +65,13 @@ public CallInstr(Operation op, CallInstr ordinary) {
ordinary.getClosureArg(null));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getResult());
}

public Variable getResult() {
return result;
}
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -38,6 +39,15 @@ public Instr clone(CloneInfo ii) {
return new CheckArgsArrayArityInstr(getArgsArray().cloneForInlining(ii), required, opt, rest);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArgsArray());
e.encode(required);
e.encode(opt);
e.encode(rest);
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyArray args = (RubyArray) getArgsArray().retrieve(context, self, currScope, currDynScope, temp);
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CheckArityInstr.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Fixnum;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
@@ -50,6 +51,15 @@ public Instr clone(CloneInfo info) {
return new CheckArgsArrayArityInstr(ii.getArgs(), required, opt, rest);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(required);
e.encode(opt);
e.encode(rest);
e.encode(receivesKeywords);
}

public void checkArity(ThreadContext context, Object[] args) {
IRRuntimeHelpers.checkArity(context, args, required, opt, rest, receivesKeywords, restKey);
}
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.Block;
@@ -28,6 +29,12 @@ public Instr clone(CloneInfo info) {
return new CheckForLJEInstr(maybeLambda);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(maybeLambda());
}

public void visit(IRVisitor visitor) {
visitor.CheckForLJEInstr(this);
}
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Symbol;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.CallType;
@@ -34,6 +35,13 @@ public Instr clone(CloneInfo ii) {
return new ConstMissingInstr(ii.getRenamedVariable(result), getReceiver().cloneForInlining(ii), missingConst);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReceiver());
e.encode(getMissingConst());
}

@Override
public String[] toStringNonOperandArgs() {
String[] base = super.toStringNonOperandArgs();
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/CopyInstr.java
Original file line number Diff line number Diff line change
@@ -10,6 +10,7 @@
import org.jruby.ir.operands.Variable;

import java.util.Map;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;

public class CopyInstr extends ResultBaseInstr implements FixedArityInstr {
@@ -37,6 +38,12 @@ public Instr clone(CloneInfo ii) {
return new CopyInstr(getOperation(), ii.getRenamedVariable(result), getSource().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getSource());
}

@Override
public void visit(IRVisitor visitor) {
visitor.CopyInstr(this);
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -47,6 +48,14 @@ public String[] toStringNonOperandArgs() {
return new String[] {"name: " + newIRClassBody.getName() };
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getNewIRClassBody());
e.encode(getContainer());
e.encode(getSuperClass());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Object container = getContainer().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -39,6 +40,13 @@ public Instr clone(CloneInfo ii) {
return new DefineClassMethodInstr(getContainer().cloneForInlining(ii), method);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getContainer());
e.encode(getMethod());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject obj = (IRubyObject) getContainer().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.instructions;

import org.jruby.ir.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -39,6 +40,12 @@ public Instr clone(CloneInfo ii) {
return new DefineInstanceMethodInstr(method);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getMethod());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRRuntimeHelpers.defInterpretedInstanceMethod(context, method, currDynScope, self);
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.*;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -51,6 +52,13 @@ public Instr clone(CloneInfo ii) {
return new DefineMetaClassInstr(ii.getRenamedVariable(result), getObject().cloneForInlining(ii), metaClassBody);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getObject());
e.encode(getMetaClassBody());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Ruby runtime = context.runtime;
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -42,6 +43,13 @@ public Instr clone(CloneInfo ii) {
return new DefineModuleInstr(ii.getRenamedVariable(result), this.newIRModuleBody, getContainer().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getNewIRModuleBody());
e.encode(getContainer());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Object rubyContainer = getContainer().retrieve(context, self, currScope, currDynScope, temp);
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/EQQInstr.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -32,6 +33,13 @@ public Instr clone(CloneInfo ii) {
return new EQQInstr(ii.getRenamedVariable(result), getArg1().cloneForInlining(ii), getArg2().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArg1());
e.encode(getArg2());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
return IRRuntimeHelpers.isEQQ(context,
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;

public class ExceptionRegionStartMarkerInstr extends Instr implements FixedArityInstr {
@@ -20,6 +21,12 @@ public Instr clone(CloneInfo ii) {
return new ExceptionRegionStartMarkerInstr(ii.getRenamedLabel((Label) operands[0]));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getFirstRescueBlockLabel());
}

@Override
public void visit(IRVisitor visitor) {
visitor.ExceptionRegionStartMarkerInstr(this);
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -27,6 +28,13 @@ public Instr clone(CloneInfo ii) {
return new GVarAliasInstr(getNewName().cloneForInlining(ii), getOldName().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getNewName());
e.encode(getOldName());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
String newNameString = getNewName().retrieve(context, self, currScope, currDynScope, temp).toString();
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -39,6 +40,13 @@ public Instr clone(CloneInfo ii) {
getObject() == null ? null : (Variable) getObject().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getStartingScope());
e.encode(getObject());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
StaticScope scope = (StaticScope) getStartingScope().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.StringLiteral;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -40,6 +41,12 @@ public Object interpret(ThreadContext context, StaticScope currScope, DynamicSco
return context.runtime.getEncodingService().getEncoding(encoding);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getEncoding().toString());
}

@Override
public void visit(IRVisitor visitor) {
visitor.GetEncodingInstr(this);
Original file line number Diff line number Diff line change
@@ -7,23 +7,28 @@
import org.jruby.ir.operands.GlobalVariable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

public class GetGlobalVariableInstr extends GetInstr implements FixedArityInstr {
public class GetGlobalVariableInstr extends ResultBaseInstr implements FixedArityInstr {
public GetGlobalVariableInstr(Variable dest, String gvarName) {
this(dest, new GlobalVariable(gvarName));
}

public GetGlobalVariableInstr(Variable dest, GlobalVariable gvar) {
super(Operation.GET_GLOBAL_VAR, dest, gvar, null);
super(Operation.GET_GLOBAL_VAR, dest, new Operand[] { gvar });
}

public GlobalVariable getGVar() {
return (GlobalVariable) operands[0];
}

public boolean computeScopeFlags(IRScope scope) {
String name = ((GlobalVariable) getSource()).getName();
String name = getGVar().getName();

if (name.equals("$_") || name.equals("$~") || name.equals("$`") || name.equals("$'") ||
name.equals("$+") || name.equals("$LAST_READ_LINE") || name.equals("$LAST_MATCH_INFO") ||
@@ -37,12 +42,18 @@ public boolean computeScopeFlags(IRScope scope) {

@Override
public Instr clone(CloneInfo ii) {
return new GetGlobalVariableInstr(ii.getRenamedVariable(getResult()), ((GlobalVariable)getSource()).getName());
return new GetGlobalVariableInstr(ii.getRenamedVariable(getResult()), getGVar().getName());
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getGVar());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
return getSource().retrieve(context, self, currScope, currDynScope, temp);
return getGVar().retrieve(context, self, currScope, currDynScope, temp);
}

@Override
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/GetInstr.java
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;

// Represents result = source.ref or result = source where source is not a stack variable
public abstract class GetInstr extends ResultBaseInstr implements FixedArityInstr {
@@ -24,6 +25,13 @@ public Operand getSource() {
return operands[0];
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getSource());
e.encode(getRef());
}

@Override
public String[] toStringNonOperandArgs() {
return new String[] {"name: " + ref};
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -69,6 +70,14 @@ private Object cache(Ruby runtime, RubyModule module) {
return constant;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getCurrentModule());
e.encode(getConstName());
e.encode(isNoPrivateConsts());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Object cmVal = getCurrentModule().retrieve(context, self, currScope, currDynScope, temp);
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/Instr.java
Original file line number Diff line number Diff line change
@@ -2,13 +2,15 @@

// A generic IR instruction is of the form: v = OP(arg_array, attribute_array)

import org.jruby.RubyInstanceConfig;
import org.jruby.ir.IRScope;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Interp;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -54,6 +56,11 @@ public String[] toStringNonOperandArgs() {
return EMPTY_STRINGS;
}

public void encode(IRWriterEncoder e) {
if (RubyInstanceConfig.IR_WRITING_DEBUG) System.out.println("Instr(" + getOperation() + "): " + this);
e.encode(getOperation());
}

/**
* Instructions are meant to be in a machine-readable format so offline tooling can parse the
* debugging output. The format is:
6 changes: 6 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/JumpInstr.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;

public class JumpInstr extends Instr implements FixedArityInstr {
@@ -20,6 +21,11 @@ public Instr clone(CloneInfo ii) {
return new JumpInstr(ii.getRenamedLabel(getJumpTarget()));
}

@Override
public void encode(IRWriterEncoder e) {
e.encode(getJumpTarget());
}

@Override
public void visit(IRVisitor visitor) {
visitor.JumpInstr(this);
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/LabelInstr.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;

public class LabelInstr extends Instr implements FixedArityInstr {
@@ -20,6 +21,12 @@ public Instr clone(CloneInfo ii) {
return new LabelInstr(ii.getRenamedLabel(getLabel()));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getLabel());
}

@Override
public void visit(IRVisitor visitor) {
visitor.LabelInstr(this);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -50,6 +51,13 @@ public Instr clone(CloneInfo ii) {
return new LexicalSearchConstInstr(ii.getRenamedVariable(result), getDefiningScope().cloneForInlining(ii), constName);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getDefiningScope());
e.encode(getConstName());
}

private Object cache(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
StaticScope staticScope = (StaticScope) getDefiningScope().retrieve(context, self, currScope, currDynScope, temp);

Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;

@@ -36,6 +37,12 @@ public Instr clone(CloneInfo ii) {
return this;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getLineNumber());
}

@Override
public void visit(IRVisitor visitor) {
visitor.LineNumberInstr(this);
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Interp;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -59,6 +60,13 @@ public Instr clone(CloneInfo ii) {
(LocalVariable)ii.getRenamedVariable(getLocalVar()));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getScope());
e.encode(getLocalVar());
}

@Interp
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/Match2Instr.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -43,6 +44,13 @@ public Instr clone(CloneInfo ii) {
getReceiver().cloneForInlining(ii), getArg().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReceiver());
e.encode(getArg());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyRegexp regexp = (RubyRegexp) getReceiver().retrieve(context, self, currScope, currDynScope, temp);
8 changes: 8 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/Match3Instr.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -44,6 +45,13 @@ public Instr clone(CloneInfo ii) {
getReceiver().cloneForInlining(ii), getArg().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReceiver());
e.encode(getArg());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyRegexp regexp = (RubyRegexp) getReceiver().retrieve(context, self, currScope, currDynScope, temp);
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -38,6 +39,12 @@ public Instr clone(CloneInfo ii) {
return new MatchInstr((Variable) result.cloneForInlining(ii), getReceiver().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReceiver());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyRegexp regexp = (RubyRegexp) getReceiver().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.specialized.OneOperandArgNoBlockNoResultCallInstr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.CallType;

@@ -27,6 +28,14 @@ public Instr clone(CloneInfo ii) {
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReceiver());
e.encode(getName());
e.encode(getCallArgs());
}

@Override
public void visit(IRVisitor visitor) {
visitor.NoResultCallInstr(this);
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.StringLiteral;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
@@ -49,6 +50,13 @@ public Instr clone(CloneInfo info) {
}
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReturnValue());
e.encode(methodName);
}

@Override
public void visit(IRVisitor visitor) {
visitor.NonlocalReturnInstr(this);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.operands.Operand;

import java.util.Map;
import org.jruby.ir.persistence.IRWriterEncoder;

public abstract class OneOperandBranchInstr extends BranchInstr {
public OneOperandBranchInstr(Operation op, Operand[] operands) {
@@ -14,4 +15,11 @@ public OneOperandBranchInstr(Operation op, Operand[] operands) {
public Operand getArg1() {
return operands[1];
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArg1());
e.encode(getJumpTarget());
}
}
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -39,6 +40,14 @@ public Instr clone(CloneInfo ii) {
return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), index, minArgsLength);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArray());
e.encode(getIndex());
e.encode(getMinArgsLength());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this?
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
@@ -34,6 +35,13 @@ public Instr clone(CloneInfo ii) {
getBlock().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getModuleBody());
e.encode(getBlock());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
InterpretedIRBodyMethod bodyMethod = (InterpretedIRBodyMethod) getModuleBody().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -6,37 +6,53 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.GlobalVariable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

public class PutGlobalVarInstr extends PutInstr implements FixedArityInstr {
public class PutGlobalVarInstr extends Instr implements FixedArityInstr {
public PutGlobalVarInstr(String varName, Operand value) {
super(Operation.PUT_GLOBAL_VAR, new GlobalVariable(varName), null, value);
super(Operation.PUT_GLOBAL_VAR, new Operand[] {new GlobalVariable(varName), value});
}

@Override
public boolean computeScopeFlags(IRScope scope) {
String gvName = ((GlobalVariable) getTarget()).getName();
String name = getTarget().getName();

if (gvName.equals("$_") || gvName.equals("$~")) {
if (name.equals("$_") || name.equals("$~")) {
scope.getFlags().add(IRFlags.USES_BACKREF_OR_LASTLINE);
return true;
}

return false;
}

public GlobalVariable getTarget() {
return (GlobalVariable) operands[0];
}

public Operand getValue() {
return operands[1];
}

@Override
public Instr clone(CloneInfo ii) {
return new PutGlobalVarInstr(((GlobalVariable) getTarget()).getName(), getValue().cloneForInlining(ii));
return new PutGlobalVarInstr(getTarget().getName(), getValue().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getTarget());
e.encode(getValue());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
GlobalVariable target = (GlobalVariable)getTarget();
GlobalVariable target = getTarget();
IRubyObject value = (IRubyObject) getValue().retrieve(context, self, currScope, currDynScope, temp);
context.runtime.getGlobalVariables().set(target.getName(), value);
return null;
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/PutInstr.java
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;

// Represents target.ref = value or target = value where target is not a stack variable
public abstract class PutInstr extends Instr implements FixedArityInstr {
@@ -25,6 +26,14 @@ public Operand getValue() {
return operands[1];
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getTarget());
e.encode(getRef());
e.encode(getValue());
}

@Override
public String[] toStringNonOperandArgs() {
return new String[] {"name: " + ref};
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Arity;
@@ -50,6 +51,15 @@ public Instr clone(CloneInfo ii) {
return new RaiseArgumentErrorInstr(required, opt, rest, numArgs);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getRequired());
e.encode(getOpt());
e.encode(getRest());
e.encode(getNumArgs());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Arity.raiseArgumentError(context.runtime, numArgs, required, required + opt);
Original file line number Diff line number Diff line change
@@ -2,6 +2,7 @@

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -28,6 +29,12 @@ public Instr clone(CloneInfo ii) {
return new RaiseRequiredKeywordArgumentError(name);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getName());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
throw IRRuntimeHelpers.newRequiredKeywordArgumentError(context, name);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.ThreadContext;
@@ -36,6 +37,13 @@ public Instr clone(CloneInfo ii) {
return new ReceiveKeywordArgInstr(ii.getRenamedVariable(result), argName, required);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(argName);
e.encode(required);
}

@Override
public IRubyObject receiveArg(ThreadContext context, IRubyObject[] args, boolean acceptsKeywordArgument) {
return IRRuntimeHelpers.receiveKeywordArg(context, args, required, argName, acceptsKeywordArgument);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.ThreadContext;
@@ -34,6 +35,12 @@ public Instr clone(CloneInfo ii) {
return new ReceiveKeywordRestArgInstr(ii.getRenamedVariable(result), required);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(required);
}

@Override
public IRubyObject receiveArg(ThreadContext context, IRubyObject[] args, boolean keywordArgumentSupplied) {
return IRRuntimeHelpers.receiveKeywordRestArg(context, args, required, keywordArgumentSupplied);
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
@@ -57,6 +58,14 @@ public Instr clone(CloneInfo info) {
return new OptArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preArgs + optArgIndex, minReqdArgs);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(requiredArgs);
e.encode(getPreArgs());
e.encode(getArgIndex());
}

@Override
public IRubyObject receiveArg(ThreadContext context, IRubyObject[] args, boolean acceptsKeywordArgument) {
return IRRuntimeHelpers.receiveOptArg(args, requiredArgs, preArgs, argIndex, acceptsKeywordArgument);
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
@@ -56,6 +57,14 @@ public Instr clone(CloneInfo info) {
return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preReqdArgsCount, postReqdArgsCount, argIndex);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArgIndex());
e.encode(preReqdArgsCount);
e.encode(postReqdArgsCount);
}

public IRubyObject receivePostReqdArg(IRubyObject[] args, boolean acceptsKeywordArgument) {
return IRRuntimeHelpers.receivePostReqdArg(args, preReqdArgsCount, postReqdArgsCount, argIndex, acceptsKeywordArgument);
}
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
@@ -26,6 +27,12 @@ public Instr clone(CloneInfo info) {
return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), -1, -1, argIndex);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArgIndex());
}

@Override
public void visit(IRVisitor visitor) {
visitor.ReceivePreReqdArgInstr(this);
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
@@ -39,6 +40,13 @@ public Instr clone(CloneInfo info) {
return new RestArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), argIndex, (required - argIndex), argIndex);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(required);
e.encode(getArgIndex());
}

@Override
public IRubyObject receiveArg(ThreadContext context, IRubyObject[] args, boolean acceptsKeywordArguments) {
return IRRuntimeHelpers.receiveRestArg(context, args, required, argIndex, acceptsKeywordArguments);
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.*;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.WrappedIRClosure;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -40,6 +41,13 @@ public Instr clone(CloneInfo ii) {
return new RecordEndBlockInstr(declaringScope, (WrappedIRClosure) getEndBlockClosure().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getDeclaringScope());
e.encode(getEndBlockClosure());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Block blk = (Block) getEndBlockClosure().retrieve(context, self, currScope, context.getCurrentScope(), temp);
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.operands.WrappedIRClosure;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
@@ -49,7 +50,14 @@ public Instr clone(CloneInfo info) {

return new CopyInstr(ii.getRenamedVariable(result), ii.getCallClosure());
}


@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getSource());
e.encode(getResult());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Block block = (Block) getSource().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import org.jruby.ir.operands.Array;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -57,6 +58,15 @@ public Instr clone(CloneInfo ii) {
return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), preArgsCount, postArgsCount, index);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArray());
e.encode(getPreArgsCount());
e.encode(getPostArgsCount());
e.encode(getIndex());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this?
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -37,6 +38,13 @@ public Instr clone(CloneInfo ii) {
getArg1().cloneForInlining(ii), getArg2().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArg1());
e.encode(getArg2());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
IRubyObject excType = (IRubyObject) getArg1().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -44,6 +45,15 @@ public Instr clone(CloneInfo ii) {
return new RestArgMultipleAsgnInstr(ii.getRenamedVariable(result), getArray().cloneForInlining(ii), preArgsCount, postArgsCount, index);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArray());
e.encode(getPreArgsCount());
e.encode(getPostArgsCount());
e.encode(getIndex());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
// ENEBO: Can I assume since IR figured this is an internal array it will be RubyArray like this?
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;

/**
* For most instrs that have a result this is their base class. Some instrs, most notably
@@ -18,6 +19,13 @@ public ResultBaseInstr(Operation operation, Variable result, Operand[] operands)
this.result = result;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getResult());
}

public Variable getResult() {
return result;
}
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/ReturnInstr.java
Original file line number Diff line number Diff line change
@@ -4,6 +4,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.InlineCloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
@@ -25,6 +26,12 @@ public Instr clone(CloneInfo info) {
return v == null ? null : new CopyInstr(v, getReturnValue().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getReturnValue());
}

@Override
public void visit(IRVisitor visitor) {
visitor.ReturnInstr(this);
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Boolean;
import org.jruby.ir.operands.*;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -64,6 +65,13 @@ public Instr clone(CloneInfo ii) {
return new RuntimeHelperCall(var == null ? null : ii.getRenamedVariable(var), helperMethod, cloneOperands(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getHelperMethod().ordinal());
e.encode(getArgs());
}

@Override
public String[] toStringNonOperandArgs() {
return new String[] { "method: " + helperMethod};
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -54,6 +55,14 @@ public Instr clone(CloneInfo ii) {
return new SearchConstInstr(ii.getRenamedVariable(result), constName, getStartingScope().cloneForInlining(ii), noPrivateConsts);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getConstName());
e.encode(getStartingScope());
e.encode(isNoPrivateConsts());
}

@Override
public String[] toStringNonOperandArgs() {
return new String[] {"name: " + constName, "no_priv: " + noPrivateConsts};
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -41,6 +42,13 @@ public Instr clone(CloneInfo ii) {
return new SetCapturedVarInstr(ii.getRenamedVariable(result), getMatch2Result().cloneForInlining(ii), varName);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getMatch2Result());
e.encode(getVarName());
}

@Interp
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.LocalVariable;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -63,6 +64,14 @@ public Instr clone(CloneInfo ii) {
(LocalVariable) getLocalVar().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getScope());
e.encode(getLocalVar());
e.encode(getValue());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Object varValue = getValue().retrieve(context, self, currScope, currDynScope, temp);
Original file line number Diff line number Diff line change
@@ -3,6 +3,7 @@
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.interpreter.Profiler;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.ir.transformations.inlining.SimpleCloneInfo;
@@ -36,6 +37,12 @@ public void visit(IRVisitor visitor) {
visitor.ThreadPollInstr(this);
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(onBackEdge);
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
if (IRRuntimeHelpers.inProfileMode()) Profiler.clockTick();
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.IRException;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Block;
@@ -29,6 +30,12 @@ public Instr clone(CloneInfo ii) {
return new ThrowExceptionInstr(getException().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getException());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
if (getException() instanceof IRException) {
7 changes: 7 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/ToAryInstr.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.operands.Array;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -47,6 +48,12 @@ public Instr clone(CloneInfo ii) {
return new ToAryInstr((Variable) result.cloneForInlining(ii), getArray().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArray());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
return IRRuntimeHelpers.irToAry(context,
10 changes: 10 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/TraceInstr.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.jruby.ir.instructions;

import org.jruby.ir.Operation;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -54,6 +55,15 @@ public String[] toStringNonOperandArgs() {
return new String[] {"ev: " + event, "name: " + name, "file: " + filename, "line: " + linenumber};
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getEvent().ordinal());
e.encode(getName());
e.encode(getFilename());
e.encode(getLinenumber());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
if (context.runtime.hasEventHooks()) {
Original file line number Diff line number Diff line change
@@ -3,12 +3,21 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Label;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;

public abstract class TwoOperandBranchInstr extends BranchInstr {
public TwoOperandBranchInstr(Operation op, Operand arg1, Operand arg2, Label jumpTarget) {
super(op, new Operand[] {jumpTarget, arg1, arg2});
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArg1());
e.encode(getArg2());
e.encode(getJumpTarget());
}

public Operand getArg1() {
return operands[1];
}
Original file line number Diff line number Diff line change
@@ -7,6 +7,7 @@
import org.jruby.ir.Operation;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -35,6 +36,12 @@ public Instr clone(CloneInfo ii) {
return new UndefMethodInstr((Variable)result.cloneForInlining(ii), getMethodName().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getMethodName());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
RubyModule module = IRRuntimeHelpers.findInstanceMethodContainer(context, currDynScope, self);
9 changes: 9 additions & 0 deletions core/src/main/java/org/jruby/ir/instructions/YieldInstr.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.operands.Operand;
import org.jruby.ir.operands.UndefinedValue;
import org.jruby.ir.operands.Variable;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.runtime.IRRuntimeHelpers;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
@@ -50,6 +51,14 @@ public boolean isUnwrapArray() {
return unwrapArray;
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getBlockArg());
e.encode(getYieldArg());
e.encode(isUnwrapArray());
}

@Interp
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@
import org.jruby.ir.instructions.FixedArityInstr;
import org.jruby.ir.instructions.Instr;
import org.jruby.ir.operands.Operand;
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
@@ -25,6 +26,12 @@ public Instr clone(CloneInfo ii) {
return new RestoreErrorInfoInstr(getArg().cloneForInlining(ii));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
e.encode(getArg());
}

@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope currDynScope, IRubyObject self, Object[] temp) {
context.setErrorInfo((IRubyObject) getArg().retrieve(context, self, currScope, currDynScope, temp));
Original file line number Diff line number Diff line change
@@ -72,6 +72,10 @@ public void encode(OperandType value) {
public void encode(Operand operand) {
}

@Override
public void encode(Operand[] operand) {
}

@Override
public void encode(boolean value) {
}
Original file line number Diff line number Diff line change
@@ -26,6 +26,7 @@ public interface IRWriterEncoder {
public void encode(Type value);
public void encode(Operation value);
public void encode(Operand value);
public void encode(Operand[] value);
public void encode(OperandType value);
public void encode(boolean value);
public void encode(byte value);
12 changes: 9 additions & 3 deletions core/src/main/java/org/jruby/ir/persistence/IRWriterFile.java
Original file line number Diff line number Diff line change
@@ -36,7 +36,6 @@ public class IRWriterFile implements IRWriterEncoder, IRPersistenceValues {
private final ByteBuffer buf = ByteBuffer.allocate(TWO_MEGS);
private final File file;
private final OperandEncoderMap operandEncoder;
private final InstrEncoderMap instrEncoder;
private final IRWriterAnalzer analyzer;

int headersOffset = -1;
@@ -45,7 +44,6 @@ public class IRWriterFile implements IRWriterEncoder, IRPersistenceValues {
public IRWriterFile(File file) throws FileNotFoundException {
this.file = file;
this.operandEncoder = new OperandEncoderMap(this);
this.instrEncoder = new InstrEncoderMap(this);
this.analyzer = new IRWriterAnalzer();
}

@@ -154,9 +152,17 @@ public void encode(Operand operand) {
operandEncoder.encode(operand);
}

@Override
public void encode(Operand[] operands) {
encode(operands.length);
for(Operand arg: operands) {
encode(arg);
}
}

@Override
public void encode(Instr instr) {
instrEncoder.encode(instr);
instr.encode(this);
}

@Override
606 changes: 0 additions & 606 deletions core/src/main/java/org/jruby/ir/persistence/InstrEncoderMap.java

This file was deleted.

4 changes: 1 addition & 3 deletions core/src/main/java/org/jruby/ir/targets/JVMVisitor.java
Original file line number Diff line number Diff line change
@@ -1070,9 +1070,7 @@ public void GetFieldInstr(GetFieldInstr getfieldinstr) {

@Override
public void GetGlobalVariableInstr(GetGlobalVariableInstr getglobalvariableinstr) {
Operand source = getglobalvariableinstr.getSource();
GlobalVariable gvar = (GlobalVariable)source;
String name = gvar.getName();
String name = getglobalvariableinstr.getGVar().getName();
jvmMethod().loadRuntime();
jvmMethod().invokeVirtual(Type.getType(Ruby.class), Method.getMethod("org.jruby.internal.runtime.GlobalVariables getGlobalVariables()"));
jvmAdapter().ldc(name);