Branch: Tag:

2017-11-11

2017-11-11 16:35:01 by Tobias S. Josefowitz <tobij@tobij.de>

GC: Inline markers into datastructures

Initial work is done. This may have worse performance characteristics
for now. Futher work will use the block allocator provided iterator
instead of linked lists to visit all objects and potentially optimize
the memory layout of the marker struct.

28:   #include "pike_compiler.h"   #include "block_allocator.h"   #include "bitvector.h" + #include "gc_header.h"      #ifdef PIKE_DEBUG   #define PIKE_TYPE_DEBUG
259:      ATTRIBUTE((malloc))   PMOD_EXPORT struct pike_type * alloc_pike_type(void) { -  return ba_alloc(&type_allocator); +  struct pike_type *t = ba_alloc(&type_allocator); +  gc_init_marker(&t->m); +  return t;   }      PMOD_EXPORT void count_memory_in_pike_types(size_t *n, size_t *s) {
555:    debug_malloc_pass(t = ba_alloc(&type_allocator));       t->refs = 0; +  gc_init_marker(&t->m);    add_ref(t); /* For DMALLOC... */    t->type = type;    t->flags = 0;
9090: Inside #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP)
   case T_OR:    case T_AND:    case PIKE_T_RING: +  debug_gc_check (t->car, " as car in a type"); +  debug_gc_check (t->cdr, " as cdr in a type"); +  break;    case PIKE_T_ATTRIBUTE:    case PIKE_T_NAME: -  + #ifdef PIKE_DEBUG +  /* this is a string and without PIKE_DEBUG +  * they are not touched by the GC */    debug_gc_check (t->car, " as car in a type"); -  + #endif    debug_gc_check (t->cdr, " as cdr in a type");    break;    case T_ARRAY:
9145: Inside #if defined (PIKE_DEBUG) || defined (DO_PIKE_CLEANUP)
   for(t = pike_type_hash[e]; t; t=t->next) {    if (gc_keep_markers) {    /* Make sure that leaked types also have markers at cleanup... */ -  (void)pmod_get_marker(t); +  (void)get_marker(t);    }    gc_check_type(t);    }