@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.
@@ -2596,6 +2596,8 @@ var init_wasi_host = __esm({
2596
2596
  muted;
2597
2597
  signals;
2598
2598
  sigmask;
2599
+ linkedTls;
2600
+ linkedModules;
2599
2601
  interrupted;
2600
2602
  quietly = (fn) => fn();
2601
2603
  listening;
@@ -3614,7 +3616,9 @@ var init_wasix_process = __esm({
3614
3616
  ...fds.isShared ? { shared: true } : {},
3615
3617
  setjmps: this.driver.setjmps(),
3616
3618
  ...this.host.signals ? { signals: this.host.signals.snapshot() } : {},
3617
- ...this.host.sigmask ? { blocked: this.host.sigmask.inherited() } : {}
3619
+ ...this.host.sigmask ? { blocked: this.host.sigmask.inherited() } : {},
3620
+ ...this.host.linkedTls ? { tls: this.host.linkedTls() } : {},
3621
+ ...this.host.linkedModules ? { modules: this.host.linkedModules() } : {}
3618
3622
  };
3619
3623
  return this.call({
3620
3624
  op: "proc-fork",
@@ -4018,7 +4022,7 @@ var KERNEL_VERSION, OS_RELEASE;
4018
4022
  var init_version = __esm({
4019
4023
  "src/version.ts"() {
4020
4024
  "use strict";
4021
- KERNEL_VERSION = true ? "1.93.1" : "0.0.0-dev";
4025
+ KERNEL_VERSION = true ? "1.93.3" : "0.0.0-dev";
4022
4026
  OS_RELEASE = "6.0.0-slicc";
4023
4027
  }
4024
4028
  });
@@ -13065,6 +13069,7 @@ var init_wasix_linker = __esm({
13065
13069
  cppException;
13066
13070
  main;
13067
13071
  modules = /* @__PURE__ */ new Map();
13072
+ forkedTls;
13068
13073
  byPath = /* @__PURE__ */ new Map();
13069
13074
  mainGot = [];
13070
13075
  slots = /* @__PURE__ */ new Map();
@@ -13214,6 +13219,21 @@ var init_wasix_linker = __esm({
13214
13219
  reserve(size) {
13215
13220
  return this.indices?.reserve(this.table.length, size) ?? this.table.length;
13216
13221
  }
13222
+ tlsBases() {
13223
+ const bases = [];
13224
+ for (const [handle, linked] of this.modules) {
13225
+ const base = linked.instance.exports.__tls_base;
13226
+ if (base instanceof WebAssembly.Global) bases.push([handle, base.value]);
13227
+ }
13228
+ return bases;
13229
+ }
13230
+ carryTls(linked) {
13231
+ const base = this.forkedTls?.get(linked.handle);
13232
+ const global = linked.instance.exports.__tls_base;
13233
+ if (base === void 0 || !(global instanceof WebAssembly.Global)) return false;
13234
+ global.value = base;
13235
+ return true;
13236
+ }
13217
13237
  replay(record) {
13218
13238
  if (record.kind === "closure") {
13219
13239
  growTable(this.table, record.index + 1);
@@ -13353,7 +13373,7 @@ var init_wasix_linker = __esm({
13353
13373
  if (init) {
13354
13374
  call(linked.instance, "__wasm_apply_data_relocs");
13355
13375
  call(linked.instance, "__wasm_call_ctors");
13356
- } else {
13376
+ } else if (!this.carryTls(linked)) {
13357
13377
  call(linked.instance, "__wasix_init_tls");
13358
13378
  }
13359
13379
  return linked;
@@ -14404,6 +14424,7 @@ function spawnsThreads(module) {
14404
14424
  }
14405
14425
  async function instantiate(host, module, memory, threads, {
14406
14426
  thread = false,
14427
+ forked,
14407
14428
  stats,
14408
14429
  signals,
14409
14430
  program,
@@ -14477,14 +14498,21 @@ async function instantiate(host, module, memory, threads, {
14477
14498
  wasixHost.types.register(() => read2(path), instance, table, sync ? TABLE_BASE2 : 0);
14478
14499
  }
14479
14500
  }
14480
- if (sync) {
14481
- sync.linker.bindMain(instance, !thread);
14482
- if (path !== void 0) sync.linker.mainPath = path;
14483
- if (thread) sync.catchUp();
14484
- sync.linker.bindMainGot();
14485
- }
14501
+ if (sync) bindLinker(host, sync, instance, { thread, forked, path });
14486
14502
  return { instance, driver };
14487
14503
  }
14504
+ function bindLinker(host, sync, instance, at) {
14505
+ sync.linker.bindMain(instance, !at.thread);
14506
+ if (at.path !== void 0) sync.linker.mainPath = at.path;
14507
+ host.linkedTls = () => sync.linker.tlsBases();
14508
+ host.linkedModules = () => sync.linker.compiled();
14509
+ if (at.forked) {
14510
+ sync.linker.forkedTls = new Map(at.forked.tls ?? []);
14511
+ sync.linker.cache = at.forked.modules;
14512
+ }
14513
+ if (at.thread || at.forked) sync.catchUp();
14514
+ sync.linker.bindMainGot();
14515
+ }
14488
14516
  function procTree(call2, pid) {
14489
14517
  return new ProcTree(
14490
14518
  {
@@ -14586,6 +14614,7 @@ async function runWasiProcess(init, port3) {
14586
14614
  }
14587
14615
  const program = await programImports(init.program, host, transport, MAIN_TID);
14588
14616
  const { instance, driver } = await instantiate(host, module, memory, threads, {
14617
+ ...fork ? { forked: fork } : {},
14589
14618
  stats,
14590
14619
  signals,
14591
14620
  foreign: init.program.foreign,