/** * Spread the trailing [] argument into its component type assigning given names. * * @param names names to use for the decomposed arguments * @return a new signature with decomposed arguments in place of the trailing array */ public Signature spread(String... names) { Class<?> aryType = lastArgType(); assert lastArgType().isArray(); Class<?>[] newTypes = new Class<?>[names.length]; Arrays.fill(newTypes, aryType.getComponentType()); return spread(names, newTypes); }
/** * Prepare a binder for this call site's target, forcing varargs if specified * * @param varargs whether to only call an arg-boxed variable arity path * @return the prepared binder */ public Binder prepareBinder(boolean varargs) { SmartBinder binder = SmartBinder.from(signature); if (varargs || arity > 3) { // we know we want to call varargs path always, so prepare args[] here if (arity == -1) { // do nothing, already have IRubyObject[] in args } else if (arity == 0) { binder = binder.insert(argOffset, "args", IRubyObject.NULL_ARRAY); } else { binder = binder .collect("args", "arg[0-9]+"); } } // add block if needed if (signature.lastArgType() != Block.class) { binder = binder.append("block", Block.NULL_BLOCK); } // bind to site binder = binder.insert(0, "site", this); return binder.binder(); }
/** * Prepare a binder for this call site's target, forcing varargs if specified * * @param varargs whether to only call an arg-boxed variable arity path * @return the prepared binder */ public Binder prepareBinder(boolean varargs) { SmartBinder binder = SmartBinder.from(signature); if (varargs || arity > 3) { // we know we want to call varargs path always, so prepare args[] here if (arity == -1) { // do nothing, already have IRubyObject[] in args } else if (arity == 0) { binder = binder.insert(argOffset, "args", IRubyObject.NULL_ARRAY); } else { binder = binder .collect("args", "arg[0-9]+"); } } // add block if needed if (signature.lastArgType() != Block.class) { binder = binder.append("block", Block.NULL_BLOCK); } // bind to site binder = binder.insert(0, "site", this); return binder.binder(); }
MethodHandle buildJavaFieldHandle(InvokeSite site, DynamicMethod method, IRubyObject self) throws Throwable { if (method instanceof InstanceFieldGetter) { if (site.arity != 0 || site.signature.lastArgType() == Block.class) return null; } else if (method instanceof InstanceFieldSetter) { if (site.arity != 1 || site.signature.lastArgType() == Block.class) return null;
MethodHandle buildJavaFieldHandle(InvokeSite site, DynamicMethod method, IRubyObject self) throws Throwable { if (method instanceof InstanceFieldGetter) { if (site.arity != 0 || site.signature.lastArgType() == Block.class) return null; } else if (method instanceof InstanceFieldSetter) { if (site.arity != 1 || site.signature.lastArgType() == Block.class) return null;
MethodHandle getHandle(IRubyObject self, RubyClass dispatchClass, DynamicMethod method) throws Throwable { boolean blockGiven = signature.lastArgType() == Block.class; MethodHandle mh = buildNewInstanceHandle(method, self); if (mh == null) mh = buildNotEqualHandle(method, self); if (mh == null) mh = Bootstrap.buildNativeHandle(this, method, blockGiven); if (mh == null) mh = buildJavaFieldHandle(this, method, self); if (mh == null) mh = Bootstrap.buildIndyHandle(this, method, method.getImplementationClass()); if (mh == null) mh = Bootstrap.buildJittedHandle(this, method, blockGiven); if (mh == null) mh = Bootstrap.buildAttrHandle(this, method, self, dispatchClass); if (mh == null) mh = buildAliasHandle(method, self, dispatchClass); if (mh == null) mh = buildStructHandle(method, self, dispatchClass); if (mh == null) mh = Bootstrap.buildGenericHandle(this, method, dispatchClass); assert mh != null : "we should have a method handle of some sort by now"; return mh; }
MethodHandle getHandle(IRubyObject self, RubyClass dispatchClass, DynamicMethod method) throws Throwable { boolean blockGiven = signature.lastArgType() == Block.class; MethodHandle mh = buildNewInstanceHandle(method, self); if (mh == null) mh = buildNotEqualHandle(method, self); if (mh == null) mh = Bootstrap.buildNativeHandle(this, method, blockGiven); if (mh == null) mh = buildJavaFieldHandle(this, method, self); if (mh == null) mh = Bootstrap.buildIndyHandle(this, method, method.getImplementationClass()); if (mh == null) mh = Bootstrap.buildJittedHandle(this, method, blockGiven); if (mh == null) mh = Bootstrap.buildAttrHandle(this, method, self, dispatchClass); if (mh == null) mh = buildAliasHandle(method, self, dispatchClass); if (mh == null) mh = buildStructHandle(method, self, dispatchClass); if (mh == null) mh = Bootstrap.buildGenericHandle(this, method, dispatchClass); assert mh != null : "we should have a method handle of some sort by now"; return mh; }
if (site.fullSignature.lastArgType() == Block.class) { if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) { LOG.info(site.name() + "\tpassed a closure to Java method " + nativeCall + ": " + Bootstrap.logMethod(method));
if (site.fullSignature.lastArgType() == Block.class) { if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) { LOG.info(site.name() + "\tpassed a closure to Java method " + nativeCall + ": " + Bootstrap.logMethod(method));
boolean blockGiven = site.signature.lastArgType() == Block.class;
boolean blockGiven = site.signature.lastArgType() == Block.class;