mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-10-21 05:50:55 +08:00
The new @scriptc/threads package exports publish(value) and
sharesPublishedGraphs. Node.js runs its JavaScript: publish validates
the whole graph (plain objects, arrays, class instances, Maps, Sets and
primitives other than symbols), then deep-freezes it, and published Maps
and Sets reject mutation. scriptc builds lower both exports to
intrinsics and never compile the package body.
In scriptc, publish makes the graph immutable and immortal: a
compiler-emitted walker per static type (llvm/publish.ts) marks every
object rc == SIZE_MAX through a runtime worklist (scr_publish.c), so
retains, releases and the collector skip it and nothing frees it, and
the objects leave the collector's buffers. Hierarchy members dispatch on
the concrete class; arrays, maps, sets, strings and dyn subgraphs have
runtime walkers. Static types over-approximate a graph, so an
unpublishable type gets a refusing walker that fails only when a value
is present, and every mark is logged so a refusal restores the whole
graph, exactly like the Node implementation's validate-first order.
A typed-ref capsule over a published object travels through postMessage
and workerData as a pointer (a fresh capsule in the receiver; vtables,
adapters and type keys are process-wide); immortal dyn graphs inside a
message are shared the same way. Iterating a published map no longer
writes its iteration depth.
Stores into the static types a program publishes (computed by
backend/publication.ts, a class with its whole hierarchy) carry a guard
that throws Node's frozen-object TypeErrors, and may-throw counts them.
The corpus program pins the contract against Node: shared and cyclic
class graphs with arrays, maps, sets and records read identically on
both threads, every write form fails with Node's message, unpublished
instances of the same classes stay writable, a refused publish leaves
its graph unchanged, and a worker-published graph reaches the main
thread. packages/threads/README.md documents the contract and the
differences (prototypes and identity across messages).
Each mark records its object kind, so a successful publish takes the
objects out of the RC audit's live counts (immortal objects are never
freed).
Dates (time values) and process streams (descriptors) are scalars in
scriptc, so their walkers refuse a date field or root directly instead
of pushing its bits as a pointer; the refusal corpus program pins the
statically typed refusals (date, function, RegExp, typed array and Error
values in class and record fields, and a date root) against Node.
Main lowers a discarded or union-typed `xs.pop()` to a length
truncation; those stores now carry a `pop` marker so a published array
fails with pop's own TypeError ("Cannot delete property 'N'", or the
length message for an empty array, whose `length = 0` store the emitter
drops unless the array type can be published).
50 lines
2.3 KiB
JSON
50 lines
2.3 KiB
JSON
{
|
|
"name": "scriptc-monorepo",
|
|
"private": true,
|
|
"engines": {
|
|
"node": ">=24.0.0"
|
|
},
|
|
"scripts": {
|
|
"build": "pnpm -r --filter \"./packages/*\" run build",
|
|
"build:fresh": "rm -rf packages/compiler/dist packages/cli/dist node_modules/.cache/scriptc-tsc && pnpm build",
|
|
"build:native-compiler": "node --max-old-space-size=8192 --import tsx scripts/build-native-cli.mts",
|
|
"bench:builds": "node scripts/bench-builds.mjs",
|
|
"bench:runtime": "node scripts/bench-runtime.mjs",
|
|
"bench:ast-access": "node scripts/bench-ast-access.mjs",
|
|
"bench:backend-analysis": "node scripts/bench-backend-analysis.mjs",
|
|
"test": "vitest run",
|
|
"test:ts7": "node scripts/test-ts7.mjs",
|
|
"generate:ts7-ast": "node scripts/generate-ts7-ast-schema.mjs",
|
|
"test:fetch-conformance": "vitest run tests/harness/fetch-conformance.test.ts",
|
|
"test:test262": "tsx tests/test262/run.ts",
|
|
"test:test262:fetch": "node tests/test262/fetch.mjs",
|
|
"test:cache-identity": "node tests/harness/cache-identity.mjs",
|
|
"test:sandbox": "node scripts/sandbox-test.mjs",
|
|
"test:sandbox:image": "node scripts/sandbox-image.mjs",
|
|
"test:watch": "vitest",
|
|
"lint": "oxlint --deny-warnings packages scripts internal/compatibility/src tests/harness vitest.config.ts",
|
|
"lint:fix": "pnpm lint --fix",
|
|
"format": "oxfmt --write \"{packages,scripts,internal/compatibility/src,tests/harness}/**/*.{js,mjs,cjs,ts,mts,cts,tsx}\" vitest.config.ts .oxlintrc.jsonc .oxfmtrc.jsonc",
|
|
"format:check": "oxfmt --check \"{packages,scripts,internal/compatibility/src,tests/harness}/**/*.{js,mjs,cjs,ts,mts,cts,tsx}\" vitest.config.ts .oxlintrc.jsonc .oxfmtrc.jsonc",
|
|
"manifest": "tsx scripts/surface-manifest.mjs",
|
|
"node-compat": "pnpm --filter @internal/compatibility run update",
|
|
"node-compat:backlog": "pnpm --filter @internal/compatibility run backlog --",
|
|
"node-compat:check": "pnpm --filter @internal/compatibility run check",
|
|
"scriptc": "tsx packages/cli/src/main.ts"
|
|
},
|
|
"devDependencies": {
|
|
"@scriptc/threads": "workspace:*",
|
|
"@types/node": "^24.0.0",
|
|
"effect": "3.22.2",
|
|
"js-yaml": "4.3.0",
|
|
"oxfmt": "0.71.0",
|
|
"oxlint": "1.86.0",
|
|
"rollup": "4.62.2",
|
|
"three": "0.186.1",
|
|
"tsx": "^4.19.0",
|
|
"typescript": "5.9.3",
|
|
"vercel": "58.1.0",
|
|
"vitest": "^3.0.0"
|
|
}
|
|
}
|