@Override public void PopMethodFrameInstr(PopMethodFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postMethodFrameOnly()")); }
@Override public void PushBackrefFrameInstr(PushBackrefFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preBackrefMethod()")); }
@Override public void PopBackrefFrameInstr(PopBackrefFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postBackrefMethod()")); }
@Override public void PopMethodFrameInstr(PopMethodFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postMethodFrameOnly()")); }
@Override public void PopBindingInstr(PopBindingInstr popbindinginstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void popScope()")); }
@Override public void PopBackrefFrameInstr(PopBackrefFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postBackrefMethod()")); }
@Override public void PushBackrefFrameInstr(PushBackrefFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preBackrefMethod()")); }
@Override public void PopBindingInstr(PopBindingInstr popbindinginstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void popScope()")); }
@Override public void BlockGivenInstr(BlockGivenInstr blockGivenInstr) { jvm.method().loadRuntime(); visit(blockGivenInstr.getBlockArg()); jvm.method().invokeVirtual(Type.getType(Block.class), Method.getMethod("boolean isGiven()")); jvm.method().invokeVirtual(Type.getType(Ruby.class), Method.getMethod("org.jruby.RubyBoolean newBoolean(boolean)")); jvmStoreLocal(blockGivenInstr.getResult()); }
@Override public void BlockGivenInstr(BlockGivenInstr blockGivenInstr) { jvm.method().loadRuntime(); visit(blockGivenInstr.getBlockArg()); jvm.method().invokeVirtual(Type.getType(Block.class), Method.getMethod("boolean isGiven()")); jvm.method().invokeVirtual(Type.getType(Ruby.class), Method.getMethod("org.jruby.RubyBoolean newBoolean(boolean)")); jvmStoreLocal(blockGivenInstr.getResult()); }
@Override public void ConstMissingInstr(ConstMissingInstr constmissinginstr) { visit(constmissinginstr.getReceiver()); jvm.method().adapter.checkcast("org/jruby/RubyModule"); jvm.method().loadContext(); jvm.method().adapter.ldc("const_missing"); jvm.method().pushSymbol(constmissinginstr.getMissingConst()); jvm.method().invokeVirtual(Type.getType(RubyModule.class), Method.getMethod("org.jruby.runtime.builtin.IRubyObject callMethod(org.jruby.runtime.ThreadContext, java.lang.String, org.jruby.runtime.builtin.IRubyObject)")); }
@Override public void ConstMissingInstr(ConstMissingInstr constmissinginstr) { visit(constmissinginstr.getReceiver()); jvm.method().adapter.checkcast("org/jruby/RubyModule"); jvm.method().loadContext(); jvm.method().adapter.ldc("const_missing"); jvm.method().pushSymbol(constmissinginstr.getMissingConst()); jvm.method().invokeVirtual(Type.getType(RubyModule.class), Method.getMethod("org.jruby.runtime.builtin.IRubyObject callMethod(org.jruby.runtime.ThreadContext, java.lang.String, org.jruby.runtime.builtin.IRubyObject)")); }
@Override public void BreakInstr(BreakInstr breakInstr) { IRBytecodeAdapter m = jvm.method(); SkinnyMethodAdapter a = m.adapter; m.loadLocal(0); // context a.aload(1); // current scope // FIXME: This can also be done in the helper itself m.invokeVirtual(Type.getType(IRScope.class), Method.getMethod("org.jruby.ir.IRScope getIRScope()")); a.ldc(breakInstr.getScopeToReturnTo().getScopeId()); visit(breakInstr.getReturnValue()); // FIXME: emit block-type for the scope that is currently executing // For now, it is null m.pushNil(); a.invokestatic(p(IRubyObject.class), "initiateBreak", sig(ThreadContext.class, IRScope.class, IRScope.class, IRubyObject.class, Block.Type.class)); }
@Override public void BreakInstr(BreakInstr breakInstr) { IRBytecodeAdapter m = jvm.method(); SkinnyMethodAdapter a = m.adapter; m.loadLocal(0); // context a.aload(1); // current scope // FIXME: This can also be done in the helper itself m.invokeVirtual(Type.getType(IRScope.class), Method.getMethod("org.jruby.ir.IRScope getIRScope()")); a.ldc(breakInstr.getScopeToReturnTo().getScopeId()); visit(breakInstr.getReturnValue()); // FIXME: emit block-type for the scope that is currently executing // For now, it is null m.pushNil(); a.invokestatic(p(IRubyObject.class), "initiateBreak", sig(ThreadContext.class, IRScope.class, IRScope.class, IRubyObject.class, Block.Type.class)); }
@Override public void ConstMissingInstr(ConstMissingInstr constmissinginstr) { visit(constmissinginstr.getReceiver()); jvmAdapter().checkcast("org/jruby/RubyModule"); jvmMethod().loadContext(); jvmAdapter().ldc("const_missing"); jvmMethod().pushSymbol(constmissinginstr.getMissingConst().getBytes()); jvmMethod().invokeVirtual(Type.getType(RubyModule.class), Method.getMethod("org.jruby.runtime.builtin.IRubyObject callMethod(org.jruby.runtime.ThreadContext, java.lang.String, org.jruby.runtime.builtin.IRubyObject)")); jvmStoreLocal(constmissinginstr.getResult()); }
@Override public void ConstMissingInstr(ConstMissingInstr constmissinginstr) { visit(constmissinginstr.getReceiver()); jvmAdapter().checkcast("org/jruby/RubyModule"); jvmMethod().loadContext(); jvmAdapter().ldc("const_missing"); jvmMethod().pushSymbol(constmissinginstr.getMissingConst().getBytes()); jvmMethod().invokeVirtual(Type.getType(RubyModule.class), Method.getMethod("org.jruby.runtime.builtin.IRubyObject callMethod(org.jruby.runtime.ThreadContext, java.lang.String, org.jruby.runtime.builtin.IRubyObject)")); jvmStoreLocal(constmissinginstr.getResult()); }
@Override public void PushMethodFrameInstr(PushMethodFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().loadFrameClass(); jvmMethod().loadFrameName(); jvmMethod().loadSelf(); jvmMethod().loadBlock(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preMethodFrameOnly(org.jruby.RubyModule, String, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.Block)")); // FIXME: this should be part of explicit call protocol only when needed, optimizable, and correct for the scope // See also CompiledIRMethod.call jvmMethod().loadContext(); jvmAdapter().getstatic(p(Visibility.class), pushframeinstr.getVisibility().name(), ci(Visibility.class)); jvmAdapter().invokevirtual(p(ThreadContext.class), "setCurrentVisibility", sig(void.class, Visibility.class)); }
@Override public void PushMethodFrameInstr(PushMethodFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().loadFrameClass(); jvmMethod().loadFrameName(); jvmMethod().loadSelf(); jvmMethod().loadBlock(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preMethodFrameOnly(org.jruby.RubyModule, String, org.jruby.runtime.builtin.IRubyObject, org.jruby.runtime.Block)")); // FIXME: this should be part of explicit call protocol only when needed, optimizable, and correct for the scope // See also CompiledIRMethod.call jvmMethod().loadContext(); jvmAdapter().getstatic(p(Visibility.class), pushframeinstr.getVisibility().name(), ci(Visibility.class)); jvmAdapter().invokevirtual(p(ThreadContext.class), "setCurrentVisibility", sig(void.class, Visibility.class)); }
@Override public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) { IRScope scope = jvm.methodData().scope; if (scope.isScriptScope() && scope.getRootLexicalScope() != null) { // script scope, so we don't push a new scope; instead we push the top-level scope it provides jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("prepareScriptScope", sig(DynamicScope.class, ThreadContext.class, StaticScope.class)); jvmStoreLocal(DYNAMIC_SCOPE); return; } else { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmAdapter().invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class)); jvmAdapter().dup(); jvmStoreLocal(DYNAMIC_SCOPE); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void pushScope(org.jruby.runtime.DynamicScope)")); } }
@Override public void PushMethodBindingInstr(PushMethodBindingInstr pushbindinginstr) { IRScope scope = jvm.methodData().scope; if (scope.isScriptScope() && scope.getRootLexicalScope() != null) { // script scope, so we don't push a new scope; instead we push the top-level scope it provides jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmMethod().invokeIRHelper("prepareScriptScope", sig(DynamicScope.class, ThreadContext.class, StaticScope.class)); jvmStoreLocal(DYNAMIC_SCOPE); return; } else { jvmMethod().loadContext(); jvmMethod().loadStaticScope(); jvmAdapter().invokestatic(p(DynamicScope.class), "newDynamicScope", sig(DynamicScope.class, StaticScope.class)); jvmAdapter().dup(); jvmStoreLocal(DYNAMIC_SCOPE); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void pushScope(org.jruby.runtime.DynamicScope)")); } }