public IRScope getNewLexicalParentForClosure() { return inClosureCloneMode ? clonedClosure : getInlineHostScope(); }
public IRScope getNewLexicalParentForClosure() { return inClosureCloneMode ? clonedClosure : getInlineHostScope(); }
@Override public Instr cloneForInlining(InlinerInfo ii) { // The frame will now be allocated in the caller's scope return new PushBindingInstr(ii.getInlineHostScope()); }
@Override public Instr cloneForInlining(InlinerInfo ii) { // The frame will now be allocated in the caller's scope return new PushBindingInstr(ii.getInlineHostScope()); }
public Label getRenamedLabel(Label l) { Label newLbl = this.lblRenameMap.get(l); if (newLbl == null) { newLbl = inClosureCloneMode ? l.clone() : getInlineHostScope().getNewLabel(); this.lblRenameMap.put(l, newLbl); } return newLbl; }
public Label getRenamedLabel(Label l) { Label newLbl = this.lblRenameMap.get(l); if (newLbl == null) { newLbl = inClosureCloneMode ? l.clone() : getInlineHostScope().getNewLabel(); this.lblRenameMap.put(l, newLbl); } return newLbl; }
public InlinerInfo(CallBase call, CFG c) { this.varRenameMap = new HashMap<Variable, Variable>(); this.lblRenameMap = new HashMap<Label, Label>(); this.bbRenameMap = new HashMap<BasicBlock, BasicBlock>(); this.yieldSites = new ArrayList(); this.call = call; this.callArgs = call.getCallArgs(); this.callerCFG = c; this.callReceiver = call.getReceiver(); this.inClosureCloneMode = false; this.inClosureInlineMode = false; this.canMapArgsStatically = !containsSplat(callArgs); this.argsArray = this.canMapArgsStatically ? null : getInlineHostScope().getNewTemporaryVariable(); synchronized(globalInlineCount) { this.inlineVarPrefix = "%in" + globalInlineCount + "_"; globalInlineCount++; } }
public InlinerInfo(CallBase call, CFG c) { this.varRenameMap = new HashMap<Variable, Variable>(); this.lblRenameMap = new HashMap<Label, Label>(); this.bbRenameMap = new HashMap<BasicBlock, BasicBlock>(); this.yieldSites = new ArrayList(); this.call = call; this.callArgs = call.getCallArgs(); this.callerCFG = c; this.callReceiver = call.getReceiver(); this.inClosureCloneMode = false; this.inClosureInlineMode = false; this.canMapArgsStatically = !containsSplat(callArgs); this.argsArray = this.canMapArgsStatically ? null : getInlineHostScope().getNewTemporaryVariable(); synchronized(globalInlineCount) { this.inlineVarPrefix = "%in" + globalInlineCount + "_"; globalInlineCount++; } }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.getInlineHostScope() == methodToReturnFrom) { // Convert to a regular return instruction return new NonlocalReturnInstr(returnValue.cloneForInlining(ii)); } else { return cloneForInlining(ii); } }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.getInlineHostScope() == methodToReturnFrom) { // Convert to a regular return instruction return new NonlocalReturnInstr(returnValue.cloneForInlining(ii)); } else { return cloneForInlining(ii); } }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.getInlineHostScope() == scopeToReturnTo) { // If the break got inlined into the scope we had to break to, replace the break // with a COPY of the break-value into the call's result var. // Ex: v = foo { ..; break n; ..}. So, "break n" is replaced with "v = n" // The CFG for the closure will be such that after break, control goes to the // scope exit block. So, we know that after the copy, we'll continue with the // instruction after the call. Variable v = ii.getCallResultVariable(); return (v == null) ? null : new CopyInstr(v, returnValue.cloneForInlining(ii)); } else { return cloneForInlining(ii); } }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.getInlineHostScope() == scopeToReturnTo) { // If the break got inlined into the scope we had to break to, replace the break // with a COPY of the break-value into the call's result var. // Ex: v = foo { ..; break n; ..}. So, "break n" is replaced with "v = n" // The CFG for the closure will be such that after break, control goes to the // scope exit block. So, we know that after the copy, we'll continue with the // instruction after the call. Variable v = ii.getCallResultVariable(); return (v == null) ? null : new CopyInstr(v, returnValue.cloneForInlining(ii)); } else { return cloneForInlining(ii); } }
public BasicBlock cloneForInlinedClosure(InlinerInfo ii) { // Update cfg for this bb IRScope hostScope = ii.getInlineHostScope(); BasicBlock clonedBB = ii.getOrCreateRenamedBB(this); // Process instructions for (Instr i: getInstrs()) { Instr clonedInstr = i.cloneForInlinedClosure(ii); if (clonedInstr != null) { clonedBB.addInstr(clonedInstr); if (clonedInstr instanceof CallBase) { CallBase call = (CallBase)clonedInstr; Operand block = call.getClosureArg(null); if (block instanceof WrappedIRClosure) hostScope.addClosure(((WrappedIRClosure)block).getClosure()); } } } return clonedBB; }
public BasicBlock cloneForInlinedClosure(InlinerInfo ii) { // Update cfg for this bb IRScope hostScope = ii.getInlineHostScope(); BasicBlock clonedBB = ii.getOrCreateRenamedBB(this); // Process instructions for (Instr i: getInstrs()) { Instr clonedInstr = i.cloneForInlinedClosure(ii); if (clonedInstr != null) { clonedBB.addInstr(clonedInstr); if (clonedInstr instanceof CallBase) { CallBase call = (CallBase)clonedInstr; Operand block = call.getClosureArg(null); if (block instanceof WrappedIRClosure) hostScope.addClosure(((WrappedIRClosure)block).getClosure()); } } } return clonedBB; }
public BasicBlock cloneForInlinedMethod(InlinerInfo ii) { IRScope hostScope = ii.getInlineHostScope(); BasicBlock clonedBB = ii.getOrCreateRenamedBB(this); for (Instr i: getInstrs()) { Instr clonedInstr = i.cloneForInlinedScope(ii); if (clonedInstr != null) { clonedBB.addInstr(clonedInstr); if (clonedInstr instanceof YieldInstr) ii.recordYieldSite(clonedBB, (YieldInstr)clonedInstr); if (clonedInstr instanceof CallBase) { CallBase call = (CallBase)clonedInstr; Operand block = call.getClosureArg(null); if (block instanceof WrappedIRClosure) hostScope.addClosure(((WrappedIRClosure)block).getClosure()); } } } return clonedBB; }
public BasicBlock cloneForInlinedMethod(InlinerInfo ii) { IRScope hostScope = ii.getInlineHostScope(); BasicBlock clonedBB = ii.getOrCreateRenamedBB(this); for (Instr i: getInstrs()) { Instr clonedInstr = i.cloneForInlinedScope(ii); if (clonedInstr != null) { clonedBB.addInstr(clonedInstr); if (clonedInstr instanceof YieldInstr) ii.recordYieldSite(clonedBB, (YieldInstr)clonedInstr); if (clonedInstr instanceof CallBase) { CallBase call = (CallBase)clonedInstr; Operand block = call.getClosureArg(null); if (block instanceof WrappedIRClosure) hostScope.addClosure(((WrappedIRClosure)block).getClosure()); } } } return clonedBB; }
public void setupYieldArgsAndYieldResult(YieldInstr yi, BasicBlock yieldBB, Arity blockArity) { int blockArityValue = blockArity.getValue(); Operand yieldInstrArg = yi.getYieldArg(); if ((yieldInstrArg == UndefinedValue.UNDEFINED) || (blockArityValue == 0)) { this.yieldArg = new Array(); // Zero-elt array } else if (yieldInstrArg instanceof Array) { this.yieldArg = yieldInstrArg; // 1:1 arg match if (((Array)yieldInstrArg).size() == blockArityValue) canMapArgsStatically = true; } else { // SSS FIXME: The code below is not entirely correct. We have to process 'yi.getYieldArg()' similar // to how InterpretedIRBlockBody (1.8 and 1.9 modes) processes it. We may need a special instruction // that takes care of aligning the stars and bringing good fortune to arg yielder and arg receiver. IRScope callerScope = getInlineHostScope(); boolean needSpecialProcessing = (blockArityValue != -1) && (blockArityValue != 1); Variable yieldArgArray = callerScope.getNewTemporaryVariable(); yieldBB.addInstr(new ToAryInstr(yieldArgArray, yieldInstrArg, callerScope.getManager().getTrue())); this.yieldArg = yieldArgArray; } this.yieldResult = yi.getResult(); }
public void setupYieldArgsAndYieldResult(YieldInstr yi, BasicBlock yieldBB, Arity blockArity) { int blockArityValue = blockArity.getValue(); Operand yieldInstrArg = yi.getYieldArg(); if ((yieldInstrArg == UndefinedValue.UNDEFINED) || (blockArityValue == 0)) { this.yieldArg = new Array(); // Zero-elt array } else if (yieldInstrArg instanceof Array) { this.yieldArg = yieldInstrArg; // 1:1 arg match if (((Array)yieldInstrArg).size() == blockArityValue) canMapArgsStatically = true; } else { // SSS FIXME: The code below is not entirely correct. We have to process 'yi.getYieldArg()' similar // to how InterpretedIRBlockBody (1.8 and 1.9 modes) processes it. We may need a special instruction // that takes care of aligning the stars and bringing good fortune to arg yielder and arg receiver. IRScope callerScope = getInlineHostScope(); boolean needSpecialProcessing = (blockArityValue != -1) && (blockArityValue != 1); Variable yieldArgArray = callerScope.getNewTemporaryVariable(); yieldBB.addInstr(new ToAryInstr(yieldArgArray, yieldInstrArg, callerScope.getManager().getTrue())); this.yieldArg = yieldArgArray; } this.yieldResult = yi.getResult(); }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); int remaining = n - preReqdArgsCount; Operand argVal; if (remaining <= argIndex) { // SSS: FIXME: Argh! argVal = ii.getInlineHostScope().getManager().getNil(); } else { argVal = (remaining > postReqdArgsCount) ? ii.getArg(n - postReqdArgsCount + argIndex) : ii.getArg(preReqdArgsCount + argIndex); } return new CopyInstr(ii.getRenamedVariable(result), argVal); } else { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preReqdArgsCount, postReqdArgsCount, argIndex); } }
@Override public Instr cloneForInlinedScope(InlinerInfo ii) { if (ii.canMapArgsStatically()) { int n = ii.getArgsCount(); int remaining = n - preReqdArgsCount; Operand argVal; if (remaining <= argIndex) { // SSS: FIXME: Argh! argVal = ii.getInlineHostScope().getManager().getNil(); } else { argVal = (remaining > postReqdArgsCount) ? ii.getArg(n - postReqdArgsCount + argIndex) : ii.getArg(preReqdArgsCount + argIndex); } return new CopyInstr(ii.getRenamedVariable(result), argVal); } else { return new ReqdArgMultipleAsgnInstr(ii.getRenamedVariable(result), ii.getArgs(), preReqdArgsCount, postReqdArgsCount, argIndex); } }