Changeset c44e622
- Timestamp:
- Feb 24, 2016, 10:36:17 AM (9 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:
- ae7f1e0
- Parents:
- d41280e
- Location:
- src/examples/gc_no_raii
- Files:
-
- 1 added
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/premake4.lua
rd41280e rc44e622 42 42 linkoptions (linkOptionList) 43 43 includedirs (includeDirList) 44 files { " ../fstream.c", "../iostream.c", "../iterator.c", "src/**.c" }44 files { "src/**.c" } 45 45 46 46 configuration "debug" -
src/examples/gc_no_raii/src/gcpointers.c
rd41280e rc44e622 3 3 #include "gc.h" 4 4 #include "internal/collector.h" 5 #include "internal/object_header.h"5 //#include "internal/object_header.h" 6 6 // #include "internal/state.h" 7 7 /* 8 8 void register_ptr(gcpointer_t* this) 9 9 { 10 if(gcpointer_null(this)) return;11 12 _Bool managed = gc_is_managed(this);13 14 if(managed)15 {16 gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this);17 check(obj);18 check(gc_obj_is_valide(obj));19 check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL);20 this->next = obj->type_chain;21 obj->type_chain = this;22 check(obj->is_valide());23 }24 else25 {26 gc_object_header* obj = gc_get_object_ptr((void*)this->ptr);27 check(obj);28 check(gc_obj_is_valide(obj));29 check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL);30 this->next = obj->root_chain;31 obj->root_chain = this;32 check(gc_obj_is_valide(obj));33 }10 // if(gcpointer_null(this)) return; 11 // 12 // _Bool managed = gc_is_managed(this); 13 // 14 // if(managed) 15 // { 16 // gc_object_header* obj = gc_get_object_for_ref(gc_get_state(), (void*)this); 17 // check(obj); 18 // check(gc_obj_is_valide(obj)); 19 // check(gc_is_managed(this) == gc_is_managed(obj->type_chain) || obj->type_chain == NULL); 20 // this->next = obj->type_chain; 21 // obj->type_chain = this; 22 // check(obj->is_valide()); 23 // } 24 // else 25 // { 26 // gc_object_header* obj = gc_get_object_ptr((void*)this->ptr); 27 // check(obj); 28 // check(gc_obj_is_valide(obj)); 29 // check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || obj->root_chain == NULL); 30 // this->next = obj->root_chain; 31 // obj->root_chain = this; 32 // check(gc_obj_is_valide(obj)); 33 // } 34 34 } 35 35 36 36 void unregister_ptr(gcpointer_t* this) 37 37 { 38 if(gcpointer_null(this)) return;39 40 gcpointer_t** prev_next_ptr = gc_find_previous_ref(this);41 check((*prev_next_ptr) == this);42 43 (*prev_next_ptr) = this->next;38 // if(gcpointer_null(this)) return; 39 // 40 // gcpointer_t** prev_next_ptr = gc_find_previous_ref(this); 41 // check((*prev_next_ptr) == this); 42 // 43 // (*prev_next_ptr) = this->next; 44 44 } 45 45 … … 99 99 { 100 100 return this->ptr == (intptr_t)NULL; 101 } 101 }*/ -
src/examples/gc_no_raii/src/gctest.c
rd41280e rc44e622 1 #include <fstream> 1 2 2 3 #include "gc.h" 3 #include "fstream.h"4 4 5 5 int main() { -
src/examples/gc_no_raii/src/internal/collector.c
rd41280e rc44e622 6 6 #include <string.h> 7 7 8 #include "fstream.h"8 #include <fstream> 9 9 10 10 #include "memory_pool.h" -
src/examples/gc_no_raii/src/internal/collector.h
rd41280e rc44e622 6 6 #include "tools.h" 7 7 8 #include "gcpointers.h" 9 #include "internal/collector.h" 10 #include "internal/gc_tools.h" 11 #include "internal/globals.h" 8 //#include "gcpointers.h" 9 //#include "internal/gc_tools.h" 10 //#include "internal/globals.h" 12 11 #include "internal/object_header.h" 13 #include "internal/state.h"12 //#include "internal/state.h" 14 13 #include "tools/worklist.h" 15 14 /* 16 15 inline bool gc_is_managed(void* address) 17 16 { … … 27 26 inline gc_memory_pool* gc_pool_of(void* address) 28 27 { 29 return (struct gc_memory_pool*)(((intptr_t)address) & POOL_PTR_MASK);28 //return (struct gc_memory_pool*)(((intptr_t)address) & POOL_PTR_MASK); 30 29 } 31 30 … … 47 46 48 47 void gc_scan_object(struct gc_object_header* object, worklist_t* worklist); 48 */ -
src/examples/gc_no_raii/src/internal/state.c
rd41280e rc44e622 1 1 #include "state.h" 2 2 3 #include <stdlib.h>4 5 // general purpouse includes6 #include "tools.h"7 8 // platform abstraction includes9 #include "allocate-pool.h"10 11 // gc internal includes12 // #include "globals.h"13 #include "memory_pool.h"3 // #include <stdlib.h> 4 // 5 // //general purpouse includes 6 // #include "tools.h" 7 // 8 // //platform abstraction includes 9 // #include "allocate-pool.h" 10 // 11 // //gc internal includes 12 // // #include "globals.h" 13 // #include "memory_pool.h" 14 14 // #include "memory_pool_iterator.h" 15 15 // #include "object_header.h" … … 25 25 // #endif 26 26 27 void gc_state_ctor(gc_state* state)28 {29 state->from_code = 0;30 state->to_space = NULL;31 state->from_space = NULL;32 state->total_space = 0;33 state->used_space = 0;34 // state->pools_table();35 36 gc_allocate_pool(state);37 38 state->is_initialized = true;39 }27 // void gc_state_ctor(gc_state* state) 28 // { 29 // state->from_code = 0; 30 // state->to_space = NULL; 31 // state->from_space = NULL; 32 // state->total_space = 0; 33 // state->used_space = 0; 34 // // state->pools_table(); 35 // 36 // gc_allocate_pool(state); 37 // 38 // state->is_initialized = true; 39 // } 40 40 41 41 // bool state::is_in_heap(void* address) const … … 59 59 // } 60 60 // 61 gc_object_header* gc_get_object_for_ref(gc_state* state, void* member)62 {63 intptr_t target = ((intptr_t)member);64 if(!gc_is_in_heap(state, member)) return NULL;65 66 gc_memory_pool* pool = gc_pool_of(member);67 gc_pool_object_iterator it = gc_pool_iterator_for(pool, member);68 gc_pool_object_iterator end = gc_pool_end(pool);69 70 while(it != end)71 {72 gc_object_header* object = *it;73 {74 intptr_t start = ((intptr_t)object);75 intptr_t end = ((intptr_t)start + object->size);76 if(start < target && end > target)77 {78 return object;79 }80 }81 ++it;82 }83 84 checkf(false, "is_in_heap() and iterator_for() return inconsistent data");85 abort();86 return NULL;87 }61 // gc_object_header* gc_get_object_for_ref(gc_state* state, void* member) 62 // { 63 // intptr_t target = ((intptr_t)member); 64 // if(!gc_is_in_heap(state, member)) return NULL; 65 // 66 // gc_memory_pool* pool = gc_pool_of(member); 67 // gc_pool_object_iterator it = gc_pool_iterator_for(pool, member); 68 // gc_pool_object_iterator end = gc_pool_end(pool); 69 // 70 // while(it != end) 71 // { 72 // gc_object_header* object = *it; 73 // { 74 // intptr_t start = ((intptr_t)object); 75 // intptr_t end = ((intptr_t)start + object->size); 76 // if(start < target && end > target) 77 // { 78 // return object; 79 // } 80 // } 81 // ++it; 82 // } 83 // 84 // checkf(false, "is_in_heap() and iterator_for() return inconsistent data"); 85 // abort(); 86 // return NULL; 87 // } 88 88 // 89 89 // void* state::try_allocate(size_t size) -
src/examples/gc_no_raii/src/tools/worklist.h
rd41280e rc44e622 4 4 #include <stdint.h> 5 5 6 #include "vector.h" 7 /* 6 8 typedef intptr_t* worklist_element_t; 7 9 … … 13 15 14 16 void push_back(worklist_t* worklist, worklist_element_t element); 17 */ 18 19 //typedef vector(intptr_t*) worklist_t;
Note: See TracChangeset
for help on using the changeset viewer.