From 20e71fff3ba60f344df5ca1d10c93394df2f8026 Mon Sep 17 00:00:00 2001 From: Justin Ethier Date: Tue, 20 Oct 2015 01:54:15 -0400 Subject: [PATCH] Bug fixes --- include/cyclone/runtime.h | 2 ++ runtime.c | 16 +++++++--------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/include/cyclone/runtime.h b/include/cyclone/runtime.h index 78b2d12c..45e75e1a 100644 --- a/include/cyclone/runtime.h +++ b/include/cyclone/runtime.h @@ -209,6 +209,8 @@ void dispatch_va(int argc, function_type_va func, object clo, object cont, objec void do_dispatch(int argc, function_type func, object clo, object *buffer); /* Global variables. */ +extern gc_heap *Cyc_heap; +extern gc_thread_data *Cyc_thread; extern clock_t start; /* Starting time. */ extern char *stack_begin; /* Initialized by main. */ extern char *stack_limit1; /* Initialized by main. */ diff --git a/runtime.c b/runtime.c index ef2baf1b..e3cb758a 100644 --- a/runtime.c +++ b/runtime.c @@ -9,9 +9,6 @@ #include "cyclone/types.h" #include "cyclone/runtime.h" -gc_heap *Cyc_heap; -gc_thread_data *Cyc_thread; - /* Error checking section - type mismatch, num args, etc */ /* Type names to use for error messages */ const char *tag_names[21] = { \ @@ -2593,7 +2590,7 @@ void GC(cont, args, num_args) closure cont; object *args; int num_args; int scani = 0, alloci = 0; // TODO: not quite sure how to do this yet, want to user pointers but realloc can move them... need to think about how this will work int heap_grown = 0; -fprintf("DEBUG, started minor GC\n"); // JAE DEBUG +fprintf(stderr, "DEBUG, started minor GC\n"); // JAE DEBUG // Prevent overrunning buffer if (num_args > NUM_GC_ANS) { printf("Fatal error - too many arguments (%d) to GC\n", num_args); @@ -2707,14 +2704,15 @@ fprintf("DEBUG, started minor GC\n"); // JAE DEBUG // Check if we need to do a major GC if (heap_grown) { size_t freed = 0; -fprintf("DEBUG, starting major mark/sweep GC\n"); // JAE DEBUG - TODO: not good enough, need to pass current cont/args - what about mutation barrier, do we care at this point??? - I don't think so because those are just updates to globals +fprintf(stderr, "DEBUG, starting major mark/sweep GC\n"); // JAE DEBUG + gc_mark(Cyc_heap, cont); + for (i = 0; i < num_args; i++){ + gc_mark(Cyc_heap, args[i]); + } gc_collect(Cyc_heap, &freed); } -fprintf("DEBUG, finished minor GC\n"); // JAE DEBUG +fprintf(stderr, "DEBUG, finished minor GC\n"); // JAE DEBUG longjmp(jmp_main,1); // Return globals gc_cont, gc_ans }