@Override public boolean canGenerate(JRubyCallSite site, RubyClass cls, DynamicMethod method) { NativeCall nativeCall = method.getNativeCall(); if (nativeCall != null) { // has an explicit native call path if (nativeCall.isJava()) { if (!RubyInstanceConfig.INVOKEDYNAMIC_JAVA) { throw new IndirectBindingException("direct Java dispatch not enabled"); } // if Java, must: // * match arity <= 3 // * not be passed a block (no coercion yet) // * be a normal wrapper around a class or module (not a Ruby subclass) if (nativeCall.getNativeSignature().length != site.arity() || site.arity() > 3 || site.isIterator() || !cls.getJavaProxy()) { throw new IndirectBindingException("Java call arity mismatch or > 3 args"); } return true; } } return false; }
@Override public boolean canGenerate(JRubyCallSite site, RubyClass cls, DynamicMethod method) { NativeCall nativeCall = method.getNativeCall(); if (nativeCall != null) { // has an explicit native call path if (nativeCall.isJava()) { if (!RubyInstanceConfig.INVOKEDYNAMIC_JAVA) { throw new IndirectBindingException("direct Java dispatch not enabled"); } // if Java, must: // * match arity <= 3 // * not be passed a block (no coercion yet) // * be a normal wrapper around a class or module (not a Ruby subclass) if (nativeCall.getNativeSignature().length != site.arity() || site.arity() > 3 || site.isIterator() || !cls.getJavaProxy()) { throw new IndirectBindingException("Java call arity mismatch or > 3 args"); } return true; } } return false; }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject[] args, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, args, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, -1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 4); return (IRubyObject) target.invokeWithArguments(context, caller, self, args, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, arg0, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 1); return (IRubyObject) target.invokeWithArguments(context, caller, self, arg0, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 0); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 0); return (IRubyObject) target.invokeWithArguments(context, caller, self, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, arg0, arg1, arg2, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 3); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 3); return (IRubyObject) target.invokeWithArguments(context, caller, self, arg0, arg1, arg2, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, arg0, arg1, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 2); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 2); return (IRubyObject) target.invokeWithArguments(context, caller, self, arg0, arg1, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, arg0, arg1, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 2); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 2); return (IRubyObject) target.invokeWithArguments(context, caller, self, arg0, arg1, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 0); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 0); return (IRubyObject) target.invokeWithArguments(context, caller, self, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, arg0, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 1); return (IRubyObject) target.invokeWithArguments(context, caller, self, arg0, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, arg0, arg1, arg2, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, 3); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 3); return (IRubyObject) target.invokeWithArguments(context, caller, self, arg0, arg1, arg2, block); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject[] args, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String method = site.name(); SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(method); if (methodMissing(entry, site.callType(), method, caller)) { try { return callMethodMissing(entry, site.callType(), context, self, method, args, block); } catch (JumpException.BreakJump bj) { return handleBreakJump(context, bj); } catch (JumpException.RetryJump rj) { return retryJumpError(context); } finally { if (site.isIterator()) block.escape(); } } MethodHandle target = getTarget(site, selfClass, entry, -1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, true, 4); return (IRubyObject) target.invokeWithArguments(context, caller, self, args, block); }
private static MethodHandle postProcess(JRubyCallSite site, MethodHandle target) { if (site.isIterator()) {
private static MethodHandle postProcess(JRubyCallSite site, MethodHandle target) { if (site.isIterator()) {