@ai-ecoverse/slicc-kernel 1.122.2 → 1.123.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.
@@ -253,13 +253,14 @@ var init_cpu_clock = __esm({
253
253
  });
254
254
 
255
255
  // src/kernel/protocol.ts
256
- var WASM_PROCESS_INIT, WASM_PROCESS_EXIT, WASM_PROCESS_ERROR, WASM_THREAD_SPAWN, WASM_THREAD_INIT, WASM_THREAD_EXIT, WASM_MAX_THREADS, WASM_DEFAULT_THREADS;
256
+ var WASM_PROCESS_INIT, WASM_PROCESS_EXIT, WASM_PROCESS_ERROR, WASM_PROCESS_READY, WASM_THREAD_SPAWN, WASM_THREAD_INIT, WASM_THREAD_EXIT, WASM_MAX_THREADS, WASM_DEFAULT_THREADS;
257
257
  var init_protocol = __esm({
258
258
  "src/kernel/protocol.ts"() {
259
259
  "use strict";
260
260
  WASM_PROCESS_INIT = "wasm-process-init";
261
261
  WASM_PROCESS_EXIT = "wasm-process-exit";
262
262
  WASM_PROCESS_ERROR = "wasm-process-error";
263
+ WASM_PROCESS_READY = "wasm-process-ready";
263
264
  WASM_THREAD_SPAWN = "wasm-thread-spawn";
264
265
  WASM_THREAD_INIT = "wasm-thread-init";
265
266
  WASM_THREAD_EXIT = "wasm-thread-exit";
@@ -2185,6 +2186,7 @@ function liveRoot(Fs, bridge) {
2185
2186
  guardRenames(Fs);
2186
2187
  guardKeptNodes(Fs, plugin.handled);
2187
2188
  guardStaleNodes(Fs, plugin);
2189
+ guardVanished(Fs);
2188
2190
  guardStatfs(Fs);
2189
2191
  const memfs = root.memfs ?? root.node_ops;
2190
2192
  const live = plugin.node_ops;
@@ -2292,6 +2294,44 @@ function guardStaleNodes(Fs, plugin) {
2292
2294
  return fresh;
2293
2295
  };
2294
2296
  }
2297
+ function guardVanished(Fs) {
2298
+ const forget = Fs.hashRemoveNode?.bind(Fs);
2299
+ if (!forget || !Fs.lookupPath || Fs.sliccVanished) return;
2300
+ Fs.sliccVanished = true;
2301
+ const drop = forget;
2302
+ const lookupPath = Fs.lookupPath.bind(Fs);
2303
+ const ops = Fs;
2304
+ const cached = (path, follow2) => {
2305
+ try {
2306
+ const node = lookupPath(path, { follow: follow2 }).node;
2307
+ return node.live && node.live.openCount === 0 && !node.live.dirty ? node : void 0;
2308
+ } catch {
2309
+ return void 0;
2310
+ }
2311
+ };
2312
+ let open;
2313
+ for (const [name2, follows] of RESOLVING) {
2314
+ const op = ops[name2]?.bind(Fs);
2315
+ if (name2 === "open") open = op;
2316
+ if (op) ops[name2] = vanishing(op, follows);
2317
+ }
2318
+ function vanishing(op, follows) {
2319
+ return (...args) => {
2320
+ try {
2321
+ return op(...args);
2322
+ } catch (err) {
2323
+ const path = args[0];
2324
+ const code2 = err.errno;
2325
+ const taken = code2 === wasiErrno("EEXIST") && op === open;
2326
+ if (code2 !== wasiErrno("ENOENT") && !taken || typeof path !== "string") throw err;
2327
+ const node = cached(path, follows(args));
2328
+ if (!node) throw err;
2329
+ drop(node);
2330
+ return op(...args);
2331
+ }
2332
+ };
2333
+ }
2334
+ }
2295
2335
  function guardRenames(Fs) {
2296
2336
  const rename = Fs.rename?.bind(Fs);
2297
2337
  if (!rename || Fs.sliccRename) return;
@@ -2405,7 +2445,7 @@ function readingLinks(Fs) {
2405
2445
  }
2406
2446
  };
2407
2447
  }
2408
- var S_IFDIR, S_IFREG, S_IFLNK, S_IFSOCK, S_IFIFO, S_IFMT, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR, SEEK_END, EARLY_WHOLE_FILE, O_APPEND, O_ACCMODE, O_TRUNC, O_PATH, stale, opening;
2448
+ var S_IFDIR, S_IFREG, S_IFLNK, S_IFSOCK, S_IFIFO, S_IFMT, PERM_MASK, DEFAULT_DIR_PERM, UMASK, SEEK_CUR, SEEK_END, EARLY_WHOLE_FILE, O_APPEND, O_ACCMODE, O_TRUNC, O_PATH, stale, opening, O_NOFOLLOW, RESOLVING;
2409
2449
  var init_live_vfs_fs = __esm({
2410
2450
  "src/realm/live-vfs-fs.ts"() {
2411
2451
  "use strict";
@@ -2433,6 +2473,16 @@ var init_live_vfs_fs = __esm({
2433
2473
  O_PATH = 2097152;
2434
2474
  stale = (s) => !!s.orphan && !s.kept;
2435
2475
  opening = /* @__PURE__ */ new WeakMap();
2476
+ O_NOFOLLOW = 131072;
2477
+ RESOLVING = [
2478
+ ["open", (args) => (args[1] & O_NOFOLLOW) === 0],
2479
+ ["stat", (args) => !args[1]],
2480
+ ["lstat", () => false],
2481
+ ["unlink", () => false],
2482
+ ["rename", () => false],
2483
+ ["readlink", () => false],
2484
+ ["truncate", () => true]
2485
+ ];
2436
2486
  }
2437
2487
  });
2438
2488
 
@@ -2553,7 +2603,7 @@ var KERNEL_VERSION, OS_RELEASE;
2553
2603
  var init_version = __esm({
2554
2604
  "src/version.ts"() {
2555
2605
  "use strict";
2556
- KERNEL_VERSION = true ? "1.122.2" : "0.0.0-dev";
2606
+ KERNEL_VERSION = true ? "1.123.0" : "0.0.0-dev";
2557
2607
  OS_RELEASE = "6.0.0-slicc";
2558
2608
  }
2559
2609
  });
@@ -5142,14 +5192,20 @@ var init_cred = __esm({
5142
5192
  });
5143
5193
 
5144
5194
  // src/process/procfs.ts
5195
+ function isSysFile(at) {
5196
+ return typeof at === "string" || typeof at === "function";
5197
+ }
5145
5198
  function sysEntry(parts) {
5146
5199
  let at = SYS_TREE;
5147
5200
  for (const part of parts) {
5148
- if (typeof at !== "object" || !Object.hasOwn(at, part)) return void 0;
5201
+ if (isSysFile(at) || !Object.hasOwn(at, part)) return void 0;
5149
5202
  at = at[part];
5150
5203
  }
5151
5204
  return at;
5152
5205
  }
5206
+ function sysText(file, listing) {
5207
+ return typeof file === "string" ? file : file(listing());
5208
+ }
5153
5209
  function commOf(info) {
5154
5210
  const name2 = info.argv[0] ?? "";
5155
5211
  return name2.slice(name2.lastIndexOf("/") + 1).slice(0, 15);
@@ -5399,7 +5455,7 @@ function useProcfs(Fs, sys, pid, memory = memorySource()) {
5399
5455
  dir.node_ops.lookup = (at, child) => {
5400
5456
  if (!Object.hasOwn(tree, child)) throw error();
5401
5457
  const next2 = tree[child];
5402
- return typeof next2 === "string" ? file(at, child, () => next2) : sysDir(at, child, next2);
5458
+ return isSysFile(next2) ? file(at, child, () => sysText(next2, procList)) : sysDir(at, child, next2);
5403
5459
  };
5404
5460
  dir.node_ops.readdir = () => [".", "..", ...Object.keys(tree)];
5405
5461
  return dir;
@@ -5523,8 +5579,13 @@ var init_procfs = __esm({
5523
5579
  PID_FILES = ["cmdline", "comm", "stat", "statm", "status"];
5524
5580
  SYSTEM_FILES = ["loadavg", "meminfo", "stat", "uptime", "version"];
5525
5581
  SYS_TREE = {
5526
- kernel: { osrelease: `${OS_RELEASE}
5527
- `, ostype: "Linux\n" }
5582
+ kernel: {
5583
+ osrelease: `${OS_RELEASE}
5584
+ `,
5585
+ ostype: "Linux\n",
5586
+ slicc_wasm_memories: (listing) => `${listing.wasm?.live ?? 0} ${listing.wasm?.ceiling ?? 0}
5587
+ `
5588
+ }
5528
5589
  };
5529
5590
  sigMask = (mask = 0) => (mask >>> 1).toString(16).padStart(16, "0");
5530
5591
  STATES = {
@@ -5960,6 +6021,7 @@ async function runWasmProcess(init, port2, deps = {}) {
5960
6021
  return WebAssembly.instantiate(init.program.module, imports);
5961
6022
  }).then((instance) => {
5962
6023
  memory = wasmMemory(instance, imports);
6024
+ port2.postMessage({ type: WASM_PROCESS_READY });
5963
6025
  exports = instance.exports;
5964
6026
  publishMemory(init.sab, memory?.buffer.byteLength ?? 0);
5965
6027
  done(
@@ -6130,6 +6192,7 @@ var init_process_runtime = __esm({
6130
6192
  "src/process/process-runtime.ts"() {
6131
6193
  "use strict";
6132
6194
  init_loopback_names();
6195
+ init_protocol();
6133
6196
  init_signals();
6134
6197
  init_emscripten_vfs_hook();
6135
6198
  init_live_vfs_fs();
@@ -10938,7 +11001,9 @@ var init_wasi_procfs = __esm({
10938
11001
  }
10939
11002
  if (top === "sys") {
10940
11003
  const entry = sysEntry(parts.slice(1));
10941
- if (typeof entry === "string") return { kind: "file", content: () => entry };
11004
+ if (typeof entry === "string" || typeof entry === "function") {
11005
+ return { kind: "file", content: () => sysText(entry, () => this.listing()) };
11006
+ }
10942
11007
  return entry && { kind: "dir", names: () => Object.keys(entry) };
10943
11008
  }
10944
11009
  if (top === "self") {
@@ -13252,6 +13317,7 @@ async function runWasiProcess(init, port2) {
13252
13317
  restoreExportedMemory(instance, memory, init);
13253
13318
  main.memory = memoryOf(instance, memory);
13254
13319
  publishMemory(init.sab, sizeOf2(main)());
13320
+ port2.postMessage({ type: WASM_PROCESS_READY });
13255
13321
  signals.bind(instance.exports);
13256
13322
  if (importsSigactionHook(module)) signals.useHook();
13257
13323
  if (fork?.signals) signals.restore(fork.signals);