@ai-ecoverse/slicc-kernel 1.189.1 → 1.189.2

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.
@@ -9071,7 +9071,7 @@ function satisfies(version, range2) {
9071
9071
  }
9072
9072
 
9073
9073
  // src/version.ts
9074
- var KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
9074
+ var KERNEL_VERSION = true ? "1.189.2" : "0.0.0-dev";
9075
9075
  var OS_RELEASE = "6.0.0-slicc";
9076
9076
  function procVersion() {
9077
9077
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -15640,6 +15640,10 @@ var MountTable = class {
15640
15640
  for (const mount of this.mounts.values()) if (within7(mount.target, path)) return true;
15641
15641
  return false;
15642
15642
  }
15643
+ readOnlyAt(path) {
15644
+ const found = this.locate(path);
15645
+ return found !== void 0 && readonly(found.mount);
15646
+ }
15643
15647
  locate(path) {
15644
15648
  let best;
15645
15649
  for (const mount of this.mounts.values()) {
@@ -35424,6 +35428,8 @@ var Launcher = class {
35424
35428
  tagBases = /* @__PURE__ */ new Map();
35425
35429
  links = /* @__PURE__ */ new Map();
35426
35430
  freshModules = new FreshModules();
35431
+ imagePaths = /* @__PURE__ */ new WeakMap();
35432
+ imageHolds = /* @__PURE__ */ new Map();
35427
35433
  granted = /* @__PURE__ */ new Map();
35428
35434
  users;
35429
35435
  sudoer;
@@ -36413,7 +36419,7 @@ var Launcher = class {
36413
36419
  const pin = await this.pinOf(path, caller);
36414
36420
  const sum = Object.values(pin)[0];
36415
36421
  const key = sum === void 0 ? await this.cacheKey(path, asked) : `${path}:sha256:${sum}`;
36416
- return this.cached(this.compiled, key, async () => {
36422
+ const loaded = this.cached(this.compiled, key, async () => {
36417
36423
  const { bytes: read, key: readKey } = await this.keyed(path, caller, asked);
36418
36424
  const bytes = sum === void 0 ? read : await this.pinnedBytes(pin, read);
36419
36425
  const memory = importedMemory(bytes);
@@ -36427,6 +36433,9 @@ var Launcher = class {
36427
36433
  key: sum === void 0 ? readKey : key
36428
36434
  };
36429
36435
  });
36436
+ const value2 = await loaded;
36437
+ this.imagePaths.set(value2.module, path);
36438
+ return value2;
36430
36439
  }
36431
36440
  async checkedSources(planned, caller) {
36432
36441
  const { target } = planned;
@@ -36544,7 +36553,39 @@ var Launcher = class {
36544
36553
  return {
36545
36554
  path,
36546
36555
  read: () => this.base.readFileBuffer(path),
36547
- stale: () => this.forgetCompiled(path)
36556
+ stale: () => this.forgetCompiled(path),
36557
+ kept: () => this.keptCopies(path).map((at) => ({ path: at, read: () => this.base.readFileBuffer(at) }))
36558
+ };
36559
+ }
36560
+ keptCopies(path) {
36561
+ const out = /* @__PURE__ */ new Set();
36562
+ for (const hold of this.imageHolds.get(path) ?? []) {
36563
+ for (const key of hold.holds.held()) out.add(hold.holds.keptAt(key)?.hidden ?? key);
36564
+ }
36565
+ out.delete(path);
36566
+ return [...out];
36567
+ }
36568
+ holdImage(program) {
36569
+ const module = program.abi === "js" ? void 0 : program.module;
36570
+ const path = this.compile && module ? this.imagePaths.get(module) : void 0;
36571
+ if (!module || path === void 0 || this.mounts.readOnlyAt(path)) return (status) => status;
36572
+ const holds3 = this.imageHolds.get(path) ?? /* @__PURE__ */ new Set();
36573
+ this.imageHolds.set(path, holds3);
36574
+ let hold = [...holds3].find((known) => known.module === module);
36575
+ if (!hold) {
36576
+ hold = { module, holds: new HeldPaths(), users: 0 };
36577
+ hold.holds.hold(path, true, true);
36578
+ holds3.add(hold);
36579
+ this.held.add(hold.holds);
36580
+ }
36581
+ const mine = hold;
36582
+ mine.users++;
36583
+ return (status) => {
36584
+ if (--mine.users > 0) return status;
36585
+ holds3.delete(mine);
36586
+ if (holds3.size === 0 && this.imageHolds.get(path) === holds3) this.imageHolds.delete(path);
36587
+ this.held.delete(mine.holds);
36588
+ return status;
36548
36589
  };
36549
36590
  }
36550
36591
  exeId(target) {
@@ -36956,7 +36997,7 @@ var Launcher = class {
36956
36997
  handle.onState(
36957
36998
  (state) => state === "stopped" ? this.stopped.add(pid) : this.stopped.delete(pid)
36958
36999
  );
36959
- void handle.exited.then((status) => {
37000
+ void handle.exited.then(this.holdImage(req.program)).then((status) => {
36960
37001
  this.traceEnded(pid, handle, status);
36961
37002
  this.cwds.release(this.cwdSlots.get(pid));
36962
37003
  this.cwdSlots.delete(pid);