@ai-ecoverse/slicc-kernel 1.98.3 → 1.99.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 +56 -1
- package/dist/kernel-worker.js +240 -15
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-process-worker.js +89 -18
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +240 -15
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +89 -18
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
|
@@ -1478,6 +1478,57 @@ var init_cred = __esm({
|
|
|
1478
1478
|
}
|
|
1479
1479
|
});
|
|
1480
1480
|
|
|
1481
|
+
// src/process/wasi/slicc-sem.ts
|
|
1482
|
+
function remainingMs(deadline, now) {
|
|
1483
|
+
if (deadline <= now) return 0;
|
|
1484
|
+
return Number((deadline - now + NS_PER_MS - 1n) / NS_PER_MS);
|
|
1485
|
+
}
|
|
1486
|
+
function semImports(host) {
|
|
1487
|
+
const { mem } = host;
|
|
1488
|
+
const call2 = (req) => host.o.kernel.call(req);
|
|
1489
|
+
const name2 = (ptr, len) => mem.string(ptr, len);
|
|
1490
|
+
return {
|
|
1491
|
+
sem_open: (np, nl, oflag, mode, value2, out) => {
|
|
1492
|
+
const handle = call2({
|
|
1493
|
+
op: "sem-open",
|
|
1494
|
+
name: name2(np, nl),
|
|
1495
|
+
create: (oflag & SEM_CREAT) !== 0,
|
|
1496
|
+
exclusive: (oflag & SEM_EXCL) !== 0,
|
|
1497
|
+
mode,
|
|
1498
|
+
value: value2
|
|
1499
|
+
});
|
|
1500
|
+
mem.view().setUint32(out, handle, true);
|
|
1501
|
+
},
|
|
1502
|
+
sem_close: (handle) => void call2({ op: "sem-close", handle }),
|
|
1503
|
+
sem_unlink: (np, nl) => void call2({ op: "sem-unlink", name: name2(np, nl) }),
|
|
1504
|
+
sem_post: (handle) => void call2({ op: "sem-post", handle }),
|
|
1505
|
+
sem_wait: (handle, how, clock, deadline) => {
|
|
1506
|
+
const kind = HOW[how];
|
|
1507
|
+
if (!kind) throw new WasiError("EINVAL");
|
|
1508
|
+
let timeoutMs2 = -1;
|
|
1509
|
+
if (kind === "timed") {
|
|
1510
|
+
if (deadline < 0n) throw new WasiError("EINVAL");
|
|
1511
|
+
if (clock !== CLOCK.REALTIME && clock !== CLOCK.MONOTONIC) throw new WasiError("EINVAL");
|
|
1512
|
+
timeoutMs2 = remainingMs(deadline, host.now(clock));
|
|
1513
|
+
}
|
|
1514
|
+
call2({ op: "sem-wait", handle, how: kind, timeoutMs: timeoutMs2 });
|
|
1515
|
+
},
|
|
1516
|
+
sem_getvalue: (handle, out) => void mem.view().setInt32(out, call2({ op: "sem-getvalue", handle }), true)
|
|
1517
|
+
};
|
|
1518
|
+
}
|
|
1519
|
+
var SEM_CREAT, SEM_EXCL, HOW, NS_PER_MS;
|
|
1520
|
+
var init_slicc_sem = __esm({
|
|
1521
|
+
"src/process/wasi/slicc-sem.ts"() {
|
|
1522
|
+
"use strict";
|
|
1523
|
+
init_wasi_abi();
|
|
1524
|
+
init_wasi_files();
|
|
1525
|
+
SEM_CREAT = 1;
|
|
1526
|
+
SEM_EXCL = 2;
|
|
1527
|
+
HOW = ["block", "try", "timed"];
|
|
1528
|
+
NS_PER_MS = 1000000n;
|
|
1529
|
+
}
|
|
1530
|
+
});
|
|
1531
|
+
|
|
1481
1532
|
// src/kernel/pipe.ts
|
|
1482
1533
|
var PIPE_CAPACITY;
|
|
1483
1534
|
var init_pipe = __esm({
|
|
@@ -3056,7 +3107,7 @@ function filestatOf(path, s) {
|
|
|
3056
3107
|
size: BigInt(s.size),
|
|
3057
3108
|
ino: s.ino !== void 0 ? BigInt(s.ino) : pathInode(path),
|
|
3058
3109
|
...s.nlink !== void 0 ? { nlink: BigInt(s.nlink) } : {},
|
|
3059
|
-
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) *
|
|
3110
|
+
mtimeNs: BigInt(Math.round(s.mtimeMs ?? 0)) * NS_PER_MS2
|
|
3060
3111
|
};
|
|
3061
3112
|
}
|
|
3062
3113
|
function kernelFiletype(kind) {
|
|
@@ -3106,7 +3157,7 @@ function wrap(table) {
|
|
|
3106
3157
|
}
|
|
3107
3158
|
return out;
|
|
3108
3159
|
}
|
|
3109
|
-
var WasiExit, IDS,
|
|
3160
|
+
var WasiExit, IDS, NS_PER_MS2, AT_SYMLINK_NOFOLLOW, AT_EACCESS, ROOT_IDS, GONE, S_IFIFO, DEFAULT_UMASK, MONOTONIC_BASE, MAX_READ, SIGPIPE_EXIT, SIG_IGN, SEALED_MODE, WasiHost;
|
|
3110
3161
|
var init_wasi_host = __esm({
|
|
3111
3162
|
"src/process/wasi/wasi-host.ts"() {
|
|
3112
3163
|
"use strict";
|
|
@@ -3114,6 +3165,7 @@ var init_wasi_host = __esm({
|
|
|
3114
3165
|
init_physical_path();
|
|
3115
3166
|
init_cpu_clock();
|
|
3116
3167
|
init_cred();
|
|
3168
|
+
init_slicc_sem();
|
|
3117
3169
|
init_wasi_abi();
|
|
3118
3170
|
init_wasi_fds();
|
|
3119
3171
|
init_wasi_files();
|
|
@@ -3129,14 +3181,14 @@ var init_wasi_host = __esm({
|
|
|
3129
3181
|
}
|
|
3130
3182
|
};
|
|
3131
3183
|
IDS = ["ruid", "euid", "suid", "rgid", "egid", "sgid"];
|
|
3132
|
-
|
|
3184
|
+
NS_PER_MS2 = 1000000n;
|
|
3133
3185
|
AT_SYMLINK_NOFOLLOW = 1;
|
|
3134
3186
|
AT_EACCESS = 2;
|
|
3135
3187
|
ROOT_IDS = Object.freeze({ uid: 0, gid: 0 });
|
|
3136
3188
|
GONE = /* @__PURE__ */ new Set(["ENOENT", "ENOTDIR"]);
|
|
3137
3189
|
S_IFIFO = 4096;
|
|
3138
3190
|
DEFAULT_UMASK = 18;
|
|
3139
|
-
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) *
|
|
3191
|
+
MONOTONIC_BASE = BigInt(Math.round(performance.timeOrigin)) * NS_PER_MS2;
|
|
3140
3192
|
MAX_READ = 1024 * 1024;
|
|
3141
3193
|
SIGPIPE_EXIT = 141;
|
|
3142
3194
|
SIG_IGN = 1;
|
|
@@ -3334,6 +3386,7 @@ var init_wasi_host = __esm({
|
|
|
3334
3386
|
});
|
|
3335
3387
|
void this.o.kernel.call({ op: "proc-setcred", change });
|
|
3336
3388
|
},
|
|
3389
|
+
...semImports(this),
|
|
3337
3390
|
groups_get: (buf, cap, count) => {
|
|
3338
3391
|
const { groups } = this.o.kernel.call({ op: "proc-cred" });
|
|
3339
3392
|
if (cap !== 0 && cap < groups.length) throw new WasiError("EINVAL");
|
|
@@ -3424,7 +3477,7 @@ var init_wasi_host = __esm({
|
|
|
3424
3477
|
return this.cache;
|
|
3425
3478
|
}
|
|
3426
3479
|
now(id) {
|
|
3427
|
-
if (id === CLOCK.REALTIME) return BigInt(Date.now()) *
|
|
3480
|
+
if (id === CLOCK.REALTIME) return BigInt(Date.now()) * NS_PER_MS2;
|
|
3428
3481
|
if (id === CLOCK.MONOTONIC) {
|
|
3429
3482
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
3430
3483
|
}
|
|
@@ -3933,7 +3986,7 @@ var init_wasi_host = __esm({
|
|
|
3933
3986
|
current ??= statOf(path);
|
|
3934
3987
|
return current[field2] ?? current.mtimeMs ?? now;
|
|
3935
3988
|
};
|
|
3936
|
-
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 /
|
|
3989
|
+
const pick = (set, setNow, value2, field2) => flags & setNow ? now : flags & set ? Number(value2 / NS_PER_MS2) : kept(field2);
|
|
3937
3990
|
(follow2 ? this.o.fs.utimes : this.o.fs.lutimes).call(
|
|
3938
3991
|
this.o.fs,
|
|
3939
3992
|
path,
|
|
@@ -4591,7 +4644,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
4591
4644
|
var init_version = __esm({
|
|
4592
4645
|
"src/version.ts"() {
|
|
4593
4646
|
"use strict";
|
|
4594
|
-
KERNEL_VERSION = true ? "1.
|
|
4647
|
+
KERNEL_VERSION = true ? "1.99.0" : "0.0.0-dev";
|
|
4595
4648
|
OS_RELEASE = "6.0.0-slicc";
|
|
4596
4649
|
}
|
|
4597
4650
|
});
|
|
@@ -13276,16 +13329,18 @@ function mutableGlobals(exports) {
|
|
|
13276
13329
|
}
|
|
13277
13330
|
return out;
|
|
13278
13331
|
}
|
|
13279
|
-
var UNWINDING, REWINDING, AsyncifyDriver;
|
|
13332
|
+
var STACK_POINTER, UNWINDING, REWINDING, AsyncifyDriver;
|
|
13280
13333
|
var init_wasix_fork = __esm({
|
|
13281
13334
|
"src/process/wasi/wasix-fork.ts"() {
|
|
13282
13335
|
"use strict";
|
|
13283
13336
|
init_wasi_abi();
|
|
13337
|
+
STACK_POINTER = "__stack_pointer";
|
|
13284
13338
|
UNWINDING = 1;
|
|
13285
13339
|
REWINDING = 2;
|
|
13286
13340
|
AsyncifyDriver = class {
|
|
13287
13341
|
exports = {};
|
|
13288
13342
|
stackUpper = 0;
|
|
13343
|
+
linked;
|
|
13289
13344
|
pending;
|
|
13290
13345
|
answer = 0;
|
|
13291
13346
|
snapshots = /* @__PURE__ */ new Map();
|
|
@@ -13294,10 +13349,12 @@ var init_wasix_fork = __esm({
|
|
|
13294
13349
|
constructor(mem) {
|
|
13295
13350
|
this.mem = mem;
|
|
13296
13351
|
}
|
|
13352
|
+
useStack(pointer, low) {
|
|
13353
|
+
this.linked = { pointer, low };
|
|
13354
|
+
}
|
|
13297
13355
|
bind(exports) {
|
|
13298
13356
|
this.exports = exports;
|
|
13299
|
-
|
|
13300
|
-
this.stackUpper = sp instanceof WebAssembly.Global ? sp.value : 0;
|
|
13357
|
+
this.stackUpper = this.stackPointer();
|
|
13301
13358
|
}
|
|
13302
13359
|
get supported() {
|
|
13303
13360
|
return typeof this.exports.asyncify_start_unwind === "function";
|
|
@@ -13332,7 +13389,7 @@ var init_wasix_fork = __esm({
|
|
|
13332
13389
|
}
|
|
13333
13390
|
fork(fork) {
|
|
13334
13391
|
const sp = this.stackPointer();
|
|
13335
|
-
const globals =
|
|
13392
|
+
const globals = this.globals();
|
|
13336
13393
|
return this.unwind((data) => {
|
|
13337
13394
|
this.answer = fork(data, globals, sp);
|
|
13338
13395
|
});
|
|
@@ -13343,7 +13400,7 @@ var init_wasix_fork = __esm({
|
|
|
13343
13400
|
v.setBigUint64(snapPtr, BigInt(retPtr), true);
|
|
13344
13401
|
v.setBigUint64(snapPtr + 8, BigInt(id), true);
|
|
13345
13402
|
v.setBigUint64(snapPtr + 16, 0x51cc5117n, true);
|
|
13346
|
-
const globals =
|
|
13403
|
+
const globals = this.globals();
|
|
13347
13404
|
return this.unwind((data) => {
|
|
13348
13405
|
const end = this.mem.view().getUint32(data, true);
|
|
13349
13406
|
this.snapshots.set(id, { frames: this.mem.bytes(data + 8, end - data - 8).slice(), globals });
|
|
@@ -13361,11 +13418,24 @@ var init_wasix_fork = __esm({
|
|
|
13361
13418
|
this.answer = Number(val) || 1;
|
|
13362
13419
|
});
|
|
13363
13420
|
}
|
|
13421
|
+
stackGlobal() {
|
|
13422
|
+
const g = this.exports[STACK_POINTER];
|
|
13423
|
+
return g instanceof WebAssembly.Global ? g : this.linked?.pointer;
|
|
13424
|
+
}
|
|
13364
13425
|
stackPointer() {
|
|
13365
|
-
|
|
13366
|
-
|
|
13426
|
+
return this.stackGlobal()?.value ?? 0;
|
|
13427
|
+
}
|
|
13428
|
+
globals() {
|
|
13429
|
+
const out = mutableGlobals(this.exports);
|
|
13430
|
+
if (this.linked && !out.some(([name2]) => name2 === STACK_POINTER)) {
|
|
13431
|
+
out.push([STACK_POINTER, this.linked.pointer.value]);
|
|
13432
|
+
}
|
|
13433
|
+
return out;
|
|
13367
13434
|
}
|
|
13368
13435
|
dataPointer() {
|
|
13436
|
+
if (this.linked && !(this.exports[STACK_POINTER] instanceof WebAssembly.Global)) {
|
|
13437
|
+
return this.linked.low + 15 & ~15;
|
|
13438
|
+
}
|
|
13369
13439
|
const g = this.exports.__data_end;
|
|
13370
13440
|
const dataEnd = g instanceof WebAssembly.Global ? g.value : 0;
|
|
13371
13441
|
return dataEnd < this.stackUpper ? dataEnd + 15 & ~15 : 16;
|
|
@@ -13385,7 +13455,7 @@ var init_wasix_fork = __esm({
|
|
|
13385
13455
|
}
|
|
13386
13456
|
restoreGlobals(globals) {
|
|
13387
13457
|
for (const [name2, value2] of globals) {
|
|
13388
|
-
const g = this.exports[name2];
|
|
13458
|
+
const g = name2 === STACK_POINTER ? this.stackGlobal() : this.exports[name2];
|
|
13389
13459
|
if (g instanceof WebAssembly.Global) g.value = value2;
|
|
13390
13460
|
}
|
|
13391
13461
|
}
|
|
@@ -13397,7 +13467,7 @@ var init_wasix_fork = __esm({
|
|
|
13397
13467
|
function timeoutMs(ns) {
|
|
13398
13468
|
const value2 = BigInt.asUintN(64, ns);
|
|
13399
13469
|
if (value2 === FOREVER) return -1;
|
|
13400
|
-
const ms = (value2 +
|
|
13470
|
+
const ms = (value2 + NS_PER_MS3 - 1n) / NS_PER_MS3;
|
|
13401
13471
|
return ms > BigInt(MAX_TIMEOUT_MS) ? -1 : Number(ms);
|
|
13402
13472
|
}
|
|
13403
13473
|
function wasixEpollImports(host) {
|
|
@@ -13458,7 +13528,7 @@ function wasixEpollImports(host) {
|
|
|
13458
13528
|
}
|
|
13459
13529
|
};
|
|
13460
13530
|
}
|
|
13461
|
-
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER, MAX_TIMEOUT_MS,
|
|
13531
|
+
var EVENT_SIZE, DATA_OFFSET, DATA_SIZE, MAX_EVENTS, FOREVER, MAX_TIMEOUT_MS, NS_PER_MS3, EVENTFD_SEMAPHORE, EVENTFD_NONBLOCK, EVENTFD_MAX, OPS;
|
|
13462
13532
|
var init_wasix_epoll = __esm({
|
|
13463
13533
|
"src/process/wasi/wasix-epoll.ts"() {
|
|
13464
13534
|
"use strict";
|
|
@@ -13470,7 +13540,7 @@ var init_wasix_epoll = __esm({
|
|
|
13470
13540
|
MAX_EVENTS = 4096;
|
|
13471
13541
|
FOREVER = 0xffffffffffffffffn;
|
|
13472
13542
|
MAX_TIMEOUT_MS = 2147483647;
|
|
13473
|
-
|
|
13543
|
+
NS_PER_MS3 = 1000000n;
|
|
13474
13544
|
EVENTFD_SEMAPHORE = 1;
|
|
13475
13545
|
EVENTFD_NONBLOCK = 4;
|
|
13476
13546
|
EVENTFD_MAX = 0xfffffffffffffffen;
|
|
@@ -15135,6 +15205,7 @@ async function instantiate(host, module, memory, threads, {
|
|
|
15135
15205
|
}
|
|
15136
15206
|
}
|
|
15137
15207
|
if (sync) bindLinker(host, sync, instance, { thread, forked, path });
|
|
15208
|
+
if (sync && !thread) driver.useStack(sync.linker.stackPointer, sync.linker.stackLow);
|
|
15138
15209
|
return { instance, driver };
|
|
15139
15210
|
}
|
|
15140
15211
|
function bindLinker(host, sync, instance, at) {
|