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

Side by Side Diff: runtime/vm/os_thread_fuchsia.cc

Issue 2796143002: [Fuchsia] Implements the thread interrupter for CPU profiling. (Closed)
Patch Set: Format Created 3 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 | « runtime/vm/os_thread_fuchsia.h ('k') | runtime/vm/thread_interrupter_fuchsia.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) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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 #if defined(HOST_OS_FUCHSIA) 6 #if defined(HOST_OS_FUCHSIA)
7 7
8 #include "vm/os_thread.h" 8 #include "vm/os_thread.h"
9 #include "vm/os_thread_fuchsia.h" 9 #include "vm/os_thread_fuchsia.h"
10 10
11 #include <errno.h> // NOLINT 11 #include <errno.h> // NOLINT
12 #include <magenta/syscalls.h> 12 #include <magenta/syscalls.h>
13 #include <magenta/syscalls/object.h>
14 #include <magenta/threads.h>
13 #include <magenta/types.h> 15 #include <magenta/types.h>
14 16
15 #include "platform/assert.h" 17 #include "platform/assert.h"
16 18
17 namespace dart { 19 namespace dart {
18 20
19 #define VALIDATE_PTHREAD_RESULT(result) \ 21 #define VALIDATE_PTHREAD_RESULT(result) \
20 if (result != 0) { \ 22 if (result != 0) { \
21 FATAL1("pthread error: %d", result); \ 23 FATAL1("pthread error: %d", result); \
22 } 24 }
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 result = pthread_create(&tid, &attr, ThreadStart, data); 116 result = pthread_create(&tid, &attr, ThreadStart, data);
115 RETURN_ON_PTHREAD_FAILURE(result); 117 RETURN_ON_PTHREAD_FAILURE(result);
116 118
117 result = pthread_attr_destroy(&attr); 119 result = pthread_attr_destroy(&attr);
118 RETURN_ON_PTHREAD_FAILURE(result); 120 RETURN_ON_PTHREAD_FAILURE(result);
119 121
120 return 0; 122 return 0;
121 } 123 }
122 124
123 125
124 const ThreadId OSThread::kInvalidThreadId = static_cast<ThreadId>(0); 126 const ThreadId OSThread::kInvalidThreadId = MX_KOID_INVALID;
125 const ThreadJoinId OSThread::kInvalidThreadJoinId = 127 const ThreadJoinId OSThread::kInvalidThreadJoinId =
126 static_cast<ThreadJoinId>(0); 128 static_cast<ThreadJoinId>(0);
127 129
128 130
129 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) { 131 ThreadLocalKey OSThread::CreateThreadLocal(ThreadDestructor destructor) {
130 pthread_key_t key = kUnsetThreadLocalKey; 132 pthread_key_t key = kUnsetThreadLocalKey;
131 int result = pthread_key_create(&key, destructor); 133 int result = pthread_key_create(&key, destructor);
132 VALIDATE_PTHREAD_RESULT(result); 134 VALIDATE_PTHREAD_RESULT(result);
133 ASSERT(key != kUnsetThreadLocalKey); 135 ASSERT(key != kUnsetThreadLocalKey);
134 return key; 136 return key;
(...skipping 14 matching lines...) Expand all
149 } 151 }
150 152
151 153
152 intptr_t OSThread::GetMaxStackSize() { 154 intptr_t OSThread::GetMaxStackSize() {
153 const int kStackSize = (128 * kWordSize * KB); 155 const int kStackSize = (128 * kWordSize * KB);
154 return kStackSize; 156 return kStackSize;
155 } 157 }
156 158
157 159
158 ThreadId OSThread::GetCurrentThreadId() { 160 ThreadId OSThread::GetCurrentThreadId() {
159 return pthread_self(); 161 mx_info_handle_basic_t info;
162 mx_handle_t thread_handle = thrd_get_mx_handle(thrd_current());
163 mx_status_t status =
164 mx_object_get_info(thread_handle, MX_INFO_HANDLE_BASIC, &info,
165 sizeof(info), nullptr, nullptr);
166 return status == NO_ERROR ? info.koid : MX_KOID_INVALID;
160 } 167 }
161 168
162 169
163 #ifndef PRODUCT 170 #ifndef PRODUCT
164 ThreadId OSThread::GetCurrentThreadTraceId() { 171 ThreadId OSThread::GetCurrentThreadTraceId() {
165 return pthread_self(); 172 return pthread_self();
166 } 173 }
167 #endif // PRODUCT 174 #endif // PRODUCT
168 175
169 176
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 void Monitor::NotifyAll() { 431 void Monitor::NotifyAll() {
425 // When running with assertions enabled we track the owner. 432 // When running with assertions enabled we track the owner.
426 ASSERT(IsOwnedByCurrentThread()); 433 ASSERT(IsOwnedByCurrentThread());
427 int result = pthread_cond_broadcast(data_.cond()); 434 int result = pthread_cond_broadcast(data_.cond());
428 VALIDATE_PTHREAD_RESULT(result); 435 VALIDATE_PTHREAD_RESULT(result);
429 } 436 }
430 437
431 } // namespace dart 438 } // namespace dart
432 439
433 #endif // defined(HOST_OS_FUCHSIA) 440 #endif // defined(HOST_OS_FUCHSIA)
OLDNEW
« no previous file with comments | « runtime/vm/os_thread_fuchsia.h ('k') | runtime/vm/thread_interrupter_fuchsia.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698