Skip to content

[pull] master from ruby:master#1210

Merged
pull[bot] merged 8 commits into
turkdevops:masterfrom
ruby:master
Jul 14, 2026
Merged

[pull] master from ruby:master#1210
pull[bot] merged 8 commits into
turkdevops:masterfrom
ruby:master

Conversation

@pull

@pull pull Bot commented Jul 14, 2026

Copy link
Copy Markdown

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 : )

k0kubun and others added 8 commits July 13, 2026 16:04
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.
@pull pull Bot locked and limited conversation to collaborators Jul 14, 2026
@pull pull Bot added the ⤵️ pull label Jul 14, 2026
@pull pull Bot merged commit 3513044 into turkdevops:master Jul 14, 2026
0 of 2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants