Skip to content

Commit ce0117a

Browse files
authored
feat(codegen+runtime): representation-aware type lowering + native-ABI material evidence gate (#5466)
v0.5.1213. Lands the type-lowering track: i32/u32/f64/i128(BigInt)/StringRef native reps with runtime-guarded fast/fallback splits (scalar params, number-keyed Map/Set, typed string/i32 methods, typed function/closure/method clones, packed numeric array loops with side-exit versioning), plus the differential typed-vs-any material evidence CI gate with anti-gaming guards and the --explain-lowering report. Review hardening folded in: spec-exact ToInt32 (toint32_wrap) at user-visible bitwise sites + runtime js_dynamic_bitnot ((1e20)|0 and ~(1e20) were wrong on main too); magnitude-bound proof behind toint32_fast; captured-buffer locals can't earn unchecked native-pointer proofs; reverse local-value alias chains invalidate on write; runtime-key array stores register the matching typed-feedback contract; typed_i1_functions gates the i1 typed-call branch. Verified: the 3 pre-merge runtime regressions (Array.fromAsync, dynamic-import namespace, fetch headers.forEach) byte-match node; 16-test gap differential clean (3 mismatches attributed pre-existing via a control binary at the merge parent); native-region-proof/native-abi-proof suites, typed-feedback runtime evidence, and capture workloads green locally and on CI.
1 parent 3a0d4e1 commit ce0117a

148 files changed

Lines changed: 40540 additions & 1756 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/test.yml

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,9 @@ jobs:
517517
- name: Run harness unit tests
518518
run: python3 -m unittest tests.test_compiler_output_regression
519519

520+
- name: Run native ABI evidence report unit tests
521+
run: python3 -m unittest tests.test_native_abi_evidence_report
522+
520523
- name: Gate native-region proof compiler output
521524
run: |
522525
python3 scripts/compiler_output_regression.py suite \
@@ -525,8 +528,25 @@ jobs:
525528
--benchmark-mode smoke \
526529
--runs 1 \
527530
--perf-counters off \
531+
--gate \
528532
--print-summary
529533
534+
- name: Gate native-ABI proof compiler output
535+
run: |
536+
python3 scripts/compiler_output_regression.py suite \
537+
--suite native-abi-proof \
538+
--perry target/debug/perry \
539+
--benchmark-mode smoke \
540+
--runs 1 \
541+
--perf-counters off \
542+
--gate \
543+
--print-summary
544+
545+
- name: Gate typed feedback runtime evidence
546+
env:
547+
PERRY_BIN: ${{ github.workspace }}/target/debug/perry
548+
run: python3 -m unittest tests.test_typed_feedback_runtime_evidence
549+
530550
- name: Gate positive vectorization compiler output
531551
run: |
532552
python3 scripts/compiler_output_regression.py capture \
@@ -582,6 +602,70 @@ jobs:
582602
name: compiler-output-regression
583603
path: target/compiler-output-regression/
584604

605+
# ---------------------------------------------------------------------------
606+
# Native ABI evidence packet
607+
#
608+
# Full material-performance packet for the type-lowering gate. This is heavier
609+
# than the per-PR compiler-output smoke because it runs the native-ABI proof
610+
# packet with timing-quality samples, runtime checks, and release/LTO symbol
611+
# freshness. Gate tag pushes and opt-in PR/manual runs; ordinary PRs rely on
612+
# the lighter report/unit and compiler-output structural gates above.
613+
# ---------------------------------------------------------------------------
614+
native-abi-evidence-packet:
615+
if: >-
616+
github.event_name == 'push' ||
617+
(github.event_name == 'workflow_dispatch' && inputs.run_extended_tests) ||
618+
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'run-extended-tests'))
619+
runs-on: ubuntu-latest
620+
timeout-minutes: 90
621+
env:
622+
RUSTC_WRAPPER: sccache
623+
SCCACHE_GHA_ENABLED: "false"
624+
SCCACHE_DIR: ${{ github.workspace }}/.sccache
625+
SCCACHE_CACHE_SIZE: "12G"
626+
CARGO_INCREMENTAL: "0"
627+
steps:
628+
- uses: actions/checkout@v6
629+
630+
- name: Install Rust toolchain
631+
uses: dtolnay/rust-toolchain@stable
632+
633+
- name: Install sccache
634+
uses: mozilla-actions/sccache-action@v0.0.10
635+
636+
- name: Cache sccache objects
637+
uses: actions/cache@v4
638+
with:
639+
path: ${{ github.workspace }}/.sccache
640+
key: sccache-${{ runner.os }}-perry-native-abi-evidence-${{ github.run_id }}
641+
restore-keys: |
642+
sccache-${{ runner.os }}-perry-
643+
644+
- uses: Swatinem/rust-cache@v2
645+
with:
646+
shared-key: "${{ runner.os }}-perry"
647+
save-if: ${{ github.ref == 'refs/heads/main' }}
648+
649+
- name: Install clang
650+
run: |
651+
sudo apt-get update
652+
sudo apt-get install -y clang
653+
654+
- name: Gate native ABI evidence packet
655+
env:
656+
RUSTC_WRAPPER: ""
657+
RUSTFLAGS: -Awarnings
658+
run: |
659+
PYTHON=python3 bash tests/test_native_abi_evidence_packet_smoke.sh \
660+
target/native-abi-evidence-packet
661+
662+
- name: Upload native ABI evidence packet
663+
if: always()
664+
uses: actions/upload-artifact@v7
665+
with:
666+
name: native-abi-evidence-packet
667+
path: target/native-abi-evidence-packet/
668+
585669
# ---------------------------------------------------------------------------
586670
# Parity tests (Perry output vs Node.js)
587671
# ---------------------------------------------------------------------------

CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## v0.5.1213 — representation-aware type lowering + native-ABI material evidence gate (#5466)
2+
3+
Lands the type-lowering track on main (builds on #5291; integrates #5462's
4+
material evidence gate, #5464's packed-loop follow-ups, and the CodeRabbit
5+
review fixes).
6+
7+
- **Representation-aware type lowering**: i32/u32/f64/i128(BigInt)/StringRef
8+
native reps with runtime-guarded fast/fallback splits for scalar params,
9+
number-keyed Map/Set, typed string/i32 methods, typed function/closure/method
10+
clones (f64/i32/i1/string families), and packed numeric array loops (f64 +
11+
i32 loop versioning with side-exit slow clones). `lower_expr` now
12+
speculatively tries the native-rep value path for every expression and
13+
materializes through the evidence-recording boundary.
14+
- **Native-ABI material evidence gate**: differential typed-vs-`any` CI gate
15+
recomputing speedups/counter reductions from real `-O3` IR + GC traces with
16+
anti-gaming guards; 185+ codegen proof-suite regression tests; release-symbol
17+
sentinel check; `--explain-lowering` user-facing report.
18+
- **ToInt32 correctness (pre-existing, surfaced by review)**: the guarded
19+
`toint32` lowering now performs the spec's modular reduction instead of a
20+
bare `fptosi`, so finite values ≥ 2^63 (`(1e20) | 0`, nested integer-local
21+
multiplies) wrap to the correct int32 instead of LLVM-poison NaN; the
22+
`toint32_fast` gate (`is_known_finite`) is now a conservative magnitude-bound
23+
proof. New `test_gap_toint32_large_finite.ts`.
24+
- **Review fixes**: closure-captured buffer locals can no longer receive
25+
unchecked native-pointer proofs before an escape walk stamps the hazard map;
26+
`invalidate_local_write_facts` drops reverse local-value alias chains;
27+
runtime-key array stores register the `array_set_index_or_string` typed-
28+
feedback contract matching the emitted helper; `typed_i1_functions` is
29+
plumbed into `FnCtx` so the i1 typed-call branch gates like its siblings.
30+
- Verified: the three pre-merge runtime regressions (Array.fromAsync,
31+
dynamic-import namespace, fetch headers.forEach) match node byte-for-byte;
32+
16-test gap differential clean (3 pre-existing mismatches attributed to main
33+
via control binary); evidence suites, typed-feedback runtime evidence, and
34+
capture workloads green.
35+
136
## v0.5.1212 — fix(runtime): #5839 — PlainYearMonth/PlainMonthDay toLocaleString reject ISO calendar
237

338
Part of the #5839 Temporal test262 worklist (56 failing built-ins/Temporal + intl402/Temporal cases). Picked the `toLocaleString/calendar-mismatch.js` "even when instance has the ISO calendar" cluster as a coherent, self-contained fix.

CLAUDE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co
88

99
Perry is a native TypeScript compiler written in Rust that compiles TypeScript source code directly to native executables. It uses SWC for TypeScript parsing and LLVM for code generation.
1010

11-
**Current Version:** 0.5.1212
11+
**Current Version:** 0.5.1213
1212

1313

1414
## TypeScript Parity Status

0 commit comments

Comments
 (0)