Make it possible to defer start, boost web memory.

This commit is contained in:
Brad Nelson
2023-02-20 18:11:45 -08:00
parent 5a40463464
commit d2c62a35b9
3 changed files with 48 additions and 7 deletions

View File

@ -16,7 +16,7 @@
(function() {
const HEAP_SIZE = (1024 * 1024);
const HEAP_SIZE = (4 * 1024 * 1024);
const STACK_CELLS = 4096;
const VOCABULARY_DEPTH = 16;
@ -601,18 +601,29 @@ function getGlobalObj() {
var globalObj = getGlobalObj();
var module = VM(globalObj, ffi, heap);
function run() {
module.run();
setTimeout(run, 0);
}
if (globalObj.write) {
function Start() {
Init();
setTimeout(run, 0);
}
if (globalObj.write) {
Start();
} else {
window.addEventListener('load', function() {
Init();
setTimeout(run, 0);
});
if (globalObj.ueforth === null) {
globalObj.ueforth = context;
context.Start = Start;
} else {
window.addEventListener('load', function() {
Init();
setTimeout(run, 0);
});
}
}
})();