mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-04 11:46:35 +02:00
Added moveBuf and helper functions
This commit is contained in:
parent
d7640c988b
commit
e941b19db4
4 changed files with 29 additions and 2 deletions
13
gc.c
13
gc.c
|
@ -262,6 +262,19 @@ size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr)
|
||||||
return max_freed;
|
return max_freed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void gc_thr_grow_move_buffer(gc_thread_data *d){
|
||||||
|
if (!d) return;
|
||||||
|
|
||||||
|
if (d->moveBufLen == 0) { // Special case
|
||||||
|
d->moveBufLen = 128;
|
||||||
|
d->moveBuf = NULL;
|
||||||
|
} else {
|
||||||
|
d->moveBufLen *= 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
d->moveBuf = realloc(d->moveBuf, d->moveBufLen);
|
||||||
|
}
|
||||||
|
|
||||||
// void gc_init()
|
// void gc_init()
|
||||||
// {
|
// {
|
||||||
// }
|
// }
|
||||||
|
|
|
@ -13,7 +13,6 @@
|
||||||
|
|
||||||
long global_stack_size = 0;
|
long global_stack_size = 0;
|
||||||
long global_heap_size = 0;
|
long global_heap_size = 0;
|
||||||
gc_heap *Cyc_heap;
|
|
||||||
|
|
||||||
static void c_entry_pt(int,closure,closure);
|
static void c_entry_pt(int,closure,closure);
|
||||||
static void Cyc_main(long stack_size,long heap_size,char *stack_base);
|
static void Cyc_main(long stack_size,long heap_size,char *stack_base);
|
||||||
|
@ -59,6 +58,10 @@ static void Cyc_main (stack_size,heap_size,stack_base)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
Cyc_heap = gc_heap_create(heap_size, 0);
|
Cyc_heap = gc_heap_create(heap_size, 0);
|
||||||
|
Cyc_thread = (gc_thread_data *)malloc(sizeof(gc_thread_data));
|
||||||
|
Cyc_thread->moveBufLen = 0;
|
||||||
|
gc_thr_grow_move_buffer(Cyc_thread); // Initialize the buffer
|
||||||
|
|
||||||
|
|
||||||
// JAE TODO: clean up below (and all of this old code, really)
|
// JAE TODO: clean up below (and all of this old code, really)
|
||||||
bottom = calloc(1,heap_size);
|
bottom = calloc(1,heap_size);
|
||||||
|
|
|
@ -20,6 +20,13 @@
|
||||||
/* Define general object type. */
|
/* Define general object type. */
|
||||||
typedef void *object;
|
typedef void *object;
|
||||||
|
|
||||||
|
/* Thread data structures */
|
||||||
|
typedef struct gc_thread_data_t gc_thread_data;
|
||||||
|
struct gc_thread_data_t {
|
||||||
|
char *moveBuf; /* list of objects moved to heap during GC */
|
||||||
|
int moveBufLen;
|
||||||
|
};
|
||||||
|
|
||||||
/* GC data structures */
|
/* GC data structures */
|
||||||
|
|
||||||
typedef struct gc_free_list_t gc_free_list;
|
typedef struct gc_free_list_t gc_free_list;
|
||||||
|
@ -69,6 +76,7 @@ size_t gc_heap_total_size(gc_heap *h);
|
||||||
void gc_mark(gc_heap *h, object obj);
|
void gc_mark(gc_heap *h, object obj);
|
||||||
size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr);
|
size_t gc_sweep(gc_heap *h, size_t *sum_freed_ptr);
|
||||||
void gc_collect(gc_heap *h, size_t *sum_freed);
|
void gc_collect(gc_heap *h, size_t *sum_freed);
|
||||||
|
void gc_thr_grow_move_buffer(gc_thread_data *d);
|
||||||
|
|
||||||
/* GC debugging flags */
|
/* GC debugging flags */
|
||||||
//#define DEBUG_GC 0
|
//#define DEBUG_GC 0
|
||||||
|
|
|
@ -9,6 +9,9 @@
|
||||||
#include "cyclone/types.h"
|
#include "cyclone/types.h"
|
||||||
#include "cyclone/runtime.h"
|
#include "cyclone/runtime.h"
|
||||||
|
|
||||||
|
gc_heap *Cyc_heap;
|
||||||
|
gc_thread_data *Cyc_thread;
|
||||||
|
|
||||||
/* Error checking section - type mismatch, num args, etc */
|
/* Error checking section - type mismatch, num args, etc */
|
||||||
/* Type names to use for error messages */
|
/* Type names to use for error messages */
|
||||||
const char *tag_names[21] = { \
|
const char *tag_names[21] = { \
|
||||||
|
@ -2405,7 +2408,7 @@ char *gc_move(char *obj) {
|
||||||
} \
|
} \
|
||||||
}
|
}
|
||||||
|
|
||||||
void GC(cont,ans,num_ans) closure cont; object *args; int num_args;
|
void GC(cont, args, num_args) closure cont; object *args; int num_args;
|
||||||
{
|
{
|
||||||
char tmp;
|
char tmp;
|
||||||
object temp;
|
object temp;
|
||||||
|
|
Loading…
Add table
Reference in a new issue