Changeset 76af36f
- Timestamp:
- Sep 13, 2016, 4:21:26 PM (9 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:
- 4c1403c
- Parents:
- 4ed70597
- Location:
- src/examples/gc_no_raii
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/gcpointers.c
r4ed70597 r76af36f 25 25 check(obj); 26 26 check(is_valid(obj)); 27 check(gc_is_managed(this) == gc_is_managed(obj->root_chain) || !obj->root_chain); 27 check(!obj->root_chain || this->ptr == obj->root_chain->ptr); 28 check(!obj->root_chain || gc_is_managed(this) == gc_is_managed(obj->root_chain)); 28 29 this->next = obj->root_chain; 29 30 obj->root_chain = this; … … 69 70 } 70 71 71 gcpointer_t * gcpointer_assign(gcpointer_t* this, gcpointer_t*rhs)72 gcpointer_t ?=?(gcpointer_t* this, gcpointer_t rhs) 72 73 { 73 if(this != rhs)74 {75 unregister_ptr(this);74 unregister_ptr(this); 75 this->ptr = rhs.ptr; 76 register_ptr(this); 76 77 77 this->ptr = rhs->ptr; 78 79 register_ptr(this); 80 } 81 82 return this; 78 return *this; 83 79 } 84 80 … … 107 103 } 108 104 109 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) *other) {110 (&this->internal) { other ->internal };105 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) other) { 106 (&this->internal) { other.internal }; 111 107 } 112 108 … … 115 111 } 116 112 117 // forall(otype T) gcpointer(T) ?=?(gcpointer(T) this, gcpointer(T) rhs); 113 forall(otype T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs) { 114 this->internal = rhs.internal; 115 return *this; 116 } 118 117 // 119 118 // forall(otype T) T *?(gcpointer(T) this); -
src/examples/gc_no_raii/src/gcpointers.h
r4ed70597 r76af36f 33 33 forall(otype T) void ?{}(gcpointer(T)* this); 34 34 forall(otype T) void ?{}(gcpointer(T)* this, void* address); 35 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) *other);35 forall(otype T) void ?{}(gcpointer(T)* this, gcpointer(T) other); 36 36 forall(otype T) void ^?{}(gcpointer(T)* this); 37 37 forall(otype T) gcpointer(T) ?=?(gcpointer(T)* this, gcpointer(T) rhs); -
src/examples/gc_no_raii/src/internal/card_table.h
r4ed70597 r76af36f 7 7 { 8 8 size_t card = ( ((intptr_t)address) & CARDS_OFFSET_MASK ) >> CARDS_SIZE_EXP; 9 checkf(card < CARDS_COUNT, (const char*)"%lu %lu = (%lx & %lx) >> %lu\n", (size_t)CARDS_COUNT, (size_t)card, (size_t)address, (size_t)CARDS_OFFSET_MASK, (size_t)CARDS_SIZE_EXP); 9 10 check(card < CARDS_COUNT); 10 11 return card; -
src/examples/gc_no_raii/src/internal/collector.h
r4ed70597 r76af36f 1 1 #pragma once 2 2 3 #include <stdlib >3 #include <stdlib.h> 4 4 5 5 #include "tools.h" -
src/examples/gc_no_raii/src/internal/memory_pool.c
r4ed70597 r76af36f 87 87 intptr_t member_add = (intptr_t)member; 88 88 intptr_t start_obj; 89 intptr_t start_obj_add;90 89 91 90 do … … 95 94 check(card != 0 || start_obj); 96 95 card--; 97 start_obj_add = (intptr_t)start_obj;98 96 } 99 while(start_obj _add > member_add || start_obj_add != 0);97 while(start_obj > member_add || !(start_obj)); 100 98 101 99 check( start_obj ); -
src/examples/gc_no_raii/src/internal/object_header.c
r4ed70597 r76af36f 90 90 while(root) 91 91 { 92 check (gc_get_object_ptr( (void*)root->ptr ) ==this);92 checkf(gc_get_object_ptr( (void*)root->ptr ) == this, (const char*)"Expected %lX got %lX\n", gc_get_object_ptr( (void*)root->ptr ), this); 93 93 94 94 root = root->next; … … 106 106 return true; 107 107 } 108 #else 109 #error blarg 108 110 #endif -
src/examples/gc_no_raii/src/internal/object_header.h
r4ed70597 r76af36f 49 49 50 50 #ifndef NDEBUG 51 bool is_valid( struct gc_object_header* obj);51 bool is_valid(const gc_object_header* const this); 52 52 #endif -
src/examples/gc_no_raii/src/internal/state.c
r4ed70597 r76af36f 76 76 gc_object_header* gc_get_object_for_ref(gc_state* state, void* member) 77 77 { 78 volatile int stage = 0; 78 79 intptr_t target = ((intptr_t)member); 79 80 if(!gc_is_in_heap(state, member)) return NULL; 81 stage++; 80 82 81 83 gc_memory_pool* pool = gc_pool_of(member); 84 stage++; 82 85 gc_pool_object_iterator it = gc_pool_iterator_for(pool, member); 86 stage++; 83 87 gc_pool_object_iterator end = end(pool); 88 stage++; 84 89 85 90 while(it != end) 86 91 { 87 92 gc_object_header* object = *it; 93 check(object); 94 check( is_valid(object) ); 88 95 { 89 96 intptr_t start = ((intptr_t)object); … … 94 101 } 95 102 } 103 stage++; 96 104 ++it; 97 105 } … … 273 281 } 274 282 275 check(size + gc_pool_size_used(pool) == gc_pool_size_total(pool)); 283 checkf(size + gc_pool_size_left(pool) == gc_pool_size_total(pool), 284 (const char*)"expected %lu + %lu == %lu\n", 285 (size_t)size, 286 (size_t)gc_pool_size_left(pool), 287 (size_t)gc_pool_size_total(pool)); 276 288 277 289 pool = pool->next; -
src/examples/gc_no_raii/test/badlll.c
r4ed70597 r76af36f 11 11 typedef gcpointer(List_t) LLL; 12 12 13 #define MAX (1024 * 1 024)13 #define MAX (1024 * 1) 14 14 15 15 LLL buildLLL(int sz) 16 16 { 17 17 int i = 0; 18 LLL ll0 , lll, llc;18 LLL ll0; 19 19 20 20 gcmalloc( &ll0 ); 21 21 List_t* ll0_ptr = get( &ll0 ); 22 22 ll0_ptr->val = i; 23 lll = ll0;23 LLL lll = ll0; 24 24 25 25 for (i = 1; i < sz; i++) 26 26 { 27 LLL llc; 27 28 gcmalloc( &llc ); 28 29 List_t* llc_ptr = get( &llc );
Note: See TracChangeset
for help on using the changeset viewer.