diff options
-rw-r--r-- | Makefile | 2 | ||||
-rw-r--r-- | eval.cpp | 6 | ||||
-rw-r--r-- | gc.cpp | 10 |
3 files changed, 12 insertions, 6 deletions
@@ -2,7 +2,7 @@ sonsi: main.o parser.o builtin.o model.o eval.o exc.o consts.o types.o gc.o g++ -o sonsi $^ -pg -lgmp .cpp.o: - g++ $< -c -pg -DGMP_SUPPORT -Wall -DGC_INFO -O2 + g++ $< -c -g -DGMP_SUPPORT -Wall -DGC_INFO -O2 clean: rm -f *.o @@ -149,6 +149,9 @@ EvalObj *Evaluator::run_expr(Pair *prog) { FrameObj **top_ptr = eval_stack; Pair *pc = prog; Continuation *cont = NULL; +#ifdef GC_DEBUG + fprintf(stderr, "Start the evaluation...\n"); +#endif // envt is this->envt push(pc, top_ptr, envt); gc.attach(prog); @@ -170,6 +173,7 @@ EvalObj *Evaluator::run_expr(Pair *prog) { } //< static_cast because the while condition RetAddr *ret_addr = static_cast<RetAddr*>(*top_ptr); + gc.attach(args); if (!ret_addr->addr) { Pair *nexp = TO_PAIR(cont->proc_body->cdr); @@ -189,11 +193,11 @@ EvalObj *Evaluator::run_expr(Pair *prog) { gc.attach(cont); } else pc = nexp; + gc.expose(args); top_ptr++; } else { - gc.attach(args); EvalObj *opt = args->car; if (opt->is_opt_obj()) pc = static_cast<OptObj*>(opt)-> @@ -48,7 +48,7 @@ void GarbageCollector::force() { } // fetch the pending pointers in the list // clear the list pending_list = NULL; */ - fprintf(stderr, "%d\n", mapping.size()); + fprintf(stderr, "%ld\n", mapping.size()); for (EvalObj2Int::iterator it = mapping.begin(); it != mapping.end(); it++) if (it->second == 0) *r++ = it->first; @@ -86,10 +86,12 @@ void GarbageCollector::force() { fprintf(stderr, "GC: Forced clear, %lu objects are freed, " "%lu remains\n" "=============================\n", cnt, mapping.size()); -/* for (EvalObj2Int::iterator it = mapping.begin(); + +#endif +#ifdef GC_DEBUG + for (EvalObj2Int::iterator it = mapping.begin(); it != mapping.end(); it++) - fprintf(stderr, "%llx => %lu\n", (ull)it->first, it->second); - */ + fprintf(stderr, "%llx => %s\n", (ull)it->first, it->first->ext_repr().c_str()); #endif collecting = false; } |