@ai-ecoverse/slicc-kernel 1.76.0 → 1.77.1
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 +6 -6
- package/dist/driver-worker.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +198 -11
- package/dist/kernel-worker.js.map +4 -4
- package/dist/node-driver-worker.js.map +1 -1
- package/dist/node-process-worker.js +194 -136
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +198 -11
- package/dist/node.js.map +4 -4
- package/dist/process-worker.js +68 -10
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
package/dist/process-worker.js
CHANGED
|
@@ -195,6 +195,8 @@ function slots(sab) {
|
|
|
195
195
|
function useLocalClock(sab) {
|
|
196
196
|
local = sab && sab.byteLength >= LOCAL + SAB_CLOCK_I64 * 8 ? slots(sab) : void 0;
|
|
197
197
|
if (!local) return;
|
|
198
|
+
localSab = sab;
|
|
199
|
+
localStart = epochMicros();
|
|
198
200
|
const wait2 = (typed, index3, value2, timeout) => localWait(() => rawWait(typed, index3, value2, timeout));
|
|
199
201
|
Atomics.wait = wait2;
|
|
200
202
|
}
|
|
@@ -211,13 +213,26 @@ function localWait(wait2) {
|
|
|
211
213
|
Atomics.store(clock, IDLE, idle + (end > start2 ? end - start2 : 0n));
|
|
212
214
|
}
|
|
213
215
|
}
|
|
214
|
-
|
|
216
|
+
function localCpuNanos() {
|
|
217
|
+
if (!local || !localSab) return void 0;
|
|
218
|
+
const now = epochMicros();
|
|
219
|
+
const blocked = Number(Atomics.load(local, BLOCKED)) + localIdle(localSab, now).idle;
|
|
220
|
+
return BigInt(Math.max(0, now - localStart - blocked)) * 1000n;
|
|
221
|
+
}
|
|
222
|
+
function localIdle(sab, now) {
|
|
223
|
+
const state = Number(Atomics.load(slots(sab), IDLE));
|
|
224
|
+
if (state >= 0) return { idle: state, waiting: false };
|
|
225
|
+
return { idle: Math.max(0, now + state), waiting: true };
|
|
226
|
+
}
|
|
227
|
+
var LOCAL, BLOCKED, IDLE, local, localSab, localStart, rawWait;
|
|
215
228
|
var init_cpu_clock = __esm({
|
|
216
229
|
"src/kernel/cpu-clock.ts"() {
|
|
217
230
|
"use strict";
|
|
218
231
|
init_sync_sab_wire();
|
|
219
232
|
LOCAL = SAB_CLOCK_OFFSET;
|
|
233
|
+
BLOCKED = 0;
|
|
220
234
|
IDLE = 1;
|
|
235
|
+
localStart = 0;
|
|
221
236
|
rawWait = Atomics.wait.bind(Atomics);
|
|
222
237
|
}
|
|
223
238
|
});
|
|
@@ -3179,6 +3194,22 @@ function cString(memory, at) {
|
|
|
3179
3194
|
function baseOf(Fs, dirfd) {
|
|
3180
3195
|
return dirfd === AT_FDCWD ? Fs.cwd?.() ?? "/" : Fs.getStream?.(dirfd)?.path ?? "/";
|
|
3181
3196
|
}
|
|
3197
|
+
function readonlyRefusal(Fs, memory, call2) {
|
|
3198
|
+
if (!(call2.amode & W_ACCESS)) return 0;
|
|
3199
|
+
try {
|
|
3200
|
+
const name2 = cString(memory, call2.path);
|
|
3201
|
+
const abs = name2.startsWith("/") ? name2 : `${baseOf(Fs, call2.dirfd)}/${name2}`;
|
|
3202
|
+
const follow2 = (call2.flags & AT_SYMLINK_NOFOLLOW) === 0;
|
|
3203
|
+
const { node } = Fs.lookupPath.call(Fs, abs, {
|
|
3204
|
+
follow: follow2
|
|
3205
|
+
});
|
|
3206
|
+
const bridge = node.live ? node.mount.opts.bridge : void 0;
|
|
3207
|
+
const stat = bridge?.stat;
|
|
3208
|
+
return stat?.(liveNodePath(node)).readonly ? -wasiErrno("EROFS") : 0;
|
|
3209
|
+
} catch {
|
|
3210
|
+
return 0;
|
|
3211
|
+
}
|
|
3212
|
+
}
|
|
3182
3213
|
function kernelChecks(Fs, memory, call2) {
|
|
3183
3214
|
const name2 = cString(memory, call2.path);
|
|
3184
3215
|
const abs = name2.startsWith("/") ? name2 : `${baseOf(Fs, call2.dirfd)}/${name2}`;
|
|
@@ -3192,9 +3223,12 @@ function kernelChecks(Fs, memory, call2) {
|
|
|
3192
3223
|
}
|
|
3193
3224
|
function kernelAccess(imports, fs, memory, glue) {
|
|
3194
3225
|
wrapImport(imports, "faccessat", glue, (own) => (dirfd, path, amode, flags) => {
|
|
3195
|
-
const rc = own(dirfd, path, amode, flags);
|
|
3196
3226
|
const Fs = fs();
|
|
3197
3227
|
const heap = memory();
|
|
3228
|
+
const call2 = { dirfd, path, amode: amode & 7, flags };
|
|
3229
|
+
const refused = Fs?.lookupPath && heap ? readonlyRefusal(Fs, heap, call2) : 0;
|
|
3230
|
+
if (refused !== 0) return refused;
|
|
3231
|
+
const rc = own(dirfd, path, amode, flags);
|
|
3198
3232
|
if (rc !== 0 || !Fs?.lookupPath || !heap) return rc;
|
|
3199
3233
|
try {
|
|
3200
3234
|
return kernelChecks(Fs, heap, { dirfd, path, amode: amode & 7, flags });
|
|
@@ -3213,7 +3247,7 @@ function linuxDevices(Fs) {
|
|
|
3213
3247
|
}
|
|
3214
3248
|
}
|
|
3215
3249
|
}
|
|
3216
|
-
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, DEVICE_MODES;
|
|
3250
|
+
var O_CLOEXEC, FD_CLOEXEC, F_DUPFD, F_GETFD, F_SETFD, F_GETFL, F_DUPFD_CLOEXEC, tracked, IMPORT_NAMES, EBADF, AT_SYMLINK_NOFOLLOW, EMSCRIPTEN_EPERM, O_PATH, LITERALS, UTIME_NOW, UTIME_OMIT, PROT_WRITE, MAP_PRIVATE, MAP_TYPE, O_WRONLY, MAP_ALIGN, DIR_MODE, LINK_MODE, CHAR_DEVICE, O_ACCMODE2, O_CREAT2, field, pinnedRoot, rootKind, NAME, AT_FDCWD, AT_EACCESS, W_ACCESS, DEVICE_MODES;
|
|
3217
3251
|
var init_process_fds = __esm({
|
|
3218
3252
|
"src/process/process-fds.ts"() {
|
|
3219
3253
|
"use strict";
|
|
@@ -3250,7 +3284,10 @@ var init_process_fds = __esm({
|
|
|
3250
3284
|
faccessat: "__syscall_faccessat",
|
|
3251
3285
|
utimensat: "__syscall_utimensat",
|
|
3252
3286
|
getppid: "slicc_getppid_js",
|
|
3253
|
-
resizeHeap: "emscripten_resize_heap"
|
|
3287
|
+
resizeHeap: "emscripten_resize_heap",
|
|
3288
|
+
fdWrite: "fd_write",
|
|
3289
|
+
fdRead: "fd_read",
|
|
3290
|
+
sleepMs: "slicc_sleep_ms"
|
|
3254
3291
|
};
|
|
3255
3292
|
UTIME_NOW = 1073741823;
|
|
3256
3293
|
UTIME_OMIT = 1073741822;
|
|
@@ -3269,6 +3306,7 @@ var init_process_fds = __esm({
|
|
|
3269
3306
|
NAME = /^[a-z_][a-z0-9_-]*$/i;
|
|
3270
3307
|
AT_FDCWD = -100;
|
|
3271
3308
|
AT_EACCESS = 512;
|
|
3309
|
+
W_ACCESS = 2;
|
|
3272
3310
|
DEVICE_MODES = [
|
|
3273
3311
|
["/", 493],
|
|
3274
3312
|
["/dev", 493],
|
|
@@ -4109,8 +4147,8 @@ function pidStat(info, boot) {
|
|
|
4109
4147
|
0,
|
|
4110
4148
|
ticks(info.utime ?? 0),
|
|
4111
4149
|
ticks(info.stime ?? 0),
|
|
4112
|
-
0,
|
|
4113
|
-
0,
|
|
4150
|
+
ticks(info.cutime ?? 0),
|
|
4151
|
+
ticks(info.cstime ?? 0),
|
|
4114
4152
|
20,
|
|
4115
4153
|
0,
|
|
4116
4154
|
1,
|
|
@@ -4134,7 +4172,7 @@ function pidStat(info, boot) {
|
|
|
4134
4172
|
`;
|
|
4135
4173
|
}
|
|
4136
4174
|
function pidStatus(info) {
|
|
4137
|
-
const state = info.state
|
|
4175
|
+
const state = STATES[info.state];
|
|
4138
4176
|
const c = info.cred ?? ROOT;
|
|
4139
4177
|
const ids = (r, e, s) => `${r} ${e} ${s} ${e}`;
|
|
4140
4178
|
return [
|
|
@@ -4410,7 +4448,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
4410
4448
|
readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
|
|
4411
4449
|
};
|
|
4412
4450
|
}
|
|
4413
|
-
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask;
|
|
4451
|
+
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask, STATES;
|
|
4414
4452
|
var init_procfs = __esm({
|
|
4415
4453
|
"src/process/procfs.ts"() {
|
|
4416
4454
|
"use strict";
|
|
@@ -4428,6 +4466,7 @@ var init_procfs = __esm({
|
|
|
4428
4466
|
PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
|
|
4429
4467
|
SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime"];
|
|
4430
4468
|
sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
4469
|
+
STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
|
|
4431
4470
|
}
|
|
4432
4471
|
});
|
|
4433
4472
|
|
|
@@ -4673,6 +4712,19 @@ function reportGrowth(imports, publish, glue) {
|
|
|
4673
4712
|
return grown;
|
|
4674
4713
|
});
|
|
4675
4714
|
}
|
|
4715
|
+
function holdWhileStopped(imports, header, glue) {
|
|
4716
|
+
const hold = () => {
|
|
4717
|
+
while (Atomics.load(header, SAB_I_STOP) === 1) Atomics.wait(header, SAB_I_STOP, 1);
|
|
4718
|
+
};
|
|
4719
|
+
for (const name2 of ["fdWrite", "fdRead", "sleepMs"]) {
|
|
4720
|
+
wrapImport(imports, name2, glue, (original) => (...args) => {
|
|
4721
|
+
hold();
|
|
4722
|
+
const done = original(...args);
|
|
4723
|
+
hold();
|
|
4724
|
+
return done;
|
|
4725
|
+
});
|
|
4726
|
+
}
|
|
4727
|
+
}
|
|
4676
4728
|
function callerOwner(Fs, init) {
|
|
4677
4729
|
return init.owners ? {} : { owner: ownByCaller(Fs, init.cred, credAbi(init.program.glue)) };
|
|
4678
4730
|
}
|
|
@@ -4697,6 +4749,7 @@ function kernelWrappers(imports, module, deps) {
|
|
|
4697
4749
|
positionalIo(imports, { glue, fs: fsOf, sys, memory });
|
|
4698
4750
|
const grown = () => publishMemory(init.sab, memory()?.buffer.byteLength ?? 0);
|
|
4699
4751
|
reportGrowth(imports, grown, kernelGlue);
|
|
4752
|
+
holdWhileStopped(imports, new Int32Array(init.sab, 0, SAB_HEADER_I32), kernelGlue);
|
|
4700
4753
|
}
|
|
4701
4754
|
async function runWasmProcess(init, port2, deps = {}) {
|
|
4702
4755
|
const signals = new SignalGate(
|
|
@@ -4988,6 +5041,9 @@ var init_process_runtime = __esm({
|
|
|
4988
5041
|
" utimensat: typeof ___syscall_utimensat === 'function' ? ___syscall_utimensat : undefined,",
|
|
4989
5042
|
" getppid: typeof _slicc_getppid_js === 'function' ? _slicc_getppid_js : undefined,",
|
|
4990
5043
|
" resizeHeap: typeof _emscripten_resize_heap === 'function' ? _emscripten_resize_heap : undefined,",
|
|
5044
|
+
" fdWrite: typeof _fd_write === 'function' ? _fd_write : undefined,",
|
|
5045
|
+
" fdRead: typeof _fd_read === 'function' ? _fd_read : undefined,",
|
|
5046
|
+
" sleepMs: typeof slicc_sleep_ms === 'function' ? slicc_sleep_ms : undefined,",
|
|
4991
5047
|
"};",
|
|
4992
5048
|
"Module.sliccFdImports ??= {",
|
|
4993
5049
|
" fd_sync: typeof _fd_sync === 'function' ? _fd_sync : undefined,",
|
|
@@ -6729,6 +6785,7 @@ var init_wasi_host = __esm({
|
|
|
6729
6785
|
"src/process/wasi/wasi-host.ts"() {
|
|
6730
6786
|
"use strict";
|
|
6731
6787
|
init_physical_path();
|
|
6788
|
+
init_cpu_clock();
|
|
6732
6789
|
init_cred();
|
|
6733
6790
|
init_wasi_abi();
|
|
6734
6791
|
init_wasi_fds();
|
|
@@ -6884,7 +6941,8 @@ var init_wasi_host = __esm({
|
|
|
6884
6941
|
if (this.o.fs.owners && amode & 1) throw new WasiError("EACCES");
|
|
6885
6942
|
return;
|
|
6886
6943
|
}
|
|
6887
|
-
pathOwned(path, !nofollow);
|
|
6944
|
+
const st = pathOwned(path, !nofollow);
|
|
6945
|
+
if (amode & 2 && st.readonly) throw new WasiError("EROFS");
|
|
6888
6946
|
if (!this.o.fs.owners) return;
|
|
6889
6947
|
const kind = flags & AT_EACCESS2 ? "eaccess" : "access";
|
|
6890
6948
|
this.o.fs.access?.(path, amode & 7, kind, nofollow);
|
|
@@ -6992,7 +7050,7 @@ var init_wasi_host = __esm({
|
|
|
6992
7050
|
if (id === CLOCK.MONOTONIC) {
|
|
6993
7051
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
6994
7052
|
}
|
|
6995
|
-
return BigInt(Math.round((performance.now() - this.started) * 1e6)) + 1n;
|
|
7053
|
+
return (localCpuNanos() ?? BigInt(Math.round((performance.now() - this.started) * 1e6))) + 1n;
|
|
6996
7054
|
}
|
|
6997
7055
|
environ() {
|
|
6998
7056
|
const listen2 = this.listening.length > 0 ? { SLICC_LISTEN_FDS: this.listening.join(" ") } : {};
|