Skip to content

Commit 900a7e7

Browse files
olwangclaude
andcommitted
feat(reg-vm,jit): land optimizing-JIT work + clear landing blockers
Large JIT advance on the register-VM native tier (Cranelift): OSR, scalar replacement (Option/Result/variant/struct), closure inlining/sinking, combinator expansion, checked-int elision, and a transactional heap-write boundary, plus the supporting hardening harness (differential + deopt-stress backends, perf gate, CI lanes, fuzz targets) and the reg_vm/analyzer/hir module decomposition. Blocker fixes (this pass, all differential-green in the dev container): - reg-vm: CallNative added to native_jit_written_reg (stale field memoization) - reg-vm: OSR pipeline threads the slice-elision ip-map (silent OSR bail) - reg-vm: closure-fuse invalidates defs on base-register clobber (wrong polymorphic dispatch) - reg-vm (OSR eligibility): candidate gate admits GetField + combinator intrinsics; ListPush is OSR-admissible only for region-local lists; closure sink gated on statically-proven scalar captures - reg-vm: native return-guard no longer lets a scratch FieldHandle escape - reg-vm: try_native/try_osr refuse while mem_budget is armed (heap-writing native can allocate off-the-meter) - spec: 7.1/7.2/10/3.1 reconciled with the heap-write transaction (journaled undo, commit-on-success, abort-on-bail) Known gap (latent; precise resume default-off): a reassigned scalar param is not restored on precise deopt -- blocked on J0.1 NativeTy-aware deopt state maps (repro: precise_deopt_restores_reassigned_scalar_param, #[ignore]). Verification (dev container): differential 33/0 (incl. force-deopt backends), jit_acceptance 83/0, rsscript lib 275/0, vm-jit 81/0, deopt-stress 8/0, default workspace build + lib 156/0, JIT perf gate PASS. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
1 parent bede8db commit 900a7e7

161 files changed

Lines changed: 32010 additions & 11233 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/actions/rsscript-review/action.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ runs:
132132
cp "$REVIEW_OUTPUT_FILE" "$COMMENT_FILE"
133133
134134
# Write outputs
135-
COMMENT_DELIMITER="RSSCRIPT_REVIEW_$(uuidgen 2>/dev/null || python3 -c 'import uuid; print(uuid.uuid4().hex)')"
135+
COMMENT_DELIMITER="RSSCRIPT_REVIEW_$(uuidgen 2>/dev/null || date +%s%N)"
136136
{
137137
echo "comment<<$COMMENT_DELIMITER"
138138
cat "$REVIEW_OUTPUT_FILE"
@@ -168,7 +168,7 @@ runs:
168168
fi
169169
170170
if [ -s "$CI_JSON_FILE" ]; then
171-
REVIEW_STATUS=$(python3 -c 'import json,sys; print(json.load(open(sys.argv[1])).get("status","unknown"))' "$CI_JSON_FILE")
171+
REVIEW_STATUS=$(perl -MJSON::PP -e 'local $/; my $d = decode_json(<>); print $d->{status} // "unknown";' < "$CI_JSON_FILE")
172172
elif [ $EXIT_CODE -ne 0 ]; then
173173
REVIEW_STATUS="fail"
174174
else
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
name: JIT hardening
2+
3+
on:
4+
workflow_dispatch:
5+
schedule:
6+
# Weekly bounded hardening sweep. Fuzz targets are capped by
7+
# `-max_total_time=60`; this schedule gives them continuity without making
8+
# every pull request pay the nightly/cargo-fuzz install cost.
9+
- cron: "17 10 * * 6"
10+
11+
concurrency:
12+
group: jit-hardening-${{ github.ref }}
13+
cancel-in-progress: true
14+
15+
jobs:
16+
hardening:
17+
runs-on: ubuntu-latest
18+
19+
steps:
20+
- name: Checkout
21+
uses: actions/checkout@v5
22+
23+
- name: Build dev container
24+
run: docker compose build dev
25+
26+
- name: Native JIT hardening gate
27+
run: |
28+
docker compose run --rm dev cargo test -p rsscript --lib register_window_tests --features native-jit -- --test-threads=1
29+
docker compose run --rm dev cargo test -p rsscript child_native --features native-jit -- --test-threads=1
30+
docker compose run --rm dev cargo test -p rsscript --test runtime native_jit_fast_backends_include_deopt_every_safepoint --features native-jit -- --test-threads=1
31+
docker compose run --rm dev cargo test -p rsscript --test runtime jit_acceptance_runs_ --features native-jit -- --test-threads=1
32+
docker compose run --rm dev cargo test -p rsscript --test runtime native_jit_acceptance_reports_real_native_execution --features native-jit -- --test-threads=1
33+
docker compose run --rm dev cargo test -p rsscript --test runtime native_jit_precompiles_cold_scalar_call_chains --features native-jit -- --test-threads=1
34+
docker compose run --rm dev cargo test -p rsscript --test runtime native_jit_precompiles_handle_return_call_chains --features native-jit -- --test-threads=1
35+
docker compose run --rm dev cargo test -p vm-jit native_call_can_pass_flat -- --test-threads=1
36+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_consumes_handle_return_compiled_call --features native-jit -- --test-threads=1
37+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_passes_bool_args_and_return --features native-jit -- --test-threads=1
38+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_passes_float_args_and_return --features native-jit -- --test-threads=1
39+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_passes_flat_int_arg_to_compiled_call --features native-jit -- --test-threads=1
40+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_passes_flat_float_arg_to_compiled_call --features native-jit -- --test-threads=1
41+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_passes_flat_int_mut_arg_to_compiled_call --features native-jit -- --test-threads=1
42+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_passes_handle_arg_to_compiled_call --features native-jit -- --test-threads=1
43+
docker compose run --rm dev cargo test -p rsscript --lib native_direct_dispatch_invokes_mut_handle_compiled_call --features native-jit -- --test-threads=1
44+
docker compose run --rm dev cargo test -p rsscript --lib precise_deopt_with_nested_child_native_frames_resumes_leaf_safepoint --features native-jit -- --test-threads=1
45+
docker compose run --rm dev cargo test -p rsscript --test runtime report_profile_guided_pic_shows_hottest_first_order --features native-jit -- --test-threads=1
46+
docker compose run --rm dev cargo test -p rsscript --test runtime report_shows_profile_guided_branch_feedback --features native-jit -- --test-threads=1
47+
docker compose run --rm dev cargo test -p rsscript --test runtime report_groups_native_decline_reasons_by_count --features native-jit -- --test-threads=1
48+
docker compose run --rm dev bash -lc 'RSS_DIFF_PROPTEST_CASES=16 RSS_DIFF_SHRINK_ITERS=0 cargo test -p rsscript --test differential backends_agree_on_seed_decoded_programs --features native-jit -- --test-threads=1'
49+
docker compose run --rm dev cargo test --release -p rsscript --test runtime jit_perf_gate_against_baseline --features native-jit -- --test-threads=1 --nocapture
50+
docker compose run --rm dev bash -lc 'rustup toolchain install nightly --component rust-src && target="$(rustc -vV | sed -n "s/^host: //p")" && RUSTFLAGS="-Zsanitizer=address" cargo +nightly test -Zbuild-std --target "$target" -p vm-jit native_scalar_call -- --test-threads=1 && RUSTFLAGS="-Zsanitizer=address" cargo +nightly test -Zbuild-std --target "$target" -p rsscript child_native --features native-jit -- --test-threads=1 && RUSTFLAGS="-Zsanitizer=address" cargo +nightly test -Zbuild-std --target "$target" -p rsscript forced_all_native_safepoints_exercises_child_native_deopt --features native-jit -- --test-threads=1 && RUSTFLAGS="-Zsanitizer=address" cargo +nightly test -Zbuild-std --target "$target" -p vm-jit guard_closure_id_passes_or_bails -- --test-threads=1 && RUSTFLAGS="-Zsanitizer=address" cargo +nightly test -Zbuild-std --target "$target" -p vm-jit direct_flat_reads_index_in_register -- --test-threads=1'
51+
52+
- name: Miri pure-core smoke
53+
run: docker compose run --rm dev bash -lc 'rustup toolchain install nightly --component miri,rust-src && cargo +nightly miri test -p rss-testgen --lib'
54+
55+
- name: No-panic fuzz smoke
56+
run: docker compose run --rm dev bash -lc 'rustup toolchain install nightly && (command -v cargo-fuzz >/dev/null || cargo install cargo-fuzz --locked) && cd fuzz && cargo +nightly fuzz run no_panic -- -runs=20000 -max_total_time=60'
57+
58+
- name: Native JIT differential fuzz smoke
59+
run: docker compose run --rm dev bash -lc 'rustup toolchain install nightly && (command -v cargo-fuzz >/dev/null || cargo install cargo-fuzz --locked) && cd fuzz && cargo +nightly fuzz run differential --features native-jit -- -runs=5000 -max_total_time=60'

.github/workflows/jit-perf.yml

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: JIT perf gate
2+
3+
on:
4+
workflow_dispatch:
5+
pull_request:
6+
branches: [main]
7+
paths:
8+
- ".github/workflows/jit-perf.yml"
9+
- "benchmarks/vm-jit/**"
10+
- "crates/rsscript/src/reg_vm/**"
11+
- "crates/rsscript/tests/jit_acceptance.rs"
12+
- "crates/vm-jit/**"
13+
push:
14+
branches: [main]
15+
paths:
16+
- ".github/workflows/jit-perf.yml"
17+
- "benchmarks/vm-jit/**"
18+
- "crates/rsscript/src/reg_vm/**"
19+
- "crates/rsscript/tests/jit_acceptance.rs"
20+
- "crates/vm-jit/**"
21+
22+
concurrency:
23+
group: jit-perf-${{ github.ref }}
24+
cancel-in-progress: true
25+
26+
jobs:
27+
perf-gate:
28+
runs-on: ubuntu-latest
29+
30+
steps:
31+
- name: Checkout
32+
uses: actions/checkout@v5
33+
34+
- name: Build dev container
35+
run: docker compose build dev
36+
37+
- name: JIT perf gate
38+
run: docker compose run --rm dev cargo test --release -p rsscript --test runtime jit_perf_gate_against_baseline --features native-jit -- --test-threads=1 --nocapture

AGENT.md

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -68,12 +68,14 @@ it as the lone exception, not the pattern. Spec: Constitution Article VIII, §2A
6868
rss check [--core|--no-core] [--interface <f.rssi> ...] <file.rss> # type/effect check
6969
rss check <package-directory> # check a package
7070
rss check --explain <CODE> # explain a diagnostic code, e.g. RS0026
71-
rss lint <file.rss> # check + style lints
71+
rss check --lint <file.rss> # check + style lints
72+
rss fix [--write] <file.rss> # apply machine-applicable fixes
7273
rss fmt <file.rss> # canonical formatter
73-
rss run <file-or-package-dir> [-- <args>...] # lower to Rust + build + run
74+
rss run --vm <file-or-package-dir> [-- <args>...] # fast VM run
75+
rss run <file-or-package-dir> [-- <args>...] # lower to Rust + build + run
7476
rss test [--all] [--filter <substr>]
75-
rss dev [--run] [--once] <file-or-dir> # watch loop
7677
rss pkg [--json] [dir] # package health check
78+
rss pkg add <dep|dep@version|path>
7779
rss pkg review [--json] [dir] # review surface
7880
rss pkg diff [--json] <old-dir> <new-dir>
7981
rss pkg ci [--json] [dir] # CI-facing package check
@@ -192,7 +194,7 @@ if count == 1 {
192194
Log.write(message: read "many")
193195
}
194196

195-
for query in queries { // `for` iterates a `List<T>` only (v0.6)
197+
for query in queries { // `for` iterates a `List<T>` only
196198
DbConnection.query(conn: mut conn, sql: read query.sql)?
197199
}
198200

@@ -325,7 +327,7 @@ Constructors are call-like and use the same named-arg + effect rules.
325327

326328
---
327329

328-
## 7. Async (restricted in v0.6)
330+
## 7. Async (restricted v0.7 surface)
329331

330332
```rust
331333
features: async
@@ -336,9 +338,12 @@ async fn fetch(url: read Url) -> Result<Int, HttpError> {
336338
}
337339
```
338340

339-
Rules: `await` appears **only inside an `async fn`** and must directly consume an
340-
async call. There is no `Future`/`Poll`/`spawn` surface in v0.6 (single-isolate,
341-
cooperative). `spawn` and `Stream<T>` are review-visible but not executable yet.
341+
Rules: `await` appears **only inside an `async fn`**. The executable v0.7 surface
342+
supports direct `await`, structured `task_group { async let ... }`, `select`,
343+
bounded channels, streams, and `await for` in the single-isolate cooperative
344+
model. There is no public `Future`/`Poll`/`spawn` surface; unstructured `spawn`,
345+
async closures, public task handles, and cross-isolate task execution remain
346+
future work.
342347

343348
---
344349

Makefile

Lines changed: 0 additions & 58 deletions
This file was deleted.

0 commit comments

Comments
 (0)