Changeset 3090127 for libcfa/src


Ignore:
Timestamp:
Mar 30, 2020, 11:36:54 AM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
a685335
Parents:
bb2e05e
Message:

Naming updates, most are to get exception names to the new cfa(module)_ format.

Location:
libcfa/src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/exception.c

    rbb2e05e r3090127  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Jun 26 15:13:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 18:17:34 2018
    13 // Update Count     : 11
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Mar 27 10:19:00 2020
     13// Update Count     : 12
    1414//
    1515
     
    4141
    4242// Base exception vtable is abstract, you should not have base exceptions.
    43 struct __cfaabi_ehm__base_exception_t_vtable
    44                 ___cfaabi_ehm__base_exception_t_vtable_instance = {
     43struct __cfaehm_base_exception_t_vtable
     44                ___cfaehm_base_exception_t_vtable_instance = {
    4545        .parent = NULL,
    4646        .size = 0,
     
    5353// Temperary global exception context. Does not work with concurency.
    5454struct exception_context_t {
    55     struct __cfaabi_ehm__try_resume_node * top_resume;
    56     struct __cfaabi_ehm__try_resume_node * current_resume;
     55    struct __cfaehm_try_resume_node * top_resume;
     56    struct __cfaehm_try_resume_node * current_resume;
    5757
    5858    exception_t * current_exception;
     
    7070// RESUMPTION ================================================================
    7171
    72 void __cfaabi_ehm__throw_resume(exception_t * except) {
     72void __cfaehm_throw_resume(exception_t * except) {
    7373        struct exception_context_t * context = this_exception_context();
    7474
    7575        __cfaabi_dbg_print_safe("Throwing resumption exception\n");
    7676
    77         struct __cfaabi_ehm__try_resume_node * original_head = context->current_resume;
    78         struct __cfaabi_ehm__try_resume_node * current =
     77        struct __cfaehm_try_resume_node * original_head = context->current_resume;
     78        struct __cfaehm_try_resume_node * current =
    7979                (original_head) ? original_head->next : context->top_resume;
    8080
     
    9191
    9292        // Fall back to termination:
    93         __cfaabi_ehm__throw_terminate(except);
     93        __cfaehm_throw_terminate(except);
    9494        // TODO: Default handler for resumption.
    9595}
     
    9999// be added after the node is built but before it is made the top node.
    100100
    101 void __cfaabi_ehm__try_resume_setup(struct __cfaabi_ehm__try_resume_node * node,
     101void __cfaehm_try_resume_setup(struct __cfaehm_try_resume_node * node,
    102102                        _Bool (*handler)(exception_t * except)) {
    103103        struct exception_context_t * context = this_exception_context();
     
    107107}
    108108
    109 void __cfaabi_ehm__try_resume_cleanup(struct __cfaabi_ehm__try_resume_node * node) {
     109void __cfaehm_try_resume_cleanup(struct __cfaehm_try_resume_node * node) {
    110110        struct exception_context_t * context = this_exception_context();
    111111        context->top_resume = node->next;
     
    118118// May have to move to cfa for constructors and destructors (references).
    119119
    120 struct __cfaabi_ehm__node {
    121         struct __cfaabi_ehm__node * next;
     120struct __cfaehm_node {
     121        struct __cfaehm_node * next;
    122122};
    123123
    124124#define NODE_TO_EXCEPT(node) ((exception_t *)(1 + (node)))
    125 #define EXCEPT_TO_NODE(except) ((struct __cfaabi_ehm__node *)(except) - 1)
     125#define EXCEPT_TO_NODE(except) ((struct __cfaehm_node *)(except) - 1)
    126126
    127127// Creates a copy of the indicated exception and sets current_exception to it.
    128 static void __cfaabi_ehm__allocate_exception( exception_t * except ) {
     128static void __cfaehm_allocate_exception( exception_t * except ) {
    129129        struct exception_context_t * context = this_exception_context();
    130130
    131131        // Allocate memory for the exception.
    132         struct __cfaabi_ehm__node * store = malloc(
    133                 sizeof( struct __cfaabi_ehm__node ) + except->virtual_table->size );
     132        struct __cfaehm_node * store = malloc(
     133                sizeof( struct __cfaehm_node ) + except->virtual_table->size );
    134134
    135135        if ( ! store ) {
     
    147147
    148148// Delete the provided exception, unsetting current_exception if relivant.
    149 static void __cfaabi_ehm__delete_exception( exception_t * except ) {
     149static void __cfaehm_delete_exception( exception_t * except ) {
    150150        struct exception_context_t * context = this_exception_context();
    151151
     
    153153
    154154        // Remove the exception from the list.
    155         struct __cfaabi_ehm__node * to_free = EXCEPT_TO_NODE(except);
    156         struct __cfaabi_ehm__node * node;
     155        struct __cfaehm_node * to_free = EXCEPT_TO_NODE(except);
     156        struct __cfaehm_node * node;
    157157
    158158        if ( context->current_exception == except ) {
     
    174174
    175175// If this isn't a rethrow (*except==0), delete the provided exception.
    176 void __cfaabi_ehm__cleanup_terminate( void * except ) {
    177         if ( *(void**)except ) __cfaabi_ehm__delete_exception( *(exception_t **)except );
     176void __cfaehm_cleanup_terminate( void * except ) {
     177        if ( *(void**)except ) __cfaehm_delete_exception( *(exception_t **)except );
    178178}
    179179
     
    187187                int version,
    188188                _Unwind_Action actions,
    189                 _Unwind_Exception_Class exceptionClass,
     189                _Unwind_Exception_Class exception_class,
    190190                struct _Unwind_Exception * unwind_exception,
    191191                struct _Unwind_Context * unwind_context,
     
    198198
    199199// The exception that is being thrown must already be stored.
    200 __attribute__((noreturn)) void __cfaabi_ehm__begin_unwind(void) {
     200static __attribute__((noreturn)) void __cfaehm_begin_unwind(void) {
    201201        if ( ! this_exception_context()->current_exception ) {
    202202                printf("UNWIND ERROR missing exception in begin unwind\n");
     
    230230}
    231231
    232 void __cfaabi_ehm__throw_terminate( exception_t * val ) {
     232void __cfaehm_throw_terminate( exception_t * val ) {
    233233        __cfaabi_dbg_print_safe("Throwing termination exception\n");
    234234
    235         __cfaabi_ehm__allocate_exception( val );
    236         __cfaabi_ehm__begin_unwind();
    237 }
    238 
    239 void __cfaabi_ehm__rethrow_terminate(void) {
     235        __cfaehm_allocate_exception( val );
     236        __cfaehm_begin_unwind();
     237}
     238
     239void __cfaehm_rethrow_terminate(void) {
    240240        __cfaabi_dbg_print_safe("Rethrowing termination exception\n");
    241241
    242         __cfaabi_ehm__begin_unwind();
     242        __cfaehm_begin_unwind();
    243243}
    244244
     
    246246// ".cfi_personality 0x3,__gcfa_personality_v0" this function will be called twice when unwinding.
    247247//  Once in the search phase and once in the cleanup phase.
    248 _Unwind_Reason_Code __gcfa_personality_v0 (
    249                 int version, _Unwind_Action actions, unsigned long long exceptionClass,
    250                 struct _Unwind_Exception* unwind_exception,
    251                 struct _Unwind_Context* unwind_context)
     248_Unwind_Reason_Code __gcfa_personality_v0(
     249                int version,
     250                _Unwind_Action actions,
     251                unsigned long long exception_class,
     252                struct _Unwind_Exception * unwind_exception,
     253                struct _Unwind_Context * unwind_context)
    252254{
    253255
    254256        //__cfaabi_dbg_print_safe("CFA: 0x%lx\n", _Unwind_GetCFA(context));
    255257        __cfaabi_dbg_print_safe("Personality function (%d, %x, %llu, %p, %p):",
    256                         version, actions, exceptionClass, unwind_exception, unwind_context);
     258                        version, actions, exception_class, unwind_exception, unwind_context);
    257259
    258260        // If we've reached the end of the stack then there is nothing much we can do...
     
    342344                                //  - The BSP (Probably the base stack pointer)
    343345
    344 
    345346                                // The current apprach uses one exception table entry per try block
    346347                                _uleb128_t imatcher;
     
    414415// and simply linked from libcfa but there is one problem left, see the exception table for details
    415416__attribute__((noinline))
    416 void __cfaabi_ehm__try_terminate(void (*try_block)(),
     417void __cfaehm_try_terminate(void (*try_block)(),
    417418                void (*catch_block)(int index, exception_t * except),
    418419                __attribute__((unused)) int (*match_block)(exception_t * except)) {
     
    480481        // handler landing pad offset and 1 (action code, gcc seems to use 0).
    481482        ".LLSDACSBCFA2:\n"
    482         "       .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n"
     483        "       .uleb128 .TRYSTART-__cfaehm_try_terminate\n"
    483484        "       .uleb128 .TRYEND-.TRYSTART\n"
    484         "       .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n"
     485        "       .uleb128 .CATCH-__cfaehm_try_terminate\n"
    485486        "       .uleb128 1\n"
    486487        ".LLSDACSECFA2:\n"
    487488        // TABLE FOOTER
    488489        "       .text\n"
    489         "       .size   __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n"
     490        "       .size   __cfaehm_try_terminate, .-__cfaehm_try_terminate\n"
    490491);
    491492
     
    524525        ".LLSDACSBCFA2:\n"
    525526        //      Handled area start (relative to start of function)
    526         "       .uleb128 .TRYSTART-__cfaabi_ehm__try_terminate\n"
     527        "       .uleb128 .TRYSTART-__cfaehm_try_terminate\n"
    527528        //      Handled area length
    528529        "       .uleb128 .TRYEND-.TRYSTART\n"
    529530        //      Handler landing pad address (relative to start of function)
    530         "       .uleb128 .CATCH-__cfaabi_ehm__try_terminate\n"
     531        "       .uleb128 .CATCH-__cfaehm_try_terminate\n"
    531532        //      Action code, gcc seems to always use 0.
    532533        "       .uleb128 1\n"
     
    534535        ".LLSDACSECFA2:\n"
    535536        "       .text\n"
    536         "       .size   __cfaabi_ehm__try_terminate, .-__cfaabi_ehm__try_terminate\n"
     537        "       .size   __cfaehm_try_terminate, .-__cfaehm_try_terminate\n"
    537538        "       .ident  \"GCC: (Ubuntu 6.2.0-3ubuntu11~16.04) 6.2.0 20160901\"\n"
    538539        "       .section        .note.GNU-stack,\"x\",@progbits\n"
  • libcfa/src/exception.h

    rbb2e05e r3090127  
    99// Author           : Andrew Beach
    1010// Created On       : Mon Jun 26 15:11:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb 22 18:11:15 2018
    13 // Update Count     : 8
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Mar 27 10:16:00 2020
     13// Update Count     : 9
    1414//
    1515
     
    2121#endif
    2222
    23 struct __cfaabi_ehm__base_exception_t;
    24 typedef struct __cfaabi_ehm__base_exception_t exception_t;
    25 struct __cfaabi_ehm__base_exception_t_vtable {
    26         const struct __cfaabi_ehm__base_exception_t_vtable * parent;
     23struct __cfaehm_base_exception_t;
     24typedef struct __cfaehm_base_exception_t exception_t;
     25struct __cfaehm_base_exception_t_vtable {
     26        const struct __cfaehm_base_exception_t_vtable * parent;
    2727        size_t size;
    28         void (*copy)(struct __cfaabi_ehm__base_exception_t *this,
    29                      struct __cfaabi_ehm__base_exception_t * other);
    30         void (*free)(struct __cfaabi_ehm__base_exception_t *this);
    31         const char * (*msg)(struct __cfaabi_ehm__base_exception_t *this);
     28        void (*copy)(struct __cfaehm_base_exception_t *this,
     29                     struct __cfaehm_base_exception_t * other);
     30        void (*free)(struct __cfaehm_base_exception_t *this);
     31        const char * (*msg)(struct __cfaehm_base_exception_t *this);
    3232};
    33 struct __cfaabi_ehm__base_exception_t {
    34         struct __cfaabi_ehm__base_exception_t_vtable const * virtual_table;
     33struct __cfaehm_base_exception_t {
     34        struct __cfaehm_base_exception_t_vtable const * virtual_table;
    3535};
    36 extern struct __cfaabi_ehm__base_exception_t_vtable
    37         ___cfaabi_ehm__base_exception_t_vtable_instance;
     36extern struct __cfaehm_base_exception_t_vtable
     37        ___cfaehm_base_exception_t_vtable_instance;
    3838
    3939
    4040// Used in throw statement translation.
    41 void __cfaabi_ehm__throw_terminate(exception_t * except) __attribute__((noreturn));
    42 void __cfaabi_ehm__rethrow_terminate() __attribute__((noreturn));
    43 void __cfaabi_ehm__throw_resume(exception_t * except);
     41void __cfaehm_throw_terminate(exception_t * except) __attribute__((noreturn));
     42void __cfaehm_rethrow_terminate() __attribute__((noreturn));
     43void __cfaehm_throw_resume(exception_t * except);
    4444
    4545// Function catches termination exceptions.
    46 void __cfaabi_ehm__try_terminate(
     46void __cfaehm_try_terminate(
    4747    void (*try_block)(),
    4848    void (*catch_block)(int index, exception_t * except),
     
    5050
    5151// Clean-up the exception in catch blocks.
    52 void __cfaabi_ehm__cleanup_terminate(void * except);
     52void __cfaehm_cleanup_terminate(void * except);
    5353
    5454// Data structure creates a list of resume handlers.
    55 struct __cfaabi_ehm__try_resume_node {
    56     struct __cfaabi_ehm__try_resume_node * next;
     55struct __cfaehm_try_resume_node {
     56    struct __cfaehm_try_resume_node * next;
    5757    _Bool (*handler)(exception_t * except);
    5858};
    5959
    6060// These act as constructor and destructor for the resume node.
    61 void __cfaabi_ehm__try_resume_setup(
    62     struct __cfaabi_ehm__try_resume_node * node,
     61void __cfaehm_try_resume_setup(
     62    struct __cfaehm_try_resume_node * node,
    6363    _Bool (*handler)(exception_t * except));
    64 void __cfaabi_ehm__try_resume_cleanup(
    65     struct __cfaabi_ehm__try_resume_node * node);
     64void __cfaehm_try_resume_cleanup(
     65    struct __cfaehm_try_resume_node * node);
    6666
    6767// Check for a standard way to call fake deconstructors.
    68 struct __cfaabi_ehm__cleanup_hook {};
     68struct __cfaehm_cleanup_hook {};
    6969
    7070#ifdef __cforall
Note: See TracChangeset for help on using the changeset viewer.