@ai-ecoverse/slicc-kernel 1.8.0 → 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 +45 -10
- package/dist/node-process-worker.js.map +3 -3
- package/dist/node.js +111 -2
- package/dist/node.js.map +2 -2
- package/dist/process-worker.js +45 -10
- package/dist/process-worker.js.map +3 -3
- package/package.json +1 -1
|
@@ -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,6 +5903,20 @@ __export(wasi_runtime_exports, {
|
|
|
5889
5903
|
trapMessage: () => trapMessage,
|
|
5890
5904
|
unsupportedImport: () => unsupportedImport
|
|
5891
5905
|
});
|
|
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
|
+
}
|
|
5892
5920
|
function accepted(imp, scope2) {
|
|
5893
5921
|
const { module, name, kind } = imp;
|
|
5894
5922
|
if (module === PREVIEW1 || module === WASIX) return true;
|
|
@@ -5899,7 +5927,7 @@ function accepted(imp, scope2) {
|
|
|
5899
5927
|
return true;
|
|
5900
5928
|
return module === "wasi" && name === "thread-spawn" && (scope2.wasix || !!scope2.memory?.shared);
|
|
5901
5929
|
}
|
|
5902
|
-
function unsupportedImport(module, memory, extended = false) {
|
|
5930
|
+
function unsupportedImport(module, memory, extended = false, foreign = {}) {
|
|
5903
5931
|
const imports = WebAssembly.Module.imports(module);
|
|
5904
5932
|
const wasix = imports.some((i) => i.module === WASIX);
|
|
5905
5933
|
const wasi = wasix || imports.some((i) => i.module === PREVIEW1);
|
|
@@ -5911,12 +5939,14 @@ function unsupportedImport(module, memory, extended = false) {
|
|
|
5911
5939
|
}
|
|
5912
5940
|
return `imports ${refused.module}.${refused.name}: no WASI preview1 program (an Emscripten one runs with its glue)`;
|
|
5913
5941
|
}
|
|
5942
|
+
const unanswerable = extended ? void 0 : firstOther(foreign);
|
|
5943
|
+
if (unanswerable) return noErrno(unanswerable);
|
|
5914
5944
|
if (!WebAssembly.Module.exports(module).some((e) => e.name === "_start")) {
|
|
5915
5945
|
return "no WASI command (it exports no _start)";
|
|
5916
5946
|
}
|
|
5917
5947
|
return void 0;
|
|
5918
5948
|
}
|
|
5919
|
-
function linkImports(module, preview1, wasix, memory, threads, program = {}) {
|
|
5949
|
+
function linkImports(module, preview1, wasix, memory, threads, program = {}, foreign) {
|
|
5920
5950
|
for (const ns of Object.keys(program)) {
|
|
5921
5951
|
if (RESERVED.has(ns)) throw new Error(`the imports module may not define ${ns}`);
|
|
5922
5952
|
}
|
|
@@ -5930,9 +5960,8 @@ function linkImports(module, preview1, wasix, memory, threads, program = {}) {
|
|
|
5930
5960
|
const ns = imports[imp.module] ??= {};
|
|
5931
5961
|
if (imp.name in ns) continue;
|
|
5932
5962
|
if (imp.kind === "memory" && memory) ns[imp.name] = memory;
|
|
5933
|
-
else if (imp.
|
|
5934
|
-
|
|
5935
|
-
}
|
|
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);
|
|
5936
5965
|
}
|
|
5937
5966
|
return imports;
|
|
5938
5967
|
}
|
|
@@ -6004,7 +6033,8 @@ async function instantiate(host, module, memory, threads, {
|
|
|
6004
6033
|
thread = false,
|
|
6005
6034
|
stats,
|
|
6006
6035
|
signals,
|
|
6007
|
-
program
|
|
6036
|
+
program,
|
|
6037
|
+
foreign
|
|
6008
6038
|
} = {}) {
|
|
6009
6039
|
const driver = new AsyncifyDriver(host.mem);
|
|
6010
6040
|
const wasixHost = WebAssembly.Module.imports(module).some((i) => i.module === WASIX) ? new WasixHost(host, driver, module) : void 0;
|
|
@@ -6041,7 +6071,7 @@ async function instantiate(host, module, memory, threads, {
|
|
|
6041
6071
|
() => memory ?? instance?.exports.memory,
|
|
6042
6072
|
() => instance
|
|
6043
6073
|
);
|
|
6044
|
-
const hostImports = linkImports(module, preview1, wasix, memory, threads, extra);
|
|
6074
|
+
const hostImports = linkImports(module, preview1, wasix, memory, threads, extra, foreign);
|
|
6045
6075
|
const imports = sync ? merge(hostImports, sync.linker.mainImports(module)) : hostImports;
|
|
6046
6076
|
instance = await WebAssembly.instantiate(module, imports);
|
|
6047
6077
|
stats?.phase("instantiate");
|
|
@@ -6087,7 +6117,8 @@ async function runWasiProcess(init, port2) {
|
|
|
6087
6117
|
const refused = unsupportedImport(
|
|
6088
6118
|
module,
|
|
6089
6119
|
init.program.memory,
|
|
6090
|
-
init.program.imports !== void 0
|
|
6120
|
+
init.program.imports !== void 0,
|
|
6121
|
+
init.program.foreign
|
|
6091
6122
|
);
|
|
6092
6123
|
if (refused) {
|
|
6093
6124
|
say(refused);
|
|
@@ -6115,6 +6146,7 @@ async function runWasiProcess(init, port2) {
|
|
|
6115
6146
|
const { instance, driver } = await instantiate(host, module, memory, threads, {
|
|
6116
6147
|
stats,
|
|
6117
6148
|
signals,
|
|
6149
|
+
foreign: init.program.foreign,
|
|
6118
6150
|
...program ? { program } : {}
|
|
6119
6151
|
});
|
|
6120
6152
|
restoreExportedMemory(instance, memory, init);
|
|
@@ -6185,6 +6217,7 @@ async function runWasiThread(init, port2) {
|
|
|
6185
6217
|
const program = await programImports(init.program, host, transport, thread.tid);
|
|
6186
6218
|
const { instance } = await instantiate(host, init.program.module, thread.memory, threads, {
|
|
6187
6219
|
thread: true,
|
|
6220
|
+
foreign: init.program.foreign,
|
|
6188
6221
|
...program ? { program } : {}
|
|
6189
6222
|
});
|
|
6190
6223
|
const start = instance.exports.wasi_thread_start;
|
|
@@ -6211,7 +6244,7 @@ async function runWasiThread(init, port2) {
|
|
|
6211
6244
|
throw e;
|
|
6212
6245
|
}
|
|
6213
6246
|
}
|
|
6214
|
-
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;
|
|
6215
6248
|
var init_wasi_runtime = __esm({
|
|
6216
6249
|
"src/process/wasi/wasi-runtime.ts"() {
|
|
6217
6250
|
"use strict";
|
|
@@ -6225,6 +6258,7 @@ var init_wasi_runtime = __esm({
|
|
|
6225
6258
|
init_wasi_files();
|
|
6226
6259
|
init_wasi_host();
|
|
6227
6260
|
init_wasi_imports();
|
|
6261
|
+
init_wasi_module();
|
|
6228
6262
|
init_wasi_signals();
|
|
6229
6263
|
init_wasi_stats();
|
|
6230
6264
|
init_wasi_threads();
|
|
@@ -6235,7 +6269,8 @@ var init_wasi_runtime = __esm({
|
|
|
6235
6269
|
TRAPPED = 134;
|
|
6236
6270
|
PREVIEW1 = "wasi_snapshot_preview1";
|
|
6237
6271
|
WASIX = "wasix_32v1";
|
|
6238
|
-
RESERVED =
|
|
6272
|
+
RESERVED = RESERVED_NAMESPACES;
|
|
6273
|
+
noErrno = (key) => `imports ${key}: its result cannot carry ENOSYS, and this host does not provide it`;
|
|
6239
6274
|
FALLBACK_MAXIMUM_PAGES = 32768;
|
|
6240
6275
|
LinkSync = class {
|
|
6241
6276
|
count = 0;
|