@Override public Binder prepareBinder() { // collect dregexp args into an array String[] argNames = new String[type().parameterCount()]; Class[] argTypes = new Class[argNames.length]; argNames[0] = "context"; argTypes[0] = ThreadContext.class; for (int i = 1; i < argNames.length; i++) { argNames[i] = "part" + i; argTypes[i] = RubyString.class; } // "once" deregexp must be handled on the call side return SmartBinder .from(RubyRegexp.class, argNames, argTypes) .collect("parts", "part.*") .binder(); }
@Override public Binder prepareBinder() { // collect dregexp args into an array String[] argNames = new String[type().parameterCount()]; Class[] argTypes = new Class[argNames.length]; argNames[0] = "context"; argTypes[0] = ThreadContext.class; for (int i = 1; i < argNames.length; i++) { argNames[i] = "part" + i; argTypes[i] = RubyString.class; } // "once" deregexp must be handled on the call side return SmartBinder .from(RubyRegexp.class, argNames, argTypes) .collect("parts", "part.*") .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(); }
/** * 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(); }
static MethodHandle buildGenericHandle(InvokeSite site, DynamicMethod method, RubyClass dispatchClass) { SmartBinder binder; binder = SmartBinder.from(site.signature) .permute("context", "self", "arg.*", "block") .insert(2, new String[]{"rubyClass", "name"}, new Class[]{RubyModule.class, String.class}, dispatchClass, site.name()) .insert(0, "method", DynamicMethod.class, method); if (site.arity > 3) { binder = binder.collect("args", "arg.*"); } if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) { LOG.info(site.name() + "\tbound indirectly " + method + ", " + Bootstrap.logMethod(method)); } return binder.invokeVirtualQuiet(LOOKUP, "call").handle(); }
static MethodHandle buildGenericHandle(InvokeSite site, DynamicMethod method, RubyClass dispatchClass) { SmartBinder binder; binder = SmartBinder.from(site.signature) .permute("context", "self", "arg.*", "block") .insert(2, new String[]{"rubyClass", "name"}, new Class[]{RubyModule.class, String.class}, dispatchClass, site.name()) .insert(0, "method", DynamicMethod.class, method); if (site.arity > 3) { binder = binder.collect("args", "arg.*"); } if (Options.INVOKEDYNAMIC_LOG_BINDING.load()) { LOG.info(site.name() + "\tbound indirectly " + method + ", " + Bootstrap.logMethod(method)); } return binder.invokeVirtualQuiet(LOOKUP, "call").handle(); }
.collect("args", "arg.*");
.collect("args", "arg.*");
.collect("args", "arg.*") .invoke(mh) .handle();
.collect("args", "arg.*") .invoke(mh) .handle();
} else { mh = (MethodHandle) compiledIRMethod.getHandle(); binder = binder.collect("args", "arg.*");
} else { mh = (MethodHandle) compiledIRMethod.getHandle(); binder = binder.collect("args", "arg.*");