1 /******************************************************
8 * Copyright (c) 2006, 2007 Charles R. Childers
10 * Permission to use, copy, modify, and distribute this
11 * software for any purpose with or without fee is hereby
12 * granted, provided that the above copyright notice and
13 * this permission notice appear in all copies.
15 * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR
16 * DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE
17 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18 * AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE
19 * FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
20 * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
21 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF
22 * CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
23 * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
25 ******************************************************/
37 extern long gc_used
, gc_objects
, gc_depth
, gc_tdepth
, last
;
38 extern VM_STACK data
, address
, alternate
;
39 extern ENTRY dictionary
[];
40 extern GCITEM gc_list
[];
41 extern GCITEM gc_trash
[];
44 /******************************************************
45 *|G| :stat ( - ) Display information about
46 *|G| the virtual machine status
49 *|F| Display information about Toka's memory use,
52 ******************************************************/
56 long permanent_objects
, permanent_size
;
61 for (a
= 0; a
!= gc_depth
; a
++)
62 size
+= gc_list
[a
].size
;
63 for (a
= 0; a
!= gc_tdepth
; a
++)
64 tsize
+= gc_trash
[a
].size
;
66 permanent_objects
= gc_objects
- gc_depth
- gc_tdepth
;
67 permanent_size
= gc_used
- size
- tsize
;
69 a
= (sizeof(GCITEM
) * 128)*2;
70 b
= (sizeof(ENTRY
) * MAX_DICTIONARY_ENTRIES
);
71 c
= sizeof(VM_STACK
) * 3 + ((MAX_DATA_STACK
* sizeof(long))*2) + (MAX_RETURN_STACK
* sizeof(long));
73 total
= a
+ b
+ c
+ permanent_size
+ size
+ tsize
;
75 printf("-- Memory Use -------------------------------\n");
76 printf(" %lu KiB (%lu) used for dictionary\n", b
/1024, b
);
77 printf(" %lu KiB (%lu) used for gc bookkeeping\n", a
/1024, a
);
78 printf(" %lu KiB (%lu) used for stacks\n", c
/1024, c
);
80 printf(" Permanent Allocations:\n");
81 printf(" %lu objects totaling %lu KiB (%lu)\n", permanent_objects
, permanent_size
/1024, permanent_size
);
82 printf(" Temporary Allocations:\n");
83 printf(" User: %lu objects totaling %lu KiB (%lu)\n", gc_depth
, size
/1024, size
);
84 printf(" System: %lu objects totaling %lu KiB (%lu)\n", gc_tdepth
, tsize
/1024, tsize
);
86 printf(" Total: %lu KiB (%lu)\n", total
/1024, total
);
87 printf("-- Dictionary -------------------------------\n");
88 printf(" %lu named items (Max: %lu)\n", last
, (long)MAX_DICTIONARY_ENTRIES
);
89 printf("-- Stacks -----------------------------------\n");
90 printf(" Data: %lu items (Max: %lu)\n", data
.sp
, (long)MAX_DATA_STACK
);
91 printf(" Alternate: %lu items (Max: %lu)\n", alternate
.sp
, (long)MAX_DATA_STACK
);
92 printf(" Address: %lu items (Max: %lu)\n", address
.sp
, (long)MAX_RETURN_STACK
);
93 printf("---------------------------------------------\n");