You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Browse filesBrowse the repository at this point in the historyBrowse files
authored
fix(runtime): #5552 demote unique strings in remaining array insert paths (unshift / fill / with / from_jsvalue) (#5567)
* fix(runtime): #5552 demote unique strings in remaining array insert paths
Follow-up to #5533 (object fields) and #5548 (the array store paths it
enumerated). A uniquely-owned (refcount==1) heap string written into an array
element aliases that slot, so a later in-place `s += x` on the source local
(`js_string_append`'s refcount==1 fast path) rewrites the stored element and
corrupts it. #5548 fixed the push / set / from_values / splice-insert paths; the
sibling insert/replace paths below do the same raw element write without the
demote.
Apply the same tag-checked `js_string_addref_if_heap_string` (no-op for SSO /
non-string, idempotent) before the element write at each:
- `js_array_unshift_f64` (covers `js_array_unshift_jsvalue` transitively) and the
per-item loop in `js_array_unshift_variadic`.
- `js_array_fill` / `js_array_fill_range` (demote once before the fill loop — the
source aliases every filled slot) and `js_array_fill_generic` (its
object-receiver loop writes `value` into each index directly; the array
receiver delegates to the two above, so the extra demote is idempotent).
- `js_array_with` (the replacement value stored into the new array's slot; the
cloned elements are already shared).
- `js_array_from_jsvalue` (mixed-type literal construction — the JSValue sibling
of the already-covered `js_array_from_values`).
Internal reshuffles (sort, splice tail shift, slice copy, copyWithin) only move
values already stored in an array — already shared — so no demote is needed.
Tests: `string_append_heap_alias.rs` gains compile-run regressions for unshift /
fill / with, each confirmed to fail without the demote. `js_array_from_jsvalue`
is not emitted by codegen from any TypeScript source, so it gets a runtime unit
test (`array/tests.rs`) instead, also confirmed to fail without the demote.
Refs #5533, #5548.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
* fix(runtime): restore GC_STORE_AUDIT marker on unshift_variadic insert write
The #5552 demote line pushed the ptr::write past the proximity window of the
existing GC_STORE_AUDIT(BARRIERED) marker, failing the lint job's GC store-site
inventory check. Re-annotate the insert write directly.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
---------
Co-authored-by: Ralph <ralph@skelpo.com>
Co-authored-by: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
0 commit comments