Changeset 97e3296 for src/Concurrency


Ignore:
Timestamp:
Aug 17, 2017, 3:42:16 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
6ac5223
Parents:
f710aca
Message:

First working implementation of external scheduling... Still lots of testing to do

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Concurrency/Keywords.cc

    rf710aca r97e3296  
    200200                std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
    201201                void validate( DeclarationWithType * );
    202                 void addStatments( CompoundStmt *, const std::list<DeclarationWithType * > &);
     202                void addStatments( FunctionDecl* func, CompoundStmt *, const std::list<DeclarationWithType * > &);
    203203
    204204                static void implement( std::list< Declaration * > & translationUnit ) {
     
    210210                StructDecl* monitor_decl = nullptr;
    211211                StructDecl* guard_decl = nullptr;
     212
     213                static std::unique_ptr< Type > generic_func;
    212214        };
     215
     216        std::unique_ptr< Type > MutexKeyword::generic_func = std::unique_ptr< Type >(
     217                new FunctionType(
     218                        noQualifiers,
     219                        true
     220                )
     221        );
    213222
    214223        //-----------------------------------------------------------------------------
     
    394403        // Mutex keyword implementation
    395404        //=============================================================================================
     405
    396406        void MutexKeyword::visit(FunctionDecl* decl) {
    397407                Visitor::visit(decl);
     
    410420                if( !guard_decl ) throw SemanticError( "mutex keyword requires monitors to be in scope, add #include <monitor>", decl );
    411421
    412                 addStatments( body, mutexArgs );
     422                addStatments( decl, body, mutexArgs );
    413423        }
    414424
     
    456466        }
    457467
    458         void MutexKeyword::addStatments( CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
     468        void MutexKeyword::addStatments( FunctionDecl* func, CompoundStmt * body, const std::list<DeclarationWithType * > & args ) {
    459469                ObjectDecl * monitors = new ObjectDecl(
    460470                        "__monitors",
     
    487497                );
    488498
     499                assert(generic_func);
     500
    489501                //in reverse order :
    490                 // monitor_guard_t __guard = { __monitors, # };
     502                // monitor_guard_t __guard = { __monitors, #, func };
    491503                body->push_front(
    492504                        new DeclStmt( noLabels, new ObjectDecl(
     
    502514                                        {
    503515                                                new SingleInit( new VariableExpr( monitors ) ),
    504                                                 new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) )
     516                                                new SingleInit( new ConstantExpr( Constant::from_ulong( args.size() ) ) ),
     517                                                new SingleInit( new CastExpr( new VariableExpr( func ), generic_func->clone() ) )
    505518                                        },
    506519                                        noDesignators,
Note: See TracChangeset for help on using the changeset viewer.