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

Unified Diff: runtime/vm/os_thread_android.cc

Issue 1953143002: Fix the profiler for threads spawned from the Linux eventhandler (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months 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 | « no previous file | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_thread_android.cc
diff --git a/runtime/vm/os_thread_android.cc b/runtime/vm/os_thread_android.cc
index 9b93cbe70940f5ee6a532286164279c8cfea6edb..2f51e6f2283526eb64fbefdb25f650364724bbfd 100644
--- a/runtime/vm/os_thread_android.cc
+++ b/runtime/vm/os_thread_android.cc
@@ -3,6 +3,8 @@
// BSD-style license that can be found in the LICENSE file.
#include "platform/globals.h" // NOLINT
+#include "platform/signal_blocker.h" // NOLINT
+
#if defined(TARGET_OS_ANDROID)
#include "vm/os_thread.h"
@@ -83,6 +85,21 @@ class ThreadStartData {
};
+// Spawned threads inherit their spawner's signal mask. We sometimes spawn
+// threads for running Dart code from a thread that is blocking SIGPROF.
+// This function explicitly unblocks SIGPROF so the profiler continues to
+// sample this thread.
+static void UnblockSIGPROF() {
+ sigset_t set;
+ sigemptyset(&set);
+ sigaddset(&set, SIGPROF);
+ int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
+ USE(r);
+ ASSERT(r == 0);
+ ASSERT(!CHECK_IS_BLOCKING(SIGPROF));
+}
+
+
// Dispatch to the thread start function provided by the caller. This trampoline
// is used to ensure that the thread is properly destroyed if the thread just
// exits.
@@ -99,7 +116,7 @@ static void* ThreadStart(void* data_ptr) {
if (thread != NULL) {
OSThread::SetCurrent(thread);
thread->set_name(name);
-
+ UnblockSIGPROF();
// Call the supplied thread start function handing it its parameters.
function(parameter);
}
« no previous file with comments | « no previous file | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698