@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
|
@@ -2434,9 +2434,9 @@ function readyEvents(subs, ready) {
|
|
|
2434
2434
|
hangup: ready.hangup?.includes(s.fd) === true
|
|
2435
2435
|
}));
|
|
2436
2436
|
}
|
|
2437
|
-
function selectOnce(deps, read2, write2,
|
|
2437
|
+
function selectOnce(deps, read2, write2, timeoutMs2) {
|
|
2438
2438
|
try {
|
|
2439
|
-
const ready = deps.kernel.call({ op: "fd-select", read: read2, write: write2, timeoutMs });
|
|
2439
|
+
const ready = deps.kernel.call({ op: "fd-select", read: read2, write: write2, timeoutMs: timeoutMs2 });
|
|
2440
2440
|
return { ready, interrupted: false };
|
|
2441
2441
|
} catch (e) {
|
|
2442
2442
|
if (!deps.interruptWakes || e.code !== "EINTR") throw e;
|
|
@@ -3835,16 +3835,16 @@ function importsContext({
|
|
|
3835
3835
|
...processes(host, call2, tid !== MAIN_TID),
|
|
3836
3836
|
async: {
|
|
3837
3837
|
submit: (req) => call2({ op: "async-submit", req }),
|
|
3838
|
-
wait(
|
|
3838
|
+
wait(timeoutMs2) {
|
|
3839
3839
|
for (; ; ) {
|
|
3840
3840
|
try {
|
|
3841
3841
|
return call2({
|
|
3842
3842
|
op: "async-wait",
|
|
3843
|
-
...
|
|
3843
|
+
...timeoutMs2 !== void 0 ? { timeoutMs: timeoutMs2 } : {}
|
|
3844
3844
|
});
|
|
3845
3845
|
} catch (err) {
|
|
3846
3846
|
if (code(err) !== "EINTR") throw err;
|
|
3847
|
-
if (
|
|
3847
|
+
if (timeoutMs2 !== void 0) return 0;
|
|
3848
3848
|
}
|
|
3849
3849
|
}
|
|
3850
3850
|
},
|
|
@@ -4105,7 +4105,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4105
4105
|
var init_version = __esm({
|
|
4106
4106
|
"src/version.ts"() {
|
|
4107
4107
|
"use strict";
|
|
4108
|
-
KERNEL_VERSION = true ? "1.
|
|
4108
|
+
KERNEL_VERSION = true ? "1.95.0" : "0.0.0-dev";
|
|
4109
4109
|
OS_RELEASE = "6.0.0-slicc";
|
|
4110
4110
|
}
|
|
4111
4111
|
});
|
|
@@ -5849,11 +5849,11 @@ function createSyncSabTransport(sab, port3, deps = {}) {
|
|
|
5849
5849
|
}
|
|
5850
5850
|
}
|
|
5851
5851
|
return {
|
|
5852
|
-
call(req,
|
|
5852
|
+
call(req, timeoutMs2, label, transfer = []) {
|
|
5853
5853
|
if (deps.memory) publishMemory(sab, deps.memory());
|
|
5854
5854
|
const id = ++seq;
|
|
5855
5855
|
calls += Number(!PATH_OPS.has(req.op));
|
|
5856
|
-
const deadline = now() +
|
|
5856
|
+
const deadline = now() + timeoutMs2;
|
|
5857
5857
|
let out = null;
|
|
5858
5858
|
let status2 = 0;
|
|
5859
5859
|
let offset = 0;
|
|
@@ -5896,12 +5896,12 @@ function errnoError(code2, path) {
|
|
|
5896
5896
|
return syncError(code2, `sync-sab bridge, '${path}'`);
|
|
5897
5897
|
}
|
|
5898
5898
|
function createSyncFsSabBridge(transport, opts = {}) {
|
|
5899
|
-
const
|
|
5899
|
+
const timeoutMs2 = opts.timeoutMs ?? SYNC_FS_REQUEST_TIMEOUT_MS;
|
|
5900
5900
|
let identity = {};
|
|
5901
5901
|
let last = null;
|
|
5902
5902
|
function run(req, path, transfer) {
|
|
5903
5903
|
last = null;
|
|
5904
|
-
const result = transport.call(req,
|
|
5904
|
+
const result = transport.call(req, timeoutMs2, `sync-sab bridge, '${path}'`, transfer);
|
|
5905
5905
|
if (!result.ok) throw errnoError(result.errno, path);
|
|
5906
5906
|
return result;
|
|
5907
5907
|
}
|
|
@@ -11107,11 +11107,11 @@ function drain(Fs, stream) {
|
|
|
11107
11107
|
}
|
|
11108
11108
|
return out;
|
|
11109
11109
|
}
|
|
11110
|
-
function kernelSelect(Fs, transport, read2, write2,
|
|
11110
|
+
function kernelSelect(Fs, transport, read2, write2, timeoutMs2) {
|
|
11111
11111
|
const kernel = (fd) => Fs.getStream(fd)?.sliccKernelFd;
|
|
11112
11112
|
const kr = read2.map(kernel);
|
|
11113
11113
|
const kw = write2.map(kernel);
|
|
11114
|
-
const r = transport.call({ op: "fd-select", read: kr, write: kw, timeoutMs }, Infinity, "select");
|
|
11114
|
+
const r = transport.call({ op: "fd-select", read: kr, write: kw, timeoutMs: timeoutMs2 }, Infinity, "select");
|
|
11115
11115
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
11116
11116
|
const got = r.kind === "json" ? r.json : { read: [], write: [] };
|
|
11117
11117
|
return {
|
|
@@ -11130,11 +11130,11 @@ function ownReady(Fs, read2, write2) {
|
|
|
11130
11130
|
write: write2.filter((fd) => flags(fd) & (POLLOUT2 | POLLERR2 | POLLNVAL))
|
|
11131
11131
|
};
|
|
11132
11132
|
}
|
|
11133
|
-
function anySelect(Fs, transport, read2, write2,
|
|
11133
|
+
function anySelect(Fs, transport, read2, write2, timeoutMs2) {
|
|
11134
11134
|
const kernel = (fd) => Fs.getStream(fd)?.sliccKernelFd;
|
|
11135
11135
|
const own = (fd) => kernel(fd) === void 0;
|
|
11136
|
-
if (![...read2, ...write2].some(own)) return kernelSelect(Fs, transport, read2, write2,
|
|
11137
|
-
const deadline =
|
|
11136
|
+
if (![...read2, ...write2].some(own)) return kernelSelect(Fs, transport, read2, write2, timeoutMs2);
|
|
11137
|
+
const deadline = timeoutMs2 < 0 ? Number.POSITIVE_INFINITY : Date.now() + timeoutMs2;
|
|
11138
11138
|
const kernelRead = read2.filter((fd) => !own(fd));
|
|
11139
11139
|
const kernelWrite = write2.filter((fd) => !own(fd));
|
|
11140
11140
|
for (; ; ) {
|
|
@@ -11245,7 +11245,7 @@ function createProcessKernel(deps) {
|
|
|
11245
11245
|
if (!r.ok) return -wasiErrno(r.errno);
|
|
11246
11246
|
return r.kind === "json" ? r.json : -wasiErrno("EIO");
|
|
11247
11247
|
},
|
|
11248
|
-
select: (read2, write2,
|
|
11248
|
+
select: (read2, write2, timeoutMs2) => anySelect(Fs, transport, read2, write2, timeoutMs2),
|
|
11249
11249
|
execWait,
|
|
11250
11250
|
execve(file, argv, env, cwd) {
|
|
11251
11251
|
const pid = spawnChild(file, argv, env, cwd, [0, 1, 2], void 0, true);
|
|
@@ -11392,11 +11392,11 @@ var init_process_signals = __esm({
|
|
|
11392
11392
|
}
|
|
11393
11393
|
transport() {
|
|
11394
11394
|
return {
|
|
11395
|
-
call: (req,
|
|
11395
|
+
call: (req, timeoutMs2, label) => {
|
|
11396
11396
|
this.report();
|
|
11397
11397
|
this.depth++;
|
|
11398
11398
|
try {
|
|
11399
|
-
const result = this.raw.call(req,
|
|
11399
|
+
const result = this.raw.call(req, timeoutMs2, label);
|
|
11400
11400
|
this.deliver();
|
|
11401
11401
|
return result;
|
|
11402
11402
|
} finally {
|
|
@@ -11949,9 +11949,9 @@ function bridgeFlags(init) {
|
|
|
11949
11949
|
}
|
|
11950
11950
|
function credSyncTransport(gated, early, cred) {
|
|
11951
11951
|
return {
|
|
11952
|
-
call: (req,
|
|
11952
|
+
call: (req, timeoutMs2, label) => {
|
|
11953
11953
|
if (!FS_OPS.has(req.op)) early();
|
|
11954
|
-
const r = gated.call(req,
|
|
11954
|
+
const r = gated.call(req, timeoutMs2, label);
|
|
11955
11955
|
if (cred && req.op === "proc-setcred" && r.ok && r.kind === "json")
|
|
11956
11956
|
Object.assign(cred, r.json);
|
|
11957
11957
|
return r;
|
|
@@ -12769,6 +12769,91 @@ var init_wasix_fork = __esm({
|
|
|
12769
12769
|
}
|
|
12770
12770
|
});
|
|
12771
12771
|
|
|
12772
|
+
// src/process/wasi/wasix-epoll.ts
|
|
12773
|
+
function timeoutMs(ns) {
|
|
12774
|
+
const value2 = BigInt.asUintN(64, ns);
|
|
12775
|
+
if (value2 === FOREVER) return -1;
|
|
12776
|
+
const ms = (value2 + NS_PER_MS2 - 1n) / NS_PER_MS2;
|
|
12777
|
+
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
12778
|
+
}
|
|
12779
|
+
function wasixEpollImports(host) {
|
|
12780
|
+
const { mem, fds, o } = host;
|
|
12781
|
+
const call2 = (req) => o.kernel.call(req);
|
|
12782
|
+
const kernelFd = (fd, refusal2) => {
|
|
12783
|
+
const e = fds.find(fd);
|
|
12784
|
+
if (!e) throw new WasiError("EBADF");
|
|
12785
|
+
if (e.type !== "kernel") throw new WasiError(refusal2);
|
|
12786
|
+
};
|
|
12787
|
+
const writeEvents2 = (ptr, events) => {
|
|
12788
|
+
const view = mem.view();
|
|
12789
|
+
events.forEach((ev, i) => {
|
|
12790
|
+
const at = ptr + i * EVENT_SIZE;
|
|
12791
|
+
mem.bytes(at, EVENT_SIZE).fill(0);
|
|
12792
|
+
view.setUint32(at, ev.events, true);
|
|
12793
|
+
mem.bytes(at + DATA_OFFSET, DATA_SIZE).set(ev.data);
|
|
12794
|
+
});
|
|
12795
|
+
};
|
|
12796
|
+
return {
|
|
12797
|
+
epoll_create: (out) => {
|
|
12798
|
+
const fd = call2({ op: "epoll-create" });
|
|
12799
|
+
fds.adopt(fd, "stream", false);
|
|
12800
|
+
mem.view().setUint32(out, fd, true);
|
|
12801
|
+
},
|
|
12802
|
+
epoll_ctl: (epfd, op, fd, event) => {
|
|
12803
|
+
const how = OPS[op];
|
|
12804
|
+
if (!how) throw new WasiError("EINVAL");
|
|
12805
|
+
kernelFd(epfd, "EINVAL");
|
|
12806
|
+
kernelFd(fd, "EPERM");
|
|
12807
|
+
if (how !== "del" && event === 0) throw new WasiError("EINVAL");
|
|
12808
|
+
const events = event === 0 ? 0 : mem.view().getUint32(event, true);
|
|
12809
|
+
const data = event === 0 ? [] : [...mem.bytes(event + DATA_OFFSET, DATA_SIZE)];
|
|
12810
|
+
call2({ op: "epoll-ctl", epfd, how, fd, events, data });
|
|
12811
|
+
},
|
|
12812
|
+
epoll_wait: (epfd, ptr, maxevents, timeout, out) => {
|
|
12813
|
+
mem.view().setUint32(out, 0, true);
|
|
12814
|
+
if ((maxevents | 0) <= 0) throw new WasiError("EINVAL");
|
|
12815
|
+
kernelFd(epfd, "EINVAL");
|
|
12816
|
+
const max = Math.min(maxevents | 0, MAX_EVENTS);
|
|
12817
|
+
const ms = host.entered ? 0 : timeoutMs(timeout);
|
|
12818
|
+
const events = call2({ op: "epoll-wait", epfd, max, timeoutMs: ms });
|
|
12819
|
+
if (host.entered && events.length === 0 && timeoutMs(timeout) !== 0) return E.INTR;
|
|
12820
|
+
writeEvents2(ptr, events);
|
|
12821
|
+
mem.view().setUint32(out, events.length, true);
|
|
12822
|
+
return E.SUCCESS;
|
|
12823
|
+
},
|
|
12824
|
+
fd_event: (initial, flags, out) => {
|
|
12825
|
+
const value2 = BigInt.asUintN(64, initial);
|
|
12826
|
+
if (value2 > EVENTFD_MAX) throw new WasiError("EINVAL");
|
|
12827
|
+
const fd = call2({
|
|
12828
|
+
op: "eventfd-open",
|
|
12829
|
+
initial: value2.toString(),
|
|
12830
|
+
semaphore: (flags & EVENTFD_SEMAPHORE) !== 0
|
|
12831
|
+
});
|
|
12832
|
+
fds.adopt(fd, "stream", (flags & EVENTFD_NONBLOCK) !== 0);
|
|
12833
|
+
mem.view().setUint32(out, fd, true);
|
|
12834
|
+
}
|
|
12835
|
+
};
|
|
12836
|
+
}
|
|
12837
|
+
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER, MAX_TIMEOUT_MS, NS_PER_MS2, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, OPS;
|
|
12838
|
+
var init_wasix_epoll = __esm({
|
|
12839
|
+
"src/process/wasi/wasix-epoll.ts"() {
|
|
12840
|
+
"use strict";
|
|
12841
|
+
init_wasi_abi();
|
|
12842
|
+
init_wasi_files();
|
|
12843
|
+
EVENT_SIZE = 32;
|
|
12844
|
+
DATA_OFFSET = 8;
|
|
12845
|
+
DATA_SIZE = 24;
|
|
12846
|
+
MAX_EVENTS = 4096;
|
|
12847
|
+
FOREVER = 0xffffffffffffffffn;
|
|
12848
|
+
MAX_TIMEOUT_MS = 2147483647;
|
|
12849
|
+
NS_PER_MS2 = 1000000n;
|
|
12850
|
+
EVENTFD_SEMAPHORE = 1;
|
|
12851
|
+
EVENTFD_NONBLOCK = 4;
|
|
12852
|
+
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
12853
|
+
OPS = ["add", "set", "del", "mod"];
|
|
12854
|
+
}
|
|
12855
|
+
});
|
|
12856
|
+
|
|
12772
12857
|
// src/process/wasi/wasix-ffi.ts
|
|
12773
12858
|
function read(view, at, type) {
|
|
12774
12859
|
if (type === "i32") return view.getInt32(at, true);
|
|
@@ -13951,6 +14036,7 @@ var init_wasix_host = __esm({
|
|
|
13951
14036
|
init_wasi_host();
|
|
13952
14037
|
init_wasi_module();
|
|
13953
14038
|
init_wasi_threads();
|
|
14039
|
+
init_wasix_epoll();
|
|
13954
14040
|
init_wasix_ffi();
|
|
13955
14041
|
init_wasix_linker();
|
|
13956
14042
|
init_wasix_process();
|
|
@@ -14077,7 +14163,8 @@ var init_wasix_host = __esm({
|
|
|
14077
14163
|
{ mem: this.mem, table: () => this.table, types: this.types },
|
|
14078
14164
|
...a
|
|
14079
14165
|
),
|
|
14080
|
-
...wasixSocketImports(this.host, this.host.imports())
|
|
14166
|
+
...wasixSocketImports(this.host, this.host.imports()),
|
|
14167
|
+
...wasixEpollImports(this.host)
|
|
14081
14168
|
});
|
|
14082
14169
|
}
|
|
14083
14170
|
preview1() {
|