mirror of
https://github.com/justinethier/cyclone.git
synced 2025-07-11 23:07:36 +02:00
Decrease memory usage of object header
This commit is contained in:
parent
55c884ef4e
commit
b14d25afc9
3 changed files with 12 additions and 12 deletions
10
gc.c
10
gc.c
|
@ -376,7 +376,7 @@ char *gc_copy_obj(object dest, char *obj, gc_thread_data *thd)
|
||||||
case symbol_tag:
|
case symbol_tag:
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "gc_copy_obj: bad tag obj=%p obj.tag=%ld\n",(object) obj, type_of(obj));
|
fprintf(stderr, "gc_copy_obj: bad tag obj=%p obj.tag=%d\n",(object) obj, type_of(obj));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return (char *)obj;
|
return (char *)obj;
|
||||||
|
@ -493,7 +493,7 @@ void *gc_alloc(gc_heap_root *hrt, size_t size, char *obj, gc_thread_data *thd, i
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#if GC_DEBUG_VERBOSE
|
#if GC_DEBUG_VERBOSE
|
||||||
fprintf(stderr, "alloc %p size = %zu, obj=%p, tag=%ld, mark=%d\n", result, size, obj, type_of(obj), mark(((object)result)));
|
fprintf(stderr, "alloc %p size = %zu, obj=%p, tag=%d, mark=%d\n", result, size, obj, type_of(obj), mark(((object)result)));
|
||||||
// Debug check, should no longer be necessary
|
// Debug check, should no longer be necessary
|
||||||
//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);
|
||||||
|
@ -538,7 +538,7 @@ size_t gc_allocated_bytes(object obj, gc_free_list *q, gc_free_list *r)
|
||||||
if (t == mutex_tag) return gc_heap_align(sizeof(mutex_type));
|
if (t == mutex_tag) return gc_heap_align(sizeof(mutex_type));
|
||||||
if (t == cond_var_tag) return gc_heap_align(sizeof(cond_var_type));
|
if (t == cond_var_tag) return gc_heap_align(sizeof(cond_var_type));
|
||||||
|
|
||||||
fprintf(stderr, "gc_allocated_bytes: unexpected object %p of type %ld\n", obj, t);
|
fprintf(stderr, "gc_allocated_bytes: unexpected object %p of type %d\n", obj, t);
|
||||||
exit(1);
|
exit(1);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -626,7 +626,7 @@ size_t gc_sweep(gc_heap *h, int heap_type, size_t *sum_freed_ptr)
|
||||||
|
|
||||||
if (mark(p) == gc_color_clear) {
|
if (mark(p) == gc_color_clear) {
|
||||||
#if GC_DEBUG_VERBOSE
|
#if GC_DEBUG_VERBOSE
|
||||||
fprintf(stderr, "sweep is freeing unmarked obj: %p with tag %ld\n", p, type_of(p));
|
fprintf(stderr, "sweep is freeing unmarked obj: %p with tag %d\n", p, type_of(p));
|
||||||
#endif
|
#endif
|
||||||
mark(p) = gc_color_blue; // Needed?
|
mark(p) = gc_color_blue; // Needed?
|
||||||
if (type_of(p) == mutex_tag) {
|
if (type_of(p) == mutex_tag) {
|
||||||
|
@ -1086,7 +1086,7 @@ void gc_collector_mark_gray(object parent, object obj)
|
||||||
if (is_object_type(obj) && mark(obj) == gc_color_clear) {
|
if (is_object_type(obj) && mark(obj) == gc_color_clear) {
|
||||||
mark_stack = vpbuffer_add(mark_stack, &mark_stack_len, mark_stack_i++, obj);
|
mark_stack = vpbuffer_add(mark_stack, &mark_stack_len, mark_stack_i++, obj);
|
||||||
#if GC_DEBUG_VERBOSE
|
#if GC_DEBUG_VERBOSE
|
||||||
fprintf(stderr, "mark gray parent = %p (%ld) obj = %p\n", parent, type_of(parent), obj);
|
fprintf(stderr, "mark gray parent = %p (%d) obj = %p\n", parent, type_of(parent), obj);
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -89,7 +89,7 @@ enum object_tag {
|
||||||
};
|
};
|
||||||
|
|
||||||
// Define the size of object tags
|
// Define the size of object tags
|
||||||
typedef long tag_type;
|
typedef unsigned char tag_type;
|
||||||
|
|
||||||
/* Threading */
|
/* Threading */
|
||||||
typedef enum { CYC_THREAD_STATE_NEW, CYC_THREAD_STATE_RUNNABLE,
|
typedef enum { CYC_THREAD_STATE_NEW, CYC_THREAD_STATE_RUNNABLE,
|
||||||
|
@ -166,7 +166,7 @@ struct gc_heap_root_t {
|
||||||
|
|
||||||
typedef struct gc_header_type_t gc_header_type;
|
typedef struct gc_header_type_t gc_header_type;
|
||||||
struct gc_header_type_t {
|
struct gc_header_type_t {
|
||||||
unsigned int mark; // mark bits (TODO: only need 2, reduce size of type?)
|
unsigned char mark; // mark bits (only need 2)
|
||||||
unsigned char grayed; // stack object to be grayed when moved to heap
|
unsigned char grayed; // stack object to be grayed when moved to heap
|
||||||
};
|
};
|
||||||
#define mark(x) (((list) x)->hdr.mark)
|
#define mark(x) (((list) x)->hdr.mark)
|
||||||
|
|
10
runtime.c
10
runtime.c
|
@ -636,7 +636,7 @@ object Cyc_display(object x, FILE *port)
|
||||||
fprintf(port, ")");
|
fprintf(port, ")");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
fprintf(port, "Cyc_display: bad tag x=%ld\n", ((closure)x)->tag);
|
fprintf(port, "Cyc_display: bad tag x=%d\n", ((closure)x)->tag);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return quote_void;}
|
return quote_void;}
|
||||||
|
@ -2632,7 +2632,7 @@ object apply(void *data, object cont, object func, object args){
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
printf("Invalid object type %ld\n", type_of(func));
|
printf("Invalid object type %d\n", type_of(func));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return NULL; // Never reached
|
return NULL; // Never reached
|
||||||
|
@ -2834,7 +2834,7 @@ char *gc_move(char *obj, gc_thread_data *thd, int *alloci, int *heap_grown) {
|
||||||
case boolean_tag: break;
|
case boolean_tag: break;
|
||||||
case symbol_tag: break; // JAE TODO: raise an error here? Should not be possible in real code, though (IE, without GC DEBUG flag)
|
case symbol_tag: break; // JAE TODO: raise an error here? Should not be possible in real code, though (IE, without GC DEBUG flag)
|
||||||
default:
|
default:
|
||||||
fprintf(stderr, "gc_move: bad tag obj=%p obj.tag=%ld\n",(object) obj, type_of(obj));
|
fprintf(stderr, "gc_move: bad tag obj=%p obj.tag=%d\n",(object) obj, type_of(obj));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
return (char *)obj;
|
return (char *)obj;
|
||||||
|
@ -2908,7 +2908,7 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, obje
|
||||||
} else if (type_of(o) == forward_tag) {
|
} else if (type_of(o) == forward_tag) {
|
||||||
// Already transported, skip
|
// Already transported, skip
|
||||||
} else {
|
} else {
|
||||||
printf("Unexpected type %ld transporting mutation\n", type_of(o));
|
printf("Unexpected type %d transporting mutation\n", type_of(o));
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2969,7 +2969,7 @@ int gc_minor(void *data, object low_limit, object high_limit, closure cont, obje
|
||||||
case boolean_tag:
|
case boolean_tag:
|
||||||
default:
|
default:
|
||||||
fprintf(stderr,
|
fprintf(stderr,
|
||||||
"GC: unexpected object type %ld for object %p\n", type_of(obj), obj);
|
"GC: unexpected object type %d for object %p\n", type_of(obj), obj);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
scani++;
|
scani++;
|
||||||
|
|
Loading…
Add table
Reference in a new issue