Changeset 310e5b7


Ignore:
Timestamp:
Sep 14, 2017, 4:26:54 PM (4 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
e149f77
Parents:
1dcd9554
Message:

Fix some issues with waitfor... it appears to work!

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Waitfor.cc

    r1dcd9554 r310e5b7  
    204204                        return new ConstantExpr( Constant::from_bool( ifnull ) );
    205205                }
     206
     207                VariableExpr * extractVariable( Expression * func ) {
     208                        if( VariableExpr * var = dynamic_cast< VariableExpr * >( func ) ) {
     209                                return var;
     210                        }
     211
     212                        CastExpr * cast = strict_dynamic_cast< CastExpr * >( func );
     213                        return strict_dynamic_cast< VariableExpr * >( cast->arg );
     214                }
     215
     216                Expression * betterIsDtor( Expression * func ) {
     217                        VariableExpr * typed_func = extractVariable( func );
     218                        bool is_dtor = InitTweak::isDestructor( typed_func->var );
     219                        return new ConstantExpr( Constant::from_bool( is_dtor ) );
     220                }
    206221        };
    207222
     
    212227
    213228        void GenerateWaitForPass::premutate( FunctionDecl * decl) {
    214                 if( decl->name != "__accept_internal" ) return;
     229                if( decl->name != "__waitfor_internal" ) return;
    215230
    216231                decl_waitfor = decl;
     
    313328                Type * fptr_t = new PointerType( noQualifiers, new FunctionType( noQualifiers, true ) );
    314329
     330                Expression * is_dtor = betterIsDtor( clause.target.function );
    315331                CompoundStmt * compound = new CompoundStmt( noLabels );
    316332                compound->push_back( makeAccStatement( acceptables, index, "func"    , new CastExpr( clause.target.function, fptr_t )                            , indexer ) );
    317333                compound->push_back( makeAccStatement( acceptables, index, "count"   , new ConstantExpr( Constant::from_ulong( clause.target.arguments.size() ) ), indexer ) );
    318334                compound->push_back( makeAccStatement( acceptables, index, "monitors", new VariableExpr( monitors )                                              , indexer ) );
    319                 compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , new ConstantExpr( Constant::from_bool( true ) )                           , indexer ) );
     335                compound->push_back( makeAccStatement( acceptables, index, "is_dtor" , is_dtor                                                                   , indexer ) );
    320336
    321337                stmt->push_back( new IfStmt(
  • src/Parser/StatementNode.cc

    r1dcd9554 r310e5b7  
    250250        delete targetExpr;
    251251
    252         node->clauses.push_back( WaitForStmt::Clause{
     252        node->clauses.insert( node->clauses.begin(), WaitForStmt::Clause{
    253253                std::move( target ),
    254254                maybeMoveBuild<Statement >( stmt ),
  • src/Parser/parserutility.cc

    r1dcd9554 r310e5b7  
    2929
    3030Expression *notZeroExpr( Expression *orig ) {
     31        if( !orig ) return nullptr;
    3132        UntypedExpr *comparison = new UntypedExpr( new NameExpr( "?!=?" ) );
    3233        comparison->get_args().push_back( orig );
  • src/libcfa/concurrency/monitor

    r1dcd9554 r310e5b7  
    111111};
    112112
    113 int __accept_internal( unsigned short count, __acceptable_t * acceptables, int duration );
     113int __waitfor_internal( unsigned short count, __acceptable_t * acceptables, int duration );
    114114
    115115// Local Variables: //
  • src/libcfa/concurrency/monitor.c

    r1dcd9554 r310e5b7  
    398398//-----------------------------------------------------------------------------
    399399// Internal scheduling
    400 int __accept_internal( unsigned short acc_count, __acceptable_t * acceptables ) {
     400int __waitfor_internal( unsigned short acc_count, __acceptable_t * acceptables ) {
    401401        thread_desc * thrd = this_thread;
    402402
  • src/tests/sched-ext-parse.c

    r1dcd9554 r310e5b7  
    1616        //---------------------------------------
    1717        waitfor( f1, a ) {
    18                 1;
     18                // 1;
    1919        }
    2020
     
    8080                16;
    8181        }
    82         or waitfor( f1, a, a ) {
     82        or waitfor( f2, a, a ) {
    8383                17;
    8484        }
  • src/tests/sched-ext.c

    r1dcd9554 r310e5b7  
    4545        acceptable.monitors      = &a;
    4646
    47         __accept_internal( 1, &acceptable );
     47        __waitfor_internal( 1, &acceptable );
    4848
    4949        sout | "Accepted" | endl;
Note: See TracChangeset for help on using the changeset viewer.