Conversation
bec543f to
9c35a32
Compare
This confirms and compiles symbol-only, simple keyword arguments as a direct operand of the call, to allow downstream optimizations to prepare those keyword arguments in an appropriate way. Normal literal hashes and any keyword-like hashes with splats are compiled as before, with the Hash being built and stored and then loaded when the argument list is being built. Keyword hashes that are simple avoid the copy so they are associated directly with the call. Order continues to be preserved for the values of the simple kwargs hash, but the hash itself with its literal keys and any literal values are now both an operand of and metadata for the call.
9c35a32 to
fd7647d
Compare
This uses the keyword metadata in CallBase to embed a list of keys into the call site. This allows sending the kwarg values directly on the stack, to be passed along to receivers as-is or laily wrapped in a Hash for older-style receivers. This does not wire up either of these paths yet and will not dispatch correctly until the remaining binding logic is in place.
MetaCallSite accepts any number of object arguments with a descriptor describing the layout of those arguments. From there it determines the appropriate specialized call site to use for those arguments. This will be the initial stage of future invokedynamic binding, to allow as little custom logic on the call side as possible and all decisions made during binding.
This wires up methods with only simple keywords, using the fallback logic of boxing those arguments into a Hash and reinvoking the existing call sites.
Some cases with non-symbol keys appear to be getting marked by the parser as kwargs. Double-check so we don't assume. See jruby#9370
* Proper type of call site for normal/functional/variable. * Proper calculation of argument positions and counts
|
Pushed more fixes that allow language specs to run. Base was prior to many spec fixes and green CI so merged from master. |
This will expand as the capabilities progress, but for now there are several limitations on the direct-passing MetaCallSite: * Must have keywords (no real benefit right now for other forms). * No splats of positional or keyword arguments. * No supers. * No refined methods. This patch also modifies InvocationCompiler to allow querying for direct argument passing, since there's no effective way to implement it from the non-indy JIT. When running in AOT mode (and this is meaning AOT mode with no indy, as for GraalVM Native Image) we will always use the classic call site logic and full Hash kwargs.
|
Most recent changes have direct argument passing for normal positional and normal keyword arguments wired up to a new MetaCallSite. MetaCallSite will be like a switchboard of sorts, either binding the directly-passed arguments straight through to appropriate target, or falling back on boxing argument lists into arrays and keyword arguments into hashes. The current logic only has one path: box kwargs and fall back on the old logic that knows how to handle route simple argument lists. The next missing piece to prove this out is a way to specify native core methods with explicit mapping of parameters to their Ruby type. An idea for what this might look like, based on @JRubyMethod(name = "read_nonblock", direct = true, strictKeywords = false)
public IRubyObject read_nonblock(ThreadContext context,
@Req IRubyObject length,
@Opt(NIL) IRubyObject buffer,
@OptKey(name = "exception", defaultValue = NIL) IRubyObject _exception) {
boolean exception = _exception != context.fals;
return doReadNonblock(context, length, buffer, exception);
}If we can encode this information into the method table, setting up MetaCallSite to pass these arguments directly through and in the correct order will be a simple matter of method handles. |
This PR will implement pass-through keyword arguments for simple cases of calling core methods or calling other keyword-receiving methods. It is meant as a starting point to fully support pass-through of as many forms of keyword-based invocation as possible.
IR changes
Core changes
exception:ornonblock:would be good candidates for now.JIT changes
Caller side
The caller side indy optimizations can be implemented early and provides benefits without the rest due to moving hash construction and flags-setting into the call site.
Callee side