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: 20423479f3a7
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 84d9a8b62b3b
Choose a head ref
  • 2 commits
  • 18 files changed
  • 1 contributor

Commits on Apr 6, 2015

  1. Add isPotentiallyRefined boolean to all call types so we can define y…

    …et-to-be-made refinedCallsite types
    enebo committed Apr 6, 2015
    Copy the full SHA
    ba3c0f4 View commit details
  2. Copy the full SHA
    84d9a8b View commit details
Showing with 110 additions and 93 deletions.
  1. +10 −11 core/src/main/java/org/jruby/ir/IRBuilder.java
  2. +8 −7 core/src/main/java/org/jruby/ir/instructions/AttrAssignInstr.java
  3. +8 −2 core/src/main/java/org/jruby/ir/instructions/CallBase.java
  4. +17 −22 core/src/main/java/org/jruby/ir/instructions/CallInstr.java
  5. +6 −4 core/src/main/java/org/jruby/ir/instructions/ClassSuperInstr.java
  6. +5 −4 core/src/main/java/org/jruby/ir/instructions/ConstMissingInstr.java
  7. +6 −4 core/src/main/java/org/jruby/ir/instructions/InstanceSuperInstr.java
  8. +10 −7 core/src/main/java/org/jruby/ir/instructions/NoResultCallInstr.java
  9. +9 −6 core/src/main/java/org/jruby/ir/instructions/UnresolvedSuperInstr.java
  10. +5 −4 core/src/main/java/org/jruby/ir/instructions/ZSuperInstr.java
  11. +3 −3 core/src/main/java/org/jruby/ir/instructions/specialized/OneArgOperandAttrAssignInstr.java
  12. +3 −3 core/src/main/java/org/jruby/ir/instructions/specialized/OneFixnumArgNoBlockCallInstr.java
  13. +4 −3 core/src/main/java/org/jruby/ir/instructions/specialized/OneFloatArgNoBlockCallInstr.java
  14. +4 −3 core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgBlockCallInstr.java
  15. +4 −3 core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockCallInstr.java
  16. +4 −3 core/src/main/java/org/jruby/ir/instructions/specialized/OneOperandArgNoBlockNoResultCallInstr.java
  17. +4 −3 core/src/main/java/org/jruby/ir/instructions/specialized/ZeroOperandArgNoBlockCallInstr.java
  18. +0 −1 test/mri/excludes/TestRubyLiteral.rb
21 changes: 10 additions & 11 deletions core/src/main/java/org/jruby/ir/IRBuilder.java
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@
import java.io.FileInputStream;
import java.io.IOException;
import java.util.*;
import org.jruby.util.StringSupport;

import static org.jruby.ir.instructions.RuntimeHelperCall.Methods.*;

@@ -857,7 +856,7 @@ private Operand buildAttrAssign(final AttrAssignNode attrAssignNode) {
List<Operand> args = new ArrayList<>();
Node argsNode = attrAssignNode.getArgsNode();
Operand lastArg = buildAttrAssignCallArgs(args, argsNode, containsAssignment);
addInstr(AttrAssignInstr.create(obj, attrAssignNode.getName(), args.toArray(new Operand[args.size()])));
addInstr(AttrAssignInstr.create(obj, attrAssignNode.getName(), args.toArray(new Operand[args.size()]), scope.maybeUsingRefinements()));
return lastArg;
}

@@ -866,7 +865,7 @@ public Operand buildAttrAssignAssignment(Node node, Operand value) {
Operand obj = build(attrAssignNode.getReceiverNode());
Operand[] args = setupCallArgs(attrAssignNode.getArgsNode());
args = addArg(args, value);
addInstr(AttrAssignInstr.create(obj, attrAssignNode.getName(), args));
addInstr(AttrAssignInstr.create(obj, attrAssignNode.getName(), args, scope.maybeUsingRefinements()));
return value;
}

