mirror of
https://github.com/citron-neo/emulator.git
synced 2026-07-05 15:21:57 -07:00
fix: remove redundant TLS ld/st
This commit is contained in:
@@ -66,7 +66,7 @@ struct KernelCore::Impl {
|
||||
global_object_list_container = std::make_unique<KAutoObjectWithListContainer>(kernel);
|
||||
global_scheduler_context = std::make_unique<Kernel::GlobalSchedulerContext>(kernel);
|
||||
|
||||
is_phantom_mode_for_singlecore = false;
|
||||
tls_data.is_phantom_mode_for_singlecore = false;
|
||||
|
||||
// Derive the initial memory layout from the emulated board
|
||||
Init::InitializeSlabResourceCounts(kernel);
|
||||
@@ -354,34 +354,42 @@ struct KernelCore::Impl {
|
||||
application_process->Open();
|
||||
}
|
||||
|
||||
static inline thread_local u8 host_thread_id = UINT8_MAX;
|
||||
static thread_local struct {
|
||||
std::optional<KThread> raw_thread;
|
||||
KThread *thread = nullptr;
|
||||
u8 host_thread_id = UINT8_MAX;
|
||||
bool is_phantom_mode_for_singlecore{false};
|
||||
KThread* current_thread{nullptr};
|
||||
} tls_data;
|
||||
|
||||
/// Sets the host thread ID for the caller.
|
||||
LTO_NOINLINE u32 SetHostThreadId(std::size_t core_id) {
|
||||
u32 SetHostThreadId(std::size_t core_id) {
|
||||
auto& t = tls_data;
|
||||
// This should only be called during core init.
|
||||
ASSERT(host_thread_id == UINT8_MAX);
|
||||
|
||||
//ASSERT(t.host_thread_id == UINT8_MAX);
|
||||
// The first four slots are reserved for CPU core threads
|
||||
ASSERT(core_id < Core::Hardware::NUM_CPU_CORES);
|
||||
host_thread_id = static_cast<u8>(core_id);
|
||||
return host_thread_id;
|
||||
//ASSERT(core_id < Core::Hardware::NUM_CPU_CORES);
|
||||
t.host_thread_id = u8(core_id);
|
||||
return t.host_thread_id;
|
||||
}
|
||||
|
||||
/// Gets the host thread ID for the caller
|
||||
LTO_NOINLINE u32 GetHostThreadId() const {
|
||||
return host_thread_id;
|
||||
u32 GetHostThreadId() const {
|
||||
auto& t = tls_data;
|
||||
return t.host_thread_id;
|
||||
}
|
||||
|
||||
// Gets the dummy KThread for the caller, allocating a new one if this is the first time
|
||||
LTO_NOINLINE KThread* GetHostDummyThread(KThread* existing_thread) {
|
||||
const auto initialize{[](KThread* thread) LTO_NOINLINE {
|
||||
KThread* GetHostDummyThread(KThread* existing_thread) {
|
||||
auto& t = tls_data;
|
||||
const auto initialize{[](KThread* thread) {
|
||||
ASSERT(KThread::InitializeDummyThread(thread, nullptr).IsSuccess());
|
||||
return thread;
|
||||
}};
|
||||
|
||||
thread_local KThread raw_thread{system.Kernel()};
|
||||
thread_local KThread* thread = existing_thread ? existing_thread : initialize(&raw_thread);
|
||||
return thread;
|
||||
t.raw_thread.emplace(system.Kernel());
|
||||
t.thread = existing_thread ? existing_thread : initialize(&t.raw_thread.value());
|
||||
return t.thread;
|
||||
}
|
||||
|
||||
/// Registers a CPU core thread by allocating a host thread ID for it
|
||||
@@ -406,32 +414,32 @@ struct KernelCore::Impl {
|
||||
return this_id;
|
||||
}
|
||||
|
||||
static inline thread_local bool is_phantom_mode_for_singlecore{false};
|
||||
|
||||
LTO_NOINLINE bool IsPhantomModeForSingleCore() const {
|
||||
return is_phantom_mode_for_singlecore;
|
||||
bool IsPhantomModeForSingleCore() const {
|
||||
auto& t = tls_data;
|
||||
return t.is_phantom_mode_for_singlecore;
|
||||
}
|
||||
|
||||
LTO_NOINLINE void SetIsPhantomModeForSingleCore(bool value) {
|
||||
void SetIsPhantomModeForSingleCore(bool value) {
|
||||
auto& t = tls_data;
|
||||
ASSERT(!is_multicore);
|
||||
is_phantom_mode_for_singlecore = value;
|
||||
t.is_phantom_mode_for_singlecore = value;
|
||||
}
|
||||
|
||||
bool IsShuttingDown() const {
|
||||
return is_shutting_down.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
static inline thread_local KThread* current_thread{nullptr};
|
||||
|
||||
LTO_NOINLINE KThread* GetCurrentEmuThread() {
|
||||
if (!current_thread) {
|
||||
current_thread = GetHostDummyThread(nullptr);
|
||||
KThread* GetCurrentEmuThread() {
|
||||
auto& t = tls_data;
|
||||
if (!t.current_thread) {
|
||||
t.current_thread = GetHostDummyThread(nullptr);
|
||||
}
|
||||
return current_thread;
|
||||
return t.current_thread;
|
||||
}
|
||||
|
||||
LTO_NOINLINE void SetCurrentEmuThread(KThread* thread) {
|
||||
current_thread = thread;
|
||||
void SetCurrentEmuThread(KThread* thread) {
|
||||
auto& t = tls_data;
|
||||
t.current_thread = thread;
|
||||
}
|
||||
|
||||
void DeriveInitialMemoryLayout() {
|
||||
|
||||
@@ -134,13 +134,13 @@ void ComputePipeline::Configure(Tegra::Engines::KeplerCompute& kepler_compute,
|
||||
|
||||
// See vk_graphics_pipeline.cpp: small_vector keeps the span sized to the
|
||||
// actual write count.
|
||||
thread_local boost::container::small_vector<VideoCommon::ImageViewInOut, 64> views;
|
||||
thread_local boost::container::small_vector<VideoCommon::SamplerId, 64> samplers;
|
||||
boost::container::small_vector<VideoCommon::ImageViewInOut, 64> views;
|
||||
boost::container::small_vector<VideoCommon::SamplerId, 64> samplers;
|
||||
views.clear();
|
||||
samplers.clear();
|
||||
thread_local BindlessCache bindless_cache;
|
||||
thread_local size_t bindless_cache_rr{0};
|
||||
thread_local std::vector<u8> bindless_scratch;
|
||||
BindlessCache bindless_cache;
|
||||
size_t bindless_cache_rr{0};
|
||||
std::vector<u8> bindless_scratch;
|
||||
|
||||
const auto& qmd{kepler_compute.launch_description};
|
||||
const auto& cbufs{qmd.const_buffer_config};
|
||||
|
||||
@@ -324,11 +324,11 @@ template <typename Spec>
|
||||
void GraphicsPipeline::ConfigureImpl(bool is_indexed) {
|
||||
// std::array<T, 16384> made CheckFeedbackLoop iterate the full capacity
|
||||
// per draw; small_vector lets the span size match the actual write count.
|
||||
thread_local boost::container::small_vector<VideoCommon::ImageViewInOut, 64> views;
|
||||
thread_local boost::container::small_vector<VideoCommon::SamplerId, 64> samplers;
|
||||
thread_local BindlessCache bindless_cache;
|
||||
thread_local size_t bindless_cache_rr{0};
|
||||
thread_local std::vector<u8> bindless_scratch;
|
||||
boost::container::small_vector<VideoCommon::ImageViewInOut, 64> views;
|
||||
boost::container::small_vector<VideoCommon::SamplerId, 64> samplers;
|
||||
BindlessCache bindless_cache;
|
||||
size_t bindless_cache_rr{0};
|
||||
std::vector<u8> bindless_scratch;
|
||||
views.clear();
|
||||
samplers.clear();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user