Skip to content

Commit

Permalink
Add result logic to Backref and GlobalVar in builder to reduce temp v…
Browse files Browse the repository at this point in the history
…ars and accidental pinning
  • Loading branch information
enebo committed Jan 17, 2017
1 parent c0ac99b commit eb115c2
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Expand Up @@ -392,7 +392,7 @@ private Operand buildOperand(Variable result, Node node) throws NotCompilableExc
case ARGSPUSHNODE: return buildArgsPush((ArgsPushNode) node);
case ARRAYNODE: return buildArray((ArrayNode) node, false);
case ATTRASSIGNNODE: return buildAttrAssign(result, (AttrAssignNode) node);
case BACKREFNODE: return buildBackref((BackRefNode) node);
case BACKREFNODE: return buildBackref(result, (BackRefNode) node);
case BEGINNODE: return buildBegin((BeginNode) node);
case BIGNUMNODE: return buildBignum((BignumNode) node);
case BLOCKNODE: return buildBlock((BlockNode) node);
Expand Down Expand Up @@ -428,7 +428,7 @@ private Operand buildOperand(Variable result, Node node) throws NotCompilableExc
case FLOATNODE: return buildFloat((FloatNode) node);
case FORNODE: return buildFor((ForNode) node);
case GLOBALASGNNODE: return buildGlobalAsgn((GlobalAsgnNode) node);
case GLOBALVARNODE: return buildGlobalVar((GlobalVarNode) node);
case GLOBALVARNODE: return buildGlobalVar(result, (GlobalVarNode) node);
case HASHNODE: return buildHash((HashNode) node);
case IFNODE: return buildIf((IfNode) node);
case INSTASGNNODE: return buildInstAsgn((InstAsgnNode) node);
Expand Down Expand Up @@ -892,8 +892,9 @@ public Operand buildAttrAssignAssignment(Node node, Operand value) {
return value;
}

public Operand buildBackref(BackRefNode node) {
return addResultInstr(new BuildBackrefInstr(createTemporaryVariable(), node.getType()));
public Operand buildBackref(Variable result, BackRefNode node) {
if (result == null) result = createTemporaryVariable();
return addResultInstr(new BuildBackrefInstr(result, node.getType()));
}

public Operand buildBegin(BeginNode beginNode) {
Expand Down Expand Up @@ -2873,8 +2874,10 @@ public Operand buildGlobalAsgn(GlobalAsgnNode globalAsgnNode) {
return value;
}

public Operand buildGlobalVar(GlobalVarNode node) {
return addResultInstr(new GetGlobalVariableInstr(createTemporaryVariable(), node.getName()));
public Operand buildGlobalVar(Variable result, GlobalVarNode node) {
if (result == null) result = createTemporaryVariable();

return addResultInstr(new GetGlobalVariableInstr(result, node.getName()));
}

public Operand buildHash(HashNode hashNode) {
Expand Down

0 comments on commit eb115c2

Please sign in to comment.