protected IRClosure cloneForInlining(CloneInfo ii, IRClosure clone) { // SSS FIXME: This is fragile. Untangle this state. // Why is this being copied over to InterpretedIRBlockBody? clone.isBeginEndBlock = this.isBeginEndBlock; SimpleCloneInfo clonedII = ii.cloneForCloningClosure(clone); // if (getCFG() != null) { // clone.setCFG(getCFG().clone(clonedII, clone)); // } else { List<Instr> newInstrs = new ArrayList<>(interpreterContext.getInstructions().length); for (Instr i: interpreterContext.getInstructions()) { newInstrs.add(i.clone(clonedII)); } clone.allocateInterpreterContext(newInstrs); // } return clone; }
@Override public Operand cloneForInlining(CloneInfo ii) { return ii.getRenamedLabel(this); }
/** * Return a new instance of a label for the newly cloned scope. Maps are maintained * because Labels expect to share the same instance across a CFG. * * @param label to be renamed. * @return the new Label */ public Label getRenamedLabel(Label label) { if (Label.UNRESCUED_REGION_LABEL.equals(label)) return label; // Special case -- is there a way to avoid this? Label newLabel = this.labelRenameMap.get(label); if (newLabel == null) { newLabel = getRenamedLabelSimple(label); this.labelRenameMap.put(label, newLabel); } return newLabel; }
/** * Return a new instance of a variable for the newly cloned scope. Maps are maintained * because Variables typically share the same instance across a CFG (of the same lexical depth). * * @param variable to be renamed * @return the new Variable */ public Variable getRenamedVariable(Variable variable) { if (variable instanceof Self) return getRenamedSelfVariable(variable); Variable newVariable = variableRenameMap.get(variable); if (newVariable == null) { newVariable = getRenamedVariableSimple(variable); variableRenameMap.put(variable, newVariable); } return newVariable; } }
@Override public Instr clone(CloneInfo ii) { return new ConstMissingInstr(ii.getScope(), ii.getRenamedVariable(result), getReceiver().cloneForInlining(ii), missingConst, cloneCallArgs(ii), isPotentiallyRefined(), getCallSite(), getCallSiteId()); }
@Override public Operand cloneForInlining(CloneInfo ii) { return ii.getRenamedVariable(this); } }
@Override public Instr clone(CloneInfo ii) { return new ArrayDerefInstr(ii.getScope(), (Variable) getResult().cloneForInlining(ii), getReceiver().cloneForInlining(ii), key, getCallSite(), getCallSiteId()); }
@Override public Instr clone(CloneInfo ii) { return new OneFixnumArgNoBlockCallInstr(ii.getScope(), getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined(), callSite, callSiteId); }
@Override public Instr clone(CloneInfo ii) { // SSS FIXME: Do we need to rename lvar really? It is just a name-proxy! return new LoadLocalVarInstr(scope, (TemporaryLocalVariable)ii.getRenamedVariable(result), (LocalVariable)ii.getRenamedVariable(getLocalVar())); }
@Override public Instr clone(CloneInfo ii) { return new ArrayDerefInstr(ii.getScope(), (Variable) getResult().cloneForInlining(ii), getReceiver().cloneForInlining(ii), key, getCallSite(), getCallSiteId()); }
/** * Return a new instance of a variable for the newly cloned scope. Maps are maintained * because Variables typically share the same instance across a CFG (of the same lexical depth). * * @param variable to be renamed * @return the new Variable */ public Variable getRenamedVariable(Variable variable) { if (variable instanceof Self) return getRenamedSelfVariable(variable); Variable newVariable = variableRenameMap.get(variable); if (newVariable == null) { newVariable = getRenamedVariableSimple(variable); variableRenameMap.put(variable, newVariable); } return newVariable; } }
@Override public Instr clone(CloneInfo ii) { return new ConstMissingInstr(ii.getScope(), ii.getRenamedVariable(result), getReceiver().cloneForInlining(ii), missingConst, cloneCallArgs(ii), isPotentiallyRefined(), getCallSite(), getCallSiteId()); }
@Override public Operand cloneForInlining(CloneInfo info) { // Making interp instrs so that if JIT hits IRClosure we will not concurrently modify the same IRScope. if (info instanceof SimpleCloneInfo && !((SimpleCloneInfo) info).isEnsureBlockCloneMode()) { // FIXME: It really bothers me we do not clone closure here but cloning like main clone case loses interpContext + other things. return new WrappedIRClosure(info.getRenamedVariable(self), closure); } return new WrappedIRClosure(info.getRenamedVariable(self), closure.cloneForInlining(info)); }
@Override public Operand cloneForInlining(CloneInfo ii) { return ii.getRenamedLabel(this); }
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()); } else { int id = lexicalParent.getNextClosureId(); ByteList fullName = lexicalParent.getName().getBytes().dup(); fullName.append(CLOSURE_CLONE); fullName.append(new Integer(id).toString().getBytes()); clonedClosure = new IRClosure(this, lexicalParent, id, getManager().runtime.newSymbol(fullName)); } // WrappedIRClosure should always have a single unique IRClosure in them so we should // not end up adding n copies of the same closure as distinct clones... lexicalParent.addClosure(clonedClosure); return cloneForInlining(ii, clonedClosure); }
/** * Return a new instance of a label for the newly cloned scope. Maps are maintained * because Labels expect to share the same instance across a CFG. * * @param label to be renamed. * @return the new Label */ public Label getRenamedLabel(Label label) { if (Label.UNRESCUED_REGION_LABEL.equals(label)) return label; // Special case -- is there a way to avoid this? Label newLabel = this.labelRenameMap.get(label); if (newLabel == null) { newLabel = getRenamedLabelSimple(label); this.labelRenameMap.put(label, newLabel); } return newLabel; }
protected IRClosure cloneForInlining(CloneInfo ii, IRClosure clone) { // SSS FIXME: This is fragile. Untangle this state. // Why is this being copied over to InterpretedIRBlockBody? clone.isBeginEndBlock = this.isBeginEndBlock; SimpleCloneInfo clonedII = ii.cloneForCloningClosure(clone); // if (getCFG() != null) { // clone.setCFG(getCFG().clone(clonedII, clone)); // } else { List<Instr> newInstrs = new ArrayList<>(interpreterContext.getInstructions().length); for (Instr i: interpreterContext.getInstructions()) { newInstrs.add(i.clone(clonedII)); } clone.allocateInterpreterContext(newInstrs); // } return clone; }
@Override public Instr clone(CloneInfo ii) { return new OneFixnumArgNoBlockCallInstr(ii.getScope(), getCallType(), ii.getRenamedVariable(result), getName(), getReceiver().cloneForInlining(ii), cloneCallArgs(ii), isPotentiallyRefined(), callSite, callSiteId); }
@Override public Instr clone(CloneInfo ii) { // Share the cache! return new BuildDynRegExpInstr(ii.getRenamedVariable(result), cloneOperands(ii), options, this.reCache); }
@Override public Instr clone(CloneInfo info) { Operand operand = this.operand.cloneForInlining(info); Label rubyCase = info.getRenamedLabel(this.rubyCase); Label[] targets = new Label[this.targets.length]; for (int i = 0; i < targets.length; i++) targets[i] = info.getRenamedLabel(this.targets[i]); Label elseTarget = info.getRenamedLabel(this.elseTarget); return new BSwitchInstr(jumps, operand, rubyCase, targets, elseTarget); }