@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
package/dist/process-worker.js
CHANGED
|
@@ -1070,10 +1070,28 @@ function createSyncSabTransport(sab, port2, deps = {}) {
|
|
|
1070
1070
|
const wait2 = deps.wait ?? ((a, i, v, t) => rawWait(a, i, v, t));
|
|
1071
1071
|
const now = deps.now ?? (() => performance.now());
|
|
1072
1072
|
let seq = 0;
|
|
1073
|
+
let typical = 0;
|
|
1074
|
+
const ready = (id) => Atomics.load(header, SAB_I_STATE) === SAB_STATE_READY && Atomics.load(header, SAB_I_SEQ) === id;
|
|
1075
|
+
function spinUntil(id, until) {
|
|
1076
|
+
for (let stride = 0; stride < SPIN_STRIDES; stride++) {
|
|
1077
|
+
for (let i = 0; i < SPIN_STRIDE; i++) if (ready(id)) return true;
|
|
1078
|
+
if (now() >= until) return false;
|
|
1079
|
+
}
|
|
1080
|
+
return false;
|
|
1081
|
+
}
|
|
1082
|
+
function settled2(start2) {
|
|
1083
|
+
typical += (Math.min(now() - start2, SPIN_CAP_MS) - typical) / 8;
|
|
1084
|
+
}
|
|
1073
1085
|
function awaitReady(id, deadline, label) {
|
|
1086
|
+
const start2 = now();
|
|
1087
|
+
if (spinning && typical < SPIN_MS && spinUntil(id, start2 + SPIN_MS)) {
|
|
1088
|
+
settled2(start2);
|
|
1089
|
+
return;
|
|
1090
|
+
}
|
|
1074
1091
|
for (; ; ) {
|
|
1075
1092
|
const published = Atomics.load(header, SAB_I_PUB);
|
|
1076
|
-
if (
|
|
1093
|
+
if (ready(id)) {
|
|
1094
|
+
settled2(start2);
|
|
1077
1095
|
return;
|
|
1078
1096
|
}
|
|
1079
1097
|
const remaining = deadline - now();
|
|
@@ -1281,7 +1299,7 @@ function createSyncFsSabBridge(transport, opts = {}) {
|
|
|
1281
1299
|
statfs: (path = "/") => parseSyncFsUsage(json2({ op: "statfs", path }, path))
|
|
1282
1300
|
};
|
|
1283
1301
|
}
|
|
1284
|
-
var PATH_OPS, calls;
|
|
1302
|
+
var PATH_OPS, calls, SPIN_MS, SPIN_STRIDE, SPIN_STRIDES, SPIN_CORES, spinning, SPIN_CAP_MS;
|
|
1285
1303
|
var init_sync_sab_bridge = __esm({
|
|
1286
1304
|
"src/realm/sync-sab-bridge.ts"() {
|
|
1287
1305
|
"use strict";
|
|
@@ -1291,6 +1309,12 @@ var init_sync_sab_bridge = __esm({
|
|
|
1291
1309
|
init_sync_sab_wire();
|
|
1292
1310
|
PATH_OPS = new Set(SYNC_FS_OPS);
|
|
1293
1311
|
calls = 0;
|
|
1312
|
+
SPIN_MS = 0.06;
|
|
1313
|
+
SPIN_STRIDE = 128;
|
|
1314
|
+
SPIN_STRIDES = 256;
|
|
1315
|
+
SPIN_CORES = 4;
|
|
1316
|
+
spinning = (globalThis.navigator?.hardwareConcurrency ?? 0) >= SPIN_CORES;
|
|
1317
|
+
SPIN_CAP_MS = 1;
|
|
1294
1318
|
}
|
|
1295
1319
|
});
|
|
1296
1320
|
|
|
@@ -2491,7 +2515,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2491
2515
|
var init_version = __esm({
|
|
2492
2516
|
"src/version.ts"() {
|
|
2493
2517
|
"use strict";
|
|
2494
|
-
KERNEL_VERSION = true ? "1.108.
|
|
2518
|
+
KERNEL_VERSION = true ? "1.108.5" : "0.0.0-dev";
|
|
2495
2519
|
OS_RELEASE = "6.0.0-slicc";
|
|
2496
2520
|
}
|
|
2497
2521
|
});
|
|
@@ -6444,7 +6468,7 @@ function pinnedIo2(bridge, handle, rewriting) {
|
|
|
6444
6468
|
} : {}
|
|
6445
6469
|
};
|
|
6446
6470
|
}
|
|
6447
|
-
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, SHARED_IDS_BYTES, StatCache;
|
|
6471
|
+
var WasiError, FileBuffer, LocalFile, MAX_LINKS, MISS_TTL_MS, CACHE_CAP, FS_GEN, CRED_GEN, RING2, RING_SIZE2, SLOT2, FD_RING, FD_RING_SIZE, SHARED_IDS_BYTES, StatCache;
|
|
6448
6472
|
var init_wasi_files = __esm({
|
|
6449
6473
|
"src/process/wasi/wasi-files.ts"() {
|
|
6450
6474
|
"use strict";
|
|
@@ -6671,7 +6695,9 @@ var init_wasi_files = __esm({
|
|
|
6671
6695
|
RING2 = 8;
|
|
6672
6696
|
RING_SIZE2 = 64;
|
|
6673
6697
|
SLOT2 = 3;
|
|
6674
|
-
|
|
6698
|
+
FD_RING = RING2 + RING_SIZE2 * SLOT2;
|
|
6699
|
+
FD_RING_SIZE = 64;
|
|
6700
|
+
SHARED_IDS_BYTES = (FD_RING + FD_RING_SIZE * 2) * 4;
|
|
6675
6701
|
StatCache = class {
|
|
6676
6702
|
stats = /* @__PURE__ */ new Map();
|
|
6677
6703
|
lstats = /* @__PURE__ */ new Map();
|
|
@@ -6997,6 +7023,9 @@ function within(path, root) {
|
|
|
6997
7023
|
function kernelEntry2() {
|
|
6998
7024
|
return { type: "kernel", nonblock: false, append: false };
|
|
6999
7025
|
}
|
|
7026
|
+
function ringed(shared) {
|
|
7027
|
+
return shared.length >= FD_RING + FD_RING_SIZE * 2;
|
|
7028
|
+
}
|
|
7000
7029
|
function deviceEntry(meta) {
|
|
7001
7030
|
return { type: "device", device: meta.device, ...meta.access ? { access: meta.access } : {} };
|
|
7002
7031
|
}
|
|
@@ -7164,16 +7193,44 @@ var init_wasi_fds = __esm({
|
|
|
7164
7193
|
this.seen = Atomics.load(ids, GEN2);
|
|
7165
7194
|
}
|
|
7166
7195
|
sync() {
|
|
7167
|
-
const
|
|
7196
|
+
const shared = this.shared;
|
|
7197
|
+
const gen = Atomics.load(shared, GEN2);
|
|
7168
7198
|
if (gen === this.seen) return;
|
|
7169
|
-
this.
|
|
7170
|
-
|
|
7199
|
+
if (!this.replay(shared, gen)) {
|
|
7200
|
+
this.table.clear();
|
|
7201
|
+
this.cloexec.clear();
|
|
7202
|
+
}
|
|
7171
7203
|
this.seen = gen;
|
|
7172
7204
|
}
|
|
7173
|
-
|
|
7205
|
+
replay(shared, upTo) {
|
|
7206
|
+
if (upTo - this.seen > FD_RING_SIZE || !ringed(shared)) return false;
|
|
7207
|
+
const changed2 = [];
|
|
7208
|
+
for (let g = this.seen + 1; g <= upTo; g++) {
|
|
7209
|
+
const at = FD_RING + g % FD_RING_SIZE * 2;
|
|
7210
|
+
if (Atomics.load(shared, at) !== g) return false;
|
|
7211
|
+
const fd = Atomics.load(shared, at + 1);
|
|
7212
|
+
if (fd < 0 || Atomics.load(shared, at) !== g) return false;
|
|
7213
|
+
changed2.push(fd);
|
|
7214
|
+
}
|
|
7215
|
+
for (const fd of changed2) {
|
|
7216
|
+
this.table.delete(fd);
|
|
7217
|
+
this.cloexec.delete(fd);
|
|
7218
|
+
}
|
|
7219
|
+
return true;
|
|
7220
|
+
}
|
|
7221
|
+
bump(...fds) {
|
|
7174
7222
|
if (!this.shared) return;
|
|
7175
|
-
const
|
|
7176
|
-
|
|
7223
|
+
const shared = this.shared;
|
|
7224
|
+
for (const fd of fds.length > 0 ? fds : [-1]) {
|
|
7225
|
+
const gen = Atomics.add(shared, GEN2, 1) + 1;
|
|
7226
|
+
if (ringed(shared)) {
|
|
7227
|
+
const at = FD_RING + gen % FD_RING_SIZE * 2;
|
|
7228
|
+
Atomics.store(shared, at, 0);
|
|
7229
|
+
Atomics.store(shared, at + 1, fd);
|
|
7230
|
+
Atomics.store(shared, at, gen);
|
|
7231
|
+
}
|
|
7232
|
+
if (gen - 1 === this.seen) this.seen = gen;
|
|
7233
|
+
}
|
|
7177
7234
|
}
|
|
7178
7235
|
stdioEntry(fd) {
|
|
7179
7236
|
let info;
|
|
@@ -7216,7 +7273,7 @@ var init_wasi_fds = __esm({
|
|
|
7216
7273
|
e.append = append;
|
|
7217
7274
|
if (this.shared) {
|
|
7218
7275
|
this.publishFlags(fd, e);
|
|
7219
|
-
this.bump();
|
|
7276
|
+
this.bump(fd);
|
|
7220
7277
|
}
|
|
7221
7278
|
} else if (e.type === "file") e.file.append = append;
|
|
7222
7279
|
}
|
|
@@ -7226,7 +7283,7 @@ var init_wasi_fds = __esm({
|
|
|
7226
7283
|
else this.cloexec.delete(fd);
|
|
7227
7284
|
if (this.shared) {
|
|
7228
7285
|
this.kernel.call({ op: "fd-cloexec", fd, on });
|
|
7229
|
-
this.bump();
|
|
7286
|
+
this.bump(fd);
|
|
7230
7287
|
}
|
|
7231
7288
|
}
|
|
7232
7289
|
cwd() {
|
|
@@ -7243,7 +7300,7 @@ var init_wasi_fds = __esm({
|
|
|
7243
7300
|
adopt(fd, kind, nonblock, dgram = false) {
|
|
7244
7301
|
this.table.set(fd, { type: "kernel", kind, dgram, nonblock, append: false });
|
|
7245
7302
|
if (this.shared && nonblock) this.publishFlags(fd, { nonblock, append: false });
|
|
7246
|
-
this.bump();
|
|
7303
|
+
this.bump(fd);
|
|
7247
7304
|
}
|
|
7248
7305
|
get(fd) {
|
|
7249
7306
|
const e = this.find(fd);
|
|
@@ -7268,7 +7325,7 @@ var init_wasi_fds = __esm({
|
|
|
7268
7325
|
...meta ? { meta } : {}
|
|
7269
7326
|
});
|
|
7270
7327
|
this.table.set(fd, e);
|
|
7271
|
-
this.bump();
|
|
7328
|
+
this.bump(fd);
|
|
7272
7329
|
return fd;
|
|
7273
7330
|
}
|
|
7274
7331
|
cloexec = /* @__PURE__ */ new Set();
|
|
@@ -7284,14 +7341,14 @@ var init_wasi_fds = __esm({
|
|
|
7284
7341
|
at = this.install(e.type === "file" ? e : { ...e }, min);
|
|
7285
7342
|
}
|
|
7286
7343
|
if (cloexec) this.setCloexec(at, true);
|
|
7287
|
-
this.bump();
|
|
7344
|
+
this.bump(at);
|
|
7288
7345
|
return at;
|
|
7289
7346
|
}
|
|
7290
7347
|
pipe() {
|
|
7291
7348
|
const [r, w] = this.kernel.sys.pipe();
|
|
7292
7349
|
this.table.set(r, { type: "kernel", kind: "stream", nonblock: false, append: false });
|
|
7293
7350
|
this.table.set(w, { type: "kernel", kind: "stream", nonblock: false, append: false });
|
|
7294
|
-
this.bump();
|
|
7351
|
+
this.bump(r, w);
|
|
7295
7352
|
return [r, w];
|
|
7296
7353
|
}
|
|
7297
7354
|
chdir(path) {
|
|
@@ -7391,7 +7448,7 @@ var init_wasi_fds = __esm({
|
|
|
7391
7448
|
} finally {
|
|
7392
7449
|
this.release(e);
|
|
7393
7450
|
this.dropLocks(e);
|
|
7394
|
-
this.bump();
|
|
7451
|
+
this.bump(fd);
|
|
7395
7452
|
}
|
|
7396
7453
|
}
|
|
7397
7454
|
renumber(from, to, keep = false) {
|
|
@@ -7410,7 +7467,7 @@ var init_wasi_fds = __esm({
|
|
|
7410
7467
|
}
|
|
7411
7468
|
if (old) this.release(old);
|
|
7412
7469
|
this.dropLocks(old);
|
|
7413
|
-
this.bump();
|
|
7470
|
+
this.bump(from, to);
|
|
7414
7471
|
}
|
|
7415
7472
|
release(e) {
|
|
7416
7473
|
if (e.type !== "file" || --e.file.refs > 0) return;
|
|
@@ -7598,7 +7655,6 @@ var init_wasi_fds = __esm({
|
|
|
7598
7655
|
kind = "tty";
|
|
7599
7656
|
} else return void 0;
|
|
7600
7657
|
this.adopt(fd, kind, nonblock);
|
|
7601
|
-
this.bump();
|
|
7602
7658
|
return fd;
|
|
7603
7659
|
}
|
|
7604
7660
|
openCharDevice(openDevice2, oflags, rights) {
|
|
@@ -7723,7 +7779,7 @@ var init_wasi_fds = __esm({
|
|
|
7723
7779
|
if (truncate) this.fs.touched?.(path, ino);
|
|
7724
7780
|
this.table.set(fd, { type: "kernel", kind: "file", nonblock: false, append, path, ino });
|
|
7725
7781
|
if (append) this.publishFlags(fd, { nonblock: false, append });
|
|
7726
|
-
this.bump();
|
|
7782
|
+
this.bump(fd);
|
|
7727
7783
|
return fd;
|
|
7728
7784
|
}
|
|
7729
7785
|
createNew(path, oflags, mode) {
|
|
@@ -7759,7 +7815,7 @@ var init_wasi_fds = __esm({
|
|
|
7759
7815
|
if (e.type === "kernel") {
|
|
7760
7816
|
const at = this.kernel.call({ op: "fd-dup", fd });
|
|
7761
7817
|
this.table.set(at, { ...e });
|
|
7762
|
-
this.bump();
|
|
7818
|
+
this.bump(at);
|
|
7763
7819
|
return at;
|
|
7764
7820
|
}
|
|
7765
7821
|
if (e.type === "file") e.file.refs++;
|
|
@@ -8754,6 +8810,7 @@ var init_wasi_host = __esm({
|
|
|
8754
8810
|
muted;
|
|
8755
8811
|
signals;
|
|
8756
8812
|
sigmask;
|
|
8813
|
+
tid = 1;
|
|
8757
8814
|
linkedTls;
|
|
8758
8815
|
threadEntry;
|
|
8759
8816
|
linkedModules;
|
|
@@ -9443,14 +9500,13 @@ var init_wasi_host = __esm({
|
|
|
9443
9500
|
brokenPipe() {
|
|
9444
9501
|
let action;
|
|
9445
9502
|
try {
|
|
9446
|
-
action = this.o.kernel.call({ op: "proc-kill-self", sig: SIG.PIPE,
|
|
9503
|
+
action = this.o.kernel.call({ op: "proc-kill-self", sig: SIG.PIPE, dry: true });
|
|
9447
9504
|
} catch {
|
|
9448
9505
|
action = "terminate";
|
|
9449
9506
|
}
|
|
9450
|
-
if (action
|
|
9451
|
-
|
|
9452
|
-
|
|
9453
|
-
this.o.kernel.call({ op: "thread-kill", tid: mask.tid, sig: SIG.PIPE });
|
|
9507
|
+
if (action === "ignore") return;
|
|
9508
|
+
if (action === "terminate" && !this.sigmask?.blocks(SIG.PIPE)) throw new WasiExit(SIGPIPE_EXIT);
|
|
9509
|
+
this.o.kernel.call({ op: "thread-kill", tid: this.tid, sig: SIG.PIPE });
|
|
9454
9510
|
}
|
|
9455
9511
|
read(fd, max) {
|
|
9456
9512
|
const e = this.fds.get(fd);
|
|
@@ -12901,6 +12957,7 @@ async function runWasiThread(init, port2) {
|
|
|
12901
12957
|
),
|
|
12902
12958
|
shared: threads.ids
|
|
12903
12959
|
});
|
|
12960
|
+
host.tid = thread.tid;
|
|
12904
12961
|
host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
|
|
12905
12962
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
12906
12963
|
const { module } = init.program;
|