Add more memory diagnostics.
This commit is contained in:
@ -74,6 +74,7 @@
|
|||||||
sys: 'argc sys: 'argv sys: 'runner
|
sys: 'argc sys: 'argv sys: 'runner
|
||||||
: context ( -- a ) 'context @ cell+ ;
|
: context ( -- a ) 'context @ cell+ ;
|
||||||
: remaining ( -- n ) 'heap-start @ 'heap-size @ + 'heap @ - ;
|
: remaining ( -- n ) 'heap-start @ 'heap-size @ + 'heap @ - ;
|
||||||
|
: used ( -- n ) 'heap @ sp@ 'stack-cells @ cells + - 28 + ;
|
||||||
|
|
||||||
( Compilation State )
|
( Compilation State )
|
||||||
: [ 0 state ! ; immediate
|
: [ 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
|
if 0 state ! sp0 sp! fp0 fp! rp0 rp! ." ERROR" cr then
|
||||||
prompt refill drop again ;
|
prompt refill drop again ;
|
||||||
: raw-ok ." v{{VERSION}} - rev {{REVISION}}" cr
|
: 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 ;
|
prompt refill drop quit ;
|
||||||
|
|||||||
@ -24,7 +24,7 @@
|
|||||||
#define VOCABULARY_DEPTH 16
|
#define VOCABULARY_DEPTH 16
|
||||||
|
|
||||||
#if PRINT_ERRORS
|
#if PRINT_ERRORS
|
||||||
#include <unistd.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -180,8 +180,9 @@ static cell_t *evaluate1(cell_t *sp, float **fp) {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
#if PRINT_ERRORS
|
#if PRINT_ERRORS
|
||||||
write(2, (void *) name, len);
|
fprintf(stderr, "CANT FIND: ");
|
||||||
write(2, "\n", 1);
|
fwrite((void *) name, 1, len, stderr);
|
||||||
|
fprintf(stderr, "\n");
|
||||||
#endif
|
#endif
|
||||||
*++sp = name;
|
*++sp = name;
|
||||||
*++sp = len;
|
*++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; }
|
for (int i = 0; i < VOCABULARY_DEPTH; ++i) { *g_sys.heap++ = 0; }
|
||||||
|
|
||||||
forth_run(0);
|
forth_run(0);
|
||||||
(*g_sys.current)[-1] |= IMMEDIATE; // Make last word ; IMMEDIATE
|
|
||||||
g_sys.DOLIT_XT = FIND("DOLIT");
|
g_sys.DOLIT_XT = FIND("DOLIT");
|
||||||
g_sys.DOFLIT_XT = FIND("DOFLIT");
|
g_sys.DOFLIT_XT = FIND("DOFLIT");
|
||||||
g_sys.DOEXIT_XT = FIND("EXIT");
|
g_sys.DOEXIT_XT = FIND("EXIT");
|
||||||
|
|||||||
Reference in New Issue
Block a user