kern/util: update structure layouts to match Nintendo (saves 0x10 per KThread/KSession)

This commit is contained in:
Michael Scire 2021-10-16 16:13:10 -07:00
parent 7805a3624e
commit 26c02e2019
6 changed files with 15 additions and 12 deletions

View file

@ -71,10 +71,11 @@ namespace ams::kern {
private:
KAutoObject *m_next_closed_object;
std::atomic<u32> m_ref_count;
u32 m_reserved;
public:
static KAutoObject *Create(KAutoObject *ptr);
public:
constexpr ALWAYS_INLINE explicit KAutoObject() : m_next_closed_object(nullptr), m_ref_count(0) { MESOSPHERE_ASSERT_THIS(); }
constexpr ALWAYS_INLINE explicit KAutoObject() : m_next_closed_object(nullptr), m_ref_count(0), m_reserved(0) { MESOSPHERE_ASSERT_THIS(); }
/* Destroy is responsible for destroying the auto object's resources when ref_count hits zero. */
virtual void Destroy() { MESOSPHERE_ASSERT_THIS(); }

View file

@ -35,13 +35,13 @@ namespace ams::kern {
ServerClosed = 3,
};
private:
std::atomic<std::underlying_type<State>::type> m_atomic_state;
bool m_initialized;
KServerSession m_server;
KClientSession m_client;
std::atomic<std::underlying_type<State>::type> m_atomic_state;
KClientPort *m_port;
uintptr_t m_name;
KProcess *m_process;
bool m_initialized;
private:
ALWAYS_INLINE void SetState(State state) {
m_atomic_state = static_cast<u8>(state);
@ -52,7 +52,7 @@ namespace ams::kern {
}
public:
constexpr KSession()
: m_server(), m_client(), m_atomic_state(static_cast<std::underlying_type<State>::type>(State::Invalid)), m_port(), m_name(), m_process(), m_initialized()
: m_atomic_state(static_cast<std::underlying_type<State>::type>(State::Invalid)), m_initialized(), m_server(), m_client(), m_port(), m_name(), m_process()
{
/* ... */
}

View file

@ -177,9 +177,8 @@ namespace ams::kern {
static_assert(ams::util::HasRedBlackKeyType<ConditionVariableComparator>);
static_assert(std::same_as<ams::util::RedBlackKeyType<ConditionVariableComparator, void>, ConditionVariableComparator::RedBlackKeyType>);
private:
static inline std::atomic<u64> s_next_thread_id = 0;
static constinit inline std::atomic<u64> s_next_thread_id = 0;
private:
alignas(16) KThreadContext m_thread_context{};
util::IntrusiveListNode m_process_list_node{};
util::IntrusiveRedBlackTreeNode m_condvar_arbiter_tree_node{};
s32 m_priority{};
@ -189,6 +188,7 @@ namespace ams::kern {
ConditionVariableThreadTree *m_condvar_tree{};
uintptr_t m_condvar_key{};
alignas(16) KThreadContext m_thread_context{};
u64 m_virtual_affinity_mask{};
KAffinityMask m_physical_affinity_mask{};
u64 m_thread_id{};
@ -204,7 +204,6 @@ namespace ams::kern {
s64 m_schedule_count{};
s64 m_last_scheduled_tick{};
QueueEntry m_per_core_priority_queue_entry[cpu::NumCores]{};
KLightLock *m_waiting_lock{};
KThreadQueue *m_wait_queue{};
WaiterList m_waiter_list{};
WaiterList m_pinned_waiter_list{};

View file

@ -148,9 +148,6 @@ namespace ams::kern {
m_priority = prio;
m_base_priority = prio;
/* Set waiting lock to null. */
m_waiting_lock = nullptr;
/* Initialize wait queue/sync index. */
m_synced_index = -1;
m_wait_queue = nullptr;