@ai-ecoverse/slicc-kernel 1.7.2 → 1.8.1
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.
- package/README.md +1 -1
- package/dist/kernel-worker.js +111 -2
- package/dist/kernel-worker.js.map +2 -2
- package/dist/node-process-worker.js +62 -20
- package/dist/node-process-worker.js.map +4 -4
- package/dist/node.js +111 -2
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +62 -20
- package/dist/process-worker.js.map +4 -4
- package/package.json +2 -2
|
@@ -4431,6 +4431,20 @@ var init_wasi_imports = __esm({
|
|
|
4431
4431
|
}
|
|
4432
4432
|
});
|
|
4433
4433
|
|
|
4434
|
+
// src/process/wasi/wasi-module.ts
|
|
4435
|
+
var RESERVED_NAMESPACES;
|
|
4436
|
+
var init_wasi_module = __esm({
|
|
4437
|
+
"src/process/wasi/wasi-module.ts"() {
|
|
4438
|
+
"use strict";
|
|
4439
|
+
RESERVED_NAMESPACES = /* @__PURE__ */ new Set([
|
|
4440
|
+
"wasi_snapshot_preview1",
|
|
4441
|
+
"wasix_32v1",
|
|
4442
|
+
"wasi",
|
|
4443
|
+
"env"
|
|
4444
|
+
]);
|
|
4445
|
+
}
|
|
4446
|
+
});
|
|
4447
|
+
|
|
4434
4448
|
// src/process/wasi/wasi-signals.ts
|
|
4435
4449
|
var DELIVERED, DELIVERED_MASK, WasiSignals;
|
|
4436
4450
|
var init_wasi_signals = __esm({
|
|
@@ -5889,29 +5903,50 @@ __export(wasi_runtime_exports, {
|
|
|
5889
5903
|
trapMessage: () => trapMessage,
|
|
5890
5904
|
unsupportedImport: () => unsupportedImport
|
|
5891
5905
|
});
|
|
5892
|
-
function
|
|
5906
|
+
function enosys(module, name, foreign) {
|
|
5907
|
+
const type = foreign?.[module]?.[name];
|
|
5908
|
+
if (type === "other") throw new Error(noErrno(`${module}.${name}`));
|
|
5909
|
+
if (type === "none") return () => void 0;
|
|
5910
|
+
if (type === "i64") return () => 52n;
|
|
5911
|
+
return () => 52;
|
|
5912
|
+
}
|
|
5913
|
+
function firstOther(foreign) {
|
|
5914
|
+
for (const [module, fields] of Object.entries(foreign)) {
|
|
5915
|
+
const name = Object.keys(fields).find((field) => fields[field] === "other");
|
|
5916
|
+
if (name !== void 0) return `${module}.${name}`;
|
|
5917
|
+
}
|
|
5918
|
+
return void 0;
|
|
5919
|
+
}
|
|
5920
|
+
function accepted(imp, scope2) {
|
|
5921
|
+
const { module, name, kind } = imp;
|
|
5922
|
+
if (module === PREVIEW1 || module === WASIX) return true;
|
|
5923
|
+
if (!RESERVED.has(module) && (scope2.extended || scope2.wasi && kind === "function")) return true;
|
|
5924
|
+
if (scope2.pie && (module === "GOT.mem" || module === "GOT.func")) return true;
|
|
5925
|
+
if (scope2.pie && module === "env" && kind !== "memory") return true;
|
|
5926
|
+
if (kind === "memory" && scope2.memory?.module === module && scope2.memory.name === name)
|
|
5927
|
+
return true;
|
|
5928
|
+
return module === "wasi" && name === "thread-spawn" && (scope2.wasix || !!scope2.memory?.shared);
|
|
5929
|
+
}
|
|
5930
|
+
function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
5893
5931
|
const imports = WebAssembly.Module.imports(module);
|
|
5894
5932
|
const wasix = imports.some((i) => i.module === WASIX);
|
|
5895
|
-
const
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
if (
|
|
5900
|
-
|
|
5901
|
-
if (imp.kind === "memory" && memory?.module === imp.module && memory.name === imp.name)
|
|
5902
|
-
continue;
|
|
5903
|
-
if (imp.module === "wasi" && imp.name === "thread-spawn" && (wasix || memory?.shared)) continue;
|
|
5904
|
-
if (imp.kind === "memory" || imp.module === "wasi") {
|
|
5905
|
-
return `imports ${imp.module}.${imp.name}: no WASI program this host runs`;
|
|
5933
|
+
const wasi = wasix || imports.some((i) => i.module === PREVIEW1);
|
|
5934
|
+
const scope2 = { extended, wasi, wasix, pie: dylinkInfo(module) !== void 0, memory };
|
|
5935
|
+
const refused = imports.find((imp) => !accepted(imp, scope2));
|
|
5936
|
+
if (refused) {
|
|
5937
|
+
if (refused.kind === "memory" || refused.module === "wasi") {
|
|
5938
|
+
return `imports ${refused.module}.${refused.name}: no WASI program this host runs`;
|
|
5906
5939
|
}
|
|
5907
|
-
return `imports ${
|
|
5940
|
+
return `imports ${refused.module}.${refused.name}: no WASI preview1 program (an Emscripten one runs with its glue)`;
|
|
5908
5941
|
}
|
|
5942
|
+
const unanswerable = extended ? void 0 : firstOther(foreign);
|
|
5943
|
+
if (unanswerable) return noErrno(unanswerable);
|
|
5909
5944
|
if (!WebAssembly.Module.exports(module).some((e) => e.name === "_start")) {
|
|
5910
5945
|
return "no WASI command (it exports no _start)";
|
|
5911
5946
|
}
|
|
5912
5947
|
return void 0;
|
|
5913
5948
|
}
|
|
5914
|
-
function linkImports(module, preview1, wasix, memory, threads, program = {}) {
|
|
5949
|
+
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign) {
|
|
5915
5950
|
for (const ns of Object.keys(program)) {
|
|
5916
5951
|
if (RESERVED.has(ns)) throw new Error(`the imports module may not define ${ns}`);
|
|
5917
5952
|
}
|
|
@@ -5925,7 +5960,8 @@ function linkImports(module, preview1, wasix, memory, threads, program = {}) {
|
|
|
5925
5960
|
const ns = imports[imp.module] ??= {};
|
|
5926
5961
|
if (imp.name in ns) continue;
|
|
5927
5962
|
if (imp.kind === "memory" && memory) ns[imp.name] = memory;
|
|
5928
|
-
else if (imp.
|
|
5963
|
+
else if (imp.module === "wasi" && imp.name === "thread-spawn") ns[imp.name] = () => -1;
|
|
5964
|
+
else if (imp.kind === "function") ns[imp.name] = enosys(imp.module, imp.name, foreign);
|
|
5929
5965
|
}
|
|
5930
5966
|
return imports;
|
|
5931
5967
|
}
|
|
@@ -5997,7 +6033,8 @@ async function instantiate(host, module, memory, threads, {
|
|
|
5997
6033
|
thread = false,
|
|
5998
6034
|
stats,
|
|
5999
6035
|
signals,
|
|
6000
|
-
program
|
|
6036
|
+
program,
|
|
6037
|
+
foreign
|
|
6001
6038
|
} = {}) {
|
|
6002
6039
|
const driver = new AsyncifyDriver(host.mem);
|
|
6003
6040
|
const wasixHost = WebAssembly.Module.imports(module).some((i) => i.module === WASIX) ? new WasixHost(host, driver, module) : void 0;
|
|
@@ -6034,7 +6071,7 @@ async function instantiate(host, module, memory, threads, {
|
|
|
6034
6071
|
() => memory ?? instance?.exports.memory,
|
|
6035
6072
|
() => instance
|
|
6036
6073
|
);
|
|
6037
|
-
const hostImports = linkImports(module, preview1, wasix, memory, threads, extra);
|
|
6074
|
+
const hostImports = linkImports(module, preview1, wasix, memory, threads, extra, foreign);
|
|
6038
6075
|
const imports = sync ? merge(hostImports, sync.linker.mainImports(module)) : hostImports;
|
|
6039
6076
|
instance = await WebAssembly.instantiate(module, imports);
|
|
6040
6077
|
stats?.phase("instantiate");
|
|
@@ -6080,7 +6117,8 @@ async function runWasiProcess(init, port2) {
|
|
|
6080
6117
|
const refused = unsupportedImport(
|
|
6081
6118
|
module,
|
|
6082
6119
|
init.program.memory,
|
|
6083
|
-
init.program.imports !== void 0
|
|
6120
|
+
init.program.imports !== void 0,
|
|
6121
|
+
init.program.foreign
|
|
6084
6122
|
);
|
|
6085
6123
|
if (refused) {
|
|
6086
6124
|
say(refused);
|
|
@@ -6108,6 +6146,7 @@ async function runWasiProcess(init, port2) {
|
|
|
6108
6146
|
const { instance, driver } = await instantiate(host, module, memory, threads, {
|
|
6109
6147
|
stats,
|
|
6110
6148
|
signals,
|
|
6149
|
+
foreign: init.program.foreign,
|
|
6111
6150
|
...program ? { program } : {}
|
|
6112
6151
|
});
|
|
6113
6152
|
restoreExportedMemory(instance, memory, init);
|
|
@@ -6178,6 +6217,7 @@ async function runWasiThread(init, port2) {
|
|
|
6178
6217
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
6179
6218
|
const { instance } = await instantiate(host, init.program.module, thread.memory, threads, {
|
|
6180
6219
|
thread: true,
|
|
6220
|
+
foreign: init.program.foreign,
|
|
6181
6221
|
...program ? { program } : {}
|
|
6182
6222
|
});
|
|
6183
6223
|
const start = instance.exports.wasi_thread_start;
|
|
@@ -6204,7 +6244,7 @@ async function runWasiThread(init, port2) {
|
|
|
6204
6244
|
throw e;
|
|
6205
6245
|
}
|
|
6206
6246
|
}
|
|
6207
|
-
var TRAPPED, PREVIEW1, WASIX, RESERVED, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
6247
|
+
var TRAPPED, PREVIEW1, WASIX, RESERVED, noErrno, FALLBACK_MAXIMUM_PAGES, LinkSync, DL_GEN, BACKTRACE_FRAMES;
|
|
6208
6248
|
var init_wasi_runtime = __esm({
|
|
6209
6249
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
6210
6250
|
"use strict";
|
|
@@ -6218,6 +6258,7 @@ var init_wasi_runtime = __esm({
|
|
|
6218
6258
|
init_wasi_files();
|
|
6219
6259
|
init_wasi_host();
|
|
6220
6260
|
init_wasi_imports();
|
|
6261
|
+
init_wasi_module();
|
|
6221
6262
|
init_wasi_signals();
|
|
6222
6263
|
init_wasi_stats();
|
|
6223
6264
|
init_wasi_threads();
|
|
@@ -6228,7 +6269,8 @@ var init_wasi_runtime = __esm({
|
|
|
6228
6269
|
TRAPPED = 134;
|
|
6229
6270
|
PREVIEW1 = "wasi_snapshot_preview1";
|
|
6230
6271
|
WASIX = "wasix_32v1";
|
|
6231
|
-
RESERVED =
|
|
6272
|
+
RESERVED = RESERVED_NAMESPACES;
|
|
6273
|
+
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
6232
6274
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
6233
6275
|
LinkSync = class {
|
|
6234
6276
|
count = 0;
|