Changes in / [713905fd:e6e1a12]


Ignore:
Files:
4 deleted
10 edited

Legend:

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

    r713905fd re6e1a12  
    121121        last = 0p;
    122122        cancellation = 0p;
    123     ehm_state.ehm_buffer{};
    124     ehm_state.buffer_lock{};
    125     ehm_state.ehm_enabled = false;
    126123}
    127124
     
    286283}
    287284
    288 
    289 ////////////////////////////////////////////////////////////////////////////////////////////////////
    290 // non local ehm routines
    291 
    292 // helper for popping from coroutine's ehm buffer
    293 inline nonlocal_exception * pop_ehm_head( coroutine$ * this ) {
    294     lock( this->ehm_state.buffer_lock __cfaabi_dbg_ctx2 );
    295     nonlocal_exception * nl_ex = pop_head( this->ehm_state.ehm_buffer );
    296     unlock( this->ehm_state.buffer_lock );
    297     return nl_ex;
    298 }
    299 
    300 // user facing ehm operations
    301 forall(T & | is_coroutine(T)) {
    302     // enable/disable non-local exceptions
    303     void enable_ehm( T & cor ) libcfa_public { get_coroutine( cor )->ehm_state.ehm_enabled = true; }
    304     void disable_ehm( T & cor ) libcfa_public { get_coroutine( cor )->ehm_state.ehm_enabled = false; }
    305 
    306     // poll for non-local exceptions
    307     bool poll( T & cor ) libcfa_public {
    308         coroutine$ * base_cor = get_coroutine( cor );
    309         nonlocal_exception * nl_ex = pop_ehm_head( base_cor );
    310 
    311         // if no exceptions return false
    312         if ( nl_ex == 0p ) return false;
    313        
    314         // otherwise loop and throwResume all pending exceptions
    315         while ( nl_ex != 0p ){
    316             exception_t * ex = nl_ex->the_exception;
    317             free( nl_ex );
    318             throwResume *ex;
    319             nl_ex = pop_ehm_head( base_cor );
    320         }
    321        
    322         return true;
    323     }
    324 
    325     // poll iff nonlocal ehm is enabled
    326     bool checked_poll( T & cor ) libcfa_public { return get_coroutine( cor )->ehm_state.ehm_enabled ? poll( cor ) : false; }
    327 }
    328 
    329 // resume non local exception at receiver (i.e. enqueue in ehm buffer)
    330 forall(exceptT &, T & | ehm_resume_at( exceptT, T ))
    331 void resumeAt( T & receiver, exceptT & ex )  libcfa_public {
    332     coroutine$ * cor = get_coroutine( receiver );
    333     nonlocal_exception * nl_ex = alloc();
    334     (*nl_ex){ (exception_t *)&ex };
    335     lock( cor->ehm_state.buffer_lock __cfaabi_dbg_ctx2 );
    336     append( cor->ehm_state.ehm_buffer, nl_ex );
    337     unlock( cor->ehm_state.buffer_lock );
    338 }
    339 
    340285// Local Variables: //
    341286// mode: c //
  • libcfa/src/concurrency/coroutine.hfa

    r713905fd re6e1a12  
    1919#include "invoke.h"
    2020#include "../exception.hfa"
    21 
    22 //-----------------------------------------------------------------------------
    23 // Type used to store and queue nonlocal exceptions on coroutines
    24 struct nonlocal_exception {
    25     exception_t * the_exception;
    26     nonlocal_exception * next;
    27 };
    28 static inline void ?{} ( nonlocal_exception & this, exception_t * ex ) with(this) {
    29     the_exception = ex;
    30     next = 0p;
    31 }
    32 
    33 static inline nonlocal_exception *& get_next( nonlocal_exception & this ) __attribute__((const)) {
    34     return this.next;
    35 }
    3621
    3722//-----------------------------------------------------------------------------
     
    218203}
    219204
    220 // non local ehm routines
    221 forall(T & | is_coroutine(T)) {
    222     void enable_ehm( T & cor );
    223     void disable_ehm( T & cor );
    224     bool poll( T & cor );
    225     bool checked_poll( T & cor );
    226 }
    227 
    228 // trait for exceptions able to be resumed at another coroutine
    229 forall(exceptT &, T & | is_coroutine(T))
    230 trait ehm_resume_at { void $throwResume(exceptT &); };
    231 
    232 forall(exceptT &, T & | ehm_resume_at( exceptT, T ))
    233 void resumeAt( T & receiver, exceptT & ex );
    234 
    235205// Local Variables: //
    236206// mode: c //
  • libcfa/src/concurrency/invoke.h

    r713905fd re6e1a12  
    7474        };
    7575
    76     struct nonlocal_ehm {
    77         // list of pending nonlocal exceptions
    78         __queue_t(struct nonlocal_exception) ehm_buffer;
    79 
    80         // lock to protect the buffer
    81         struct __spinlock_t buffer_lock;
    82 
    83         // enable/disabled flag
    84         bool ehm_enabled;
    85     };
    86 
    8776        enum __Coroutine_State { Halted, Start, Primed, Blocked, Ready, Active, Cancelled, Halting };
    8877
     
    10998                struct _Unwind_Exception * cancellation;
    11099
    111         // Non-local exception handling information
    112         struct nonlocal_ehm ehm_state;
    113100        };
    114101        // Wrapper for gdb
  • src/AST/Decl.hpp

    r713905fd re6e1a12  
    6969public:
    7070        /// Represents the type with all types and typedefs expanded.
     71        /// This field is generated by SymTab::Validate::Pass2
    7172        std::string mangleName;
    7273        /// Stores the scope level at which the variable was declared.
  • src/AST/SymbolTable.cpp

    r713905fd re6e1a12  
    1919
    2020#include "Copy.hpp"
     21#include <iostream>
     22#include <algorithm>
     23
    2124#include "Decl.hpp"
    2225#include "Expr.hpp"
     
    203206                        out.push_back(decl.second);
    204207                }
     208
     209                // std::cerr << otypeKey << ' ' << out.size() << std::endl;
    205210        }
    206211
  • src/GenPoly/SpecializeNew.cpp

    r713905fd re6e1a12  
    104104
    105105bool needsPolySpecialization(
    106                 const ast::Type * /*formalType*/,
     106                const ast::Type * formalType,
    107107                const ast::Type * actualType,
    108108                const ast::TypeSubstitution * subs ) {
     
    126126                        if ( closedVars.find( *inst ) == closedVars.end() ) {
    127127                                return true;
    128                         } else {
     128                        }
     129                        else {
    129130                                assertf(false, "closed: %s", inst->name.c_str());
    130131                        }
  • src/InitTweak/FixInitNew.cpp

    r713905fd re6e1a12  
    2222#include "AST/SymbolTable.hpp"
    2323#include "AST/Type.hpp"
    24 #include "CodeGen/OperatorTable.h"     // for isConstructor, isCtorDtor, isD...
     24#include "CodeGen/GenType.h"           // for genPrettyType
     25#include "CodeGen/OperatorTable.h"
     26#include "Common/PassVisitor.h"        // for PassVisitor, WithStmtsToAdd
    2527#include "Common/SemanticError.h"      // for SemanticError
    2628#include "Common/ToString.hpp"         // for toCString
     
    3133#include "ResolvExpr/Resolver.h"       // for findVoidExpression
    3234#include "ResolvExpr/Unify.h"          // for typesCompatible
     35#include "SymTab/Autogen.h"            // for genImplicitCall
    3336#include "SymTab/GenImplicitCall.hpp"  // for genImplicitCall
     37#include "SymTab/Indexer.h"            // for Indexer
     38#include "SymTab/Mangler.h"            // for Mangler
     39#include "SynTree/LinkageSpec.h"       // for C, Spec, Cforall, isBuiltin
     40#include "SynTree/Attribute.h"         // for Attribute
     41#include "SynTree/Constant.h"          // for Constant
     42#include "SynTree/Declaration.h"       // for ObjectDecl, FunctionDecl, Decl...
     43#include "SynTree/Expression.h"        // for UniqueExpr, VariableExpr, Unty...
     44#include "SynTree/Initializer.h"       // for ConstructorInit, SingleInit
     45#include "SynTree/Label.h"             // for Label, operator<
     46#include "SynTree/Mutator.h"           // for mutateAll, Mutator, maybeMutate
     47#include "SynTree/Statement.h"         // for ExprStmt, CompoundStmt, Branch...
     48#include "SynTree/Type.h"              // for Type, Type::StorageClasses
     49#include "SynTree/TypeSubstitution.h"  // for TypeSubstitution, operator<<
     50#include "SynTree/DeclReplacer.h"      // for DeclReplacer
     51#include "SynTree/Visitor.h"           // for acceptAll, maybeAccept
     52#include "Validate/FindSpecialDecls.h" // for dtorStmt, dtorStructDestroy
    3453
    3554extern bool ctordtorp; // print all debug
  • src/ResolvExpr/CommonType.cc

    r713905fd re6e1a12  
    696696                void postvisit( const ast::BasicType * basic ) {
    697697                        if ( auto basic2 = dynamic_cast< const ast::BasicType * >( type2 ) ) {
     698                                #warning remove casts when `commonTypes` moved to new AST
     699                               
     700                                /*
     701                                ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)basic2->kind ];
     702                                if (
     703                                        ( ( kind == basic->kind && basic->qualifiers >= basic2->qualifiers )
     704                                                || widen.first )
     705                                        && ( ( kind == basic2->kind && basic->qualifiers <= basic2->qualifiers )
     706                                                || widen.second )
     707                                ) {
     708                                        result = new ast::BasicType{ kind, basic->qualifiers | basic2->qualifiers };
     709                                }
     710                                */
    698711                                ast::BasicType::Kind kind;
    699712                                if (basic->kind != basic2->kind && !widen.first && !widen.second) return;
     
    706719                                        result = new ast::BasicType{ kind, basic->qualifiers | basic2->qualifiers };
    707720                                }
     721                               
    708722                        } else if (
    709723                                dynamic_cast< const ast::ZeroType * >( type2 )
    710724                                || dynamic_cast< const ast::OneType * >( type2 )
    711725                        ) {
     726                                #warning remove casts when `commonTypes` moved to new AST
     727                                ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)ast::BasicType::SignedInt ];
     728                                /*
     729                                if ( // xxx - what does qualifier even do here??
     730                                        ( ( basic->qualifiers >= type2->qualifiers )
     731                                                || widen.first )
     732                                         && ( ( /* kind != basic->kind && basic->qualifiers <= type2->qualifiers )
     733                                                || widen.second )
     734                                )
     735                                */
    712736                                if (widen.second) {
    713737                                        result = new ast::BasicType{ basic->kind, basic->qualifiers | type2->qualifiers };
    714738                                }
    715739                        } else if ( const ast::EnumInstType * enumInst = dynamic_cast< const ast::EnumInstType * >( type2 ) ) {
     740                                #warning remove casts when `commonTypes` moved to new AST
    716741                                const ast::EnumDecl* enumDecl = enumInst->base;
    717742                                if ( enumDecl->base ) {
    718743                                        result = enumDecl->base.get();
    719744                                } else {
    720                                         #warning remove casts when `commonTypes` moved to new AST
    721745                                        ast::BasicType::Kind kind = (ast::BasicType::Kind)(int)commonTypes[ (BasicType::Kind)(int)basic->kind ][ (BasicType::Kind)(int)ast::BasicType::SignedInt ];
    722746                                        if (
     
    739763                                auto entry = open.find( *var );
    740764                                if ( entry != open.end() ) {
     765                                // if (tenv.lookup(*var)) {
    741766                                        ast::AssertionSet need, have;
    742767                                        if ( ! tenv.bindVar(
  • src/ResolvExpr/Unify.cc

    r713905fd re6e1a12  
    12981298                auto var1 = dynamic_cast< const ast::TypeInstType * >( type1 );
    12991299                auto var2 = dynamic_cast< const ast::TypeInstType * >( type2 );
     1300                ast::OpenVarSet::const_iterator
     1301                        entry1 = var1 ? open.find( *var1 ) : open.end(),
     1302                        entry2 = var2 ? open.find( *var2 ) : open.end();
     1303                // bool isopen1 = entry1 != open.end();
     1304                // bool isopen2 = entry2 != open.end();
    13001305                bool isopen1 = var1 && env.lookup(*var1);
    13011306                bool isopen2 = var2 && env.lookup(*var2);
    13021307
     1308                /*
     1309                if ( isopen1 && isopen2 ) {
     1310                        if ( entry1->second.kind != entry2->second.kind ) return false;
     1311                        return env.bindVarToVar(
     1312                                var1, var2, ast::TypeData{ entry1->second, entry2->second }, need, have,
     1313                                open, widen );
     1314                } else if ( isopen1 ) {
     1315                        return env.bindVar( var1, type2, entry1->second, need, have, open, widen );
     1316                } else if ( isopen2 ) {
     1317                        return env.bindVar( var2, type1, entry2->second, need, have, open, widen, symtab );
     1318                } */
    13031319                if ( isopen1 && isopen2 ) {
    13041320                        if ( var1->base->kind != var2->base->kind ) return false;
     
    13101326                } else if ( isopen2 ) {
    13111327                        return env.bindVar( var2, type1, ast::TypeData{var2->base}, need, have, open, widen );
    1312                 } else {
     1328                }else {
    13131329                        return ast::Pass<Unify_new>::read(
    13141330                                type1, type2, env, need, have, open, widen );
    13151331                }
     1332               
    13161333        }
    13171334
  • src/Validate/LinkReferenceToTypes.cpp

    r713905fd re6e1a12  
    8080ast::EnumInstType const * LinkTypesCore::postvisit( ast::EnumInstType const * type ) {
    8181        ast::EnumDecl const * decl = symtab.lookupEnum( type->name );
    82         ast::EnumInstType * mut = ast::mutate( type );
    8382        // It's not a semantic error if the enum is not found, just an implicit forward declaration.
    8483        if ( decl ) {
    8584                // Just linking in the node.
     85                auto mut = ast::mutate( type );
    8686                mut->base = decl;
     87                type = mut;
    8788        }
    8889        if ( !decl || !decl->body ) {
     90                auto mut = ast::mutate( type );
    8991                forwardEnums[ mut->name ].push_back( mut );
    90         }
    91         return mut;
     92                type = mut;
     93        }
     94        return type;
    9295}
    9396
    9497ast::StructInstType const * LinkTypesCore::postvisit( ast::StructInstType const * type ) {
    9598        ast::StructDecl const * decl = symtab.lookupStruct( type->name );
    96         ast::StructInstType * mut = ast::mutate( type );
    9799        // It's not a semantic error if the struct is not found, just an implicit forward declaration.
    98100        if ( decl ) {
    99101                // Just linking in the node.
     102                auto mut = ast::mutate( type );
    100103                mut->base = decl;
     104                type = mut;
    101105        }
    102106        if ( !decl || !decl->body ) {
     107                auto mut = ast::mutate( type );
    103108                forwardStructs[ mut->name ].push_back( mut );
    104         }
    105         return mut;
     109                type = mut;
     110        }
     111        return type;
    106112}
    107113
    108114ast::UnionInstType const * LinkTypesCore::postvisit( ast::UnionInstType const * type ) {
    109115        ast::UnionDecl const * decl = symtab.lookupUnion( type->name );
    110         ast::UnionInstType * mut = ast::mutate( type );
    111116        // It's not a semantic error if the union is not found, just an implicit forward declaration.
    112117        if ( decl ) {
    113118                // Just linking in the node.
     119                auto mut = ast::mutate( type );
    114120                mut->base = decl;
     121                type = mut;
    115122        }
    116123        if ( !decl || !decl->body ) {
     124                auto mut = ast::mutate( type );
    117125                forwardUnions[ mut->name ].push_back( mut );
    118         }
    119         return mut;
     126                type = mut;
     127        }
     128        return type;
    120129}
    121130
Note: See TracChangeset for help on using the changeset viewer.