Changes in / [578c09a:b39e6566]


Ignore:
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • libcfa/src/concurrency/coroutine.cfa

    r578c09a rb39e6566  
    4646
    4747//-----------------------------------------------------------------------------
     48EHM_VIRTUAL_TABLE(SomeCoroutineCancelled, std_coroutine_cancelled);
     49
    4850forall(T &)
    4951void copy(CoroutineCancelled(T) * dst, CoroutineCancelled(T) * src) {
     
    6062// This code should not be inlined. It is the error path on resume.
    6163forall(T & | is_coroutine(T))
    62 void __cfaehm_cancelled_coroutine(
    63                 T & cor, $coroutine * desc, _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable ) {
     64void __cfaehm_cancelled_coroutine( T & cor, $coroutine * desc ) {
    6465        verify( desc->cancellation );
    6566        desc->state = Cancelled;
     
    6768
    6869        // TODO: Remove explitate vtable set once trac#186 is fixed.
    69         CoroutineCancelled(T) except;
    70         except.virtual_table = &_default_vtable;
     70        SomeCoroutineCancelled except;
     71        except.virtual_table = &std_coroutine_cancelled;
    7172        except.the_coroutine = &cor;
    7273        except.the_exception = except;
    7374        // Why does this need a cast?
    74         throwResume (CoroutineCancelled(T) &)except;
     75        throwResume (SomeCoroutineCancelled &)except;
    7576
    7677        except->virtual_table->free( except );
     
    145146// Part of the Public API
    146147// Not inline since only ever called once per coroutine
    147 forall(T & | is_coroutine(T) | { _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable; })
     148forall(T & | is_coroutine(T))
    148149void prime(T& cor) {
    149150        $coroutine* this = get_coroutine(cor);
  • libcfa/src/concurrency/coroutine.hfa

    r578c09a rb39e6566  
    2222//-----------------------------------------------------------------------------
    2323// Exception thrown from resume when a coroutine stack is cancelled.
     24EHM_EXCEPTION(SomeCoroutineCancelled)(
     25        void * the_coroutine;
     26        exception_t * the_exception;
     27);
     28
     29EHM_EXTERN_VTABLE(SomeCoroutineCancelled, std_coroutine_cancelled);
     30
    2431EHM_FORALL_EXCEPTION(CoroutineCancelled, (coroutine_t &), (coroutine_t)) (
    2532        coroutine_t * the_coroutine;
     
    3744// Anything that implements this trait can be resumed.
    3845// Anything that is resumed is a coroutine.
    39 trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(CoroutineCancelled, (T))) {
     46trait is_coroutine(T & | IS_RESUMPTION_EXCEPTION(SomeCoroutineCancelled)) {
    4047        void main(T & this);
    4148        $coroutine * get_coroutine(T & this);
     
    6067//-----------------------------------------------------------------------------
    6168// Public coroutine API
    62 forall(T & | is_coroutine(T) | { _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable; })
     69forall(T & | is_coroutine(T))
    6370void prime(T & cor);
    6471
     
    130137
    131138forall(T & | is_coroutine(T))
    132 void __cfaehm_cancelled_coroutine(
    133         T & cor, $coroutine * desc, _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable );
     139void __cfaehm_cancelled_coroutine( T & cor, $coroutine * desc );
    134140
    135141// Resume implementation inlined for performance
    136 forall(T & | is_coroutine(T) | { _EHM_VTABLE_TYPE(CoroutineCancelled)(T) & const _default_vtable; })
     142forall(T & | is_coroutine(T))
    137143static inline T & resume(T & cor) {
    138144        // optimization : read TLS once and reuse it
     
    164170        $ctx_switch( src, dst );
    165171        if ( unlikely(dst->cancellation) ) {
    166                 __cfaehm_cancelled_coroutine( cor, dst, _default_vtable );
     172                __cfaehm_cancelled_coroutine( cor, dst );
    167173        }
    168174
  • libcfa/src/exception.hfa

    r578c09a rb39e6566  
    142142                _EHM_VTABLE_TYPE(exception_name) parameters const &) {} \
    143143
     144#define _EHM_TRAIT_FUNCTION2(exception_name, forall_clause, parameters) \
     145        forall_clause _EHM_VTABLE_TYPE(exception_name) parameters const & \
     146                        get_exception_vtable(exception_name parameters const & this)
     147
    144148#define __EHM_TRAIT_FUNCTION(exception_name, forall_clause, parameters) \
    145149        forall_clause inline _EHM_VTABLE_TYPE(exception_name) parameters const & \
  • src/Concurrency/Keywords.cc

    r578c09a rb39e6566  
    414414                if ( type_decl && isDestructorFor( decl, type_decl ) )
    415415                        dtor_decl = decl;
    416                 else if ( vtable_name.empty() || !decl->has_body() )
     416                else if ( vtable_name.empty() )
     417                        ;
     418                else if( !decl->has_body() )
    417419                        ;
    418420                else if ( auto param = isMainFor( decl, cast_target ) ) {
     
    426428                        std::list< Expression * > poly_args = { new TypeExpr( struct_type->clone() ) };
    427429                        ObjectDecl * vtable_object = Virtual::makeVtableInstance(
    428                                 "_default_vtable_object_declaration",
    429430                                vtable_decl->makeInst( poly_args ), struct_type, nullptr );
    430431                        declsToAddAfter.push_back( vtable_object );
    431                         declsToAddAfter.push_back(
    432                                 new ObjectDecl(
    433                                         Virtual::concurrentDefaultVTableName(),
    434                                         Type::Const,
    435                                         LinkageSpec::Cforall,
    436                                         /* bitfieldWidth */ nullptr,
    437                                         new ReferenceType( Type::Const, vtable_object->type->clone() ),
    438                                         new SingleInit( new VariableExpr( vtable_object ) )
    439                                 )
    440                         );
    441432                        declsToAddAfter.push_back( Virtual::makeGetExceptionFunction(
    442433                                vtable_object, except_decl->makeInst( std::move( poly_args ) )
     
    497488                        except_decl->makeInst( poly_args )
    498489                ) );
    499                 ObjectDecl * vtable_object = Virtual::makeVtableForward(
    500                         "_default_vtable_object_declaration",
    501                         vtable_decl->makeInst( move( poly_args ) ) );
    502                 declsToAddBefore.push_back( vtable_object );
    503                 declsToAddAfter.push_back(
    504                         new ObjectDecl(
    505                                 Virtual::concurrentDefaultVTableName(),
    506                                 Type::Const,
    507                                 LinkageSpec::Cforall,
    508                                 /* bitfieldWidth */ nullptr,
    509                                 new ReferenceType( Type::Const, vtable_object->type->clone() ),
    510                                 /* init */ nullptr
    511                         )
    512                 );
     490                declsToAddBefore.push_back( Virtual::makeVtableForward(
     491                        vtable_decl->makeInst( move( poly_args ) ) ) );
    513492        }
    514493
  • src/Virtual/Tables.cc

    r578c09a rb39e6566  
    1010// Created On       : Mon Aug 31 11:11:00 2020
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 21 15:36:00 2021
    13 // Update Count     : 2
     12// Last Modified On : Thr Apr  8 15:51:00 2021
     13// Update Count     : 1
    1414//
    1515
     
    5050}
    5151
    52 std::string concurrentDefaultVTableName() {
    53         return "_default_vtable";
    54 }
    55 
    5652bool isVTableInstanceName( std::string const & name ) {
    5753        // There are some delicate length calculations here.
     
    6157
    6258static ObjectDecl * makeVtableDeclaration(
    63                 std::string const & name,
    6459                StructInstType * type, Initializer * init ) {
     60        std::string const & name = instanceName( type->name );
    6561        Type::StorageClasses storage = noStorageClasses;
    6662        if ( nullptr == init ) {
     
    7773}
    7874
    79 ObjectDecl * makeVtableForward( std::string const & name, StructInstType * type ) {
     75ObjectDecl * makeVtableForward( StructInstType * type ) {
    8076        assert( type );
    81         return makeVtableDeclaration( name, type, nullptr );
     77        return makeVtableDeclaration( type, nullptr );
    8278}
    8379
    8480ObjectDecl * makeVtableInstance(
    85                 std::string const & name, StructInstType * vtableType,
    86                 Type * objectType, Initializer * init ) {
     81                StructInstType * vtableType, Type * objectType, Initializer * init ) {
    8782        assert( vtableType );
    8883        assert( objectType );
     
    120115                assert(false);
    121116        }
    122         return makeVtableDeclaration( name, vtableType, init );
     117        return makeVtableDeclaration( vtableType, init );
    123118}
    124119
     
    172167}
    173168
     169ObjectDecl * makeTypeIdForward() {
     170        return nullptr;
     171}
     172
    174173Attribute * linkonce( const std::string & subsection ) {
    175174        const std::string section = ".gnu.linkonce." + subsection;
  • src/Virtual/Tables.h

    r578c09a rb39e6566  
    1010// Created On       : Mon Aug 31 11:07:00 2020
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Apr 21 10:30:00 2021
    13 // Update Count     : 2
     12// Last Modified On : Thr Apr  8 15:55:00 2021
     13// Update Count     : 1
    1414//
    1515
     
    2727std::string instanceName( std::string const & vtable_name );
    2828std::string vtableInstanceName( std::string const & type_name );
    29 std::string concurrentDefaultVTableName();
    3029bool isVTableInstanceName( std::string const & name );
    3130
    32 ObjectDecl * makeVtableForward(
    33         std::string const & name, StructInstType * vtableType );
     31ObjectDecl * makeVtableForward( StructInstType * vtableType );
    3432/* Create a forward declaration of a vtable of the given type.
    3533 * vtableType node is consumed.
    3634 */
    3735
    38 ObjectDecl * makeVtableInstance(
    39         std::string const & name,
    40         StructInstType * vtableType, Type * objectType,
     36ObjectDecl * makeVtableInstance( StructInstType * vtableType, Type * objectType,
    4137        Initializer * init = nullptr );
    4238/* Create an initialized definition of a vtable.
  • tests/exceptions/cancel/coroutine.cfa

    r578c09a rb39e6566  
    2525                resume(cancel);
    2626                printf("4");
    27         } catchResume (CoroutineCancelled(WillCancel) * error) {
     27        } catchResume (SomeCoroutineCancelled * error) {
    2828                printf("2");
    2929                if ((virtual internal_error *)error->the_exception) {
Note: See TracChangeset for help on using the changeset viewer.