Changeset 1eba452 for src/examples/gc_no_raii/src/internal/object_header.c
- Timestamp:
- Sep 15, 2016, 10:29:43 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:
- fc4a0fa, fd782b2
- Parents:
- 96a10cd (diff), 50c5cf3 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/examples/gc_no_raii/src/internal/object_header.c
r96a10cd r1eba452 3 3 #include <stdint.h> 4 4 5 #include "collector.h" 5 6 #include "globals.h" 6 7 #include "gcpointers.h" … … 8 9 void ctor(gc_object_header* const this, size_t inSize) 9 10 { 10 #if _DEBUG11 #ifndef NDEBUG 11 12 this->canary_start = CANARY_VALUE; 12 13 #endif … … 18 19 this->is_forwarded = false; 19 20 20 #if _DEBUG21 #ifndef NDEBUG 21 22 this->canary_end = CANARY_VALUE; 22 23 #endif … … 25 26 void copy_ctor(gc_object_header* const this, const gc_object_header* const other) 26 27 { 27 #if _DEBUG28 #ifndef NDEBUG 28 29 this->canary_start = CANARY_VALUE; 29 30 #endif … … 35 36 this->is_forwarded = false; 36 37 37 #if _DEBUG38 #ifndef NDEBUG 38 39 this->canary_end = CANARY_VALUE; 39 40 #endif … … 42 43 while(root) 43 44 { 44 check(g et_object_ptr(root->ptr) == other);45 check(gc_get_object_ptr( (void*)root->ptr ) == other); 45 46 root->ptr = ((intptr_t)this) + sizeof(gc_object_header); 46 47 47 check(g et_object_ptr(root->ptr) == this);48 check(gc_get_object_ptr( (void*)root->ptr ) == this); 48 49 root = root->next; 49 50 } … … 56 57 57 58 size_t offset = (intptr_t)type - (intptr_t)other; 58 check(offset < size);59 check(offset < this->size); 59 60 60 61 gcpointer_t* member_ptr = (gcpointer_t*)( (intptr_t)this + offset ); … … 63 64 64 65 size_t next_offset = type->next ? (intptr_t)type->next - (intptr_t)other : 0; 65 check(next_offset < size);66 check(next_offset < this->size); 66 67 67 68 gcpointer_t* next_ptr = type->next ? (gcpointer_t*)((intptr_t)this + next_offset) : NULL; … … 73 74 } 74 75 75 check(is_valid e(this));76 check(is_valid(this)); 76 77 } 77 78 78 #if _DEBUG79 bool is_valid e(const gc_object_header* const this)79 #ifndef NDEBUG 80 bool is_valid(const gc_object_header* const this) 80 81 { 81 check( this->canary_start ==CANARY_VALUE);82 check( this->canary_end ==CANARY_VALUE);82 check((intptr_t)this->canary_start == (intptr_t)CANARY_VALUE); 83 check((intptr_t)this->canary_end == (intptr_t)CANARY_VALUE); 83 84 84 check(this->is_forwarded == ( this->forward != nullptr));85 check(this->is_forwarded == ( (intptr_t)this->forward != (intptr_t)NULL)); 85 86 86 87 check(this->size < POOL_SIZE_BYTES); … … 89 90 while(root) 90 91 { 91 check (get_object_ptr(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); 92 93 93 94 root = root->next; 94 95 } 95 96 96 gcpointer_t* type = t ype_chain;97 gcpointer_t* type = this->type_chain; 97 98 while(type) 98 99 { 99 100 check((intptr_t)type > (intptr_t)this); 100 check((intptr_t)type < (intptr_t)(( intptr_t)this +size));101 check((intptr_t)type < (intptr_t)(((intptr_t)this) + this->size)); 101 102 102 103 type = type->next; … … 105 106 return true; 106 107 } 108 #else 109 #error blarg 107 110 #endif
Note: See TracChangeset
for help on using the changeset viewer.