Skip to content

perf(codegen): specialize typed-array helper integer args - #7951

Merged
proggeramlug merged 2 commits into
mainfrom
fix/7221-float64array-spec-abi
Aug 12, 2026
Merged

perf(codegen): specialize typed-array helper integer args#7951
proggeramlug merged 2 commits into
mainfrom
fix/7221-float64array-spec-abi

Conversation

@proggeramlug

@proggeramlug proggeramlug commented Aug 12, 2026

Copy link
Copy Markdown
Contributor

Closes #7221

Summary

  • prove immutable numeric literal locals used as typed-array constructor lengths, so new Float64Array(nodes) keeps its non-view shape at direct call sites
  • reuse the complete integer-local write-set proof for specialized raw-i32 arguments and seed those facts into the specialized callee
  • cover the real PutValueSet lowering path with IR and checksum-equivalence regressions

Validation

  • cargo fmt --all -- --check
  • cargo test -p perry-codegen
  • bash scripts/check_file_size.sh
  • Node/Perry checksum output: issue7221: 1011200 0.40900000000000003
  • M1 mini, 15 alternating runs: helper p50 16.717 -> 5.945 us/frame (-64.4%); fixed helper matches fixed inline at 5.942 us/frame; all 60 arms returned checksum 1551490560
  • LLVM trace: specialized tuple ta7x10000,i32,i32,i32,b; helper emits direct store double and no js_typed_array_index_set_dynamic call

Summary by CodeRabbit

  • Performance

    • Improved specialized Float64Array operations by using proven integer indices and direct stores.
    • Reduced boxing and overhead for eligible typed-array constructor lengths and integer arguments.
    • Added support for more efficient specialized ABI calls while preserving safe handling of unproven values.
  • Bug Fixes

    • Added regression coverage to verify consistent Float64Array results across repeated updates and frames.

@coderabbitai

coderabbitai Bot commented Aug 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 22ec7a15-cc21-426e-bfaf-1d7887d030d6

📥 Commits

Reviewing files that changed from the base of the PR and between b994484 and f70ea0b.

📒 Files selected for processing (10)
  • changelog.d/7951-float64array-spec-abi.md
  • crates/perry-codegen/src/codegen/function.rs
  • crates/perry-codegen/src/collectors/hir_facts.rs
  • crates/perry-codegen/src/collectors/integer_locals.rs
  • crates/perry-codegen/src/collectors/mod.rs
  • crates/perry-codegen/src/collectors/spec_abi_sites.rs
  • crates/perry-codegen/src/collectors/spec_abi_sites/tests.rs
  • crates/perry-codegen/src/lower_call/func_ref.rs
  • crates/perry-codegen/tests/spec_abi_typed_array_local_length.rs
  • test-files/test_issue_7221_spec_abi_float64array_local_length.ts

📝 Walkthrough

Walkthrough

The change extends typed-array specialization with integer-local provenance and specialized I32 parameter facts. Specialized calls lower proven locals as raw i32 values. New tests verify direct Float64Array stores, boxed fallbacks, and checksum-equivalent execution.

Changes

Float64Array specialization ABI

Layer / File(s) Summary
ABI provenance analysis
crates/perry-codegen/src/collectors/spec_abi_sites.rs, crates/perry-codegen/src/collectors/spec_abi_sites/tests.rs
Call-site analysis tracks immutable typed-array lengths and proven integer locals. Proven locals use I32; mutable or overwritten locals remain boxed.
Specialized fact propagation
crates/perry-codegen/src/collectors/integer_locals.rs, crates/perry-codegen/src/collectors/hir_facts.rs, crates/perry-codegen/src/codegen/function.rs, crates/perry-codegen/src/collectors/mod.rs
Specialized I32 parameters seed integer analysis. The renamed fact-graph API forwards typed-array and integer facts.
Raw I32 specialized-call lowering
crates/perry-codegen/src/lower_call/func_ref.rs
Proven integer locals become RawArg::I32Value and lower through fptosi before specialized calls.
IR and execution validation
crates/perry-codegen/tests/spec_abi_typed_array_local_length.rs, test-files/test_issue_7221_spec_abi_float64array_local_length.ts, changelog.d/7951-float64array-spec-abi.md
Tests verify raw I32 calls, direct floating-point stores, absence of dynamic boxed stores, boxed fallbacks, and checksum equivalence.

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant TypeScriptHelper
  participant SpecAbiCollector
  participant FactGraph
  participant SpecializedHelper
  participant Float64ArrayStorage
  TypeScriptHelper->>SpecAbiCollector: analyze typed-array and numeric arguments
  SpecAbiCollector->>FactGraph: pass typed-array length and I32 facts
  FactGraph->>SpecializedHelper: lower specialized representation tuple
  SpecializedHelper->>Float64ArrayStorage: store Float64 value at raw i32 index
Loading

Possibly related PRs

Suggested reviewers: thehypnoo

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The changes satisfy issue #7221 by selecting specialized typed-array ABIs, propagating raw i32 arguments, emitting direct stores, and adding regression coverage.
Out of Scope Changes check ✅ Passed The code, changelog, and regression tests are directly related to the typed-array specialization objective in issue #7221.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Title check ✅ Passed The title clearly and concisely identifies the main change: specializing typed-array helper integer arguments.
Description check ✅ Passed The description provides the summary, related issue, concrete changes, and detailed validation results, despite using a Validation heading instead of the template's Test plan heading.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/7221-float64array-spec-abi

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@proggeramlug
proggeramlug marked this pull request as ready for review August 12, 2026 11:06
@proggeramlug
proggeramlug merged commit c3789e6 into main Aug 12, 2026
1 of 19 checks passed
@proggeramlug
proggeramlug deleted the fix/7221-float64array-spec-abi branch August 12, 2026 11:22
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.

spec-ABI misses a monomorphic Float64Array helper; helper form is ~3x slower than inline

1 participant