Upgrade to major GC if data heap exceeds limit

This commit is contained in:
Justin Ethier 2015-07-03 23:27:24 -04:00
parent d0e05c0fd3
commit 6c40a29d5d
3 changed files with 12 additions and 0 deletions

View file

@ -65,6 +65,7 @@ static void main_main (stack_size,heap_size,stack_base)
alloc_end = allocp + heap_size - 8; alloc_end = allocp + heap_size - 8;
dhallocp = dhbottom = calloc(1, heap_size); dhallocp = dhbottom = calloc(1, heap_size);
dhalloc_limit = dhallocp + (long)((heap_size - 8) * 0.90);
dhalloc_end = dhallocp + heap_size - 8; dhalloc_end = dhallocp + heap_size - 8;
#if DEBUG_SHOW_DIAG #if DEBUG_SHOW_DIAG
printf("main: heap_size=%ld allocp=%p alloc_end=%p\n", printf("main: heap_size=%ld allocp=%p alloc_end=%p\n",

View file

@ -42,6 +42,7 @@ char *alloc_end;
copying to occur during GC */ copying to occur during GC */
char *dhbottom; /* Bottom of data heap */ char *dhbottom; /* Bottom of data heap */
char *dhallocp; /* Current place in data heap */ char *dhallocp; /* Current place in data heap */
char *dhalloc_limit; /* GC beyond this limit */
char *dhalloc_end; char *dhalloc_end;
long no_gcs = 0; /* Count the number of GC's. */ long no_gcs = 0; /* Count the number of GC's. */
long no_major_gcs = 0; /* Count the number of GC's. */ long no_major_gcs = 0; /* Count the number of GC's. */
@ -1674,6 +1675,14 @@ void GC_loop(int major, closure cont, object *ans, int num_ans)
char *tmp_dhbottom = dhbottom; char *tmp_dhbottom = dhbottom;
char *tmp_dhallocp = dhallocp; char *tmp_dhallocp = dhallocp;
char *tmp_dhallocp_end = dhalloc_end; char *tmp_dhallocp_end = dhalloc_end;
if (dhallocp > dhalloc_limit) {
// Upgrade to major GC
major = 1;
no_major_gcs++;
no_gcs--;
}
if (major) { if (major) {
// Initialize new heap (TODO: make a function for this) // Initialize new heap (TODO: make a function for this)
bottom = calloc(1,global_heap_size); bottom = calloc(1,global_heap_size);
@ -1684,6 +1693,7 @@ void GC_loop(int major, closure cont, object *ans, int num_ans)
old_heap_high_limit = tmp_alloc_end; old_heap_high_limit = tmp_alloc_end;
dhallocp = dhbottom = calloc(1, global_heap_size); dhallocp = dhbottom = calloc(1, global_heap_size);
dhalloc_limit = dhallocp + (long)((global_heap_size - 8) * 0.90);
dhalloc_end = dhallocp + global_heap_size - 8; dhalloc_end = dhallocp + global_heap_size - 8;
} }

View file

@ -224,6 +224,7 @@ extern char *alloc_end;
copying to occur during GC */ copying to occur during GC */
extern char *dhbottom; /* Bottom of data heap */ extern char *dhbottom; /* Bottom of data heap */
extern char *dhallocp; /* Current place in data heap */ extern char *dhallocp; /* Current place in data heap */
extern char *dhalloc_limit; /* GC beyond this limit */
extern char *dhalloc_end; extern char *dhalloc_end;
extern long no_gcs; /* Count the number of GC's. */ extern long no_gcs; /* Count the number of GC's. */
extern long no_major_gcs; /* Count the number of GC's. */ extern long no_major_gcs; /* Count the number of GC's. */