Implement aarch64_get_thread_helper() for Windows AArch64#67
Draft
raneashay wants to merge 1 commit intomicrosoft:mainfrom
Draft
Implement aarch64_get_thread_helper() for Windows AArch64#67raneashay wants to merge 1 commit intomicrosoft:mainfrom
aarch64_get_thread_helper() for Windows AArch64#67raneashay wants to merge 1 commit intomicrosoft:mainfrom
Conversation
Prior to this patch, on Windows/AArch64, `aarch64_get_thread_helper()` resolves to `Thread::current()`, which, although correct, is suboptimal, since it requires all registers from `r0` through `r17` to be saved by the caller. Linux/AArch64 has a hand-written assembly implementation that clobbers just `x0` and `x1`, making it more efficient. This patch implements a similar hand-written assembly implementation for Windows. Unlike Linux, which stores the thread identifying information pointer in the `tpidr_el0` register, Windows stores the pointer to the Thread Environment Block in `x18`, so this assembly code basically reads the `*[*(x18 + 0x58) + _tls_index * 8] + _jvm_thr_current_tls_offset` address, where `0x58` is the offset into the TEB to get to the thread local storage pointer (see https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm), and `_jvm_thr_current_tls_offset` is computed in `cache_global_variables()` once using `Thread::_thr_current` and is then reused in each call to the assembly code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Prior to this patch, on Windows/AArch64,
aarch64_get_thread_helper()resolves to
Thread::current(), which, although correct, is suboptimal,since it requires all registers from
r0throughr17to be saved bythe caller. Linux/AArch64 has a hand-written assembly implementation
that clobbers just
x0andx1, making it more efficient. This patchimplements a similar hand-written assembly implementation for Windows.
Unlike Linux, which stores the thread identifying information pointer in
the
tpidr_el0register, Windows stores the pointer to the ThreadEnvironment Block in
x18, so this assembly code basically reads the*[*(x18 + 0x58) + _tls_index * 8] + _jvm_thr_current_tls_offsetaddress, where
0x58is the offset into the TEB to get to the threadlocal storage pointer (see
https://www.geoffchappell.com/studies/windows/km/ntoskrnl/inc/api/pebteb/teb/index.htm),
and
_jvm_thr_current_tls_offsetis computed incache_global_variables()once usingThread::_thr_currentand is thenreused in each call to the assembly code.