Changeset 16cfd8c for src/examples/gc_no_raii/src/internal/state.c
- Timestamp:
- Apr 21, 2016, 4:54:33 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 8a74081
- Parents:
- 8c8b614
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/internal/state.c
r8c8b614 r16cfd8c 12 12 #include "globals.h" 13 13 #include "memory_pool.h" 14 // #include "memory_pool_iterator.h"15 14 #include "object_header.h" 16 15 … … 46 45 } 47 46 48 bool gc_state_is_in_heap(const gc_state* const this, void* address) 47 void dtor(gc_state *const this) 48 { 49 dtor(&this->pools_table); 50 this->is_initialized = false; 51 } 52 53 bool gc_is_in_heap(const gc_state* const this, const void* const address) 49 54 { 50 55 gc_memory_pool* target_pool = gc_pool_of(address); … … 56 61 } 57 62 58 bool gc_ state_is_in_to_space(const gc_state* const this, void*address)63 bool gc_is_in_to_space(const gc_state* const this, const void* const address) 59 64 { 60 65 gc_memory_pool* target_pool = gc_pool_of(address); … … 73 78 gc_memory_pool* pool = gc_pool_of(member); 74 79 gc_pool_object_iterator it = gc_pool_iterator_for(pool, member); 75 gc_pool_object_iterator end = gc_pool_end(pool);80 gc_pool_object_iterator end = end(pool); 76 81 77 82 while(it != end) … … 94 99 } 95 100 96 void* gc_try_allocate(gc_state *const this, size_t size)101 void* gc_try_allocate(gc_state* const this, size_t size) 97 102 { 98 103 gc_memory_pool* pool = this->from_space; … … 109 114 } 110 115 111 void gc_ state_allocate_pool(gc_state *const this)116 void gc_allocate_pool(gc_state *const this) 112 117 { 113 118 gc_memory_pool* old_from_space = this->from_space; … … 117 122 this->to_space = (gc_memory_pool*)(pal_allocPool(POOL_SIZE_BYTES, 1)); 118 123 119 gc_memory_pool_ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space, this->from_code);120 gc_memory_pool_ctor(this->to_space, POOL_SIZE_BYTES, old_to_space, this->from_space, (~this->from_code) & 0x01);124 ctor(this->from_space, POOL_SIZE_BYTES, old_from_space, this->to_space, this->from_code); 125 ctor(this->to_space, POOL_SIZE_BYTES, old_to_space, this->from_space, (~this->from_code) & 0x01); 121 126 122 127 this->total_space += gc_pool_size_used(this->from_space); … … 126 131 } 127 132 128 void gc_ state_collect(gc_state* const this)133 void gc_collect(gc_state* const this) 129 134 { 130 135 // DEBUG("collecting"); … … 149 154 gc_state_calc_usage(this); 150 155 151 if(gc_needs_collect(this)) gc_ state_allocate_pool(this);156 if(gc_needs_collect(this)) gc_allocate_pool(this); 152 157 153 158 // DEBUG("done"); … … 281 286 while(potential_ref < (void**)pool->m_free) 282 287 { 283 check(!gc_is_in_heap( *potential_ref));288 check(!gc_is_in_heap(this, *potential_ref)); 284 289 potential_ref++; 285 290 }
Note: See TracChangeset
for help on using the changeset viewer.