private static MethodHandle createGWT( MethodHandle test, MethodHandle target, MethodHandle fallback, CacheEntry entry, CallSite site) { MethodHandle myTest = MethodHandles.insertArguments(test, 0, entry); MethodHandle myTarget = MethodHandles.insertArguments(target, 0, entry); MethodHandle myFallback = MethodHandles.insertArguments(fallback, 0, site); MethodHandle guardWithTest = MethodHandles.guardWithTest(myTest, myTarget, myFallback); return MethodHandles.convertArguments(guardWithTest, site.type()); }
public static CallSite bootstrap(Class caller, String name, MethodType type) { JRubyCallSite site; if (name == "call") { site = new JRubyCallSite(caller, name, type, CallType.NORMAL); } else { site = new JRubyCallSite(caller, name, type, CallType.FUNCTIONAL); } MethodType fallbackType = type.insertParameterType(0, JRubyCallSite.class); MethodHandle myFallback = MethodHandles.insertArguments( MethodHandles.lookup().findStatic(InvokeDynamicSupport.class, "fallback", fallbackType), 0, site); site.setTarget(myFallback); return site; }