@Override public void CheckArityInstr(CheckArityInstr checkarityinstr) { if (jvm.methodData().specificArity >= 0) { // no arity check in specific arity path } else { checkArity(checkarityinstr.required, checkarityinstr.opt, checkarityinstr.rest, checkarityinstr.receivesKeywords, checkarityinstr.restKey); } }
@Override public void CheckArityInstr(CheckArityInstr checkarityinstr) { if (jvm.methodData().specificArity >= 0) { // no arity check in specific arity path } else { checkArity(checkarityinstr.required, checkarityinstr.opt, checkarityinstr.rest, checkarityinstr.receivesKeywords, checkarityinstr.restKey); } }
private int getJVMLocalVarIndex(Variable variable) { return jvm.methodData().local(variable); }
private int getJVMLocalVarIndex(Variable variable) { if (variable instanceof TemporaryLocalVariable) { switch (((TemporaryLocalVariable)variable).getType()) { case FLOAT: return jvm.methodData().local(variable, JVM.DOUBLE_TYPE); case FIXNUM: return jvm.methodData().local(variable, JVM.LONG_TYPE); case BOOLEAN: return jvm.methodData().local(variable, JVM.BOOLEAN_TYPE); default: return jvm.methodData().local(variable); } } else { return jvm.methodData().local(variable); } }
private int getJVMLocalVarIndex(Variable variable) { if (variable instanceof TemporaryLocalVariable) { switch (((TemporaryLocalVariable)variable).getType()) { case FLOAT: return jvm.methodData().local(variable, JVM.DOUBLE_TYPE); case FIXNUM: return jvm.methodData().local(variable, JVM.LONG_TYPE); case BOOLEAN: return jvm.methodData().local(variable, JVM.BOOLEAN_TYPE); default: return jvm.methodData().local(variable); } } else { return jvm.methodData().local(variable); } }
@Override public void ReceivePreReqdArgInstr(ReceivePreReqdArgInstr instr) { if (jvm.methodData().specificArity >= 0 && instr.getArgIndex() < jvm.methodData().specificArity) { jvmAdapter().aload(jvm.methodData().signature.argOffset("arg" + instr.getArgIndex())); } else { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.getArgIndex()); jvmMethod().invokeIRHelper("getPreArgSafe", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class)); } jvmStoreLocal(instr.getResult()); }
@Override public void PushBlockBindingInstr(PushBlockBindingInstr instr) { IRScope scope = jvm.methodData().scope; // FIXME: Centralize this out of InterpreterContext boolean reuseParentDynScope = scope.getExecutionContext().getFlags().contains(IRFlags.REUSE_PARENT_DYNSCOPE); boolean pushNewDynScope = !scope.getExecutionContext().getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED) && !reuseParentDynScope; jvmMethod().loadContext(); jvmMethod().loadSelfBlock(); jvmAdapter().ldc(pushNewDynScope); jvmAdapter().ldc(reuseParentDynScope); jvmMethod().invokeIRHelper("pushBlockDynamicScopeIfNeeded", sig(DynamicScope.class, ThreadContext.class, Block.class, boolean.class, boolean.class)); jvmStoreLocal(DYNAMIC_SCOPE); }
@Override public void PushBlockBindingInstr(PushBlockBindingInstr instr) { IRScope scope = jvm.methodData().scope; // FIXME: Centralize this out of InterpreterContext boolean reuseParentDynScope = scope.getExecutionContext().getFlags().contains(IRFlags.REUSE_PARENT_DYNSCOPE); boolean pushNewDynScope = !scope.getExecutionContext().getFlags().contains(IRFlags.DYNSCOPE_ELIMINATED) && !reuseParentDynScope; jvmMethod().loadContext(); jvmMethod().loadSelfBlock(); jvmAdapter().ldc(pushNewDynScope); jvmAdapter().ldc(reuseParentDynScope); jvmMethod().invokeIRHelper("pushBlockDynamicScopeIfNeeded", sig(DynamicScope.class, ThreadContext.class, Block.class, boolean.class, boolean.class)); jvmStoreLocal(DYNAMIC_SCOPE); }
@Override public void PrepareBlockArgsInstr(PrepareBlockArgsInstr instr) { jvmMethod().loadContext(); jvmMethod().loadSelfBlock(); jvmMethod().loadArgs(); jvmAdapter().ldc(((IRClosure)jvm.methodData().scope).receivesKeywordArgs()); jvmMethod().invokeIRHelper("prepareBlockArgs", sig(IRubyObject[].class, ThreadContext.class, Block.class, IRubyObject[].class, boolean.class)); jvmMethod().storeArgs(); }
@Override public void PrepareBlockArgsInstr(PrepareBlockArgsInstr instr) { jvmMethod().loadContext(); jvmMethod().loadSelfBlock(); jvmMethod().loadArgs(); jvmAdapter().ldc(((IRClosure)jvm.methodData().scope).receivesKeywordArgs()); jvmMethod().invokeIRHelper("prepareBlockArgs", sig(IRubyObject[].class, ThreadContext.class, Block.class, IRubyObject[].class, boolean.class)); jvmMethod().storeArgs(); }
@Override public void ReceiveKeywordRestArgInstr(ReceiveKeywordRestArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.required); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveKeywordRestArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveKeywordRestArgInstr(ReceiveKeywordRestArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.required); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveKeywordRestArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveKeywordArgInstr(ReceiveKeywordArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.required); jvmAdapter().ldc(instr.getId()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveKeywordArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, String.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveRestArgInstr(ReceiveRestArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.required); jvmAdapter().pushInt(instr.getArgIndex()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveRestArg", sig(IRubyObject.class, ThreadContext.class, Object[].class, int.class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveRestArgInstr(ReceiveRestArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.required); jvmAdapter().pushInt(instr.getArgIndex()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveRestArg", sig(IRubyObject.class, ThreadContext.class, Object[].class, int.class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveKeywordArgInstr(ReceiveKeywordArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.required); jvmAdapter().ldc(instr.getId()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveKeywordArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, String.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveOptArgInstr(ReceiveOptArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.requiredArgs); jvmAdapter().pushInt(instr.preArgs); jvmAdapter().pushInt(instr.getArgIndex()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveOptArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, int.class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceiveOptArgInstr(ReceiveOptArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.requiredArgs); jvmAdapter().pushInt(instr.preArgs); jvmAdapter().pushInt(instr.getArgIndex()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receiveOptArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, int.class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceivePostReqdArgInstr(ReceivePostReqdArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.preReqdArgsCount); jvmAdapter().pushInt(instr.optArgsCount); jvmAdapter().pushBoolean(instr.restArg); jvmAdapter().pushInt(instr.postReqdArgsCount); jvmAdapter().pushInt(instr.getArgIndex()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receivePostReqdArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, int.class, boolean.class, int.class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }
@Override public void ReceivePostReqdArgInstr(ReceivePostReqdArgInstr instr) { jvmMethod().loadContext(); jvmMethod().loadArgs(); jvmAdapter().pushInt(instr.preReqdArgsCount); jvmAdapter().pushInt(instr.optArgsCount); jvmAdapter().pushBoolean(instr.restArg); jvmAdapter().pushInt(instr.postReqdArgsCount); jvmAdapter().pushInt(instr.getArgIndex()); jvmAdapter().ldc(jvm.methodData().scope.receivesKeywordArgs()); jvmMethod().invokeIRHelper("receivePostReqdArg", sig(IRubyObject.class, ThreadContext.class, IRubyObject[].class, int.class, int.class, boolean.class, int.class, int.class, boolean.class)); jvmStoreLocal(instr.getResult()); }