@@ -1268,7 +1267,7 @@ public Operand buildConstDeclAssignment(ConstDeclNode constDeclNode, Operand val
private void genInheritanceSearchInstrs(Operand startingModule, Variable constVal, Label foundLabel, boolean noPrivateConstants, String name) {
addInstr(new InheritanceSearchConstInstr(constVal, startingModule, name, noPrivateConstants));
addInstr(BNEInstr.create(foundLabel, constVal, UndefinedValue.UNDEFINED));
addInstr(new ConstMissingInstr(constVal, startingModule, name));
addInstr(new ConstMissingInstr(constVal, startingModule, name, scope.maybeUsingRefinements()));
addInstr(new LabelInstr(foundLabel));
}

@@ -2431,7 +2430,7 @@ public Operand buildFor(ForNode forNode) {
Variable result = createTemporaryVariable();
Operand receiver = build(forNode.getIterNode());
Operand forBlock = buildForIter(forNode);
CallInstr callInstr = new CallInstr(CallType.NORMAL, result, "each", receiver, NO_ARGS, forBlock);
CallInstr callInstr = new CallInstr(CallType.NORMAL, result, "each", receiver, NO_ARGS, forBlock, scope.maybeUsingRefinements());
receiveBreakException(forBlock, callInstr);

return result;
@@ -3278,16 +3277,16 @@ private Operand buildSuperInstr(Operand block, Operand[] args) {
Variable ret = createTemporaryVariable();
if (scope instanceof IRMethod && scope.getLexicalParent() instanceof IRClassBody) {
if (((IRMethod) scope).isInstanceMethod) {
superInstr = new InstanceSuperInstr(ret, scope.getCurrentModuleVariable(), getName(), args, block);
superInstr = new InstanceSuperInstr(ret, scope.getCurrentModuleVariable(), getName(), args, block, scope.maybeUsingRefinements());
} else {
superInstr = new ClassSuperInstr(ret, scope.getCurrentModuleVariable(), getName(), args, block);
superInstr = new ClassSuperInstr(ret, scope.getCurrentModuleVariable(), getName(), args, block, scope.maybeUsingRefinements());
}
} else {
// We dont always know the method name we are going to be invoking if the super occurs in a closure.
// This is because the super can be part of a block that will be used by 'define_method' to define
// a new method. In that case, the method called by super will be determined by the 'name' argument
// to 'define_method'.
superInstr = new UnresolvedSuperInstr(ret, buildSelf(), args, block);
superInstr = new UnresolvedSuperInstr(ret, buildSelf(), args, block, scope.maybeUsingRefinements());
}
receiveBreakException(block, superInstr);
return ret;
@@ -3303,7 +3302,7 @@ public Operand buildSuper(SuperNode superNode) {
}

private Operand buildSuperInScriptBody() {
return addResultInstr(new UnresolvedSuperInstr(createTemporaryVariable(), buildSelf(), NO_ARGS, null));
return addResultInstr(new UnresolvedSuperInstr(createTemporaryVariable(), buildSelf(), NO_ARGS, null, scope.maybeUsingRefinements()));
}

public Operand buildSValue(SValueNode node) {
@@ -3456,7 +3455,7 @@ public Operand run() {
next = getNewLabel();
addInstr(BNEInstr.create(next, new Fixnum(depthFromSuper), scopeDepth));
Operand[] args = adjustVariableDepth(getCallArgs(superScope, superBuilder), depthFromSuper);
addInstr(new ZSuperInstr(zsuperResult, buildSelf(), args, block));
addInstr(new ZSuperInstr(zsuperResult, buildSelf(), args, block, scope.maybeUsingRefinements()));
addInstr(new JumpInstr(allDoneLabel));

// We may run out of live builds and walk int already built scopes if zsuper in an eval
@@ -3470,7 +3469,7 @@ public Operand run() {
// If we hit a method, this is known to always succeed
if (superScope instanceof IRMethod) {
Operand[] args = adjustVariableDepth(getCallArgs(superScope, superBuilder), depthFromSuper);
addInstr(new ZSuperInstr(zsuperResult, buildSelf(), args, block));
addInstr(new ZSuperInstr(zsuperResult, buildSelf(), args, block, scope.maybeUsingRefinements()));
} //else {
// FIXME: Do or don't ... there is no try
/* Control should never get here in the runtime */
Original file line number Diff line number Diff line change
@@ -18,16 +18,16 @@
// 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) {
public static AttrAssignInstr create(Operand obj, String attr, Operand[] args, boolean isPotentiallyRefined) {
if (!containsArgSplat(args) && args.length == 1) {
return new OneArgOperandAttrAssignInstr(obj, attr, args);
return new OneArgOperandAttrAssignInstr(obj, attr, args, isPotentiallyRefined);
}

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

public AttrAssignInstr(Operand obj, String attr, Operand[] args) {
super(Operation.ATTR_ASSIGN, CallType.UNKNOWN, attr, obj, args, null);
public AttrAssignInstr(Operand obj, String attr, Operand[] args, boolean isPotentiallyRefined) {
super(Operation.ATTR_ASSIGN, CallType.UNKNOWN, attr, obj, args, null, isPotentiallyRefined);
}

@Override
@@ -43,7 +43,7 @@ public boolean computeScopeFlags(IRScope scope) {

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

@Override
@@ -53,10 +53,11 @@ public void encode(IRWriterEncoder e) {
e.encode(getReceiver());
e.encode(getName());
e.encode(getCallArgs());
e.encode(isPotentiallyRefined());
}

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

@Override
10 changes: 8 additions & 2 deletions core/src/main/java/org/jruby/ir/instructions/CallBase.java
Original file line number Diff line number Diff line change
@@ -13,7 +13,6 @@
import org.jruby.runtime.builtin.IRubyObject;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;

@@ -36,8 +35,10 @@ public abstract class CallBase extends Instr implements ClosureAcceptingInstr {
private boolean dontInline;
private boolean containsArgSplat;
private 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, String name, Operand receiver, Operand[] args, Operand closure,
boolean potentiallyRefined) {
super(op, getOperands(receiver, args, closure));

this.callSiteId = callSiteCounter++;
@@ -53,6 +54,7 @@ protected CallBase(Operation op, CallType callType, String name, Operand receive
targetRequiresCallersFrame = true;
dontInline = false;
procNew = false;
this.potentiallyRefined = potentiallyRefined;
}

@Override
@@ -179,6 +181,10 @@ public static boolean isAllFloats(Operand[] args) {
return true;
}

public boolean isPotentiallyRefined() {
return potentiallyRefined;
}

@Override
public boolean computeScopeFlags(IRScope scope) {
boolean modifiedScope = false;
39 changes: 17 additions & 22 deletions core/src/main/java/org/jruby/ir/instructions/CallInstr.java
Original file line number Diff line number Diff line change
@@ -27,46 +27,40 @@ public static CallInstr create(IRScope scope, Variable result, String name, Oper
}

public static CallInstr create(IRScope scope, CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
if (scope.maybeUsingRefinements()) {
// FIXME: Make same instr with refined callSite here or push though all path below
}
boolean isPotentiallyRefined = scope.maybeUsingRefinements();

if (!containsArgSplat(args)) {
boolean hasClosure = closure != null;

if (args.length == 0 && !hasClosure) {
return new ZeroOperandArgNoBlockCallInstr(callType, result, name, receiver, args);
return new ZeroOperandArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);
} else if (args.length == 1) {
if (hasClosure) return new OneOperandArgBlockCallInstr(callType, result, name, receiver, args, closure);
if (isAllFixnums(args)) return new OneFixnumArgNoBlockCallInstr(callType, result, name, receiver, args);
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(callType, result, name, receiver, args);
if (hasClosure) return new OneOperandArgBlockCallInstr(callType, result, name, receiver, args, closure, isPotentiallyRefined);
if (isAllFixnums(args)) return new OneFixnumArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);
if (isAllFloats(args)) return new OneFloatArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);

return new OneOperandArgNoBlockCallInstr(callType, result, name, receiver, args);
return new OneOperandArgNoBlockCallInstr(callType, result, name, receiver, args, isPotentiallyRefined);
}
}

return new CallInstr(callType, result, name, receiver, args, closure);
return new CallInstr(callType, result, name, receiver, args, closure, isPotentiallyRefined);
}


public CallInstr(CallType callType, Variable result, String name, Operand receiver, Operand[] args, Operand closure) {
this(Operation.CALL, callType, result, name, receiver, args, closure);
public CallInstr(CallType callType, Variable result, String 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, Operand closure) {
super(op, callType, name, receiver, args, closure);
protected CallInstr(Operation op, CallType callType, Variable result, String name, Operand receiver, Operand[] args,
Operand closure, boolean potentiallyRefined) {
super(op, callType, name, receiver, args, closure, potentiallyRefined);

assert result != null;

this.result = result;
}

public CallInstr(Operation op, CallInstr ordinary) {
this(op, ordinary.getCallType(), ordinary.getResult(),
ordinary.getName(), ordinary.getReceiver(), ordinary.getCallArgs(),
ordinary.getClosureArg(null));
}

@Override
public void encode(IRWriterEncoder e) {
super.encode(e);
@@ -112,13 +106,14 @@ public void updateResult(Variable v) {
}

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

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

@Override
Original file line number Diff line number Diff line change
@@ -14,8 +14,9 @@
import org.jruby.runtime.builtin.IRubyObject;

public class ClassSuperInstr extends CallInstr {
public ClassSuperInstr(Variable result, Operand definingModule, String name, Operand[] args, Operand closure) {
super(Operation.CLASS_SUPER, CallType.SUPER, result, name, definingModule, args, closure);
public ClassSuperInstr(Variable result, Operand definingModule, String name, Operand[] args, Operand closure,
boolean isPotentiallyRefined) {
super(Operation.CLASS_SUPER, CallType.SUPER, result, name, definingModule, args, closure, isPotentiallyRefined);
}

public Operand getDefiningModule() {
@@ -25,7 +26,7 @@ public Operand getDefiningModule() {
@Override
public Instr clone(CloneInfo ii) {
return new ClassSuperInstr(ii.getRenamedVariable(getResult()), getDefiningModule().cloneForInlining(ii), name,
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii));
cloneCallArgs(ii), getClosureArg() == null ? null : getClosureArg().cloneForInlining(ii), isPotentiallyRefined());
}

public static ClassSuperInstr decode(IRReaderDecoder d) {
@@ -46,8 +47,9 @@ public static ClassSuperInstr decode(IRReaderDecoder d) {
}

Operand closure = hasClosureArg ? d.decodeOperand() : null;
boolean isPotentiallyRefined = d.decodeBoolean();

return new ClassSuperInstr(d.decodeVariable(), receiver, methAddr, args, closure);
return new ClassSuperInstr(d.decodeVariable(), receiver, methAddr, args, closure, isPotentiallyRefined);
}
// We cannot convert this into a NoCallResultInstr
@Override
Original file line number Diff line number Diff line change
@@ -21,9 +21,10 @@
public class ConstMissingInstr extends CallInstr implements FixedArityInstr {
private final String missingConst;

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

this.missingConst = missingConst;
}
@@ -34,7 +35,7 @@ public String getMissingConst() {

@Override
public Instr clone(CloneInfo ii) {
return new ConstMissingInstr(ii.getRenamedVariable(result), getReceiver().cloneForInlining(ii), missingConst);
return new ConstMissingInstr(ii.getRenamedVariable(result), getReceiver().cloneForInlining(ii), missingConst, isPotentiallyRefined());
}

@Override
@@ -47,7 +48,7 @@ public void encode(IRWriterEncoder e) {
}

public static ConstMissingInstr decode(IRReaderDecoder d) {
return new ConstMissingInstr(d.decodeVariable(), d.decodeOperand(), d.decodeString());
return new ConstMissingInstr(d.decodeVariable(), d.decodeOperand(), d.decodeString(), d.decodeBoolean());
}

@Override
Original file line number Diff line number Diff line change
@@ -17,8 +17,9 @@
import org.jruby.runtime.builtin.IRubyObject;

public class InstanceSuperInstr extends CallInstr {
public InstanceSuperInstr(Variable result, Operand definingModule, String name, Operand[] args, Operand closure) {
super(Operation.INSTANCE_SUPER, CallType.SUPER, result, name, definingModule, args, closure);
public InstanceSuperInstr(Variable result, Operand definingModule, String name, Operand[] args, Operand closure,
boolean isPotentiallyRefined) {
super(Operation.INSTANCE_SUPER, CallType.SUPER, result, name, definingModule, args, closure, isPotentiallyRefined);
}

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

public static InstanceSuperInstr decode(IRReaderDecoder d) {
@@ -49,8 +50,9 @@ public static InstanceSuperInstr decode(IRReaderDecoder d) {
}

Operand closure = hasClosureArg ? d.decodeOperand() : null;
boolean isPotentiallyRefined = d.decodeBoolean();

return new InstanceSuperInstr(d.decodeVariable(), receiver, methAddr, args, closure);
return new InstanceSuperInstr(d.decodeVariable(), receiver, methAddr, args, closure, isPotentiallyRefined);
}

// We cannot convert this into a NoCallResultInstr
Loading