Changeset 3090127


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.

Files:
5 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
  • src/ControlStruct/ExceptTranslate.cc

    rbb2e05e r3090127  
    99// Author           : Andrew Beach
    1010// Created On       : Wed Jun 14 16:49:00 2017
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Dec 13 23:40:15 2019
    13 // Update Count     : 12
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Mar 27 11:58:00 2020
     13// Update Count     : 13
    1414//
    1515
     
    211211                        ThrowStmt *throwStmt ) {
    212212                // __throw_terminate( `throwStmt->get_name()` ); }
    213                 return create_given_throw( "__cfaabi_ehm__throw_terminate", throwStmt );
     213                return create_given_throw( "__cfaehm_throw_terminate", throwStmt );
    214214        }
    215215
     
    232232                        ) ) );
    233233                result->push_back( new ExprStmt(
    234                         new UntypedExpr( new NameExpr( "__cfaabi_ehm__rethrow_terminate" ) )
     234                        new UntypedExpr( new NameExpr( "__cfaehm_rethrow_terminate" ) )
    235235                        ) );
    236236                delete throwStmt;
     
    241241                        ThrowStmt *throwStmt ) {
    242242                // __throw_resume( `throwStmt->get_name` );
    243                 return create_given_throw( "__cfaabi_ehm__throw_resume", throwStmt );
     243                return create_given_throw( "__cfaehm_throw_resume", throwStmt );
    244244        }
    245245
     
    309309                        local_except->get_attributes().push_back( new Attribute(
    310310                                "cleanup",
    311                                 { new NameExpr( "__cfaabi_ehm__cleanup_terminate" ) }
     311                                { new NameExpr( "__cfaehm_cleanup_terminate" ) }
    312312                                ) );
    313313
     
    429429                        FunctionDecl * terminate_catch,
    430430                        FunctionDecl * terminate_match ) {
    431                 // { __cfaabi_ehm__try_terminate(`try`, `catch`, `match`); }
     431                // { __cfaehm_try_terminate(`try`, `catch`, `match`); }
    432432
    433433                UntypedExpr * caller = new UntypedExpr( new NameExpr(
    434                         "__cfaabi_ehm__try_terminate" ) );
     434                        "__cfaehm_try_terminate" ) );
    435435                std::list<Expression *>& args = caller->get_args();
    436436                args.push_back( nameOf( try_wrapper ) );
     
    486486
    487487                // struct __try_resume_node __resume_node
    488                 //      __attribute__((cleanup( __cfaabi_ehm__try_resume_cleanup )));
     488                //      __attribute__((cleanup( __cfaehm_try_resume_cleanup )));
    489489                // ** unwinding of the stack here could cause problems **
    490490                // ** however I don't think that can happen currently **
    491                 // __cfaabi_ehm__try_resume_setup( &__resume_node, resume_handler );
     491                // __cfaehm_try_resume_setup( &__resume_node, resume_handler );
    492492
    493493                std::list< Attribute * > attributes;
     
    495495                        std::list< Expression * > attr_params;
    496496                        attr_params.push_back( new NameExpr(
    497                                 "__cfaabi_ehm__try_resume_cleanup" ) );
     497                                "__cfaehm_try_resume_cleanup" ) );
    498498                        attributes.push_back( new Attribute( "cleanup", attr_params ) );
    499499                }
     
    514514
    515515                UntypedExpr *setup = new UntypedExpr( new NameExpr(
    516                         "__cfaabi_ehm__try_resume_setup" ) );
     516                        "__cfaehm_try_resume_setup" ) );
    517517                setup->get_args().push_back( new AddressExpr( nameOf( obj ) ) );
    518518                setup->get_args().push_back( nameOf( resume_handler ) );
     
    539539        ObjectDecl * ExceptionMutatorCore::create_finally_hook(
    540540                        FunctionDecl * finally_wrapper ) {
    541                 // struct __cfaabi_ehm__cleanup_hook __finally_hook
     541                // struct __cfaehm_cleanup_hook __finally_hook
    542542                //      __attribute__((cleanup( finally_wrapper )));
    543543
     
    593593                        // Skip children?
    594594                        return;
    595                 } else if ( structDecl->get_name() == "__cfaabi_ehm__base_exception_t" ) {
     595                } else if ( structDecl->get_name() == "__cfaehm_base_exception_t" ) {
    596596                        assert( nullptr == except_decl );
    597597                        except_decl = structDecl;
    598598                        init_func_types();
    599                 } else if ( structDecl->get_name() == "__cfaabi_ehm__try_resume_node" ) {
     599                } else if ( structDecl->get_name() == "__cfaehm_try_resume_node" ) {
    600600                        assert( nullptr == node_decl );
    601601                        node_decl = structDecl;
    602                 } else if ( structDecl->get_name() == "__cfaabi_ehm__cleanup_hook" ) {
     602                } else if ( structDecl->get_name() == "__cfaehm_cleanup_hook" ) {
    603603                        assert( nullptr == hook_decl );
    604604                        hook_decl = structDecl;
  • src/ResolvExpr/Resolver.cc

    rbb2e05e r3090127  
    99// Author           : Aaron B. Moss
    1010// Created On       : Sun May 17 12:17:01 2015
    11 // Last Modified By : Aaron B. Moss
    12 // Last Modified On : Wed May 29 11:00:00 2019
    13 // Update Count     : 241
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Fri Mar 27 11:58:00 2020
     13// Update Count     : 242
    1414//
    1515
     
    560560                // TODO: Replace *exception type with &exception type.
    561561                if ( throwStmt->get_expr() ) {
    562                         const StructDecl * exception_decl = indexer.lookupStruct( "__cfaabi_ehm__base_exception_t" );
     562                        const StructDecl * exception_decl = indexer.lookupStruct( "__cfaehm_base_exception_t" );
    563563                        assert( exception_decl );
    564564                        Type * exceptType = new PointerType( noQualifiers, new StructInstType( noQualifiers, const_cast<StructDecl *>(exception_decl) ) );
     
    14771477                if ( throwStmt->expr ) {
    14781478                        const ast::StructDecl * exceptionDecl =
    1479                                 symtab.lookupStruct( "__cfaabi_ehm__base_exception_t" );
     1479                                symtab.lookupStruct( "__cfaehm_base_exception_t" );
    14801480                        assert( exceptionDecl );
    14811481                        ast::ptr< ast::Type > exceptType =
  • tests/exceptions/except-mac.hfa

    rbb2e05e r3090127  
    77
    88// The fully (perhaps overly) qualified name of the base exception type:
    9 #define BASE_EXCEPT __cfaabi_ehm__base_exception_t
     9#define BASE_EXCEPT __cfaehm_base_exception_t
    1010
    1111// Get the name of the vtable type and vtable instance for an exception type:
Note: See TracChangeset for help on using the changeset viewer.