Changeset 307a732 for src/libcfa
- Timestamp:
- Jul 4, 2017, 11:52:33 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:
- 44f44617, 67fa9f9, ad0be81
- Parents:
- 86f384b
- Location:
- src/libcfa
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/libcfa/Makefile.am
r86f384b r307a732 50 50 51 51 libobjs = ${headers:=.o} 52 libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} 52 libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} exception.c 53 53 54 54 # not all platforms support concurrency, add option do disable it -
src/libcfa/Makefile.in
r86f384b r307a732 102 102 containers/pair.c containers/result.c containers/vector.c \ 103 103 concurrency/coroutine.c concurrency/thread.c \ 104 concurrency/kernel.c concurrency/monitor.c \104 concurrency/kernel.c concurrency/monitor.c exception.c \ 105 105 concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \ 106 106 concurrency/invoke.c concurrency/preemption.c … … 126 126 libcfa_d_a-interpose.$(OBJEXT) \ 127 127 libhdr/libcfa_d_a-libdebug.$(OBJEXT) $(am__objects_2) \ 128 $(am__objects_3)128 libcfa_d_a-exception.$(OBJEXT) $(am__objects_3) 129 129 am_libcfa_d_a_OBJECTS = $(am__objects_4) 130 130 libcfa_d_a_OBJECTS = $(am_libcfa_d_a_OBJECTS) … … 136 136 containers/pair.c containers/result.c containers/vector.c \ 137 137 concurrency/coroutine.c concurrency/thread.c \ 138 concurrency/kernel.c concurrency/monitor.c \138 concurrency/kernel.c concurrency/monitor.c exception.c \ 139 139 concurrency/CtxSwitch-@MACHINE_TYPE@.S concurrency/alarm.c \ 140 140 concurrency/invoke.c concurrency/preemption.c … … 158 158 libcfa_a-interpose.$(OBJEXT) \ 159 159 libhdr/libcfa_a-libdebug.$(OBJEXT) $(am__objects_6) \ 160 $(am__objects_7)160 libcfa_a-exception.$(OBJEXT) $(am__objects_7) 161 161 am_libcfa_a_OBJECTS = $(am__objects_8) 162 162 libcfa_a_OBJECTS = $(am_libcfa_a_OBJECTS) … … 328 328 libobjs = ${headers:=.o} 329 329 libsrc = libcfa-prelude.c interpose.c libhdr/libdebug.c ${headers:=.c} \ 330 $(am__append_4)330 exception.c $(am__append_4) 331 331 libcfa_a_SOURCES = ${libsrc} 332 332 libcfa_a_CFLAGS = -nodebug -O2 … … 514 514 515 515 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-assert.Po@am__quote@ 516 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-exception.Po@am__quote@ 516 517 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-fstream.Po@am__quote@ 517 518 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-interpose.Po@am__quote@ … … 524 525 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_a-stdlib.Po@am__quote@ 525 526 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-assert.Po@am__quote@ 527 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-exception.Po@am__quote@ 526 528 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-fstream.Po@am__quote@ 527 529 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/libcfa_d_a-interpose.Po@am__quote@ … … 850 852 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_d_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi` 851 853 854 libcfa_d_a-exception.obj: exception.c 855 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT libcfa_d_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_d_a-exception.Tpo -c -o libcfa_d_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi` 856 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_d_a-exception.Tpo $(DEPDIR)/libcfa_d_a-exception.Po 857 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exception.c' object='libcfa_d_a-exception.obj' libtool=no @AMDEPBACKSLASH@ 858 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 859 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -c -o libcfa_d_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi` 860 852 861 concurrency/libcfa_d_a-alarm.o: concurrency/alarm.c 853 862 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_d_a_CFLAGS) $(CFLAGS) -MT concurrency/libcfa_d_a-alarm.o -MD -MP -MF concurrency/$(DEPDIR)/libcfa_d_a-alarm.Tpo -c -o concurrency/libcfa_d_a-alarm.o `test -f 'concurrency/alarm.c' || echo '$(srcdir)/'`concurrency/alarm.c … … 1143 1152 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1144 1153 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o concurrency/libcfa_a-monitor.obj `if test -f 'concurrency/monitor.c'; then $(CYGPATH_W) 'concurrency/monitor.c'; else $(CYGPATH_W) '$(srcdir)/concurrency/monitor.c'; fi` 1154 1155 libcfa_a-exception.obj: exception.c 1156 @am__fastdepCC_TRUE@ $(AM_V_CC)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -MT libcfa_a-exception.obj -MD -MP -MF $(DEPDIR)/libcfa_a-exception.Tpo -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi` 1157 @am__fastdepCC_TRUE@ $(AM_V_at)$(am__mv) $(DEPDIR)/libcfa_a-exception.Tpo $(DEPDIR)/libcfa_a-exception.Po 1158 @AMDEP_TRUE@@am__fastdepCC_FALSE@ $(AM_V_CC)source='exception.c' object='libcfa_a-exception.obj' libtool=no @AMDEPBACKSLASH@ 1159 @AMDEP_TRUE@@am__fastdepCC_FALSE@ DEPDIR=$(DEPDIR) $(CCDEPMODE) $(depcomp) @AMDEPBACKSLASH@ 1160 @am__fastdepCC_FALSE@ $(AM_V_CC@am__nodep@)$(CC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(libcfa_a_CFLAGS) $(CFLAGS) -c -o libcfa_a-exception.obj `if test -f 'exception.c'; then $(CYGPATH_W) 'exception.c'; else $(CYGPATH_W) '$(srcdir)/exception.c'; fi` 1145 1161 1146 1162 concurrency/libcfa_a-alarm.o: concurrency/alarm.c -
src/libcfa/exception.c
r86f384b r307a732 44 44 // RESUMPTION ================================================================ 45 45 46 void __cfaehm__throw_resum e(exceptionexcept) {47 48 // DEBUG 49 printf("Throwing resumption exception %d\n", except);50 51 struct __ try_resume_node * original_head = shared_stack.current_resume;52 struct __ try_resume_node * current =46 void __cfaehm__throw_resumption(exception * except) { 47 48 // DEBUG 49 printf("Throwing resumption exception %d\n", *except); 50 51 struct __cfaehm__try_resume_node * original_head = shared_stack.current_resume; 52 struct __cfaehm__try_resume_node * current = 53 53 (original_head) ? original_head->next : shared_stack.top_resume; 54 54 55 55 for ( ; current ; current = current->next) { 56 56 shared_stack.current_resume = current; 57 if (current-> try_to_handle(except)) {57 if (current->handler(except)) { 58 58 shared_stack.current_resume = original_head; 59 59 return; … … 61 61 } 62 62 63 printf("Unhandled exception %d\n", except);63 printf("Unhandled exception %d\n", *except); 64 64 shared_stack.current_resume = original_head; 65 65 66 66 // Fall back to termination: 67 __cfaehm__throw_terminat e(except);67 __cfaehm__throw_termination(except); 68 68 // TODO: Default handler for resumption. 69 69 } … … 73 73 * after the node is built but before it is made the top node. 74 74 */ 75 void __ try_resume_setup(struct__try_resume_node * node,76 bool (*handler)(exceptionexcept)) {75 void __cfaehm__try_resume_setup(struct __cfaehm__try_resume_node * node, 76 int (*handler)(exception * except)) { 77 77 node->next = shared_stack.top_resume; 78 node-> try_to_handle= handler;78 node->handler = handler; 79 79 shared_stack.top_resume = node; 80 80 } 81 81 82 void __ try_resume_cleanup(struct__try_resume_node * node) {82 void __cfaehm__try_resume_cleanup(struct __cfaehm__try_resume_node * node) { 83 83 shared_stack.top_resume = node->next; 84 84 } … … 111 111 } 112 112 113 void __cfaehm__throw_terminat e( intval ) {113 void __cfaehm__throw_termination( exception * val ) { 114 114 // Store the current exception 115 shared_stack.current_exception = val;116 117 // DEBUG 118 printf("Throwing termination exception %d\n", val);115 shared_stack.current_exception = *val; 116 117 // DEBUG 118 printf("Throwing termination exception %d\n", *val); 119 119 120 120 // Call stdlibc to raise the exception … … 147 147 148 148 // Nesting this the other way would probably be faster. 149 void __cfaehm__rethrow_terminat e(void) {149 void __cfaehm__rethrow_termination(void) { 150 150 // DEBUG 151 151 printf("Rethrowing termination exception\n"); 152 152 153 __cfaehm__throw_terminat e(shared_stack.current_exception);153 __cfaehm__throw_termination(&shared_stack.current_exception); 154 154 } 155 155 … … 322 322 // for details 323 323 __attribute__((noinline)) 324 void __ try_terminate(void (*try_block)(),325 void (*catch_block)(int index, exception except),326 __attribute__((unused)) int (*match_block)(exception except)) {324 void __cfaehm__try_terminate(void (*try_block)(), 325 void (*catch_block)(int index, exception * except), 326 __attribute__((unused)) int (*match_block)(exception * except)) { 327 327 //! volatile int xy = 0; 328 328 //! printf("%p %p %p %p\n", &try_block, &catch_block, &match_block, &xy); … … 364 364 // Exception handler 365 365 catch_block(shared_stack.current_handler_index, 366 shared_stack.current_exception);366 &shared_stack.current_exception); 367 367 } 368 368 … … 384 384 // Body uses language specific data and therefore could be modified arbitrarily 385 385 ".LLSDACSBCFA2:\n" // BODY start 386 " .uleb128 .TRYSTART-__ try_terminate\n" // Handled area start (relative to start of function)386 " .uleb128 .TRYSTART-__cfaehm__try_terminate\n" // Handled area start (relative to start of function) 387 387 " .uleb128 .TRYEND-.TRYSTART\n" // Handled area length 388 " .uleb128 .CATCH-__ try_terminate\n" // Hanlder landing pad adress (relative to start of function)388 " .uleb128 .CATCH-__cfaehm__try_terminate\n" // Hanlder landing pad adress (relative to start of function) 389 389 " .uleb128 1\n" // Action code, gcc seems to use always 0 390 390 ".LLSDACSECFA2:\n" // BODY end 391 391 " .text\n" // TABLE footer 392 " .size __ try_terminate, .-__try_terminate\n"392 " .size __cfaehm__try_terminate, .-__cfaehm__try_terminate\n" 393 393 " .ident \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n" 394 394 // " .section .note.GNU-stack,\"x\",@progbits\n" -
src/libcfa/exception.h
r86f384b r307a732 38 38 // Data structure creates a list of resume handlers. 39 39 struct __cfaehm__try_resume_node { 40 __cfaehm__try_resume_node * next;40 struct __cfaehm__try_resume_node * next; 41 41 int (*handler)(exception * except); 42 42 }; 43 43 44 44 void __cfaehm__try_resume_setup( 45 __cfaehm__try_resume_node * node,45 struct __cfaehm__try_resume_node * node, 46 46 int (*handler)(exception * except)); 47 47 void __cfaehm__try_resume_cleanup( 48 __cfaehm__try_resume_node * node);48 struct __cfaehm__try_resume_node * node); 49 49 50 50 // Check for a standard way to call fake deconstructors.
Note:
See TracChangeset
for help on using the changeset viewer.