mirror of
https://github.com/dart-lang/sdk
synced 2024-09-18 20:51:19 +00:00
Fix the profiler for threads spawned from the Linux eventhandler
Fixes #26416 BUG= R=asiva@google.com Review URL: https://codereview.chromium.org/1953143002 .
This commit is contained in:
parent
230824610f
commit
5d02929fa0
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue