Add more memory diagnostics.
This commit is contained in:
@ -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 ;
|
||||
|
||||
@ -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");
|
||||
|
||||
Reference in New Issue
Block a user