mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-14 16:27:35 +02:00
Upgrade to major GC if data heap exceeds limit
This commit is contained in:
parent
d0e05c0fd3
commit
6c40a29d5d
3 changed files with 12 additions and 0 deletions
|
@ -65,6 +65,7 @@ static void main_main (stack_size,heap_size,stack_base)
|
|||
alloc_end = allocp + heap_size - 8;
|
||||
|
||||
dhallocp = dhbottom = calloc(1, heap_size);
|
||||
dhalloc_limit = dhallocp + (long)((heap_size - 8) * 0.90);
|
||||
dhalloc_end = dhallocp + heap_size - 8;
|
||||
#if DEBUG_SHOW_DIAG
|
||||
printf("main: heap_size=%ld allocp=%p alloc_end=%p\n",
|
||||
|
|
10
runtime.c
10
runtime.c
|
@ -42,6 +42,7 @@ char *alloc_end;
|
|||
copying to occur during GC */
|
||||
char *dhbottom; /* Bottom of data heap */
|
||||
char *dhallocp; /* Current place in data heap */
|
||||
char *dhalloc_limit; /* GC beyond this limit */
|
||||
char *dhalloc_end;
|
||||
long no_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_dhallocp = dhallocp;
|
||||
char *tmp_dhallocp_end = dhalloc_end;
|
||||
|
||||
if (dhallocp > dhalloc_limit) {
|
||||
// Upgrade to major GC
|
||||
major = 1;
|
||||
no_major_gcs++;
|
||||
no_gcs--;
|
||||
}
|
||||
|
||||
if (major) {
|
||||
// Initialize new heap (TODO: make a function for this)
|
||||
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;
|
||||
|
||||
dhallocp = dhbottom = calloc(1, global_heap_size);
|
||||
dhalloc_limit = dhallocp + (long)((global_heap_size - 8) * 0.90);
|
||||
dhalloc_end = dhallocp + global_heap_size - 8;
|
||||
}
|
||||
|
||||
|
|
|
@ -224,6 +224,7 @@ extern char *alloc_end;
|
|||
copying to occur during GC */
|
||||
extern char *dhbottom; /* Bottom of data heap */
|
||||
extern char *dhallocp; /* Current place in data heap */
|
||||
extern char *dhalloc_limit; /* GC beyond this limit */
|
||||
extern char *dhalloc_end;
|
||||
extern long no_gcs; /* Count the number of GC's. */
|
||||
extern long no_major_gcs; /* Count the number of GC's. */
|
||||
|
|
Loading…
Add table
Reference in a new issue