mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-12 23:37:38 +02:00
Additional debug information
This commit is contained in:
parent
656a7f01d4
commit
dc8f4c02a1
1 changed files with 37 additions and 2 deletions
39
gc.c
39
gc.c
|
@ -88,6 +88,35 @@ static struct ck_malloc my_allocator = {
|
||||||
.realloc = my_realloc
|
.realloc = my_realloc
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if GC_DEBUG_TRACE
|
||||||
|
static double allocated_obj_counts[25] = {
|
||||||
|
0,0,0,0,0,
|
||||||
|
0,0,0,0,0,
|
||||||
|
0,0,0,0,0,
|
||||||
|
0,0,0,0,0,
|
||||||
|
0,0,0,0,0};
|
||||||
|
|
||||||
|
void print_allocated_obj_counts()
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
fprintf(stderr, "Allocated objects:\n");
|
||||||
|
fprintf(stderr, "Tag, Allocations\n");
|
||||||
|
for (i = 0; i < 25; i++){
|
||||||
|
fprintf(stderr, "%d, %lf\n", i, allocated_obj_counts[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_current_time()
|
||||||
|
{
|
||||||
|
time_t rawtime;
|
||||||
|
struct tm * timeinfo;
|
||||||
|
|
||||||
|
time ( &rawtime );
|
||||||
|
timeinfo = localtime ( &rawtime );
|
||||||
|
fprintf(stderr, "%s", asctime (timeinfo));
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/////////////
|
/////////////
|
||||||
// Functions
|
// Functions
|
||||||
|
|
||||||
|
@ -284,6 +313,9 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data * thd)
|
||||||
{
|
{
|
||||||
// NOTE: no additional type checking because this is called from gc_move
|
// NOTE: no additional type checking because this is called from gc_move
|
||||||
// which already does that
|
// which already does that
|
||||||
|
#if GC_DEBUG_TRACE
|
||||||
|
allocated_obj_counts[type_of(obj)]++;
|
||||||
|
#endif
|
||||||
|
|
||||||
switch (type_of(obj)) {
|
switch (type_of(obj)) {
|
||||||
case pair_tag:{
|
case pair_tag:{
|
||||||
|
@ -1294,6 +1326,9 @@ void gc_collector()
|
||||||
size_t total_size;
|
size_t total_size;
|
||||||
size_t total_free;
|
size_t total_free;
|
||||||
time_t gc_collector_start = time(NULL);
|
time_t gc_collector_start = time(NULL);
|
||||||
|
print_allocated_obj_counts();
|
||||||
|
print_current_time();
|
||||||
|
fprintf(stderr, "Starting gc_collector\n");
|
||||||
#endif
|
#endif
|
||||||
//clear :
|
//clear :
|
||||||
ck_pr_cas_int(&gc_stage, STAGE_RESTING, STAGE_CLEAR_OR_MARKING);
|
ck_pr_cas_int(&gc_stage, STAGE_RESTING, STAGE_CLEAR_OR_MARKING);
|
||||||
|
@ -1368,9 +1403,9 @@ void gc_collector()
|
||||||
total_free = cached_heap_free_sizes[HEAP_SM] +
|
total_free = cached_heap_free_sizes[HEAP_SM] +
|
||||||
cached_heap_free_sizes[HEAP_MED] + cached_heap_free_sizes[HEAP_REST];
|
cached_heap_free_sizes[HEAP_MED] + cached_heap_free_sizes[HEAP_REST];
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"sweep done, total_size = %zu, total_free = %zu, freed = %zu, elapsed = %zu\n",
|
"sweep done, total_size = %zu, total_free = %zu, freed = %zu, elapsed = %ld\n",
|
||||||
total_size, total_free, freed,
|
total_size, total_free, freed,
|
||||||
time(NULL) - gc_collector_start);
|
(time(NULL) - gc_collector_start));
|
||||||
#endif
|
#endif
|
||||||
#if GC_DEBUG_TRACE
|
#if GC_DEBUG_TRACE
|
||||||
fprintf(stderr, "cleaning up any old thread data\n");
|
fprintf(stderr, "cleaning up any old thread data\n");
|
||||||
|
|
Loading…
Add table
Reference in a new issue