renamed all if (accounting) {...} to
#if accounting ... #endif
This commit is contained in:
parent
ac5ac00bab
commit
b7410520cb
BIN
bin/ikarus
BIN
bin/ikarus
Binary file not shown.
|
@ -17,6 +17,7 @@
|
||||||
|
|
||||||
#define accounting 0
|
#define accounting 0
|
||||||
|
|
||||||
|
#if accounting
|
||||||
static int pair_count = 0;
|
static int pair_count = 0;
|
||||||
static int symbol_count = 0;
|
static int symbol_count = 0;
|
||||||
static int closure_count = 0;
|
static int closure_count = 0;
|
||||||
|
@ -25,6 +26,7 @@ static int record_count = 0;
|
||||||
static int continuation_count = 0;
|
static int continuation_count = 0;
|
||||||
static int string_count = 0;
|
static int string_count = 0;
|
||||||
static int htable_count = 0;
|
static int htable_count = 0;
|
||||||
|
#endif
|
||||||
|
|
||||||
typedef struct qupages_t{
|
typedef struct qupages_t{
|
||||||
ikp p; /* pointer to the scan start */
|
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_stack(gc_t*, ikp top, ikp base);
|
||||||
static void collect_loop(gc_t*);
|
static void collect_loop(gc_t*);
|
||||||
static void fix_weak_pointers(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);
|
collect_stack(&gc, pcb->frame_pointer, pcb->frame_base - wordsize);
|
||||||
pcb->next_k = add_object(&gc, pcb->next_k, "next_k");
|
pcb->next_k = add_object(&gc, pcb->next_k, "next_k");
|
||||||
pcb->oblist = add_object(&gc, pcb->oblist, "oblist");
|
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 */
|
/* now we trace all live objects */
|
||||||
collect_loop(&gc);
|
collect_loop(&gc);
|
||||||
|
|
||||||
|
@ -321,7 +331,7 @@ ik_collect(int mem_req, ikpcb* pcb){
|
||||||
pcb->weak_pairs_ap = 0;
|
pcb->weak_pairs_ap = 0;
|
||||||
pcb->weak_pairs_ep = 0;
|
pcb->weak_pairs_ep = 0;
|
||||||
|
|
||||||
if(accounting){
|
#if accounting
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"[%d cons|%d sym|%d cls|%d vec|%d rec|%d cck|%d str|%d htb]\n",
|
"[%d cons|%d sym|%d cls|%d vec|%d rec|%d cck|%d str|%d htb]\n",
|
||||||
pair_count,
|
pair_count,
|
||||||
|
@ -340,7 +350,7 @@ ik_collect(int mem_req, ikpcb* pcb){
|
||||||
continuation_count = 0;
|
continuation_count = 0;
|
||||||
string_count = 0;
|
string_count = 0;
|
||||||
htable_count = 0;
|
htable_count = 0;
|
||||||
}
|
#endif
|
||||||
//ik_dump_metatable(pcb);
|
//ik_dump_metatable(pcb);
|
||||||
#ifndef NDEBUG
|
#ifndef NDEBUG
|
||||||
fprintf(stderr, "collect done\n");
|
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
|
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)){
|
if(is_fixnum(x)){
|
||||||
return 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(y, off_symbol_system_plist) = ref(x, off_symbol_system_plist);
|
||||||
ref(x, -symbol_tag) = forward_ptr;
|
ref(x, -symbol_tag) = forward_ptr;
|
||||||
ref(x, wordsize-symbol_tag) = y;
|
ref(x, wordsize-symbol_tag) = y;
|
||||||
if(accounting){
|
#if accounting
|
||||||
symbol_count++;
|
symbol_count++;
|
||||||
}
|
#endif
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
else if(tag == closure_tag){
|
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(y,-closure_tag) = add_code_entry(gc, ref(y,-closure_tag));
|
||||||
ref(x,-closure_tag) = forward_ptr;
|
ref(x,-closure_tag) = forward_ptr;
|
||||||
ref(x,wordsize-closure_tag) = y;
|
ref(x,wordsize-closure_tag) = y;
|
||||||
if(accounting){
|
#if accounting
|
||||||
closure_count++;
|
closure_count++;
|
||||||
}
|
#endif
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
else if(tag == vector_tag){
|
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);
|
memcpy(y+off_vector_data, x+off_vector_data, size);
|
||||||
ref(x,-vector_tag) = forward_ptr;
|
ref(x,-vector_tag) = forward_ptr;
|
||||||
ref(x,wordsize-vector_tag) = y;
|
ref(x,wordsize-vector_tag) = y;
|
||||||
if(accounting){
|
#if accounting
|
||||||
vector_count++;
|
vector_count++;
|
||||||
}
|
#endif
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
else if(tagof(fst) == rtd_tag){
|
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);
|
memcpy(y-vector_tag, x-vector_tag, size+wordsize);
|
||||||
ref(x,-vector_tag) = forward_ptr;
|
ref(x,-vector_tag) = forward_ptr;
|
||||||
ref(x,wordsize-vector_tag) = y;
|
ref(x,wordsize-vector_tag) = y;
|
||||||
if(accounting){
|
#if accounting
|
||||||
record_count++;
|
record_count++;
|
||||||
}
|
#endif
|
||||||
return y;
|
return y;
|
||||||
}
|
}
|
||||||
else if(fst == code_tag){
|
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_top) = new_top;
|
||||||
ref(y, off_continuation_size) = (ikp) size;
|
ref(y, off_continuation_size) = (ikp) size;
|
||||||
ref(y, off_continuation_next) = next;
|
ref(y, off_continuation_next) = next;
|
||||||
if(accounting){
|
#if accounting
|
||||||
continuation_count++;
|
continuation_count++;
|
||||||
}
|
#endif
|
||||||
return y;
|
|
||||||
}
|
}
|
||||||
else if(tagof(fst) == pair_tag){
|
else if(tagof(fst) == pair_tag){
|
||||||
/* tcbucket */
|
/* tcbucket */
|
||||||
|
@ -842,9 +856,9 @@ add_object(gc_t* gc, ikp x, char* caller){
|
||||||
strlen + 1);
|
strlen + 1);
|
||||||
ref(x, -string_tag) = forward_ptr;
|
ref(x, -string_tag) = forward_ptr;
|
||||||
ref(x, wordsize-string_tag) = new_str;
|
ref(x, wordsize-string_tag) = new_str;
|
||||||
if(accounting){
|
#if accounting
|
||||||
string_count++;
|
string_count++;
|
||||||
}
|
#endif
|
||||||
return new_str;
|
return new_str;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
|
@ -200,11 +200,6 @@ ik_munmap(void* mem, int size){
|
||||||
int mapsize = pages * pagesize;
|
int mapsize = pages * pagesize;
|
||||||
assert(size == mapsize);
|
assert(size == mapsize);
|
||||||
assert(((-pagesize) & (int)mem) == (int)mem);
|
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;
|
total_allocated_pages -= pages;
|
||||||
int err = munmap(mem, mapsize);
|
int err = munmap(mem, mapsize);
|
||||||
if(err != 0){
|
if(err != 0){
|
||||||
|
|
BIN
src/ikarus.boot
BIN
src/ikarus.boot
Binary file not shown.
|
@ -231,14 +231,17 @@
|
||||||
))
|
))
|
||||||
|
|
||||||
|
|
||||||
(define (expand-file ifile)
|
(define (read-file ifile)
|
||||||
(with-input-from-file ifile
|
(with-input-from-file ifile
|
||||||
(lambda ()
|
(lambda ()
|
||||||
(let f ()
|
(let f ()
|
||||||
(let ([x (read)])
|
(let ([x (read)])
|
||||||
(unless (eof-object? x)
|
(if (eof-object? x)
|
||||||
(sc-expand x)
|
'()
|
||||||
(f)))))))
|
(cons x (f))))))))
|
||||||
|
|
||||||
|
(define (expand-file ifile)
|
||||||
|
(map sc-expand (read-file ifile)))
|
||||||
|
|
||||||
(define (compile-library ifile ofile)
|
(define (compile-library ifile ofile)
|
||||||
(parameterize ([assembler-output #f]
|
(parameterize ([assembler-output #f]
|
||||||
|
@ -247,6 +250,7 @@
|
||||||
(printf "compiling ~a ... " ifile)
|
(printf "compiling ~a ... " ifile)
|
||||||
(compile-file ifile ofile 'replace)
|
(compile-file ifile ofile 'replace)
|
||||||
;(expand-file ifile)
|
;(expand-file ifile)
|
||||||
|
;(read-file ifile)
|
||||||
(newline)))
|
(newline)))
|
||||||
|
|
||||||
(for-each
|
(for-each
|
||||||
|
|
Loading…
Reference in New Issue