db0fa84d59
OSThread::GetCurrentThreadId() is used in many places throughout the vm, particularly in facilities that are used heavily, such as SafepointRwLock. The high frequency of invocations means that the runtime overhead of getting the current thread id has a significant impact on the overall performance of the vm. The current Fuchsia implemention of OSThread::GetCurrentThreadId() makes a syscall to get the koid of the current thread's handle, resulting in hundreds of nanoseconds of unnecessary overhead per invocation. This patch changes to using the thread's handle as the id, which is guaranteed to be unique for the lifetime of the thread, unless it is closed prematurely (nothing in the vm does this). This approach is similar to what MUSL libc (the libc used by Fuchsia) does for the same purpose and has significant mileage. Bug: b/182183059 TEST=existing ci test suite; manually deployed into Fuchsia build. Change-Id: I274a793a823a717c8dd206b396001c6acb897b9a Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/193643 Reviewed-by: Chase Latta <chaselatta@google.com> Commit-Queue: Chase Latta <chaselatta@google.com>