JIT code accounting: add count of procedures

Extends ac601a095b.
This commit is contained in:
Matthew Flatt 2018-08-09 19:38:55 -06:00
parent 59d505c157
commit b533a13d20
4 changed files with 14 additions and 2 deletions

View File

@ -312,6 +312,7 @@ typedef struct Thread_Local_Variables {
struct Scheme_Thread *main_break_target_thread_;
intptr_t scheme_code_page_total_;
intptr_t scheme_code_total_;
intptr_t scheme_code_count_;
intptr_t max_gc_pre_used_bytes_;
int num_major_garbage_collections_;
int num_minor_garbage_collections_;
@ -693,6 +694,7 @@ XFORM_GC_VARIABLE_STACK_THROUGH_THREAD_LOCAL;
#define main_break_target_thread XOA (scheme_get_thread_local_variables()->main_break_target_thread_)
#define scheme_code_page_total XOA (scheme_get_thread_local_variables()->scheme_code_page_total_)
#define scheme_code_total XOA (scheme_get_thread_local_variables()->scheme_code_total_)
#define scheme_code_count XOA (scheme_get_thread_local_variables()->scheme_code_count_)
#define max_gc_pre_used_bytes XOA (scheme_get_thread_local_variables()->max_gc_pre_used_bytes_)
#define num_major_garbage_collections XOA (scheme_get_thread_local_variables()->num_major_garbage_collections_)
#define num_minor_garbage_collections XOA (scheme_get_thread_local_variables()->num_minor_garbage_collections_)

View File

@ -190,7 +190,6 @@ Scheme_Env *scheme_basic_env()
scheme_init_validate();
#ifdef MZ_USE_JIT
scheme_init_jit();
scheme_init_jitprep();
#endif
scheme_init_process_globals();
@ -446,6 +445,8 @@ static Scheme_Env *place_instance_init(void *stack_base, int initial_main_os_thr
scheme_init_compenv_places();
scheme_init_jitprep();
#ifdef TIME_STARTUP_PROCESS
printf("pre-process @ %" PRIdPTR "\n", scheme_get_process_milliseconds());
#endif

View File

@ -45,6 +45,9 @@ static Scheme_Object *omitable_symbol;
static Scheme_Object *folding_symbol;
THREAD_LOCAL_DECL(Scheme_Hash_Table *local_primitive_tables);
THREAD_LOCAL_DECL(extern intptr_t scheme_code_page_total);
THREAD_LOCAL_DECL(extern intptr_t scheme_code_total);
THREAD_LOCAL_DECL(extern intptr_t scheme_code_count);
static Scheme_Object *primitive_table(int argc, Scheme_Object **argv);
static Scheme_Object *primitive_to_position(int argc, Scheme_Object **argv);
@ -1951,7 +1954,8 @@ static void show_perf(Performance_Entry *perf_entries, int perf_count,
tab_number(gc_total, gc_tab, gc_len),
gc_total);
#ifdef MZ_PRECISE_GC
fprintf(stderr, ";; [JIT code: %"PRIdPTR" bytes JIT code+admin: %"PRIdPTR" bytes]\n",
fprintf(stderr, ";; [JIT code: %"PRIdPTR" procs %"PRIdPTR" bytes JIT code+admin: %"PRIdPTR" bytes]\n",
scheme_code_count,
scheme_code_total,
scheme_code_page_total);
#endif

View File

@ -944,6 +944,7 @@ THREAD_LOCAL_DECL(static void *code_allocation_page_list);
THREAD_LOCAL_DECL(intptr_t scheme_code_page_total);
THREAD_LOCAL_DECL(intptr_t scheme_code_total);
THREAD_LOCAL_DECL(intptr_t scheme_code_count);
#if defined(MZ_CODE_ALLOC_USE_MPROTECT) && !defined(MAP_ANON)
static int fd, fd_created;
@ -1163,6 +1164,7 @@ void *scheme_malloc_code(intptr_t size)
pg = malloc_page(sz);
scheme_code_page_total += sz;
scheme_code_total += sz;
scheme_code_count++;
*(intptr_t *)pg = sz;
chain_page(pg);
LOG_CODE_MALLOC(1, printf("allocated large %p (%ld) [now %ld]\n",
@ -1173,6 +1175,7 @@ void *scheme_malloc_code(intptr_t size)
size2 = free_list[bucket].size;
scheme_code_total += size2;
scheme_code_count++;
if (!free_list[bucket].elems) {
/* add a new page's worth of items to the free list */
@ -1271,6 +1274,7 @@ void scheme_free_code(void *p)
/* it was a large object on its own page(s) */
scheme_code_page_total -= size;
scheme_code_total -= size;
--scheme_code_count;
LOG_CODE_MALLOC(1, printf("freeing large %p (%ld) [%ld left]\n",
p, size, scheme_code_page_total));
unchain_page((char *)p - CODE_HEADER_SIZE);
@ -1285,6 +1289,7 @@ void scheme_free_code(void *p)
size2 = free_list[bucket].size;
scheme_code_total -= size2;
--scheme_code_count;
LOG_CODE_MALLOC(0, printf("freeing %ld / %ld\n", size2, bucket));