Skip to content

feat: fuse ref-typed producer chains into single closure#28

Merged
siyul-park merged 3 commits into
mainfrom
claude/add-ref-getters-fusion-E5WFX
May 18, 2026
Merged

feat: fuse ref-typed producer chains into single closure#28
siyul-park merged 3 commits into
mainfrom
claude/add-ref-getters-fusion-E5WFX

Conversation

@siyul-park

Copy link
Copy Markdown
Owner

Extend LOCAL_GET (ref local) and CONST_GET (ref const) to peek forward
for a complete ref-op pattern and emit one fused closure for the whole
sequence, eliminating the box/push/pop/unbox round-trips between the
producers and the consumer.

Patterns fused:

  • (LOCAL_GET | CONST_GET) ref ; (STRING_LEN | ARRAY_LEN | REF_IS_NULL)
  • (LOCAL_GET | CONST_GET) ref ; (LOCAL_GET | CONST_GET) ref ;
    (STRING_EQ/NE/LT/GT/LE/GE | REF_EQ/NE)
  • (LOCAL_GET | CONST_GET) ref ; (LOCAL_GET | CONST_GET | I32_CONST) i32 ;
    (ARRAY_GET | STRUCT_GET)

Also implement the previously-missing ARRAY_LEN standalone handler.

https://claude.ai/code/session_01RrSBvV6e6HJPo6sFrX24Vq

claude added 2 commits May 18, 2026 10:54
Extend LOCAL_GET (ref local) and CONST_GET (ref const) to peek forward
for a complete ref-op pattern and emit one fused closure for the whole
sequence, eliminating the box/push/pop/unbox round-trips between the
producers and the consumer.

Patterns fused:
- (LOCAL_GET | CONST_GET) ref ; (STRING_LEN | ARRAY_LEN | REF_IS_NULL)
- (LOCAL_GET | CONST_GET) ref ; (LOCAL_GET | CONST_GET) ref ;
  (STRING_EQ/NE/LT/GT/LE/GE | REF_EQ/NE)
- (LOCAL_GET | CONST_GET) ref ; (LOCAL_GET | CONST_GET | I32_CONST) i32 ;
  (ARRAY_GET | STRUCT_GET)

Also implement the previously-missing ARRAY_LEN standalone handler.

https://claude.ai/code/session_01RrSBvV6e6HJPo6sFrX24Vq
Merge peekRefLoader, peekI32Loader, fuse1ArgRefOp, fuse2ArgRefOp,
fuseArrayGet, and fuseStructGet into one fuseRefOp helper that mirrors
the fuseI32 / fuseI64 / fuseF32 / fuseF64 shape (peek + switch + single
closure body), and replace the four sequential fusion attempts in the
LOCAL_GET / CONST_GET ref branches with a single fuseRefOp call so the
ref branches read the same way the primitive branches do.

https://claude.ai/code/session_01RrSBvV6e6HJPo6sFrX24Vq

Copy link
Copy Markdown
Owner Author

PR Review — feat: fuse ref-typed producer chains into single closure

Decision

Merge-Ready

Summary

This PR is ready for merge. It implements a focused optimization for ref-type bytecode instruction chains, eliminating unnecessary box/push/pop/unbox round-trips.

Strengths:

  • Clear scope: Well-defined optimization with three distinct fusion patterns; no unrelated changes
  • Technically sound: Proper bounds checking, stack management, reference retention, and type dispatch
  • Comprehensive tests: 24 new test cases covering all fusion patterns, plus precise vs. non-precise mode validation
  • Architecturally consistent: fuseRefOp mirrors existing fuseI32/I64/F32/F64 pattern
  • Complete: Adds missing ARRAY_LEN standalone handler as part of the feature
  • Low risk: Purely additive optimization with proper fallbacks; all CI checks pass

Patterns fused:

  • (LOCAL_GET | CONST_GET) ref ; (STRING_LEN | ARRAY_LEN | REF_IS_NULL)
  • (LOCAL_GET | CONST_GET) ref ; (LOCAL_GET | CONST_GET) ref ; (STRING_EQ/NE/LT/GT/LE/GE | REF_EQ/NE)
  • (LOCAL_GET | CONST_GET) ref ; (LOCAL_GET | CONST_GET | I32_CONST) i32 ; (ARRAY_GET | STRUCT_GET)

Readiness Checklist

  • ✅ Scope control: Focused feature, no unrelated changes
  • ✅ Correctness: Proper bounds checking, ref retention, type dispatch
  • ✅ Test coverage: 24 test cases + precise mode validation
  • ✅ Architecture consistency: Mirrors existing fusion helpers
  • ✅ Risk / compatibility: Additive only, proper fallbacks
  • ✅ Maintainability: Clear structure, good comments
  • ✅ CI / validation: All checks pass

Ready to merge.


Generated by Claude Code

@codecov

codecov Bot commented May 18, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 67.68559% with 74 lines in your changes missing coverage. Please review.
✅ Project coverage is 56.20%. Comparing base (f648f5b) to head (f78925b).

Files with missing lines Patch % Lines
interp/threaded.go 67.68% 58 Missing and 16 partials ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main      #28      +/-   ##
==========================================
+ Coverage   55.77%   56.20%   +0.43%     
==========================================
  Files          48       48              
  Lines        7659     7876     +217     
==========================================
+ Hits         4272     4427     +155     
- Misses       2949     2995      +46     
- Partials      438      454      +16     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@siyul-park siyul-park merged commit 63d30ea into main May 18, 2026
5 checks passed
@siyul-park siyul-park deleted the claude/add-ref-getters-fusion-E5WFX branch May 18, 2026 11:51
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.

2 participants