- Timestamp:
- Feb 4, 2025, 10:10:11 AM (8 weeks ago)
- Branches:
- master
- Children:
- 332e93a
- Parents:
- dfe8f78
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Concurrency/Actors.cpp ¶
rdfe8f78 r1ee74df 29 29 struct CollectactorStructDecls : public ast::WithGuards { 30 30 unordered_set<const StructDecl *> & actorStructDecls; 31 unordered_set<const StructDecl *> 32 const StructDecl * *requestDecl;33 const EnumDecl * *allocationDecl;34 const StructDecl * *actorDecl;35 const StructDecl * *msgDecl;31 unordered_set<const StructDecl *> & messageStructDecls; 32 const StructDecl *& requestDecl; 33 const EnumDecl *& allocationDecl; 34 const StructDecl *& actorDecl; 35 const StructDecl *& msgDecl; 36 36 StructDecl * parentDecl; 37 37 bool insideStruct = false; … … 40 40 // finds and sets a ptr to the allocation enum, which is needed in the next pass 41 41 void previsit( const EnumDecl * decl ) { 42 if( decl->name == "allocation" ) *allocationDecl = decl;42 if( decl->name == "allocation" ) allocationDecl = decl; 43 43 } 44 44 … … 48 48 if ( decl->name == "actor" ) { 49 49 actorStructDecls.insert( decl ); // skip inserting fwd decl 50 *actorDecl = decl;50 actorDecl = decl; 51 51 } else if( decl->name == "message" ) { 52 52 messageStructDecls.insert( decl ); // skip inserting fwd decl 53 *msgDecl = decl; 54 } else if( decl->name == "request" ) *requestDecl = decl; 55 else { 53 msgDecl = decl; 54 } else if( decl->name == "request" ) { 55 requestDecl = decl; 56 } else { 56 57 GuardValue(insideStruct); 57 58 insideStruct = true; … … 73 74 // this collects the derived actor and message struct decl ptrs 74 75 void postvisit( const StructInstType * node ) { 75 if ( ! *actorDecl || ! *msgDecl ) return;76 if ( !actorDecl || !msgDecl ) return; 76 77 if ( insideStruct && !namedDecl ) { 77 78 auto actorIter = actorStructDecls.find( node->aggr() ); … … 89 90 public: 90 91 CollectactorStructDecls( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 91 const StructDecl * * requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl **msgDecl )92 const StructDecl *& requestDecl, const EnumDecl *& allocationDecl, const StructDecl *& actorDecl, const StructDecl *& msgDecl ) 92 93 : actorStructDecls( actorStructDecls ), messageStructDecls( messageStructDecls ), requestDecl( requestDecl ), 93 94 allocationDecl( allocationDecl ), actorDecl(actorDecl), msgDecl(msgDecl) {} … … 196 197 struct GenFuncsCreateTables : public ast::WithDeclsToAdd { 197 198 unordered_set<const StructDecl *> & actorStructDecls; 198 unordered_set<const StructDecl *> 199 const StructDecl * *requestDecl;200 const EnumDecl * *allocationDecl;201 const StructDecl * *actorDecl;202 const StructDecl * *msgDecl;199 unordered_set<const StructDecl *> & messageStructDecls; 200 const StructDecl *& requestDecl; 201 const EnumDecl *& allocationDecl; 202 const StructDecl *& actorDecl; 203 const StructDecl *& msgDecl; 203 204 FwdDeclTable & forwardDecls; 204 205 … … 279 280 decl->location, 280 281 "base_actor", 281 new PointerType( new PointerType( new StructInstType( *actorDecl ) ) )282 new PointerType( new PointerType( new StructInstType( actorDecl ) ) ) 282 283 ), 283 284 new ObjectDecl( 284 285 decl->location, 285 286 "base_msg", 286 new PointerType( new PointerType( new StructInstType( *msgDecl ) ) )287 new PointerType( new PointerType( new StructInstType( msgDecl ) ) ) 287 288 ) 288 289 }, // params … … 291 292 decl->location, 292 293 "__CFA_receive_wrap_ret", 293 new EnumInstType( *allocationDecl )294 new EnumInstType( allocationDecl ) 294 295 ) 295 296 }, … … 323 324 decl->location, 324 325 "new_req", 325 new StructInstType( *requestDecl )326 new StructInstType( requestDecl ) 326 327 ) 327 328 )); … … 331 332 derivedReceive->params.push_back( ast::deepCopy( derivedActorRef ) ); 332 333 derivedReceive->params.push_back( ast::deepCopy( derivedMsgRef ) ); 333 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *actorDecl ) ) ) );334 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *msgDecl ) ) ) );335 derivedReceive->returns.push_back( new EnumInstType( *allocationDecl ) );334 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( actorDecl ) ) ) ); 335 derivedReceive->params.push_back( new PointerType( new PointerType( new StructInstType( msgDecl ) ) ) ); 336 derivedReceive->returns.push_back( new EnumInstType( allocationDecl ) ); 336 337 337 338 // Generates: allocation (*my_work_fn)( derived_actor &, derived_msg &, actor **, message ** ) = receive; … … 348 349 // Function type is: allocation (*)( actor &, message & ) 349 350 FunctionType * genericReceive = new FunctionType(); 350 genericReceive->params.push_back( new ReferenceType( new StructInstType( *actorDecl ) ) );351 genericReceive->params.push_back( new ReferenceType( new StructInstType( *msgDecl ) ) );352 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *actorDecl ) ) ) );353 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( *msgDecl ) ) ) );354 genericReceive->returns.push_back( new EnumInstType( *allocationDecl ) );351 genericReceive->params.push_back( new ReferenceType( new StructInstType( actorDecl ) ) ); 352 genericReceive->params.push_back( new ReferenceType( new StructInstType( msgDecl ) ) ); 353 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( actorDecl ) ) ) ); 354 genericReceive->params.push_back( new PointerType( new PointerType( new StructInstType( msgDecl ) ) ) ); 355 genericReceive->returns.push_back( new EnumInstType( allocationDecl ) ); 355 356 356 357 // Generates: allocation (*fn)( actor &, message & ) = (allocation (*)( actor &, message & ))my_work_fn; … … 378 379 { 379 380 new NameExpr( decl->location, "new_req" ), 380 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "receiver" ) ), new PointerType( new StructInstType( *actorDecl ) ), ExplicitCast ),381 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "msg" ) ), new PointerType( new StructInstType( *msgDecl ) ), ExplicitCast ),381 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "receiver" ) ), new PointerType( new StructInstType( actorDecl ) ), ExplicitCast ), 382 new CastExpr( decl->location, new AddressExpr( new NameExpr( decl->location, "msg" ) ), new PointerType( new StructInstType( msgDecl ) ), ExplicitCast ), 382 383 new NameExpr( decl->location, "fn" ) 383 384 } … … 443 444 public: 444 445 GenFuncsCreateTables( unordered_set<const StructDecl *> & actorStructDecls, unordered_set<const StructDecl *> & messageStructDecls, 445 const StructDecl * * requestDecl, const EnumDecl ** allocationDecl, const StructDecl ** actorDecl, const StructDecl **msgDecl,446 const StructDecl *& requestDecl, const EnumDecl *& allocationDecl, const StructDecl *& actorDecl, const StructDecl *& msgDecl, 446 447 FwdDeclTable & forwardDecls ) : actorStructDecls(actorStructDecls), messageStructDecls(messageStructDecls), 447 448 requestDecl(requestDecl), allocationDecl(allocationDecl), actorDecl(actorDecl), msgDecl(msgDecl), forwardDecls(forwardDecls) {} … … 453 454 struct FwdDeclOperator : public ast::WithDeclsToAdd { 454 455 unordered_set<const StructDecl *> & actorStructDecls; 455 unordered_set<const StructDecl *> 456 unordered_set<const StructDecl *> & messageStructDecls; 456 457 FwdDeclTable & forwardDecls; 457 458 … … 495 496 // for storing through the passes 496 497 // these are populated with various important struct decls 497 const StructDecl * requestDeclPtr = nullptr; 498 const EnumDecl * allocationDeclPtr = nullptr; 499 const StructDecl * actorDeclPtr = nullptr; 500 const StructDecl * msgDeclPtr = nullptr; 501 502 // double pointer to modify local ptrs above 503 const StructDecl ** requestDecl = &requestDeclPtr; 504 const EnumDecl ** allocationDecl = &allocationDeclPtr; 505 const StructDecl ** actorDecl = &actorDeclPtr; 506 const StructDecl ** msgDecl = &msgDeclPtr; 498 const StructDecl * requestDecl = nullptr; 499 const EnumDecl * allocationDecl = nullptr; 500 const StructDecl * actorDecl = nullptr; 501 const StructDecl * msgDecl = nullptr; 507 502 508 503 // first pass collects ptrs to allocation enum, request type, and generic receive fn typedef 509 504 // also populates maps of all derived actors and messages 510 Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,511 allocationDecl, actorDecl, msgDecl );505 Pass<CollectactorStructDecls>::run( translationUnit, actorStructDecls, messageStructDecls, 506 requestDecl, allocationDecl, actorDecl, msgDecl ); 512 507 513 508 // check that we have found all the decls we need from <actor.hfa>, if not no need to run the rest of this pass 514 if ( !allocationDecl Ptr || !requestDeclPtr || !actorDeclPtr || !msgDeclPtr)509 if ( !allocationDecl || !requestDecl || !actorDecl || !msgDecl ) 515 510 return; 516 511 517 512 // second pass locates all receive() routines that overload the generic receive fn 518 513 // it then generates the appropriate operator '|' send routines for the receive routines 519 Pass<GenFuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, requestDecl,520 allocationDecl, actorDecl, msgDecl, forwardDecls );514 Pass<GenFuncsCreateTables>::run( translationUnit, actorStructDecls, messageStructDecls, 515 requestDecl, allocationDecl, actorDecl, msgDecl, forwardDecls ); 521 516 522 517 // The third pass forward declares operator '|' send routines
Note: See TracChangeset
for help on using the changeset viewer.