mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-08 13:37:33 +02:00
Added debugging
This commit is contained in:
parent
ab5d12b896
commit
f6e14ef3a8
3 changed files with 20 additions and 14 deletions
26
gc.c
26
gc.c
|
@ -345,7 +345,7 @@ void *gc_alloc(gc_heap *h, size_t size, char *obj, gc_thread_data *thd, int *hea
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if GC_DEBUG_TRACE
|
#if GC_DEBUG_TRACE
|
||||||
fprintf(stdout, "alloc %p size = %d, obj=%p, tag=%ld\n", result, size, obj, type_of(obj));
|
fprintf(stdout, "alloc %p size = %d, obj=%p, tag=%ld, mark=%d\n", result, size, obj, type_of(obj), mark(((object)result)));
|
||||||
//// TODO: Debug check, remove (ifdef it) once GC is stabilized
|
//// TODO: Debug check, remove (ifdef it) once GC is stabilized
|
||||||
//if (is_value_type(result)) {
|
//if (is_value_type(result)) {
|
||||||
// printf("Invalid allocated address - is a value type %p\n", result);
|
// printf("Invalid allocated address - is a value type %p\n", result);
|
||||||
|
@ -704,7 +704,7 @@ void gc_stack_mark_gray3(gc_thread_data *thd, object obj, int depth)
|
||||||
object high_limit = ((gc_thread_data *)thd)->stack_start;
|
object high_limit = ((gc_thread_data *)thd)->stack_start;
|
||||||
int color;
|
int color;
|
||||||
|
|
||||||
if (is_object_type(obj) && depth < 100) {
|
if (is_object_type(obj) && depth < 15) {
|
||||||
color = mark(obj);
|
color = mark(obj);
|
||||||
#if GC_SAFETY_CHECKS
|
#if GC_SAFETY_CHECKS
|
||||||
if (check_overflow(low_limit, obj) &&
|
if (check_overflow(low_limit, obj) &&
|
||||||
|
@ -718,7 +718,7 @@ void gc_stack_mark_gray3(gc_thread_data *thd, object obj, int depth)
|
||||||
#endif
|
#endif
|
||||||
if (color == gc_color_clear) {
|
if (color == gc_color_clear) {
|
||||||
gc_mark_gray(thd, obj);
|
gc_mark_gray(thd, obj);
|
||||||
printf("marked heap obj from stack barrier %p %d\n", obj, color);
|
//printf("marked heap obj from stack barrier %p %d\n", obj, color);
|
||||||
} else if (color == gc_color_red) {
|
} else if (color == gc_color_red) {
|
||||||
gc_stack_mark_refs_gray(thd, obj, depth + 1);
|
gc_stack_mark_refs_gray(thd, obj, depth + 1);
|
||||||
}
|
}
|
||||||
|
@ -801,7 +801,7 @@ void gc_mut_update(gc_thread_data *thd, object old_obj, object value)
|
||||||
//printf("\n");
|
//printf("\n");
|
||||||
gc_mark_gray(thd, old_obj);
|
gc_mark_gray(thd, old_obj);
|
||||||
// TODO: need this too???
|
// TODO: need this too???
|
||||||
//gc_stack_mark_gray(thd, value);
|
gc_stack_mark_gray(thd, value);
|
||||||
} else if (stage == STAGE_TRACING) {
|
} else if (stage == STAGE_TRACING) {
|
||||||
//printf("DEBUG - GC async tracing marking heap obj %p ", old_obj);
|
//printf("DEBUG - GC async tracing marking heap obj %p ", old_obj);
|
||||||
//Cyc_display(old_obj, stdout);
|
//Cyc_display(old_obj, stdout);
|
||||||
|
@ -1105,8 +1105,6 @@ void gc_collector()
|
||||||
#if GC_DEBUG_TRACE
|
#if GC_DEBUG_TRACE
|
||||||
time_t sweep_start = time(NULL);
|
time_t sweep_start = time(NULL);
|
||||||
#endif
|
#endif
|
||||||
// TODO: what kind of sync is required here?
|
|
||||||
|
|
||||||
//clear :
|
//clear :
|
||||||
gc_stage = STAGE_CLEAR_OR_MARKING;
|
gc_stage = STAGE_CLEAR_OR_MARKING;
|
||||||
// exchange values of markColor and clearColor
|
// exchange values of markColor and clearColor
|
||||||
|
@ -1118,16 +1116,24 @@ void gc_collector()
|
||||||
printf("DEBUG - swap clear %d / mark %d\n", gc_color_clear, gc_color_mark);
|
printf("DEBUG - swap clear %d / mark %d\n", gc_color_clear, gc_color_mark);
|
||||||
#endif
|
#endif
|
||||||
gc_handshake(STATUS_SYNC1);
|
gc_handshake(STATUS_SYNC1);
|
||||||
//printf("DEBUG - after handshake sync 1\n");
|
#if GC_DEBUG_TRACE
|
||||||
|
printf("DEBUG - after handshake sync 1\n");
|
||||||
|
#endif
|
||||||
//mark :
|
//mark :
|
||||||
gc_handshake(STATUS_SYNC2);
|
gc_handshake(STATUS_SYNC2);
|
||||||
//printf("DEBUG - after handshake sync 2\n");
|
#if GC_DEBUG_TRACE
|
||||||
|
printf("DEBUG - after handshake sync 2\n");
|
||||||
|
#endif
|
||||||
gc_stage = STAGE_TRACING;
|
gc_stage = STAGE_TRACING;
|
||||||
gc_post_handshake(STATUS_ASYNC);
|
gc_post_handshake(STATUS_ASYNC);
|
||||||
//printf("DEBUG - after post_handshake aync\n");
|
#if GC_DEBUG_TRACE
|
||||||
|
printf("DEBUG - after post_handshake aync\n");
|
||||||
|
#endif
|
||||||
gc_mark_globals();
|
gc_mark_globals();
|
||||||
gc_wait_handshake();
|
gc_wait_handshake();
|
||||||
//printf("DEBUG - after wait_handshake aync\n");
|
#if GC_DEBUG_TRACE
|
||||||
|
printf("DEBUG - after wait_handshake aync\n");
|
||||||
|
#endif
|
||||||
//trace :
|
//trace :
|
||||||
gc_collector_trace();
|
gc_collector_trace();
|
||||||
#if GC_DEBUG_TRACE
|
#if GC_DEBUG_TRACE
|
||||||
|
|
|
@ -180,8 +180,8 @@ gc_heap *gc_get_heap();
|
||||||
//void gc_collector()
|
//void gc_collector()
|
||||||
|
|
||||||
/* GC debugging flags */
|
/* GC debugging flags */
|
||||||
#define GC_DEBUG_TRACE 0
|
#define GC_DEBUG_TRACE 1
|
||||||
#define GC_DEBUG_VERBOSE 0
|
#define GC_DEBUG_VERBOSE 1
|
||||||
|
|
||||||
/* Additional runtime checking of the GC system.
|
/* Additional runtime checking of the GC system.
|
||||||
This is here because these checks should not be
|
This is here because these checks should not be
|
||||||
|
|
|
@ -47,7 +47,7 @@ const char *tag_names[21] = { \
|
||||||
|
|
||||||
void Cyc_invalid_type_error(void *data, int tag, object found) {
|
void Cyc_invalid_type_error(void *data, int tag, object found) {
|
||||||
char buf[256];
|
char buf[256];
|
||||||
snprintf(buf, 255, "Invalid type: expected %s, found", tag_names[tag]);
|
snprintf(buf, 255, "Invalid type: expected %s, found (%p) ", tag_names[tag], found);
|
||||||
Cyc_rt_raise2(data, buf, found);
|
Cyc_rt_raise2(data, buf, found);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2415,7 +2415,7 @@ void Cyc_start_thread(gc_thread_data *thd)
|
||||||
void gc_mark_globals()
|
void gc_mark_globals()
|
||||||
{
|
{
|
||||||
#if GC_DEBUG_TRACE
|
#if GC_DEBUG_TRACE
|
||||||
printf("(gc_mark_globals heap: %p size: %d)\n", h, (unsigned int)gc_heap_total_size(h));
|
//printf("(gc_mark_globals heap: %p size: %d)\n", h, (unsigned int)gc_heap_total_size(h));
|
||||||
printf("Cyc_global_variables %p\n", Cyc_global_variables);
|
printf("Cyc_global_variables %p\n", Cyc_global_variables);
|
||||||
#endif
|
#endif
|
||||||
// Mark global variables
|
// Mark global variables
|
||||||
|
|
Loading…
Add table
Reference in a new issue