@ai-ecoverse/slicc-kernel 1.75.1 → 1.77.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 +6 -6
- package/dist/driver-worker.js.map +1 -1
- package/dist/index.js.map +1 -1
- package/dist/kernel-worker.js +87 -15
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-driver-worker.js.map +1 -1
- package/dist/node-process-worker.js +180 -133
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +87 -15
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +54 -7
- package/dist/process-worker.js.map +2 -2
- 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
|
});
|
|
@@ -3250,7 +3265,10 @@ var init_process_fds = __esm({
|
|
|
3250
3265
|
faccessat: "__syscall_faccessat",
|
|
3251
3266
|
utimensat: "__syscall_utimensat",
|
|
3252
3267
|
getppid: "slicc_getppid_js",
|
|
3253
|
-
resizeHeap: "emscripten_resize_heap"
|
|
3268
|
+
resizeHeap: "emscripten_resize_heap",
|
|
3269
|
+
fdWrite: "fd_write",
|
|
3270
|
+
fdRead: "fd_read",
|
|
3271
|
+
sleepMs: "slicc_sleep_ms"
|
|
3254
3272
|
};
|
|
3255
3273
|
UTIME_NOW = 1073741823;
|
|
3256
3274
|
UTIME_OMIT = 1073741822;
|
|
@@ -4109,8 +4127,8 @@ function pidStat(info, boot) {
|
|
|
4109
4127
|
0,
|
|
4110
4128
|
ticks(info.utime ?? 0),
|
|
4111
4129
|
ticks(info.stime ?? 0),
|
|
4112
|
-
0,
|
|
4113
|
-
0,
|
|
4130
|
+
ticks(info.cutime ?? 0),
|
|
4131
|
+
ticks(info.cstime ?? 0),
|
|
4114
4132
|
20,
|
|
4115
4133
|
0,
|
|
4116
4134
|
1,
|
|
@@ -4134,7 +4152,7 @@ function pidStat(info, boot) {
|
|
|
4134
4152
|
`;
|
|
4135
4153
|
}
|
|
4136
4154
|
function pidStatus(info) {
|
|
4137
|
-
const state = info.state
|
|
4155
|
+
const state = STATES[info.state];
|
|
4138
4156
|
const c = info.cred ?? ROOT;
|
|
4139
4157
|
const ids = (r, e, s) => `${r} ${e} ${s} ${e}`;
|
|
4140
4158
|
return [
|
|
@@ -4410,7 +4428,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
|
|
|
4410
4428
|
readdir: (node) => pidNames(selfReaddir ? selfReaddir(node) : [".", ".."])
|
|
4411
4429
|
};
|
|
4412
4430
|
}
|
|
4413
|
-
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask;
|
|
4431
|
+
var HZ, DIR_MODE2, FILE_MODE, LINK_MODE2, ENOENT, EINVAL, UID, KIB, FALLBACK_MEMORY, PID_FILES, SYSTEM_FILES, sigMask, STATES;
|
|
4414
4432
|
var init_procfs = __esm({
|
|
4415
4433
|
"src/process/procfs.ts"() {
|
|
4416
4434
|
"use strict";
|
|
@@ -4428,6 +4446,7 @@ var init_procfs = __esm({
|
|
|
4428
4446
|
PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
|
|
4429
4447
|
SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime"];
|
|
4430
4448
|
sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
|
|
4449
|
+
STATES = { S: "S (sleeping)", T: "T (stopped)", Z: "Z (zombie)" };
|
|
4431
4450
|
}
|
|
4432
4451
|
});
|
|
4433
4452
|
|
|
@@ -4673,6 +4692,19 @@ function reportGrowth(imports, publish, glue) {
|
|
|
4673
4692
|
return grown;
|
|
4674
4693
|
});
|
|
4675
4694
|
}
|
|
4695
|
+
function holdWhileStopped(imports, header, glue) {
|
|
4696
|
+
const hold = () => {
|
|
4697
|
+
while (Atomics.load(header, SAB_I_STOP) === 1) Atomics.wait(header, SAB_I_STOP, 1);
|
|
4698
|
+
};
|
|
4699
|
+
for (const name2 of ["fdWrite", "fdRead", "sleepMs"]) {
|
|
4700
|
+
wrapImport(imports, name2, glue, (original) => (...args) => {
|
|
4701
|
+
hold();
|
|
4702
|
+
const done = original(...args);
|
|
4703
|
+
hold();
|
|
4704
|
+
return done;
|
|
4705
|
+
});
|
|
4706
|
+
}
|
|
4707
|
+
}
|
|
4676
4708
|
function callerOwner(Fs, init) {
|
|
4677
4709
|
return init.owners ? {} : { owner: ownByCaller(Fs, init.cred, credAbi(init.program.glue)) };
|
|
4678
4710
|
}
|
|
@@ -4697,6 +4729,7 @@ function kernelWrappers(imports, module, deps) {
|
|
|
4697
4729
|
positionalIo(imports, { glue, fs: fsOf, sys, memory });
|
|
4698
4730
|
const grown = () => publishMemory(init.sab, memory()?.buffer.byteLength ?? 0);
|
|
4699
4731
|
reportGrowth(imports, grown, kernelGlue);
|
|
4732
|
+
holdWhileStopped(imports, new Int32Array(init.sab, 0, SAB_HEADER_I32), kernelGlue);
|
|
4700
4733
|
}
|
|
4701
4734
|
async function runWasmProcess(init, port2, deps = {}) {
|
|
4702
4735
|
const signals = new SignalGate(
|
|
@@ -4959,6 +4992,7 @@ var init_process_runtime = __esm({
|
|
|
4959
4992
|
PLACED = /* @__PURE__ */ new Set(["stream", "file", "socket", "clipboard"]);
|
|
4960
4993
|
GLUE_TRAILER = [
|
|
4961
4994
|
"if (typeof ENV !== 'undefined') Object.assign(ENV, Module.sliccEnv);",
|
|
4995
|
+
"if (typeof thisProgram !== 'undefined' && Module.thisProgram === '') thisProgram = '';",
|
|
4962
4996
|
"const __sliccTake = (name, value) => {",
|
|
4963
4997
|
" const own = Object.getOwnPropertyDescriptor(Module, name);",
|
|
4964
4998
|
" if (own && 'value' in own && own.value != null) return;",
|
|
@@ -4987,6 +5021,9 @@ var init_process_runtime = __esm({
|
|
|
4987
5021
|
" utimensat: typeof ___syscall_utimensat === 'function' ? ___syscall_utimensat : undefined,",
|
|
4988
5022
|
" getppid: typeof _slicc_getppid_js === 'function' ? _slicc_getppid_js : undefined,",
|
|
4989
5023
|
" resizeHeap: typeof _emscripten_resize_heap === 'function' ? _emscripten_resize_heap : undefined,",
|
|
5024
|
+
" fdWrite: typeof _fd_write === 'function' ? _fd_write : undefined,",
|
|
5025
|
+
" fdRead: typeof _fd_read === 'function' ? _fd_read : undefined,",
|
|
5026
|
+
" sleepMs: typeof slicc_sleep_ms === 'function' ? slicc_sleep_ms : undefined,",
|
|
4990
5027
|
"};",
|
|
4991
5028
|
"Module.sliccFdImports ??= {",
|
|
4992
5029
|
" fd_sync: typeof _fd_sync === 'function' ? _fd_sync : undefined,",
|
|
@@ -6728,6 +6765,7 @@ var init_wasi_host = __esm({
|
|
|
6728
6765
|
"src/process/wasi/wasi-host.ts"() {
|
|
6729
6766
|
"use strict";
|
|
6730
6767
|
init_physical_path();
|
|
6768
|
+
init_cpu_clock();
|
|
6731
6769
|
init_cred();
|
|
6732
6770
|
init_wasi_abi();
|
|
6733
6771
|
init_wasi_fds();
|
|
@@ -6991,7 +7029,7 @@ var init_wasi_host = __esm({
|
|
|
6991
7029
|
if (id === CLOCK.MONOTONIC) {
|
|
6992
7030
|
return MONOTONIC_BASE + BigInt(Math.round(performance.now() * 1e6));
|
|
6993
7031
|
}
|
|
6994
|
-
return BigInt(Math.round((performance.now() - this.started) * 1e6)) + 1n;
|
|
7032
|
+
return (localCpuNanos() ?? BigInt(Math.round((performance.now() - this.started) * 1e6))) + 1n;
|
|
6995
7033
|
}
|
|
6996
7034
|
environ() {
|
|
6997
7035
|
const listen2 = this.listening.length > 0 ? { SLICC_LISTEN_FDS: this.listening.join(" ") } : {};
|
|
@@ -11279,6 +11317,7 @@ function childOps(kernel, io, defaults) {
|
|
|
11279
11317
|
const [file] = o.argv;
|
|
11280
11318
|
if (file === void 0) throw new JsCallError("EINVAL", "spawn");
|
|
11281
11319
|
const group = groupOf(o, "spawn");
|
|
11320
|
+
const named = argv0Of(o.argv0, "spawn");
|
|
11282
11321
|
const mine = [];
|
|
11283
11322
|
const theirs = [];
|
|
11284
11323
|
try {
|
|
@@ -11287,6 +11326,7 @@ function childOps(kernel, io, defaults) {
|
|
|
11287
11326
|
op: "proc-spawn",
|
|
11288
11327
|
file,
|
|
11289
11328
|
argv: [...o.argv],
|
|
11329
|
+
...named,
|
|
11290
11330
|
env: { ...o.env ?? defaults.env },
|
|
11291
11331
|
cwd: o.cwd ?? defaults.cwd,
|
|
11292
11332
|
stdio,
|
|
@@ -11311,6 +11351,11 @@ function groupOf(o, call2) {
|
|
|
11311
11351
|
if (session && pgid !== void 0) throw new JsCallError("EINVAL", call2);
|
|
11312
11352
|
return session ? { session: true } : pgid !== void 0 ? { pgid } : {};
|
|
11313
11353
|
}
|
|
11354
|
+
function argv0Of(argv0, call2) {
|
|
11355
|
+
if (argv0 === void 0) return {};
|
|
11356
|
+
if (typeof argv0 !== "string") throw new JsCallError("EINVAL", call2);
|
|
11357
|
+
return { argv0 };
|
|
11358
|
+
}
|
|
11314
11359
|
async function closeAll(io, fds) {
|
|
11315
11360
|
for (const fd of fds) if (fd !== void 0) await io.close(fd).catch(() => void 0);
|
|
11316
11361
|
}
|
|
@@ -12377,6 +12422,7 @@ function runSync(kernel, d, o) {
|
|
|
12377
12422
|
const [file] = o.argv;
|
|
12378
12423
|
if (file === void 0) throw new JsCallError("EINVAL", "run");
|
|
12379
12424
|
const group = groupOf(o, "run");
|
|
12425
|
+
const named = argv0Of(o.argv0, "run");
|
|
12380
12426
|
const stdout = stdioOf(o.stdout);
|
|
12381
12427
|
const stderr = stderrOf(o.stderr);
|
|
12382
12428
|
const input = typeof o.input === "string" ? encoder2.encode(o.input) : o.input;
|
|
@@ -12386,6 +12432,7 @@ function runSync(kernel, d, o) {
|
|
|
12386
12432
|
op: "proc-run",
|
|
12387
12433
|
file,
|
|
12388
12434
|
argv: [...o.argv],
|
|
12435
|
+
...named,
|
|
12389
12436
|
env: { ...o.env ?? d.env },
|
|
12390
12437
|
cwd: o.cwd === void 0 ? d.cwd : d.resolve(o.cwd),
|
|
12391
12438
|
...group,
|