Potential speedup?

Attempt to speed up gc_collector_mark_gray by forcing it to be inlined via a C macro. I am skeptical the compiler cannot do this already but the change seems to speed the earley benchmark up by several seconds.
This commit is contained in:
Justin Ethier 2017-01-11 18:03:13 +00:00
parent f6fc268820
commit e6a145eeac

35
gc.c
View file

@ -1183,21 +1183,28 @@ void gc_collector_trace()
}
}
static void gc_collector_mark_gray(object parent, object obj)
{
// "Color" objects gray by adding them to the mark stack for further processing.
//
// Note that stack objects are always colored red during creation, so
// they should never be added to the mark stack. Which would be bad because it
// could lead to stack corruption.
if (is_object_type(obj) && mark(obj) == gc_color_clear) {
mark_stack = vpbuffer_add(mark_stack, &mark_stack_len, mark_stack_i++, obj);
#if GC_DEBUG_VERBOSE
fprintf(stderr, "mark gray parent = %p (%d) obj = %p\n", parent,
type_of(parent), obj);
#endif
// "Color" objects gray by adding them to the mark stack for further processing.
//
// Note that stack objects are always colored red during creation, so
// they should never be added to the mark stack. Which would be bad because it
// could lead to stack corruption.
//
// Attempt to speed this up by forcing an inline
//
#define gc_collector_mark_gray(parent, gobj) \
if (is_object_type(gobj) && mark(gobj) == gc_color_clear) { \
mark_stack = vpbuffer_add(mark_stack, &mark_stack_len, mark_stack_i++, gobj); \
}
}
//static void gc_collector_mark_gray(object parent, object obj)
//{
// if (is_object_type(obj) && mark(obj) == gc_color_clear) {
// mark_stack = vpbuffer_add(mark_stack, &mark_stack_len, mark_stack_i++, obj);
//#if GC_DEBUG_VERBOSE
// fprintf(stderr, "mark gray parent = %p (%d) obj = %p\n", parent,
// type_of(parent), obj);
//#endif
// }
//}
// TODO: seriously consider changing the mark() macro to color(),
// and sync up the header variable. that would make all of this code