@ai-ecoverse/slicc-kernel 1.7.1 → 1.8.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.
@@ -734,7 +734,7 @@ function sabViews(sab) {
734
734
  window: new Uint8Array(sab, SAB_HEADER_BYTES)
735
735
  };
736
736
  }
737
- var SAB_HEADER_I32, SAB_HEADER_BYTES, SAB_I_STATE, SAB_I_SEQ, SAB_I_STATUS, SAB_I_TOTAL, SAB_I_CHUNK, SAB_I_OFFSET, SAB_I_SIGNALS, SAB_I_TIMERS, SAB_STATE_IDLE, SAB_STATE_PENDING, SAB_STATE_READY, SAB_STATUS_BYTES, SAB_STATUS_JSON, SAB_STATUS_VOID, SAB_STATUS_ERRNO, SAB_DEFAULT_WINDOW_BYTES, SAB_MIN_BYTES, SYNC_SAB_REQ_MSG, SYNC_SAB_NEXT_MSG, encoder, decoder;
737
+ var SAB_HEADER_I32, SAB_HEADER_BYTES, SAB_I_STATE, SAB_I_SEQ, SAB_I_STATUS, SAB_I_TOTAL, SAB_I_CHUNK, SAB_I_OFFSET, SAB_I_REQ, SAB_I_PUB, SAB_I_SIGNALS, SAB_I_TIMERS, SAB_STATE_IDLE, SAB_STATE_PENDING, SAB_STATE_READY, SAB_STATUS_BYTES, SAB_STATUS_JSON, SAB_STATUS_VOID, SAB_STATUS_ERRNO, SAB_DEFAULT_WINDOW_BYTES, SAB_MIN_BYTES, SYNC_SAB_REQ_MSG, SYNC_SAB_NEXT_MSG, encoder, decoder;
738
738
  var init_sync_sab_wire = __esm({
739
739
  "src/realm/sync-sab-wire.ts"() {
740
740
  "use strict";
@@ -746,6 +746,8 @@ var init_sync_sab_wire = __esm({
746
746
  SAB_I_TOTAL = 3;
747
747
  SAB_I_CHUNK = 4;
748
748
  SAB_I_OFFSET = 5;
749
+ SAB_I_REQ = 6;
750
+ SAB_I_PUB = 7;
749
751
  SAB_I_SIGNALS = 8;
750
752
  SAB_I_TIMERS = 9;
751
753
  SAB_STATE_IDLE = 0;
@@ -773,15 +775,13 @@ function createSyncSabTransport(sab, port, deps = {}) {
773
775
  let seq = 0;
774
776
  function awaitReady(id, deadline, label) {
775
777
  for (; ; ) {
776
- const remaining = deadline - now();
777
- if (remaining <= 0) throw syncError("ETIMEDOUT", label);
778
- wait(header, SAB_I_STATE, SAB_STATE_PENDING, remaining);
778
+ const published = Atomics.load(header, SAB_I_PUB);
779
779
  if (Atomics.load(header, SAB_I_STATE) === SAB_STATE_READY && Atomics.load(header, SAB_I_SEQ) === id) {
780
780
  return;
781
781
  }
782
- if (Atomics.load(header, SAB_I_STATE) === SAB_STATE_READY) {
783
- Atomics.store(header, SAB_I_STATE, SAB_STATE_PENDING);
784
- }
782
+ const remaining = deadline - now();
783
+ if (remaining <= 0) throw syncError("ETIMEDOUT", label);
784
+ wait(header, SAB_I_PUB, published, remaining);
785
785
  }
786
786
  }
787
787
  return {
@@ -791,6 +791,7 @@ function createSyncSabTransport(sab, port, deps = {}) {
791
791
  let out = null;
792
792
  let status2 = 0;
793
793
  let offset = 0;
794
+ Atomics.store(header, SAB_I_REQ, id);
794
795
  try {
795
796
  for (; ; ) {
796
797
  Atomics.store(header, SAB_I_STATE, SAB_STATE_PENDING);
@@ -817,6 +818,7 @@ function createSyncSabTransport(sab, port, deps = {}) {
817
818
  if (chunk === 0) throw syncError("EIO", label);
818
819
  }
819
820
  } finally {
821
+ Atomics.store(header, SAB_I_REQ, 0);
820
822
  Atomics.store(header, SAB_I_STATE, SAB_STATE_IDLE);
821
823
  }
822
824
  return decodeSabResult(status2, out);
@@ -5887,22 +5889,27 @@ __export(wasi_runtime_exports, {
5887
5889
  trapMessage: () => trapMessage,
5888
5890
  unsupportedImport: () => unsupportedImport
5889
5891
  });
5892
+ function accepted(imp, scope2) {
5893
+ const { module, name, kind } = imp;
5894
+ if (module === PREVIEW1 || module === WASIX) return true;
5895
+ if (!RESERVED.has(module) && (scope2.extended || scope2.wasi && kind === "function")) return true;
5896
+ if (scope2.pie && (module === "GOT.mem" || module === "GOT.func")) return true;
5897
+ if (scope2.pie && module === "env" && kind !== "memory") return true;
5898
+ if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name)
5899
+ return true;
5900
+ return module === "wasi" && name === "thread-spawn" && (scope2.wasix || !!scope2.memory?.shared);
5901
+ }
5890
5902
  function unsupportedImport(module, memory, extended = false) {
5891
5903
  const imports = WebAssembly.Module.imports(module);
5892
5904
  const wasix = imports.some((i) => i.module === WASIX);
5893
- const pie = dylinkInfo(module) !== void 0;
5894
- for (const imp of imports) {
5895
- if (imp.module === PREVIEW1 || imp.module === WASIX) continue;
5896
- if (extended && !RESERVED.has(imp.module)) continue;
5897
- if (pie && (imp.module === "GOT.mem" || imp.module === "GOT.func")) continue;
5898
- if (pie && imp.module === "env" && imp.kind !== "memory") continue;
5899
- if (imp.kind === "memory" && memory?.module === imp.module && memory.name === imp.name)
5900
- continue;
5901
- if (imp.module === "wasi" && imp.name === "thread-spawn" && (wasix || memory?.shared)) continue;
5902
- if (imp.kind === "memory" || imp.module === "wasi") {
5903
- return `imports ${imp.module}.${imp.name}: no WASI program this host runs`;
5905
+ const wasi = wasix || imports.some((i) => i.module === PREVIEW1);
5906
+ const scope2 = { extended, wasi, wasix, pie: dylinkInfo(module) !== void 0, memory };
5907
+ const refused = imports.find((imp) => !accepted(imp, scope2));
5908
+ if (refused) {
5909
+ if (refused.kind === "memory" || refused.module === "wasi") {
5910
+ return `imports ${refused.module}.${refused.name}: no WASI program this host runs`;
5904
5911
  }
5905
- return `imports ${imp.module}.${imp.name}: no WASI preview1 program (an Emscripten one runs with its glue)`;
5912
+ return `imports ${refused.module}.${refused.name}: no WASI preview1 program (an Emscripten one runs with its glue)`;
5906
5913
  }
5907
5914
  if (!WebAssembly.Module.exports(module).some((e) => e.name === "_start")) {
5908
5915
  return "no WASI command (it exports no _start)";
@@ -5923,7 +5930,9 @@ function linkImports(module, preview1, wasix, memory, threads, program = {}) {
5923
5930
  const ns = imports[imp.module] ??= {};
5924
5931
  if (imp.name in ns) continue;
5925
5932
  if (imp.kind === "memory" && memory) ns[imp.name] = memory;
5926
- else if (imp.kind === "function") ns[imp.name] = () => imp.name === "thread-spawn" ? -1 : 52;
5933
+ else if (imp.kind === "function") {
5934
+ ns[imp.name] = () => imp.module === "wasi" && imp.name === "thread-spawn" ? -1 : 52;
5935
+ }
5927
5936
  }
5928
5937
  return imports;
5929
5938
  }