@ai-ecoverse/slicc-kernel 1.57.0 → 1.57.1
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/README.md +1 -1
- package/dist/kernel-worker.js +4 -0
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +252 -79
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +4 -0
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +252 -79
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -4555,10 +4555,26 @@ function pathInode(path) {
|
|
|
4555
4555
|
}
|
|
4556
4556
|
return h;
|
|
4557
4557
|
}
|
|
4558
|
-
function
|
|
4559
|
-
|
|
4560
|
-
|
|
4558
|
+
function inoKey(st) {
|
|
4559
|
+
return "ino" in st && typeof st.ino === "number" ? st.ino % 4294967296 | 0 : 0;
|
|
4560
|
+
}
|
|
4561
|
+
function pathHash(path) {
|
|
4562
|
+
let h = 2166136261;
|
|
4563
|
+
for (let i = 0; i < path.length; i++) h = Math.imul(h ^ path.charCodeAt(i), 16777619);
|
|
4564
|
+
return h === 0 ? 1 : h;
|
|
4565
|
+
}
|
|
4566
|
+
function index(map, key, path) {
|
|
4567
|
+
const paths = map.get(key) ?? /* @__PURE__ */ new Set();
|
|
4568
|
+
paths.add(path);
|
|
4569
|
+
map.set(key, paths);
|
|
4570
|
+
}
|
|
4571
|
+
function cachingBridge(bridge, now = () => performance.now(), shared) {
|
|
4572
|
+
const blind = shared !== void 0 && shared.length * 4 < SHARED_IDS_BYTES;
|
|
4573
|
+
const cache = new StatCache(blind ? void 0 : shared);
|
|
4574
|
+
const { stats, lstats } = cache;
|
|
4561
4575
|
const cached = (map, path, get) => {
|
|
4576
|
+
if (blind) return get();
|
|
4577
|
+
cache.fresh();
|
|
4562
4578
|
let hit = map.get(path);
|
|
4563
4579
|
if (hit === void 0 || "until" in hit && hit.until <= now()) {
|
|
4564
4580
|
try {
|
|
@@ -4566,22 +4582,29 @@ function cachingBridge(bridge, now = () => performance.now()) {
|
|
|
4566
4582
|
} catch (e) {
|
|
4567
4583
|
hit = { error: e, until: now() + MISS_TTL_MS };
|
|
4568
4584
|
}
|
|
4569
|
-
|
|
4585
|
+
cache.put(map, path, hit);
|
|
4570
4586
|
}
|
|
4571
4587
|
if ("until" in hit) throw hit.error;
|
|
4572
4588
|
return hit;
|
|
4573
4589
|
};
|
|
4574
|
-
const invalidate = () =>
|
|
4575
|
-
|
|
4576
|
-
|
|
4590
|
+
const invalidate = () => cache.mutated([]);
|
|
4591
|
+
const touched = (path, ino) => cache.changed(path, ino);
|
|
4592
|
+
const mutating = (op, ...paths) => {
|
|
4593
|
+
try {
|
|
4594
|
+
return op();
|
|
4595
|
+
} finally {
|
|
4596
|
+
cache.mutated(paths);
|
|
4597
|
+
}
|
|
4577
4598
|
};
|
|
4578
|
-
const
|
|
4599
|
+
const rewriting = (p, op, ...also) => {
|
|
4600
|
+
const ino = cache.inoOf(p, () => bridge.stat(p));
|
|
4579
4601
|
try {
|
|
4580
4602
|
return op();
|
|
4581
4603
|
} finally {
|
|
4582
|
-
|
|
4604
|
+
cache.mutated([p, ...also], ino);
|
|
4583
4605
|
}
|
|
4584
4606
|
};
|
|
4607
|
+
const entry = (p) => [p, p.slice(0, p.lastIndexOf("/")) || "/"];
|
|
4585
4608
|
return {
|
|
4586
4609
|
readFile: (p) => bridge.readFile(p),
|
|
4587
4610
|
readdir: (p) => bridge.readdir(p),
|
|
@@ -4589,9 +4612,9 @@ function cachingBridge(bridge, now = () => performance.now()) {
|
|
|
4589
4612
|
const list = bridge.readdirStat(p);
|
|
4590
4613
|
const base = p === "/" ? "" : p;
|
|
4591
4614
|
for (const [name2, st] of list) {
|
|
4592
|
-
if (!st) continue;
|
|
4593
|
-
|
|
4594
|
-
if (!st.isSymbolicLink)
|
|
4615
|
+
if (!st || blind) continue;
|
|
4616
|
+
cache.put(lstats, `${base}/${name2}`, st);
|
|
4617
|
+
if (!st.isSymbolicLink) cache.put(stats, `${base}/${name2}`, st);
|
|
4595
4618
|
}
|
|
4596
4619
|
return list;
|
|
4597
4620
|
},
|
|
@@ -4606,40 +4629,41 @@ function cachingBridge(bridge, now = () => performance.now()) {
|
|
|
4606
4629
|
return false;
|
|
4607
4630
|
}
|
|
4608
4631
|
},
|
|
4609
|
-
writeFile: (p, bytes, open) =>
|
|
4610
|
-
mkdir: (p) => mutating(() => bridge.mkdir(p)),
|
|
4632
|
+
writeFile: (p, bytes, open) => rewriting(p, () => bridge.writeFile(p, bytes, open), ...entry(p).slice(1)),
|
|
4633
|
+
mkdir: (p) => mutating(() => bridge.mkdir(p), ...entry(p)),
|
|
4611
4634
|
rm: (p) => mutating(() => bridge.rm(p)),
|
|
4612
4635
|
rename: (from, to) => mutating(() => bridge.rename(from, to)),
|
|
4613
4636
|
unlink: (p) => mutating(() => bridge.unlink(p)),
|
|
4614
4637
|
rmdir: (p) => mutating(() => bridge.rmdir(p)),
|
|
4615
|
-
symlink: (target, link) => mutating(() => bridge.symlink(target, link)),
|
|
4616
|
-
chmod: (p, mode) =>
|
|
4617
|
-
utimes: (p, a, m) =>
|
|
4618
|
-
lutimes: (p, a, m) => mutating(() => bridge.lutimes(p, a, m)),
|
|
4638
|
+
symlink: (target, link) => mutating(() => bridge.symlink(target, link), ...entry(link)),
|
|
4639
|
+
chmod: (p, mode) => rewriting(p, () => bridge.chmod(p, mode)),
|
|
4640
|
+
utimes: (p, a, m) => rewriting(p, () => bridge.utimes(p, a, m)),
|
|
4641
|
+
lutimes: (p, a, m) => mutating(() => bridge.lutimes(p, a, m), p),
|
|
4619
4642
|
...bridge.hold ? { hold: bridge.hold.bind(bridge) } : {},
|
|
4620
4643
|
...bridge.kept ? { kept: bridge.kept.bind(bridge) } : {},
|
|
4621
|
-
...bridge.pinned ? { pinned: (handle) => pinnedIo2(bridge, handle,
|
|
4622
|
-
...bridge.create ? { create: (p) => mutating(() => bridge.create?.(p)) } : {},
|
|
4644
|
+
...bridge.pinned ? { pinned: (handle) => pinnedIo2(bridge, handle, rewriting) } : {},
|
|
4645
|
+
...bridge.create ? { create: (p) => mutating(() => bridge.create?.(p), ...entry(p)) } : {},
|
|
4623
4646
|
...bridge.pread && bridge.pwrite && bridge.truncate ? {
|
|
4624
4647
|
pread: bridge.pread.bind(bridge),
|
|
4625
|
-
pwrite: (p, at, bytes, transfer) =>
|
|
4626
|
-
truncate: (p, size) =>
|
|
4648
|
+
pwrite: (p, at, bytes, transfer) => rewriting(p, () => bridge.pwrite?.(p, at, bytes, transfer)),
|
|
4649
|
+
truncate: (p, size) => rewriting(p, () => bridge.truncate?.(p, size))
|
|
4627
4650
|
} : {},
|
|
4628
|
-
invalidate
|
|
4651
|
+
invalidate,
|
|
4652
|
+
touched
|
|
4629
4653
|
};
|
|
4630
4654
|
}
|
|
4631
|
-
function pinnedIo2(bridge, handle,
|
|
4655
|
+
function pinnedIo2(bridge, handle, rewriting) {
|
|
4632
4656
|
const io = bridge.pinned(handle);
|
|
4633
4657
|
const { pread, pwrite, truncate } = io;
|
|
4634
4658
|
return {
|
|
4635
4659
|
readFile: (p) => io.readFile(p),
|
|
4636
|
-
writeFile: (p, bytes, open) =>
|
|
4660
|
+
writeFile: (p, bytes, open) => rewriting(p, () => io.writeFile(p, bytes, open)),
|
|
4637
4661
|
pread: (p, at, n, version) => pread(p, at, n, version),
|
|
4638
|
-
pwrite: (p, at, bytes, transfer) =>
|
|
4639
|
-
truncate: (p, size) =>
|
|
4662
|
+
pwrite: (p, at, bytes, transfer) => rewriting(p, () => pwrite(p, at, bytes, transfer)),
|
|
4663
|
+
truncate: (p, size) => rewriting(p, () => truncate(p, size))
|
|
4640
4664
|
};
|
|
4641
4665
|
}
|
|
4642
|
-
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS;
|
|
4666
|
+
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, FS_GEN, RING, RING_SIZE, SLOT, SHARED_IDS_BYTES, StatCache;
|
|
4643
4667
|
var init_wasi_files = __esm({
|
|
4644
4668
|
"src/process/wasi/wasi-files.ts"() {
|
|
4645
4669
|
"use strict";
|
|
@@ -4829,6 +4853,110 @@ var init_wasi_files = __esm({
|
|
|
4829
4853
|
};
|
|
4830
4854
|
MAX_LINKS = 40;
|
|
4831
4855
|
MISS_TTL_MS = 20;
|
|
4856
|
+
FS_GEN = 4;
|
|
4857
|
+
RING = 8;
|
|
4858
|
+
RING_SIZE = 64;
|
|
4859
|
+
SLOT = 3;
|
|
4860
|
+
SHARED_IDS_BYTES = (RING + RING_SIZE * SLOT) * 4;
|
|
4861
|
+
StatCache = class {
|
|
4862
|
+
stats = /* @__PURE__ */ new Map();
|
|
4863
|
+
lstats = /* @__PURE__ */ new Map();
|
|
4864
|
+
byHash = /* @__PURE__ */ new Map();
|
|
4865
|
+
byIno = /* @__PURE__ */ new Map();
|
|
4866
|
+
shared;
|
|
4867
|
+
seen;
|
|
4868
|
+
constructor(shared) {
|
|
4869
|
+
this.shared = shared;
|
|
4870
|
+
this.seen = shared ? Atomics.load(shared, FS_GEN) : 0;
|
|
4871
|
+
}
|
|
4872
|
+
put(map, path, entry) {
|
|
4873
|
+
map.set(path, entry);
|
|
4874
|
+
if (!this.shared) return;
|
|
4875
|
+
index(this.byHash, pathHash(path), path);
|
|
4876
|
+
const ino = inoKey(entry);
|
|
4877
|
+
if (ino !== 0) index(this.byIno, ino, path);
|
|
4878
|
+
}
|
|
4879
|
+
fresh() {
|
|
4880
|
+
if (!this.shared) return;
|
|
4881
|
+
const now = Atomics.load(this.shared, FS_GEN);
|
|
4882
|
+
if (now === this.seen) return;
|
|
4883
|
+
this.replay(now);
|
|
4884
|
+
this.seen = now;
|
|
4885
|
+
}
|
|
4886
|
+
changed(path, ino = 0) {
|
|
4887
|
+
const key = ino % 4294967296 | 0;
|
|
4888
|
+
if (this.shared) {
|
|
4889
|
+
const g = this.publish(this.shared, path === void 0 ? 0 : pathHash(path), key);
|
|
4890
|
+
this.replay(g - 1);
|
|
4891
|
+
this.seen = g;
|
|
4892
|
+
if (path === void 0) this.clear();
|
|
4893
|
+
else this.drop(pathHash(path), key);
|
|
4894
|
+
}
|
|
4895
|
+
if (path === void 0) return;
|
|
4896
|
+
this.stats.delete(path);
|
|
4897
|
+
this.lstats.delete(path);
|
|
4898
|
+
}
|
|
4899
|
+
mutated(paths, ino = 0) {
|
|
4900
|
+
this.clear();
|
|
4901
|
+
if (!this.shared) return;
|
|
4902
|
+
const key = ino % 4294967296 | 0;
|
|
4903
|
+
for (const [i, hash] of (paths.length > 0 ? paths.map(pathHash) : [0]).entries()) {
|
|
4904
|
+
this.seen = this.publish(this.shared, hash, i === 0 ? key : 0);
|
|
4905
|
+
}
|
|
4906
|
+
}
|
|
4907
|
+
inoOf(path, look) {
|
|
4908
|
+
if (!this.shared) return 0;
|
|
4909
|
+
this.fresh();
|
|
4910
|
+
const hit = this.stats.get(path);
|
|
4911
|
+
if (hit && "ino" in hit && typeof hit.ino === "number") return hit.ino;
|
|
4912
|
+
try {
|
|
4913
|
+
return look().ino ?? 0;
|
|
4914
|
+
} catch {
|
|
4915
|
+
return 0;
|
|
4916
|
+
}
|
|
4917
|
+
}
|
|
4918
|
+
publish(shared, hash, ino) {
|
|
4919
|
+
const g = Atomics.add(shared, FS_GEN, 1) + 1;
|
|
4920
|
+
const at = RING + g % RING_SIZE * SLOT;
|
|
4921
|
+
Atomics.store(shared, at, 0);
|
|
4922
|
+
Atomics.store(shared, at + 1, hash);
|
|
4923
|
+
Atomics.store(shared, at + 2, ino);
|
|
4924
|
+
Atomics.store(shared, at, g);
|
|
4925
|
+
return g;
|
|
4926
|
+
}
|
|
4927
|
+
replay(upTo) {
|
|
4928
|
+
const shared = this.shared;
|
|
4929
|
+
const missed = [];
|
|
4930
|
+
for (let g = this.seen + 1; g <= upTo && upTo - this.seen <= RING_SIZE; g++) {
|
|
4931
|
+
const at = RING + g % RING_SIZE * SLOT;
|
|
4932
|
+
const tag = Atomics.load(shared, at);
|
|
4933
|
+
const hash = Atomics.load(shared, at + 1);
|
|
4934
|
+
const ino = Atomics.load(shared, at + 2);
|
|
4935
|
+
if (tag !== g || hash === 0 || Atomics.load(shared, at) !== g) break;
|
|
4936
|
+
missed.push([hash, ino]);
|
|
4937
|
+
}
|
|
4938
|
+
if (missed.length < upTo - this.seen) this.clear();
|
|
4939
|
+
else for (const [hash, ino] of missed) this.drop(hash, ino);
|
|
4940
|
+
}
|
|
4941
|
+
drop(hash, ino) {
|
|
4942
|
+
const paths = [
|
|
4943
|
+
...this.byHash.get(hash) ?? [],
|
|
4944
|
+
...ino === 0 ? [] : this.byIno.get(ino) ?? []
|
|
4945
|
+
];
|
|
4946
|
+
for (const path of paths) {
|
|
4947
|
+
this.stats.delete(path);
|
|
4948
|
+
this.lstats.delete(path);
|
|
4949
|
+
}
|
|
4950
|
+
this.byHash.delete(hash);
|
|
4951
|
+
if (ino !== 0) this.byIno.delete(ino);
|
|
4952
|
+
}
|
|
4953
|
+
clear() {
|
|
4954
|
+
this.stats.clear();
|
|
4955
|
+
this.lstats.clear();
|
|
4956
|
+
this.byHash.clear();
|
|
4957
|
+
this.byIno.clear();
|
|
4958
|
+
}
|
|
4959
|
+
};
|
|
4832
4960
|
}
|
|
4833
4961
|
});
|
|
4834
4962
|
|
|
@@ -5161,7 +5289,14 @@ var init_wasi_fds = __esm({
|
|
|
5161
5289
|
handed.add(e.file.buffer);
|
|
5162
5290
|
promoted.set(e.file, fd);
|
|
5163
5291
|
}
|
|
5164
|
-
this.table.set(fd, {
|
|
5292
|
+
this.table.set(fd, {
|
|
5293
|
+
type: "kernel",
|
|
5294
|
+
kind: "file",
|
|
5295
|
+
nonblock: false,
|
|
5296
|
+
append: e.file.append,
|
|
5297
|
+
path: e.file.path,
|
|
5298
|
+
ino: this.inoOf(e.file.path)
|
|
5299
|
+
});
|
|
5165
5300
|
}
|
|
5166
5301
|
for (const file of promoted.keys()) {
|
|
5167
5302
|
if (--file.buffer.opens <= 0) {
|
|
@@ -5275,9 +5410,21 @@ var init_wasi_fds = __esm({
|
|
|
5275
5410
|
buffer.orphan();
|
|
5276
5411
|
this.buffers.delete(path);
|
|
5277
5412
|
}
|
|
5413
|
+
inoOf(path) {
|
|
5414
|
+
try {
|
|
5415
|
+
return this.fs.stat(path).ino;
|
|
5416
|
+
} catch {
|
|
5417
|
+
return void 0;
|
|
5418
|
+
}
|
|
5419
|
+
}
|
|
5278
5420
|
renamed(from, to) {
|
|
5279
5421
|
if (from === to) return;
|
|
5280
5422
|
if (this.shared) this.kernel.call({ op: "fd-path-renamed", from, to });
|
|
5423
|
+
for (const e of this.table.values()) {
|
|
5424
|
+
if (e.type === "kernel" && e.path !== void 0 && within(e.path, from)) {
|
|
5425
|
+
e.path = to + e.path.slice(from.length);
|
|
5426
|
+
}
|
|
5427
|
+
}
|
|
5281
5428
|
const moved = [];
|
|
5282
5429
|
for (const [p, buffer] of this.buffers) {
|
|
5283
5430
|
if (within(p, from)) moved.push([p, buffer]);
|
|
@@ -5356,7 +5503,10 @@ var init_wasi_fds = __esm({
|
|
|
5356
5503
|
const made = !existing && this.createNew(path, oflags);
|
|
5357
5504
|
const truncate = made || (oflags & OFLAGS.TRUNC) !== 0;
|
|
5358
5505
|
const fd = this.kernel.sys.openVfs(path, flags, 0, truncate ? { truncate } : {});
|
|
5359
|
-
|
|
5506
|
+
const was = existing && this.inoOf(path);
|
|
5507
|
+
if (truncate) this.fs.touched?.(path, was);
|
|
5508
|
+
const ino = existing ? was : this.inoOf(path);
|
|
5509
|
+
this.table.set(fd, { type: "kernel", kind: "file", nonblock: false, append, path, ino });
|
|
5360
5510
|
if (append) this.publishFlags(fd, { nonblock: false, append });
|
|
5361
5511
|
this.bump();
|
|
5362
5512
|
return fd;
|
|
@@ -6150,11 +6300,29 @@ var init_wasi_host = __esm({
|
|
|
6150
6300
|
if (!kernel.sys.pread) throw new WasiError("ESPIPE");
|
|
6151
6301
|
return kernel.sys.pread(fd, Math.min(max, MAX_READ), at);
|
|
6152
6302
|
},
|
|
6153
|
-
pwrite: (body, at) => kernel.call({ op: "fd-pwrite", fd, offset: at, body }),
|
|
6303
|
+
pwrite: (body, at) => this.changed(fd, e, kernel.call({ op: "fd-pwrite", fd, offset: at, body })),
|
|
6154
6304
|
size: () => this.kernelStat(fd).size,
|
|
6155
|
-
truncate: (size) => void kernel.call({ op: "fd-resize", fd, size })
|
|
6305
|
+
truncate: (size) => this.changed(fd, e, void kernel.call({ op: "fd-resize", fd, size }))
|
|
6156
6306
|
};
|
|
6157
6307
|
}
|
|
6308
|
+
unnamed = /* @__PURE__ */ new WeakSet();
|
|
6309
|
+
changed(fd, e, result) {
|
|
6310
|
+
if (e.path === void 0 && !this.unnamed.has(e)) this.learnPath(fd, e);
|
|
6311
|
+
this.o.fs.touched?.(e.path, e.ino);
|
|
6312
|
+
return result;
|
|
6313
|
+
}
|
|
6314
|
+
learnPath(fd, e) {
|
|
6315
|
+
this.unnamed.add(e);
|
|
6316
|
+
let path;
|
|
6317
|
+
try {
|
|
6318
|
+
const st = this.kernelStat(fd);
|
|
6319
|
+
path = st.orphan ? void 0 : st.path;
|
|
6320
|
+
if (path !== void 0) e.ino = this.o.fs.stat(path).ino;
|
|
6321
|
+
} catch {
|
|
6322
|
+
return;
|
|
6323
|
+
}
|
|
6324
|
+
e.path = path;
|
|
6325
|
+
}
|
|
6158
6326
|
kernelStat(fd) {
|
|
6159
6327
|
return this.o.kernel.call({ op: "fd-vfs-stat", fd });
|
|
6160
6328
|
}
|
|
@@ -6163,7 +6331,8 @@ var init_wasi_host = __esm({
|
|
|
6163
6331
|
const e = this.fds.get(fd);
|
|
6164
6332
|
if (e.type === "kernel") {
|
|
6165
6333
|
try {
|
|
6166
|
-
|
|
6334
|
+
const n = this.o.kernel.sys.write(fd, data, { nonblock: e.nonblock });
|
|
6335
|
+
return this.fds.kind(fd, e) === "file" ? this.changed(fd, e, n) : n;
|
|
6167
6336
|
} catch (err) {
|
|
6168
6337
|
const broken = err.code === "EPIPE";
|
|
6169
6338
|
if (broken && this.fds.kind(fd, e) !== "socket") throw new WasiExit(SIGPIPE_EXIT);
|
|
@@ -6360,6 +6529,7 @@ var init_wasi_threads = __esm({
|
|
|
6360
6529
|
"src/process/wasi/wasi-threads.ts"() {
|
|
6361
6530
|
"use strict";
|
|
6362
6531
|
init_protocol();
|
|
6532
|
+
init_wasi_files();
|
|
6363
6533
|
LAST_TID = 0;
|
|
6364
6534
|
RUNNING = 1;
|
|
6365
6535
|
MAIN_TID = 1;
|
|
@@ -6382,7 +6552,7 @@ var init_wasi_threads = __esm({
|
|
|
6382
6552
|
this.memory = memory;
|
|
6383
6553
|
this.cap = cap;
|
|
6384
6554
|
this.tid = tid;
|
|
6385
|
-
this.ids = new Int32Array(ids ?? new SharedArrayBuffer(
|
|
6555
|
+
this.ids = new Int32Array(ids ?? new SharedArrayBuffer(SHARED_IDS_BYTES));
|
|
6386
6556
|
if (!ids) Atomics.store(this.ids, LAST_TID, MAIN_TID);
|
|
6387
6557
|
}
|
|
6388
6558
|
spawn(arg) {
|
|
@@ -7824,8 +7994,8 @@ function readExports(r, s) {
|
|
|
7824
7994
|
for (let i = r.u32(); i > 0; i--) {
|
|
7825
7995
|
const name2 = r.name();
|
|
7826
7996
|
const kind = r.byte();
|
|
7827
|
-
const
|
|
7828
|
-
if (kind === 0) s.info.exports[name2] =
|
|
7997
|
+
const index3 = r.u32();
|
|
7998
|
+
if (kind === 0) s.info.exports[name2] = index3;
|
|
7829
7999
|
}
|
|
7830
8000
|
}
|
|
7831
8001
|
function readElems(r, s) {
|
|
@@ -8128,15 +8298,15 @@ var init_wasix_linker = __esm({
|
|
|
8128
8298
|
return out;
|
|
8129
8299
|
}
|
|
8130
8300
|
allocateClosure() {
|
|
8131
|
-
const
|
|
8132
|
-
growTable(this.table,
|
|
8133
|
-
this.live.add(
|
|
8134
|
-
return
|
|
8301
|
+
const index3 = this.indices.allocate(this.table.length);
|
|
8302
|
+
growTable(this.table, index3 + 1);
|
|
8303
|
+
this.live.add(index3);
|
|
8304
|
+
return index3;
|
|
8135
8305
|
}
|
|
8136
|
-
freeClosure(
|
|
8137
|
-
this.indices?.free(
|
|
8138
|
-
this.live.delete(
|
|
8139
|
-
this.table.set(
|
|
8306
|
+
freeClosure(index3) {
|
|
8307
|
+
this.indices?.free(index3);
|
|
8308
|
+
this.live.delete(index3);
|
|
8309
|
+
this.table.set(index3, null);
|
|
8140
8310
|
}
|
|
8141
8311
|
live = /* @__PURE__ */ new Set();
|
|
8142
8312
|
prepareClosure(record) {
|
|
@@ -8369,12 +8539,12 @@ var init_wasix_linker = __esm({
|
|
|
8369
8539
|
this.indexTable();
|
|
8370
8540
|
const known = this.slots.get(fn);
|
|
8371
8541
|
if (known !== void 0) return known;
|
|
8372
|
-
const
|
|
8373
|
-
growTable(this.table,
|
|
8374
|
-
this.table.set(
|
|
8375
|
-
this.slots.set(fn,
|
|
8376
|
-
this.publisher?.({ kind: "slot", index:
|
|
8377
|
-
return
|
|
8542
|
+
const index3 = this.reserve(1);
|
|
8543
|
+
growTable(this.table, index3 + 1);
|
|
8544
|
+
this.table.set(index3, fn);
|
|
8545
|
+
this.slots.set(fn, index3);
|
|
8546
|
+
this.publisher?.({ kind: "slot", index: index3, handle, name: name2 });
|
|
8547
|
+
return index3;
|
|
8378
8548
|
}
|
|
8379
8549
|
allocate(size, alignment) {
|
|
8380
8550
|
if (size === 0) return 0;
|
|
@@ -8659,11 +8829,11 @@ var init_wasix_sockets = __esm({
|
|
|
8659
8829
|
});
|
|
8660
8830
|
|
|
8661
8831
|
// src/process/wasi/wasix-host.ts
|
|
8662
|
-
function futexWait(view,
|
|
8832
|
+
function futexWait(view, index3, expected, ms, interrupted) {
|
|
8663
8833
|
const deadline = performance.now() + ms;
|
|
8664
8834
|
for (; ; ) {
|
|
8665
8835
|
const slice = interrupted ? Math.min(FUTEX_SLICE_MS, ms) : ms;
|
|
8666
|
-
if (Atomics.wait(view,
|
|
8836
|
+
if (Atomics.wait(view, index3, expected, slice) !== "timed-out") return true;
|
|
8667
8837
|
if (interrupted?.()) return true;
|
|
8668
8838
|
ms = deadline - performance.now();
|
|
8669
8839
|
if (ms <= 0) return false;
|
|
@@ -8792,21 +8962,21 @@ var init_wasix_host = __esm({
|
|
|
8792
8962
|
if (!this.linker) throw new WasiError("ENOTSUP");
|
|
8793
8963
|
this.mem.view().setUint32(out, this.linker.allocateClosure(), true);
|
|
8794
8964
|
},
|
|
8795
|
-
closure_prepare: (backing,
|
|
8965
|
+
closure_prepare: (backing, index3, argTypes, argCount, resultTypes, resultCount, userData) => {
|
|
8796
8966
|
if (!this.linker) throw new WasiError("ENOTSUP");
|
|
8797
8967
|
const params = valueTypes(this.mem.bytes(argTypes, argCount));
|
|
8798
8968
|
const results = valueTypes(this.mem.bytes(resultTypes, resultCount));
|
|
8799
8969
|
if (!params || !results) throw new WasiError("EINVAL");
|
|
8800
8970
|
try {
|
|
8801
|
-
this.linker.prepareClosure({ index:
|
|
8971
|
+
this.linker.prepareClosure({ index: index3, backing, userData, params, results });
|
|
8802
8972
|
} catch (e) {
|
|
8803
8973
|
if (e instanceof DlError) throw new WasiError("EINVAL");
|
|
8804
8974
|
throw e;
|
|
8805
8975
|
}
|
|
8806
8976
|
},
|
|
8807
|
-
closure_free: (
|
|
8977
|
+
closure_free: (index3) => {
|
|
8808
8978
|
if (!this.linker) throw new WasiError("ENOTSUP");
|
|
8809
|
-
this.linker.freeClosure(
|
|
8979
|
+
this.linker.freeClosure(index3);
|
|
8810
8980
|
},
|
|
8811
8981
|
call_dynamic: (...a) => void callDynamic(
|
|
8812
8982
|
{ mem: this.mem, table: () => this.table, types: this.types },
|
|
@@ -9111,10 +9281,10 @@ function parseFunctionNames(payload) {
|
|
|
9111
9281
|
if (end > payload.length) throw new RangeError("truncated name section");
|
|
9112
9282
|
if (id === 1) {
|
|
9113
9283
|
for (let count = leb(); count > 0; count--) {
|
|
9114
|
-
const
|
|
9284
|
+
const index3 = leb();
|
|
9115
9285
|
const length = leb();
|
|
9116
9286
|
if (at + length > end) throw new RangeError("truncated name section");
|
|
9117
|
-
names.set(
|
|
9287
|
+
names.set(index3, decoder3.decode(payload.subarray(at, at + length)));
|
|
9118
9288
|
at += length;
|
|
9119
9289
|
}
|
|
9120
9290
|
}
|
|
@@ -9138,7 +9308,7 @@ function nameFrame(line, module, name2) {
|
|
|
9138
9308
|
}
|
|
9139
9309
|
function sidecarNames(read2, path) {
|
|
9140
9310
|
let names;
|
|
9141
|
-
return (
|
|
9311
|
+
return (index3) => {
|
|
9142
9312
|
if (!names) {
|
|
9143
9313
|
try {
|
|
9144
9314
|
names = parseFunctionNames(read2(path));
|
|
@@ -9146,7 +9316,7 @@ function sidecarNames(read2, path) {
|
|
|
9146
9316
|
names = /* @__PURE__ */ new Map();
|
|
9147
9317
|
}
|
|
9148
9318
|
}
|
|
9149
|
-
return names.get(
|
|
9319
|
+
return names.get(index3);
|
|
9150
9320
|
};
|
|
9151
9321
|
}
|
|
9152
9322
|
var UNNAMED_FRAME, WASM_MODULE;
|
|
@@ -9507,7 +9677,7 @@ async function runWasiProcess(init, port2) {
|
|
|
9507
9677
|
parent: () => identify(transport, init).ppid,
|
|
9508
9678
|
kernel: { sys: traced(stats, "kernel", sys), call: call2 },
|
|
9509
9679
|
fs: procfsBridge(
|
|
9510
|
-
cachingBridge(traced(stats, "fs", createSyncFsSabBridge(transport))),
|
|
9680
|
+
cachingBridge(traced(stats, "fs", createSyncFsSabBridge(transport)), void 0, threads?.ids),
|
|
9511
9681
|
procTree(call2, id.pid)
|
|
9512
9682
|
),
|
|
9513
9683
|
...descriptors(init, fork, threads)
|
|
@@ -9600,7 +9770,10 @@ async function runWasiThread(init, port2) {
|
|
|
9600
9770
|
ppid: id.ppid,
|
|
9601
9771
|
parent: () => identify(transport, init).ppid,
|
|
9602
9772
|
kernel: { sys, call: call2 },
|
|
9603
|
-
fs: procfsBridge(
|
|
9773
|
+
fs: procfsBridge(
|
|
9774
|
+
cachingBridge(createSyncFsSabBridge(transport), void 0, threads.ids),
|
|
9775
|
+
procTree(call2, id.pid)
|
|
9776
|
+
),
|
|
9604
9777
|
shared: threads.ids
|
|
9605
9778
|
});
|
|
9606
9779
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
@@ -9712,13 +9885,13 @@ var init_wasi_runtime = __esm({
|
|
|
9712
9885
|
},
|
|
9713
9886
|
unlock: () => this.call({ op: "dl-unlock", owner: this.owner }),
|
|
9714
9887
|
allocate: (floor) => {
|
|
9715
|
-
const
|
|
9888
|
+
const index3 = this.call({ op: "dl-closure", floor });
|
|
9716
9889
|
this.catchUp();
|
|
9717
9890
|
this.bump();
|
|
9718
|
-
return
|
|
9891
|
+
return index3;
|
|
9719
9892
|
},
|
|
9720
|
-
free: (
|
|
9721
|
-
this.call({ op: "dl-closure-free", index:
|
|
9893
|
+
free: (index3) => {
|
|
9894
|
+
this.call({ op: "dl-closure-free", index: index3 });
|
|
9722
9895
|
this.bump();
|
|
9723
9896
|
}
|
|
9724
9897
|
};
|
|
@@ -9771,8 +9944,8 @@ var init_wasi_runtime = __esm({
|
|
|
9771
9944
|
});
|
|
9772
9945
|
|
|
9773
9946
|
// src/process/js/async-sab.ts
|
|
9774
|
-
async function changed(header,
|
|
9775
|
-
const waited = waitAsync(header,
|
|
9947
|
+
async function changed(header, index3, seen, waitAsync = defaultWaitAsync) {
|
|
9948
|
+
const waited = waitAsync(header, index3, seen);
|
|
9776
9949
|
if (waited.async) await waited.value;
|
|
9777
9950
|
}
|
|
9778
9951
|
function createAsyncSabTransport(sab, port2, waitAsync = defaultWaitAsync) {
|
|
@@ -10534,7 +10707,7 @@ function openRequest(abs, o) {
|
|
|
10534
10707
|
...o.truncate ? { truncate: true } : {}
|
|
10535
10708
|
};
|
|
10536
10709
|
}
|
|
10537
|
-
function
|
|
10710
|
+
function index2(n, what) {
|
|
10538
10711
|
if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
|
|
10539
10712
|
}
|
|
10540
10713
|
var CHUNK2, MAX_IO, O_WRONLY6, O_RDWR6, O_APPEND3;
|
|
@@ -10707,7 +10880,7 @@ function syncOps(kernel, shared) {
|
|
|
10707
10880
|
return got;
|
|
10708
10881
|
};
|
|
10709
10882
|
const read2 = (fd, max = CHUNK2) => {
|
|
10710
|
-
|
|
10883
|
+
index2(max, "read");
|
|
10711
10884
|
const emulated = readDevice(info(fd), max, shared.random);
|
|
10712
10885
|
if (emulated) return emulated;
|
|
10713
10886
|
const r = kernel.blocking({ op: "fd-read", fd, max: Math.min(max, MAX_IO) });
|
|
@@ -10785,8 +10958,8 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
10785
10958
|
return kernel.json({ op: "fd-vfs-stat", fd }).size;
|
|
10786
10959
|
},
|
|
10787
10960
|
read(position, length) {
|
|
10788
|
-
|
|
10789
|
-
|
|
10961
|
+
index2(position, "read");
|
|
10962
|
+
index2(length, "read");
|
|
10790
10963
|
const parts = [];
|
|
10791
10964
|
let got = 0;
|
|
10792
10965
|
do {
|
|
@@ -10801,7 +10974,7 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
10801
10974
|
return joined(parts, got);
|
|
10802
10975
|
},
|
|
10803
10976
|
write(position, data) {
|
|
10804
|
-
|
|
10977
|
+
index2(position, "write");
|
|
10805
10978
|
let at = 0;
|
|
10806
10979
|
do {
|
|
10807
10980
|
live();
|
|
@@ -10815,7 +10988,7 @@ function syncFile(kernel, fd, path, append, forget) {
|
|
|
10815
10988
|
},
|
|
10816
10989
|
truncate(size) {
|
|
10817
10990
|
live();
|
|
10818
|
-
|
|
10991
|
+
index2(size, "truncate");
|
|
10819
10992
|
kernel.call({ op: "fd-resize", fd, size });
|
|
10820
10993
|
},
|
|
10821
10994
|
sync() {
|
|
@@ -11211,7 +11384,7 @@ function createContext(o) {
|
|
|
11211
11384
|
return got;
|
|
11212
11385
|
};
|
|
11213
11386
|
const read2 = async (fd, max = CHUNK2, signal) => {
|
|
11214
|
-
|
|
11387
|
+
index2(max, "read");
|
|
11215
11388
|
const emulated = readDevice(await info(fd), max, random);
|
|
11216
11389
|
if (emulated) return emulated;
|
|
11217
11390
|
return readPipe(kernel, fd, Math.min(max, MAX_IO), signal);
|
|
@@ -11358,8 +11531,8 @@ function fileHandle(kernel, fd, path, append, forget) {
|
|
|
11358
11531
|
return s.size;
|
|
11359
11532
|
},
|
|
11360
11533
|
async read(position, length) {
|
|
11361
|
-
|
|
11362
|
-
|
|
11534
|
+
index2(position, "read");
|
|
11535
|
+
index2(length, "read");
|
|
11363
11536
|
const parts = [];
|
|
11364
11537
|
let got = 0;
|
|
11365
11538
|
do {
|
|
@@ -11374,7 +11547,7 @@ function fileHandle(kernel, fd, path, append, forget) {
|
|
|
11374
11547
|
return joined(parts, got);
|
|
11375
11548
|
},
|
|
11376
11549
|
async write(position, data) {
|
|
11377
|
-
|
|
11550
|
+
index2(position, "write");
|
|
11378
11551
|
let at = 0;
|
|
11379
11552
|
do {
|
|
11380
11553
|
live();
|
|
@@ -11388,7 +11561,7 @@ function fileHandle(kernel, fd, path, append, forget) {
|
|
|
11388
11561
|
},
|
|
11389
11562
|
async truncate(size) {
|
|
11390
11563
|
live();
|
|
11391
|
-
|
|
11564
|
+
index2(size, "truncate");
|
|
11392
11565
|
await kernel.call({ op: "fd-resize", fd, size });
|
|
11393
11566
|
},
|
|
11394
11567
|
async sync() {
|