Changeset 8a930c03 for src/Concurrency/Waituntil.cpp
- Timestamp:
- Jun 12, 2023, 12:05:58 PM (2 years ago)
- Branches:
- master
- Children:
- fec8bd1
- Parents:
- 2b78949 (diff), 38e266ca (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Waituntil.cpp
r2b78949 r8a930c03 14 14 // 15 15 16 #include "Waituntil.hpp" 17 16 18 #include <string> 17 19 18 #include " Waituntil.hpp"20 #include "AST/Copy.hpp" 19 21 #include "AST/Expr.hpp" 20 22 #include "AST/Pass.hpp" … … 93 95 case 0: 94 96 try { 95 if (on_selected( A, clause1 ))97 on_selected( A, clause1 ); 96 98 doA(); 97 99 } … … 120 122 // the unregister and on_selected calls are needed to support primitives where the acquire has side effects 121 123 // so the corresponding block MUST be run for those primitives to not lose state (example is channels) 122 if ( ! has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) && on_selected( A, clause1 ) ) 124 if ( !has_run(clause_statuses[0]) && whenA && unregister_select(A, clause1) ) 125 on_selected( A, clause1 ) 123 126 doA(); 124 127 ... repeat if above for B and C ... … … 617 620 618 621 // Generates: 619 /* if ( on_selected( target_1, node_1 ))... corresponding body of target_1 ...622 /* on_selected( target_1, node_1 ); ... corresponding body of target_1 ... 620 623 */ 621 624 CompoundStmt * GenerateWaitUntilCore::genStmtBlock( const WhenClause * clause, const ClauseData * data ) { … … 623 626 return new CompoundStmt( cLoc, 624 627 { 625 new IfStmt( cLoc, 626 genSelectTraitCall( clause, data, "on_selected" ), 627 new CompoundStmt( cLoc, 628 { 629 ast::deepCopy( clause->stmt ) 630 } 631 ) 632 ) 628 new ExprStmt( cLoc, 629 genSelectTraitCall( clause, data, "on_selected" ) 630 ), 631 ast::deepCopy( clause->stmt ) 633 632 } 634 633 ); … … 642 641 case 0: 643 642 try { 644 if (on_selected( target1, clause1 ))645 643 on_selected( target1, clause1 ); 644 dotarget1stmt(); 646 645 } 647 646 finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); } … … 662 661 case 0: 663 662 try { 664 if (on_selected( target1, clause1 ))665 663 on_selected( target1, clause1 ); 664 dotarget1stmt(); 666 665 } 667 666 finally { clause_statuses[i] = __SELECT_RUN; unregister_select(target1, clause1); } … … 938 937 } 939 938 940 // C_TODO: will remove this commented code later. Currently it isn't needed but may switch to a modified version of this later if it has better performance941 // std::vector<ptr<CaseClause>> switchCases;942 943 // int idx = 0;944 // for ( const auto & clause: stmt->clauses ) {945 // const CodeLocation & cLoc = clause->location;946 // switchCases.push_back(947 // new CaseClause( cLoc,948 // new CastExpr( cLoc,949 // new AddressExpr( cLoc, new NameExpr( cLoc, data.at(idx)->targetName ) ),950 // new BasicType( BasicType::Kind::LongUnsignedInt ), GeneratedFlag::ExplicitCast951 // ),952 // {953 // new CompoundStmt( cLoc,954 // {955 // ast::deepCopy( clause->stmt ),956 // new BranchStmt( cLoc, BranchStmt::Kind::Break, Label( cLoc ) )957 // }958 // )959 // }960 // )961 // );962 // idx++;963 // }964 965 939 return new CompoundStmt( loc, 966 940 { 967 941 new ExprStmt( loc, new UntypedExpr( loc, new NameExpr( loc, "park" ) ) ), 968 942 outerIf 969 // new SwitchStmt( loc,970 // new NameExpr( loc, statusName ),971 // std::move( switchCases )972 // )973 943 } 974 944 ); … … 1013 983 const CodeLocation & cLoc = stmt->clauses.at(idx)->location; 1014 984 985 Expr * baseCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ); 1015 986 Expr * ifCond; 1016 987 … … 1023 994 ), 1024 995 new CastExpr( cLoc, 1025 genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" ),996 baseCond, 1026 997 new BasicType( BasicType::Kind::Bool ), GeneratedFlag::ExplicitCast 1027 998 ), 1028 999 LogicalFlag::AndExpr 1029 1000 ); 1030 } else ifCond = genSelectTraitCall( stmt->clauses.at(idx), data.at(idx), "register_select" );1001 } else ifCond = baseCond; 1031 1002 1032 1003 return new CompoundStmt( cLoc, … … 1046 1017 ifCond, 1047 1018 genStmtBlock( stmt->clauses.at(idx), data.at(idx) ), 1048 // ast::deepCopy( stmt->clauses.at(idx)->stmt ),1049 1019 recursiveOrIfGen( stmt, data, idx + 1, elseWhenName ) 1050 1020 )
Note:
See TracChangeset
for help on using the changeset viewer.