diff options
| author | lizzie <lizzie@eden-emu.dev> | 2026-05-09 05:48:20 +0200 |
|---|---|---|
| committer | crueter <crueter@eden-emu.dev> | 2026-05-09 05:48:20 +0200 |
| commit | 672c21829b1126aeb1c1bfb867ac03e57e2e3c3a (patch) | |
| tree | f8fe9f55586701d050e473b290468949d917adee /src | |
| parent | eec460ec2ef13dee7376f2854ba00da9a98b0cd5 (diff) | |
[core/hle/kernel] Remove redundant TLS load/stores, reuse computed segment+address instead (#3932)
While originally for MSVC, this also should help clang/gcc not die trying to make codegen for the load/store of fields for the tls_data
should help to reuse computed values instead of recomputing shit for no reason
Signed-off-by: lizzie <lizzie@eden-emu.dev>
Reviewed-on: https://git.eden-emu.dev/eden-emu/eden/pulls/3932
Reviewed-by: MaranBr <maranbr@eden-emu.dev>
Reviewed-by: CamilleLaVey <camillelavey99@gmail.com>
Diffstat (limited to 'src')
| -rw-r--r-- | src/core/hle/kernel/kernel.cpp | 19 |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/core/hle/kernel/kernel.cpp b/src/core/hle/kernel/kernel.cpp index 129bda194a..5f88fa498f 100644 --- a/src/core/hle/kernel/kernel.cpp +++ b/src/core/hle/kernel/kernel.cpp @@ -372,17 +372,17 @@ struct KernelCore::Impl { } // Gets the dummy KThread for the caller, allocating a new one if this is the first time - KThread* GetHostDummyThread(KThread* existing_thread) { - if (tls_data.thread == nullptr) { + KThread* GetHostDummyThread(ThreadLocalData& t, KThread* existing_thread) { + if (t.thread == nullptr) { auto const initialize{[](KThread* thread) { ASSERT(KThread::InitializeDummyThread(thread, nullptr).IsSuccess()); return thread; }}; - tls_data.raw_thread.emplace(system.Kernel()); - tls_data.thread = existing_thread ? existing_thread : initialize(&*tls_data.raw_thread); - ASSERT(tls_data.thread != nullptr); + t.raw_thread.emplace(system.Kernel()); + t.thread = existing_thread ? existing_thread : initialize(&*t.raw_thread); + ASSERT(t.thread != nullptr); } - return tls_data.thread; + return t.thread; } /// Registers a CPU core thread by allocating a host thread ID for it @@ -395,7 +395,7 @@ struct KernelCore::Impl { /// Registers a new host thread by allocating a host thread ID for it void RegisterHostThread(KThread* existing_thread) { - (void)GetHostDummyThread(existing_thread); + (void)GetHostDummyThread(tls_data, existing_thread); } [[nodiscard]] u32 GetCurrentHostThreadID() { @@ -419,9 +419,8 @@ struct KernelCore::Impl { } KThread* GetCurrentEmuThread() { - if (!tls_data.current_thread) - tls_data.current_thread = GetHostDummyThread(nullptr); - return tls_data.current_thread; + auto& t = tls_data; + return t.current_thread ? t.current_thread : (t.current_thread = GetHostDummyThread(t, nullptr)); } void SetCurrentEmuThread(KThread* thread) { |
