Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(112)

Unified Diff: runtime/vm/profiler.cc

Issue 83623004: Guard against an isolate being scheduled twice (Closed) Base URL: https://dart.googlecode.com/svn/branches/bleeding_edge/dart
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « runtime/vm/profiler.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/profiler.cc
diff --git a/runtime/vm/profiler.cc b/runtime/vm/profiler.cc
index c45c1d4cc1e3e212c6017495e65341d798bd5790..a6e53a7fb64832d7a1e2410b2c0a790f9402de8b 100644
--- a/runtime/vm/profiler.cc
+++ b/runtime/vm/profiler.cc
@@ -169,6 +169,27 @@ void ProfilerManager::ShutdownIsolateForProfiling(Isolate* isolate) {
}
+void ProfilerManager::ScheduleIsolateHelper(Isolate* isolate) {
+ ScopedMonitor lock(monitor_);
+ intptr_t i = FindIsolate(isolate);
+ if (i >= 0) {
+ // Already scheduled.
+ return;
+ }
+ {
+ ScopedMutex profiler_data_lock(isolate->profiler_data_mutex());
+ IsolateProfilerData* profiler_data = isolate->profiler_data();
+ if (profiler_data == NULL) {
+ return;
+ }
+ profiler_data->Scheduled(OS::GetCurrentTimeMicros(),
+ Thread::GetCurrentThreadId());
+ }
+ AddIsolate(isolate);
+ lock.Notify();
+}
+
+
void ProfilerManager::ScheduleIsolate(Isolate* isolate, bool inside_signal) {
if (!FLAG_profile) {
return;
@@ -178,34 +199,12 @@ void ProfilerManager::ScheduleIsolate(Isolate* isolate, bool inside_signal) {
if (!inside_signal) {
ScopedSignalBlocker ssb;
{
- ScopedMonitor lock(monitor_);
- {
- ScopedMutex profiler_data_lock(isolate->profiler_data_mutex());
- IsolateProfilerData* profiler_data = isolate->profiler_data();
- if (profiler_data == NULL) {
- return;
- }
- profiler_data->Scheduled(OS::GetCurrentTimeMicros(),
- Thread::GetCurrentThreadId());
- }
- AddIsolate(isolate);
- lock.Notify();
+ ScheduleIsolateHelper(isolate);
}
} else {
// Do not need a signal blocker inside a signal handler.
{
- ScopedMonitor lock(monitor_);
- {
- ScopedMutex profiler_data_lock(isolate->profiler_data_mutex());
- IsolateProfilerData* profiler_data = isolate->profiler_data();
- if (profiler_data == NULL) {
- return;
- }
- profiler_data->Scheduled(OS::GetCurrentTimeMicros(),
- Thread::GetCurrentThreadId());
- }
- AddIsolate(isolate);
- lock.Notify();
+ ScheduleIsolateHelper(isolate);
}
}
}
« no previous file with comments | « runtime/vm/profiler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698