public void pushmethod(String name, int arity) { Method m; switch (arity) { case 0: case 1: case 2: case 3: m = new Method(name, JVM.OBJECT_TYPE, ARGS[arity]); break; default: throw new RuntimeException("Unsupported arity " + arity + " for " + name); } methodStack.push(new MethodData(new SkinnyMethodAdapter(cls, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, m.getName(), m.getDescriptor(), null, null), arity)); }
public void invokeVirtual(Type type, Method method) { adapter.invokevirtual(type.getInternalName(), method.getName(), method.getDescriptor()); }
Type[] ex = toType(md.getExceptions()); String field_name = "__mth$" + md.getName() + md.scrambledSignature(); clazzInit.push(m.getName()); clazzInit.push(m.getDescriptor()); clazzInit.push(md.isImplemented()); clazzInit.invokeStatic(PROXY_HELPER_TYPE, PROXY_HELPER_GET_METHOD); clazzInit.putStatic(selfType, field_name, PROXY_METHOD_TYPE); org.objectweb.asm.commons.Method sm = new org.objectweb.asm.commons.Method( "__super$" + m.getName(), m.getReturnType(), m .getArgumentTypes()); ga.getStatic(selfType, field_name, PROXY_METHOD_TYPE); if (m.getArgumentTypes().length == 0) { ga.unbox(m.getReturnType()); ga.returnValue(); ga.loadLocal(loc, thr); ga.invokeConstructor(udt, org.objectweb.asm.commons.Method .getMethod("void <init>(java.lang.Throwable)")); ga.throwException();
@Override public void PopMethodFrameInstr(PopMethodFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postMethodFrameOnly()")); }
private void generateGetProxyClass(Type selfType, ClassVisitor cw) { // make getter for proxy class GeneratorAdapter gpc = new GeneratorAdapter(Opcodes.ACC_PUBLIC, new org.objectweb.asm.commons.Method("___getProxyClass", PROXY_CLASS_TYPE, EMPTY_TYPE_ARR), null, EMPTY_TYPE_ARR, cw); gpc.getStatic(selfType, PROXY_CLASS_FIELD_NAME, PROXY_CLASS_TYPE); gpc.returnValue(); gpc.endMethod(); }
qualifiedName.toString().replace('.', '/'), method.getSimpleName().toString(), Method.getMethod(buffer.toString()).getDescriptor(), false); Method handleInit = Method.getMethod("void foo(org.jruby.RubyModule, org.jruby.runtime.Visibility, java.lang.String, long, boolean, boolean, java.lang.String, int, int, java.util.concurrent.Callable, java.util.concurrent.Callable, java.util.concurrent.Callable, java.util.concurrent.Callable, java.util.concurrent.Callable)"); mv.invokespecial("org/jruby/internal/runtime/methods/HandleMethod", "<init>", handleInit.getDescriptor());
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(); }
Type[] ex = toType(md.getExceptions()); String field_name = "__mth$" + md.getName() + md.scrambledSignature(); clazzInit.push(m.getName()); clazzInit.push(m.getDescriptor()); clazzInit.push(md.isImplemented()); clazzInit.invokeStatic(PROXY_HELPER_TYPE, PROXY_HELPER_GET_METHOD); clazzInit.putStatic(selfType, field_name, PROXY_METHOD_TYPE); org.objectweb.asm.commons.Method sm = new org.objectweb.asm.commons.Method( "__super$" + m.getName(), m.getReturnType(), m .getArgumentTypes()); ga.getStatic(selfType, field_name, PROXY_METHOD_TYPE); if (m.getArgumentTypes().length == 0) { ga.unbox(m.getReturnType()); ga.returnValue(); ga.loadLocal(loc, thr); ga.invokeConstructor(udt, org.objectweb.asm.commons.Method .getMethod("void <init>(java.lang.Throwable)")); ga.throwException();
public void invokeVirtual(Type type, Method method) { adapter.invokevirtual(type.getInternalName(), method.getName(), method.getDescriptor()); }
@Override public void PushBackrefFrameInstr(PushBackrefFrameInstr pushframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void preBackrefMethod()")); }
private void generateGetProxyClass(Type selfType, ClassVisitor cw) { // make getter for proxy class GeneratorAdapter gpc = new GeneratorAdapter(Opcodes.ACC_PUBLIC, new org.objectweb.asm.commons.Method("___getProxyClass", PROXY_CLASS_TYPE, EMPTY_TYPE_ARR), null, EMPTY_TYPE_ARR, cw); gpc.getStatic(selfType, PROXY_CLASS_FIELD_NAME, PROXY_CLASS_TYPE); gpc.returnValue(); gpc.endMethod(); }
qualifiedName.toString().replace('.', '/'), method.getSimpleName().toString(), Method.getMethod(buffer.toString()).getDescriptor(), false); Method handleInit = Method.getMethod("void foo(org.jruby.RubyModule, org.jruby.runtime.Visibility, java.lang.String, long, boolean, boolean, java.lang.String, int, int, java.util.concurrent.Callable, java.util.concurrent.Callable, java.util.concurrent.Callable, java.util.concurrent.Callable, java.util.concurrent.Callable)"); mv.invokespecial("org/jruby/internal/runtime/methods/HandleMethod", "<init>", handleInit.getDescriptor());
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(); }
clazzInit.push(m.getName()); clazzInit.push(m.getDescriptor()); clazzInit.push(md.isImplemented()); org.objectweb.asm.commons.Method sm = new org.objectweb.asm.commons.Method( "__super$" + m.getName(), m.getReturnType(), m.getArgumentTypes() ); ga.getStatic(selfType, field_name, PROXY_METHOD_TYPE); if (m.getArgumentTypes().length == 0) { ga.unbox(m.getReturnType()); ga.returnValue(); ga.dup(); ga.loadLocal(loc, thr); ga.invokeConstructor(udt, org.objectweb.asm.commons.Method.getMethod("void <init>(java.lang.Throwable)")); ga.throwException();
public void pushmethod(String name, int arity) { Method m; switch (arity) { case 0: case 1: case 2: case 3: m = new Method(name, JVM.OBJECT_TYPE, ARGS[arity]); break; default: throw new RuntimeException("Unsupported arity " + arity + " for " + name); } methodStack.push(new MethodData(new SkinnyMethodAdapter(cls, Opcodes.ACC_PUBLIC | Opcodes.ACC_STATIC, m.getName(), m.getDescriptor(), null, null), arity)); }
public void invokeStatic(Type type, Method method) { adapter.invokestatic(type.getInternalName(), method.getName(), method.getDescriptor()); }
@Override public void PopBackrefFrameInstr(PopBackrefFrameInstr popframeinstr) { jvmMethod().loadContext(); jvmMethod().invokeVirtual(Type.getType(ThreadContext.class), Method.getMethod("void postBackrefMethod()")); }
/** * @see InternalJavaProxy */ private static void generate___getProxyClass(Type selfType, ClassVisitor cw) { // public JavaProxyClass __getProxyClass() { return /* static */ __proxy_class; } // make getter for proxy class (due implements InternalJavaProxy) GeneratorAdapter gpc = new GeneratorAdapter(Opcodes.ACC_PUBLIC, new org.objectweb.asm.commons.Method("___getProxyClass", PROXY_CLASS_TYPE, EMPTY_TYPE_ARRAY), null, EMPTY_TYPE_ARRAY, cw); gpc.getStatic(selfType, PROXY_CLASS_FIELD_NAME, PROXY_CLASS_TYPE); gpc.returnValue(); gpc.endMethod(); }
public void adaptHandle(ExecutableElementDescriptor executableElementDescriptor, int implClass) { ExecutableElementDescriptor desc = executableElementDescriptor; // adapt handle mv.aload(RUNTIME); mv.ldc(calculateActualRequired(desc.method, desc.method.getParameters().size(), desc.optional, desc.rest, desc.isStatic, desc.hasContext, desc.hasBlock)); mv.ldc(desc.required); mv.ldc(desc.optional); mv.ldc(desc.rest); mv.ldc(desc.rubyName); mv.ldc(Type.getObjectType(desc.declaringClassPath)); mv.ldc(desc.isStatic); mv.ldc(desc.hasContext); mv.ldc(desc.hasBlock); mv.ldc(desc.anno.frame()); mv.aload(implClass); mv.invokestatic("org/jruby/internal/runtime/methods/InvokeDynamicMethodFactory", "adaptHandle", Method.getMethod("java.util.concurrent.Callable adaptHandle(java.lang.invoke.MethodHandle, org.jruby.Ruby, int, int, int, boolean, java.lang.String, java.lang.Class, boolean, boolean, boolean, boolean, org.jruby.RubyModule)").getDescriptor()); }
clazzInit.push(m.getName()); clazzInit.push(m.getDescriptor()); clazzInit.push(md.isImplemented()); org.objectweb.asm.commons.Method sm = new org.objectweb.asm.commons.Method( "__super$" + m.getName(), m.getReturnType(), m.getArgumentTypes() ); ga.getStatic(selfType, field_name, PROXY_METHOD_TYPE); if (m.getArgumentTypes().length == 0) { ga.unbox(m.getReturnType()); ga.returnValue(); ga.dup(); ga.loadLocal(loc, thr); ga.invokeConstructor(udt, org.objectweb.asm.commons.Method.getMethod("void <init>(java.lang.Throwable)")); ga.throwException();