Changeset 46f1d20 for src/examples/gc_no_raii/src/internal/collector.c
- Timestamp:
- Sep 9, 2016, 11:50:04 AM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- ddcfb88
- Parents:
- 850fda6
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/internal/collector.c
r850fda6 r46f1d20 25 25 gc_object_header* obj = gc_get_object_ptr((void*)target->ptr); 26 26 27 check( gc_is_valide(obj));27 check(is_valid(obj)); 28 28 29 29 gcpointer_t** prev_next_ptr = managed ? &obj->type_chain : &obj->root_chain; … … 38 38 void* gc_allocate(size_t target_size) 39 39 { 40 sout | "Allocating " | target_size | " bytes" | endl;40 // sout | "Allocating " | target_size | " bytes" | endl; 41 41 42 42 size_t size = gc_compute_size(target_size + sizeof(gc_object_header)); 43 43 44 sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;45 sout | "Actual allocation size: " | size | " bytes" | endl;44 // sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl; 45 // sout | "Actual allocation size: " | size | " bytes" | endl; 46 46 47 47 check(size < POOL_SIZE_BYTES); … … 60 60 if((intptr_t)(block = gc_try_allocate(gc, size))) return gc_finish_alloc_block(block, size, target_size); 61 61 62 checkf( false, "ERROR: allocation in new pool failed");62 checkf( (int) 0, "ERROR: allocation in new pool failed"); 63 63 64 64 return NULL; … … 67 67 void* gc_finish_alloc_block(void* block, size_t actual_size, size_t target_size) 68 68 { 69 void* data = (void*)(((intptr_t)block) + sizeof(gc_object_header));69 intptr_t data = ((intptr_t)block) + sizeof(gc_object_header); 70 70 void* header = block; 71 71 72 check( ((intptr_t)data)> ((intptr_t)block));73 check( ((intptr_t)data)>= ((intptr_t)header));74 check( is_aligned(data));75 check( ((intptr_t)data) + target_size <= ((intptr_t)block) + actual_size);72 check( data > ((intptr_t)block)); 73 check( data >= ((intptr_t)header)); 74 check( gc_is_aligned( (void*)data ) ); 75 check( data + target_size <= ((intptr_t)block) + actual_size ); 76 76 77 77 gc_object_header* obj = placement_ctor(header, actual_size); 78 78 79 79 (void)obj; //remove unsused warning since this is for debug 80 check(obj == g et_object_ptr(data));80 check(obj == gc_get_object_ptr( (void*)data )); 81 81 82 82 gc_register_allocation(gc_get_state(), actual_size); 83 83 84 return data;84 return (void*)data; 85 85 } 86 86 … … 119 119 check(!ptr->forward); 120 120 check(!ptr->is_forwarded); 121 check(gc_ is_from_space(gc_pool_of(ptr)));121 check(gc_pool_is_from_space(gc_pool_of(ptr))); 122 122 123 123 gc_memory_pool* pool = gc_pool_of(ptr)->mirror; … … 143 143 check(((intptr_t)field) < ((intptr_t)((intptr_t)object) + object->size)); 144 144 145 check(gc_is_in_to_space(gc_get_state(), & type->ptr));145 check(gc_is_in_to_space(gc_get_state(), &field->ptr)); 146 146 147 147 intptr_t* ref = &field->ptr;
Note: See TracChangeset
for help on using the changeset viewer.