@ai-ecoverse/slicc-kernel 1.98.2 → 1.98.4

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.
@@ -4591,7 +4591,7 @@ var KERNEL_VERSION, OS_RELEASE;
4591
4591
  var init_version = __esm({
4592
4592
  "src/version.ts"() {
4593
4593
  "use strict";
4594
- KERNEL_VERSION = true ? "1.98.2" : "0.0.0-dev";
4594
+ KERNEL_VERSION = true ? "1.98.4" : "0.0.0-dev";
4595
4595
  OS_RELEASE = "6.0.0-slicc";
4596
4596
  }
4597
4597
  });
@@ -13276,16 +13276,18 @@ function mutableGlobals(exports) {
13276
13276
  }
13277
13277
  return out;
13278
13278
  }
13279
- var UNWINDING, REWINDING, AsyncifyDriver;
13279
+ var STACK_POINTER, UNWINDING, REWINDING, AsyncifyDriver;
13280
13280
  var init_wasix_fork = __esm({
13281
13281
  "src/process/wasi/wasix-fork.ts"() {
13282
13282
  "use strict";
13283
13283
  init_wasi_abi();
13284
+ STACK_POINTER = "__stack_pointer";
13284
13285
  UNWINDING = 1;
13285
13286
  REWINDING = 2;
13286
13287
  AsyncifyDriver = class {
13287
13288
  exports = {};
13288
13289
  stackUpper = 0;
13290
+ linked;
13289
13291
  pending;
13290
13292
  answer = 0;
13291
13293
  snapshots = /* @__PURE__ */ new Map();
@@ -13294,10 +13296,12 @@ var init_wasix_fork = __esm({
13294
13296
  constructor(mem) {
13295
13297
  this.mem = mem;
13296
13298
  }
13299
+ useStack(pointer, low) {
13300
+ this.linked = { pointer, low };
13301
+ }
13297
13302
  bind(exports) {
13298
13303
  this.exports = exports;
13299
- const sp = this.exports.__stack_pointer;
13300
- this.stackUpper = sp instanceof WebAssembly.Global ? sp.value : 0;
13304
+ this.stackUpper = this.stackPointer();
13301
13305
  }
13302
13306
  get supported() {
13303
13307
  return typeof this.exports.asyncify_start_unwind === "function";
@@ -13332,7 +13336,7 @@ var init_wasix_fork = __esm({
13332
13336
  }
13333
13337
  fork(fork) {
13334
13338
  const sp = this.stackPointer();
13335
- const globals = mutableGlobals(this.exports);
13339
+ const globals = this.globals();
13336
13340
  return this.unwind((data) => {
13337
13341
  this.answer = fork(data, globals, sp);
13338
13342
  });
@@ -13343,7 +13347,7 @@ var init_wasix_fork = __esm({
13343
13347
  v.setBigUint64(snapPtr, BigInt(retPtr), true);
13344
13348
  v.setBigUint64(snapPtr + 8, BigInt(id), true);
13345
13349
  v.setBigUint64(snapPtr + 16, 0x51cc5117n, true);
13346
- const globals = mutableGlobals(this.exports);
13350
+ const globals = this.globals();
13347
13351
  return this.unwind((data) => {
13348
13352
  const end = this.mem.view().getUint32(data, true);
13349
13353
  this.snapshots.set(id, { frames: this.mem.bytes(data + 8, end - data - 8).slice(), globals });
@@ -13361,11 +13365,24 @@ var init_wasix_fork = __esm({
13361
13365
  this.answer = Number(val) || 1;
13362
13366
  });
13363
13367
  }
13368
+ stackGlobal() {
13369
+ const g = this.exports[STACK_POINTER];
13370
+ return g instanceof WebAssembly.Global ? g : this.linked?.pointer;
13371
+ }
13364
13372
  stackPointer() {
13365
- const g = this.exports.__stack_pointer;
13366
- return g instanceof WebAssembly.Global ? g.value : 0;
13373
+ return this.stackGlobal()?.value ?? 0;
13374
+ }
13375
+ globals() {
13376
+ const out = mutableGlobals(this.exports);
13377
+ if (this.linked && !out.some(([name2]) => name2 === STACK_POINTER)) {
13378
+ out.push([STACK_POINTER, this.linked.pointer.value]);
13379
+ }
13380
+ return out;
13367
13381
  }
13368
13382
  dataPointer() {
13383
+ if (this.linked && !(this.exports[STACK_POINTER] instanceof WebAssembly.Global)) {
13384
+ return this.linked.low + 15 & ~15;
13385
+ }
13369
13386
  const g = this.exports.__data_end;
13370
13387
  const dataEnd = g instanceof WebAssembly.Global ? g.value : 0;
13371
13388
  return dataEnd < this.stackUpper ? dataEnd + 15 & ~15 : 16;
@@ -13385,7 +13402,7 @@ var init_wasix_fork = __esm({
13385
13402
  }
13386
13403
  restoreGlobals(globals) {
13387
13404
  for (const [name2, value2] of globals) {
13388
- const g = this.exports[name2];
13405
+ const g = name2 === STACK_POINTER ? this.stackGlobal() : this.exports[name2];
13389
13406
  if (g instanceof WebAssembly.Global) g.value = value2;
13390
13407
  }
13391
13408
  }
@@ -15135,6 +15152,7 @@ async function instantiate(host, module, memory, threads, {
15135
15152
  }
15136
15153
  }
15137
15154
  if (sync) bindLinker(host, sync, instance, { thread, forked, path });
15155
+ if (sync && !thread) driver.useStack(sync.linker.stackPointer, sync.linker.stackLow);
15138
15156
  return { instance, driver };
15139
15157
  }
15140
15158
  function bindLinker(host, sync, instance, at) {