Changes in / [67bfc50:badd22f]
- Files:
-
- 2 added
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/invoke.h
r67bfc50 rbadd22f 26 26 #ifndef _INVOKE_H_ 27 27 #define _INVOKE_H_ 28 29 struct __cfaehm_try_resume_node; 30 struct __cfaehm_base_exception_t; 31 struct exception_context_t { 32 struct __cfaehm_try_resume_node * top_resume; 33 struct __cfaehm_base_exception_t * current_exception; 34 }; 28 35 29 36 struct __stack_context_t { … … 51 58 // base of stack 52 59 void * base; 60 61 // Information for exception handling. 62 struct exception_context_t exception_context; 53 63 }; 54 64 … … 84 94 }; 85 95 86 static inline struct __stack_t * __get_stack( struct $coroutine * cor ) { return (struct __stack_t*)(((uintptr_t)cor->stack.storage) & ((uintptr_t)-2)); } 96 static inline struct __stack_t * __get_stack( struct $coroutine * cor ) { 97 return (struct __stack_t*)(((uintptr_t)cor->stack.storage) & ((uintptr_t)-2)); 98 } 87 99 88 100 // struct which calls the monitor is accepting -
libcfa/src/concurrency/kernel/startup.cfa
r67bfc50 rbadd22f 516 516 ( this.terminated ){ 0 }; 517 517 ( this.runner ){}; 518 init( this, name, _cltr ); 518 519 disable_interrupts(); 520 init( this, name, _cltr ); 521 enable_interrupts( __cfaabi_dbg_ctx ); 519 522 520 523 __cfadbg_print_safe(runtime_core, "Kernel : Starting core %p\n", &this); … … 540 543 free( this.stack ); 541 544 542 deinit( this ); 545 disable_interrupts(); 546 deinit( this ); 547 enable_interrupts( __cfaabi_dbg_ctx ); 543 548 } 544 549 -
libcfa/src/concurrency/ready_queue.cfa
r67bfc50 rbadd22f 150 150 // queues or removing them. 151 151 uint_fast32_t ready_mutate_lock( void ) with(*__scheduler_lock) { 152 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 153 152 154 // Step 1 : lock global lock 153 155 // It is needed to avoid processors that register mid Critical-Section … … 164 166 } 165 167 168 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 166 169 return s; 167 170 } 168 171 169 172 void ready_mutate_unlock( uint_fast32_t last_s ) with(*__scheduler_lock) { 173 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 174 170 175 // Step 1 : release local locks 171 176 // This must be done while the global lock is held to avoid … … 182 187 /*paranoid*/ assert(true == lock); 183 188 __atomic_store_n(&lock, (bool)false, __ATOMIC_RELEASE); 189 190 /* paranoid */ verify( ! kernelTLS.preemption_state.enabled ); 184 191 } 185 192 -
libcfa/src/exception.c
r67bfc50 rbadd22f 10 10 // Created On : Mon Jun 26 15:13:00 2017 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Thr May 21 12:18:00 202013 // Update Count : 2 012 // Last Modified On : Wed Aug 12 13:55:00 2020 13 // Update Count : 21 14 14 // 15 15 … … 28 28 #include <unwind.h> 29 29 #include <bits/debug.hfa> 30 #include "concurrency/invoke.h" 30 31 #include "stdhdr/assert.h" 31 32 … … 59 60 60 61 // Temperary global exception context. Does not work with concurency. 61 struct exception_context_t { 62 struct __cfaehm_try_resume_node * top_resume; 63 64 exception_t * current_exception; 65 int current_handler_index; 66 } static shared_stack = {NULL, NULL, 0}; 62 static struct exception_context_t shared_stack = {NULL, NULL}; 67 63 68 64 // Get the current exception context. … … 122 118 123 119 // MEMORY MANAGEMENT ========================================================= 120 121 struct __cfaehm_node { 122 struct _Unwind_Exception unwind_exception; 123 struct __cfaehm_node * next; 124 int handler_index; 125 }; 126 127 #define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node))) 128 #define EXCEPT_TO_NODE(except) ((struct __cfaehm_node *)(except) - 1) 129 #define UNWIND_TO_NODE(unwind) ((struct __cfaehm_node *)(unwind)) 130 #define NULL_MAP(map, ptr) ((ptr) ? (map(ptr)) : NULL) 124 131 125 132 // How to clean up an exception in various situations. … … 137 144 } 138 145 139 // We need a piece of storage to raise the exception, for now its a single140 // piece.141 static struct _Unwind_Exception this_exception_storage;142 143 struct __cfaehm_node {144 struct __cfaehm_node * next;145 };146 147 #define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node)))148 #define EXCEPT_TO_NODE(except) ((struct __cfaehm_node *)(except) - 1)149 150 146 // Creates a copy of the indicated exception and sets current_exception to it. 151 147 static void __cfaehm_allocate_exception( exception_t * except ) { … … 161 157 } 162 158 159 // Initialize the node: 160 exception_t * except_store = NODE_TO_EXCEPT(store); 161 store->unwind_exception.exception_class = __cfaehm_exception_class; 162 store->unwind_exception.exception_cleanup = __cfaehm_exception_cleanup; 163 store->handler_index = 0; 164 except->virtual_table->copy( except_store, except ); 165 163 166 // Add the node to the list: 164 store->next = EXCEPT_TO_NODE(context->current_exception); 165 context->current_exception = NODE_TO_EXCEPT(store); 166 167 // Copy the exception to storage. 168 except->virtual_table->copy( context->current_exception, except ); 169 170 // Set up the exception storage. 171 this_exception_storage.exception_class = __cfaehm_exception_class; 172 this_exception_storage.exception_cleanup = __cfaehm_exception_cleanup; 167 store->next = NULL_MAP(EXCEPT_TO_NODE, context->current_exception); 168 context->current_exception = except_store; 173 169 } 174 170 … … 185 181 if ( context->current_exception == except ) { 186 182 node = to_free->next; 187 context->current_exception = (node) ? NODE_TO_EXCEPT(node) : 0;183 context->current_exception = NULL_MAP(NODE_TO_EXCEPT, node); 188 184 } else { 189 185 node = EXCEPT_TO_NODE(context->current_exception); … … 213 209 // Verify actions follow the rules we expect. 214 210 verify((actions & _UA_CLEANUP_PHASE) && (actions & _UA_FORCE_UNWIND)); 215 verify(!(actions & (_UA_SEARCH_PHASE | _UA_HAND ER_FRAME)));211 verify(!(actions & (_UA_SEARCH_PHASE | _UA_HANDLER_FRAME))); 216 212 217 213 if ( actions & _UA_END_OF_STACK ) { … … 222 218 } 223 219 220 static struct _Unwind_Exception cancel_exception_storage; 221 224 222 // Cancel the current stack, prefroming approprate clean-up and messaging. 225 223 void __cfaehm_cancel_stack( exception_t * exception ) { 226 224 // TODO: Detect current stack and pick a particular stop-function. 227 225 _Unwind_Reason_Code ret; 228 ret = _Unwind_ForcedUnwind( & this_exception_storage, _Stop_Fn, (void*)0x22 );226 ret = _Unwind_ForcedUnwind( &cancel_exception_storage, _Stop_Fn, (void*)0x22 ); 229 227 printf("UNWIND ERROR %d after force unwind\n", ret); 230 228 abort(); … … 247 245 static void __cfaehm_begin_unwind(void(*defaultHandler)(exception_t *)) { 248 246 struct exception_context_t * context = this_exception_context(); 249 struct _Unwind_Exception * storage = &this_exception_storage;250 247 if ( NULL == context->current_exception ) { 251 248 printf("UNWIND ERROR missing exception in begin unwind\n"); 252 249 abort(); 253 250 } 251 struct _Unwind_Exception * storage = 252 &EXCEPT_TO_NODE(context->current_exception)->unwind_exception; 254 253 255 254 // Call stdlibc to raise the exception … … 419 418 _Unwind_Reason_Code ret = (0 == index) 420 419 ? _URC_CONTINUE_UNWIND : _URC_HANDLER_FOUND; 421 context->current_handler_index = index;420 UNWIND_TO_NODE(unwind_exception)->handler_index = index; 422 421 423 422 // Based on the return value, check if we matched the exception … … 425 424 __cfadbg_print_safe(exception, " handler found\n"); 426 425 } else { 426 // TODO: Continue the search if there is more in the table. 427 427 __cfadbg_print_safe(exception, " no handler\n"); 428 428 } … … 516 516 // Exception handler 517 517 // Note: Saving the exception context on the stack breaks termination exceptions. 518 catch_block( this_exception_context()->current_handler_index,518 catch_block( EXCEPT_TO_NODE( this_exception_context()->current_exception )->handler_index, 519 519 this_exception_context()->current_exception ); 520 520 } -
src/AST/Pass.hpp
r67bfc50 rbadd22f 91 91 static void run( std::list< ptr<Decl> > & decls, Args &&... args ) { 92 92 Pass<core_t> visitor( std::forward<Args>( args )... ); 93 accept_all( decls, visitor ); 94 } 95 96 template< typename... Args > 97 static void run( std::list< ptr<Decl> > & decls ) { 98 Pass<core_t> visitor; 93 99 accept_all( decls, visitor ); 94 100 }
Note: See TracChangeset
for help on using the changeset viewer.