@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.
@@ -2454,7 +2454,7 @@ var KERNEL_VERSION, OS_RELEASE;
2454
2454
  var init_version = __esm({
2455
2455
  "src/version.ts"() {
2456
2456
  "use strict";
2457
- KERNEL_VERSION = true ? "1.98.2" : "0.0.0-dev";
2457
+ KERNEL_VERSION = true ? "1.98.4" : "0.0.0-dev";
2458
2458
  OS_RELEASE = "6.0.0-slicc";
2459
2459
  }
2460
2460
  });
@@ -10224,16 +10224,18 @@ function mutableGlobals(exports) {
10224
10224
  }
10225
10225
  return out;
10226
10226
  }
10227
- var UNWINDING, REWINDING, AsyncifyDriver;
10227
+ var STACK_POINTER, UNWINDING, REWINDING, AsyncifyDriver;
10228
10228
  var init_wasix_fork = __esm({
10229
10229
  "src/process/wasi/wasix-fork.ts"() {
10230
10230
  "use strict";
10231
10231
  init_wasi_abi();
10232
+ STACK_POINTER = "__stack_pointer";
10232
10233
  UNWINDING = 1;
10233
10234
  REWINDING = 2;
10234
10235
  AsyncifyDriver = class {
10235
10236
  exports = {};
10236
10237
  stackUpper = 0;
10238
+ linked;
10237
10239
  pending;
10238
10240
  answer = 0;
10239
10241
  snapshots = /* @__PURE__ */ new Map();
@@ -10242,10 +10244,12 @@ var init_wasix_fork = __esm({
10242
10244
  constructor(mem) {
10243
10245
  this.mem = mem;
10244
10246
  }
10247
+ useStack(pointer, low) {
10248
+ this.linked = { pointer, low };
10249
+ }
10245
10250
  bind(exports) {
10246
10251
  this.exports = exports;
10247
- const sp = this.exports.__stack_pointer;
10248
- this.stackUpper = sp instanceof WebAssembly.Global ? sp.value : 0;
10252
+ this.stackUpper = this.stackPointer();
10249
10253
  }
10250
10254
  get supported() {
10251
10255
  return typeof this.exports.asyncify_start_unwind === "function";
@@ -10280,7 +10284,7 @@ var init_wasix_fork = __esm({
10280
10284
  }
10281
10285
  fork(fork) {
10282
10286
  const sp = this.stackPointer();
10283
- const globals = mutableGlobals(this.exports);
10287
+ const globals = this.globals();
10284
10288
  return this.unwind((data) => {
10285
10289
  this.answer = fork(data, globals, sp);
10286
10290
  });
@@ -10291,7 +10295,7 @@ var init_wasix_fork = __esm({
10291
10295
  v.setBigUint64(snapPtr, BigInt(retPtr), true);
10292
10296
  v.setBigUint64(snapPtr + 8, BigInt(id), true);
10293
10297
  v.setBigUint64(snapPtr + 16, 0x51cc5117n, true);
10294
- const globals = mutableGlobals(this.exports);
10298
+ const globals = this.globals();
10295
10299
  return this.unwind((data) => {
10296
10300
  const end = this.mem.view().getUint32(data, true);
10297
10301
  this.snapshots.set(id, { frames: this.mem.bytes(data + 8, end - data - 8).slice(), globals });
@@ -10309,11 +10313,24 @@ var init_wasix_fork = __esm({
10309
10313
  this.answer = Number(val) || 1;
10310
10314
  });
10311
10315
  }
10316
+ stackGlobal() {
10317
+ const g = this.exports[STACK_POINTER];
10318
+ return g instanceof WebAssembly.Global ? g : this.linked?.pointer;
10319
+ }
10312
10320
  stackPointer() {
10313
- const g = this.exports.__stack_pointer;
10314
- return g instanceof WebAssembly.Global ? g.value : 0;
10321
+ return this.stackGlobal()?.value ?? 0;
10322
+ }
10323
+ globals() {
10324
+ const out = mutableGlobals(this.exports);
10325
+ if (this.linked && !out.some(([name2]) => name2 === STACK_POINTER)) {
10326
+ out.push([STACK_POINTER, this.linked.pointer.value]);
10327
+ }
10328
+ return out;
10315
10329
  }
10316
10330
  dataPointer() {
10331
+ if (this.linked && !(this.exports[STACK_POINTER] instanceof WebAssembly.Global)) {
10332
+ return this.linked.low + 15 & ~15;
10333
+ }
10317
10334
  const g = this.exports.__data_end;
10318
10335
  const dataEnd = g instanceof WebAssembly.Global ? g.value : 0;
10319
10336
  return dataEnd < this.stackUpper ? dataEnd + 15 & ~15 : 16;
@@ -10333,7 +10350,7 @@ var init_wasix_fork = __esm({
10333
10350
  }
10334
10351
  restoreGlobals(globals) {
10335
10352
  for (const [name2, value2] of globals) {
10336
- const g = this.exports[name2];
10353
+ const g = name2 === STACK_POINTER ? this.stackGlobal() : this.exports[name2];
10337
10354
  if (g instanceof WebAssembly.Global) g.value = value2;
10338
10355
  }
10339
10356
  }
@@ -12083,6 +12100,7 @@ async function instantiate(host, module, memory, threads, {
12083
12100
  }
12084
12101
  }
12085
12102
  if (sync) bindLinker(host, sync, instance, { thread, forked, path });
12103
+ if (sync && !thread) driver.useStack(sync.linker.stackPointer, sync.linker.stackLow);
12086
12104
  return { instance, driver };
12087
12105
  }
12088
12106
  function bindLinker(host, sync, instance, at) {