@ai-ecoverse/slicc-kernel 1.83.0 → 1.84.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.
@@ -4714,9 +4714,11 @@ function reportGrowth(imports, publish, glue) {
4714
4714
  return grown;
4715
4715
  });
4716
4716
  }
4717
- function holdWhileStopped(imports, header, glue) {
4717
+ function holdWhileStopped(imports, header, glue, poll = () => void 0) {
4718
4718
  const hold = () => {
4719
4719
  while (Atomics.load(header, SAB_I_STOP) === 1) Atomics.wait(header, SAB_I_STOP, 1);
4720
+ const due = Atomics.load(header, SAB_I_SIGNALS) | Atomics.load(header, SAB_I_TIMERS) | Atomics.load(header, SAB_I_KILLED);
4721
+ if (due !== 0) poll();
4720
4722
  };
4721
4723
  for (const name2 of ["fdWrite", "fdRead", "sleepMs"]) {
4722
4724
  wrapImport(
@@ -4724,7 +4726,7 @@ function holdWhileStopped(imports, header, glue) {
4724
4726
  name2,
4725
4727
  glue,
4726
4728
  (original) => (...args) => {
4727
- hold();
4729
+ while (Atomics.load(header, SAB_I_STOP) === 1) Atomics.wait(header, SAB_I_STOP, 1);
4728
4730
  const done = original(...args);
4729
4731
  hold();
4730
4732
  return done;
@@ -4757,7 +4759,7 @@ function kernelWrappers(imports, module, deps) {
4757
4759
  positionalIo(imports, { glue, fs: fsOf, sys, memory });
4758
4760
  const grown = () => publishMemory(init.sab, memory()?.buffer.byteLength ?? 0);
4759
4761
  reportGrowth(imports, grown, kernelGlue);
4760
- holdWhileStopped(imports, new Int32Array(init.sab, 0, SAB_HEADER_I32), kernelGlue);
4762
+ holdWhileStopped(imports, new Int32Array(init.sab, 0, SAB_HEADER_I32), kernelGlue, deps.poll);
4761
4763
  }
4762
4764
  async function runWasmProcess(init, port2, deps = {}) {
4763
4765
  const signals = new SignalGate(
@@ -4827,7 +4829,8 @@ async function runWasmProcess(init, port2, deps = {}) {
4827
4829
  transport,
4828
4830
  sys,
4829
4831
  memory: () => memory,
4830
- ppid: () => identify(transport, init).ppid
4832
+ ppid: () => identify(transport, init).ppid,
4833
+ poll: () => void signals.interrupt()
4831
4834
  });
4832
4835
  return WebAssembly.instantiate(init.program.module, imports);
4833
4836
  }).then((instance) => {
@@ -11473,6 +11476,13 @@ function brokenPipe(err, info) {
11473
11476
  function written(r, fallback) {
11474
11477
  return r.ok && r.kind === "json" && typeof r.json === "number" ? r.json : fallback;
11475
11478
  }
11479
+ function statFsOf(json2) {
11480
+ const usage = parseSyncFsUsage(json2);
11481
+ const blocks = usage ? Math.ceil(usage.quota / BLOCK) : 0;
11482
+ const free = usage ? Math.max(0, Math.floor((usage.quota - usage.usage) / BLOCK)) : 0;
11483
+ const bytes = { quota: usage?.quota ?? 0, usage: usage?.usage ?? 0 };
11484
+ return { type: 0, bsize: BLOCK, blocks, bfree: free, bavail: free, files: 0, ffree: 0, ...bytes };
11485
+ }
11476
11486
  function joined(parts, length) {
11477
11487
  if (parts.length === 1) return parts[0];
11478
11488
  const out = new Uint8Array(length);
@@ -11516,16 +11526,18 @@ function openRequest(abs, o) {
11516
11526
  function index2(n, what) {
11517
11527
  if (!Number.isSafeInteger(n) || n < 0) throw new JsCallError("EINVAL", what);
11518
11528
  }
11519
- var CHUNK, MAX_IO, O_WRONLY6, O_RDWR6, O_APPEND3;
11529
+ var CHUNK, MAX_IO, O_WRONLY6, O_RDWR6, O_APPEND3, BLOCK;
11520
11530
  var init_js_io = __esm({
11521
11531
  "src/process/js/js-io.ts"() {
11522
11532
  "use strict";
11533
+ init_sync_fs_wire();
11523
11534
  init_js_kernel();
11524
11535
  CHUNK = 64 * 1024;
11525
11536
  MAX_IO = 1024 * 1024;
11526
11537
  O_WRONLY6 = 1;
11527
11538
  O_RDWR6 = 2;
11528
11539
  O_APPEND3 = 1024;
11540
+ BLOCK = 4096;
11529
11541
  }
11530
11542
  });
11531
11543
 
@@ -12690,6 +12702,11 @@ function syncPathOps(kernel, resolve, statOf, open) {
12690
12702
  if (inDev(abs)) return devSync(kernel, devReadlink(abs));
12691
12703
  return String(kernel.json({ op: "readlink", path: abs }));
12692
12704
  },
12705
+ statfs(path) {
12706
+ const abs = resolve(path);
12707
+ statOf("stat", abs);
12708
+ return statFsOf(kernel.json({ op: "statfs", path: abs }));
12709
+ },
12693
12710
  readFile(path) {
12694
12711
  const abs = resolve(path);
12695
12712
  if (inDev(abs)) return readWholeSync(open(abs));
@@ -13387,6 +13404,11 @@ function pathOps(kernel, resolve, statOf, open) {
13387
13404
  if (inDev(abs)) return devAsync(kernel, devReadlink(abs));
13388
13405
  return String(await kernel.json({ op: "readlink", path: abs }));
13389
13406
  },
13407
+ async statfs(path) {
13408
+ const abs = resolve(path);
13409
+ await statOf("stat", abs);
13410
+ return statFsOf(await kernel.json({ op: "statfs", path: abs }));
13411
+ },
13390
13412
  async readFile(path) {
13391
13413
  const abs = resolve(path);
13392
13414
  if (inDev(abs)) return readWhole(await open(abs));