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

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

Issue 2916313003: [Fuchsia] Enable CPU profiling for the standalone VM (Closed)
Patch Set: Poll until suspended Created 3 years, 6 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
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.h"
8 #include "vm/os_thread.h" 9 #include "vm/os_thread.h"
9 #include "vm/os_thread_fuchsia.h" 10 #include "vm/os_thread_fuchsia.h"
10 11
11 #include <errno.h> // NOLINT 12 #include <errno.h> // NOLINT
13 #include <magenta/status.h>
12 #include <magenta/syscalls.h> 14 #include <magenta/syscalls.h>
13 #include <magenta/syscalls/object.h> 15 #include <magenta/syscalls/object.h>
14 #include <magenta/threads.h> 16 #include <magenta/threads.h>
15 #include <magenta/types.h> 17 #include <magenta/types.h>
16 18
17 #include "platform/assert.h" 19 #include "platform/assert.h"
18 20
19 namespace dart { 21 namespace dart {
20 22
21 #define VALIDATE_PTHREAD_RESULT(result) \ 23 #define VALIDATE_PTHREAD_RESULT(result) \
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 return kStackSize; 158 return kStackSize;
157 } 159 }
158 160
159 161
160 ThreadId OSThread::GetCurrentThreadId() { 162 ThreadId OSThread::GetCurrentThreadId() {
161 mx_info_handle_basic_t info; 163 mx_info_handle_basic_t info;
162 mx_handle_t thread_handle = thrd_get_mx_handle(thrd_current()); 164 mx_handle_t thread_handle = thrd_get_mx_handle(thrd_current());
163 mx_status_t status = 165 mx_status_t status =
164 mx_object_get_info(thread_handle, MX_INFO_HANDLE_BASIC, &info, 166 mx_object_get_info(thread_handle, MX_INFO_HANDLE_BASIC, &info,
165 sizeof(info), nullptr, nullptr); 167 sizeof(info), nullptr, nullptr);
166 return status == NO_ERROR ? info.koid : MX_KOID_INVALID; 168 if (status != NO_ERROR) {
169 FATAL1("Failed to get thread koid: %s\n", mx_status_get_string(status));
170 }
171 return info.koid;
167 } 172 }
168 173
169 174
170 #ifndef PRODUCT 175 #ifndef PRODUCT
171 ThreadId OSThread::GetCurrentThreadTraceId() { 176 ThreadId OSThread::GetCurrentThreadTraceId() {
172 return pthread_self(); 177 return pthread_self();
173 } 178 }
174 #endif // PRODUCT 179 #endif // PRODUCT
175 180
176 181
(...skipping 214 matching lines...) Expand 10 before | Expand all | Expand 10 after
391 #if defined(DEBUG) 396 #if defined(DEBUG)
392 // When running with assertions enabled we track the owner. 397 // When running with assertions enabled we track the owner.
393 ASSERT(IsOwnedByCurrentThread()); 398 ASSERT(IsOwnedByCurrentThread());
394 ThreadId saved_owner = owner_; 399 ThreadId saved_owner = owner_;
395 owner_ = OSThread::kInvalidThreadId; 400 owner_ = OSThread::kInvalidThreadId;
396 #endif // defined(DEBUG) 401 #endif // defined(DEBUG)
397 402
398 Monitor::WaitResult retval = kNotified; 403 Monitor::WaitResult retval = kNotified;
399 if (micros == kNoTimeout) { 404 if (micros == kNoTimeout) {
400 // Wait forever. 405 // Wait forever.
401 int result = pthread_cond_wait(data_.cond(), data_.mutex()); 406 int result;
407 do {
408 result = pthread_cond_wait(data_.cond(), data_.mutex());
409 // TODO(MG-795): Disallow ETIMEDOUT when pthread_cond_wait() can no longer
410 // return it.
411 } while (result == ETIMEDOUT);
402 VALIDATE_PTHREAD_RESULT(result); 412 VALIDATE_PTHREAD_RESULT(result);
403 } else { 413 } else {
404 struct timespec ts; 414 struct timespec ts;
405 ComputeTimeSpecMicros(&ts, micros); 415 ComputeTimeSpecMicros(&ts, micros);
406 int result = pthread_cond_timedwait(data_.cond(), data_.mutex(), &ts); 416 int result = pthread_cond_timedwait(data_.cond(), data_.mutex(), &ts);
407 ASSERT((result == 0) || (result == ETIMEDOUT)); 417 ASSERT((result == 0) || (result == ETIMEDOUT));
408 if (result == ETIMEDOUT) { 418 if (result == ETIMEDOUT) {
409 retval = kTimedOut; 419 retval = kTimedOut;
410 } 420 }
411 } 421 }
(...skipping 19 matching lines...) Expand all
431 void Monitor::NotifyAll() { 441 void Monitor::NotifyAll() {
432 // When running with assertions enabled we track the owner. 442 // When running with assertions enabled we track the owner.
433 ASSERT(IsOwnedByCurrentThread()); 443 ASSERT(IsOwnedByCurrentThread());
434 int result = pthread_cond_broadcast(data_.cond()); 444 int result = pthread_cond_broadcast(data_.cond());
435 VALIDATE_PTHREAD_RESULT(result); 445 VALIDATE_PTHREAD_RESULT(result);
436 } 446 }
437 447
438 } // namespace dart 448 } // namespace dart
439 449
440 #endif // defined(HOST_OS_FUCHSIA) 450 #endif // defined(HOST_OS_FUCHSIA)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698