mirror of
https://github.com/remko/waforth
synced 2024-12-27 09:59:29 +01:00
Grow table from within WebAssembly
This commit is contained in:
parent
30f1200472
commit
532d9e1f34
2 changed files with 6 additions and 6 deletions
|
@ -2188,9 +2188,12 @@
|
||||||
(global.set $cp (i32.add (global.get $cp) (local.get $nameLength)))))
|
(global.set $cp (i32.add (global.get $cp) (local.get $nameLength)))))
|
||||||
|
|
||||||
;; Load the code
|
;; Load the code
|
||||||
(call $shell_load (i32.const 0x1000 (; = MODULE_HEADER_BASE ;))
|
(if (i32.ge_u (global.get $nextTableIndex) (table.size 0))
|
||||||
(i32.sub (global.get $cp) (i32.const 0x1000 (; = MODULE_HEADER_BASE ;)))
|
(then (drop (table.grow 0 (ref.func $!) (table.size 0))))) ;; Double size
|
||||||
(global.get $nextTableIndex))
|
(call $shell_load
|
||||||
|
(i32.const 0x1000 (; = MODULE_HEADER_BASE ;))
|
||||||
|
(i32.sub (global.get $cp) (i32.const 0x1000 (; = MODULE_HEADER_BASE ;)))
|
||||||
|
(global.get $nextTableIndex))
|
||||||
|
|
||||||
(global.set $nextTableIndex (i32.add (global.get $nextTableIndex) (i32.const 1))))
|
(global.set $nextTableIndex (i32.add (global.get $nextTableIndex) (i32.const 1))))
|
||||||
|
|
||||||
|
|
|
@ -147,9 +147,6 @@ class WAForth {
|
||||||
}
|
}
|
||||||
data = new Uint8Array(dataCopy);
|
data = new Uint8Array(dataCopy);
|
||||||
}
|
}
|
||||||
if (index >= table.length) {
|
|
||||||
table.grow(table.length); // Double size
|
|
||||||
}
|
|
||||||
// console.log("Load", index, arrayToBase64(data));
|
// console.log("Load", index, arrayToBase64(data));
|
||||||
try {
|
try {
|
||||||
var module = new WebAssembly.Module(data);
|
var module = new WebAssembly.Module(data);
|
||||||
|
|
Loading…
Reference in a new issue