mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-14 04:39:43 +08:00
* feat: support multi-instance library mode via runtime symbol localization - Add the abi.localize_runtime profile field: the archive build combines the program object with exactly the runtime/vendor members it reaches and demotes every external definition except the profile-declared symbols to a local symbol (darwin: one ld -r pass with -exported_symbols_list; linux: ld -r then objcopy --keep-global-symbols) - N archives built under pairwise-distinct prefixes now link into one process with no symbol collisions and no shared mutable runtime state: each instance owns a private copy of the allocator, collector, result arena, and panic sink, so sinks register per instance and a trap poisons only the instance it fired in - Document the embedder contract beside the profile spec: one thread per instance (an instance is never entered from two threads), and values cross instances only through the embedder's own byte/record marshalling - Refuse cross-target localized builds with SC3002 (the step runs the host toolchain's ld/objcopy over host-format objects); absent or false keeps the classic single-archive artifact byte-for-byte - Add the two-instance acceptance probe (two archives, two embedder threads, independent collects, a trap delivered to its own sink exactly once while the other instance keeps answering) plus symbol-exactness, profile-shape, and target-posture suites, and schedule the artifact contracts on the gate host * fix: tighten runtime localization validation * fix: harden localized library publication
22 lines
523 B
TypeScript
22 lines
523 B
TypeScript
// Multi-instance fixture, instance A (prefix ma_): mutable module state the
|
|
// probe advances from A's dedicated thread, plus a deliberately trapping
|
|
// export (array index OOB — the runtime's own range trap) that must reach
|
|
// ONLY this instance's sink.
|
|
let calls = 0;
|
|
|
|
export function bump(x: number): number {
|
|
calls++;
|
|
return x + calls;
|
|
}
|
|
|
|
export function callsSeen(): number {
|
|
return calls;
|
|
}
|
|
|
|
export function boom(i: number): number {
|
|
const xs = [1, 2, 3];
|
|
return xs[i]!;
|
|
}
|
|
|
|
console.log("multi-a ready");
|