@Override public Instr clone(CloneInfo ii) { // We record cloned scope so that debugging can remember where the linenumber original came from. // FIXME: Consider just saving filename and not entire scope if (ii instanceof InlineCloneInfo) { new InlinedLineNumberInstr(((InlineCloneInfo) ii).getScopeBeingInlined(), lineNumber); } // If a simple clone then we can share this instance since it cannot cause flow // control to change (ipc and rpc should never be accessed). return this; }
@Override public Operand cloneForInlining(CloneInfo ii) { if (ii instanceof InlineCloneInfo) { InlineCloneInfo iici = (InlineCloneInfo) ii; // inlined method lives somewhere else so we need to save that scope location. if (iici.getHostScope() != iici.getScopeBeingInlined()) { return new Scope(((InlineCloneInfo) ii).getScopeBeingInlined()); } } return this; }
@Override public Operand cloneForInlining(CloneInfo ii) { if (ii instanceof InlineCloneInfo) { InlineCloneInfo iici = (InlineCloneInfo) ii; // inlined method lives somewhere else so we need to save that scope location. if (iici.getHostScope() != iici.getScopeBeingInlined()) { return new Scope(((InlineCloneInfo) ii).getScopeBeingInlined()); } } return this; }
@Override public Instr clone(CloneInfo ii) { // We record cloned scope so that debugging can remember where the linenumber original came from. // FIXME: Consider just saving filename and not entire scope if (ii instanceof InlineCloneInfo) { new InlinedLineNumberInstr(((InlineCloneInfo) ii).getScopeBeingInlined(), lineNumber); } // If a simple clone then we can share this instance since it cannot cause flow // control to change (ipc and rpc should never be accessed). return this; }
@Override public Instr clone(CloneInfo info) { if (info instanceof InlineCloneInfo) { InlineCloneInfo ii = (InlineCloneInfo) info; // lexical closure if (ii.getScopeBeingInlined().isScopeContainedBy(ii.getHostScope())) return NopInstr.NOP; } return this; }
@Override public Instr clone(CloneInfo info) { if (info instanceof InlineCloneInfo) { InlineCloneInfo ii = (InlineCloneInfo) info; // lexical closure if (ii.getScopeBeingInlined().isScopeContainedBy(ii.getHostScope())) return NopInstr.NOP; } return this; }
public Variable getRenamedSelfVariable(Variable self) { /* Note: evals make all this weird but our heuristics are such that we should not see the same callsite * make a monocall across an eval (within an eval is fine). If we ever cache pre-compiled evals we may * end up breaking here. * * There are two closure types we will see while inlinine. * 1. A closure attached to the call we are inlining or exists within host scope itself. ( .... inline_me { foo } * This will have same self as the host scope itself. * 2. A closure in the method we are inlining. * That will the same self as the inlined methods scope */ if (isClosure) { if (getScopeBeingInlined().getNearestTopLocalVariableScope() == getHostScope()) { return self; } else { return callReceiver; } } else { // method scope return callReceiver; } }
public Variable getRenamedSelfVariable(Variable self) { /* Note: evals make all this weird but our heuristics are such that we should not see the same callsite * make a monocall across an eval (within an eval is fine). If we ever cache pre-compiled evals we may * end up breaking here. * * There are two closure types we will see while inlinine. * 1. A closure attached to the call we are inlining or exists within host scope itself. ( .... inline_me { foo } * This will have same self as the host scope itself. * 2. A closure in the method we are inlining. * That will the same self as the inlined methods scope */ if (isClosure) { if (getScopeBeingInlined().getNearestTopLocalVariableScope() == getHostScope()) { return self; } else { return callReceiver; } } else { // method scope return callReceiver; } }
@Override public Instr clone(CloneInfo info) { if (info instanceof SimpleCloneInfo) return new NonlocalReturnInstr(getReturnValue().cloneForInlining(info), methodName); InlineCloneInfo ii = (InlineCloneInfo) info; if (ii.isClosure()) { if (ii.getHostScope() instanceof IRMethod) { // Lexically contained non-local returns can return directly if the live in the method they are inlining to. if (((InlineCloneInfo) info).getScopeBeingInlined().isScopeContainedBy(ii.getHostScope())) { return new ReturnInstr(getReturnValue().cloneForInlining(ii)); } // Treat like inlining of a regular method-return (note: a jump is added to exit so this copy // actually ends up being the methods return value). Variable v = ii.getCallResultVariable(); return v == null ? null : new CopyInstr(v, getReturnValue().cloneForInlining(ii)); } return new NonlocalReturnInstr(getReturnValue().cloneForInlining(ii), methodName); } else { throw new UnsupportedOperationException("Nonlocal returns shouldn't show up outside closures."); } }
@Override public Instr clone(CloneInfo info) { if (info instanceof SimpleCloneInfo) return new NonlocalReturnInstr(getReturnValue().cloneForInlining(info), methodName); InlineCloneInfo ii = (InlineCloneInfo) info; if (ii.isClosure()) { if (ii.getHostScope() instanceof IRMethod) { // Lexically contained non-local returns can return directly if the live in the method they are inlining to. if (((InlineCloneInfo) info).getScopeBeingInlined().isScopeContainedBy(ii.getHostScope())) { return new ReturnInstr(getReturnValue().cloneForInlining(ii)); } // Treat like inlining of a regular method-return (note: a jump is added to exit so this copy // actually ends up being the methods return value). Variable v = ii.getCallResultVariable(); return v == null ? null : new CopyInstr(v, getReturnValue().cloneForInlining(ii)); } return new NonlocalReturnInstr(getReturnValue().cloneForInlining(ii), methodName); } else { throw new UnsupportedOperationException("Nonlocal returns shouldn't show up outside closures."); } }