public static CallSite attrAssign(Lookup lookup, String name, MethodType type) { InvokeSite site = new InvokeSite(type, JavaNameMangler.demangleMethodName(name.split(":")[1])); MethodHandle handle = insertArguments( findStatic( lookup, Bootstrap.class, "attrAssign", type.insertParameterTypes(0, InvokeSite.class)), 0, site); site.setTarget(handle); return site; }
if (method.getArity().isFixed()) { if (method.getArity().getValue() <= 3) { Binder b = Binder.from(site.type()); if (!nc.hasContext()) { b.drop(0); b.insert(site.type().parameterCount() - 1, Block.NULL_BLOCK); } else if (!nc.hasBlock() && block) { b.drop(site.type().parameterCount() - 2, 1); MethodType type2 = site.type() .insertParameterTypes(2, RubyModule.class, String.class) .insertParameterTypes(0, DynamicMethod.class); mh = Binder.from(site.type()) .insert(2, selfClass, site.name) .from(site.type()) .insert(0, site.name) } else { MethodHandle test = Binder .from(site.type().changeReturnType(boolean.class)) .insert(0, new Class[]{RubyClass.class}, selfClass) .invokeStatic(MethodHandles.lookup(), Bootstrap.class, "testType");
if (method.getArity().isFixed()) { if (method.getArity().getValue() <= 3) { Binder b = Binder.from(site.type()); if (!nc.hasContext()) { b.drop(0); b.insert(site.type().parameterCount() - 1, Block.NULL_BLOCK); } else if (!nc.hasBlock() && block) { b.drop(site.type().parameterCount() - 2, 1); MethodType type2 = site.type() .insertParameterTypes(2, RubyModule.class, String.class) .insertParameterTypes(0, DynamicMethod.class); mh = Binder.from(site.type()) .insert(2, selfClass, site.name) .from(site.type()) .insert(0, site.name) } else { MethodHandle test = Binder .from(site.type().changeReturnType(boolean.class)) .insert(0, new Class[]{RubyClass.class}, selfClass) .invokeStatic(MethodHandles.lookup(), Bootstrap.class, "testType");
public static IRubyObject attrAssign(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0) throws Throwable { RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, false); mh = foldArguments( mh, Binder.from(site.type()) .drop(0, 2) .identity()); site.setTarget(mh); mh.invokeWithArguments(context, self, arg0); return arg0; }
public static IRubyObject attrAssign(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0) throws Throwable { RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, false); mh = foldArguments( mh, Binder.from(site.type()) .drop(0, 2) .identity()); site.setTarget(mh); mh.invokeWithArguments(context, self, arg0); return arg0; }
public static IRubyObject invokeSelf(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, Block block) throws Throwable { // TODO: literal block wrapper for break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.FUNCTIONAL, methodName, self)) { return callMethodMissing(entry, CallType.FUNCTIONAL, context, self, methodName, arg0); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 3, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, arg1, arg2, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 2, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, arg1, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 0, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 0, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, block); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2, Block block) throws Throwable { // TODO: literal block handling of break, etc RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 3, true); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, arg1, arg2, block); }
public static CallSite invoke(Lookup lookup, String name, MethodType type) { InvokeSite site = new InvokeSite(type, JavaNameMangler.demangleMethodName(name.split(":")[1])); MethodHandle handle = insertArguments( findStatic( lookup, Bootstrap.class, "invoke", type.insertParameterTypes(0, InvokeSite.class)), 0, site); site.setTarget(handle); return site; }
public static CallSite invokeSelf(Lookup lookup, String name, MethodType type) { InvokeSite site = new InvokeSite(type, JavaNameMangler.demangleMethodName(name.split(":")[1])); MethodHandle handle = insertArguments( findStatic( lookup, Bootstrap.class, "invokeSelf", type.insertParameterTypes(0, InvokeSite.class)), 0, site); site.setTarget(handle); return site; }
public static CallSite invoke(Lookup lookup, String name, MethodType type) { InvokeSite site = new InvokeSite(type, JavaNameMangler.demangleMethodName(name.split(":")[1])); MethodHandle handle = insertArguments( findStatic( lookup, Bootstrap.class, "invoke", type.insertParameterTypes(0, InvokeSite.class)), 0, site); site.setTarget(handle); return site; }
public static IRubyObject invokeSelf(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) throws Throwable { RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.FUNCTIONAL, methodName, self)) { return callMethodMissing(entry, CallType.FUNCTIONAL, context, self, methodName, arg0, arg1, arg2); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 3, false); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, arg1, arg2); }
public static IRubyObject invokeSelf(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1) throws Throwable { RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.FUNCTIONAL, methodName, self)) { return callMethodMissing(entry, CallType.FUNCTIONAL, context, self, methodName, arg0, arg1); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 2, false); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, arg1); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0, IRubyObject arg1, IRubyObject arg2) throws Throwable { RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 3, false); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0, arg1, arg2); }
public static IRubyObject invoke(InvokeSite site, ThreadContext context, IRubyObject self, IRubyObject arg0) throws Throwable { RubyClass selfClass = self.getMetaClass(); String methodName = site.name; SwitchPoint switchPoint = (SwitchPoint)selfClass.getInvalidator().getData(); CacheEntry entry = selfClass.searchWithCache(methodName); DynamicMethod method = entry.method; if (methodMissing(entry, CallType.NORMAL, methodName, self)) { return callMethodMissing(entry, CallType.NORMAL, context, self, methodName, arg0); } MethodHandle mh = getHandle(selfClass, switchPoint, site, method, 1, false); site.setTarget(mh); return (IRubyObject)mh.invokeWithArguments(context, self, arg0); }