@ai-ecoverse/slicc-kernel 1.94.4 → 1.95.0
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 +85 -3
- package/dist/kernel-worker.js +393 -54
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +108 -21
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +391 -52
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +108 -21
- package/dist/process-worker.js.map +4 -4
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -1042,11 +1042,11 @@ function createSyncSabTransport(sab, port2, deps = {}) {
|
|
|
1042
1042
|
}
|
|
1043
1043
|
}
|
|
1044
1044
|
return {
|
|
1045
|
-
call(req,
|
|
1045
|
+
call(req, timeoutMs2, label, transfer = []) {
|
|
1046
1046
|
if (deps.memory) publishMemory(sab, deps.memory());
|
|
1047
1047
|
const id = ++seq;
|
|
1048
1048
|
calls += Number(!PATH_OPS.has(req.op));
|
|
1049
|
-
const deadline = now() +
|
|
1049
|
+
const deadline = now() + timeoutMs2;
|
|
1050
1050
|
let out = null;
|
|
1051
1051
|
let status2 = 0;
|
|
1052
1052
|
let offset = 0;
|
|
@@ -1089,12 +1089,12 @@ function errnoError(code2, path) {
|
|
|
1089
1089
|
return syncError(code2, `sync-sab bridge, '${path}'`);
|
|
1090
1090
|
}
|
|
1091
1091
|
function createSyncFsSabBridge(transport, opts = {}) {
|
|
1092
|
-
const
|
|
1092
|
+
const timeoutMs2 = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
1093
1093
|
let identity = {};
|
|
1094
1094
|
let last = null;
|
|
1095
1095
|
function run(req, path, transfer) {
|
|
1096
1096
|
last = null;
|
|
1097
|
-
const result = transport.call(req,
|
|
1097
|
+
const result = transport.call(req, timeoutMs2, `sync-sab bridge, '${path}'`, transfer);
|
|
1098
1098
|
if (!result.ok) throw errnoError(result.errno, path);
|
|
1099
1099
|
return result;
|
|
1100
1100
|
}
|
|
@@ -4149,11 +4149,11 @@ function drain(Fs, stream) {
|
|
|
4149
4149
|
}
|
|
4150
4150
|
return out;
|
|
4151
4151
|
}
|
|
4152
|
-
function kernelSelect(Fs, transport, read2, write2,
|
|
4152
|
+
function kernelSelect(Fs, transport, read2, write2, timeoutMs2) {
|
|
4153
4153
|
const kernel = (fd) => Fs.getStream(fd)?.sliccKernelFd;
|
|
4154
4154
|
const kr = read2.map(kernel);
|
|
4155
4155
|
const kw = write2.map(kernel);
|
|
4156
|
-
const r = transport.call({ op: "fd-select", read: kr, write: kw, timeoutMs }, Infinity, "select");
|
|
4156
|
+
const r = transport.call({ op: "fd-select", read: kr, write: kw, timeoutMs: timeoutMs2 }, Infinity, "select");
|
|
4157
4157
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
4158
4158
|
const got = r.kind === "json" ? r.json : { read: [], write: [] };
|
|
4159
4159
|
return {
|
|
@@ -4172,11 +4172,11 @@ function ownReady(Fs, read2, write2) {
|
|
|
4172
4172
|
write: write2.filter((fd) => flags(fd) & (POLLOUT2 | POLLERR2 | POLLNVAL))
|
|
4173
4173
|
};
|
|
4174
4174
|
}
|
|
4175
|
-
function anySelect(Fs, transport, read2, write2,
|
|
4175
|
+
function anySelect(Fs, transport, read2, write2, timeoutMs2) {
|
|
4176
4176
|
const kernel = (fd) => Fs.getStream(fd)?.sliccKernelFd;
|
|
4177
4177
|
const own = (fd) => kernel(fd) === void 0;
|
|
4178
|
-
if (![...read2, ...write2].some(own)) return kernelSelect(Fs, transport, read2, write2,
|
|
4179
|
-
const deadline =
|
|
4178
|
+
if (![...read2, ...write2].some(own)) return kernelSelect(Fs, transport, read2, write2, timeoutMs2);
|
|
4179
|
+
const deadline = timeoutMs2 < 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs2;
|
|
4180
4180
|
const kernelRead = read2.filter((fd) => !own(fd));
|
|
4181
4181
|
const kernelWrite = write2.filter((fd) => !own(fd));
|
|
4182
4182
|
for (; ; ) {
|
|
@@ -4287,7 +4287,7 @@ function createProcessKernel(deps) {
|
|
|
4287
4287
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
4288
4288
|
return r.kind === "json" ? r.json : -wasiErrno("EIO");
|
|
4289
4289
|
},
|
|
4290
|
-
select: (read2, write2,
|
|
4290
|
+
select: (read2, write2, timeoutMs2) => anySelect(Fs, transport, read2, write2, timeoutMs2),
|
|
4291
4291
|
execWait,
|
|
4292
4292
|
execve(file, argv, env, cwd) {
|
|
4293
4293
|
const pid = spawnChild(file, argv, env, cwd, [0, 1, 2], void 0, true);
|
|
@@ -4434,11 +4434,11 @@ var init_process_signals = __esm({
|
|
|
4434
4434
|
}
|
|
4435
4435
|
transport() {
|
|
4436
4436
|
return {
|
|
4437
|
-
call: (req,
|
|
4437
|
+
call: (req, timeoutMs2, label) => {
|
|
4438
4438
|
this.report();
|
|
4439
4439
|
this.depth++;
|
|
4440
4440
|
try {
|
|
4441
|
-
const result = this.raw.call(req,
|
|
4441
|
+
const result = this.raw.call(req, timeoutMs2, label);
|
|
4442
4442
|
this.deliver();
|
|
4443
4443
|
return result;
|
|
4444
4444
|
} finally {
|
|
@@ -4703,7 +4703,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4703
4703
|
var init_version = __esm({
|
|
4704
4704
|
"src/version.ts"() {
|
|
4705
4705
|
"use strict";
|
|
4706
|
-
KERNEL_VERSION = true ? "1.
|
|
4706
|
+
KERNEL_VERSION = true ? "1.95.0" : "0.0.0-dev";
|
|
4707
4707
|
OS_RELEASE = "6.0.0-slicc";
|
|
4708
4708
|
}
|
|
4709
4709
|
});
|
|
@@ -5408,9 +5408,9 @@ function bridgeFlags(init) {
|
|
|
5408
5408
|
}
|
|
5409
5409
|
function credSyncTransport(gated, early, cred) {
|
|
5410
5410
|
return {
|
|
5411
|
-
call: (req,
|
|
5411
|
+
call: (req, timeoutMs2, label) => {
|
|
5412
5412
|
if (!FS_OPS.has(req.op)) early();
|
|
5413
|
-
const r = gated.call(req,
|
|
5413
|
+
const r = gated.call(req, timeoutMs2, label);
|
|
5414
5414
|
if (cred && req.op === "proc-setcred" && r.ok && r.kind === "json")
|
|
5415
5415
|
Object.assign(cred, r.json);
|
|
5416
5416
|
return r;
|
|
@@ -7339,9 +7339,9 @@ function readyEvents(subs, ready) {
|
|
|
7339
7339
|
hangup: ready.hangup?.includes(s.fd) === true
|
|
7340
7340
|
}));
|
|
7341
7341
|
}
|
|
7342
|
-
function selectOnce(deps, read2, write2,
|
|
7342
|
+
function selectOnce(deps, read2, write2, timeoutMs2) {
|
|
7343
7343
|
try {
|
|
7344
|
-
const ready = deps.kernel.call({ op: "fd-select", read: read2, write: write2, timeoutMs });
|
|
7344
|
+
const ready = deps.kernel.call({ op: "fd-select", read: read2, write: write2, timeoutMs: timeoutMs2 });
|
|
7345
7345
|
return { ready, interrupted: false };
|
|
7346
7346
|
} catch (e) {
|
|
7347
7347
|
if (!deps.interruptWakes || e.code !== "EINTR") throw e;
|
|
@@ -8815,16 +8815,16 @@ function importsContext({
|
|
|
8815
8815
|
...processes(host, call2, tid !== MAIN_TID),
|
|
8816
8816
|
async: {
|
|
8817
8817
|
submit: (req) => call2({ op: "async-submit", req }),
|
|
8818
|
-
wait(
|
|
8818
|
+
wait(timeoutMs2) {
|
|
8819
8819
|
for (; ; ) {
|
|
8820
8820
|
try {
|
|
8821
8821
|
return call2({
|
|
8822
8822
|
op: "async-wait",
|
|
8823
|
-
...
|
|
8823
|
+
...timeoutMs2 !== void 0 ? { timeoutMs: timeoutMs2 } : {}
|
|
8824
8824
|
});
|
|
8825
8825
|
} catch (err) {
|
|
8826
8826
|
if (code(err) !== "EINTR") throw err;
|
|
8827
|
-
if (
|
|
8827
|
+
if (timeoutMs2 !== void 0) return 0;
|
|
8828
8828
|
}
|
|
8829
8829
|
}
|
|
8830
8830
|
},
|
|
@@ -9717,6 +9717,91 @@ var init_wasix_fork = __esm({
|
|
|
9717
9717
|
}
|
|
9718
9718
|
});
|
|
9719
9719
|
|
|
9720
|
+
// src/process/wasi/wasix-epoll.ts
|
|
9721
|
+
function timeoutMs(ns) {
|
|
9722
|
+
const value2 = BigInt.asUintN(64, ns);
|
|
9723
|
+
if (value2 === FOREVER) return -1;
|
|
9724
|
+
const ms = (value2 + NS_PER_MS2 - 1n) / NS_PER_MS2;
|
|
9725
|
+
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
9726
|
+
}
|
|
9727
|
+
function wasixEpollImports(host) {
|
|
9728
|
+
const { mem, fds, o } = host;
|
|
9729
|
+
const call2 = (req) => o.kernel.call(req);
|
|
9730
|
+
const kernelFd = (fd, refusal2) => {
|
|
9731
|
+
const e = fds.find(fd);
|
|
9732
|
+
if (!e) throw new WasiError("EBADF");
|
|
9733
|
+
if (e.type !== "kernel") throw new WasiError(refusal2);
|
|
9734
|
+
};
|
|
9735
|
+
const writeEvents2 = (ptr, events) => {
|
|
9736
|
+
const view = mem.view();
|
|
9737
|
+
events.forEach((ev, i) => {
|
|
9738
|
+
const at = ptr + i * EVENT_SIZE;
|
|
9739
|
+
mem.bytes(at, EVENT_SIZE).fill(0);
|
|
9740
|
+
view.setUint32(at, ev.events, true);
|
|
9741
|
+
mem.bytes(at + DATA_OFFSET, DATA_SIZE).set(ev.data);
|
|
9742
|
+
});
|
|
9743
|
+
};
|
|
9744
|
+
return {
|
|
9745
|
+
epoll_create: (out) => {
|
|
9746
|
+
const fd = call2({ op: "epoll-create" });
|
|
9747
|
+
fds.adopt(fd, "stream", false);
|
|
9748
|
+
mem.view().setUint32(out, fd, true);
|
|
9749
|
+
},
|
|
9750
|
+
epoll_ctl: (epfd, op, fd, event) => {
|
|
9751
|
+
const how = OPS[op];
|
|
9752
|
+
if (!how) throw new WasiError("EINVAL");
|
|
9753
|
+
kernelFd(epfd, "EINVAL");
|
|
9754
|
+
kernelFd(fd, "EPERM");
|
|
9755
|
+
if (how !== "del" && event === 0) throw new WasiError("EINVAL");
|
|
9756
|
+
const events = event === 0 ? 0 : mem.view().getUint32(event, true);
|
|
9757
|
+
const data = event === 0 ? [] : [...mem.bytes(event + DATA_OFFSET, DATA_SIZE)];
|
|
9758
|
+
call2({ op: "epoll-ctl", epfd, how, fd, events, data });
|
|
9759
|
+
},
|
|
9760
|
+
epoll_wait: (epfd, ptr, maxevents, timeout, out) => {
|
|
9761
|
+
mem.view().setUint32(out, 0, true);
|
|
9762
|
+
if ((maxevents | 0) <= 0) throw new WasiError("EINVAL");
|
|
9763
|
+
kernelFd(epfd, "EINVAL");
|
|
9764
|
+
const max = Math.min(maxevents | 0, MAX_EVENTS);
|
|
9765
|
+
const ms = host.entered ? 0 : timeoutMs(timeout);
|
|
9766
|
+
const events = call2({ op: "epoll-wait", epfd, max, timeoutMs: ms });
|
|
9767
|
+
if (host.entered && events.length === 0 && timeoutMs(timeout) !== 0) return E.INTR;
|
|
9768
|
+
writeEvents2(ptr, events);
|
|
9769
|
+
mem.view().setUint32(out, events.length, true);
|
|
9770
|
+
return E.SUCCESS;
|
|
9771
|
+
},
|
|
9772
|
+
fd_event: (initial, flags, out) => {
|
|
9773
|
+
const value2 = BigInt.asUintN(64, initial);
|
|
9774
|
+
if (value2 > EVENTFD_MAX) throw new WasiError("EINVAL");
|
|
9775
|
+
const fd = call2({
|
|
9776
|
+
op: "eventfd-open",
|
|
9777
|
+
initial: value2.toString(),
|
|
9778
|
+
semaphore: (flags & EVENTFD_SEMAPHORE) !== 0
|
|
9779
|
+
});
|
|
9780
|
+
fds.adopt(fd, "stream", (flags & EVENTFD_NONBLOCK) !== 0);
|
|
9781
|
+
mem.view().setUint32(out, fd, true);
|
|
9782
|
+
}
|
|
9783
|
+
};
|
|
9784
|
+
}
|
|
9785
|
+
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER, MAX_TIMEOUT_MS, NS_PER_MS2, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, OPS;
|
|
9786
|
+
var init_wasix_epoll = __esm({
|
|
9787
|
+
"src/process/wasi/wasix-epoll.ts"() {
|
|
9788
|
+
"use strict";
|
|
9789
|
+
init_wasi_abi();
|
|
9790
|
+
init_wasi_files();
|
|
9791
|
+
EVENT_SIZE = 32;
|
|
9792
|
+
DATA_OFFSET = 8;
|
|
9793
|
+
DATA_SIZE = 24;
|
|
9794
|
+
MAX_EVENTS = 4096;
|
|
9795
|
+
FOREVER = 0xffffffffffffffffn;
|
|
9796
|
+
MAX_TIMEOUT_MS = 2147483647;
|
|
9797
|
+
NS_PER_MS2 = 1000000n;
|
|
9798
|
+
EVENTFD_SEMAPHORE = 1;
|
|
9799
|
+
EVENTFD_NONBLOCK = 4;
|
|
9800
|
+
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
9801
|
+
OPS = ["add", "set", "del", "mod"];
|
|
9802
|
+
}
|
|
9803
|
+
});
|
|
9804
|
+
|
|
9720
9805
|
// src/process/wasi/wasix-ffi.ts
|
|
9721
9806
|
function read(view, at, type) {
|
|
9722
9807
|
if (type === "i32") return view.getInt32(at, true);
|
|
@@ -10899,6 +10984,7 @@ var init_wasix_host = __esm({
|
|
|
10899
10984
|
init_wasi_host();
|
|
10900
10985
|
init_wasi_module();
|
|
10901
10986
|
init_wasi_threads();
|
|
10987
|
+
init_wasix_epoll();
|
|
10902
10988
|
init_wasix_ffi();
|
|
10903
10989
|
init_wasix_linker();
|
|
10904
10990
|
init_wasix_process();
|
|
@@ -11025,7 +11111,8 @@ var init_wasix_host = __esm({
|
|
|
11025
11111
|
{ mem: this.mem, table: () => this.table, types: this.types },
|
|
11026
11112
|
...a
|
|
11027
11113
|
),
|
|
11028
|
-
...wasixSocketImports(this.host, this.host.imports())
|
|
11114
|
+
...wasixSocketImports(this.host, this.host.imports()),
|
|
11115
|
+
...wasixEpollImports(this.host)
|
|
11029
11116
|
});
|
|
11030
11117
|
}
|
|
11031
11118
|
preview1() {
|