@ai-ecoverse/slicc-kernel 1.54.9 → 1.56.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.
@@ -5696,6 +5696,7 @@ var init_wasi_host = __esm({
5696
5696
  muted;
5697
5697
  signals;
5698
5698
  interrupted;
5699
+ quietly = (fn) => fn();
5699
5700
  listening;
5700
5701
  o;
5701
5702
  constructor(o) {
@@ -7355,6 +7356,10 @@ var init_wasix_fork = __esm({
7355
7356
  get supported() {
7356
7357
  return typeof this.exports.asyncify_start_unwind === "function";
7357
7358
  }
7359
+ get idle() {
7360
+ const state = this.exports.asyncify_get_state;
7361
+ return !this.supported || typeof state !== "function" || state() === 0;
7362
+ }
7358
7363
  resume() {
7359
7364
  if (this.exports.asyncify_get_state?.() !== UNWINDING) return false;
7360
7365
  this.exports.asyncify_stop_unwind?.();
@@ -9085,13 +9090,49 @@ var wasi_runtime_exports = {};
9085
9090
  __export(wasi_runtime_exports, {
9086
9091
  FALLBACK_MAXIMUM_PAGES: () => FALLBACK_MAXIMUM_PAGES,
9087
9092
  LinkSync: () => LinkSync,
9093
+ UNDELIVERED: () => UNDELIVERED,
9088
9094
  captureBacktraces: () => captureBacktraces,
9095
+ catchUpFirst: () => catchUpFirst,
9089
9096
  createImportedMemory: () => createImportedMemory,
9097
+ delivering: () => delivering,
9090
9098
  runWasiProcess: () => runWasiProcess,
9091
9099
  runWasiThread: () => runWasiThread,
9092
9100
  trapMessage: () => trapMessage,
9093
- unsupportedImport: () => unsupportedImport
9101
+ unsupportedImport: () => unsupportedImport,
9102
+ wireSignals: () => wireSignals
9094
9103
  });
9104
+ function wireSignals(host, gate) {
9105
+ host.interrupted = () => gate.interrupt();
9106
+ host.quietly = (fn) => gate.quiet(fn);
9107
+ }
9108
+ function catchUpFirst(host, sync) {
9109
+ return sync && (() => host.quietly(() => sync.current()));
9110
+ }
9111
+ function deliverAll(imports, host, driver, before) {
9112
+ for (const ns of DELIVERED) {
9113
+ const table = imports[ns];
9114
+ if (table) imports[ns] = delivering(ns, table, host, driver, before);
9115
+ }
9116
+ }
9117
+ function delivering(ns, table, host, driver, before) {
9118
+ const exempt = new Set(UNDELIVERED[ns]);
9119
+ const out = {};
9120
+ for (const [name2, value2] of Object.entries(table)) {
9121
+ if (exempt.has(name2) || typeof value2 !== "function") {
9122
+ out[name2] = value2;
9123
+ continue;
9124
+ }
9125
+ const fn = value2;
9126
+ out[name2] = (...args) => {
9127
+ if (driver.idle) {
9128
+ before?.();
9129
+ host.interrupted?.();
9130
+ }
9131
+ return fn(...args);
9132
+ };
9133
+ }
9134
+ return out;
9135
+ }
9095
9136
  function enosys(module, name2, foreign) {
9096
9137
  const type = foreign?.[module]?.[name2];
9097
9138
  if (type === "other") throw new Error(noErrno(`${module}.${name2}`));
@@ -9290,6 +9331,7 @@ async function instantiate(host, module, memory, threads, {
9290
9331
  sliccFs,
9291
9332
  sliccTty2
9292
9333
  );
9334
+ deliverAll(hostImports, host, driver, catchUpFirst(host, sync));
9293
9335
  const imports = sync ? merge(hostImports, sync.linker.mainImports(module)) : hostImports;
9294
9336
  instance = await WebAssembly.instantiate(module, imports);
9295
9337
  stats?.phase("instantiate");
@@ -9417,7 +9459,7 @@ async function runWasiProcess(init, port2) {
9417
9459
  if (importsSigactionHook(module)) signals.useHook();
9418
9460
  if (fork?.signals) signals.restore(fork.signals);
9419
9461
  host.signals = signals;
9420
- host.interrupted = () => gate.interrupt();
9462
+ wireSignals(host, gate);
9421
9463
  host.onRaise = (sig) => signals.raised(sig);
9422
9464
  host.muted = (fd, data) => signals.muted(fd, data);
9423
9465
  const exports = instance.exports;
@@ -9497,7 +9539,7 @@ async function runWasiThread(init, port2) {
9497
9539
  });
9498
9540
  signals.bind(instance.exports);
9499
9541
  signals.register(SIGNAL_CALLBACK);
9500
- host.interrupted = () => gate.interrupt();
9542
+ wireSignals(host, gate);
9501
9543
  host.onRaise = (sig) => signals.raised(sig);
9502
9544
  const start2 = instance.exports.wasi_thread_start;
9503
9545
  try {
@@ -9523,7 +9565,7 @@ async function runWasiThread(init, port2) {
9523
9565
  throw e;
9524
9566
  }
9525
9567
  }
9526
- var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
9568
+ var TRAPPED, PREVIEW1, WASIX, SLICC, SIGNAL_CALLBACK, takeDefault, SLICC_FS, SLICC_TTY, RESERVED2, UNDELIVERED, DELIVERED, importsSigactionHook, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
9527
9569
  var init_wasi_runtime = __esm({
9528
9570
  "src/process/wasi/wasi-runtime.ts"() {
9529
9571
  "use strict";
@@ -9560,6 +9602,13 @@ var init_wasi_runtime = __esm({
9560
9602
  SLICC_FS = "slicc_fs";
9561
9603
  SLICC_TTY = "slicc_tty";
9562
9604
  RESERVED2 = RESERVED_NAMESPACES;
9605
+ UNDELIVERED = {
9606
+ [PREVIEW1]: ["proc_exit", "clock_time_get"],
9607
+ [WASIX]: ["proc_exit2", "thread_exit", "thread_spawn_v2", "callback_signal"],
9608
+ [SLICC]: ["sigaction_set"],
9609
+ wasi: ["thread-spawn"]
9610
+ };
9611
+ DELIVERED = [PREVIEW1, WASIX, SLICC, SLICC_FS, SLICC_TTY];
9563
9612
  importsSigactionHook = (module) => WebAssembly.Module.imports(module).some((i) => i.module === SLICC && i.name === "sigaction_set");
9564
9613
  noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
9565
9614
  FALLBACK_MAXIMUM_PAGES = 32768;
@@ -9611,6 +9660,9 @@ var init_wasi_runtime = __esm({
9611
9660
  this.bump();
9612
9661
  this.catchUp();
9613
9662
  }
9663
+ current() {
9664
+ if (this.ids && Atomics.load(this.ids, DL_GEN) !== this.gen) this.catchUp();
9665
+ }
9614
9666
  catchUp() {
9615
9667
  for (; ; ) {
9616
9668
  const gen = this.ids ? Atomics.load(this.ids, DL_GEN) : 0;
@@ -9630,9 +9682,9 @@ var init_wasi_runtime = __esm({
9630
9682
  Object.entries(table).map(([name2, fn]) => [
9631
9683
  name2,
9632
9684
  ((...args) => {
9633
- if (Atomics.load(ids, DL_GEN) !== this.gen) this.catchUp();
9685
+ this.current();
9634
9686
  const result = fn(...args);
9635
- if (Atomics.load(ids, DL_GEN) !== this.gen) this.catchUp();
9687
+ this.current();
9636
9688
  return result;
9637
9689
  })
9638
9690
  ])