mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-15 16:57:35 +02:00
Starting the heap changes
This leaves everything as a mess at the moment, there are still a lot of changes that need to be made.
This commit is contained in:
parent
befbced21c
commit
0d651d4ff7
3 changed files with 22 additions and 12 deletions
18
gc.c
18
gc.c
|
@ -1648,11 +1648,29 @@ void gc_thread_data_init(gc_thread_data * thd, int mut_num, char *stack_base,
|
||||||
fprintf(stderr, "Unable to initialize thread mutex\n");
|
fprintf(stderr, "Unable to initialize thread mutex\n");
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
thd->heap = calloc(1, sizeof(gc_heap_root));
|
||||||
|
thd->heap->heap = calloc(1, sizeof(gc_heap *) * NUM_HEAP_TYPES);
|
||||||
|
thd->heap->heap[HEAP_REST] = gc_heap_create(HEAP_REST, INITIAL_HEAP_SIZE, 0, 0);
|
||||||
|
thd->heap->heap[HEAP_SM] = gc_heap_create(HEAP_SM, INITIAL_HEAP_SIZE, 0, 0);
|
||||||
|
thd->heap->heap[HEAP_64] = gc_heap_create(HEAP_64, INITIAL_HEAP_SIZE, 0, 0);
|
||||||
|
if (sizeof(void *) == 8) { // Only use this heap on 64-bit platforms
|
||||||
|
thd->heap[HEAP_96] = gc_heap_create(HEAP_96, INITIAL_HEAP_SIZE, 0, 0);
|
||||||
|
}
|
||||||
|
thd->heap->heap[HEAP_HUGE] = gc_heap_create(HEAP_HUGE, 1024, 0, 0);
|
||||||
|
thd->cached_heap_free_sizes = calloc(5, sizeof(uint64_t));
|
||||||
|
thd->cached_heap_total_sizes = calloc(5, sizeof(uint64_t));
|
||||||
}
|
}
|
||||||
|
|
||||||
void gc_thread_data_free(gc_thread_data * thd)
|
void gc_thread_data_free(gc_thread_data * thd)
|
||||||
{
|
{
|
||||||
if (thd) {
|
if (thd) {
|
||||||
|
//
|
||||||
|
// !!
|
||||||
|
// TODO: (not necessarily here, but somewhere need to roll heap pages into
|
||||||
|
// another thread data. need to include cached heap sizes/total, too.
|
||||||
|
// then free cached heap vars here.
|
||||||
|
// !!
|
||||||
|
//
|
||||||
if (pthread_mutex_destroy(&thd->lock) != 0) {
|
if (pthread_mutex_destroy(&thd->lock) != 0) {
|
||||||
// TODO: can only destroy the lock if it is unlocked. need to make sure we
|
// TODO: can only destroy the lock if it is unlocked. need to make sure we
|
||||||
// can guarantee that is the case prior to making this call
|
// can guarantee that is the case prior to making this call
|
||||||
|
|
|
@ -17,6 +17,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
// Maximum number of args that GC will accept
|
// Maximum number of args that GC will accept
|
||||||
#define NUM_GC_ARGS 128
|
#define NUM_GC_ARGS 128
|
||||||
|
@ -141,6 +142,9 @@ struct gc_thread_data_t {
|
||||||
int mark_buffer_len;
|
int mark_buffer_len;
|
||||||
pthread_mutex_t lock;
|
pthread_mutex_t lock;
|
||||||
pthread_t thread_id;
|
pthread_t thread_id;
|
||||||
|
gc_heap_root *heap;
|
||||||
|
uint64_t *cached_heap_free_sizes;
|
||||||
|
uint64_t *cached_heap_total_sizes;
|
||||||
// Data needed for call history
|
// Data needed for call history
|
||||||
char **stack_traces;
|
char **stack_traces;
|
||||||
int stack_trace_idx;
|
int stack_trace_idx;
|
||||||
|
|
12
runtime.c
12
runtime.c
|
@ -140,7 +140,6 @@ if (type_is_pair_prim(clo)) { \
|
||||||
/*END closcall section */
|
/*END closcall section */
|
||||||
|
|
||||||
/* Global variables. */
|
/* Global variables. */
|
||||||
static gc_heap_root *Cyc_heap;
|
|
||||||
object Cyc_global_variables = NULL;
|
object Cyc_global_variables = NULL;
|
||||||
int _cyc_argc = 0;
|
int _cyc_argc = 0;
|
||||||
char **_cyc_argv = NULL;
|
char **_cyc_argv = NULL;
|
||||||
|
@ -261,17 +260,6 @@ static bool set_insert(ck_hs_t * hs, const void *value)
|
||||||
|
|
||||||
void gc_init_heap(long heap_size)
|
void gc_init_heap(long heap_size)
|
||||||
{
|
{
|
||||||
size_t initial_heap_size = INITIAL_HEAP_SIZE;
|
|
||||||
Cyc_heap = calloc(1, sizeof(gc_heap_root));
|
|
||||||
Cyc_heap->heap = calloc(1, sizeof(gc_heap *) * NUM_HEAP_TYPES);
|
|
||||||
Cyc_heap->heap[HEAP_REST] = gc_heap_create(HEAP_REST, initial_heap_size, 0, 0);
|
|
||||||
Cyc_heap->heap[HEAP_SM] = gc_heap_create(HEAP_SM, initial_heap_size, 0, 0);
|
|
||||||
Cyc_heap->heap[HEAP_64] = gc_heap_create(HEAP_64, initial_heap_size, 0, 0);
|
|
||||||
if (sizeof(void *) == 8) { // Only use this heap on 64-bit platforms
|
|
||||||
Cyc_heap->heap[HEAP_96] = gc_heap_create(HEAP_96, initial_heap_size, 0, 0);
|
|
||||||
}
|
|
||||||
Cyc_heap->heap[HEAP_HUGE] = gc_heap_create(HEAP_HUGE, 1024, 0, 0);
|
|
||||||
|
|
||||||
if (!ck_hs_init(&symbol_table,
|
if (!ck_hs_init(&symbol_table,
|
||||||
CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC,
|
CK_HS_MODE_OBJECT | CK_HS_MODE_SPMC,
|
||||||
hs_hash, hs_compare,
|
hs_hash, hs_compare,
|
||||||
|
|
Loading…
Add table
Reference in a new issue