@ai-ecoverse/slicc-kernel 1.166.4 → 1.166.5

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/README.md CHANGED
@@ -424,7 +424,7 @@ The module's default export (or its `main` export) is called with a context and
424
424
  - `sync.promiseState(promise)` (#1531, slicc-jsh#974) tells a native promise's state synchronously, as Node's `util.inspect` does: `{ state: 'pending' | 'fulfilled' | 'rejected', value }`. `value` is the very fulfillment value or rejection reason (`undefined` while pending), and probing doesn't handle a rejection. On the Node entry it reads the promise through an inspector session the process worker opens on first use, one per process and per thread; the probe runs no program code. Anything that isn't a native promise (a thenable, a proxy) is a `TypeError`. It answers `undefined` in a browser, where a worker has no inspector, on a Node built without one, once a program has changed `Object.prototype` or put a `toJSON` on a built-in prototype, and when the global object can't take a new property (`Object.preventExtensions(globalThis)`, or a frozen global).
425
425
  - `sync.setStackFormatter(fn | null)` (#1612, slicc-jsh#1091) is Node only, so check it with `typeof ctx.sync.setStackFormatter === 'function'`. It returns the previous formatter, and `null` removes it.
426
426
  - **When `fn` runs:** it formats an error's `.stack` the way V8's prepare-stack-trace callback does, as `fn(error, callSites)` returning the string. It runs only when no own `Error.prepareStackTrace` function is set, as in Node, so `Error.prepareStackTrace` stays an ordinary property: after `delete` it's `undefined`, `Object.getPrototypeOf(Error)` stays `Function.prototype`, and an assignment to a frozen subclass throws in strict mode.
427
- - **What `fn` gets:** a fresh array of V8 CallSites holding only the program's own frames (its modules, `data:` imports, `sync.runScript` scripts, code they `eval`, `new Function` or `eval` code named by `//# sourceURL`, #1632, and code such a body `eval`s, #1648), `node:` frames and native frames. Kernel frames are dropped by script identity, so a script named like a kernel file doesn't let them through, and so are host files. A program's strict frames give `getFunction()` and `getThis()` as `undefined`.
427
+ - **What `fn` gets:** a fresh array of V8 CallSites holding only the program's own frames (its modules, `data:` imports, `sync.runScript` scripts, code they `eval`, `new Function` or `eval` code named by `//# sourceURL`, #1632, and code such a body `eval`s, #1648; the kernel remembers the 4096 sourceURL names it saw last, #1658), `node:` frames and native frames. Kernel frames are dropped by script identity, so a script named like a kernel file doesn't let them through, and so are host files. A program's strict frames give `getFunction()` and `getThis()` as `undefined`.
428
428
  - **Fallback:** if `fn` throws or returns a non-string, or an error is formatted while `fn` runs, the default stack is used.
429
429
  - **`{ own: true }`** (#1631): `setStackFormatter(fn, { own: true })` calls `fn(error, callSites, own)` for every stack. `own` is the program's own `Error.prepareStackTrace` (the realm's `Error`, then the main one, read as Node 26 reads it), or `undefined` when none is set or it's Node's default. `fn`'s result is the stack whatever its type, and a throw propagates out of the `.stack` read, as with Node's own callback.
430
430
  - **An own `Error.prepareStackTrace` on the Node entry** (#1631): the process worker replaces Node's stack callback with a copy of Node 26's order. A program's own `Error.prepareStackTrace`, and a host preload's, still gets V8's CallSites as in Node, kernel frames included (named `slicc-kernel:/node-process-worker.js`), with its `Error` as receiver; its result and throws are the stack. To hand it the filtered CallSites instead (no kernel frame, no host path), use `setStackFormatter(fn, { own: true })` and call `own` from `fn`. 1.165.0 filtered by default, which broke runtimes that read their own frames through an own `prepareStackTrace`; the release after it went back to V8's CallSites. Node's own internal overrides still come first with raw frames, and so do the kernel's own diagnostics: a crash report and a WASI trap backtrace still show kernel and wasm frames.
@@ -8464,7 +8464,7 @@ function satisfies(version, range2) {
8464
8464
  }
8465
8465
 
8466
8466
  // src/version.ts
8467
- var KERNEL_VERSION = true ? "1.166.4" : "0.0.0-dev";
8467
+ var KERNEL_VERSION = true ? "1.166.5" : "0.0.0-dev";
8468
8468
  var OS_RELEASE = "6.0.0-slicc";
8469
8469
  function procVersion() {
8470
8470
  return `Linux version ${OS_RELEASE} (slicc-kernel ${KERNEL_VERSION}) #1 SMP PREEMPT_DYNAMIC
@@ -1531,6 +1531,17 @@ var programHashes = /* @__PURE__ */ new Set();
1531
1531
  var programNames = /* @__PURE__ */ new Set();
1532
1532
  var SOURCE_NAMES = 4096;
1533
1533
  var sourceNames = /* @__PURE__ */ new Set();
1534
+ var setDelete = Set.prototype.delete;
1535
+ var setValues = Set.prototype.values;
1536
+ var sizeOf = Object.getOwnPropertyDescriptor(Set.prototype, "size")?.get;
1537
+ var nextOf = Object.getPrototypeOf((/* @__PURE__ */ new Set()).values()).next;
1538
+ function noteName(name) {
1539
+ if (apply(setDelete, sourceNames, [name]) !== true && apply(sizeOf, sourceNames, []) >= SOURCE_NAMES) {
1540
+ const oldest = apply(nextOf, apply(setValues, sourceNames, []), []);
1541
+ apply(setDelete, sourceNames, [oldest.value]);
1542
+ }
1543
+ apply(setAdd, sourceNames, [name]);
1544
+ }
1534
1545
  function programName(name) {
1535
1546
  return apply(startsWith, name, ["data:"]) === true || apply(setHas, programNames, [name]) === true || apply(setHas, sourceNames, [name]) === true;
1536
1547
  }
@@ -1542,7 +1553,7 @@ function noteSourceUrls(trace) {
1542
1553
  if (typeof origin !== "string" || evalAt(origin)) continue;
1543
1554
  const name = apply(nameOf, site, []);
1544
1555
  if (typeof name !== "string" || apply(setHas, ownNames, [name]) === true) continue;
1545
- if (sourceNames.size < SOURCE_NAMES) apply(setAdd, sourceNames, [name]);
1556
+ noteName(name);
1546
1557
  }
1547
1558
  }
1548
1559
  function rootOrigin(origin) {