@ai-ecoverse/slicc-kernel 1.108.3 → 1.108.5
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 +3 -3
- package/dist/kernel-worker.js +22 -9
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +84 -27
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +22 -9
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +84 -27
- package/dist/process-worker.js.map +3 -3
- package/dist/types/kernel/process.d.ts +3 -0
- package/dist/types/process/wasi/wasi-fds.d.ts +1 -0
- package/dist/types/process/wasi/wasi-files.d.ts +2 -0
- package/dist/types/process/wasi/wasi-host.d.ts +1 -0
- package/package.json +1 -1
|
@@ -887,7 +887,7 @@ function pinnedIo(bridge, handle, rewriting) {
|
|
|
887
887
|
} : {}
|
|
888
888
|
};
|
|
889
889
|
}
|
|
890
|
-
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, SHARED_IDS_BYTES, StatCache;
|
|
890
|
+
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING, RING_SIZE, SLOT, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache;
|
|
891
891
|
var init_wasi_files = __esm({
|
|
892
892
|
"src/process/wasi/wasi-files.ts"() {
|
|
893
893
|
"use strict";
|
|
@@ -1114,7 +1114,9 @@ var init_wasi_files = __esm({
|
|
|
1114
1114
|
RING = 8;
|
|
1115
1115
|
RING_SIZE = 64;
|
|
1116
1116
|
SLOT = 3;
|
|
1117
|
-
|
|
1117
|
+
FD_RING = RING + RING_SIZE * SLOT;
|
|
1118
|
+
FD_RING_SIZE = 64;
|
|
1119
|
+
SHARED_IDS_BYTES = (FD_RING + FD_RING_SIZE * 2) * 4;
|
|
1118
1120
|
StatCache = class {
|
|
1119
1121
|
stats = /* @__PURE__ */ new Map();
|
|
1120
1122
|
lstats = /* @__PURE__ */ new Map();
|
|
@@ -1886,6 +1888,9 @@ function within(path, root) {
|
|
|
1886
1888
|
function kernelEntry() {
|
|
1887
1889
|
return { type: "kernel", nonblock: false, append: false };
|
|
1888
1890
|
}
|
|
1891
|
+
function ringed(shared) {
|
|
1892
|
+
return shared.length >= FD_RING + FD_RING_SIZE * 2;
|
|
1893
|
+
}
|
|
1889
1894
|
function deviceEntry(meta) {
|
|
1890
1895
|
return { type: "device", device: meta.device, ...meta.access ? { access: meta.access } : {} };
|
|
1891
1896
|
}
|
|
@@ -2053,16 +2058,44 @@ var init_wasi_fds = __esm({
|
|
|
2053
2058
|
this.seen = Atomics.load(ids, GEN);
|
|
2054
2059
|
}
|
|
2055
2060
|
sync() {
|
|
2056
|
-
const
|
|
2061
|
+
const shared = this.shared;
|
|
2062
|
+
const gen = Atomics.load(shared, GEN);
|
|
2057
2063
|
if (gen === this.seen) return;
|
|
2058
|
-
this.
|
|
2059
|
-
|
|
2064
|
+
if (!this.replay(shared, gen)) {
|
|
2065
|
+
this.table.clear();
|
|
2066
|
+
this.cloexec.clear();
|
|
2067
|
+
}
|
|
2060
2068
|
this.seen = gen;
|
|
2061
2069
|
}
|
|
2062
|
-
|
|
2070
|
+
replay(shared, upTo) {
|
|
2071
|
+
if (upTo - this.seen > FD_RING_SIZE || !ringed(shared)) return false;
|
|
2072
|
+
const changed2 = [];
|
|
2073
|
+
for (let g = this.seen + 1; g <= upTo; g++) {
|
|
2074
|
+
const at = FD_RING + g % FD_RING_SIZE * 2;
|
|
2075
|
+
if (Atomics.load(shared, at) !== g) return false;
|
|
2076
|
+
const fd = Atomics.load(shared, at + 1);
|
|
2077
|
+
if (fd < 0 || Atomics.load(shared, at) !== g) return false;
|
|
2078
|
+
changed2.push(fd);
|
|
2079
|
+
}
|
|
2080
|
+
for (const fd of changed2) {
|
|
2081
|
+
this.table.delete(fd);
|
|
2082
|
+
this.cloexec.delete(fd);
|
|
2083
|
+
}
|
|
2084
|
+
return true;
|
|
2085
|
+
}
|
|
2086
|
+
bump(...fds) {
|
|
2063
2087
|
if (!this.shared) return;
|
|
2064
|
-
const
|
|
2065
|
-
|
|
2088
|
+
const shared = this.shared;
|
|
2089
|
+
for (const fd of fds.length > 0 ? fds : [-1]) {
|
|
2090
|
+
const gen = Atomics.add(shared, GEN, 1) + 1;
|
|
2091
|
+
if (ringed(shared)) {
|
|
2092
|
+
const at = FD_RING + gen % FD_RING_SIZE * 2;
|
|
2093
|
+
Atomics.store(shared, at, 0);
|
|
2094
|
+
Atomics.store(shared, at + 1, fd);
|
|
2095
|
+
Atomics.store(shared, at, gen);
|
|
2096
|
+
}
|
|
2097
|
+
if (gen - 1 === this.seen) this.seen = gen;
|
|
2098
|
+
}
|
|
2066
2099
|
}
|
|
2067
2100
|
stdioEntry(fd) {
|
|
2068
2101
|
let info;
|
|
@@ -2105,7 +2138,7 @@ var init_wasi_fds = __esm({
|
|
|
2105
2138
|
e.append = append;
|
|
2106
2139
|
if (this.shared) {
|
|
2107
2140
|
this.publishFlags(fd, e);
|
|
2108
|
-
this.bump();
|
|
2141
|
+
this.bump(fd);
|
|
2109
2142
|
}
|
|
2110
2143
|
} else if (e.type === "file") e.file.append = append;
|
|
2111
2144
|
}
|
|
@@ -2115,7 +2148,7 @@ var init_wasi_fds = __esm({
|
|
|
2115
2148
|
else this.cloexec.delete(fd);
|
|
2116
2149
|
if (this.shared) {
|
|
2117
2150
|
this.kernel.call({ op: "fd-cloexec", fd, on });
|
|
2118
|
-
this.bump();
|
|
2151
|
+
this.bump(fd);
|
|
2119
2152
|
}
|
|
2120
2153
|
}
|
|
2121
2154
|
cwd() {
|
|
@@ -2132,7 +2165,7 @@ var init_wasi_fds = __esm({
|
|
|
2132
2165
|
adopt(fd, kind, nonblock, dgram = false) {
|
|
2133
2166
|
this.table.set(fd, { type: "kernel", kind, dgram, nonblock, append: false });
|
|
2134
2167
|
if (this.shared && nonblock) this.publishFlags(fd, { nonblock, append: false });
|
|
2135
|
-
this.bump();
|
|
2168
|
+
this.bump(fd);
|
|
2136
2169
|
}
|
|
2137
2170
|
get(fd) {
|
|
2138
2171
|
const e = this.find(fd);
|
|
@@ -2157,7 +2190,7 @@ var init_wasi_fds = __esm({
|
|
|
2157
2190
|
...meta ? { meta } : {}
|
|
2158
2191
|
});
|
|
2159
2192
|
this.table.set(fd, e);
|
|
2160
|
-
this.bump();
|
|
2193
|
+
this.bump(fd);
|
|
2161
2194
|
return fd;
|
|
2162
2195
|
}
|
|
2163
2196
|
cloexec = /* @__PURE__ */ new Set();
|
|
@@ -2173,14 +2206,14 @@ var init_wasi_fds = __esm({
|
|
|
2173
2206
|
at = this.install(e.type === "file" ? e : { ...e }, min);
|
|
2174
2207
|
}
|
|
2175
2208
|
if (cloexec) this.setCloexec(at, true);
|
|
2176
|
-
this.bump();
|
|
2209
|
+
this.bump(at);
|
|
2177
2210
|
return at;
|
|
2178
2211
|
}
|
|
2179
2212
|
pipe() {
|
|
2180
2213
|
const [r, w] = this.kernel.sys.pipe();
|
|
2181
2214
|
this.table.set(r, { type: "kernel", kind: "stream", nonblock: false, append: false });
|
|
2182
2215
|
this.table.set(w, { type: "kernel", kind: "stream", nonblock: false, append: false });
|
|
2183
|
-
this.bump();
|
|
2216
|
+
this.bump(r, w);
|
|
2184
2217
|
return [r, w];
|
|
2185
2218
|
}
|
|
2186
2219
|
chdir(path) {
|
|
@@ -2280,7 +2313,7 @@ var init_wasi_fds = __esm({
|
|
|
2280
2313
|
} finally {
|
|
2281
2314
|
this.release(e);
|
|
2282
2315
|
this.dropLocks(e);
|
|
2283
|
-
this.bump();
|
|
2316
|
+
this.bump(fd);
|
|
2284
2317
|
}
|
|
2285
2318
|
}
|
|
2286
2319
|
renumber(from, to, keep = false) {
|
|
@@ -2299,7 +2332,7 @@ var init_wasi_fds = __esm({
|
|
|
2299
2332
|
}
|
|
2300
2333
|
if (old) this.release(old);
|
|
2301
2334
|
this.dropLocks(old);
|
|
2302
|
-
this.bump();
|
|
2335
|
+
this.bump(from, to);
|
|
2303
2336
|
}
|
|
2304
2337
|
release(e) {
|
|
2305
2338
|
if (e.type !== "file" || --e.file.refs > 0) return;
|
|
@@ -2487,7 +2520,6 @@ var init_wasi_fds = __esm({
|
|
|
2487
2520
|
kind = "tty";
|
|
2488
2521
|
} else return void 0;
|
|
2489
2522
|
this.adopt(fd, kind, nonblock);
|
|
2490
|
-
this.bump();
|
|
2491
2523
|
return fd;
|
|
2492
2524
|
}
|
|
2493
2525
|
openCharDevice(openDevice2, oflags, rights) {
|
|
@@ -2612,7 +2644,7 @@ var init_wasi_fds = __esm({
|
|
|
2612
2644
|
if (truncate) this.fs.touched?.(path, ino);
|
|
2613
2645
|
this.table.set(fd, { type: "kernel", kind: "file", nonblock: false, append, path, ino });
|
|
2614
2646
|
if (append) this.publishFlags(fd, { nonblock: false, append });
|
|
2615
|
-
this.bump();
|
|
2647
|
+
this.bump(fd);
|
|
2616
2648
|
return fd;
|
|
2617
2649
|
}
|
|
2618
2650
|
createNew(path, oflags, mode) {
|
|
@@ -2648,7 +2680,7 @@ var init_wasi_fds = __esm({
|
|
|
2648
2680
|
if (e.type === "kernel") {
|
|
2649
2681
|
const at = this.kernel.call({ op: "fd-dup", fd });
|
|
2650
2682
|
this.table.set(at, { ...e });
|
|
2651
|
-
this.bump();
|
|
2683
|
+
this.bump(at);
|
|
2652
2684
|
return at;
|
|
2653
2685
|
}
|
|
2654
2686
|
if (e.type === "file") e.file.refs++;
|
|
@@ -3689,6 +3721,7 @@ var init_wasi_host = __esm({
|
|
|
3689
3721
|
muted;
|
|
3690
3722
|
signals;
|
|
3691
3723
|
sigmask;
|
|
3724
|
+
tid = 1;
|
|
3692
3725
|
linkedTls;
|
|
3693
3726
|
threadEntry;
|
|
3694
3727
|
linkedModules;
|
|
@@ -4378,14 +4411,13 @@ var init_wasi_host = __esm({
|
|
|
4378
4411
|
brokenPipe() {
|
|
4379
4412
|
let action;
|
|
4380
4413
|
try {
|
|
4381
|
-
action = this.o.kernel.call({ op: "proc-kill-self", sig: SIG.PIPE,
|
|
4414
|
+
action = this.o.kernel.call({ op: "proc-kill-self", sig: SIG.PIPE, dry: true });
|
|
4382
4415
|
} catch {
|
|
4383
4416
|
action = "terminate";
|
|
4384
4417
|
}
|
|
4385
|
-
if (action
|
|
4386
|
-
|
|
4387
|
-
|
|
4388
|
-
this.o.kernel.call({ op: "thread-kill", tid: mask.tid, sig: SIG.PIPE });
|
|
4418
|
+
if (action === "ignore") return;
|
|
4419
|
+
if (action === "terminate" && !this.sigmask?.blocks(SIG.PIPE)) throw new WasiExit(SIGPIPE_EXIT);
|
|
4420
|
+
this.o.kernel.call({ op: "thread-kill", tid: this.tid, sig: SIG.PIPE });
|
|
4389
4421
|
}
|
|
4390
4422
|
read(fd, max) {
|
|
4391
4423
|
const e = this.fds.get(fd);
|
|
@@ -5172,7 +5204,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
5172
5204
|
var init_version = __esm({
|
|
5173
5205
|
"src/version.ts"() {
|
|
5174
5206
|
"use strict";
|
|
5175
|
-
KERNEL_VERSION = true ? "1.108.
|
|
5207
|
+
KERNEL_VERSION = true ? "1.108.5" : "0.0.0-dev";
|
|
5176
5208
|
OS_RELEASE = "6.0.0-slicc";
|
|
5177
5209
|
}
|
|
5178
5210
|
});
|
|
@@ -6934,10 +6966,28 @@ function createSyncSabTransport(sab, port3, deps = {}) {
|
|
|
6934
6966
|
const wait2 = deps.wait ?? ((a, i, v, t) => rawWait(a, i, v, t));
|
|
6935
6967
|
const now = deps.now ?? (() => performance.now());
|
|
6936
6968
|
let seq = 0;
|
|
6969
|
+
let typical = 0;
|
|
6970
|
+
const ready = (id) => Atomics.load(header, SAB_I_STATE) === SAB_STATE_READY && Atomics.load(header, SAB_I_SEQ) === id;
|
|
6971
|
+
function spinUntil(id, until) {
|
|
6972
|
+
for (let stride = 0; stride < SPIN_STRIDES; stride++) {
|
|
6973
|
+
for (let i = 0; i < SPIN_STRIDE; i++) if (ready(id)) return true;
|
|
6974
|
+
if (now() >= until) return false;
|
|
6975
|
+
}
|
|
6976
|
+
return false;
|
|
6977
|
+
}
|
|
6978
|
+
function settled2(start2) {
|
|
6979
|
+
typical += (Math.min(now() - start2, SPIN_CAP_MS) - typical) / 8;
|
|
6980
|
+
}
|
|
6937
6981
|
function awaitReady(id, deadline, label) {
|
|
6982
|
+
const start2 = now();
|
|
6983
|
+
if (spinning && typical < SPIN_MS && spinUntil(id, start2 + SPIN_MS)) {
|
|
6984
|
+
settled2(start2);
|
|
6985
|
+
return;
|
|
6986
|
+
}
|
|
6938
6987
|
for (; ; ) {
|
|
6939
6988
|
const published = Atomics.load(header, SAB_I_PUB);
|
|
6940
|
-
if (
|
|
6989
|
+
if (ready(id)) {
|
|
6990
|
+
settled2(start2);
|
|
6941
6991
|
return;
|
|
6942
6992
|
}
|
|
6943
6993
|
const remaining = deadline - now();
|
|
@@ -7145,7 +7195,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
7145
7195
|
statfs: (path = "/") => parseSyncFsUsage(json2({ op: "statfs", path }, path))
|
|
7146
7196
|
};
|
|
7147
7197
|
}
|
|
7148
|
-
var PATH_OPS, calls;
|
|
7198
|
+
var PATH_OPS, calls, SPIN_MS, SPIN_STRIDE, SPIN_STRIDES, SPIN_CORES, spinning, SPIN_CAP_MS;
|
|
7149
7199
|
var init_sync_sab_bridge = __esm({
|
|
7150
7200
|
"src/realm/sync-sab-bridge.ts"() {
|
|
7151
7201
|
"use strict";
|
|
@@ -7155,6 +7205,12 @@ var init_sync_sab_bridge = __esm({
|
|
|
7155
7205
|
init_sync_sab_wire();
|
|
7156
7206
|
PATH_OPS = new Set(SYNC_FS_OPS);
|
|
7157
7207
|
calls = 0;
|
|
7208
|
+
SPIN_MS = 0.06;
|
|
7209
|
+
SPIN_STRIDE = 128;
|
|
7210
|
+
SPIN_STRIDES = 256;
|
|
7211
|
+
SPIN_CORES = 4;
|
|
7212
|
+
spinning = (globalThis.navigator?.hardwareConcurrency ?? 0) >= SPIN_CORES;
|
|
7213
|
+
SPIN_CAP_MS = 1;
|
|
7158
7214
|
}
|
|
7159
7215
|
});
|
|
7160
7216
|
|
|
@@ -16033,6 +16089,7 @@ async function runWasiThread(init, port3) {
|
|
|
16033
16089
|
),
|
|
16034
16090
|
shared: threads.ids
|
|
16035
16091
|
});
|
|
16092
|
+
host.tid = thread.tid;
|
|
16036
16093
|
host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
|
|
16037
16094
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
16038
16095
|
const { module } = init.program;
|