Assemble kernel on client
This commit is contained in:
16
boot.js
16
boot.js
@@ -1,7 +1,19 @@
|
||||
import { Assembler } from './asm.js';
|
||||
|
||||
const assemble = (async () => {
|
||||
const asm = new Assembler();
|
||||
const resp = await fetch('wipforth.ws');
|
||||
for await (const chunk of resp.body) {
|
||||
asm.push(chunk);
|
||||
}
|
||||
return asm.wasm();
|
||||
})();
|
||||
|
||||
self.onmessage = async (e) => {
|
||||
const exports = { emu: { mem: e.data } };
|
||||
const mod = await WebAssembly.instantiateStreaming(
|
||||
fetch('wipforth.wasm'), exports)
|
||||
const wasm = await assemble;
|
||||
const mod = await WebAssembly.instantiate(wasm, exports);
|
||||
await self.postMessage('booting');
|
||||
mod.instance.exports.reset();
|
||||
console.log('System halt');
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user