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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « no previous file | runtime/vm/os_thread_linux.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #include "platform/globals.h" // NOLINT 5 #include "platform/globals.h" // NOLINT
6 #include "platform/signal_blocker.h" // NOLINT
7
6 #if defined(TARGET_OS_ANDROID) 8 #if defined(TARGET_OS_ANDROID)
7 9
8 #include "vm/os_thread.h" 10 #include "vm/os_thread.h"
9 11
10 #include <errno.h> // NOLINT 12 #include <errno.h> // NOLINT
11 #include <sys/time.h> // NOLINT 13 #include <sys/time.h> // NOLINT
12 14
13 #include "platform/assert.h" 15 #include "platform/assert.h"
14 #include "platform/utils.h" 16 #include "platform/utils.h"
15 17
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 78
77 private: 79 private:
78 const char* name_; 80 const char* name_;
79 OSThread::ThreadStartFunction function_; 81 OSThread::ThreadStartFunction function_;
80 uword parameter_; 82 uword parameter_;
81 83
82 DISALLOW_COPY_AND_ASSIGN(ThreadStartData); 84 DISALLOW_COPY_AND_ASSIGN(ThreadStartData);
83 }; 85 };
84 86
85 87
88 // Spawned threads inherit their spawner's signal mask. We sometimes spawn
89 // threads for running Dart code from a thread that is blocking SIGPROF.
90 // This function explicitly unblocks SIGPROF so the profiler continues to
91 // sample this thread.
92 static void UnblockSIGPROF() {
93 sigset_t set;
94 sigemptyset(&set);
95 sigaddset(&set, SIGPROF);
96 int r = pthread_sigmask(SIG_UNBLOCK, &set, NULL);
97 USE(r);
98 ASSERT(r == 0);
99 ASSERT(!CHECK_IS_BLOCKING(SIGPROF));
100 }
101
102
86 // Dispatch to the thread start function provided by the caller. This trampoline 103 // Dispatch to the thread start function provided by the caller. This trampoline
87 // is used to ensure that the thread is properly destroyed if the thread just 104 // is used to ensure that the thread is properly destroyed if the thread just
88 // exits. 105 // exits.
89 static void* ThreadStart(void* data_ptr) { 106 static void* ThreadStart(void* data_ptr) {
90 ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr); 107 ThreadStartData* data = reinterpret_cast<ThreadStartData*>(data_ptr);
91 108
92 const char* name = data->name(); 109 const char* name = data->name();
93 OSThread::ThreadStartFunction function = data->function(); 110 OSThread::ThreadStartFunction function = data->function();
94 uword parameter = data->parameter(); 111 uword parameter = data->parameter();
95 delete data; 112 delete data;
96 113
97 // Create new OSThread object and set as TLS for new thread. 114 // Create new OSThread object and set as TLS for new thread.
98 OSThread* thread = OSThread::CreateOSThread(); 115 OSThread* thread = OSThread::CreateOSThread();
99 if (thread != NULL) { 116 if (thread != NULL) {
100 OSThread::SetCurrent(thread); 117 OSThread::SetCurrent(thread);
101 thread->set_name(name); 118 thread->set_name(name);
102 119 UnblockSIGPROF();
103 // Call the supplied thread start function handing it its parameters. 120 // Call the supplied thread start function handing it its parameters.
104 function(parameter); 121 function(parameter);
105 } 122 }
106 123
107 return NULL; 124 return NULL;
108 } 125 }
109 126
110 127
111 int OSThread::Start(const char* name, 128 int OSThread::Start(const char* name,
112 ThreadStartFunction function, 129 ThreadStartFunction function,
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
425 void Monitor::NotifyAll() { 442 void Monitor::NotifyAll() {
426 // When running with assertions enabled we track the owner. 443 // When running with assertions enabled we track the owner.
427 ASSERT(IsOwnedByCurrentThread()); 444 ASSERT(IsOwnedByCurrentThread());
428 int result = pthread_cond_broadcast(data_.cond()); 445 int result = pthread_cond_broadcast(data_.cond());
429 VALIDATE_PTHREAD_RESULT(result); 446 VALIDATE_PTHREAD_RESULT(result);
430 } 447 }
431 448
432 } // namespace dart 449 } // namespace dart
433 450
434 #endif // defined(TARGET_OS_ANDROID) 451 #endif // defined(TARGET_OS_ANDROID)
OLDNEW
« 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