diff --git a/bin/ikarus b/bin/ikarus index 5d55fe2..bb8ab36 100755 Binary files a/bin/ikarus and b/bin/ikarus differ diff --git a/bin/ikarus-collect.c b/bin/ikarus-collect.c index 96cd09a..606bbf4 100644 --- a/bin/ikarus-collect.c +++ b/bin/ikarus-collect.c @@ -17,6 +17,7 @@ #define accounting 0 +#if accounting static int pair_count = 0; static int symbol_count = 0; static int closure_count = 0; @@ -25,6 +26,7 @@ static int record_count = 0; static int continuation_count = 0; static int string_count = 0; static int htable_count = 0; +#endif typedef struct qupages_t{ ikp p; /* pointer to the scan start */ @@ -230,7 +232,15 @@ gc_tconc_push(gc_t* gc, ikp tcbucket){ } } -static ikp add_object(gc_t* gc, ikp x, char* caller); + +#ifndef NDEBUG +static ikp add_object_proc(gc_t* gc, ikp x, char* caller); +#define add_object(gc,x,caller) add_object_proc(gc,x,caller) +#else +static ikp add_object_proc(gc_t* gc, ikp x); +#define add_object(gc,x,caller) add_object_proc(gc,x) +#endif + static void collect_stack(gc_t*, ikp top, ikp base); static void collect_loop(gc_t*); static void fix_weak_pointers(gc_t*); @@ -307,7 +317,7 @@ ik_collect(int mem_req, ikpcb* pcb){ collect_stack(&gc, pcb->frame_pointer, pcb->frame_base - wordsize); pcb->next_k = add_object(&gc, pcb->next_k, "next_k"); pcb->oblist = add_object(&gc, pcb->oblist, "oblist"); - pcb->arg_list = add_object(&gc, pcb->arg_list, "args_list"); + pcb->arg_list = add_object(&gc, pcb->arg_list, "args_list_foo"); /* now we trace all live objects */ collect_loop(&gc); @@ -321,7 +331,7 @@ ik_collect(int mem_req, ikpcb* pcb){ pcb->weak_pairs_ap = 0; pcb->weak_pairs_ep = 0; - if(accounting){ +#if accounting fprintf(stderr, "[%d cons|%d sym|%d cls|%d vec|%d rec|%d cck|%d str|%d htb]\n", pair_count, @@ -340,7 +350,7 @@ ik_collect(int mem_req, ikpcb* pcb){ continuation_count = 0; string_count = 0; htable_count = 0; - } +#endif //ik_dump_metatable(pcb); #ifndef NDEBUG fprintf(stderr, "collect done\n"); @@ -662,7 +672,12 @@ add_list(gc_t* gc, unsigned int t, int gen, ikp x, ikp* loc){ static ikp -add_object(gc_t* gc, ikp x, char* caller){ +#ifndef NDEBUG +add_object_proc(gc_t* gc, ikp x, char* caller) +#else +add_object_proc(gc_t* gc, ikp x) +#endif +{ if(is_fixnum(x)){ return x; } @@ -699,9 +714,9 @@ add_object(gc_t* gc, ikp x, char* caller){ ref(y, off_symbol_system_plist) = ref(x, off_symbol_system_plist); ref(x, -symbol_tag) = forward_ptr; ref(x, wordsize-symbol_tag) = y; - if(accounting){ +#if accounting symbol_count++; - } +#endif return y; } else if(tag == closure_tag){ @@ -717,9 +732,9 @@ add_object(gc_t* gc, ikp x, char* caller){ ref(y,-closure_tag) = add_code_entry(gc, ref(y,-closure_tag)); ref(x,-closure_tag) = forward_ptr; ref(x,wordsize-closure_tag) = y; - if(accounting){ - closure_count++; - } +#if accounting + closure_count++; +#endif return y; } else if(tag == vector_tag){ @@ -734,9 +749,9 @@ add_object(gc_t* gc, ikp x, char* caller){ memcpy(y+off_vector_data, x+off_vector_data, size); ref(x,-vector_tag) = forward_ptr; ref(x,wordsize-vector_tag) = y; - if(accounting){ - vector_count++; - } +#if accounting + vector_count++; +#endif return y; } else if(tagof(fst) == rtd_tag){ @@ -751,9 +766,9 @@ add_object(gc_t* gc, ikp x, char* caller){ memcpy(y-vector_tag, x-vector_tag, size+wordsize); ref(x,-vector_tag) = forward_ptr; ref(x,wordsize-vector_tag) = y; - if(accounting){ +#if accounting record_count++; - } +#endif return y; } else if(fst == code_tag){ @@ -780,10 +795,9 @@ add_object(gc_t* gc, ikp x, char* caller){ ref(y, off_continuation_top) = new_top; ref(y, off_continuation_size) = (ikp) size; ref(y, off_continuation_next) = next; - if(accounting){ - continuation_count++; - } - return y; +#if accounting + continuation_count++; +#endif } else if(tagof(fst) == pair_tag){ /* tcbucket */ @@ -842,9 +856,9 @@ add_object(gc_t* gc, ikp x, char* caller){ strlen + 1); ref(x, -string_tag) = forward_ptr; ref(x, wordsize-string_tag) = new_str; - if(accounting){ - string_count++; - } +#if accounting + string_count++; +#endif return new_str; } else { diff --git a/bin/ikarus-runtime.c b/bin/ikarus-runtime.c index 5fdad17..4d195be 100644 --- a/bin/ikarus-runtime.c +++ b/bin/ikarus-runtime.c @@ -200,11 +200,6 @@ ik_munmap(void* mem, int size){ int mapsize = pages * pagesize; assert(size == mapsize); assert(((-pagesize) & (int)mem) == (int)mem); -//int err = mprotect(mem, mapsize, PROT_NONE); -//if(err != 0){ -// fprintf(stderr, "error protecting unmapped pages\n"); -// exit(-1); -//} total_allocated_pages -= pages; int err = munmap(mem, mapsize); if(err != 0){ diff --git a/src/ikarus.boot b/src/ikarus.boot index 989910e..a52dac8 100644 Binary files a/src/ikarus.boot and b/src/ikarus.boot differ diff --git a/src/makefile.ss b/src/makefile.ss index 1f188bb..0052162 100755 --- a/src/makefile.ss +++ b/src/makefile.ss @@ -231,14 +231,17 @@ )) -(define (expand-file ifile) +(define (read-file ifile) (with-input-from-file ifile - (lambda () - (let f () - (let ([x (read)]) - (unless (eof-object? x) - (sc-expand x) - (f))))))) + (lambda () + (let f () + (let ([x (read)]) + (if (eof-object? x) + '() + (cons x (f)))))))) + +(define (expand-file ifile) + (map sc-expand (read-file ifile))) (define (compile-library ifile ofile) (parameterize ([assembler-output #f] @@ -247,6 +250,7 @@ (printf "compiling ~a ... " ifile) (compile-file ifile ofile 'replace) ;(expand-file ifile) + ;(read-file ifile) (newline))) (for-each