@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { // Ruby to Ruby if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound to Ruby method " + logMethod(method) + ": " + method.getNativeCall()); return postProcessNativeHandle(createRubyHandle(site, method, realName), site, method, true, false); }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { // Ruby to Ruby if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound to Ruby method " + logMethod(method) + ": " + method.getNativeCall()); return postProcessNativeHandle(createRubyHandle(site, method, realName), site, method, true, false); }
private static MethodHandle tryDispatchDirect(JRubyCallSite site, RubyClass cls, DynamicMethod method) { String[] realName = {site.name()}; method = unwrapMethod(method, realName); for (HandleGenerator generator : HANDLE_GENERATORS) { if (generator.canGenerate(site, cls, method)) { return generator.generate(site, cls, method, realName[0]); } } throw new IndirectBindingException("no direct path available for " + method.getClass().getName()); }
private static MethodHandle tryDispatchDirect(JRubyCallSite site, RubyClass cls, DynamicMethod method) { String[] realName = {site.name()}; method = unwrapMethod(method, realName); for (HandleGenerator generator : HANDLE_GENERATORS) { if (generator.canGenerate(site, cls, method)) { return generator.generate(site, cls, method, realName[0]); } } throw new IndirectBindingException("no direct path available for " + method.getClass().getName()); }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { // Ruby to Core if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound to native method " + logMethod(method) + ": " + method.getNativeCall()); return postProcessNativeHandle(createNativeHandle(cls.getClassRuntime(), site, method, realName), site, method, true, false); }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { // Ruby to Java if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound to Java method " + logMethod(method) + ": " + method.getNativeCall()); return postProcessNativeHandle(createJavaHandle(site, method), site, method, false, Options.REWRITE_JAVA_TRACE.load()); }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { // Ruby to Java if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound to Java method " + logMethod(method) + ": " + method.getNativeCall()); return postProcessNativeHandle(createJavaHandle(site, method), site, method, false, Options.REWRITE_JAVA_TRACE.load()); }
@Override public MethodHandle generate(JRubyCallSite site, RubyClass cls, DynamicMethod method, String realName) { // Ruby to Core if (RubyInstanceConfig.LOG_INDY_BINDINGS) LOG.info(site.name() + "\tbound to native method " + logMethod(method) + ": " + method.getNativeCall()); return postProcessNativeHandle(createNativeHandle(cls.getClassRuntime(), site, method, realName), site, method, true, false); }
public static IRubyObject floatOperatorFail(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, RubyFloat value) throws Throwable { String operator = site.name(); RubyClass selfClass = InvokeDynamicSupport.pollAndGetClass(context, self); CacheEntry entry = site.entry; if (entry.typeOk(selfClass)) { return entry.method.call(context, self, selfClass, operator, value); } else { entry = selfClass.searchWithCache(operator); if (InvokeDynamicSupport.methodMissing(entry, site.callType(), operator, caller)) { return InvokeDynamicSupport.callMethodMissing(entry, site.callType(), context, self, operator, value); } site.entry = entry; return entry.method.call(context, self, selfClass, operator, value); } }
public static IRubyObject floatOperatorFail(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, RubyFloat value) throws Throwable { String operator = site.name(); RubyClass selfClass = InvokeDynamicSupport.pollAndGetClass(context, self); CacheEntry entry = site.entry; if (entry.typeOk(selfClass)) { return entry.method.call(context, self, selfClass, operator, value); } else { entry = selfClass.searchWithCache(operator); if (InvokeDynamicSupport.methodMissing(entry, site.callType(), operator, caller)) { return InvokeDynamicSupport.callMethodMissing(entry, site.callType(), context, self, operator, value); } site.entry = entry; return entry.method.call(context, self, selfClass, operator, value); } }
public static IRubyObject fail(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String name = site.name(); CacheEntry entry = site.entry; if (entry.typeOk(selfClass)) { return entry.method.call(context, self, selfClass, name, arg0, arg1); } else { entry = selfClass.searchWithCache(name); if (methodMissing(entry, site.callType(), name, caller)) { return callMethodMissing(entry, site.callType(), context, self, name, arg0, arg1); } site.entry = entry; return entry.method.call(context, self, selfClass, name, arg0, arg1); } }
public static IRubyObject fail(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String name = site.name(); CacheEntry entry = site.entry; if (entry.typeOk(selfClass)) { return entry.method.call(context, self, selfClass, name, arg0); } else { entry = selfClass.searchWithCache(name); if (methodMissing(entry, site.callType(), name, caller)) { return callMethodMissing(entry, site.callType(), context, self, name, arg0); } site.entry = entry; return entry.method.call(context, self, selfClass, name, arg0); } }
public static IRubyObject fail(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject[] args, Block block) throws Throwable { RubyClass selfClass = pollAndGetClass(context, self); String name = site.name(); CacheEntry entry = site.entry; if (entry.typeOk(selfClass)) { return entry.method.call(context, self, selfClass, name, args, block); } else { entry = selfClass.searchWithCache(name); if (methodMissing(entry, site.callType(), name, caller)) { return callMethodMissing(entry, site.callType(), context, self, name, args, block); } site.entry = entry; return entry.method.call(context, self, selfClass, name, args, block); } }
public static IRubyObject fixnumOperatorFail(ThreadContext context, IRubyObject caller, IRubyObject self, JRubyCallSite site, RubyFixnum value) throws Throwable { String operator = site.name(); RubyClass selfClass = InvokeDynamicSupport.pollAndGetClass(context, self); CacheEntry entry = site.entry; if (entry.typeOk(selfClass)) { return entry.method.call(context, self, selfClass, operator, value); } else { entry = selfClass.searchWithCache(operator); if (InvokeDynamicSupport.methodMissing(entry, site.callType(), operator, caller)) { return InvokeDynamicSupport.callMethodMissing(entry, site.callType(), context, self, operator, value); } site.entry = entry; return entry.method.call(context, self, selfClass, operator, value); } }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject[] args) 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)) { IRubyObject mmResult = callMethodMissing(entry, site.callType(), context, self, method, args); // TODO: replace with handle logic return site.isAttrAssign() ? args[args.length - 1] : mmResult; } MethodHandle target = getTarget(site, selfClass, entry, -1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, false, 4); return (IRubyObject)target.invokeWithArguments(context, caller, self, args); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject[] args) 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)) { IRubyObject mmResult = callMethodMissing(entry, site.callType(), context, self, method, args); // TODO: replace with handle logic return site.isAttrAssign() ? args[args.length - 1] : mmResult; } MethodHandle target = getTarget(site, selfClass, entry, -1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, false, 4); return (IRubyObject)target.invokeWithArguments(context, caller, self, args); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) 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)) { IRubyObject mmResult = callMethodMissing(entry, site.callType(), context, self, method, arg0, arg1, arg2); // TODO: replace with handle logic return site.isAttrAssign() ? arg2 : mmResult; } MethodHandle target = getTarget(site, selfClass, entry, 3); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, false, 3); return (IRubyObject)target.invokeWithArguments(context, caller, self, arg0, arg1, arg2); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0) 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)) { IRubyObject mmResult = callMethodMissing(entry, site.callType(), context, self, method, arg0); // TODO: replace with handle logic return site.isAttrAssign() ? arg0 : mmResult; } MethodHandle target = getTarget(site, selfClass, entry, 1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, false, 1); return (IRubyObject)target.invokeWithArguments(context, caller, self, arg0); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0) 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)) { IRubyObject mmResult = callMethodMissing(entry, site.callType(), context, self, method, arg0); // TODO: replace with handle logic return site.isAttrAssign() ? arg0 : mmResult; } MethodHandle target = getTarget(site, selfClass, entry, 1); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, false, 1); return (IRubyObject)target.invokeWithArguments(context, caller, self, arg0); }
public static IRubyObject invocationFallback(JRubyCallSite site, ThreadContext context, IRubyObject caller, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) 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)) { IRubyObject mmResult = callMethodMissing(entry, site.callType(), context, self, method, arg0, arg1, arg2); // TODO: replace with handle logic return site.isAttrAssign() ? arg2 : mmResult; } MethodHandle target = getTarget(site, selfClass, entry, 3); target = updateInvocationTarget(target, site, self, selfClass, method, entry, switchPoint, false, 3); return (IRubyObject)target.invokeWithArguments(context, caller, self, arg0, arg1, arg2); }