Skip to content

Preserve incoming callInfo when forwarding arguments - #9671

Open
headius wants to merge 2 commits into
jruby:masterfrom
headius:fix_legacy_forwarding
Open

headius wants to merge 2 commits into
jruby:masterfrom
headius:fix_legacy_forwarding

Conversation

@headius

@headius headius commented Sep 11, 2026

Copy link
Copy Markdown
Member

This is a hack to fix argument forwarding when callInfo must be passed along.

The original callInfo is captured at the top of the method and used to pre-load a callInfo before later calls that forward arguments. A new keyword flag CALL_FORWARDING is added to specify that the already-prepared callInfo should be left as-is. This allows the downstream calls to see the incoming arguments and callInfo metadata largely as they were first received.

It is hacky for a number of reasons:

  • The new CALL_FORWARDING argument is just a hack to say "don't set callInfo because I already set it. A better pattern would be to build this intelligence into call/super handling.
  • This likely doesn't work properly with the Prism parser and will require additional patches there.
  • In both cases, introducing new IR instructions that specifically know how to handle forwarding would mean better optimization and fewer fragile hacks.

This patch works well enough to pass the cases from jruby/jruy#9328 but I'm dubious as to whether the fix is worth the hack.

Generated in part by GPT 5.6 but heavily refactored to remove excess complexity.

This is a hack to fix argument forwarding when callInfo must be
passed along.

The original callInfo is captured at the top of the method and used
to pre-load a callInfo before later calls that forward arguments. A
new keyword flag CALL_FORWARDING is added to specify that the
already-prepared callInfo should be left as-is. This allows the
downstream calls to see the incoming arguments and callInfo
metadata largely as they were first received.

It is hacky for a number of reasons:

* The new CALL_FORWARDING argument is just a hack to say "don't
  set callInfo because I already set it. A better pattern would be
  to build this intelligence into call/super handling.
* This likely doesn't work properly with the Prism parser and will
  require additional patches there.
* In both cases, introducing new IR instructions that specifically
  know how to handle forwarding would mean better optimization and
  fewer fragile hacks.

This patch works well enough to pass the cases from jruby/jruy#9328
but I'm dubious as to whether the fix is worth the hack.

Generated in part by GPT 5.6 but heavily refactored to remove
excess complexity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant