@ai-ecoverse/slicc-kernel 1.134.3 → 1.135.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/dist/node.js CHANGED
@@ -7467,7 +7467,7 @@ function satisfies(version, range2) {
7467
7467
  }
7468
7468
 
7469
7469
  // src/version.ts
7470
- var KERNEL_VERSION = true ? "1.134.3" : "0.0.0-dev";
7470
+ var KERNEL_VERSION = true ? "1.135.0" : "0.0.0-dev";
7471
7471
  var OS_RELEASE = "6.0.0-slicc";
7472
7472
  function procVersion() {
7473
7473
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -13672,7 +13672,7 @@ var AsyncRangedFile = class {
13672
13672
  };
13673
13673
 
13674
13674
  // src/realm/sync-sab-bridge.ts
13675
- var PATH_OPS = new Set(SYNC_FS_OPS);
13675
+ var UNCOUNTED_OPS = /* @__PURE__ */ new Set([...SYNC_FS_OPS, "cwd-check", "cwd-chdir"]);
13676
13676
  var SPIN_CORES = 4;
13677
13677
  var spinning = (globalThis.navigator?.hardwareConcurrency ?? 0) >= SPIN_CORES;
13678
13678
 
@@ -13720,6 +13720,8 @@ var SYS_TREE = {
13720
13720
  slicc_opfs_calls: (listing) => `${listing.opfsCalls ?? 0}
13721
13721
  `,
13722
13722
  slicc_opfs_ops: (listing) => `${listing.opfsOps ?? 0}
13723
+ `,
13724
+ slicc_cwd_checks: (listing) => `${listing.cwdChecks ?? 0}
13723
13725
  `
13724
13726
  }
13725
13727
  };
@@ -22950,23 +22952,55 @@ var JsThreads = class {
22950
22952
  get size() {
22951
22953
  return this.live.size;
22952
22954
  }
22955
+ pending = 0;
22956
+ get admission() {
22957
+ return this.deps.admission;
22958
+ }
22953
22959
  spawn(msg) {
22954
- const { control, port } = msg;
22955
- if (this.closed || this.live.size >= this.deps.cap) {
22956
- answer(
22957
- control,
22960
+ if (this.closed || this.live.size + this.pending >= this.deps.cap) {
22961
+ this.refuse(
22962
+ msg,
22958
22963
  this.closed ? { errno: "ESRCH", message: "the process is ending" } : { errno: "EAGAIN", message: `more than ${this.deps.cap} threads` }
22959
22964
  );
22960
- control.close();
22961
- port.close();
22962
22965
  return;
22963
22966
  }
22967
+ this.pending++;
22968
+ this.admission.admit().then(
22969
+ () => {
22970
+ this.pending--;
22971
+ if (!this.closed) {
22972
+ let worker;
22973
+ try {
22974
+ worker = this.deps.createWorker();
22975
+ } catch {
22976
+ this.admission.ended();
22977
+ this.refuse(msg, { errno: "EAGAIN", message: "no worker for the thread" });
22978
+ return;
22979
+ }
22980
+ this.begin(msg, worker);
22981
+ return;
22982
+ }
22983
+ this.admission.ended();
22984
+ this.refuse(msg, { errno: "ESRCH", message: "the process is ending" });
22985
+ },
22986
+ () => {
22987
+ this.pending--;
22988
+ this.refuse(msg, { errno: "EAGAIN", message: "no room for another worker" });
22989
+ }
22990
+ );
22991
+ }
22992
+ refuse(msg, why) {
22993
+ answer(msg.control, why);
22994
+ msg.control.close();
22995
+ msg.port.close();
22996
+ }
22997
+ begin(msg, worker) {
22998
+ const { control, port } = msg;
22964
22999
  const tid = ++this.last;
22965
23000
  const sab = new SharedArrayBuffer(SAB_HEADER_BYTES + SAB_DEFAULT_WINDOW_BYTES);
22966
23001
  const header4 = new Int32Array(sab, 0, SAB_HEADER_I32);
22967
23002
  const owned4 = new SharedArrayBuffer(4 * (1 + JS_THREAD_OWNED_FDS));
22968
23003
  if (this.frozen) Atomics.store(header4, SAB_I_STOP, 1);
22969
- const worker = this.deps.createWorker();
22970
23004
  const clock = this.deps.clocks.thread(tid + 1, sab);
22971
23005
  let ended = false;
22972
23006
  const end = (code) => {
@@ -22985,6 +23019,7 @@ var JsThreads = class {
22985
23019
  responder.dispose();
22986
23020
  lane.dispose();
22987
23021
  this.deps.clocks.threadEnded(tid + 1);
23022
+ this.admission.ended();
22988
23023
  worker.terminate();
22989
23024
  for (const fd of ownedFds(owned4)) {
22990
23025
  void this.deps.dispatch({ op: "fd-close", fd });
@@ -23036,6 +23071,7 @@ var JsThreads = class {
23036
23071
  end(JS_THREAD_CRASHED);
23037
23072
  return;
23038
23073
  }
23074
+ this.admission.started();
23039
23075
  answer(control, { tid });
23040
23076
  }
23041
23077
  crashed(message3, end) {
@@ -23530,7 +23566,8 @@ function jsThreadsOf(opts, process2, token, dispatch2, clocks, header4) {
23530
23566
  openLane: (laneDispatch) => openLane(token, laneDispatch),
23531
23567
  attach: (worker, sab, threadDispatch) => attachSyncSabResponder(worker, sab, token, { dispatch: threadDispatch }),
23532
23568
  dispatch: dispatch2,
23533
- clocks
23569
+ clocks,
23570
+ admission: opts.admission
23534
23571
  });
23535
23572
  process2.onState((state) => threads.stopped(state === "stopped"));
23536
23573
  return threads;
@@ -28000,7 +28037,6 @@ var Launcher = class {
28000
28037
  if (req.links !== void 0) this.links.set(pid, req.links);
28001
28038
  }
28002
28039
  async admitted(wasm, fds, start2) {
28003
- if (!wasm) return start2(fds);
28004
28040
  for (; ; ) {
28005
28041
  await this.memories.admit().catch(async (err) => {
28006
28042
  await fds.closeAll();
@@ -28011,7 +28047,7 @@ var Launcher = class {
28011
28047
  void Promise.resolve(handle2.ready).then(() => this.memories.started());
28012
28048
  return handle2;
28013
28049
  };
28014
- if (!this.memories.near()) {
28050
+ if (!wasm || !this.memories.near()) {
28015
28051
  try {
28016
28052
  return counted3(start2(fds));
28017
28053
  } catch (err) {
@@ -28089,6 +28125,7 @@ var Launcher = class {
28089
28125
  noLinks: stack.noLinks,
28090
28126
  ...this.prefixes.length > 0 && !stack.writer ? { readonlyAt: (path) => isProtected(this.prefixes, path) } : {},
28091
28127
  createWorker: this.createWorker,
28128
+ admission: this.memories,
28092
28129
  onError: req.report,
28093
28130
  onOom: () => {
28094
28131
  this.memories.learn();
@@ -28107,7 +28144,8 @@ var Launcher = class {
28107
28144
  peers: Number(this.locks.shared?.() === true),
28108
28145
  fsCalls: servedFsCalls(),
28109
28146
  opfsCalls: this.rootFs.opfsCalls?.() ?? 0,
28110
- opfsOps: this.rootFs.opfsOps?.() ?? 0
28147
+ opfsOps: this.rootFs.opfsOps?.() ?? 0,
28148
+ cwdChecks: this.cwds.checks
28111
28149
  }),
28112
28150
  sudo: (call, signal) => this.sudo(pid, call, signal),
28113
28151
  crontab: (call) => this.crontab(pid, call),