Skip to content

Commit

Permalink
Showing 35 changed files with 226 additions and 129 deletions.
2 changes: 1 addition & 1 deletion core/src/main/java/org/jruby/Ruby.java
Original file line number Diff line number Diff line change
@@ -1198,7 +1198,7 @@ private void init() {
// FIXME: This registers itself into static scope as a side-effect. Let's make this
// relationship handled either more directly or through a descriptice method
// FIXME: We need a failing test case for this since removing it did not regress tests
IRScope top = new IRScriptBody(irManager, "", context.getCurrentScope().getStaticScope());
IRScope top = new IRScriptBody(irManager, new ByteList("".getBytes()), context.getCurrentScope().getStaticScope());
top.allocateInterpreterContext(new ArrayList<Instr>());

// Initialize the "dummy" class used as a marker
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ast/OpAsgnConstDeclNode.java
Original file line number Diff line number Diff line change
@@ -43,6 +43,10 @@ public String getOperator() {
return StringSupport.byteListAsString(operator);
}

public ByteList getByteOperator() {
return operator;
}

@Override
public <T> T accept(NodeVisitor<T> visitor) {
return visitor.visitOpAsgnConstDeclNode(this);
12 changes: 12 additions & 0 deletions core/src/main/java/org/jruby/ast/OpAsgnNode.java
Original file line number Diff line number Diff line change
@@ -88,6 +88,10 @@ public String getOperatorName() {
return StringSupport.byteListAsString(operatorName);
}

public ByteList getOperatorByteName() {
return operatorName;
}

/**
* Gets the receiverNode.
* @return Returns a Node
@@ -111,10 +115,18 @@ public Node getValueNode() {
public String getVariableName() {
return StringSupport.byteListAsString(variableName);
}

public ByteList getVariableByteName() {
return variableName;
}

public String getVariableNameAsgn() {
return StringSupport.byteListAsString(variableNameAsgn);
}

public ByteList getVariableByteNameAsgn() {
return variableNameAsgn;
}

public List<Node> childNodes() {
return Node.createList(receiverNode, valueNode);
4 changes: 4 additions & 0 deletions core/src/main/java/org/jruby/ast/OpElementAsgnNode.java
Original file line number Diff line number Diff line change
@@ -99,6 +99,10 @@ public String getOperatorName() {
return StringSupport.byteListAsString(operatorName);
}

public ByteList getOperatorByteName() {
return operatorName;
}

/**
* Gets the receiverNode.
* @return Returns a Node
78 changes: 43 additions & 35 deletions core/src/main/java/org/jruby/ir/IRBuilder.java

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/IRClassBody.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.jruby.ir;

import org.jruby.parser.StaticScope;
import org.jruby.util.ByteList;

public class IRClassBody extends IRModuleBody {
public IRClassBody(IRManager manager, IRScope lexicalParent, String name, int lineNumber, StaticScope scope) {
public IRClassBody(IRManager manager, IRScope lexicalParent, ByteList name, int lineNumber, StaticScope scope) {
super(manager, lexicalParent, name, lineNumber, scope);
}

43 changes: 28 additions & 15 deletions core/src/main/java/org/jruby/ir/IRClosure.java
Original file line number Diff line number Diff line change
@@ -20,6 +20,7 @@
import org.jruby.runtime.MixedModeIRBlockBody;
import org.jruby.runtime.InterpretedIRBlockBody;
import org.jruby.runtime.Signature;
import org.jruby.util.ByteList;
import org.objectweb.asm.Handle;

// Closures are contexts/scopes for the purpose of IR building. They are self-contained and accumulate instructions
@@ -49,22 +50,22 @@ public class IRClosure extends IRScope {
private Handle handle;

// Used by other constructions and by IREvalScript as well
protected IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, String prefix) {
protected IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, ByteList prefix) {
super(manager, lexicalParent, null, lineNumber, staticScope);

this.startLabel = getNewLabel(prefix + "START");
this.endLabel = getNewLabel(prefix + "END");
this.closureId = lexicalParent.getNextClosureId();
setName(prefix + closureId);
setByteName(prefix.dup().append(closureId));
this.body = null;
}

/** Used by cloning code */
/* Inlining generates a new name and id and basic cloning will reuse the originals name */
protected IRClosure(IRClosure c, IRScope lexicalParent, int closureId, String fullName) {
protected IRClosure(IRClosure c, IRScope lexicalParent, int closureId, ByteList fullName) {
super(c, lexicalParent);
this.closureId = closureId;
super.setName(fullName);
super.setByteName(fullName);
this.startLabel = getNewLabel(getName() + "_START");
this.endLabel = getNewLabel(getName() + "_END");
if (getManager().isDryRun()) {
@@ -77,27 +78,29 @@ protected IRClosure(IRClosure c, IRScope lexicalParent, int closureId, String fu
this.signature = c.signature;
}

private static final ByteList CLOSURE = new ByteList(new byte[] {'_', 'C', 'L', 'O', 'S', 'U', 'R', 'E', '_'});

// Used by persistence. Knowledge of coverage not needed here since it is already instrumented into the instrs
public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature) {
this(manager, lexicalParent, lineNumber, staticScope, signature, "_CLOSURE_", false);
this(manager, lexicalParent, lineNumber, staticScope, signature, CLOSURE, false);
}

// Used by iter + lambda by IRBuilder
public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, boolean needsCoverage) {
this(manager, lexicalParent, lineNumber, staticScope, signature, "_CLOSURE_", false, needsCoverage);
this(manager, lexicalParent, lineNumber, staticScope, signature, CLOSURE, false, needsCoverage);
}


public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, String prefix) {
public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, ByteList prefix) {
this(manager, lexicalParent, lineNumber, staticScope, signature, prefix, false);
}

public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, String prefix, boolean isBeginEndBlock) {
public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, ByteList prefix, boolean isBeginEndBlock) {
this(manager, lexicalParent, lineNumber, staticScope, signature, prefix, isBeginEndBlock, false);
}

public IRClosure(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope,
Signature signature, String prefix, boolean isBeginEndBlock, boolean needsCoverage) {
Signature signature, ByteList prefix, boolean isBeginEndBlock, boolean needsCoverage) {
this(manager, lexicalParent, lineNumber, staticScope, prefix);
this.signature = signature;
lexicalParent.addClosure(this);
@@ -206,6 +209,7 @@ public boolean isNestedClosuresSafeForMethodConversion() {
return !getFlags().contains(IRFlags.ACCESS_PARENTS_LOCAL_VARIABLES);
}

// FIXME: this is needs to be ByteList
public IRMethod convertToMethod(String name) {
// We want variable scoping to be the same as a method and not see outside itself.
if (source == null ||
@@ -219,7 +223,8 @@ public IRMethod convertToMethod(String name) {
DefNode def = source;
source = null;

return new IRMethod(getManager(), getLexicalParent(), def, name, true, getLineNumber(), getStaticScope(), getFlags().contains(IRFlags.CODE_COVERAGE));
// FIXME: This should be bytelist from param vs being made (see above).
return new IRMethod(getManager(), getLexicalParent(), def, new ByteList(name.getBytes()), true, getLineNumber(), getStaticScope(), getFlags().contains(IRFlags.CODE_COVERAGE));
}

public void setSource(IterNode iter) {
@@ -336,15 +341,20 @@ protected IRClosure cloneForInlining(CloneInfo ii, IRClosure clone) {
return clone;
}

private static final ByteList CLOSURE_CLONE =
new ByteList(new byte[] {'_', 'C', 'L', 'O', 'S', 'U', 'R', 'E', '_', 'C', 'L', 'O', 'N', 'E', '_'});

public IRClosure cloneForInlining(CloneInfo ii) {
IRClosure clonedClosure;
IRScope lexicalParent = ii.getScope();

if (ii instanceof SimpleCloneInfo && !((SimpleCloneInfo)ii).isEnsureBlockCloneMode()) {
clonedClosure = new IRClosure(this, lexicalParent, closureId, getName());
clonedClosure = new IRClosure(this, lexicalParent, closureId, getByteName());
} else {
int id = lexicalParent.getNextClosureId();
String fullName = lexicalParent.getName() + "_CLOSURE_CLONE_" + id;
ByteList fullName = lexicalParent.getByteName().dup();
fullName.append(CLOSURE_CLONE);
fullName.append(new Integer(id).toString().getBytes());
clonedClosure = new IRClosure(this, lexicalParent, id, fullName);
}

@@ -356,9 +366,12 @@ public IRClosure cloneForInlining(CloneInfo ii) {
}

@Override
public void setName(String name) {
// We can distinguish closures only with parent scope name
super.setName(getLexicalParent().getName() + name);
public void setByteName(ByteList name) {
ByteList newName = getLexicalParent().getByteName().dup();

newName.append(name);

super.setByteName(newName);
}

public Signature getSignature() {
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/ir/IREvalScript.java
Original file line number Diff line number Diff line change
@@ -12,15 +12,18 @@
import org.jruby.ir.operands.LocalVariable;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.Helpers;
import org.jruby.util.ByteList;

public class IREvalScript extends IRClosure {
private List<IRClosure> beginBlocks;
private EvalType evalType;
private String fileName;

private static final ByteList EVAL_ = new ByteList(new byte[] {'E', 'V', 'A', 'L', '_'});

public IREvalScript(IRManager manager, IRScope lexicalParent, String fileName,
int lineNumber, StaticScope staticScope, EvalType evalType) {
super(manager, lexicalParent, lineNumber, staticScope, "EVAL_");
super(manager, lexicalParent, lineNumber, staticScope, EVAL_);

this.evalType = evalType;
this.fileName = fileName;
20 changes: 14 additions & 6 deletions core/src/main/java/org/jruby/ir/IRFor.java
Original file line number Diff line number Diff line change
@@ -5,21 +5,25 @@
import org.jruby.parser.StaticScope;
import org.jruby.parser.StaticScopeFactory;
import org.jruby.runtime.Signature;
import org.jruby.util.ByteList;

/**
* Represents a 'for' loop
*/
public class IRFor extends IRClosure {
public IRFor(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, String labelPrefix) {
super(manager, lexicalParent, lineNumber, StaticScopeFactory.newIRBlockScope(staticScope), signature, labelPrefix, labelPrefix == "_BEGIN_");
private static final ByteList FOR_LOOP = new ByteList(new byte[] {'_', 'F', 'O', 'R', '_', 'L', 'O', 'O', 'P', '_'});
public static final ByteList _BEGIN_ = new ByteList(new byte[] {'_', 'B', 'E', 'G', 'I', 'N', '_'});

public IRFor(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature, ByteList labelPrefix) {
super(manager, lexicalParent, lineNumber, StaticScopeFactory.newIRBlockScope(staticScope), signature, labelPrefix, labelPrefix.equals(_BEGIN_));
}

public IRFor(IRManager manager, IRScope lexicalParent, int lineNumber, StaticScope staticScope, Signature signature) {
this(manager, lexicalParent, lineNumber, StaticScopeFactory.newIRBlockScope(staticScope), signature, "_FOR_LOOP_");
this(manager, lexicalParent, lineNumber, StaticScopeFactory.newIRBlockScope(staticScope), signature, FOR_LOOP);
}

/** Used by cloning code */
private IRFor(IRClosure c, IRScope lexicalParent, int id, String fullName) {
private IRFor(IRClosure c, IRScope lexicalParent, int id, ByteList fullName) {
super(c, lexicalParent, id, fullName);
}

@@ -28,16 +32,20 @@ public IRScopeType getScopeType() {
return IRScopeType.FOR;
}

private static final ByteList FOR_LOOP_CLONE = new ByteList(new byte[] {'_', 'F', 'O', 'R', '_', 'L', 'O', 'O', 'P', '_', 'C', 'L', 'O', 'N', 'E', '_'});

@Override
public IRClosure cloneForInlining(CloneInfo ii) {
IRClosure clonedClosure;
IRScope lexicalParent = ii.getScope();

if (ii instanceof SimpleCloneInfo) {
clonedClosure = new IRFor(this, lexicalParent, closureId, getName());
clonedClosure = new IRFor(this, lexicalParent, closureId, getByteName());
} else {
int id = lexicalParent.getNextClosureId();
String fullName = lexicalParent.getName() + "_FOR_LOOP_CLONE_" + id;
ByteList fullName = lexicalParent.getByteName().dup();
fullName.append(FOR_LOOP_CLONE);
fullName.append(Integer.toString(id).getBytes());
clonedClosure = new IRFor(this, lexicalParent, id, fullName);
}

5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/ir/IRManager.java
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
import org.jruby.ir.passes.OptimizeDelegationPass;
import org.jruby.ir.passes.OptimizeDynScopesPass;
import org.jruby.ir.util.IGVInstrListener;
import org.jruby.util.ByteList;

import static org.jruby.ir.IRFlags.RECEIVES_CLOSURE_ARG;
import static org.jruby.ir.IRFlags.REQUIRES_DYNSCOPE;
@@ -36,8 +37,10 @@ public class IRManager {
private final CompilerPass optimizeDynScopesPass = new OptimizeDynScopesPass();
private final CompilerPass optimizeDelegationPass = new OptimizeDelegationPass();

private final static ByteList OBJECT = new ByteList(new byte[] {'O', 'b', 'j', 'e', 'c', 't'});

private int dummyMetaClassCount = 0;
private final IRModuleBody object = new IRClassBody(this, null, "Object", 0, null);
private final IRModuleBody object = new IRClassBody(this, null, OBJECT, 0, null);
private final Nil nil = new Nil();
private final Boolean tru = new Boolean(true);
private final Boolean fals = new Boolean(false);
3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/IRMetaClassBody.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.jruby.ir;

import org.jruby.parser.StaticScope;
import org.jruby.util.ByteList;

public class IRMetaClassBody extends IRClassBody {
public IRMetaClassBody(IRManager manager, IRScope lexicalParent, String name, int lineNumber, StaticScope scope) {
public IRMetaClassBody(IRManager manager, IRScope lexicalParent, ByteList name, int lineNumber, StaticScope scope) {
super(manager, lexicalParent, name, lineNumber, scope);
}

3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/IRMethod.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,7 @@
import org.jruby.ir.representations.BasicBlock;
import org.jruby.parser.StaticScope;
import org.jruby.runtime.ArgumentDescriptor;
import org.jruby.util.ByteList;

public class IRMethod extends IRScope {
public final boolean isInstanceMethod;
@@ -15,7 +16,7 @@ public class IRMethod extends IRScope {

private DefNode defn;

public IRMethod(IRManager manager, IRScope lexicalParent, DefNode defn, String name,
public IRMethod(IRManager manager, IRScope lexicalParent, DefNode defn, ByteList name,
boolean isInstanceMethod, int lineNumber, StaticScope staticScope, boolean needsCodeCoverage) {
super(manager, lexicalParent, name, lineNumber, staticScope);

3 changes: 2 additions & 1 deletion core/src/main/java/org/jruby/ir/IRModuleBody.java
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
package org.jruby.ir;

import org.jruby.parser.StaticScope;
import org.jruby.util.ByteList;

public class IRModuleBody extends IRScope {
public IRModuleBody(IRManager manager, IRScope lexicalParent, String name, int lineNumber, StaticScope staticScope) {
public IRModuleBody(IRManager manager, IRScope lexicalParent, ByteList name, int lineNumber, StaticScope staticScope) {
super(manager, lexicalParent, name, lineNumber, staticScope);

if (!getManager().isDryRun()) {
12 changes: 9 additions & 3 deletions core/src/main/java/org/jruby/ir/IRScope.java
Original file line number Diff line number Diff line change
@@ -24,6 +24,8 @@
import java.util.concurrent.atomic.AtomicInteger;

import org.jruby.runtime.Helpers;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;
import org.jruby.util.log.Logger;
import org.jruby.util.log.LoggerFactory;

@@ -69,7 +71,7 @@ public abstract class IRScope implements ParseResult {
private int scopeId;

/** Name */
private String name;
private ByteList name;

/** Starting line for this scope's definition */
private final int lineNumber;
@@ -149,7 +151,7 @@ protected IRScope(IRScope s, IRScope lexicalParent) {
setupLexicalContainment();
}

public IRScope(IRManager manager, IRScope lexicalParent, String name,
public IRScope(IRManager manager, IRScope lexicalParent, ByteList name,
int lineNumber, StaticScope staticScope) {
this.manager = manager;
this.lexicalParent = lexicalParent;
@@ -336,10 +338,14 @@ public int getNearestModuleReferencingScopeDepth() {
}

public String getName() {
return StringSupport.byteListAsString(name);
}

public ByteList getByteName() {
return name;
}

public void setName(String name) { // This is for IRClosure and IRMethod ;(
public void setByteName(ByteList name) {
this.name = name;
}

11 changes: 7 additions & 4 deletions core/src/main/java/org/jruby/ir/IRScriptBody.java
Original file line number Diff line number Diff line change
@@ -6,6 +6,8 @@
import org.jruby.parser.StaticScope;
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.Helpers;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;

import java.util.ArrayList;
import java.util.List;
@@ -14,9 +16,9 @@
public class IRScriptBody extends IRScope {
private List<IRClosure> beginBlocks;
private DynamicScope toplevelScope;
private String fileName;
private ByteList fileName;

public IRScriptBody(IRManager manager, String sourceName, StaticScope staticScope) {
public IRScriptBody(IRManager manager, ByteList sourceName, StaticScope staticScope) {
super(manager, null, sourceName, 0, staticScope);
this.toplevelScope = null;
this.fileName = sourceName;
@@ -85,13 +87,14 @@ public boolean isScriptScope() {
return true;
}

// FIXME: This should be ByteList
@Override
public void setFileName(String fileName) {
this.fileName = fileName;
this.fileName = new ByteList(fileName.getBytes());
}

@Override
public String getFileName() {
return fileName;
return StringSupport.byteListAsString(fileName);
}
}
Original file line number Diff line number Diff line change
@@ -2,7 +2,6 @@

import org.jruby.RubyInstanceConfig;
import org.jruby.RubyString;
import org.jruby.ir.IRScope;
import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.specialized.OneOperandArgNoBlockCallInstr;
@@ -18,6 +17,7 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

/**
* Instruction representing Ruby code of the form: "a['str']"
@@ -27,13 +27,15 @@
*/
public class ArrayDerefInstr extends OneOperandArgNoBlockCallInstr {
private final FrozenString key;
public static final ByteList AREF = new ByteList(new byte[] {'[', ']'});
public static final ByteList ASET = new ByteList(new byte[] {'[', ']', '='});

public static ArrayDerefInstr create(Variable result, Operand obj, FrozenString arg0) {
return new ArrayDerefInstr(result, obj, arg0);
}

public ArrayDerefInstr(Variable result, Operand obj, FrozenString arg0) {
super(Operation.ARRAY_DEREF, CallType.FUNCTIONAL, result, "[]", obj, new Operand[] {arg0}, false);
super(Operation.ARRAY_DEREF, CallType.FUNCTIONAL, result, AREF, obj, new Operand[] {arg0}, false);

key = arg0;
}
@@ -59,7 +61,7 @@ public static ArrayDerefInstr decode(IRReaderDecoder d) {
@Override
public Object interpret(ThreadContext context, StaticScope currScope, DynamicScope dynamicScope, IRubyObject self, Object[] temp) {
IRubyObject object = (IRubyObject) getReceiver().retrieve(context, self, currScope, dynamicScope, temp);
RubyString keyStr = (RubyString) key.retrieve(context, self, currScope, dynamicScope, temp);
RubyString keyStr = key.retrieve(context, self, currScope, dynamicScope, temp);

return IRRuntimeHelpers.callOptimizedAref(context, self, object, keyStr, getCallSite());
}
Original file line number Diff line number Diff line change
@@ -13,21 +13,22 @@
import org.jruby.parser.StaticScope;
import org.jruby.runtime.*;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

import static org.jruby.ir.IRFlags.*;

// Instruction representing Ruby code of the form: "a[i] = 5"
// which is equivalent to: a.[]=(i,5)
public class AttrAssignInstr extends NoResultCallInstr {
public static AttrAssignInstr create(Operand obj, String attr, Operand[] args, boolean isPotentiallyRefined) {
public static AttrAssignInstr create(Operand obj, ByteList attr, Operand[] args, boolean isPotentiallyRefined) {
if (!containsArgSplat(args) && args.length == 1) {
return new OneArgOperandAttrAssignInstr(obj, attr, args, isPotentiallyRefined);
}

return new AttrAssignInstr(obj, attr, args, isPotentiallyRefined);
}

public AttrAssignInstr(Operand obj, String attr, Operand[] args, boolean isPotentiallyRefined) {
public AttrAssignInstr(Operand obj, ByteList attr, Operand[] args, boolean isPotentiallyRefined) {
super(Operation.ATTR_ASSIGN, obj instanceof Self ? CallType.FUNCTIONAL : CallType.NORMAL, attr, obj, args, null, isPotentiallyRefined);
}

@@ -49,7 +50,7 @@ public boolean computeScopeFlags(IRScope scope) {

@Override
public Instr clone(CloneInfo ii) {
return new AttrAssignInstr(getReceiver().cloneForInlining(ii), getName(), cloneCallArgs(ii), isPotentiallyRefined());
return new AttrAssignInstr(getReceiver().cloneForInlining(ii), getByteName(), cloneCallArgs(ii), isPotentiallyRefined());
}

@Override
@@ -62,7 +63,7 @@ public void encode(IRWriterEncoder e) {
}

public static AttrAssignInstr decode(IRReaderDecoder d) {
return create(d.decodeOperand(), d.decodeString(), d.decodeOperandArray(), d.getCurrentScope().maybeUsingRefinements());
return create(d.decodeOperand(), d.decodeByteList(), d.decodeOperandArray(), d.getCurrentScope().maybeUsingRefinements());
}

@Override
14 changes: 10 additions & 4 deletions core/src/main/java/org/jruby/ir/instructions/CallBase.java
Original file line number Diff line number Diff line change
@@ -12,6 +12,8 @@
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.runtime.callsite.RefinedCachingCallSite;
import org.jruby.util.ArraySupport;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;

import java.util.Map;

@@ -22,7 +24,7 @@ public abstract class CallBase extends NOperandInstr implements ClosureAccepting

public transient final long callSiteId;
private final CallType callType;
protected String name;
protected ByteList name;
protected final transient CallSite callSite;
protected final transient int argsCount;
protected final transient boolean hasClosure;
@@ -36,7 +38,7 @@ public abstract class CallBase extends NOperandInstr implements ClosureAccepting
private transient boolean procNew;
private boolean potentiallyRefined;

protected CallBase(Operation op, CallType callType, String name, Operand receiver, Operand[] args, Operand closure,
protected CallBase(Operation op, CallType callType, ByteList name, Operand receiver, Operand[] args, Operand closure,
boolean potentiallyRefined) {
super(op, arrayifyOperands(receiver, args, closure));

@@ -45,7 +47,7 @@ protected CallBase(Operation op, CallType callType, String name, Operand receive
hasClosure = closure != null;
this.name = name;
this.callType = callType;
this.callSite = getCallSiteFor(callType, name, potentiallyRefined);
this.callSite = getCallSiteFor(callType, StringSupport.byteListAsString(name), potentiallyRefined);
splatMap = IRRuntimeHelpers.buildSplatMap(args);
flagsComputed = false;
canBeEval = true;
@@ -61,7 +63,7 @@ public void encode(IRWriterEncoder e) {
super.encode(e);

e.encode(getCallType().ordinal());
e.encode(getName());
e.encode(getByteName());
e.encode(getReceiver());
e.encode(calculateArity());

@@ -80,6 +82,10 @@ private int calculateArity() {
}

public String getName() {
return StringSupport.byteListAsString(name);
}

public ByteList getByteName() {
return name;
}

18 changes: 9 additions & 9 deletions core/src/main/java/org/jruby/ir/instructions/CallInstr.java
Original file line number Diff line number Diff line change
@@ -17,9 +17,9 @@
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.CallType;
import org.jruby.util.ByteList;
import org.jruby.util.KeyValuePair;

import java.util.ArrayList;
import java.util.List;

/*
@@ -28,7 +28,7 @@
public class CallInstr extends CallBase implements ResultInstr {
protected transient Variable result;

public static CallInstr createWithKwargs(IRScope scope, CallType callType, Variable result, String name,
public static CallInstr createWithKwargs(IRScope scope, CallType callType, Variable result, ByteList name,
Operand receiver, Operand[] args, Operand closure,
List<KeyValuePair<Operand, Operand>> kwargs) {
// FIXME: This is obviously total nonsense but this will be on an optimized path and we will not be constructing
@@ -40,11 +40,11 @@ public static CallInstr createWithKwargs(IRScope scope, CallType callType, Varia
return create(scope, callType, result, name, receiver, newArgs, closure);
}

public static CallInstr create(IRScope scope, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
public static CallInstr create(IRScope scope, Variable result, ByteList name, Operand receiver, Operand[] args, Operand closure) {
return create(scope, CallType.NORMAL, result, name, receiver, args, closure);
}

public static CallInstr create(IRScope scope, CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
public static CallInstr create(IRScope scope, CallType callType, Variable result, ByteList name, Operand receiver, Operand[] args, Operand closure) {
boolean isPotentiallyRefined = scope.maybeUsingRefinements();

if (!containsArgSplat(args)) {
@@ -67,12 +67,12 @@ public static CallInstr create(IRScope scope, CallType callType, Variable result
}


public CallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure,
public CallInstr(CallType callType, Variable result, ByteList name, Operand receiver, Operand[] args, Operand closure,
boolean potentiallyRefined) {
this(Operation.CALL, callType, result, name, receiver, args, closure, potentiallyRefined);
}

protected CallInstr(Operation op, CallType callType, Variable result, String name, Operand receiver, Operand[] args,
protected CallInstr(Operation op, CallType callType, Variable result, ByteList name, Operand receiver, Operand[] args,
Operand closure, boolean potentiallyRefined) {
super(op, callType, name, receiver, args, closure, potentiallyRefined);

@@ -93,7 +93,7 @@ public static CallInstr decode(IRReaderDecoder d) {
int callTypeOrdinal = d.decodeInt();
CallType callType = CallType.fromOrdinal(callTypeOrdinal);
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decodeCall - calltype: " + callType);
String methAddr = d.decodeString();
ByteList methAddr = d.decodeByteList();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decodeCall - methaddr: " + methAddr);
Operand receiver = d.decodeOperand();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decodeCall - receiver: " + receiver);
@@ -126,12 +126,12 @@ public void updateResult(Variable v) {
}

public Instr discardResult() {
return NoResultCallInstr.create(getCallType(), getName(), getReceiver(), getCallArgs(), getClosureArg(), isPotentiallyRefined());
return NoResultCallInstr.create(getCallType(), getByteName(), getReceiver(), getCallArgs(), getClosureArg(), isPotentiallyRefined());
}

@Override
public Instr clone(CloneInfo ii) {
return new CallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
return new CallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii),
getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined());
}
Original file line number Diff line number Diff line change
@@ -12,9 +12,10 @@
import org.jruby.parser.StaticScope;
import org.jruby.runtime.*;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class ClassSuperInstr extends CallInstr {
public ClassSuperInstr(Variable result, Operand definingModule, String name, Operand[] args, Operand closure,
public ClassSuperInstr(Variable result, Operand definingModule, ByteList name, Operand[] args, Operand closure,
boolean isPotentiallyRefined) {
super(Operation.CLASS_SUPER, CallType.SUPER, result, name, definingModule, args, closure, isPotentiallyRefined);
}
@@ -33,7 +34,7 @@ public static ClassSuperInstr decode(IRReaderDecoder d) {
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super");
int callTypeOrdinal = d.decodeInt();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, calltype(ord): "+ callTypeOrdinal);
String methAddr = d.decodeString();
ByteList methAddr = d.decodeByteList();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, methaddr: "+ methAddr);
Operand receiver = d.decodeOperand();
int argsCount = d.decodeInt();
Original file line number Diff line number Diff line change
@@ -22,9 +22,11 @@
public class ConstMissingInstr extends CallInstr implements FixedArityInstr {
private final ByteList missingConst;

private static final ByteList CONST_MISSING = new ByteList(new byte[] {'c', 'o', 'n', 's', 't', '_', 'm', 'i', 's', 's', 'i', 'n', 'g'});

public ConstMissingInstr(Variable result, Operand currentModule, ByteList missingConst, boolean isPotentiallyRefined) {
// FIXME: Missing encoding knowledge of the constant name.
super(Operation.CONST_MISSING, CallType.FUNCTIONAL, result, "const_missing", currentModule,
super(Operation.CONST_MISSING, CallType.FUNCTIONAL, result, CONST_MISSING, currentModule,
new Operand[]{new Symbol(missingConst)}, null, isPotentiallyRefined);

this.missingConst = missingConst;
Original file line number Diff line number Diff line change
@@ -15,9 +15,10 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class InstanceSuperInstr extends CallInstr {
public InstanceSuperInstr(Variable result, Operand definingModule, String name, Operand[] args, Operand closure,
public InstanceSuperInstr(Variable result, Operand definingModule, ByteList name, Operand[] args, Operand closure,
boolean isPotentiallyRefined) {
super(Operation.INSTANCE_SUPER, CallType.SUPER, result, name, definingModule, args, closure, isPotentiallyRefined);
}
@@ -28,15 +29,15 @@ public Operand getDefiningModule() {

@Override
public Instr clone(CloneInfo ii) {
return new InstanceSuperInstr(ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), getName(),
return new InstanceSuperInstr(ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), getByteName(),
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined());
}

public static InstanceSuperInstr decode(IRReaderDecoder d) {
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super");
int callTypeOrdinal = d.decodeInt();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, calltype(ord): "+ callTypeOrdinal);
String methAddr = d.decodeString();
ByteList methAddr = d.decodeByteList();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding super, methaddr: "+ methAddr);
Operand receiver = d.decodeOperand();
int argsCount = d.decodeInt();
5 changes: 4 additions & 1 deletion core/src/main/java/org/jruby/ir/instructions/MatchInstr.java
Original file line number Diff line number Diff line change
@@ -9,12 +9,15 @@
import org.jruby.ir.persistence.IRWriterEncoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.CallType;
import org.jruby.util.ByteList;

import static org.jruby.ir.IRFlags.USES_BACKREF_OR_LASTLINE;

public class MatchInstr extends CallInstr implements FixedArityInstr {
private static final ByteList MATCH = new ByteList(new byte[] {'=', '~'});

public MatchInstr(Variable result, Operand receiver, Operand arg) {
super(Operation.MATCH, CallType.NORMAL, result, "=~", receiver, new Operand[]{arg}, null, false);
super(Operation.MATCH, CallType.NORMAL, result, MATCH, receiver, new Operand[]{arg}, null, false);

assert result != null : "Match2Instr result is null";
}
Original file line number Diff line number Diff line change
@@ -8,10 +8,11 @@
import org.jruby.ir.persistence.IRReaderDecoder;
import org.jruby.ir.transformations.inlining.CloneInfo;
import org.jruby.runtime.CallType;
import org.jruby.util.ByteList;

public class NoResultCallInstr extends CallBase {
// FIXME: Removed results undoes specialized callinstrs. Audit how often and what and make equalivalent versions here.
public static NoResultCallInstr create(CallType callType, String name, Operand receiver, Operand[] args,
public static NoResultCallInstr create(CallType callType, ByteList name, Operand receiver, Operand[] args,
Operand closure, boolean isPotentiallyRefined) {
if (closure == null && !containsArgSplat(args) && args.length == 1) {
return new OneOperandArgNoBlockNoResultCallInstr(callType, name, receiver, args, null, isPotentiallyRefined);
@@ -20,21 +21,21 @@ public static NoResultCallInstr create(CallType callType, String name, Operand r
return new NoResultCallInstr(Operation.NORESULT_CALL, callType, name, receiver, args, closure, isPotentiallyRefined);
}

public NoResultCallInstr(Operation op, CallType callType, String name, Operand receiver, Operand[] args,
public NoResultCallInstr(Operation op, CallType callType, ByteList name, Operand receiver, Operand[] args,
Operand closure, boolean isPotentiallyRefined) {
super(op, callType, name, receiver, args, closure, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new NoResultCallInstr(getOperation(), getCallType(), getName(), getReceiver().cloneForInlining(ii),
return new NoResultCallInstr(getOperation(), getCallType(), getByteName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined());
}

public static NoResultCallInstr decode(IRReaderDecoder d) {
int callTypeOrdinal = d.decodeInt();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding call, ordinal: "+ callTypeOrdinal);
String methAddr = d.decodeString();
ByteList methAddr = d.decodeByteList();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("decoding call, methaddr: "+ methAddr);
Operand receiver = d.decodeOperand();
int argsCount = d.decodeInt();
10 changes: 6 additions & 4 deletions core/src/main/java/org/jruby/ir/instructions/TraceInstr.java
Original file line number Diff line number Diff line change
@@ -9,6 +9,8 @@
import org.jruby.runtime.RubyEvent;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;
import org.jruby.util.StringSupport;

// FIXME: When presistence is revisited this should strip these out of code streams on save and add them in if
// tracing is on for load.
@@ -17,11 +19,11 @@
*/
public class TraceInstr extends NoOperandInstr {
private final RubyEvent event;
private final String name;
private final ByteList name;
private final String filename;
private final int linenumber;

public TraceInstr(RubyEvent event, String name, String filename, int linenumber) {
public TraceInstr(RubyEvent event, ByteList name, String filename, int linenumber) {
super(Operation.TRACE);

this.event = event;
@@ -40,7 +42,7 @@ public RubyEvent getEvent() {
}

public String getName() {
return name;
return StringSupport.byteListAsString(name);
}

public String getFilename() {
@@ -66,7 +68,7 @@ public void encode(IRWriterEncoder e) {
}

public static TraceInstr decode(IRReaderDecoder d) {
return new TraceInstr(d.decodeRubyEvent(), d.decodeString(), d.decodeString(), d.decodeInt());
return new TraceInstr(d.decodeRubyEvent(), d.decodeByteList(), d.decodeString(), d.decodeInt());
}

@Override
Original file line number Diff line number Diff line change
@@ -16,9 +16,11 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class UnresolvedSuperInstr extends CallInstr {
public static final String UNKNOWN_SUPER_TARGET = "-unknown-super-target-";
public static final ByteList UNKNOWN_SUPER_TARGET =
new ByteList(new byte[] {'-', 'u', 'n', 'k', 'n', 'o', 'w', 'n', '-', 's', 'u', 'p', 'e', 'r', '-', 't', 'a', 'r', 'g', 'e', 't', '-'});

// SSS FIXME: receiver is never used -- being passed in only to meet requirements of CallInstr
public UnresolvedSuperInstr(Operation op, Variable result, Operand receiver, Operand[] args, Operand closure,
Original file line number Diff line number Diff line change
@@ -7,15 +7,16 @@
import org.jruby.parser.StaticScope;
import org.jruby.runtime.*;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class OneArgOperandAttrAssignInstr extends AttrAssignInstr {
public OneArgOperandAttrAssignInstr(Operand obj, String attr, Operand[] args, boolean isPotentiallyRefined) {
public OneArgOperandAttrAssignInstr(Operand obj, ByteList attr, Operand[] args, boolean isPotentiallyRefined) {
super(obj, attr, args, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneArgOperandAttrAssignInstr(getReceiver().cloneForInlining(ii), getName(), cloneCallArgs(ii), isPotentiallyRefined());
return new OneArgOperandAttrAssignInstr(getReceiver().cloneForInlining(ii), getByteName(), cloneCallArgs(ii), isPotentiallyRefined());
}

@Override
Original file line number Diff line number Diff line change
@@ -12,11 +12,12 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class OneFixnumArgNoBlockCallInstr extends CallInstr {
private final long fixNum;

public OneFixnumArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args, boolean potentiallyRefined) {
public OneFixnumArgNoBlockCallInstr(CallType callType, Variable result, ByteList name, Operand receiver, Operand[] args, boolean potentiallyRefined) {
super(Operation.CALL_1F, callType, result, name, receiver, args, null, potentiallyRefined);

assert args.length == 1;
@@ -26,7 +27,7 @@ public OneFixnumArgNoBlockCallInstr(CallType callType, Variable result, String n

@Override
public Instr clone(CloneInfo ii) {
return new OneFixnumArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
return new OneFixnumArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii), isPotentiallyRefined());
}

Original file line number Diff line number Diff line change
@@ -12,11 +12,12 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class OneFloatArgNoBlockCallInstr extends CallInstr {
private final double flote;

public OneFloatArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args,
public OneFloatArgNoBlockCallInstr(CallType callType, Variable result, ByteList name, Operand receiver, Operand[] args,
boolean potentiallyRefined) {
super(Operation.CALL_1D, callType, result, name, receiver, args, null, potentiallyRefined);

@@ -27,7 +28,7 @@ public OneFloatArgNoBlockCallInstr(CallType callType, Variable result, String na

@Override
public Instr clone(CloneInfo ii) {
return new OneFloatArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
return new OneFloatArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined());
}

Original file line number Diff line number Diff line change
@@ -12,16 +12,17 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class OneOperandArgBlockCallInstr extends CallInstr {
public OneOperandArgBlockCallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args,
public OneOperandArgBlockCallInstr(CallType callType, Variable result, ByteList name, Operand receiver, Operand[] args,
Operand closure, boolean isPotentiallyRefined) {
super(Operation.CALL_1OB, callType, result, name, receiver, args, closure, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneOperandArgBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii),
return new OneOperandArgBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined());
}

Original file line number Diff line number Diff line change
@@ -11,21 +11,22 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class OneOperandArgNoBlockCallInstr extends CallInstr {
public OneOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver,
public OneOperandArgNoBlockCallInstr(CallType callType, Variable result, ByteList name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
this(Operation.CALL_1O, callType, result, name, receiver, args, isPotentiallyRefined);
}

public OneOperandArgNoBlockCallInstr(Operation op, CallType callType, Variable result, String name, Operand receiver,
public OneOperandArgNoBlockCallInstr(Operation op, CallType callType, Variable result, ByteList name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
super(op, callType, result, name, receiver, args, null, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
return new OneOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined());
}

Original file line number Diff line number Diff line change
@@ -10,16 +10,17 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class OneOperandArgNoBlockNoResultCallInstr extends NoResultCallInstr {
public OneOperandArgNoBlockNoResultCallInstr(CallType callType, String name, Operand receiver, Operand[] args,
public OneOperandArgNoBlockNoResultCallInstr(CallType callType, ByteList name, Operand receiver, Operand[] args,
Operand closure, boolean isPotentiallyRefined) {
super(Operation.NORESULT_CALL_1O, callType, name, receiver, args, closure, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new OneOperandArgNoBlockNoResultCallInstr(getCallType(), getName(), getReceiver().cloneForInlining(ii),
return new OneOperandArgNoBlockNoResultCallInstr(getCallType(), getByteName(), getReceiver().cloneForInlining(ii),
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined());
}

Original file line number Diff line number Diff line change
@@ -11,24 +11,25 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

/**
* Created by enebo on 6/8/16.
*/
public class TwoOperandArgNoBlockCallInstr extends CallInstr {
public TwoOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver,
public TwoOperandArgNoBlockCallInstr(CallType callType, Variable result, ByteList name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
this(Operation.CALL_2O, callType, result, name, receiver, args, isPotentiallyRefined);
}

public TwoOperandArgNoBlockCallInstr(Operation op, CallType callType, Variable result, String name, Operand receiver,
public TwoOperandArgNoBlockCallInstr(Operation op, CallType callType, Variable result, ByteList name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
super(op, callType, result, name, receiver, args, null, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new TwoOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
return new TwoOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined());
}

Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package org.jruby.ir.instructions.specialized;

import org.jruby.ir.IRVisitor;
import org.jruby.ir.Operation;
import org.jruby.ir.instructions.CallInstr;
import org.jruby.ir.instructions.Instr;
@@ -12,16 +11,17 @@
import org.jruby.runtime.DynamicScope;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;
import org.jruby.util.ByteList;

public class ZeroOperandArgNoBlockCallInstr extends CallInstr {
public ZeroOperandArgNoBlockCallInstr(CallType callType, Variable result, String name, Operand receiver,
public ZeroOperandArgNoBlockCallInstr(CallType callType, Variable result, ByteList name, Operand receiver,
Operand[] args, boolean isPotentiallyRefined) {
super(Operation.CALL_0O, callType, result, name, receiver, args, null, isPotentiallyRefined);
}

@Override
public Instr clone(CloneInfo ii) {
return new ZeroOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getName(),
return new ZeroOperandArgNoBlockCallInstr(getCallType(), ii.getRenamedVariable(result), getByteName(),
getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined());
}

9 changes: 5 additions & 4 deletions core/src/main/java/org/jruby/ir/persistence/IRReader.java
Original file line number Diff line number Diff line change
@@ -22,6 +22,7 @@
import java.util.Map;
import java.util.concurrent.Callable;

import org.jruby.util.ByteList;
import org.jruby.util.KeyValuePair;

/**
@@ -76,7 +77,7 @@ private static KeyValuePair<IRScope, Integer> decodeScopeHeader(IRManager manage
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("DECODING SCOPE HEADER");
IRScopeType type = decoder.decodeIRScopeType();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("IRScopeType = " + type);
String name = decoder.decodeString();
ByteList name = decoder.decodeByteList();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("NAME = " + name);
int line = decoder.decodeInt();
if (RubyInstanceConfig.IR_READING_DEBUG) System.out.println("LINE = " + line);
@@ -145,14 +146,14 @@ private static StaticScope decodeStaticScope(IRReaderDecoder decoder, StaticScop
return scope;
}

public static IRScope createScope(IRManager manager, IRScopeType type, String name, int line,
IRScope lexicalParent, Signature signature, StaticScope staticScope) {
public static IRScope createScope(IRManager manager, IRScopeType type, ByteList name, int line,
IRScope lexicalParent, Signature signature, StaticScope staticScope) {

switch (type) {
case CLASS_BODY:
return new IRClassBody(manager, lexicalParent, name, line, staticScope);
case METACLASS_BODY:
return new IRMetaClassBody(manager, lexicalParent, manager.getMetaClassName(), line, staticScope);
return new IRMetaClassBody(manager, lexicalParent, new ByteList(manager.getMetaClassName().getBytes()), line, staticScope);
case INSTANCE_METHOD:
return new IRMethod(manager, lexicalParent, null, name, true, line, staticScope, false);
case CLASS_METHOD:

0 comments on commit c215a7a

Please sign in to comment.