@@ -209,6 +209,16 @@ static uword* LoadStackSlot(uword* ptr) {
209
209
return reinterpret_cast <uword*>(*ptr);
210
210
}
211
211
212
+ #if defined(DART_HOST_OS_MACOS)
213
+ // Mac profiling is cross-thread and TSAN doesn't know that thread_suspend
214
+ // establishes synchronization.
215
+ #define IGNORE_RACE (x ) x##_ignore_race
216
+ #define IGNORE_RACE2 (x ) x##IgnoreRace
217
+ #else
218
+ #define IGNORE_RACE (x ) x
219
+ #define IGNORE_RACE2 (x ) x
220
+ #endif
221
+
212
222
// The layout of C stack frames.
213
223
#if defined(HOST_ARCH_IA32) || defined(HOST_ARCH_X64) || \
214
224
defined (HOST_ARCH_ARM) || defined(HOST_ARCH_ARM64)
@@ -379,7 +389,8 @@ static bool GetAndValidateThreadStackBounds(OSThread* os_thread,
379
389
380
390
#if defined(DART_INCLUDE_SIMULATOR)
381
391
const bool use_simulator_stack_bounds =
382
- FLAG_use_simulator && thread != nullptr && thread->IsExecutingDartCode ();
392
+ FLAG_use_simulator && thread != nullptr &&
393
+ thread->IGNORE_RACE2 (IsExecutingDartCode)();
383
394
if (use_simulator_stack_bounds) {
384
395
Isolate* isolate = thread->isolate ();
385
396
ASSERT (isolate != nullptr );
@@ -1047,8 +1058,8 @@ class ProfilerDartStackWalker : public ProfilerStackWalker {
1047
1058
uword lr,
1048
1059
bool allocation_sample,
1049
1060
intptr_t skip_count = 0 )
1050
- : ProfilerStackWalker((thread->isolate () != nullptr)
1051
- ? thread->isolate()->main_port()
1061
+ : ProfilerStackWalker((thread->IGNORE_RACE ( isolate) () != nullptr)
1062
+ ? thread->IGNORE_RACE( isolate) ()->main_port()
1052
1063
: ILLEGAL_PORT,
1053
1064
sample,
1054
1065
sample_buffer,
@@ -1061,12 +1072,13 @@ class ProfilerDartStackWalker : public ProfilerStackWalker {
1061
1072
1062
1073
void walk () {
1063
1074
RELEASE_ASSERT (StubCode::HasBeenInitialized ());
1064
- if (thread_->IsDeoptimizing ()) {
1075
+ if (thread_->IGNORE_RACE2 ( IsDeoptimizing) ()) {
1065
1076
sample_->set_ignore_sample (true );
1066
1077
return ;
1067
1078
}
1068
1079
1069
- uword* exit_fp = reinterpret_cast <uword*>(thread_->top_exit_frame_info ());
1080
+ uword* exit_fp =
1081
+ reinterpret_cast <uword*>(thread_->IGNORE_RACE (top_exit_frame_info)());
1070
1082
bool has_exit_frame = exit_fp != nullptr ;
1071
1083
if (has_exit_frame) {
1072
1084
// Exited from compiled code or interpreter.
@@ -1077,13 +1089,14 @@ class ProfilerDartStackWalker : public ProfilerStackWalker {
1077
1089
pc_ = CallerPC ();
1078
1090
fp_ = CallerFP ();
1079
1091
} else {
1080
- if (thread_->vm_tag () == VMTag::kDartTagId ) {
1092
+ if (thread_->IGNORE_RACE ( vm_tag) () == VMTag::kDartTagId ) {
1081
1093
// Running compiled code.
1082
1094
// Use the FP and PC from the thread interrupt or simulator; already set
1083
1095
// in the constructor.
1084
1096
1085
1097
#if defined(DART_DYNAMIC_MODULES)
1086
- } else if (thread_->vm_tag () == VMTag::kDartInterpretedTagId ) {
1098
+ } else if (thread_->IGNORE_RACE (vm_tag)() ==
1099
+ VMTag::kDartInterpretedTagId ) {
1087
1100
// Running interpreter.
1088
1101
pc_ = reinterpret_cast <uword*>(thread_->interpreter ()->get_pc ());
1089
1102
fp_ = reinterpret_cast <uword*>(thread_->interpreter ()->get_fp ());
@@ -1286,15 +1299,15 @@ static Sample* SetupSample(Thread* thread,
1286
1299
bool allocation_sample,
1287
1300
ThreadId tid) {
1288
1301
ASSERT (thread != nullptr );
1289
- Isolate* isolate = thread->isolate ();
1302
+ Isolate* isolate = thread->IGNORE_RACE ( isolate) ();
1290
1303
SampleBlockBuffer* buffer = Profiler::sample_block_buffer ();
1291
1304
Sample* sample = allocation_sample ? buffer->ReserveAllocationSample (isolate)
1292
1305
: buffer->ReserveCPUSample (isolate);
1293
1306
if (sample == nullptr ) {
1294
1307
return nullptr ;
1295
1308
}
1296
1309
sample->Init (isolate->main_port (), OS::GetCurrentMonotonicMicros (), tid);
1297
- uword vm_tag = thread->vm_tag ();
1310
+ uword vm_tag = thread->IGNORE_RACE ( vm_tag) ();
1298
1311
#if defined(DART_INCLUDE_SIMULATOR)
1299
1312
// When running in the simulator, the runtime entry function address
1300
1313
// (stored as the vm tag) is the address of a redirect function.
@@ -1307,7 +1320,7 @@ static Sample* SetupSample(Thread* thread,
1307
1320
}
1308
1321
#endif
1309
1322
sample->set_vm_tag (vm_tag);
1310
- sample->set_user_tag (thread->user_tag ());
1323
+ sample->set_user_tag (thread->IGNORE_RACE ( user_tag) ());
1311
1324
sample->set_thread_task (thread->task_kind ());
1312
1325
return sample;
1313
1326
}
@@ -1388,7 +1401,7 @@ void Profiler::SampleThreadSingleFrame(Thread* thread,
1388
1401
ASSERT (thread != nullptr );
1389
1402
OSThread* os_thread = thread->os_thread ();
1390
1403
ASSERT (os_thread != nullptr );
1391
- Isolate* isolate = thread->isolate ();
1404
+ Isolate* isolate = thread->IGNORE_RACE ( isolate) ();
1392
1405
1393
1406
ASSERT (Profiler::sample_block_buffer () != nullptr );
1394
1407
@@ -1406,9 +1419,9 @@ void Profiler::SampleThreadSingleFrame(Thread* thread,
1406
1419
void Profiler::SampleThread (Thread* thread,
1407
1420
const InterruptedThreadState& state) {
1408
1421
ASSERT (thread != nullptr );
1409
- OSThread* os_thread = thread->os_thread ();
1422
+ OSThread* os_thread = thread->IGNORE_RACE ( os_thread) ();
1410
1423
ASSERT (os_thread != nullptr );
1411
- Isolate* isolate = thread->isolate ();
1424
+ Isolate* isolate = thread->IGNORE_RACE ( isolate) ();
1412
1425
1413
1426
// Double check if interrupts are disabled
1414
1427
// after the thread interrupter decided to send a signal.
@@ -1430,7 +1443,7 @@ void Profiler::SampleThread(Thread* thread,
1430
1443
return ;
1431
1444
}
1432
1445
1433
- const bool in_dart_code = thread->IsExecutingDartCode ();
1446
+ const bool in_dart_code = thread->IGNORE_RACE2 ( IsExecutingDartCode) ();
1434
1447
1435
1448
uintptr_t sp = 0 ;
1436
1449
uintptr_t fp = state.fp ;
@@ -1478,7 +1491,7 @@ void Profiler::SampleThread(Thread* thread,
1478
1491
}
1479
1492
1480
1493
if (thread->IsDartMutatorThread ()) {
1481
- if (thread->IsDeoptimizing ()) {
1494
+ if (thread->IGNORE_RACE2 ( IsDeoptimizing) ()) {
1482
1495
counters_.single_frame_sample_deoptimizing .fetch_add (1 );
1483
1496
SampleThreadSingleFrame (thread, sample, pc);
1484
1497
return ;
@@ -1509,7 +1522,7 @@ void Profiler::SampleThread(Thread* thread,
1509
1522
&counters_, (isolate != nullptr ) ? isolate->main_port () : ILLEGAL_PORT,
1510
1523
sample, isolate->current_sample_block (), stack_lower, stack_upper, pc, fp,
1511
1524
sp);
1512
- const bool exited_dart_code = thread->HasExitedDartCode ();
1525
+ const bool exited_dart_code = thread->IGNORE_RACE2 ( HasExitedDartCode) ();
1513
1526
ProfilerDartStackWalker dart_stack_walker (
1514
1527
thread, sample, isolate->current_sample_block (), pc, fp, sp, lr,
1515
1528
/* allocation_sample*/ false );
0 commit comments