diff --git a/Makefile b/Makefile index 71245aa..8de82df 100644 --- a/Makefile +++ b/Makefile @@ -556,6 +556,9 @@ deploy: all cd out/deploy && gcloud app deploy -q --project esp32forth *.yaml cd out/deploy && gcloud app deploy -q --project eforth *.yaml +d8: + ${HOME}/src/v8/v8/out/x64.release/d8 out/web/ueforth.js + # ---- INSTALL ---- install: $(POSIX)/ueforth diff --git a/common/tier2a_forth.fs b/common/tier2a_forth.fs index ec56358..3d0deea 100644 --- a/common/tier2a_forth.fs +++ b/common/tier2a_forth.fs @@ -21,4 +21,3 @@ : >params ( xt -- n ) >flags& 2 + sw@ $ffff and ; : >size ( xt -- n ) dup >params cells swap >name-length aligned + 3 cells + ; : >link& ( xt -- a ) 2 cells - ; : >link ( xt -- a ) >link& @ ; -: >name ( xt -- a n ) dup >name-length swap >link& over aligned - swap ; diff --git a/common/tier2b_forth.fs b/common/tier2b_forth.fs index 6dde7e0..f3f6ae1 100644 --- a/common/tier2b_forth.fs +++ b/common/tier2b_forth.fs @@ -12,4 +12,12 @@ \ See the License for the specific language governing permissions and \ limitations under the License. +: >name ( xt -- a n ) + dup >flags 8 and if + dup >link swap >name-length + else + dup >name-length swap >link& over aligned - swap + then +; + : fill32 ( a n v ) swap >r swap r> 0 ?do 2dup ! cell+ loop 2drop ; diff --git a/web/fini.fs b/web/fini.fs index 26265f7..60a83a8 100644 --- a/web/fini.fs +++ b/web/fini.fs @@ -76,7 +76,7 @@ r| return sp; }) | 2 jseval! -: web-type ( a n -- ) 2 call ; +: web-type ( a n -- ) 2 call yield ; ' web-type is type r| diff --git a/web/web.template.js b/web/web.template.js index 70a7d97..81ef4ad 100644 --- a/web/web.template.js +++ b/web/web.template.js @@ -67,7 +67,6 @@ function GetString(a, n) { return ret; } - function CELL_ALIGNED(n) { return (n + 3) & ~3; } function UPPER(ch) { return ch >= 'a'.charCodeAt(0) && ch <= 'z'.charCodeAt(0) ? (ch & 0x5F) : ch; @@ -79,8 +78,8 @@ function TOPARAMS(xt) { return TOFLAGS(xt) + 2; } function TOSIZE(xt) { return CELL_ALIGNED(u8[TONAMELEN(xt)>>2]) + 4 * i32[TOPARAMS(xt)>>2]; } function TOLINK(xt) { return xt - 2 * 4; } function TONAME(xt) { - return (i32[TOFLAGS(xt)>>2] & BUILTIN_MARK) - ? u8[TOLINK(xt)] : TOLINK(xt) - CELL_ALIGNED(u8[TONAMELEN(xt)]); + return (u8[TOFLAGS(xt)>>2] & BUILTIN_MARK) + ? i32[TOLINK(xt)] : TOLINK(xt) - CELL_ALIGNED(u8[TONAMELEN(xt)]); } function TOBODY(xt) { return xt + (i32[xt>>2] === OP_DOCREATE || i32[xt>>2] === OP_DODOES ? 2 : 1) * 4; @@ -184,10 +183,11 @@ function SSMOD(sp) { } function Finish() { - if (i32[g_sys_latestxt>>2] && !i32[TOPARAMS(i32[g_sys_latestxt>>2])>>2]) { - var sz = i32[g_sys_heap>>2] - (g_sys_latestxt + 4); + if (i32[g_sys_latestxt>>2] && !u16[TOPARAMS(i32[g_sys_latestxt>>2])>>1]) { + var sz = i32[g_sys_heap>>2] - (i32[g_sys_latestxt>>2] + 4); + sz /= 4; if (sz < 0 || sz > 0xffff) { sz = 0xffff; } - i32[TOPARAMS(i32[g_sys_latestxt>>2])>>2] = sz; + u16[TOPARAMS(i32[g_sys_latestxt>>2])>>1] = sz; } } @@ -577,8 +577,8 @@ var module = VM(globalObj, ffi, heap); Init(); function run() { module.run(); - setTimeout(run, 1); + setTimeout(run, 0); } -setTimeout(run, 1); +setTimeout(run, 0); })();