@ai-ecoverse/slicc-kernel 1.93.1 → 1.93.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.
@@ -4559,7 +4559,7 @@ var KERNEL_VERSION, OS_RELEASE;
4559
4559
  var init_version = __esm({
4560
4560
  "src/version.ts"() {
4561
4561
  "use strict";
4562
- KERNEL_VERSION = true ? "1.93.1" : "0.0.0-dev";
4562
+ KERNEL_VERSION = true ? "1.93.3" : "0.0.0-dev";
4563
4563
  OS_RELEASE = "6.0.0-slicc";
4564
4564
  }
4565
4565
  });
@@ -7388,6 +7388,8 @@ var init_wasi_host = __esm({
7388
7388
  muted;
7389
7389
  signals;
7390
7390
  sigmask;
7391
+ linkedTls;
7392
+ linkedModules;
7391
7393
  interrupted;
7392
7394
  quietly = (fn) => fn();
7393
7395
  listening;
@@ -8481,7 +8483,9 @@ var init_wasix_process = __esm({
8481
8483
  ...fds.isShared ? { shared: true } : {},
8482
8484
  setjmps: this.driver.setjmps(),
8483
8485
  ...this.host.signals ? { signals: this.host.signals.snapshot() } : {},
8484
- ...this.host.sigmask ? { blocked: this.host.sigmask.inherited() } : {}
8486
+ ...this.host.sigmask ? { blocked: this.host.sigmask.inherited() } : {},
8487
+ ...this.host.linkedTls ? { tls: this.host.linkedTls() } : {},
8488
+ ...this.host.linkedModules ? { modules: this.host.linkedModules() } : {}
8485
8489
  };
8486
8490
  return this.call({
8487
8491
  op: "proc-fork",
@@ -10014,6 +10018,7 @@ var init_wasix_linker = __esm({
10014
10018
  cppException;
10015
10019
  main;
10016
10020
  modules = /* @__PURE__ */ new Map();
10021
+ forkedTls;
10017
10022
  byPath = /* @__PURE__ */ new Map();
10018
10023
  mainGot = [];
10019
10024
  slots = /* @__PURE__ */ new Map();
@@ -10163,6 +10168,21 @@ var init_wasix_linker = __esm({
10163
10168
  reserve(size) {
10164
10169
  return this.indices?.reserve(this.table.length, size) ?? this.table.length;
10165
10170
  }
10171
+ tlsBases() {
10172
+ const bases = [];
10173
+ for (const [handle, linked] of this.modules) {
10174
+ const base = linked.instance.exports.__tls_base;
10175
+ if (base instanceof WebAssembly.Global) bases.push([handle, base.value]);
10176
+ }
10177
+ return bases;
10178
+ }
10179
+ carryTls(linked) {
10180
+ const base = this.forkedTls?.get(linked.handle);
10181
+ const global = linked.instance.exports.__tls_base;
10182
+ if (base === void 0 || !(global instanceof WebAssembly.Global)) return false;
10183
+ global.value = base;
10184
+ return true;
10185
+ }
10166
10186
  replay(record) {
10167
10187
  if (record.kind === "closure") {
10168
10188
  growTable(this.table, record.index + 1);
@@ -10302,7 +10322,7 @@ var init_wasix_linker = __esm({
10302
10322
  if (init) {
10303
10323
  call(linked.instance, "__wasm_apply_data_relocs");
10304
10324
  call(linked.instance, "__wasm_call_ctors");
10305
- } else {
10325
+ } else if (!this.carryTls(linked)) {
10306
10326
  call(linked.instance, "__wasix_init_tls");
10307
10327
  }
10308
10328
  return linked;
@@ -11353,6 +11373,7 @@ function spawnsThreads(module) {
11353
11373
  }
11354
11374
  async function instantiate(host, module, memory, threads, {
11355
11375
  thread = false,
11376
+ forked,
11356
11377
  stats,
11357
11378
  signals,
11358
11379
  program,
@@ -11426,14 +11447,21 @@ async function instantiate(host, module, memory, threads, {
11426
11447
  wasixHost.types.register(() => read2(path), instance, table, sync ? TABLE_BASE2 : 0);
11427
11448
  }
11428
11449
  }
11429
- if (sync) {
11430
- sync.linker.bindMain(instance, !thread);
11431
- if (path !== void 0) sync.linker.mainPath = path;
11432
- if (thread) sync.catchUp();
11433
- sync.linker.bindMainGot();
11434
- }
11450
+ if (sync) bindLinker(host, sync, instance, { thread, forked, path });
11435
11451
  return { instance, driver };
11436
11452
  }
11453
+ function bindLinker(host, sync, instance, at) {
11454
+ sync.linker.bindMain(instance, !at.thread);
11455
+ if (at.path !== void 0) sync.linker.mainPath = at.path;
11456
+ host.linkedTls = () => sync.linker.tlsBases();
11457
+ host.linkedModules = () => sync.linker.compiled();
11458
+ if (at.forked) {
11459
+ sync.linker.forkedTls = new Map(at.forked.tls ?? []);
11460
+ sync.linker.cache = at.forked.modules;
11461
+ }
11462
+ if (at.thread || at.forked) sync.catchUp();
11463
+ sync.linker.bindMainGot();
11464
+ }
11437
11465
  function procTree(call2, pid) {
11438
11466
  return new ProcTree(
11439
11467
  {
@@ -11535,6 +11563,7 @@ async function runWasiProcess(init, port2) {
11535
11563
  }
11536
11564
  const program = await programImports(init.program, host, transport, MAIN_TID);
11537
11565
  const { instance, driver } = await instantiate(host, module, memory, threads, {
11566
+ ...fork ? { forked: fork } : {},
11538
11567
  stats,
11539
11568
  signals,
11540
11569
  foreign: init.program.foreign,