@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.
@@ -8030,7 +8030,7 @@ var init_version = __esm({
8030
8030
  "src/version.ts"() {
8031
8031
  "use strict";
8032
8032
  init_captured_globals();
8033
- KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
8033
+ KERNEL_VERSION = true ? "1.189.2" : "0.0.0-dev";
8034
8034
  OS_RELEASE = "6.0.0-slicc";
8035
8035
  }
8036
8036
  });
@@ -8029,7 +8029,7 @@ var init_version = __esm({
8029
8029
  "src/version.ts"() {
8030
8030
  "use strict";
8031
8031
  init_captured_globals();
8032
- KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
8032
+ KERNEL_VERSION = true ? "1.189.2" : "0.0.0-dev";
8033
8033
  OS_RELEASE = "6.0.0-slicc";
8034
8034
  }
8035
8035
  });
package/dist/node.js CHANGED
@@ -7193,7 +7193,7 @@ function satisfies(version, range2) {
7193
7193
  }
7194
7194
 
7195
7195
  // src/version.ts
7196
- var KERNEL_VERSION = true ? "1.189.1" : "0.0.0-dev";
7196
+ var KERNEL_VERSION = true ? "1.189.2" : "0.0.0-dev";
7197
7197
  var OS_RELEASE = "6.0.0-slicc";
7198
7198
  function procVersion() {
7199
7199
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -12895,6 +12895,10 @@ var MountTable = class {
12895
12895
  for (const mount of this.mounts.values()) if (within5(mount.target, path)) return true;
12896
12896
  return false;
12897
12897
  }
12898
+ readOnlyAt(path) {
12899
+ const found = this.locate(path);
12900
+ return found !== void 0 && readonly(found.mount);
12901
+ }
12898
12902
  locate(path) {
12899
12903
  let best;
12900
12904
  for (const mount of this.mounts.values()) {
@@ -35304,6 +35308,8 @@ var Launcher = class {
35304
35308
  tagBases = /* @__PURE__ */ new Map();
35305
35309
  links = /* @__PURE__ */ new Map();
35306
35310
  freshModules = new FreshModules();
35311
+ imagePaths = /* @__PURE__ */ new WeakMap();
35312
+ imageHolds = /* @__PURE__ */ new Map();
35307
35313
  granted = /* @__PURE__ */ new Map();
35308
35314
  users;
35309
35315
  sudoer;
@@ -36293,7 +36299,7 @@ var Launcher = class {
36293
36299
  const pin = await this.pinOf(path, caller);
36294
36300
  const sum = Object.values(pin)[0];
36295
36301
  const key = sum === void 0 ? await this.cacheKey(path, asked) : `${path}:sha256:${sum}`;
36296
- return this.cached(this.compiled, key, async () => {
36302
+ const loaded = this.cached(this.compiled, key, async () => {
36297
36303
  const { bytes: read, key: readKey } = await this.keyed(path, caller, asked);
36298
36304
  const bytes = sum === void 0 ? read : await this.pinnedBytes(pin, read);
36299
36305
  const memory = importedMemory(bytes);
@@ -36307,6 +36313,9 @@ var Launcher = class {
36307
36313
  key: sum === void 0 ? readKey : key
36308
36314
  };
36309
36315
  });
36316
+ const value2 = await loaded;
36317
+ this.imagePaths.set(value2.module, path);
36318
+ return value2;
36310
36319
  }
36311
36320
  async checkedSources(planned, caller) {
36312
36321
  const { target } = planned;
@@ -36424,7 +36433,39 @@ var Launcher = class {
36424
36433
  return {
36425
36434
  path,
36426
36435
  read: () => this.base.readFileBuffer(path),
36427
- stale: () => this.forgetCompiled(path)
36436
+ stale: () => this.forgetCompiled(path),
36437
+ kept: () => this.keptCopies(path).map((at) => ({ path: at, read: () => this.base.readFileBuffer(at) }))
36438
+ };
36439
+ }
36440
+ keptCopies(path) {
36441
+ const out = /* @__PURE__ */ new Set();
36442
+ for (const hold of this.imageHolds.get(path) ?? []) {
36443
+ for (const key of hold.holds.held()) out.add(hold.holds.keptAt(key)?.hidden ?? key);
36444
+ }
36445
+ out.delete(path);
36446
+ return [...out];
36447
+ }
36448
+ holdImage(program) {
36449
+ const module = program.abi === "js" ? void 0 : program.module;
36450
+ const path = this.compile && module ? this.imagePaths.get(module) : void 0;
36451
+ if (!module || path === void 0 || this.mounts.readOnlyAt(path)) return (status) => status;
36452
+ const holds3 = this.imageHolds.get(path) ?? /* @__PURE__ */ new Set();
36453
+ this.imageHolds.set(path, holds3);
36454
+ let hold = [...holds3].find((known) => known.module === module);
36455
+ if (!hold) {
36456
+ hold = { module, holds: new HeldPaths(), users: 0 };
36457
+ hold.holds.hold(path, true, true);
36458
+ holds3.add(hold);
36459
+ this.held.add(hold.holds);
36460
+ }
36461
+ const mine = hold;
36462
+ mine.users++;
36463
+ return (status) => {
36464
+ if (--mine.users > 0) return status;
36465
+ holds3.delete(mine);
36466
+ if (holds3.size === 0 && this.imageHolds.get(path) === holds3) this.imageHolds.delete(path);
36467
+ this.held.delete(mine.holds);
36468
+ return status;
36428
36469
  };
36429
36470
  }
36430
36471
  exeId(target) {
@@ -36836,7 +36877,7 @@ var Launcher = class {
36836
36877
  handle.onState(
36837
36878
  (state) => state === "stopped" ? this.stopped.add(pid) : this.stopped.delete(pid)
36838
36879
  );
36839
- void handle.exited.then((status) => {
36880
+ void handle.exited.then(this.holdImage(req.program)).then((status) => {
36840
36881
  this.traceEnded(pid, handle, status);
36841
36882
  this.cwds.release(this.cwdSlots.get(pid));
36842
36883
  this.cwdSlots.delete(pid);