[pull] master from ruby:master#1210
Merged
Merged
Conversation
dump_ast reports prism byte offsets against the raw file bytes, which are authoritative, but the loader read the source in text mode, so on Windows a CRLF checkout shifted every offset and produced wrong line numbers. The broken line numbers missed the LOCALS_DB lookup, cexpr! locals were silently dropped, and the generated inline functions failed to compile (error C2065). Read the source in binary mode and normalize CRLF in extracted C snippets so that CRLF and LF checkouts generate identical rbinc files. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
The universal newline decorator states the intent more clearly than a regexp substitution and also folds a lone CR.
As a first step toward optimizing sends with complex argument passing, allow SendDirect for callees with *rest by packing the positional arguments into a rest array before the call. Track the selected optional argument JIT entry as jit_entry_idx explicitly so packed rest arguments do not confuse entry-point selection for optional, post, and keyword parameter layouts. Rest array allocation elision is left for a further follow-up, since it requires proving that the rest array does not escape.
Count keyword-to-positional-hash cases as ComplexArgPass only when the converted positional argument count is accepted by the callee. Otherwise, keep the fallback reason as ArgcParamMismatch. Add an opt test covering the arity mismatch case.
Reference the VM argument setup functions that SendDirect mirrors for keyword-to-positional-hash handling, rest parameter packing, and optional argument entry selection.
* ZJIT: Add HIR tests for block arg nil and non-nil
* ZJIT: Optimize send with a nil block to SendWithoutBlockDirect
A call like `foo(&block)` sets VM_CALL_ARGS_BLOCKARG, which previously
forced a dynamic dispatch even when the block argument is nil and the
callee is an ISEQ method that could otherwise be reduced to a
SendDirect.
Passing a nil block argument is equivalent to calling without a block,
so when we can prove the block argument is nil we strip it and treat the
call as blockless. This happens when the block argument is either:
* statically known to be nil, or
* profiled as monomorphically nil, in which case we emit a
GuardBitEquals against nil (side exit reason BlockArgNotNil) before
stripping it. The guard recompiles on exit, so a site that starts
seeing non-nil blocks re-profiles and drops the speculation, falling
back to a dynamic send instead of taking the guard exit repeatedly.
When the block argument can't be proven nil, we fall back to a dynamic
Send and record the SendBlockArgNotNil fallback reason.
The block-stripped frame state is used only to set up the callee frame
for the direct send. The pre-call guards (the nil-block GuardBitEquals,
the receiver GuardType, and the method-redefinition PatchPoint) keep
using the original frame state, which still has the block argument on
the stack. This matters because a guard side exit re-executes the
`send` in the interpreter, which pops the block argument off the stack;
reconstructing the interpreter stack without it would leave the saved
SP off by one and corrupt the pushed frame.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
See Commits and Changes for more details.
Created by
pull[bot] (v2.0.0-alpha.4)
Can you help keep this open source service alive? 💖 Please sponsor : )