@ai-ecoverse/slicc-kernel 1.100.4 → 1.101.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 +10 -2
- package/dist/kernel-worker.js +5 -13
- package/dist/kernel-worker.js.map +3 -3
- package/dist/node-process-worker.js +63 -13
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +5 -13
- package/dist/node.js.map +3 -3
- package/dist/process-worker.js +63 -13
- package/dist/process-worker.js.map +3 -3
- package/package.json +2 -2
package/dist/process-worker.js
CHANGED
|
@@ -2475,7 +2475,7 @@ var KERNEL_VERSION, OS_RELEASE;
|
|
|
2475
2475
|
var init_version = __esm({
|
|
2476
2476
|
"src/version.ts"() {
|
|
2477
2477
|
"use strict";
|
|
2478
|
-
KERNEL_VERSION = true ? "1.
|
|
2478
|
+
KERNEL_VERSION = true ? "1.101.0" : "0.0.0-dev";
|
|
2479
2479
|
OS_RELEASE = "6.0.0-slicc";
|
|
2480
2480
|
}
|
|
2481
2481
|
});
|
|
@@ -8358,6 +8358,7 @@ var init_wasi_host = __esm({
|
|
|
8358
8358
|
signals;
|
|
8359
8359
|
sigmask;
|
|
8360
8360
|
linkedTls;
|
|
8361
|
+
threadEntry;
|
|
8361
8362
|
linkedModules;
|
|
8362
8363
|
interrupted;
|
|
8363
8364
|
quietly = (fn) => fn();
|
|
@@ -9509,6 +9510,7 @@ var init_wasix_process = __esm({
|
|
|
9509
9510
|
...this.host.linkedTls ? { tls: this.host.linkedTls() } : {},
|
|
9510
9511
|
...this.host.linkedModules ? { modules: this.host.linkedModules() } : {}
|
|
9511
9512
|
};
|
|
9513
|
+
if (this.host.threadEntry) wasi.entry = this.host.threadEntry;
|
|
9512
9514
|
return this.call({
|
|
9513
9515
|
op: "proc-fork",
|
|
9514
9516
|
state: { memory, currData: 0, forkSp, callStackNames: [], ppid: this.host.o.pid, wasi },
|
|
@@ -10485,6 +10487,11 @@ var init_wasix_fork = __esm({
|
|
|
10485
10487
|
useStack(pointer, low) {
|
|
10486
10488
|
this.linked = { pointer, low };
|
|
10487
10489
|
}
|
|
10490
|
+
threadStack = false;
|
|
10491
|
+
useThreadStack(pointer, low) {
|
|
10492
|
+
this.useStack(pointer, low);
|
|
10493
|
+
this.threadStack = true;
|
|
10494
|
+
}
|
|
10488
10495
|
bind(exports) {
|
|
10489
10496
|
this.exports = exports;
|
|
10490
10497
|
this.stackUpper = this.stackPointer();
|
|
@@ -10567,9 +10574,8 @@ var init_wasix_fork = __esm({
|
|
|
10567
10574
|
return out;
|
|
10568
10575
|
}
|
|
10569
10576
|
dataPointer() {
|
|
10570
|
-
|
|
10571
|
-
|
|
10572
|
-
}
|
|
10577
|
+
const own = this.exports[STACK_POINTER] instanceof WebAssembly.Global;
|
|
10578
|
+
if (this.linked && (this.threadStack || !own)) return this.linked.low + 15 & ~15;
|
|
10573
10579
|
const g = this.exports.__data_end;
|
|
10574
10580
|
const dataEnd = g instanceof WebAssembly.Global ? g.value : 0;
|
|
10575
10581
|
return dataEnd < this.stackUpper ? dataEnd + 15 & ~15 : 16;
|
|
@@ -12083,6 +12089,7 @@ __export(wasi_runtime_exports, {
|
|
|
12083
12089
|
runWasiThread: () => runWasiThread,
|
|
12084
12090
|
sigmaskOf: () => sigmaskOf,
|
|
12085
12091
|
takeThreadDefault: () => takeThreadDefault,
|
|
12092
|
+
threadStackLow: () => threadStackLow,
|
|
12086
12093
|
trapMessage: () => trapMessage,
|
|
12087
12094
|
unsupportedImport: () => unsupportedImport,
|
|
12088
12095
|
wireSignals: () => wireSignals
|
|
@@ -12262,6 +12269,34 @@ function report(stats, sys) {
|
|
|
12262
12269
|
} catch {
|
|
12263
12270
|
}
|
|
12264
12271
|
}
|
|
12272
|
+
function isWasix(module) {
|
|
12273
|
+
return WebAssembly.Module.imports(module).some((i) => i.module === WASIX);
|
|
12274
|
+
}
|
|
12275
|
+
function threadStackLow(memory, start2) {
|
|
12276
|
+
if (start2 < 0 || start2 + START_ARGS_SLACK > memory.byteLength) return void 0;
|
|
12277
|
+
const stack = memory.getUint32(start2 + START_STACK, true);
|
|
12278
|
+
const size = memory.getUint32(start2 + START_STACK_SIZE, true);
|
|
12279
|
+
if (size < MIN_THREAD_STACK || size > memory.byteLength || size > stack) return void 0;
|
|
12280
|
+
if (stack % 16 !== 0 || stack > start2 + START_ARGS_SLACK || stack + START_ARGS_SLACK < start2) {
|
|
12281
|
+
return void 0;
|
|
12282
|
+
}
|
|
12283
|
+
return stack - size;
|
|
12284
|
+
}
|
|
12285
|
+
function ownStack(driver, instance, linked, low) {
|
|
12286
|
+
const own = instance.exports.__stack_pointer;
|
|
12287
|
+
const pointer = own instanceof WebAssembly.Global ? own : linked;
|
|
12288
|
+
if (!pointer) return false;
|
|
12289
|
+
driver.useThreadStack(pointer, low);
|
|
12290
|
+
return true;
|
|
12291
|
+
}
|
|
12292
|
+
function untilDone(run, driver) {
|
|
12293
|
+
do
|
|
12294
|
+
run();
|
|
12295
|
+
while (driver.resume());
|
|
12296
|
+
}
|
|
12297
|
+
function threadStart(instance) {
|
|
12298
|
+
return instance.exports.wasi_thread_start;
|
|
12299
|
+
}
|
|
12265
12300
|
function spawnsThreads(module) {
|
|
12266
12301
|
return WebAssembly.Module.imports(module).some(
|
|
12267
12302
|
(i) => i.module === "wasi" && i.name === "thread-spawn" || i.module === WASIX && i.name === "thread_spawn_v2"
|
|
@@ -12345,7 +12380,7 @@ async function instantiate(host, module, memory, threads, {
|
|
|
12345
12380
|
}
|
|
12346
12381
|
if (sync) bindLinker(host, sync, instance, { thread, forked, path });
|
|
12347
12382
|
if (sync && !thread) driver.useStack(sync.linker.stackPointer, sync.linker.stackLow);
|
|
12348
|
-
return { instance, driver };
|
|
12383
|
+
return { instance, driver, linkedStack: sync?.linker.stackPointer };
|
|
12349
12384
|
}
|
|
12350
12385
|
function bindLinker(host, sync, instance, at) {
|
|
12351
12386
|
sync.linker.bindMain(instance, !at.thread);
|
|
@@ -12463,7 +12498,7 @@ async function runWasiProcess(init, port2) {
|
|
|
12463
12498
|
};
|
|
12464
12499
|
}
|
|
12465
12500
|
const program = await programImports(init.program, host, transport, MAIN_TID);
|
|
12466
|
-
const { instance, driver } = await instantiate(host, module, memory, threads, {
|
|
12501
|
+
const { instance, driver, linkedStack } = await instantiate(host, module, memory, threads, {
|
|
12467
12502
|
...fork ? { forked: fork } : {},
|
|
12468
12503
|
stats,
|
|
12469
12504
|
signals,
|
|
@@ -12483,11 +12518,15 @@ async function runWasiProcess(init, port2) {
|
|
|
12483
12518
|
host.muted = (fd, data) => signals.muted(fd, data);
|
|
12484
12519
|
const exports = instance.exports;
|
|
12485
12520
|
driver.bind(instance.exports);
|
|
12521
|
+
const entry = fork?.entry;
|
|
12522
|
+
if (entry) {
|
|
12523
|
+
ownStack(driver, instance, linkedStack, entry.low);
|
|
12524
|
+
host.threadEntry = entry;
|
|
12525
|
+
}
|
|
12526
|
+
const run = entry ? () => threadStart(instance)(entry.tid, entry.arg) : () => exports._start();
|
|
12486
12527
|
try {
|
|
12487
12528
|
if (fork) driver.startChild(fork);
|
|
12488
|
-
|
|
12489
|
-
exports._start();
|
|
12490
|
-
while (driver.resume());
|
|
12529
|
+
untilDone(run, driver);
|
|
12491
12530
|
return 0;
|
|
12492
12531
|
} catch (e) {
|
|
12493
12532
|
if (e instanceof WasiExit) return e.code;
|
|
@@ -12554,7 +12593,9 @@ async function runWasiThread(init, port2) {
|
|
|
12554
12593
|
});
|
|
12555
12594
|
host.sigmask = sigmaskOf(init.program.module, init.sab, gate, threads, init.signals);
|
|
12556
12595
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
12557
|
-
const {
|
|
12596
|
+
const { module } = init.program;
|
|
12597
|
+
const { memory } = thread;
|
|
12598
|
+
const { instance, driver, linkedStack } = await instantiate(host, module, memory, threads, {
|
|
12558
12599
|
thread: true,
|
|
12559
12600
|
foreign: init.program.foreign,
|
|
12560
12601
|
path: init.program.path,
|
|
@@ -12564,9 +12605,14 @@ async function runWasiThread(init, port2) {
|
|
|
12564
12605
|
signals.register(SIGNAL_CALLBACK);
|
|
12565
12606
|
wireSignals(host, gate);
|
|
12566
12607
|
host.onRaise = (sig) => signals.raised(sig);
|
|
12567
|
-
const
|
|
12608
|
+
const low = isWasix(module) ? threadStackLow(host.mem.view(), thread.arg) : void 0;
|
|
12609
|
+
if (low !== void 0 && ownStack(driver, instance, linkedStack, low)) {
|
|
12610
|
+
driver.bind(instance.exports);
|
|
12611
|
+
host.threadEntry = { tid: thread.tid, arg: thread.arg, low };
|
|
12612
|
+
}
|
|
12613
|
+
const start2 = threadStart(instance);
|
|
12568
12614
|
try {
|
|
12569
|
-
start2(thread.tid, thread.arg);
|
|
12615
|
+
untilDone(() => start2(thread.tid, thread.arg), driver);
|
|
12570
12616
|
threads.exited();
|
|
12571
12617
|
} catch (e) {
|
|
12572
12618
|
if (e instanceof ThreadExit) {
|
|
@@ -12588,7 +12634,7 @@ async function runWasiThread(init, port2) {
|
|
|
12588
12634
|
throw e;
|
|
12589
12635
|
}
|
|
12590
12636
|
}
|
|
12591
|
-
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, takeThreadDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSlicc, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
12637
|
+
var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, takeThreadDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSlicc, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, START_STACK, START_STACK_SIZE, MIN_THREAD_STACK, START_ARGS_SLACK, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
12592
12638
|
var init_wasi_runtime = __esm({
|
|
12593
12639
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
12594
12640
|
"use strict";
|
|
@@ -12648,6 +12694,10 @@ var init_wasi_runtime = __esm({
|
|
|
12648
12694
|
importsSigactionHook = (module) => importsSlicc(module, "sigaction_set");
|
|
12649
12695
|
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
12650
12696
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
12697
|
+
START_STACK = 0;
|
|
12698
|
+
START_STACK_SIZE = 56;
|
|
12699
|
+
MIN_THREAD_STACK = 4096;
|
|
12700
|
+
START_ARGS_SLACK = 64;
|
|
12651
12701
|
LinkSync = class {
|
|
12652
12702
|
count = 0;
|
|
12653
12703
|
gen = 0;
|