diff --git a/arch/wasm/Kbuild b/arch/wasm/Kbuild index 6ddb6081d1831b..8685c846d9b428 100644 --- a/arch/wasm/Kbuild +++ b/arch/wasm/Kbuild @@ -1 +1 @@ -obj-y += kernel/ mm/ \ No newline at end of file +obj-y += kernel/ mm/ diff --git a/arch/wasm/Kconfig b/arch/wasm/Kconfig index 32a941ad9a88f1..9c39bc5db0daae 100644 --- a/arch/wasm/Kconfig +++ b/arch/wasm/Kconfig @@ -1,6 +1,6 @@ config WASM def_bool y - depends on !BINFMT_ELF && !MMU && !MODULES && !COREDUMP && !SECCOMP && !UPROBES && !COMPAT + depends on !SMP && !BINFMT_ELF && !MMU && !MODULES && !COREDUMP && !SECCOMP && !UPROBES && !COMPAT select ARCH_HAS_BINFMT_WASM select ARCH_HAS_SYSCALL_WRAPPER select ARCH_NO_SWAP @@ -8,27 +8,18 @@ config WASM select ARCH_USE_QUEUED_SPINLOCKS select BUG select FLATMEM - select FORCE_NR_CPUS + select FORCE_NR_CPUS if SMP select GENERIC_ATOMIC64 select GENERIC_CSUM select GENERIC_HWEIGHT select OF select OF_EARLY_FLATTREE select PAGE_SIZE_64KB - select SMP + # select SMP select THREAD_INFO_IN_TASK select UACCESS_MEMCPY if !MMU select USE_PER_CPU_TLS -config ARCH_HAS_BINFMT_WASM - bool - -menu "Executable file formats" - config BINFMT_WASM - bool "Kernel support for WASM binaries" - depends on ARCH_HAS_BINFMT_WASM -endmenu - config CMDLINE string "Kernel command string to append" default "" @@ -40,12 +31,12 @@ config EARLY_PRINTK def_bool y config SMP - def_bool y + def_bool n config NR_CPUS int default 1 if !SMP - default 8 if SMP + default 16 if SMP config HZ int diff --git a/arch/wasm/Makefile b/arch/wasm/Makefile index 93a13d8f956bb7..e3d666a718f919 100644 --- a/arch/wasm/Makefile +++ b/arch/wasm/Makefile @@ -3,7 +3,7 @@ LD = wasm-ld WASM_FEATURES = -matomics -mbulk-memory -mexception-handling -mextended-const -mmultivalue -mmutable-globals -mnontrapping-fptoint -mreference-types -mrelaxed-simd -msign-ext -msimd128 cflags-y += -Wno-incompatible-library-redeclaration '-D__builtin_return_address=wasm_return_address' $(WASM_FEATURES) -ldflags-y += --import-memory --shared-memory --max-memory=4294967296 --no-gc-sections +ldflags-y += --import-memory --max-memory=4294967296 --shared-memory KBUILD_CFLAGS += $(cflags-y) KBUILD_AFLAGS += $(aflags-y) diff --git a/arch/wasm/include/asm/current.h b/arch/wasm/include/asm/current.h index 30b7283e982e0d..f95d5b3f0c44fd 100644 --- a/arch/wasm/include/asm/current.h +++ b/arch/wasm/include/asm/current.h @@ -1,8 +1,10 @@ #ifndef _WASM_CURRENT_H #define _WASM_CURRENT_H +#include + struct task_struct; -extern _Thread_local struct task_struct * current; +DECLARE_PER_CPU(struct task_struct*, current); #endif diff --git a/arch/wasm/include/asm/processor.h b/arch/wasm/include/asm/processor.h index 5ff80c348b300b..bfb665f1861685 100644 --- a/arch/wasm/include/asm/processor.h +++ b/arch/wasm/include/asm/processor.h @@ -6,10 +6,7 @@ struct task_struct; -static inline void cpu_relax(void) -{ - wasm_relax(); -} +void cpu_relax(void); #define current_text_addr() wasm_return_address(-1) diff --git a/arch/wasm/include/asm/sigcontext.h b/arch/wasm/include/asm/sigcontext.h index c1b36ec5c814e0..f7b758a1b9694c 100644 --- a/arch/wasm/include/asm/sigcontext.h +++ b/arch/wasm/include/asm/sigcontext.h @@ -1,7 +1,11 @@ #ifndef _WASM_SIGCONTEXT_H #define _WASM_SIGCONTEXT_H -struct pt_regs {}; +struct pt_regs { + void* current_stack; + int (*fn)(void*); + void* fn_arg; +}; struct sigcontext { struct pt_regs regs; diff --git a/arch/wasm/include/asm/smp.h b/arch/wasm/include/asm/smp.h index 40a21cc5e0917f..da875d84284c36 100644 --- a/arch/wasm/include/asm/smp.h +++ b/arch/wasm/include/asm/smp.h @@ -1,6 +1,8 @@ #ifndef _WASM_SMP_H #define _WASM_SMP_H +#ifdef CONFIG_SMP + #define raw_smp_processor_id() (current_thread_info()->cpu) struct cpumask; @@ -8,3 +10,5 @@ void arch_send_call_function_ipi_mask(const struct cpumask *mask); void arch_send_call_function_single_ipi(int cpu); #endif + +#endif diff --git a/arch/wasm/include/asm/thread_info.h b/arch/wasm/include/asm/thread_info.h index 0f70ed85e54c9d..8dbe8ac7aa8d26 100644 --- a/arch/wasm/include/asm/thread_info.h +++ b/arch/wasm/include/asm/thread_info.h @@ -12,10 +12,8 @@ struct thread_info { struct task_struct *task; unsigned long flags; int preempt_count; - struct task_struct *from_sched; -#ifdef CONFIG_SMP + // struct task_struct *from_sched; unsigned int cpu; -#endif }; #define INIT_THREAD_INFO(tsk) \ diff --git a/arch/wasm/include/asm/wasm_imports.h b/arch/wasm/include/asm/wasm_imports.h index 10d89d8301d5e4..ef0b9d5a7ade5e 100644 --- a/arch/wasm/include/asm/wasm_imports.h +++ b/arch/wasm/include/asm/wasm_imports.h @@ -7,8 +7,6 @@ #define import(name) __attribute__((import_module("kernel"), import_name(name))) import("breakpoint") void wasm_breakpoint(void); -import("relax") void wasm_relax(void); -import("idle") void wasm_idle(void); import("halt") void wasm_halt(void); import("restart") void wasm_restart(void); @@ -27,8 +25,6 @@ import("get_now_nsec") unsigned long long wasm_get_now_nsec(void); import("get_stacktrace") void wasm_get_stacktrace(char *buf, size_t size); -import("new_worker") void wasm_new_worker(void* arg, char name[16]); - #undef import #endif diff --git a/arch/wasm/kernel/Makefile b/arch/wasm/kernel/Makefile index 278522c692e1c6..737d8c6bcdcdad 100644 --- a/arch/wasm/kernel/Makefile +++ b/arch/wasm/kernel/Makefile @@ -7,6 +7,7 @@ obj-y += \ process.o \ ptrace.o \ setup.o \ - smp.o \ stacktrace.o \ time.o + +obj-$(CONFIG_SMP) += smp.o diff --git a/arch/wasm/kernel/process.c b/arch/wasm/kernel/process.c index f5b5781b94f6ed..14aee6a9f0cae1 100644 --- a/arch/wasm/kernel/process.c +++ b/arch/wasm/kernel/process.c @@ -1,16 +1,9 @@ -#include "linux/thread_info.h" -#include #include #include #include #include #include -void arch_cpu_idle(void) -{ - wasm_idle(); -} - __asm__(".globaltype __stack_pointer, i32\n"); static void *get_stack_pointer(void) @@ -31,75 +24,47 @@ static void __always_inline set_stack_pointer(void *ptr) struct task_struct *__switch_to(struct task_struct *from, struct task_struct *to) { - // struct thread_info *from_info = task_thread_info(from); - struct thread_info *to_info = task_thread_info(to); - - to_info->from_sched = from; - - pr_info("context switch CPU: %i PID: %u -> %u STACK: %p -> %p\n", - smp_processor_id(), from->pid, to->pid, get_stack_pointer(), - to->stack); + struct pt_regs *from_regs = task_pt_regs(from); + struct pt_regs *to_regs = task_pt_regs(to); - set_stack_pointer(to->stack); - current = to; + from_regs->current_stack = get_stack_pointer(); - return from; -} + pr_info("context switch PID: %u STACK: %p\n" + "-> %u %p\n", + from->pid, from_regs->current_stack, to->pid, + to_regs->current_stack); -struct entry_arg { - int cpu; - struct thread_info *thread_info; - int (*fn)(void *); - void *fn_arg; -}; -void show_stack(struct task_struct *task, unsigned long *sp, - const char *loglvl); + set_stack_pointer(to_regs->current_stack); -int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) -{ - struct entry_arg *entry; - - if (!args->fn) panic("can't copy userspace thread"); // yet + current = to; - entry = kmalloc(sizeof(*entry), GFP_KERNEL); - if (!entry) - return -ENOMEM; + schedule_tail(from); - entry->fn = args->fn; - entry->fn_arg = args->fn_arg; - entry->thread_info = task_thread_info(p); + pr_info("regs: %p\n", to_regs); + BUG_ON(!to_regs->fn); - wasm_new_worker(entry, p->comm); + pr_info("about to call %p %p\n", to_regs->fn, to_regs->fn_arg); + to_regs->fn(to_regs->fn_arg); + to_regs->fn = NULL; - return 0; + return from; } -static atomic_t next_cpu_nr = ATOMIC_INIT(1); -void noinline_for_stack task_entry_inner(struct entry_arg *entry) +int copy_thread(struct task_struct *p, const struct kernel_clone_args *args) { - int (*fn)(void *) = entry->fn; - void *fn_arg = entry->fn_arg; - struct thread_info *thread_info = entry->thread_info; - int cpu; - kfree(entry); + struct pt_regs *childregs = task_pt_regs(p); - cpu = atomic_inc_return(&next_cpu_nr); - smp_tls_init(cpu); - current = thread_info->from_sched; - current_thread_info()->cpu = cpu; - pr_info("== THREAD ENTRY! CPU: %i ==", cpu); + memset(childregs, 0, sizeof(struct pt_regs)); - if (thread_info->from_sched) - schedule_tail(thread_info->from_sched); + childregs->current_stack = childregs; - fn(fn_arg); + if (!args->fn) + panic("can't copy userspace thread"); // yet - do_exit(0); -} + pr_info("copying thread %i %p\n", p->pid, childregs); -__attribute__((export_name("task_entry"))) void -task_entry(struct entry_arg *entry) -{ - set_stack_pointer(entry->thread_info->task->stack); - task_entry_inner(entry); + childregs->fn = args->fn; + childregs->fn_arg = args->fn_arg; + + return 0; } diff --git a/arch/wasm/kernel/setup.c b/arch/wasm/kernel/setup.c index 9a5bff7bb84485..9d408db78faafb 100644 --- a/arch/wasm/kernel/setup.c +++ b/arch/wasm/kernel/setup.c @@ -39,7 +39,9 @@ __attribute__((export_name("start"))) void __init _start(void) { static char wasm_dt[1024]; +#ifdef CONFIG_SMP early_tls_init(); +#endif __wasm_call_ctors(); setup_early_printk(NULL); diff --git a/arch/wasm/kernel/smp.c b/arch/wasm/kernel/smp.c index 232c65b8d3f987..21f69559194570 100644 --- a/arch/wasm/kernel/smp.c +++ b/arch/wasm/kernel/smp.c @@ -116,4 +116,4 @@ void handle_ipi(struct pt_regs *regs) mb(); /* Order data access and bit testing. */ } -} \ No newline at end of file +} diff --git a/arch/wasm/kernel/time.c b/arch/wasm/kernel/time.c index 0a74e2b6e6631c..cc0b8c8252abed 100644 --- a/arch/wasm/kernel/time.c +++ b/arch/wasm/kernel/time.c @@ -14,10 +14,14 @@ void calibrate_delay(void) void __delay(unsigned long cycles) { - cycles_t start = wasm_get_now_nsec(); + static int zero = 0; + int ret = __builtin_wasm_memory_atomic_wait32(&zero, 0, cycles); + BUG_ON(ret != 2); // 2 means timeout +} - while ((wasm_get_now_nsec() - start) < cycles) - cpu_relax(); +void cpu_relax(void) +{ + __delay(100); } void __udelay(unsigned long usecs) @@ -33,6 +37,10 @@ void __const_udelay(unsigned long xloops) __delay(xloops / 0x10c7ul); /* 2**32 / 1000000 (rounded up) */ } +unsigned long long sched_clock(void) { + return wasm_get_now_nsec(); +} + static u64 clock_read(struct clocksource *cs) { return wasm_get_now_nsec(); @@ -50,4 +58,4 @@ void __init time_init(void) { if (clocksource_register_khz(&clocksource, 1000000)) panic("unable to register clocksource\n"); -} \ No newline at end of file +} diff --git a/arch/wasm/mm/Makefile b/arch/wasm/mm/Makefile index 17edfd3e684fdc..5e924adc876372 100644 --- a/arch/wasm/mm/Makefile +++ b/arch/wasm/mm/Makefile @@ -1 +1,2 @@ -obj-y := init.o page.o tls.o +obj-y := init.o page.o +obj-$(CONFIG_SMP) := tls.o diff --git a/arch/wasm/mm/tls.c b/arch/wasm/mm/tls.c index 1df9521293ec38..10daf9d992d8d2 100644 --- a/arch/wasm/mm/tls.c +++ b/arch/wasm/mm/tls.c @@ -48,4 +48,4 @@ void smp_tls_init(int cpu) { BUG_ON(__per_cpu_offset[cpu] == (void *)-1); __wasm_init_tls((void *)__per_cpu_offset[cpu]); -} \ No newline at end of file +} diff --git a/flake.nix b/flake.nix index 1d167171eb8bfa..041d98ca56e871 100644 --- a/flake.nix +++ b/flake.nix @@ -6,8 +6,10 @@ packages = nixpkgs.lib.genAttrs [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ] (system: - let pkgs = nixpkgs.legacyPackages.${system}; in { - default = pkgs.clangStdenv.mkDerivation { + let pkgs = nixpkgs.legacyPackages.${system}; + llvm = pkgs.llvmPackages_17; + in { + default = llvm.stdenv.mkDerivation { pname = "linux"; version = "6.1.69-wasm"; src = ./.; @@ -35,8 +37,8 @@ pkg-config ncurses - lld - libllvm + llvm.lld + llvm.libllvm wabt esbuild ]; diff --git a/fs/Kconfig.binfmt b/fs/Kconfig.binfmt index 93539aac0e5b2e..6bbf87aaaba15a 100644 --- a/fs/Kconfig.binfmt +++ b/fs/Kconfig.binfmt @@ -168,6 +168,13 @@ config BINFMT_MISC you have use for it; the module is called binfmt_misc. If you don't know what to answer at this point, say Y. +config ARCH_HAS_BINFMT_WASM + bool + +config BINFMT_WASM + bool "Kernel support for WASM binaries" + depends on ARCH_HAS_BINFMT_WASM + config COREDUMP bool "Enable core dump support" if EXPERT default y diff --git a/include/linux/percpu-defs.h b/include/linux/percpu-defs.h index f236e9e0da6b8d..406e12d6a7a266 100644 --- a/include/linux/percpu-defs.h +++ b/include/linux/percpu-defs.h @@ -220,7 +220,7 @@ do { \ (void)__vpp_verify; \ } while (0) -#ifdef CONFIG_SMP +#if defined(CONFIG_SMP) || defined(CONFIG_USE_PER_CPU_TLS) /* * Add an offset to a pointer but keep the pointer as-is. Use RELOC_HIDE() diff --git a/kernel/sched/core.c b/kernel/sched/core.c index 2e4216758dfca5..fa5f1701a780bf 100644 --- a/kernel/sched/core.c +++ b/kernel/sched/core.c @@ -71,10 +71,6 @@ # endif #endif -#ifdef CONFIG_WASM -# include -#endif - #include #include @@ -2061,7 +2057,6 @@ static inline void enqueue_task(struct rq *rq, struct task_struct *p, int flags) } uclamp_rq_inc(rq, p); - pr_info("%s:%s %s %i %pS", __FILE__, __FUNCTION__, p->comm, p->sched_class->rank, p->sched_class->enqueue_task); p->sched_class->enqueue_task(rq, p, flags); if (sched_core_enabled(rq)) diff --git a/mm/percpu-tls.c b/mm/percpu-tls.c index fade6da230b6c9..1349d435752b58 100644 --- a/mm/percpu-tls.c +++ b/mm/percpu-tls.c @@ -14,7 +14,6 @@ EXPORT_SYMBOL(__per_cpu_offset); bool __percpu_is_static(void *ptr) { - // uintptr_t p = (uintptr_t)ptr; int i; for_each_possible_cpu(i) { void *base = __per_cpu_offset[i]; @@ -96,4 +95,4 @@ void free_percpu(void __percpu *ptr) { panic("free_percpu(%p) is unimplemented", ptr); } -EXPORT_SYMBOL_GPL(free_percpu); \ No newline at end of file +EXPORT_SYMBOL_GPL(free_percpu); diff --git a/scripts/Makefile.vmlinux_o b/scripts/Makefile.vmlinux_o index 9d4abee8209a29..0c34fed205bd69 100644 --- a/scripts/Makefile.vmlinux_o +++ b/scripts/Makefile.vmlinux_o @@ -9,24 +9,6 @@ include $(srctree)/scripts/Kbuild.include # for objtool include $(srctree)/scripts/Makefile.lib -# Generate a linker script to ensure correct ordering of initcalls for Clang LTO -# --------------------------------------------------------------------------- - -quiet_cmd_gen_initcalls_lds = GEN $@ - cmd_gen_initcalls_lds = \ - $(PYTHON3) $(srctree)/scripts/jobserver-exec \ - $(PERL) $(real-prereqs) > $@ - -.tmp_initcalls.lds: $(srctree)/scripts/generate_initcall_order.pl \ - vmlinux.a $(KBUILD_VMLINUX_LIBS) FORCE - $(call if_changed,gen_initcalls_lds) - -targets := .tmp_initcalls.lds - -ifdef CONFIG_LTO_CLANG -initcalls-lds := .tmp_initcalls.lds -endif - # objtool for vmlinux.o # --------------------------------------------------------------------------- # @@ -47,7 +29,7 @@ objtool-args = $(vmlinux-objtool-args-y) --link quiet_cmd_ld_vmlinux.o = LD $@ ifdef CONFIG_LD_IS_WASMLD cmd_ld_vmlinux.o = \ - $(LD) ${KBUILD_LDFLAGS} -o $@ \ + $(LD) ${KBUILD_LDFLAGS} --no-gc-sections -o $@ \ $(addprefix -T , $(initcalls-lds)) \ --whole-archive vmlinux.a --no-whole-archive \ $(KBUILD_VMLINUX_LIBS) \ diff --git a/tools/wasm/Makefile b/tools/wasm/Makefile index 7608e47b203fc5..2c95d6d42246b8 100644 --- a/tools/wasm/Makefile +++ b/tools/wasm/Makefile @@ -1,4 +1,4 @@ dist/index.js: src/*.ts - esbuild --bundle src/index.ts src/worker.ts --outdir=dist --format=esm --splitting --define:self.BUNDLED=true --sourcemap + esbuild --bundle src/index.ts --outdir=dist --format=esm --splitting --sourcemap --minify all: dist/index.js diff --git a/tools/wasm/src/devicetree.ts b/tools/wasm/src/devicetree.ts index 088edc764b8c9a..646c851af2846d 100644 --- a/tools/wasm/src/devicetree.ts +++ b/tools/wasm/src/devicetree.ts @@ -1,4 +1,4 @@ -import { unreachable } from "./util.ts"; +import { assert, unreachable } from "./util.ts"; const FDT_MAGIC = 0xd00dfeed; const FDT_BEGIN_NODE = 0x00000001; @@ -84,9 +84,10 @@ function inner( pad(); u32(FDT_BEGIN_NODE); - if (new TextEncoder().encode(name).byteLength > NODE_NAME_MAX_LEN) { - throw new Error("name too long"); - } + assert( + new TextEncoder().encode(name).byteLength <= NODE_NAME_MAX_LEN, + `property name too long: ${name}`, + ); stringz(name); pad(); @@ -104,9 +105,10 @@ function inner( u32(FDT_PROP); const len = u32(); - if (new TextEncoder().encode(name).byteLength > PROPERTY_NAME_MAX_LEN) { - throw new Error("name too long"); - } + assert( + new TextEncoder().encode(name).byteLength <= PROPERTY_NAME_MAX_LEN, + `property name too long: ${name}`, + ); (strings[name] ??= []).push(u32()); let value: ArrayBuffer; diff --git a/tools/wasm/src/index.ts b/tools/wasm/src/index.ts index 141006e73278db..c541d192ba2474 100644 --- a/tools/wasm/src/index.ts +++ b/tools/wasm/src/index.ts @@ -45,9 +45,12 @@ export function start({ function newWorker(name: string) { const worker = new Worker( - (self as { BUNDLED?: true }).BUNDLED - ? new URL("./worker.js", import.meta.url) - : import.meta.resolve("./worker.ts"), + new URL( + (() => { + import("./worker.ts"); + }).toString().match(/import\("(.*)"\)/)![1], + import.meta.url, + ), { type: "module", name }, ); function postMessage( @@ -75,23 +78,6 @@ export function start({ case "error": emit("error", { error: data.err, workerName: name }); break; - case "new-worker": - bootConsoleWriter.write( - new TextEncoder().encode( - `Spawning ${data.name}(${ - data.arg.toString(16).padStart(8, "0") - })\n`, - ), - ); - newWorker(data.name).postMessage( - { - type: "start", - memory, - vmlinux, - arg: data.arg, - }, - ); - break; default: unreachable( data, diff --git a/tools/wasm/src/worker.ts b/tools/wasm/src/worker.ts index ee166d6c7f273f..133667a71b07e8 100644 --- a/tools/wasm/src/worker.ts +++ b/tools/wasm/src/worker.ts @@ -3,11 +3,6 @@ import { assert, unreachable } from "./util.ts"; -const SLEEP_BUFFER = new Int32Array(new SharedArrayBuffer(4)); -function sleepSync(ms: number) { - Atomics.wait(SLEEP_BUFFER, 0, 0, ms); -} - export type ToWorkerMessage = { type: "boot"; vmlinux: WebAssembly.Module; @@ -24,8 +19,7 @@ export type FromWorkerMessage = | { type: "boot-console-write"; message: Uint8Array } | { type: "boot-console-close" } | { type: "restart" } - | { type: "error"; err: Error } - | { type: "new-worker"; arg: number; name: string }; + | { type: "error"; err: Error }; function postMessage( message: FromWorkerMessage, @@ -41,13 +35,12 @@ interface Instance { }; } -const IDLE = Symbol("idle"); -const BACKTRACE_ADDRESS_RE = /wasm:.*:((?:0x)?[0-9a-f]+)\)$/gm; -function iteratorNth(iter: Iterator, n: number) { - let value: T | undefined; - for (let i = 0; i < n; i++) value = iter.next().value; - return value; -} +// const BACKTRACE_ADDRESS_RE = /wasm:.*:((?:0x)?[0-9a-f]+)\)$/gm; +// function iteratorNth(iter: Iterator, n: number) { +// let value: T | undefined; +// for (let i = 0; i < n; i++) value = iter.next().value; +// return value; +// } async function boot( module: WebAssembly.Module, @@ -67,12 +60,6 @@ async function boot( // deno-lint-ignore no-debugger debugger; }, - relax() { - sleepSync(10); - }, - idle() { - throw IDLE; - }, halt() { self.close(); }, @@ -88,19 +75,23 @@ async function boot( postMessage({ type: "boot-console-close" }, []); }, - return_address(n: number) { - const matches = new Error().stack?.matchAll(BACKTRACE_ADDRESS_RE); - if (!matches) return -1; - const match = iteratorNth(matches, n + 1); - return parseInt(match?.[1] ?? "-1"); + return_address() { + return 0; }, + // return_address(n: number) { + // const matches = new Error().stack?.matchAll(BACKTRACE_ADDRESS_RE); + // if (!matches) return -1; + // const match = iteratorNth(matches, n + 1); + // return parseInt(match?.[1] ?? "-1"); + // }, set_irq_enabled(flags: number) { irqflags = flags; }, get_irq_enabled() { return irqflags; - }, + }, // deno-lint-ignore no-debugger + get_dt(buf: number, size: number) { assert(options.type === "boot", "get_dt called on non-boot thread"); @@ -134,14 +125,6 @@ async function boot( } memory.set(trace.slice(0, size), buf); }, - - new_worker(arg: number, name: number) { - postMessage({ - type: "new-worker", - arg, - name: new TextDecoder().decode(memory.slice(name, name + 16)), - }); - }, }, })) as Instance; @@ -156,14 +139,14 @@ async function boot( default: unreachable(options); } + console.log( + "fin", + options.type, + options.type === "secondary" ? options.type : "", + ); } catch (err) { - if (err === IDLE) { - postMessage({ - type: "boot-console-write", - message: new TextEncoder().encode(`Idle ${name}\n`), - }); - return; - } + // deno-lint-ignore no-debugger + debugger; postMessage({ type: "error", err }); } }