Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,12 @@ Prerequisites match what CI installs — see [`.github/workflows/test.yml`](.git

| Component | Version | Needed for |
|---|---|---|
| Rust | stable | Everything |
| Rust | stable (≥ 1.94) | Everything. The workspace pins no toolchain, so an older `stable` fails deep in the dependency graph with a `sqlx@0.9.0 requires rustc 1.94.0` MSRV error rather than a clear message — `rustup update stable` fixes it. |
| Rust nightly + `rust-src` | latest | tvOS / watchOS cross-compile only (`-Zbuild-std`) |
| Node.js | 22 | Parity tests (`run_parity_tests.sh`) |
| Node.js | see [`.node-version`](.node-version) | Parity tests (`run_parity_tests.sh`). Use that exact version — an older Node makes the harness classify tests `node_fail` and silently DROP them from the gate instead of failing. |
| C linker | any | Linking compiled binaries (`xcode-select --install` / `build-essential` / MSVC) |
| **libclang** | any | `bindgen`, via the `libsqlite3-sys` build script. Without it the build dies with `Unable to find libclang`. Debian/Ubuntu: `libclang-dev`; Fedora: `clang-devel`; Arch: `clang`. If it lives somewhere non-standard, point at it with `LIBCLANG_PATH=/path/to/dir` (and, if bindgen then can't find `stdarg.h`, `BINDGEN_EXTRA_CLANG_ARGS="-isystem /path/to/clang/<ver>/include"`). |
| clang | ≥ 15 | Perry's own LLVM codegen shells out to `clang -c`. Separate from the linker above — see the [installation guide](docs/src/getting-started/installation.md). `perry doctor` verifies it. |
Comment thread
coderabbitai[bot] marked this conversation as resolved.

Platform-specific extras — only required if you're touching that backend:

Expand Down
9 changes: 6 additions & 3 deletions benchmarks/compiler_output/workloads.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ schema_version = 1
source = "benchmarks/honest_bench/workloads/3_image_convolution/perry/image_conv.ts"
kind = "image_convolution"
allow_hot_loop_conversions = true
allowed_hot_loop_runtime_calls = ["js_gc_loop_safepoint"]

[workloads.image_convolution.vectorization]
min_vectorized_loops = 0
Expand All @@ -14,14 +15,15 @@ allowed_missed_reason_kinds = [
"not_beneficial",
"uncountable_loop",
"unknown_trip_count",
"unsupported_instruction",
"unsupported_reduction",
]

[workloads.image_convolution.runtime_budgets]
allocations_traced = 0
gc_collections_traced = 0
gc_collections_traced = 2
write_barriers_static = 0
write_barriers_traced = 0
write_barriers_traced = 1
boxed_number_allocations_static = 0
buffer_slow_path_accesses_static = 0

Expand Down Expand Up @@ -387,6 +389,7 @@ detail = "buffer_slow_path_calls"
[workloads.h1_native_rep_equivalence]
source = "benchmarks/compiler_output/fixtures/h1_native_rep_equivalence.ts"
kind = "native_rep"
allowed_hot_loop_runtime_calls = ["js_gc_loop_safepoint"]

[workloads.h1_native_rep_equivalence.vectorization]
min_vectorized_loops = 0
Expand Down Expand Up @@ -1307,7 +1310,7 @@ allowed_missed_reason_kinds = [
[workloads.scalar_replacement_literals.runtime_budgets]
allocations_traced = 100
gc_collections_traced = 0
write_barriers_static = 8
write_barriers_static = 10
write_barriers_traced = 8
boxed_number_allocations_static = 0
buffer_slow_path_accesses_static = 0
Expand Down
15 changes: 15 additions & 0 deletions changelog.d/6891-linux-verification-sweep.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
**`perry check` no longer passes unparseable code:** a file that failed to parse was reported only under `-v` and then skipped without recording a diagnostic, so `error_count()` stayed 0 and the command printed `All checks passed! - 0 file(s) checked` and exited 0 — while `perry compile` rejected the same file. Parse failures are now recorded as a `P001` diagnostic, so the text summary, the JSON `success` field and the exit code agree. (`perry check` had no exit-code test coverage; found while verifying a fresh Linux checkout.)

**Recovered three red CI gates on `main`:** split `perry-runtime/src/object/mod.rs` (2039 → 1709 lines) by extracting the #6812 spill/overflow storage into `object/spill.rs`, and `perry-stdlib/src/readline.rs` (2066 → 1994) by extracting the drain/pump + keypress decoding into `readline/pump.rs`, with visibility widened only enough to keep the existing `use super::*` sites resolving. Fixed the lone `cargo fmt --check` diff in `collect_modules.rs`, and refreshed the stale addr-class ratchet baseline.

**Recovered the compiler-output gate after the moving-nursery flip:** the native-region contracts now permit only the intentional `js_gc_loop_safepoint` call in otherwise runtime-free hot loops, and the image/scalar-replacement budgets record the moving collector's measured collection and root-barrier counts. Function-scoped IR checks now select functions by their definition line instead of also selecting any caller whose body mentions the target symbol; the old behavior made an unrelated `console.log` argument array look like a scalar-replacement heap allocation.

**Readline correctness fixes (review findings on the moved code):** raw-mode arrow keys work — the reader queues one byte per chunk, so `\x1b[A` arrived as three chunks and could never match the 3-byte CSI branch; the pump now reassembles escape sequences across chunks/ticks (a bare ESC flushes one tick later). `'readable'` listeners fire only when a tick delivers new data (plus once at EOF) instead of on every event-loop iteration forever. `rl.write()` actually writes to the output stream; `rl.pause()/resume()` now gate the stdin-backed interface (queued lines hold while paused); `rl.close()` stops subsequent `'line'` delivery; `process.stdin.destroy()` clears `readable` listeners too. GC hardening: line dispatch and prompt/write no longer run JS inside the `READLINE_INTERFACES` borrow (re-entrancy panic + skipped root scan), iterator/keypress/listener-attach paths root values in `RuntimeHandleScope` across allocating calls, and the readline root scanner is registered from every entry point that stores GC-visible state. Closed custom interfaces release their slot (handles are not reused). In `object/spill.rs`, the learned-inline-width hook moved off the steady-state write path (only high-water-raising writes probe TLS, learned widths unchanged).

**Fixed macOS low-address object classification and shape construction rooting:** mimalloc allocations in the Rust harness can land around 45 GB, below the obsolete 2 TB macOS floor, which made valid key arrays look invalid and left keypress-object named properties unreadable. macOS now uses the same guarded low heap floor as the other supported platforms. Shape-cache construction also roots the newborn object and in-progress key array across allocating key-string calls, and readline roots cloned listener snapshots before dispatch.

**Fixed three stale test assertions** (each verified byte-for-byte against Node 26.5.0 first — none was a real defect): perry-hir expected the `??=` RHS store as `PutValueSet` when lowering emits `PropertySet` for a plain member target; perry-codegen sliced only `fast.inner.body`..`fast.inner.exit` for the numeric stores, which #6812's spill lanes moved into the `fast.store.spill.*` / `fast.store.inline.*` successors (it now collects every `object_array_write.loop.fast.*` block); and perry-stdlib asserted `randomBytes` fires its callback synchronously after #6430 deliberately deferred it to a macrotask to match Node's libuv timing. Two of the three live in `crates/*/tests/*.rs`, which only run nightly/on tags — the #5960 blind spot.

**`run_parity_tests.sh` no longer reports false gap regressions under `PERRY_NO_AUTO_OPTIMIZE`:** the default `test-files/` suite linked the prebuilt `full` stdlib, which carries none of the `external-*` pump features, so every `events`/`http`/`net`/`fetch` test failed and surfaced as an untriaged NEW gap failure (7 of them, all passing with auto-optimize). `node-suite` already compensated; the default suite now builds the same wrapper crates and pump features. This matters locally because a cold auto-optimize run mints a ThinLTO variant per feature combination — measured at 12 variants / 71 GB after only 30 of 411 tests.

**Documented two build prerequisites that hard-fail a fresh checkout:** `libclang` (bindgen, via the `libsqlite3-sys` build script) and rustc ≥ 1.94 (sqlx 0.9.0's MSRV, which nothing in the workspace pins). `installation.md` also required "clang ≥ 15 for codegen" while every per-distro command below it installed no clang at all; the Node row now points at `.node-version` instead of a stale "22".
48 changes: 36 additions & 12 deletions crates/perry-codegen/tests/native_proof_regressions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13603,8 +13603,8 @@ fn mutable_string_key_rejects_static_write_pic() {
"a mutable key must retain dynamic PropertyKey semantics:\n{ir}"
);
assert!(
ir.contains("call double @js_put_value_set("),
"a mutable key must use the complete generic PutValue path:\n{ir}"
ir.contains("call double @js_put_value_set_dyn_ic("),
"a mutable key must use the dynamic-key PutValue path:\n{ir}"
);
}

Expand All @@ -13631,8 +13631,9 @@ fn static_put_value_rejects_write_pic_when_rhs_can_allocate() {
"an allocating RHS must stay on the rooted generic PutValue path"
);
assert!(
ir.contains("call double @js_put_value_set("),
"the rejected PIC case must retain the complete strict/sloppy runtime semantics:\n{ir}"
ir.contains("call double @js_put_value_set_dyn_ic("),
"the rejected static PIC case must retain sloppy-mode semantics through the \
dynamic-key fallback:\n{ir}"
Comment thread
proggeramlug marked this conversation as resolved.
);
}

Expand Down Expand Up @@ -13748,14 +13749,37 @@ fn nested_same_shape_object_writes_version_one_through_four_fields() {
&& ir.contains("object_array_write.loop.slow.preheader"),
"the proof must retain distinct call-free and semantic fallback clones:\n{ir}"
);
let fast_body = ir
.split("\nobject_array_write.loop.fast.inner.body")
.nth(1)
.and_then(|tail| {
tail.split("\nobject_array_write.loop.fast.inner.exit")
.next()
})
.expect("fast inner-loop block");
// Collect EVERY basic block of the fast clone rather than slicing the
// single `fast.inner.body` block. #6812's spill lanes made the inner
// body end in a `br` to `fast.store.spill.*` / `fast.store.inline.*`
// successors, so the numeric stores no longer live in the block the
// old `inner.body`..`inner.exit` slice captured — the assertions below
// then read a store-free body and failed even though the emitted code
// was correct. Keying on the `object_array_write.loop.fast.` label
// prefix keeps both invariants (call-free, N direct stores) checked
// across the whole fast region and is stable under block reordering.
let fast_body = {
let mut collected = String::new();
let mut in_fast_block = false;
for line in ir.lines() {
if let Some(label) = line.strip_suffix(':') {
if !label.starts_with(char::is_whitespace) && !label.contains(' ') {
in_fast_block = label.starts_with("object_array_write.loop.fast.");
continue;
}
}
if in_fast_block {
collected.push_str(line);
collected.push('\n');
}
}
assert!(
!collected.is_empty(),
"expected at least one object_array_write.loop.fast.* block:\n{ir}"
);
collected
};
let fast_body = fast_body.as_str();
assert!(
!fast_body.contains("call "),
"the successful raw-pointer clone must stay call/GC-free:\n{fast_body}"
Expand Down
11 changes: 9 additions & 2 deletions crates/perry-hir/tests/c262_parity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,9 +575,16 @@ fn logical_property_assignment_short_circuits_the_store_4586() {
"expected a property read on the LHS for `{src}`, got {left:?}"
);
// The single store lives on the RHS, so it is only evaluated when the
// short-circuit does NOT hold.
// short-circuit does NOT hold. Both store shapes satisfy that
// invariant: a plain member target lowers to `PropertySet`, while a
// parenthesized / `as`-cast target routes through `PutValueSet` so the
// const-immutability check runs (#6300). The property being asserted
// here is *where* the store sits, not which node encodes it.
assert!(
matches!(right.as_ref(), Expr::PutValueSet { .. }),
matches!(
right.as_ref(),
Expr::PutValueSet { .. } | Expr::PropertySet { .. }
),
"expected the store to live on the short-circuit RHS for `{src}`, got {right:?}"
);
}
Expand Down
9 changes: 6 additions & 3 deletions crates/perry-runtime/src/array/header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -507,8 +507,9 @@ pub(crate) fn test_template_raw_roots() -> (usize, usize) {
/// <= capacity <= 16M (same bound as the GC tracer's sanity guard).
#[inline(always)]
pub(crate) fn clean_arr_ptr(arr: *const ArrayHeader) -> *const ArrayHeader {
// Heap window varies by OS: macOS mimalloc lands in the 3-5 TB range;
// Android scudo + Linux glibc allocate MUCH lower (often < 1 TB); Windows
// Heap window varies by allocator and run: macOS mimalloc can land well
// below 2 TB (observed around 45 GB in the Rust test harness);
// Android scudo + Linux glibc also allocate MUCH lower (often < 1 TB); Windows
// mimalloc lands well under 1 TB (often in the GB-to-tens-of-GB range).
// iOS / tvOS / watchOS / visionOS *device* targets use libsystem_malloc
// (mimalloc is host-side only) and allocate in the same low range —
Expand All @@ -526,6 +527,7 @@ pub(crate) fn clean_arr_ptr(arr: *const ArrayHeader) -> *const ArrayHeader {
// GcHeader / obj_type validation downstream.
#[cfg(any(
target_os = "android",
target_os = "macos",
target_os = "linux",
target_os = "windows",
target_os = "ios",
Expand All @@ -536,14 +538,15 @@ pub(crate) fn clean_arr_ptr(arr: *const ArrayHeader) -> *const ArrayHeader {
const HEAP_MIN: u64 = 0x1000; // 4 KB (classic user-space floor)
#[cfg(not(any(
target_os = "android",
target_os = "macos",
target_os = "linux",
target_os = "windows",
target_os = "ios",
target_os = "tvos",
target_os = "watchos",
target_os = "visionos",
)))]
const HEAP_MIN: u64 = 0x200_0000_0000; // 2 TB — above observed corrupt handles on macOS
const HEAP_MIN: u64 = 0x200_0000_0000; // 2 TB — retained for unlisted targets
const HEAP_MAX: u64 = 0x8000_0000_0000; // 47-bit userspace cap
let bits = arr as u64;
let top16 = bits >> 48;
Expand Down
18 changes: 16 additions & 2 deletions crates/perry-runtime/src/object/alloc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -614,6 +614,11 @@ pub extern "C" fn js_object_alloc_with_shape(
crate::gc::layout_init_pointer_free(obj_ptr as *mut u8);
}

// A cache miss below allocates the keys array and every key string. Keep
// the newborn object live and reload it before installing the finished
// shape; otherwise a moving collection leaves `obj_ptr` in from-space.
let obj_scope = crate::gc::RuntimeHandleScope::new();
let obj_handle = obj_scope.root_raw_mut_ptr(obj_ptr);
let (cached, cached_runtime_id) = shape_cache_get_with_id(shape_id);
let (keys_arr, runtime_shape_id) = if !cached.is_null() {
(cached, cached_runtime_id)
Expand All @@ -627,12 +632,19 @@ pub extern "C" fn js_object_alloc_with_shape(
let num_keys = keys.len();
// Issue #179: shape-cache keys_array lives in the longlived arena.
let arr = crate::array::js_array_alloc_with_length_longlived(num_keys as u32);
let elements_ptr = unsafe { (arr as *mut u8).add(8) as *mut f64 };
// The array is not installed in the shape cache (and therefore not a
// scanner root) until every key has been allocated. A longlived-string
// allocation can collect in between, so root the in-progress array and
// reload it before each slot write.
let scope = crate::gc::RuntimeHandleScope::new();
let arr_handle = scope.root_raw_mut_ptr(arr);
for (i, key_bytes) in keys.iter().enumerate() {
let str_ptr = crate::string::js_string_from_bytes_longlived(
key_bytes.as_ptr(),
key_bytes.len() as u32,
);
let arr = arr_handle.get_raw_mut_ptr::<ArrayHeader>();
let elements_ptr = unsafe { (arr as *mut u8).add(8) as *mut f64 };
let nanboxed = f64::from_bits(
crate::value::STRING_TAG | (str_ptr as u64 & crate::value::POINTER_MASK),
);
Expand All @@ -642,11 +654,13 @@ pub extern "C" fn js_object_alloc_with_shape(
crate::array::note_array_slot_layout_only(arr, i, nanboxed.to_bits());
}
}
let arr = arr_handle.get_raw_mut_ptr::<ArrayHeader>();
shape_cache_insert(shape_id, arr);
(arr, shape_cache_get_with_id(shape_id).1)
};

unsafe {
let obj_ptr = obj_handle.get_raw_mut_ptr::<ObjectHeader>();
set_object_keys_array(obj_ptr, keys_arr);
// #6804: birth-stamp the runtime ShapeId (see `ShapeCacheEntry`) —
// newborn literals carry their stable identity immediately, so
Expand All @@ -657,7 +671,7 @@ pub extern "C" fn js_object_alloc_with_shape(
}
}

obj_ptr
obj_handle.get_raw_mut_ptr::<ObjectHeader>()
}

/// Clone a spread source object and reserve extra physical slot capacity for additional
Expand Down
Loading
Loading