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

Unified Diff: runtime/vm/os_thread_linux.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 | « runtime/vm/os_thread_android.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/os_thread_linux.cc
diff --git a/runtime/vm/os_thread_linux.cc b/runtime/vm/os_thread_linux.cc
index a0e68f1870e5b3222039a3b5467aea05d29cd214..ffcd2e67368d4c7bc4dc53acc956b07a8250fc5b 100644
--- a/runtime/vm/os_thread_linux.cc
+++ b/runtime/vm/os_thread_linux.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_LINUX)
#include "vm/os_thread.h"
@@ -85,6 +87,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.
@@ -101,7 +118,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 | « runtime/vm/os_thread_android.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698