Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[IR] Renamed GetArrayInstr --> MultipleAsgnInstr as a first step to

make multiple-assignment and block-arg receive IR instructions parallel
each other (when a block is inlined, block-arg Receive* instructions will
be changed to MultipleAsgn instructions).
  • Loading branch information...
commit 63227a1d55f5f566e06d4320b10bef89d2a27c54 1 parent 66ecd85
@subbuss subbuss authored
View
8 src/org/jruby/compiler/ir/IRBuilder.java
@@ -132,7 +132,7 @@
import org.jruby.compiler.ir.instructions.ExceptionRegionEndMarkerInstr;
import org.jruby.compiler.ir.instructions.ExceptionRegionStartMarkerInstr;
import org.jruby.compiler.ir.instructions.GVarAliasInstr;
-import org.jruby.compiler.ir.instructions.GetArrayInstr;
+import org.jruby.compiler.ir.instructions.MultipleAsgnInstr;
import org.jruby.compiler.ir.instructions.GetClassVarContainerModuleInstr;
import org.jruby.compiler.ir.instructions.GetClassVariableInstr;
import org.jruby.compiler.ir.instructions.GetFieldInstr;
@@ -806,7 +806,7 @@ protected void receiveBlockArg(IRScope s, Variable v, Operand argsArray, int arg
if (argsArray != null) {
// We are in a nested receive situation -- when we are not at the root of a masgn tree
// Ex: We are trying to receive (b,c) in this example: "|a, (b,c), d| = ..."
- s.addInstr(new GetArrayInstr(v, argsArray, argIndex, isSplat));
+ s.addInstr(new MultipleAsgnInstr(v, argsArray, argIndex, isSplat));
} else {
// argsArray can be null when the first node in the args-node-ast is a multiple-assignment
// For example, for-nodes
@@ -2583,7 +2583,7 @@ public void buildMultipleAsgnAssignment(final MultipleAsgnNode multipleAsgnNode,
buildBlockArgsAssignment(an, s, argsArray, i, false, false, false);
} else {
Variable rhsVal = s.getNewTemporaryVariable();
- s.addInstr(new GetArrayInstr(rhsVal, values, i, false));
+ s.addInstr(new MultipleAsgnInstr(rhsVal, values, i, false));
buildAssignment(an, s, rhsVal);
}
i++;
@@ -2599,7 +2599,7 @@ public void buildMultipleAsgnAssignment(final MultipleAsgnNode multipleAsgnNode,
// do nothing
} else if (values != null) {
Variable rhsVal = s.getNewTemporaryVariable();
- s.addInstr(new GetArrayInstr(rhsVal, values, i, true));
+ s.addInstr(new MultipleAsgnInstr(rhsVal, values, i, true));
buildAssignment(argsNode, s, rhsVal); // rest of the argument array!
} else {
buildBlockArgsAssignment(argsNode, s, argsArray, i, false, false, true); // rest of the argument array!
View
14 src/org/jruby/compiler/ir/IRBuilder19.java
@@ -24,7 +24,7 @@
import org.jruby.compiler.ir.instructions.CallInstr;
import org.jruby.compiler.ir.instructions.ClosureReturnInstr;
import org.jruby.compiler.ir.instructions.CopyInstr;
-import org.jruby.compiler.ir.instructions.GetArrayInstr;
+import org.jruby.compiler.ir.instructions.MultipleAsgnInstr;
import org.jruby.compiler.ir.instructions.JRubyImplCallInstr;
import org.jruby.compiler.ir.instructions.JRubyImplCallInstr.JRubyImplementationMethod;
import org.jruby.compiler.ir.instructions.LabelInstr;
@@ -259,13 +259,13 @@ public void buildArgsMasgn(Node node, IRScope s, Operand argsArray, boolean isMa
case DASGNNODE: {
DAsgnNode dynamicAsgn = (DAsgnNode) node;
v = getArgVariable(s, dynamicAsgn.getName(), dynamicAsgn.getDepth());
- s.addInstr(new GetArrayInstr(v, argsArray, preArgsCount, postArgsCount, index, isSplat));
+ s.addInstr(new MultipleAsgnInstr(v, argsArray, preArgsCount, postArgsCount, index, isSplat));
break;
}
case LOCALASGNNODE: {
LocalAsgnNode localVariable = (LocalAsgnNode) node;
v = getArgVariable(s, localVariable.getName(), localVariable.getDepth());
- s.addInstr(new GetArrayInstr(v, argsArray, preArgsCount, postArgsCount, index, isSplat));
+ s.addInstr(new MultipleAsgnInstr(v, argsArray, preArgsCount, postArgsCount, index, isSplat));
break;
}
case MULTIPLEASGN19NODE: {
@@ -273,7 +273,7 @@ public void buildArgsMasgn(Node node, IRScope s, Operand argsArray, boolean isMa
MultipleAsgn19Node childNode = (MultipleAsgn19Node) node;
if (!isMasgnRoot) {
v = s.getNewTemporaryVariable();
- s.addInstr(new GetArrayInstr(v, argsArray, preArgsCount, postArgsCount, index, isSplat));
+ s.addInstr(new MultipleAsgnInstr(v, argsArray, preArgsCount, postArgsCount, index, isSplat));
s.addInstr(new ToAryInstr(v, v, manager.getFalse()));
argsArray = v;
}
@@ -301,7 +301,7 @@ public void buildMultipleAsgn19Assignment(final MultipleAsgn19Node multipleAsgnN
buildArgsMasgn(an, s, argsArray, false, -1, -1, i, false);
} else {
Variable rhsVal = s.getNewTemporaryVariable();
- s.addInstr(new GetArrayInstr(rhsVal, values, i, false));
+ s.addInstr(new MultipleAsgnInstr(rhsVal, values, i, false));
buildAssignment(an, s, rhsVal);
}
i++;
@@ -318,7 +318,7 @@ public void buildMultipleAsgn19Assignment(final MultipleAsgn19Node multipleAsgnN
buildArgsMasgn(restNode, s, argsArray, false, i, postArgsCount, 0, true); // rest of the argument array!
} else {
Variable rhsVal = s.getNewTemporaryVariable();
- s.addInstr(new GetArrayInstr(rhsVal, values, i, postArgsCount, 0, true));
+ s.addInstr(new MultipleAsgnInstr(rhsVal, values, i, postArgsCount, 0, true));
buildAssignment(restNode, s, rhsVal); // rest of the argument array!
}
}
@@ -332,7 +332,7 @@ public void buildMultipleAsgn19Assignment(final MultipleAsgn19Node multipleAsgnN
buildArgsMasgn(an, s, argsArray, false, i, postArgsCount, j, false);
} else {
Variable rhsVal = s.getNewTemporaryVariable();
- s.addInstr(new GetArrayInstr(rhsVal, values, i, postArgsCount, j, false)); // Fetch from the end
+ s.addInstr(new MultipleAsgnInstr(rhsVal, values, i, postArgsCount, j, false)); // Fetch from the end
buildAssignment(an, s, rhsVal);
}
j++;
View
2  src/org/jruby/compiler/ir/Operation.java
@@ -98,8 +98,8 @@
GET_GLOBAL_VAR(OpFlags.f_is_load),
GET_FIELD(OpFlags.f_is_load),
GET_CVAR(OpFlags.f_is_load | OpFlags.f_can_raise_exception),
- GET_ARRAY(OpFlags.f_is_load),
BINDING_LOAD(OpFlags.f_is_load),
+ MASGN(OpFlags.f_is_load),
/** constant operations */
LEXICAL_SEARCH_CONST(OpFlags.f_can_raise_exception),
View
16 ...jruby/compiler/ir/instructions/GetArrayInstr.java → ...y/compiler/ir/instructions/MultipleAsgnInstr.java
@@ -18,10 +18,6 @@
// i.e. if I override the elt accessor method [], will multiple-assignment
// semantics change as well?
//
-// FIXME: Rename GetArrayInstr to ArrayArefInstr which would be used
-// in later passes as well when compiler passes replace ruby-array []
-// getArraySlices with inlined lookups
-//
// SSS FIXME: This is now asking to be split into multiple instructions.
// This instr. is being used to split an arg received by a parenthesized unit in
// method/block args. So, this effectively behaves like a receive* instruction.
@@ -32,7 +28,7 @@
//
// Is it time to refactor and clean this up?
-public class GetArrayInstr extends Instr implements ResultInstr {
+public class MultipleAsgnInstr extends Instr implements ResultInstr {
private Operand array;
private final int preArgsCount; // # of reqd args before rest-arg (-1 if we are fetching a pre-arg)
private final int postArgsCount; // # of reqd args after rest-arg (-1 if we are fetching a pre-arg)
@@ -40,10 +36,10 @@
private final boolean getArraySlice; // If true, returns an array slice between indexFromStart and indexFromEnd (rest of the array if indexFromEnd is -1)
private Variable result;
- public GetArrayInstr(Variable result, Operand array, int preArgsCount, int postArgsCount, int index, boolean getRestOfArray) {
- super(Operation.GET_ARRAY);
+ public MultipleAsgnInstr(Variable result, Operand array, int preArgsCount, int postArgsCount, int index, boolean getRestOfArray) {
+ super(Operation.MASGN);
- assert result != null : "GetArrayInstr result is null";
+ assert result != null : "MultipleAsgnInstr result is null";
this.result = result;
this.array = array;
@@ -53,7 +49,7 @@ public GetArrayInstr(Variable result, Operand array, int preArgsCount, int postA
this.getArraySlice = getRestOfArray;
}
- public GetArrayInstr(Variable result, Operand array, int index, boolean getRestOfArray) {
+ public MultipleAsgnInstr(Variable result, Operand array, int index, boolean getRestOfArray) {
this(result, array, -1, -1, index, getRestOfArray);
}
@@ -92,7 +88,7 @@ public Operand simplifyAndGetResult(IRScope scope, Map<Operand, Operand> valueMa
@Override
public Instr cloneForInlining(InlinerInfo ii) {
- return new GetArrayInstr(ii.getRenamedVariable(result), array.cloneForInlining(ii), preArgsCount, postArgsCount, index, getArraySlice);
+ return new MultipleAsgnInstr(ii.getRenamedVariable(result), array.cloneForInlining(ii), preArgsCount, postArgsCount, index, getArraySlice);
}
@Override
Please sign in to comment.
Something went wrong with that request. Please try again.