@scriptc/compiler 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ambient/scriptc-node-fallback.d.ts +258 -64
- package/dist/backend/c/async.d.ts +30 -0
- package/dist/backend/c/async.js +224 -0
- package/dist/backend/c/async.js.map +1 -1
- package/dist/backend/c/c-emitter.d.ts +13 -0
- package/dist/backend/c/c-emitter.js +28 -9
- package/dist/backend/c/c-emitter.js.map +1 -1
- package/dist/backend/c/exprs.d.ts +8 -1
- package/dist/backend/c/exprs.js +445 -60
- package/dist/backend/c/exprs.js.map +1 -1
- package/dist/backend/c/shapes.js +15 -13
- package/dist/backend/c/shapes.js.map +1 -1
- package/dist/backend/c/types.d.ts +4 -0
- package/dist/backend/c/types.js +20 -1
- package/dist/backend/c/types.js.map +1 -1
- package/dist/backend/c/types.test.js +8 -1
- package/dist/backend/c/types.test.js.map +1 -1
- package/dist/backend/c/walkers.js +32 -11
- package/dist/backend/c/walkers.js.map +1 -1
- package/dist/backend/json-literal.d.ts +7 -0
- package/dist/backend/json-literal.js +17 -0
- package/dist/backend/json-literal.js.map +1 -0
- package/dist/backend/json-literal.test.d.ts +1 -0
- package/dist/backend/json-literal.test.js +17 -0
- package/dist/backend/json-literal.test.js.map +1 -0
- package/dist/backend/link-plan.d.ts +2 -1
- package/dist/backend/link-plan.js +6 -1
- package/dist/backend/link-plan.js.map +1 -1
- package/dist/backend/llvm/classes.js +8 -7
- package/dist/backend/llvm/classes.js.map +1 -1
- package/dist/backend/llvm/common.d.ts +4 -0
- package/dist/backend/llvm/common.js +6 -0
- package/dist/backend/llvm/common.js.map +1 -1
- package/dist/backend/llvm/common.test.d.ts +1 -0
- package/dist/backend/llvm/common.test.js +9 -0
- package/dist/backend/llvm/common.test.js.map +1 -0
- package/dist/backend/llvm/dyn.d.ts +4 -0
- package/dist/backend/llvm/dyn.js +24 -13
- package/dist/backend/llvm/dyn.js.map +1 -1
- package/dist/backend/llvm/emitter.js +54 -12
- package/dist/backend/llvm/emitter.js.map +1 -1
- package/dist/backend/llvm/expr-bytes.d.ts +1 -1
- package/dist/backend/llvm/expr-bytes.js +8 -8
- package/dist/backend/llvm/expr-bytes.js.map +1 -1
- package/dist/backend/llvm/expr-callbacks.d.ts +9 -0
- package/dist/backend/llvm/expr-callbacks.js +125 -0
- package/dist/backend/llvm/expr-callbacks.js.map +1 -1
- package/dist/backend/llvm/expr-context.d.ts +18 -2
- package/dist/backend/llvm/expr-dispatch.js +1 -0
- package/dist/backend/llvm/expr-dispatch.js.map +1 -1
- package/dist/backend/llvm/expr-dynamic.js +9 -0
- package/dist/backend/llvm/expr-dynamic.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.d.ts +1 -1
- package/dist/backend/llvm/expr-primitives.js +38 -9
- package/dist/backend/llvm/expr-primitives.js.map +1 -1
- package/dist/backend/llvm/expr-primitives.test.d.ts +1 -0
- package/dist/backend/llvm/expr-primitives.test.js +38 -0
- package/dist/backend/llvm/expr-primitives.test.js.map +1 -0
- package/dist/backend/llvm/expr-records.js +3 -3
- package/dist/backend/llvm/expr-records.js.map +1 -1
- package/dist/backend/llvm/expr-stream-bridges.js +2 -1
- package/dist/backend/llvm/expr-stream-bridges.js.map +1 -1
- package/dist/backend/llvm/expr-stream-callbacks.d.ts +6 -0
- package/dist/backend/llvm/expr-stream-callbacks.js +122 -0
- package/dist/backend/llvm/expr-stream-callbacks.js.map +1 -1
- package/dist/backend/llvm/lib-dispatch.js +22 -0
- package/dist/backend/llvm/lib-dispatch.js.map +1 -1
- package/dist/backend/llvm/lib-filesystem.js +68 -10
- package/dist/backend/llvm/lib-filesystem.js.map +1 -1
- package/dist/backend/llvm/lib-network.js +18 -2
- package/dist/backend/llvm/lib-network.js.map +1 -1
- package/dist/backend/llvm/lib-process.js +206 -11
- package/dist/backend/llvm/lib-process.js.map +1 -1
- package/dist/backend/llvm/lib-shared.js +82 -0
- package/dist/backend/llvm/lib-shared.js.map +1 -1
- package/dist/backend/llvm/lib-stream.js +23 -0
- package/dist/backend/llvm/lib-stream.js.map +1 -1
- package/dist/backend/llvm/shapes.js +10 -8
- package/dist/backend/llvm/shapes.js.map +1 -1
- package/dist/backend/llvm/walkers.js +7 -5
- package/dist/backend/llvm/walkers.js.map +1 -1
- package/dist/backend/native-link-info.d.ts +2 -1
- package/dist/backend/native-link-info.js +4 -0
- package/dist/backend/native-link-info.js.map +1 -1
- package/dist/backend/native-link-info.test.js +24 -1
- package/dist/backend/native-link-info.test.js.map +1 -1
- package/dist/backend/native-toolchain.d.ts +11 -6
- package/dist/backend/native-toolchain.js +30 -13
- package/dist/backend/native-toolchain.js.map +1 -1
- package/dist/backend/native-toolchain.test.js +36 -1
- package/dist/backend/native-toolchain.test.js.map +1 -1
- package/dist/backend/runtime-pack-targets.test.js +1 -1
- package/dist/backend/runtime-pack-targets.test.js.map +1 -1
- package/dist/backend/runtime-pack.test.js +29 -10
- package/dist/backend/runtime-pack.test.js.map +1 -1
- package/dist/backend/targets.d.ts +9 -0
- package/dist/backend/targets.js +22 -0
- package/dist/backend/targets.js.map +1 -1
- package/dist/backend/targets.test.js +13 -1
- package/dist/backend/targets.test.js.map +1 -1
- package/dist/coverage/surface-manifest.js +9 -0
- package/dist/coverage/surface-manifest.js.map +1 -1
- package/dist/diagnostics/diagnostic.js +4 -4
- package/dist/diagnostics/diagnostic.js.map +1 -1
- package/dist/executable/executable-cache.d.ts +3 -0
- package/dist/executable/executable-cache.js +4 -0
- package/dist/executable/executable-cache.js.map +1 -1
- package/dist/executable/executable-cache.test.js +1 -0
- package/dist/executable/executable-cache.test.js.map +1 -1
- package/dist/frontend/fork-target.d.ts +17 -0
- package/dist/frontend/fork-target.js +256 -0
- package/dist/frontend/fork-target.js.map +1 -0
- package/dist/frontend/lowering/abstract-equality.d.ts +6 -0
- package/dist/frontend/lowering/abstract-equality.js +250 -0
- package/dist/frontend/lowering/abstract-equality.js.map +1 -0
- package/dist/frontend/lowering/containers/bytes.d.ts +0 -4
- package/dist/frontend/lowering/containers/bytes.js +112 -28
- package/dist/frontend/lowering/containers/bytes.js.map +1 -1
- package/dist/frontend/lowering/lower-assert.js +87 -12
- package/dist/frontend/lowering/lower-assert.js.map +1 -1
- package/dist/frontend/lowering/lower-builtins.d.ts +72 -44
- package/dist/frontend/lowering/lower-builtins.js +1323 -165
- package/dist/frontend/lowering/lower-builtins.js.map +1 -1
- package/dist/frontend/lowering/lower-calls.d.ts +37 -27
- package/dist/frontend/lowering/lower-calls.js +682 -132
- package/dist/frontend/lowering/lower-calls.js.map +1 -1
- package/dist/frontend/lowering/lower-classes.js +39 -8
- package/dist/frontend/lowering/lower-classes.js.map +1 -1
- package/dist/frontend/lowering/lower-containers.js +162 -8
- package/dist/frontend/lowering/lower-containers.js.map +1 -1
- package/dist/frontend/lowering/lower-event-emitter.js +212 -21
- package/dist/frontend/lowering/lower-event-emitter.js.map +1 -1
- package/dist/frontend/lowering/lower-exprs.js +238 -87
- package/dist/frontend/lowering/lower-exprs.js.map +1 -1
- package/dist/frontend/lowering/lower-inspect.d.ts +4 -0
- package/dist/frontend/lowering/lower-inspect.js +8 -1
- package/dist/frontend/lowering/lower-inspect.js.map +1 -1
- package/dist/frontend/lowering/lower-island.d.ts +6 -3
- package/dist/frontend/lowering/lower-island.js +165 -6
- package/dist/frontend/lowering/lower-island.js.map +1 -1
- package/dist/frontend/lowering/lower-modules.d.ts +6 -0
- package/dist/frontend/lowering/lower-modules.js +192 -38
- package/dist/frontend/lowering/lower-modules.js.map +1 -1
- package/dist/frontend/lowering/lower-namespaces.js +7 -0
- package/dist/frontend/lowering/lower-namespaces.js.map +1 -1
- package/dist/frontend/lowering/lower-server.d.ts +1 -1
- package/dist/frontend/lowering/lower-server.js +130 -27
- package/dist/frontend/lowering/lower-server.js.map +1 -1
- package/dist/frontend/lowering/lower-stmts.d.ts +5 -4
- package/dist/frontend/lowering/lower-stmts.js +141 -21
- package/dist/frontend/lowering/lower-stmts.js.map +1 -1
- package/dist/frontend/lowering/lower-stream.d.ts +3 -0
- package/dist/frontend/lowering/lower-stream.js +7 -0
- package/dist/frontend/lowering/lower-stream.js.map +1 -1
- package/dist/frontend/lowering/lowerer.d.ts +90 -13
- package/dist/frontend/lowering/lowerer.js +416 -76
- package/dist/frontend/lowering/lowerer.js.map +1 -1
- package/dist/frontend/lowering/surfaces.d.ts +31 -3
- package/dist/frontend/lowering/surfaces.js +173 -90
- package/dist/frontend/lowering/surfaces.js.map +1 -1
- package/dist/frontend/npm-static-declarations.d.ts +4 -0
- package/dist/frontend/npm-static-declarations.js +83 -14
- package/dist/frontend/npm-static-declarations.js.map +1 -1
- package/dist/frontend/npm-static-declarations.test.js +33 -2
- package/dist/frontend/npm-static-declarations.test.js.map +1 -1
- package/dist/frontend/npm-static.js +6 -5
- package/dist/frontend/npm-static.js.map +1 -1
- package/dist/frontend/npm.d.ts +15 -3
- package/dist/frontend/npm.js +80 -8
- package/dist/frontend/npm.js.map +1 -1
- package/dist/frontend/npm.test.js +76 -9
- package/dist/frontend/npm.test.js.map +1 -1
- package/dist/frontend/program.js +110 -12
- package/dist/frontend/program.js.map +1 -1
- package/dist/frontend/resolve.d.ts +28 -7
- package/dist/frontend/resolve.js +90 -26
- package/dist/frontend/resolve.js.map +1 -1
- package/dist/frontend/resolve.test.js +21 -1
- package/dist/frontend/resolve.test.js.map +1 -1
- package/dist/frontend/type-mapper.d.ts +5 -0
- package/dist/frontend/type-mapper.js +115 -33
- package/dist/frontend/type-mapper.js.map +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +30 -3
- package/dist/index.js.map +1 -1
- package/dist/ir/analysis.js +1 -0
- package/dist/ir/analysis.js.map +1 -1
- package/dist/ir/ir.d.ts +155 -66
- package/dist/ir/ir.js +143 -6
- package/dist/ir/ir.js.map +1 -1
- package/dist/ir/ir.test.js +14 -1
- package/dist/ir/ir.test.js.map +1 -1
- package/dist/ir/serialize.d.ts +1 -1
- package/dist/ir/serialize.js +1 -1
- package/dist/ir/serialize.js.map +1 -1
- package/dist/ir/validate.js +242 -18
- package/dist/ir/validate.js.map +1 -1
- package/dist/library/int-infer.test.js +4 -4
- package/dist/library/int-infer.test.js.map +1 -1
- package/dist/library/library-cache.d.ts +1 -0
- package/dist/library/library-cache.js +1 -0
- package/dist/library/library-cache.js.map +1 -1
- package/dist/library/library-cache.test.js +18 -5
- package/dist/library/library-cache.test.js.map +1 -1
- package/package.json +17 -17
- package/surface-manifest.json +163 -54
package/dist/ir/ir.js
CHANGED
|
@@ -14,8 +14,11 @@ const POINTER_HANDLE_KINDS = [
|
|
|
14
14
|
"httpRes",
|
|
15
15
|
"httpClientReq",
|
|
16
16
|
"secureCtx",
|
|
17
|
+
"cryptoHash",
|
|
18
|
+
"cryptoHmac",
|
|
17
19
|
"fsWatcher",
|
|
18
20
|
"childStream",
|
|
21
|
+
"childWriter",
|
|
19
22
|
];
|
|
20
23
|
function irKindSet(kinds) {
|
|
21
24
|
return new Set(kinds);
|
|
@@ -30,6 +33,7 @@ export const HANDLE_KINDS = irKindSet(HANDLE_KIND_LIST);
|
|
|
30
33
|
/** The IR kinds represented as pointers in both native backends. */
|
|
31
34
|
const POINTER_KIND_LIST = [
|
|
32
35
|
"string",
|
|
36
|
+
"bigint",
|
|
33
37
|
"array",
|
|
34
38
|
"map",
|
|
35
39
|
"set",
|
|
@@ -42,6 +46,7 @@ const POINTER_KIND_LIST = [
|
|
|
42
46
|
"func",
|
|
43
47
|
"object",
|
|
44
48
|
"classval",
|
|
49
|
+
"moduleNs",
|
|
45
50
|
"record",
|
|
46
51
|
"union",
|
|
47
52
|
"dyn",
|
|
@@ -57,6 +62,7 @@ export const POINTER_KINDS = irKindSet(POINTER_KIND_LIST);
|
|
|
57
62
|
* until its one retain/release family is named here. */
|
|
58
63
|
export const RUNTIME_RC_STEMS = {
|
|
59
64
|
f64: "",
|
|
65
|
+
bigint: "scr_bigint",
|
|
60
66
|
date: "",
|
|
61
67
|
string: "scr_str",
|
|
62
68
|
bool: "",
|
|
@@ -82,12 +88,16 @@ export const RUNTIME_RC_STEMS = {
|
|
|
82
88
|
httpRes: "scr_http_res",
|
|
83
89
|
httpClientReq: "scr_http_client",
|
|
84
90
|
childStream: "scr_child_stream",
|
|
91
|
+
childWriter: "scr_child_writer",
|
|
85
92
|
procStream: "",
|
|
86
93
|
fsWatcher: "scr_watcher",
|
|
87
94
|
secureCtx: "scr_secure_ctx",
|
|
95
|
+
cryptoHash: "scr_crypto_hash",
|
|
96
|
+
cryptoHmac: "scr_crypto_hash",
|
|
88
97
|
func: "scr_closure",
|
|
89
98
|
object: "",
|
|
90
99
|
classval: "scr_classobj",
|
|
100
|
+
moduleNs: "scr_str",
|
|
91
101
|
record: "",
|
|
92
102
|
union: "scr_union",
|
|
93
103
|
dyn: "scr_dyn",
|
|
@@ -124,13 +134,16 @@ export const REF_TRUTHY_KINDS = new Set([
|
|
|
124
134
|
"symbol",
|
|
125
135
|
"date", "array", "map", "set", "regex", "url", "searchParams", "stats", "fileHandle", "spawnRes", "child",
|
|
126
136
|
"netServer", "netSocket", "http2Session", "http2Stream", "dgramSocket", "testCtx", "httpReq", "httpRes", "httpClientReq",
|
|
127
|
-
"secureCtx", "fsWatcher", "childStream", "procStream", "bytes", "func", "object", "record", "promise",
|
|
137
|
+
"secureCtx", "cryptoHash", "cryptoHmac", "fsWatcher", "childStream", "childWriter", "procStream", "bytes", "func", "object", "record", "promise",
|
|
128
138
|
// A generator object is a JS object: always truthy.
|
|
129
139
|
"generator",
|
|
130
140
|
// A class object is a JS object (constructors are functions): always truthy.
|
|
131
141
|
"classval",
|
|
142
|
+
// A module namespace object is always truthy.
|
|
143
|
+
"moduleNs",
|
|
132
144
|
]);
|
|
133
145
|
export const F64 = { kind: "f64" };
|
|
146
|
+
export const BIGINT_T = { kind: "bigint" };
|
|
134
147
|
export const DATE_T = { kind: "date" };
|
|
135
148
|
export const BYTES_U8 = { kind: "bytes", elem: "u8" };
|
|
136
149
|
export const STRING = { kind: "string" };
|
|
@@ -153,8 +166,11 @@ export const HTTPREQ_T = { kind: "httpReq" };
|
|
|
153
166
|
export const HTTPRES_T = { kind: "httpRes" };
|
|
154
167
|
export const HTTPCLIENTREQ_T = { kind: "httpClientReq" };
|
|
155
168
|
export const SECURECTX_T = { kind: "secureCtx" };
|
|
169
|
+
export const CRYPTOHASH_T = { kind: "cryptoHash" };
|
|
170
|
+
export const CRYPTOHMAC_T = { kind: "cryptoHmac" };
|
|
156
171
|
export const FSWATCHER_T = { kind: "fsWatcher" };
|
|
157
172
|
export const CHILDSTREAM_T = { kind: "childStream" };
|
|
173
|
+
export const CHILDWRITER_T = { kind: "childWriter" };
|
|
158
174
|
export const PROCSTREAM_T = { kind: "procStream" };
|
|
159
175
|
export const VOID = { kind: "void" };
|
|
160
176
|
export const DYN = { kind: "dyn" };
|
|
@@ -177,6 +193,7 @@ export function isUnitType(t) {
|
|
|
177
193
|
export function isSupportedArrayElem(t) {
|
|
178
194
|
switch (t.kind) {
|
|
179
195
|
case "f64":
|
|
196
|
+
case "bigint":
|
|
180
197
|
case "bool":
|
|
181
198
|
case "string":
|
|
182
199
|
case "array":
|
|
@@ -192,6 +209,7 @@ export function isSupportedArrayElem(t) {
|
|
|
192
209
|
case "netServer":
|
|
193
210
|
case "symbol":
|
|
194
211
|
case "classval":
|
|
212
|
+
case "moduleNs":
|
|
195
213
|
return true;
|
|
196
214
|
default:
|
|
197
215
|
return false;
|
|
@@ -239,6 +257,7 @@ export function isSupportedSetElem(t) {
|
|
|
239
257
|
export function isSupportedMapValue(t) {
|
|
240
258
|
switch (t.kind) {
|
|
241
259
|
case "f64":
|
|
260
|
+
case "bigint":
|
|
242
261
|
case "string":
|
|
243
262
|
case "bool":
|
|
244
263
|
case "record":
|
|
@@ -329,6 +348,7 @@ export function typeKey(t) {
|
|
|
329
348
|
return t.kind;
|
|
330
349
|
switch (t.kind) {
|
|
331
350
|
case "f64":
|
|
351
|
+
case "bigint":
|
|
332
352
|
case "date":
|
|
333
353
|
case "string":
|
|
334
354
|
case "bool":
|
|
@@ -354,11 +374,13 @@ export function typeKey(t) {
|
|
|
354
374
|
case "set":
|
|
355
375
|
return `set<${typeKey(t.elem)}>`;
|
|
356
376
|
case "func":
|
|
357
|
-
return `func(${[...t.params.map(typeKey), ...(t.rest ? [t.restAbi === "jsval" ? "...jsval[]" : "...dyn[]"] : [])].join(",")})=>${typeKey(t.ret)}`;
|
|
377
|
+
return `func(${[...t.params.map(typeKey), ...(t.rest ? [t.restAbi === "jsval" ? "...jsval[]" : t.restAbi === "typed" ? "...typed[]" : "...dyn[]"] : [])].join(",")})=>${typeKey(t.ret)}`;
|
|
358
378
|
case "object":
|
|
359
379
|
return `object:${t.className}`;
|
|
360
380
|
case "classval":
|
|
361
381
|
return `classval:${t.className}`;
|
|
382
|
+
case "moduleNs":
|
|
383
|
+
return `moduleNs:${t.moduleId}`;
|
|
362
384
|
case "record":
|
|
363
385
|
return `record:${t.shapeId}`;
|
|
364
386
|
case "union":
|
|
@@ -388,6 +410,7 @@ export function typeEquals(a, b) {
|
|
|
388
410
|
return (b.kind === "func" &&
|
|
389
411
|
a.params.length === b.params.length &&
|
|
390
412
|
(a.rest === true) === (b.rest === true) &&
|
|
413
|
+
a.restAbi === b.restAbi &&
|
|
391
414
|
a.params.every((p, i) => typeEquals(p, b.params[i])) &&
|
|
392
415
|
typeEquals(a.ret, b.ret));
|
|
393
416
|
}
|
|
@@ -395,6 +418,8 @@ export function typeEquals(a, b) {
|
|
|
395
418
|
return b.kind === "object" && a.className === b.className;
|
|
396
419
|
if (a.kind === "classval")
|
|
397
420
|
return b.kind === "classval" && a.className === b.className;
|
|
421
|
+
if (a.kind === "moduleNs")
|
|
422
|
+
return b.kind === "moduleNs" && a.moduleId === b.moduleId;
|
|
398
423
|
// The frontend deduplicates shapes structurally (one shapeId per canonical
|
|
399
424
|
// field list), so id equality IS structural equality.
|
|
400
425
|
if (a.kind === "record")
|
|
@@ -746,6 +771,7 @@ function isJsonSafeAt(t, getRecord, getUnion, stringify, undefinedAllowed, visit
|
|
|
746
771
|
// Symbols are DROPPED by Node's stringify (undefined at the top level,
|
|
747
772
|
// omitted as object values) — silent divergence banned; rejected.
|
|
748
773
|
case "symbol":
|
|
774
|
+
case "bigint":
|
|
749
775
|
// Typed arrays stringify as index-keyed objects ({"0":1,...}) and
|
|
750
776
|
// Buffers as {type:"Buffer",data:[...]} in Node — neither shape is
|
|
751
777
|
// representable type-directedly; rejected like Maps.
|
|
@@ -755,6 +781,7 @@ function isJsonSafeAt(t, getRecord, getUnion, stringify, undefinedAllowed, visit
|
|
|
755
781
|
case "caught":
|
|
756
782
|
case "promise":
|
|
757
783
|
case "generator":
|
|
784
|
+
case "moduleNs":
|
|
758
785
|
case "void":
|
|
759
786
|
return false;
|
|
760
787
|
// Record fields drop undefined. Stringification also represents it in
|
|
@@ -1065,6 +1092,10 @@ export function canDynCheckTo(t, getRecord, getUnion) {
|
|
|
1065
1092
|
* back). */
|
|
1066
1093
|
export function canBoxFuncIntoDyn(t, getRecord, getUnion) {
|
|
1067
1094
|
return (t.kind === "func" &&
|
|
1095
|
+
// Only the legacy hidden-dyn rest ABI has a checked-dynamic call thunk.
|
|
1096
|
+
// Typed rest stays static (its trailing array is compiler-packed), and
|
|
1097
|
+
// island rest has its separate engine host-callback adapter.
|
|
1098
|
+
(t.rest !== true || t.restAbi === undefined) &&
|
|
1068
1099
|
// A jsval (island) param converts through scr_jsval_from_dyn in the
|
|
1069
1100
|
// thunk (wrapped cells unwrap by reference, dyn data deep-copies) —
|
|
1070
1101
|
// the checker-'any' callback params of the routed-dispatch lane
|
|
@@ -1630,11 +1661,14 @@ export function moduleUsesChildProcess(mod) {
|
|
|
1630
1661
|
const node = v;
|
|
1631
1662
|
if (node.kind === "libCall" &&
|
|
1632
1663
|
typeof node.fn === "string" &&
|
|
1633
|
-
(node.fn.startsWith("cp.") || node.fn.startsWith("child.") || node.fn.startsWith("spawnRes.")
|
|
1664
|
+
(node.fn.startsWith("cp.") || node.fn.startsWith("child.") || node.fn.startsWith("writer.") || node.fn.startsWith("spawnRes.") ||
|
|
1665
|
+
node.fn === "process.forkTarget" || node.fn === "process.connected" || node.fn === "process.send" ||
|
|
1666
|
+
node.fn === "process.sendCb" || node.fn === "process.disconnect" || node.fn === "process.onMessage" ||
|
|
1667
|
+
node.fn === "process.onDisconnect")) {
|
|
1634
1668
|
found = true;
|
|
1635
1669
|
return;
|
|
1636
1670
|
}
|
|
1637
|
-
if (node.kind === "child" || node.kind === "childStream" || node.kind === "spawnRes") {
|
|
1671
|
+
if (node.kind === "child" || node.kind === "childStream" || node.kind === "childWriter" || node.kind === "spawnRes") {
|
|
1638
1672
|
found = true;
|
|
1639
1673
|
return;
|
|
1640
1674
|
}
|
|
@@ -1719,6 +1753,31 @@ export function moduleUsesSymbol(mod) {
|
|
|
1719
1753
|
visit(mod);
|
|
1720
1754
|
return found;
|
|
1721
1755
|
}
|
|
1756
|
+
/** True when bigint runtime operations or bigint-typed storage appears in
|
|
1757
|
+
* the IR. The type check keeps retain/release references link-safe even
|
|
1758
|
+
* when a producing statement was replaced by a runtime fence. */
|
|
1759
|
+
export function moduleUsesBigInt(mod) {
|
|
1760
|
+
let found = false;
|
|
1761
|
+
const visit = (v) => {
|
|
1762
|
+
if (found || v === null || typeof v !== "object")
|
|
1763
|
+
return;
|
|
1764
|
+
if (Array.isArray(v)) {
|
|
1765
|
+
for (const item of v)
|
|
1766
|
+
visit(item);
|
|
1767
|
+
return;
|
|
1768
|
+
}
|
|
1769
|
+
const node = v;
|
|
1770
|
+
if (node.kind === "bigint" ||
|
|
1771
|
+
(node.kind === "libCall" && typeof node.fn === "string" && node.fn.startsWith("bigint."))) {
|
|
1772
|
+
found = true;
|
|
1773
|
+
return;
|
|
1774
|
+
}
|
|
1775
|
+
for (const key of Object.keys(v))
|
|
1776
|
+
visit(v[key]);
|
|
1777
|
+
};
|
|
1778
|
+
visit(mod);
|
|
1779
|
+
return found;
|
|
1780
|
+
}
|
|
1722
1781
|
/** True when the module uses the URLSearchParams surface — sp.* libCalls,
|
|
1723
1782
|
* the url.searchParams getter, or a searchParams-kind type anywhere on
|
|
1724
1783
|
* the IR (a fenced statement can leave a typed local whose release call
|
|
@@ -2056,6 +2115,13 @@ const LIB_MODE_REFUSED_PREFIXES = [
|
|
|
2056
2115
|
// exclude — refuse the surface like the rest of the event-loop family.
|
|
2057
2116
|
["fs.existsChk", "the async fs callback surface (fs.exists)"],
|
|
2058
2117
|
["fs.renameCb", "the async fs callback surface (fs.rename)"],
|
|
2118
|
+
["zlib.deflateCb", "the async node:zlib callback surface"],
|
|
2119
|
+
["zlib.inflateCb", "the async node:zlib callback surface"],
|
|
2120
|
+
["zlib.deflateRawCb", "the async node:zlib callback surface"],
|
|
2121
|
+
["zlib.inflateRawCb", "the async node:zlib callback surface"],
|
|
2122
|
+
["zlib.gzipCb", "the async node:zlib callback surface"],
|
|
2123
|
+
["zlib.gunzipCb", "the async node:zlib callback surface"],
|
|
2124
|
+
["zlib.unzipCb", "the async node:zlib callback surface"],
|
|
2059
2125
|
["process.stdoutWriteBytesCb", "process.stdout.write completion callbacks"],
|
|
2060
2126
|
["process.stderrWriteBytesCb", "process.stderr.write completion callbacks"],
|
|
2061
2127
|
["timers.", "the timers surface (setTimeout family)"],
|
|
@@ -2103,6 +2169,7 @@ const LIB_MODE_REFUSED_KINDS = new Map([
|
|
|
2103
2169
|
["child", "the child_process surface"],
|
|
2104
2170
|
["spawnRes", "the child_process surface"],
|
|
2105
2171
|
["childStream", "the child_process surface"],
|
|
2172
|
+
["childWriter", "the child_process surface"],
|
|
2106
2173
|
["netServer", "the node:net surface"],
|
|
2107
2174
|
["netSocket", "the node:net surface"],
|
|
2108
2175
|
["http2Session", "the node:http2 surface"],
|
|
@@ -2238,6 +2305,7 @@ export const LIB_NONDETERMINISTIC_PREFIXES = [
|
|
|
2238
2305
|
["process.kill", "process authority (kill)"],
|
|
2239
2306
|
["process.umask", "process authority (umask)"],
|
|
2240
2307
|
["process.exit", "process authority (exit)"],
|
|
2308
|
+
["process.setExitCode", "process authority (exit status)"],
|
|
2241
2309
|
["fs.", "the filesystem"],
|
|
2242
2310
|
["os.", "machine/OS identity"],
|
|
2243
2311
|
// The CA-store surface reads the host's certificate bundle (and the
|
|
@@ -2275,12 +2343,25 @@ export function moduleLibNondeterministicSurface(mod) {
|
|
|
2275
2343
|
/** The may-throw seed: libCall members that can raise. Every fs.* member
|
|
2276
2344
|
* EXCEPT existsSync (which, like Node's, swallows errors and returns false)
|
|
2277
2345
|
* throws a catchable error on failure; json.parse throws a catchable
|
|
2278
|
-
* SyntaxError-shaped string on malformed input
|
|
2279
|
-
* throw. Backends' may-throw analyses must treat a function containing one
|
|
2346
|
+
* SyntaxError-shaped string on malformed input. Backends' may-throw analyses must treat a function containing one
|
|
2280
2347
|
* of these as throwing, exactly like a `throw` statement (and must ALSO
|
|
2281
2348
|
* seed on `dynCheck` and `awaitExpr` nodes, which throw on validation
|
|
2282
2349
|
* failure / promise rejection). */
|
|
2283
2350
|
export const MAY_THROW_LIB_FNS = new Set([
|
|
2351
|
+
"bigint.parse",
|
|
2352
|
+
"bigint.fromF64",
|
|
2353
|
+
"bigint.div",
|
|
2354
|
+
"bigint.mod",
|
|
2355
|
+
"bigint.pow",
|
|
2356
|
+
"bigint.shl",
|
|
2357
|
+
"bigint.shr",
|
|
2358
|
+
"bigint.toString",
|
|
2359
|
+
"bigint.asUintN",
|
|
2360
|
+
"bigint.asIntN",
|
|
2361
|
+
"bigint.bufferRead",
|
|
2362
|
+
"bigint.bufferWrite",
|
|
2363
|
+
"bigint.dataViewGet",
|
|
2364
|
+
"bigint.dataViewSet",
|
|
2284
2365
|
"fetch.responseNew",
|
|
2285
2366
|
"fetch.abortTimeout",
|
|
2286
2367
|
"fetch.abortAny",
|
|
@@ -2341,11 +2422,13 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2341
2422
|
// any of them can throw. emitError additionally THROWS its payload when
|
|
2342
2423
|
// 'error' has no listener, Node's unhandled-'error' contract.
|
|
2343
2424
|
"emitter.emit",
|
|
2425
|
+
"emitter.emitFlex",
|
|
2344
2426
|
"emitter.emitError",
|
|
2345
2427
|
"emitter.on",
|
|
2346
2428
|
"emitter.off",
|
|
2347
2429
|
"emitter.checkListener",
|
|
2348
2430
|
"emitter.onDyn",
|
|
2431
|
+
"emitter.onFlex",
|
|
2349
2432
|
"emitter.offDyn",
|
|
2350
2433
|
"emitter.onData",
|
|
2351
2434
|
"emitter.onDataDyn",
|
|
@@ -2358,8 +2441,27 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2358
2441
|
"net.sockEndDyn",
|
|
2359
2442
|
"http.resWriteDyn",
|
|
2360
2443
|
"http.resEndDyn",
|
|
2444
|
+
"http.resAddTrailers",
|
|
2445
|
+
"http.resFlushHeaders",
|
|
2446
|
+
"http.resUncork",
|
|
2447
|
+
"http.resWriteHead",
|
|
2448
|
+
"http.resWriteHeadN",
|
|
2449
|
+
"http.resWriteHeadPairs",
|
|
2450
|
+
"http.resWrite",
|
|
2451
|
+
"http.resWriteBytes",
|
|
2452
|
+
"http.resEnd",
|
|
2453
|
+
"http.resEndStr",
|
|
2454
|
+
"http.resEndBytes",
|
|
2361
2455
|
"http.clientWriteDyn",
|
|
2362
2456
|
"http.clientEndDyn",
|
|
2457
|
+
"http.clientAddTrailers",
|
|
2458
|
+
"http.clientFlushHeaders",
|
|
2459
|
+
"http.clientUncork",
|
|
2460
|
+
"http.clientWrite",
|
|
2461
|
+
"http.clientWriteBytes",
|
|
2462
|
+
"http.clientEnd",
|
|
2463
|
+
"http.clientEndStr",
|
|
2464
|
+
"http.clientEndBytes",
|
|
2363
2465
|
// The URL-string client form throws catchably on an unparsable input
|
|
2364
2466
|
// ("Invalid URL") or a non-http scheme (ERR_INVALID_PROTOCOL).
|
|
2365
2467
|
"http.requestUrl",
|
|
@@ -2439,6 +2541,7 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2439
2541
|
"http.requestConnCb",
|
|
2440
2542
|
"process.kill",
|
|
2441
2543
|
"process.killNum",
|
|
2544
|
+
"process.setExitCode",
|
|
2442
2545
|
// cpuUsage(prev)'s field validation: negative/non-finite prev fields
|
|
2443
2546
|
// throw Node's ERR_INVALID_ARG_VALUE RangeError, catchably.
|
|
2444
2547
|
"process.cpuPrevValidate",
|
|
@@ -2455,6 +2558,8 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2455
2558
|
"error.nodeThrow",
|
|
2456
2559
|
// USVString coercion runs user toString/valueOf — throws propagate.
|
|
2457
2560
|
"dyn.toStringCoerce",
|
|
2561
|
+
// Numeric coercion runs user valueOf/toString — throws propagate.
|
|
2562
|
+
"dyn.toNumberCoerce",
|
|
2458
2563
|
"child.kill",
|
|
2459
2564
|
// The caller's lookup runs synchronously inside the connect call — a
|
|
2460
2565
|
// throw there propagates like Node's.
|
|
@@ -2555,6 +2660,27 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2555
2660
|
"fs.statSync",
|
|
2556
2661
|
"crypto.randomBytesToString",
|
|
2557
2662
|
"crypto.randomBytes",
|
|
2663
|
+
"crypto.hashDigestStr",
|
|
2664
|
+
"crypto.hashDigestBytes",
|
|
2665
|
+
"crypto.hashNew",
|
|
2666
|
+
"crypto.hmacNewStr",
|
|
2667
|
+
"crypto.hmacNewBytes",
|
|
2668
|
+
"crypto.hashUpdateStr",
|
|
2669
|
+
"crypto.hashUpdateBytes",
|
|
2670
|
+
"crypto.hmacUpdateStr",
|
|
2671
|
+
"crypto.hmacUpdateBytes",
|
|
2672
|
+
"crypto.hashCopy",
|
|
2673
|
+
"crypto.hashDigestString",
|
|
2674
|
+
"crypto.hashDigestBuffer",
|
|
2675
|
+
"crypto.hmacDigestString",
|
|
2676
|
+
"crypto.hmacDigestBuffer",
|
|
2677
|
+
"crypto.timingSafeEqual",
|
|
2678
|
+
"crypto.randomFill",
|
|
2679
|
+
"crypto.randomFillRest",
|
|
2680
|
+
"crypto.randomInt",
|
|
2681
|
+
"crypto.pbkdf2",
|
|
2682
|
+
"crypto.randomBytesCb",
|
|
2683
|
+
"crypto.pbkdf2Cb",
|
|
2558
2684
|
"buffer.concat",
|
|
2559
2685
|
"buffer.concatLen",
|
|
2560
2686
|
// The checked-dynamic compare/equals validators: Node's argument
|
|
@@ -2585,6 +2711,10 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2585
2711
|
"fs.readFileSyncBytes",
|
|
2586
2712
|
"fs.writeFileSyncBytes",
|
|
2587
2713
|
"zlib.inflateSync",
|
|
2714
|
+
"zlib.inflateRawSync",
|
|
2715
|
+
"zlib.gunzipSync",
|
|
2716
|
+
"zlib.unzipSync",
|
|
2717
|
+
"zlib.crc32",
|
|
2588
2718
|
"date.toISOString",
|
|
2589
2719
|
"date.toISOStringValue",
|
|
2590
2720
|
"fs.mkdirRecursiveSync",
|
|
@@ -2612,10 +2742,12 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2612
2742
|
// catchable AssertionError on failure.
|
|
2613
2743
|
"assert.ok",
|
|
2614
2744
|
"assert.eqF64",
|
|
2745
|
+
"assert.eqBigInt",
|
|
2615
2746
|
"assert.eqStr",
|
|
2616
2747
|
"assert.eqBool",
|
|
2617
2748
|
"assert.eqSym",
|
|
2618
2749
|
"assert.eqDyn",
|
|
2750
|
+
"assert.looseResult",
|
|
2619
2751
|
"assert.deepResult",
|
|
2620
2752
|
"assert.match",
|
|
2621
2753
|
"assert.refEqBytes",
|
|
@@ -2641,10 +2773,15 @@ export const MAY_THROW_LIB_FNS = new Set([
|
|
|
2641
2773
|
"fs.copyFileSync",
|
|
2642
2774
|
"fs.renameSync",
|
|
2643
2775
|
"fs.lstatSync",
|
|
2776
|
+
"fs.fstatSync",
|
|
2777
|
+
"fs.fchmodSync",
|
|
2778
|
+
"fs.fsyncSync",
|
|
2779
|
+
"fs.linkSync",
|
|
2644
2780
|
"fs.writeFileModeSync",
|
|
2645
2781
|
"fs.mkdirModeSync",
|
|
2646
2782
|
"fs.mkdirRecursiveModeSync",
|
|
2647
2783
|
"fs.openSync",
|
|
2784
|
+
"fs.openNumericSync",
|
|
2648
2785
|
"fs.readSync",
|
|
2649
2786
|
"fs.writeSync",
|
|
2650
2787
|
"fs.writeStrSync",
|