- Timestamp:
- Feb 7, 2026, 1:40:26 PM (6 days ago)
- Branches:
- stuck-waitfor-destruct
- Parents:
- c7d106a
- git-author:
- Matthew Au-Yeung <mw2auyeu@…> (02/07/26 13:40:05)
- git-committer:
- Matthew Au-Yeung <mw2auyeu@…> (02/07/26 13:40:26)
- Location:
- src
- Files:
-
- 1 added
- 3 edited
-
Concurrency/Keywords.cpp (modified) (7 diffs)
-
Concurrency/MutexFuncHash.hpp (added)
-
Concurrency/Waitfor.cpp (modified) (2 diffs)
-
Validate/Autogen.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
src/Concurrency/Keywords.cpp
rc7d106a ra9ce782 29 29 #include "Common/Examine.hpp" 30 30 #include "Common/Utility.hpp" 31 #include "Concurrency/MutexFuncHash.hpp" 31 32 #include "Common/UniqueName.hpp" 32 33 #include "ControlStruct/LabelGenerator.hpp" … … 1077 1078 1078 1079 // In reverse order: 1079 // monitor_dtor_guard_t __guard = { __monitor, func, f alse };1080 // monitor_dtor_guard_t __guard = { __monitor, func, func_id, false }; 1080 1081 mutBody->push_front( 1081 1082 new ast::DeclStmt( location, new ast::ObjectDecl( … … 1094 1095 generic_func, 1095 1096 ast::ExplicitCast ) ), 1097 new ast::SingleInit( location, 1098 Concurrency::hashMangleExpr( location, func ) ), 1096 1099 new ast::SingleInit( location, 1097 1100 ast::ConstantExpr::from_bool( location, false ) ), … … 1175 1178 ast::ExplicitCast 1176 1179 ) ), 1180 new ast::SingleInit( location, 1181 Concurrency::hashMangleExpr( location, func ) ), 1177 1182 }, 1178 1183 {}, … … 1475 1480 1476 1481 ast::CompoundStmt * MutexKeyword::addThreadDtorStatements( 1477 const ast::FunctionDecl* , const ast::CompoundStmt * body,1482 const ast::FunctionDecl* func, const ast::CompoundStmt * body, 1478 1483 const std::vector<const ast::DeclWithType * > & args ) { 1479 1484 assert( args.size() == 1 ); … … 1487 1492 const CodeLocation & location = mutBody->location; 1488 1493 1489 // thread_dtor_guard_t __guard = { this, intptr( 0 ) };1494 // thread_dtor_guard_t __guard = { this, func_id, intptr( 0 ) }; 1490 1495 mutBody->push_front( new ast::DeclStmt( 1491 1496 location, … … 1500 1505 new ast::CastExpr( location, 1501 1506 new ast::VariableExpr( location, arg ), argType ) ), 1507 new ast::SingleInit( location, 1508 Concurrency::hashMangleExpr( location, func ) ), 1502 1509 new ast::SingleInit( 1503 1510 location, -
src/Concurrency/Waitfor.cpp
rc7d106a ra9ce782 22 22 #include "InitTweak/InitTweak.hpp" 23 23 #include "ResolvExpr/Resolver.hpp" 24 #include "Concurrency/MutexFuncHash.hpp" 24 25 25 26 #include "AST/Print.hpp" … … 331 332 makeAccStmt( location, acceptables, index, "func", 332 333 funcExpr, context ), 334 makeAccStmt( location, acceptables, index, "func_id", 335 Concurrency::hashMangleExpr( location, 336 variableExpr->var.strict_as<ast::DeclWithType>() ), 337 context ), 333 338 makeAccStmt( location, acceptables, index, "data", 334 339 new ast::VariableExpr( location, monitors ), context ), -
src/Validate/Autogen.cpp
rc7d106a ra9ce782 402 402 } 403 403 404 ast::FunctionDecl * decl = genProto( "^?{}", { dst }, {} ); 405 // For concurrent types, remove static storage and inline specifier, and add 406 // cfa_linkonce attribute so the destructor has external linkage with linkonce 407 // semantics. This is required for waitfor to work correctly across translation 408 // units - the function pointer must be the same everywhere, and cfa_linkonce 409 // ensures only one definition survives linking. 410 if ( isConcurrentType() ) { 411 auto mut = ast::mutate( decl ); 412 mut->storage = ast::Storage::Classes(); 413 mut->funcSpec = ast::Function::Specs(); 414 mut->attributes.push_back( new ast::Attribute( "cfa_linkonce" ) ); 415 } 416 return decl; 404 return genProto( "^?{}", { dst }, {} ); 417 405 } 418 406
Note:
See TracChangeset
for help on using the changeset viewer.