Changeset 342be43
- Timestamp:
- Oct 26, 2020, 5:10:02 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- cb25fc9
- Parents:
- ab8c6a6
- Location:
- libcfa/src
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.cfa
rab8c6a6 r342be43 49 49 FORALL_DATA_INSTANCE(CoroutineCancelled, (dtype coroutine_t), (coroutine_t)) 50 50 51 struct __cfaehm_node {52 struct _Unwind_Exception unwind_exception;53 struct __cfaehm_node * next;54 int handler_index;55 };56 57 51 forall(dtype T) 58 52 void mark_exception(CoroutineCancelled(T) *) {} … … 60 54 forall(dtype T) 61 55 void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) { 56 dst->virtual_table = src->virtual_table; 62 57 dst->the_coroutine = src->the_coroutine; 63 58 dst->the_exception = src->the_exception; … … 74 69 verify( desc->cancellation ); 75 70 desc->state = Cancelled; 76 exception_t * except = (exception_t *)(1 + (__cfaehm_node *)desc->cancellation);71 exception_t * except = __cfaehm_cancellation_exception( desc->cancellation ); 77 72 78 73 // TODO: Remove explitate vtable set once trac#186 is fixed. -
libcfa/src/concurrency/exception.cfa
rab8c6a6 r342be43 54 54 55 55 STOP_AT_END_FUNCTION(thread_cancelstop, 56 57 56 __cfactx_thrd_leave(); 57 __cabi_abort( "Resumed cancelled thread" ); 58 58 ) 59 59 -
libcfa/src/concurrency/exception.hfa
rab8c6a6 r342be43 16 16 #pragma once 17 17 18 // This is an internal bridge between the two modes and must be C compatable. 19 18 20 #include "bits/defs.hfa" 19 21 #include "invoke.h" … … 31 33 struct _Unwind_Exception * unwind_exception ) OPTIONAL_THREAD; 32 34 35 struct __cfaehm_node { 36 struct _Unwind_Exception unwind_exception; 37 struct __cfaehm_node * next; 38 int handler_index; 39 }; 40 41 static inline exception_t * __cfaehm_cancellation_exception( 42 struct _Unwind_Exception * unwind_exception ) { 43 return (exception_t *)(1 + (struct __cfaehm_node *)unwind_exception); 44 } 45 33 46 #ifdef __cforall 34 47 #undef HIDE_EXPORTS -
libcfa/src/concurrency/thread.cfa
rab8c6a6 r342be43 73 73 } 74 74 75 struct __cfaehm_node {76 struct _Unwind_Exception unwind_exception;77 struct __cfaehm_node * next;78 int handler_index;79 };80 81 75 forall(dtype T) 82 76 static void default_thread_cancel_handler(ThreadCancelled(T) & ) { … … 91 85 bool join = defaultResumptionHandler != (void(*)(ThreadCancelled(T)&))0; 92 86 (this.mg){&m, (void(*)())dtor, join}; 93 {94 $thread * desc = get_thread(thrd);95 struct _Unwind_Exception * cancellation = desc->self_cor.cancellation;96 if ( likely(0p == cancellation) ) {97 return;98 } else if ( Cancelled == desc->state ) {99 return;100 }101 desc->state = Cancelled;102 if (!join) {103 defaultResumptionHandler = default_thread_cancel_handler;104 }105 ThreadCancelled(T) except;106 // TODO: Remove explitate vtable set once trac#186 is fixed.107 except.virtual_table = &get_exception_vtable(&except);108 except.the_thread = &thrd;109 except.the_exception = (exception_t *)(1 + (__cfaehm_node *)cancellation);110 throwResume except;111 87 112 except.the_exception->virtual_table->free( except.the_exception ); 113 free( cancellation ); 114 desc->self_cor.cancellation = 0p; 88 // After the guard set-up and any wait, check for cancellation. 89 $thread * desc = get_thread(thrd); 90 struct _Unwind_Exception * cancellation = desc->self_cor.cancellation; 91 if ( likely( 0p == cancellation ) ) { 92 return; 93 } else if ( Cancelled == desc->state ) { 94 return; 115 95 } 96 desc->state = Cancelled; 97 if (!join) { 98 defaultResumptionHandler = default_thread_cancel_handler; 99 } 100 101 ThreadCancelled(T) except; 102 // TODO: Remove explitate vtable set once trac#186 is fixed. 103 except.virtual_table = &get_exception_vtable(&except); 104 except.the_thread = &thrd; 105 except.the_exception = __cfaehm_cancellation_exception( cancellation ); 106 throwResume except; 107 108 except.the_exception->virtual_table->free( except.the_exception ); 109 free( cancellation ); 110 desc->self_cor.cancellation = 0p; 116 111 } 117 112 -
libcfa/src/exception.c
rab8c6a6 r342be43 24 24 #include <bits/debug.hfa> 25 25 #include "concurrency/invoke.h" 26 #include "concurrency/exception.hfa" 26 27 #include "stdhdr/assert.h" 27 28 … … 113 114 114 115 // MEMORY MANAGEMENT ========================================================= 115 116 struct __cfaehm_node {117 struct _Unwind_Exception unwind_exception;118 struct __cfaehm_node * next;119 int handler_index;120 };121 116 122 117 #define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node)))
Note: See TracChangeset
for help on using the changeset viewer.