@Override public DynamicMethod dup() { return new HandleMethod(implementationClass, visibility, callConfig, targets, parameterDesc); }
public MethodHandle getHandle(int arity) { switch (arity) { case -1: return ensureTarget4(); case 0: return ensureTarget0(); case 1: return ensureTarget1(); case 2: return ensureTarget2(); case 3: return ensureTarget3(); default: return null; } }
@Override public DynamicMethod dup() { return new HandleMethod(implementationClass, getVisibility(), name, signature.encode(), builtin, notImplemented, parameterDesc, min, max, maker0, maker1, maker2, maker3, maker4); }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { if (target0 == null) { return call(context, self, clazz, name, IRubyObject.NULL_ARRAY, block); } try { return (IRubyObject) target0.invokeWithArguments(context, self, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) { MethodHandle target2 = ensureTarget2(); if (target2 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0, arg1}, block); } try { return (IRubyObject) target2.invokeExact(context, self, clazz, name, arg0, arg1, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { MethodHandle target0 = ensureTarget0(); if (target0 == null) { return call(context, self, clazz, name, IRubyObject.NULL_ARRAY, block); } try { return (IRubyObject) target0.invokeExact(context, self, clazz, name, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { MethodHandle target1 = ensureTarget1(); if (target1 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0}, block); } try { return (IRubyObject) target1.invokeExact(context, self, clazz, name, arg0, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { MethodHandle target3 = ensureTarget3(); if (target3 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0, arg1, arg2}, block); } try { return (IRubyObject) target3.invokeExact(context, self, clazz, name, arg0, arg1, arg2, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { MethodHandle handle = ((HandleMethod)method).getHandle(site.arity()); if (handle == null) { throw new IndirectBindingException("MH dynamic method does not have needed arity"); } if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound from MHDynMethod " + logMethod(method) + ":" + handle); Signature fullSig = site.fullSignature(); MethodHandle nativeTarget = Binder .from(fullSig.type()) .permute(fullSig.to("context", "self", "arg*", "block")) .invoke(handle); nativeTarget = addOrRemoveBlock(site, nativeTarget); return nativeTarget; } }
private MethodHandle ensureTarget0() { if (!initialized0) { this.target0 = safeCall(maker0); initialized0 = true; maker0 = null; } return this.target0; }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { if (target1 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0}, block); } try { return (IRubyObject) target1.invokeWithArguments(context, self, arg0, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) { MethodHandle target2 = ensureTarget2(); if (target2 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0, arg1}, block); } try { return (IRubyObject) target2.invokeExact(context, self, clazz, name, arg0, arg1, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, Block block) { MethodHandle target0 = ensureTarget0(); if (target0 == null) { return call(context, self, clazz, name, IRubyObject.NULL_ARRAY, block); } try { return (IRubyObject) target0.invokeExact(context, self, clazz, name, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, Block block) { MethodHandle target1 = ensureTarget1(); if (target1 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0}, block); } try { return (IRubyObject) target1.invokeExact(context, self, clazz, name, arg0, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) { MethodHandle target3 = ensureTarget3(); if (target3 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0, arg1, arg2}, block); } try { return (IRubyObject) target3.invokeExact(context, self, clazz, name, arg0, arg1, arg2, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { MethodHandle handle = ((HandleMethod)method).getHandle(site.arity()); if (handle == null) { throw new IndirectBindingException("MH dynamic method does not have needed arity"); } if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound from MHDynMethod " + logMethod(method) + ":" + handle); Signature fullSig = site.fullSignature(); MethodHandle nativeTarget = Binder .from(fullSig.type()) .permute(fullSig.to("context", "self", "arg*", "block")) .invoke(handle); nativeTarget = addOrRemoveBlock(site, nativeTarget); return nativeTarget; } }
private MethodHandle ensureTarget3() { if (!initialized3) { this.target3 = safeCall(maker3); initialized3 = true; maker3 = null; } return this.target3; }
public MethodHandle getHandle(int arity) { switch (arity) { case -1: return ensureTarget4(); case 0: return ensureTarget0(); case 1: return ensureTarget1(); case 2: return ensureTarget2(); case 3: return ensureTarget3(); default: return null; } }
@Override public IRubyObject call(ThreadContext context, IRubyObject self, RubyModule clazz, String name, IRubyObject arg0, IRubyObject arg1, Block block) { if (target2 == null) { return call(context, self, clazz, name, new IRubyObject[]{arg0, arg1}, block); } try { return (IRubyObject) target2.invokeWithArguments(context, self, arg0, arg1, block); } catch (Throwable t) { Helpers.throwException(t); return null; } }
@Override public DynamicMethod dup() { return new HandleMethod(implementationClass, visibility, callConfig, targets, parameterDesc); }