@Override public void Self(Self self) { jvmMethod().loadSelf(); }
@Override public void UpdateBlockExecutionStateInstr (UpdateBlockExecutionStateInstr instr) { jvmMethod().loadSelfBlock(); jvmMethod().loadSelf(); jvmMethod().invokeIRHelper("updateBlockState", sig(IRubyObject.class, Block.class, IRubyObject.class)); jvmMethod().storeSelf(); }
@Override public void Self(Self self) { jvmMethod().loadSelf(); }
@Override public void UpdateBlockExecutionStateInstr (UpdateBlockExecutionStateInstr instr) { jvmMethod().loadSelfBlock(); jvmMethod().loadSelf(); jvmMethod().invokeIRHelper("updateBlockState", sig(IRubyObject.class, Block.class, IRubyObject.class)); jvmMethod().storeSelf(); }
@Override public void AliasInstr(AliasInstr aliasInstr) { IRBytecodeAdapter m = jvm.method(); m.loadContext(); m.loadSelf(); jvmLoadLocal(DYNAMIC_SCOPE); visit(aliasInstr.getNewName()); visit(aliasInstr.getOldName()); m.invokeIRHelper("defineAlias", sig(void.class, ThreadContext.class, IRubyObject.class, DynamicScope.class, IRubyObject.class, IRubyObject.class)); }
@Override public void AliasInstr(AliasInstr aliasInstr) { IRBytecodeAdapter m = jvm.method(); m.loadContext(); m.loadSelf(); jvmLoadLocal(DYNAMIC_SCOPE); visit(aliasInstr.getNewName()); visit(aliasInstr.getOldName()); m.invokeIRHelper("defineAlias", sig(void.class, ThreadContext.class, IRubyObject.class, DynamicScope.class, IRubyObject.class, IRubyObject.class)); }
public void oneFixnumArgNoBlockCallInstr(OneFixnumArgNoBlockCallInstr oneFixnumArgNoBlockCallInstr) { IRBytecodeAdapter m = jvmMethod(); long fixnum = oneFixnumArgNoBlockCallInstr.getFixnumArg(); Operand receiver = oneFixnumArgNoBlockCallInstr.getReceiver(); Variable result = oneFixnumArgNoBlockCallInstr.getResult(); m.loadContext(); // for visibility checking without requiring frame self // TODO: don't bother passing when fcall or vcall, and adjust callsite appropriately m.loadSelf(); // caller visit(receiver); m.invokeOtherOneFixnum(file, lastLine, oneFixnumArgNoBlockCallInstr, fixnum); if (result != null) { jvmStoreLocal(result); } else { // still need to drop, since all dyncalls return something (FIXME) m.adapter.pop(); } }
@Override public void ArrayDerefInstr(ArrayDerefInstr arrayderefinstr) { jvmMethod().loadContext(); jvmMethod().loadSelf(); visit(arrayderefinstr.getReceiver()); visit(arrayderefinstr.getKey()); jvmMethod().invokeArrayDeref(file, lastLine, arrayderefinstr); jvmStoreLocal(arrayderefinstr.getResult()); }
@Override public void UndefMethodInstr(UndefMethodInstr undefmethodinstr) { jvmMethod().loadContext(); visit(undefmethodinstr.getMethodName()); jvmLoadLocal(DYNAMIC_SCOPE); jvmMethod().loadSelf(); jvmMethod().invokeIRHelper("undefMethod", sig(IRubyObject.class, ThreadContext.class, Object.class, DynamicScope.class, IRubyObject.class)); jvmStoreLocal(undefmethodinstr.getResult()); }
@Override public void ArrayDerefInstr(ArrayDerefInstr arrayderefinstr) { jvmMethod().loadContext(); jvmMethod().loadSelf(); visit(arrayderefinstr.getReceiver()); visit(arrayderefinstr.getKey()); jvmMethod().invokeArrayDeref(file, lastLine, arrayderefinstr); jvmStoreLocal(arrayderefinstr.getResult()); }
@Override public void UndefMethodInstr(UndefMethodInstr undefmethodinstr) { jvmMethod().loadContext(); visit(undefmethodinstr.getMethodName()); jvmLoadLocal(DYNAMIC_SCOPE); jvmMethod().loadSelf(); jvmMethod().invokeIRHelper("undefMethod", sig(IRubyObject.class, ThreadContext.class, Object.class, DynamicScope.class, IRubyObject.class)); jvmStoreLocal(undefmethodinstr.getResult()); }
public void oneFixnumArgNoBlockCallInstr(OneFixnumArgNoBlockCallInstr oneFixnumArgNoBlockCallInstr) { IRBytecodeAdapter m = jvmMethod(); long fixnum = oneFixnumArgNoBlockCallInstr.getFixnumArg(); Operand receiver = oneFixnumArgNoBlockCallInstr.getReceiver(); Variable result = oneFixnumArgNoBlockCallInstr.getResult(); m.loadContext(); // for visibility checking without requiring frame self // TODO: don't bother passing when fcall or vcall, and adjust callsite appropriately m.loadSelf(); // caller visit(receiver); m.invokeOtherOneFixnum(file, lastLine, oneFixnumArgNoBlockCallInstr, fixnum); if (result != null) { jvmStoreLocal(result); } else { // still need to drop, since all dyncalls return something (FIXME) m.adapter.pop(); } }
public void oneFloatArgNoBlockCallInstr(OneFloatArgNoBlockCallInstr oneFloatArgNoBlockCallInstr) { IRBytecodeAdapter m = jvmMethod(); String name = oneFloatArgNoBlockCallInstr.getId(); double flote = oneFloatArgNoBlockCallInstr.getFloatArg(); Operand receiver = oneFloatArgNoBlockCallInstr.getReceiver(); Variable result = oneFloatArgNoBlockCallInstr.getResult(); m.loadContext(); // for visibility checking without requiring frame self // TODO: don't bother passing when fcall or vcall, and adjust callsite appropriately m.loadSelf(); // caller visit(receiver); m.invokeOtherOneFloat(file, lastLine, oneFloatArgNoBlockCallInstr, flote); if (result != null) { jvmStoreLocal(result); } else { // still need to drop, since all dyncalls return something (FIXME) m.adapter.pop(); } }
public void oneFloatArgNoBlockCallInstr(OneFloatArgNoBlockCallInstr oneFloatArgNoBlockCallInstr) { IRBytecodeAdapter m = jvmMethod(); String name = oneFloatArgNoBlockCallInstr.getId(); double flote = oneFloatArgNoBlockCallInstr.getFloatArg(); Operand receiver = oneFloatArgNoBlockCallInstr.getReceiver(); Variable result = oneFloatArgNoBlockCallInstr.getResult(); m.loadContext(); // for visibility checking without requiring frame self // TODO: don't bother passing when fcall or vcall, and adjust callsite appropriately m.loadSelf(); // caller visit(receiver); m.invokeOtherOneFloat(file, lastLine, oneFloatArgNoBlockCallInstr, flote); if (result != null) { jvmStoreLocal(result); } else { // still need to drop, since all dyncalls return something (FIXME) m.adapter.pop(); } }
@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 DefineInstanceMethodInstr(DefineInstanceMethodInstr defineinstancemethodinstr) { IRMethod method = defineinstancemethodinstr.getMethod(); JVMVisitorMethodContext context = new JVMVisitorMethodContext(); IRBytecodeAdapter m = jvmMethod(); SkinnyMethodAdapter a = m.adapter; m.loadContext(); emitMethod(method, context); MethodType variable = context.getNativeSignature(-1); // always a variable arity handle assert(variable != null); String defSignature = pushHandlesForDef( context.getVariableName(), context.getSpecificName(), context.getNativeSignaturesExceptVariable(), variable, sig(void.class, ThreadContext.class, java.lang.invoke.MethodHandle.class, IRScope.class, DynamicScope.class, IRubyObject.class), sig(void.class, ThreadContext.class, java.lang.invoke.MethodHandle.class, java.lang.invoke.MethodHandle.class, int.class, IRScope.class, DynamicScope.class, IRubyObject.class)); a.getstatic(jvm.clsData().clsName, context.getBaseName() + "_IRScope", ci(IRScope.class)); jvmLoadLocal(DYNAMIC_SCOPE); jvmMethod().loadSelf(); // add method a.invokestatic(p(IRRuntimeHelpers.class), "defCompiledInstanceMethod", defSignature); }
@Override public void DefineInstanceMethodInstr(DefineInstanceMethodInstr defineinstancemethodinstr) { IRMethod method = defineinstancemethodinstr.getMethod(); JVMVisitorMethodContext context = new JVMVisitorMethodContext(); IRBytecodeAdapter m = jvmMethod(); SkinnyMethodAdapter a = m.adapter; m.loadContext(); emitMethod(method, context); MethodType variable = context.getNativeSignature(-1); // always a variable arity handle assert(variable != null); String defSignature = pushHandlesForDef( context.getVariableName(), context.getSpecificName(), context.getNativeSignaturesExceptVariable(), variable, sig(void.class, ThreadContext.class, java.lang.invoke.MethodHandle.class, IRScope.class, DynamicScope.class, IRubyObject.class), sig(void.class, ThreadContext.class, java.lang.invoke.MethodHandle.class, java.lang.invoke.MethodHandle.class, int.class, IRScope.class, DynamicScope.class, IRubyObject.class)); a.getstatic(jvm.clsData().clsName, context.getBaseName() + "_IRScope", ci(IRScope.class)); jvmLoadLocal(DYNAMIC_SCOPE); jvmMethod().loadSelf(); // add method a.invokestatic(p(IRRuntimeHelpers.class), "defCompiledInstanceMethod", defSignature); }
@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)); }
protected void emitVarargsMethodWrapper(IRScope scope, String variableName, String specificName, Signature variableSignature, Signature specificSignature) { jvm.pushmethod(variableName, scope, variableSignature, false); IRBytecodeAdapter m = jvmMethod(); // check arity org.jruby.runtime.Signature scopeSig = scope.getStaticScope().getSignature(); checkArity(scopeSig.required(), scopeSig.opt(), scopeSig.hasRest(), scopeSig.hasKwargs(), scopeSig.keyRest()); // push leading args m.loadContext(); m.loadStaticScope(); m.loadSelf(); // unwrap specific args if (scopeSig.required() > 0) { for (int i = 0; i < scopeSig.required(); i++) { m.loadArgs(); jvmAdapter().pushInt(i); jvmAdapter().aaload(); } } // push trailing args m.loadBlock(); m.loadFrameClass(); m.loadFrameName(); // invoke specific-arity version and return Method specificMethod = new Method(specificName, Type.getType(specificSignature.type().returnType()), IRRuntimeHelpers.typesFromSignature(specificSignature)); jvmAdapter().invokestatic(m.getClassData().clsName, specificName, specificMethod.getDescriptor()); jvmAdapter().areturn(); jvm.popmethod(); }
protected void emitVarargsMethodWrapper(IRScope scope, String variableName, String specificName, Signature variableSignature, Signature specificSignature) { jvm.pushmethod(variableName, scope, variableSignature, false); IRBytecodeAdapter m = jvmMethod(); // check arity org.jruby.runtime.Signature scopeSig = scope.getStaticScope().getSignature(); checkArity(scopeSig.required(), scopeSig.opt(), scopeSig.hasRest(), scopeSig.hasKwargs(), scopeSig.keyRest()); // push leading args m.loadContext(); m.loadStaticScope(); m.loadSelf(); // unwrap specific args if (scopeSig.required() > 0) { for (int i = 0; i < scopeSig.required(); i++) { m.loadArgs(); jvmAdapter().pushInt(i); jvmAdapter().aaload(); } } // push trailing args m.loadBlock(); m.loadFrameClass(); m.loadFrameName(); // invoke specific-arity version and return Method specificMethod = new Method(specificName, Type.getType(specificSignature.type().returnType()), IRRuntimeHelpers.typesFromSignature(specificSignature)); jvmAdapter().invokestatic(m.getClassData().clsName, specificName, specificMethod.getDescriptor()); jvmAdapter().areturn(); jvm.popmethod(); }