@ai-ecoverse/slicc-kernel 1.165.1 → 1.165.3

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.
@@ -358,6 +358,9 @@ var init_wasi_abi = __esm({
358
358
  function renameWait(view) {
359
359
  return view.foreign() ? RENAME_WAIT_SHARED_MS : RENAME_WAIT_MS;
360
360
  }
361
+ function heldSlot(path) {
362
+ return HELD + (changeHash(normal(path)) & HELD_SLOTS - 1);
363
+ }
361
364
  function changeHash(path) {
362
365
  let h = 2166136261;
363
366
  for (let i = 0; i < path.length; i++) {
@@ -375,7 +378,7 @@ function normal(path) {
375
378
  }
376
379
  return `/${parts.join("/")}`;
377
380
  }
378
- var GEN, RING, RING_SIZE, SLOT, SHARED_TTL_MS, RENAME_WAIT_MS, RENAME_WAIT_SHARED_MS, DIRTY, FOREIGN, RENAMES, CHANGES_BYTES, ChangeView;
381
+ var GEN, RING, RING_SIZE, SLOT, SHARED_TTL_MS, RENAME_WAIT_MS, RENAME_WAIT_SHARED_MS, DIRTY, FOREIGN, RENAMES, HELD, HELD_SLOTS, CHANGES_BYTES, ChangeView;
379
382
  var init_changes = __esm({
380
383
  "src/fs/changes.ts"() {
381
384
  "use strict";
@@ -390,7 +393,9 @@ var init_changes = __esm({
390
393
  DIRTY = RING + RING_SIZE * SLOT;
391
394
  FOREIGN = DIRTY + 1;
392
395
  RENAMES = FOREIGN + 1;
393
- CHANGES_BYTES = (RENAMES + 1) * 4;
396
+ HELD = RENAMES + 1;
397
+ HELD_SLOTS = 1024;
398
+ CHANGES_BYTES = (HELD + HELD_SLOTS) * 4;
394
399
  ChangeView = class {
395
400
  view;
396
401
  constructor(sab) {
@@ -405,6 +410,9 @@ var init_changes = __esm({
405
410
  foreign() {
406
411
  return this.view.length > FOREIGN && capturedAtomics.load(this.view, FOREIGN) === 1;
407
412
  }
413
+ peerHeld(path) {
414
+ return this.view.length > HELD && capturedAtomics.load(this.view, heldSlot(path)) === 1;
415
+ }
408
416
  renames() {
409
417
  return this.view.length > RENAMES ? capturedAtomics.load(this.view, RENAMES) : 0;
410
418
  }
@@ -582,6 +590,14 @@ var init_pages = __esm({
582
590
  pin() {
583
591
  this.pinned = true;
584
592
  }
593
+ landed(at, length) {
594
+ const end = at + length;
595
+ for (let page = capturedMath.floor(at / PAGE); page * PAGE < end; page++) {
596
+ if (this.pages.has(page) && !this.dirty.has(page)) this.drop(page);
597
+ }
598
+ this.length = capturedMath.max(this.length, end);
599
+ this.stored = capturedMath.max(this.stored, end);
600
+ }
585
601
  reset(size) {
586
602
  if (this.pinned) return;
587
603
  for (const page of [...this.pages.keys()]) if (!this.dirty.has(page)) this.drop(page);
@@ -703,6 +719,11 @@ var init_ranged = __esm({
703
719
  get changed() {
704
720
  return this.pages.changed;
705
721
  }
722
+ wrote(at, length) {
723
+ this.pages.landed(at, length);
724
+ this.version = void 0;
725
+ this.fresh();
726
+ }
706
727
  get pinnedVersion() {
707
728
  return this.version;
708
729
  }
@@ -1271,8 +1292,43 @@ var init_wasi_files = __esm({
1271
1292
  live() {
1272
1293
  if (this.spoiled) throw new WasiError("ESTALE");
1273
1294
  }
1295
+ crowded() {
1296
+ return this.watch?.view.peerHeld(this.where) === true;
1297
+ }
1298
+ exact() {
1299
+ this.flush();
1300
+ const watch = this.watch;
1301
+ const size = this.retried(() => watch.stat(this.where)).size;
1302
+ if (this.ranged) {
1303
+ if (size !== this.ranged.size()) this.ranged.reread();
1304
+ return void 0;
1305
+ }
1306
+ if (this.data && size !== this.length) this.data = void 0;
1307
+ return this.data ? void 0 : size;
1308
+ }
1309
+ wrote(at, bytes) {
1310
+ if (this.ranged) {
1311
+ this.ranged.wrote(at, bytes.length);
1312
+ return;
1313
+ }
1314
+ const view = this.watch.view;
1315
+ const { now, changed: changed2 } = view.changedSince(this.seen, this.where);
1316
+ this.seen = now;
1317
+ if (changed2) this.data = void 0;
1318
+ if (!this.data) return;
1319
+ const end = at + bytes.length;
1320
+ this.ensure(end);
1321
+ const buf = this.data;
1322
+ if (at > this.length) buf.fill(0, this.length, at);
1323
+ buf.set(bytes, at);
1324
+ this.length = capturedMath.max(this.length, end);
1325
+ }
1274
1326
  size() {
1275
1327
  this.live();
1328
+ if (this.crowded()) {
1329
+ const known = this.exact();
1330
+ if (known !== void 0) return known;
1331
+ }
1276
1332
  if (this.ranged) return this.ranged.size();
1277
1333
  this.load();
1278
1334
  return this.length;
@@ -1292,6 +1348,13 @@ var init_wasi_files = __esm({
1292
1348
  if (bytes.length === 0) return 0;
1293
1349
  const end = at + bytes.length;
1294
1350
  this.fits(end);
1351
+ const { pwrite } = this.fs;
1352
+ if (pwrite && this.crowded() && end > this.size()) {
1353
+ const copy2 = bytes.slice();
1354
+ this.retried(() => pwrite.call(this.fs, this.where, at, copy2, true));
1355
+ this.wrote(at, bytes);
1356
+ return bytes.length;
1357
+ }
1295
1358
  this.dirty = true;
1296
1359
  if (this.ranged) {
1297
1360
  this.ranged.write(at, bytes);
@@ -7402,7 +7465,7 @@ var init_version = __esm({
7402
7465
  "src/version.ts"() {
7403
7466
  "use strict";
7404
7467
  init_captured_globals();
7405
- KERNEL_VERSION = true ? "1.165.1" : "0.0.0-dev";
7468
+ KERNEL_VERSION = true ? "1.165.3" : "0.0.0-dev";
7406
7469
  OS_RELEASE = "6.0.0-slicc";
7407
7470
  }
7408
7471
  });
@@ -19744,8 +19807,21 @@ function programScript(name2, hash) {
19744
19807
  apply(setAdd, programNames, [name2]);
19745
19808
  apply(setAdd, programHashes, [hash]);
19746
19809
  }
19810
+ var SOURCE_NAMES = 4096;
19811
+ var sourceNames = new capturedSet();
19747
19812
  function programName(name2) {
19748
- return apply(startsWith, name2, ["data:"]) === true || apply(setHas, programNames, [name2]) === true;
19813
+ return apply(startsWith, name2, ["data:"]) === true || apply(setHas, programNames, [name2]) === true || apply(setHas, sourceNames, [name2]) === true;
19814
+ }
19815
+ function noteSourceUrls(trace) {
19816
+ for (let i = 0; i < trace.length; i++) {
19817
+ const site = trace[i];
19818
+ if (apply(isEval, site, []) !== true || apply(hashOf, site, []) === ownHash) continue;
19819
+ const origin = apply(originOf, site, []);
19820
+ if (typeof origin !== "string" || evalAt(origin)) continue;
19821
+ const name2 = apply(nameOf, site, []);
19822
+ if (typeof name2 !== "string" || apply(setHas, ownNames, [name2]) === true) continue;
19823
+ if (sourceNames.size < SOURCE_NAMES) apply(setAdd, sourceNames, [name2]);
19824
+ }
19749
19825
  }
19750
19826
  function rootOrigin(origin) {
19751
19827
  let at = origin;
@@ -19793,6 +19869,7 @@ function keptFrame(site) {
19793
19869
  return apply(startsWith, file, ["node:"]) === true || programName(file);
19794
19870
  }
19795
19871
  function keptFrames(trace) {
19872
+ noteSourceUrls(trace);
19796
19873
  const out = [];
19797
19874
  for (let i = 0; i < trace.length; i++) {
19798
19875
  const site = trace[i];
@@ -19814,6 +19891,7 @@ function positionsAt(positions, error, site) {
19814
19891
  }
19815
19892
  function record(positions, error, trace) {
19816
19893
  if (typeof error === "object" && error !== null && trace.length > 0) {
19894
+ noteSourceUrls(trace);
19817
19895
  const site = trace[0];
19818
19896
  apply(mapSet, seen, [error, { site, at: positionsAt(positions, error, site) }]);
19819
19897
  }