@ai-ecoverse/slicc-kernel 1.165.0 → 1.165.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.
@@ -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.0" : "0.0.0-dev";
7468
+ KERNEL_VERSION = true ? "1.165.2" : "0.0.0-dev";
7406
7469
  OS_RELEASE = "6.0.0-slicc";
7407
7470
  }
7408
7471
  });
@@ -19873,7 +19936,7 @@ function kernelCallback(internal2, dispatch) {
19873
19936
  }
19874
19937
  if (own2 === void 0) return apply(dispatch, void 0, [error, trace]);
19875
19938
  record(positions, error, trace);
19876
- return calling(() => apply(own2.fn, own2.self, [error, keptFrames(trace)]));
19939
+ return apply(own2.fn, own2.self, [error, trace]);
19877
19940
  };
19878
19941
  }
19879
19942
  function rawReader(overrides, fallback) {