@ai-ecoverse/slicc-kernel 1.49.0 → 1.50.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.
@@ -7385,7 +7385,7 @@ var init_wasix_linker = __esm({
7385
7385
  slots = /* @__PURE__ */ new Map();
7386
7386
  nextHandle = 1;
7387
7387
  publisher;
7388
- closures;
7388
+ indices;
7389
7389
  types = new FuncTypes();
7390
7390
  memory;
7391
7391
  host;
@@ -7471,21 +7471,26 @@ var init_wasix_linker = __esm({
7471
7471
  return out;
7472
7472
  }
7473
7473
  allocateClosure() {
7474
- const index2 = this.closures.allocate(
7475
- this.table.length
7476
- );
7474
+ const index2 = this.indices.allocate(this.table.length);
7477
7475
  growTable(this.table, index2 + 1);
7478
7476
  return index2;
7479
7477
  }
7480
7478
  freeClosure(index2) {
7481
- this.closures?.free(index2);
7479
+ this.indices?.free(index2);
7482
7480
  this.table.set(index2, null);
7483
7481
  }
7482
+ reserve(size) {
7483
+ return this.indices?.reserve(this.table.length, size) ?? this.table.length;
7484
+ }
7484
7485
  replay(record) {
7485
7486
  if (record.kind === "closure") {
7486
7487
  growTable(this.table, record.index + 1);
7487
7488
  return;
7488
7489
  }
7490
+ if (record.kind === "closure-free") {
7491
+ if (record.index < this.table.length) this.table.set(record.index, null);
7492
+ return;
7493
+ }
7489
7494
  if (record.kind === "load") {
7490
7495
  if (this.modules.has(record.handle)) return;
7491
7496
  this.instantiate(record.path, this.moduleAt(record.path), record, false);
@@ -7538,7 +7543,7 @@ var init_wasix_linker = __esm({
7538
7543
  (n) => this.load(this.locate(n, cwd, search), cwd, ldPath).handle
7539
7544
  );
7540
7545
  const memoryBase = this.allocate(info.memorySize, 2 ** info.memoryAlign);
7541
- const tableBase = this.table.length;
7546
+ const tableBase = this.reserve(info.tableSize);
7542
7547
  const record = {
7543
7548
  kind: "load",
7544
7549
  handle: this.nextHandle++,
@@ -7662,8 +7667,8 @@ var init_wasix_linker = __esm({
7662
7667
  slot(fn, handle, name) {
7663
7668
  const known = this.slots.get(fn);
7664
7669
  if (known !== void 0) return known;
7665
- const index2 = this.table.length;
7666
- this.table.grow(1);
7670
+ const index2 = this.reserve(1);
7671
+ growTable(this.table, index2 + 1);
7667
7672
  this.table.set(index2, fn);
7668
7673
  this.slots.set(fn, index2);
7669
7674
  this.publisher?.({ kind: "slot", index: index2, handle, name });
@@ -7671,9 +7676,9 @@ var init_wasix_linker = __esm({
7671
7676
  }
7672
7677
  allocate(size, alignment) {
7673
7678
  if (size === 0) return 0;
7674
- const base = align(this.memory.buffer.byteLength, Math.max(alignment, 16));
7675
- growTo(this.memory, base + size);
7676
- return base;
7679
+ const to = Math.max(alignment, 16);
7680
+ const pages2 = Math.ceil((size + (to > PAGE2 ? to : 0)) / PAGE2);
7681
+ return align(this.memory.grow(pages2) * PAGE2, to);
7677
7682
  }
7678
7683
  };
7679
7684
  }
@@ -8909,7 +8914,8 @@ var init_wasi_runtime = __esm({
8909
8914
  this.call = call2;
8910
8915
  this.ids = ids;
8911
8916
  linker.publisher = (record) => this.publish(record);
8912
- linker.closures = {
8917
+ linker.indices = {
8918
+ reserve: (floor, size) => this.call({ op: "dl-reserve", floor, size }),
8913
8919
  allocate: (floor) => {
8914
8920
  const index2 = this.call({ op: "dl-closure", floor });
8915
8921
  this.catchUp();