Add more memory diagnostics.

This commit is contained in:
Brad Nelson
2022-01-09 14:20:50 -08:00
parent 3cc3884631
commit 5b131c84fe
2 changed files with 8 additions and 5 deletions

View File

@ -74,6 +74,7 @@
sys: 'argc sys: 'argv sys: 'runner
: context ( -- a ) 'context @ cell+ ;
: remaining ( -- n ) 'heap-start @ 'heap-size @ + 'heap @ - ;
: used ( -- n ) 'heap @ sp@ 'stack-cells @ cells + - 28 + ;
( Compilation State )
: [ 0 state ! ; immediate
@ -258,5 +259,7 @@ create input-buffer input-limit allot
if 0 state ! sp0 sp! fp0 fp! rp0 rp! ." ERROR" cr then
prompt refill drop again ;
: raw-ok ." v{{VERSION}} - rev {{REVISION}}" cr
remaining . ." bytes heap free" cr
remaining . ." bytes heap free "
used . ." bytes dictionary used "
'stack-cells @ cells . ." bytes x 3 stacks" cr
prompt refill drop quit ;

View File

@ -24,7 +24,7 @@
#define VOCABULARY_DEPTH 16
#if PRINT_ERRORS
#include <unistd.h>
#include <stdio.h>
#endif
static struct {
@ -180,8 +180,9 @@ static cell_t *evaluate1(cell_t *sp, float **fp) {
}
} else {
#if PRINT_ERRORS
write(2, (void *) name, len);
write(2, "\n", 1);
fprintf(stderr, "CANT FIND: ");
fwrite((void *) name, 1, len, stderr);
fprintf(stderr, "\n");
#endif
*++sp = name;
*++sp = len;
@ -219,7 +220,6 @@ static void forth_init(int argc, char *argv[], void *heap,
for (int i = 0; i < VOCABULARY_DEPTH; ++i) { *g_sys.heap++ = 0; }
forth_run(0);
(*g_sys.current)[-1] |= IMMEDIATE; // Make last word ; IMMEDIATE
g_sys.DOLIT_XT = FIND("DOLIT");
g_sys.DOFLIT_XT = FIND("DOFLIT");
g_sys.DOEXIT_XT = FIND("EXIT");