kern: KAutoObject doesn't need (virtual) destructor

This commit is contained in:
Michael Scire 2021-09-17 15:08:13 -07:00
parent a5aed96b80
commit 53aa04303a
29 changed files with 7 additions and 43 deletions

View file

@ -31,7 +31,6 @@ namespace ams::kern::arch::arm64 {
MESOSPHERE_AUTOOBJECT_TRAITS(KDebug, KSynchronizationObject);
public:
explicit KDebug() { /* ... */ }
virtual ~KDebug() { /* ... */ }
static void PostDestroy(uintptr_t arg) { MESOSPHERE_UNUSED(arg); /* ... */ }
public:

View file

@ -30,8 +30,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KAlpha() { /* ... */ }
/* virtual void Finalize() override; */
virtual bool IsInitialized() const override { return false /* TODO */; }

View file

@ -75,7 +75,6 @@ namespace ams::kern {
static KAutoObject *Create(KAutoObject *ptr);
public:
constexpr ALWAYS_INLINE explicit KAutoObject() : m_next_closed_object(nullptr), m_ref_count(0) { MESOSPHERE_ASSERT_THIS(); }
virtual ~KAutoObject() { MESOSPHERE_ASSERT_THIS(); }
/* Destroy is responsible for destroying the auto object's resources when ref_count hits zero. */
virtual void Destroy() { MESOSPHERE_ASSERT_THIS(); }
@ -139,8 +138,10 @@ namespace ams::kern {
private:
friend class KAutoObjectWithListContainer;
private:
util::IntrusiveRedBlackTreeNode list_node;
util::IntrusiveRedBlackTreeNode m_list_node;
public:
constexpr ALWAYS_INLINE KAutoObjectWithList() : m_list_node() { /* ... */ }
static ALWAYS_INLINE int Compare(const KAutoObjectWithList &lhs, const KAutoObjectWithList &rhs) {
const u64 lid = lhs.GetId();
const u64 rid = rhs.GetId();

View file

@ -24,7 +24,7 @@ namespace ams::kern {
NON_COPYABLE(KAutoObjectWithListContainer);
NON_MOVEABLE(KAutoObjectWithListContainer);
public:
using ListType = util::IntrusiveRedBlackTreeMemberTraits<&KAutoObjectWithList::list_node>::TreeType<KAutoObjectWithList>;
using ListType = util::IntrusiveRedBlackTreeMemberTraits<&KAutoObjectWithList::m_list_node>::TreeType<KAutoObjectWithList>;
public:
class ListAccessor : public KScopedLightLock {
private:

View file

@ -37,8 +37,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KBeta() { /* ... */ }
/* virtual void Finalize() override; */
virtual bool IsInitialized() const override { return false /* TODO */; }

View file

@ -34,7 +34,6 @@ namespace ams::kern {
KPort *m_parent;
public:
constexpr KClientPort() : m_num_sessions(), m_peak_sessions(), m_max_sessions(), m_parent() { /* ... */ }
virtual ~KClientPort() { /* ... */ }
void Initialize(KPort *parent, s32 max_sessions);
void OnSessionFinalized();

View file

@ -21,13 +21,12 @@ namespace ams::kern {
class KSession;
class KClientSession final : public KAutoObjectWithSlabHeapAndContainer<KClientSession, KAutoObjectWithList> {
class KClientSession final : public KAutoObject {
MESOSPHERE_AUTOOBJECT_TRAITS(KClientSession, KAutoObject);
private:
KSession *m_parent;
public:
constexpr KClientSession() : m_parent() { /* ... */ }
virtual ~KClientSession() { /* ... */ }
void Initialize(KSession *parent) {
/* Set member variables. */

View file

@ -35,8 +35,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KCodeMemory() { /* ... */ }
Result Initialize(KProcessAddress address, size_t size);
virtual void Finalize() override;

View file

@ -33,7 +33,6 @@ namespace ams::kern {
KProcess::State m_old_process_state;
public:
explicit KDebugBase() { /* ... */ }
virtual ~KDebugBase() { /* ... */ }
protected:
bool Is64Bit() const;
public:

View file

@ -31,7 +31,6 @@ namespace ams::kern {
bool m_is_initialized;
public:
constexpr KDeviceAddressSpace() : m_lock(), m_table(), m_space_address(), m_space_size(), m_is_initialized() { /* ... */ }
virtual ~KDeviceAddressSpace() { /* ... */ }
Result Initialize(u64 address, u64 size);
virtual void Finalize() override;

View file

@ -36,8 +36,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KEvent() { /* ... */ }
void Initialize();
virtual void Finalize() override;

View file

@ -32,7 +32,6 @@ namespace ams::kern {
bool m_is_initialized;
public:
constexpr KInterruptEvent() : m_interrupt_id(-1), m_core_id(-1), m_is_initialized(false) { /* ... */ }
virtual ~KInterruptEvent() { /* ... */ }
Result Initialize(int32_t interrupt_name, ams::svc::InterruptType type);
virtual void Finalize() override;

View file

@ -21,13 +21,12 @@ namespace ams::kern {
class KLightSession;
class KLightClientSession final : public KAutoObjectWithSlabHeapAndContainer<KLightClientSession, KAutoObjectWithList> {
class KLightClientSession final : public KAutoObject {
MESOSPHERE_AUTOOBJECT_TRAITS(KLightClientSession, KAutoObject);
private:
KLightSession *m_parent;
public:
constexpr KLightClientSession() : m_parent() { /* ... */ }
virtual ~KLightClientSession() { /* ... */ }
void Initialize(KLightSession *parent) {
/* Set member variables. */

View file

@ -23,7 +23,7 @@ namespace ams::kern {
class KLightSession;
class KLightServerSession final : public KAutoObjectWithSlabHeapAndContainer<KLightServerSession, KAutoObjectWithList>, public util::IntrusiveListBaseNode<KLightServerSession> {
class KLightServerSession final : public KAutoObject, public util::IntrusiveListBaseNode<KLightServerSession> {
MESOSPHERE_AUTOOBJECT_TRAITS(KLightServerSession, KAutoObject);
private:
KLightSession *m_parent;
@ -33,7 +33,6 @@ namespace ams::kern {
KThread *m_server_thread;
public:
constexpr KLightServerSession() : m_parent(), m_request_queue(), m_server_queue(), m_current_request(), m_server_thread() { /* ... */ }
virtual ~KLightServerSession() { /* ... */ }
void Initialize(KLightSession *parent) {
/* Set member variables. */

View file

@ -52,8 +52,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KLightSession() { /* ... */ }
void Initialize(KClientPort *client_port, uintptr_t name);
virtual void Finalize() override;

View file

@ -42,7 +42,6 @@ namespace ams::kern {
bool m_is_light;
public:
constexpr KPort() : m_server(), m_client(), m_name(), m_state(State::Invalid), m_is_light() { /* ... */ }
virtual ~KPort() { /* ... */ }
static void PostDestroy(uintptr_t arg) { MESOSPHERE_UNUSED(arg); /* ... */ }

View file

@ -143,7 +143,6 @@ namespace ams::kern {
}
public:
KProcess() { /* ... */ }
virtual ~KProcess() { /* ... */ }
Result Initialize(const ams::svc::CreateProcessParameter &params, const KPageGroup &pg, const u32 *caps, s32 num_caps, KResourceLimit *res_limit, KMemoryManager::Pool pool, bool immortal);
Result Initialize(const ams::svc::CreateProcessParameter &params, svc::KUserPointer<const u32 *> caps, s32 num_caps, KResourceLimit *res_limit, KMemoryManager::Pool pool);

View file

@ -28,7 +28,6 @@ namespace ams::kern {
KEvent *m_parent;
public:
constexpr explicit KReadableEvent() : KSynchronizationObject(), m_is_signaled(), m_parent() { MESOSPHERE_ASSERT_THIS(); }
virtual ~KReadableEvent() { MESOSPHERE_ASSERT_THIS(); }
constexpr void Initialize(KEvent *parent) {
MESOSPHERE_ASSERT_THIS();

View file

@ -34,7 +34,6 @@ namespace ams::kern {
KLightConditionVariable m_cond_var;
public:
constexpr ALWAYS_INLINE KResourceLimit() : m_limit_values(), m_current_values(), m_current_hints(), m_peak_values(), m_lock(), m_waiter_count(), m_cond_var() { /* ... */ }
virtual ~KResourceLimit() { /* ... */ }
static void PostDestroy(uintptr_t arg) { MESOSPHERE_UNUSED(arg); /* ... */ }

View file

@ -35,7 +35,6 @@ namespace ams::kern {
KPort *m_parent;
public:
constexpr KServerPort() : m_session_list(), m_light_session_list(), m_parent() { /* ... */ }
virtual ~KServerPort() { /* ... */ }
void Initialize(KPort *parent);
void EnqueueSession(KServerSession *session);

View file

@ -34,7 +34,6 @@ namespace ams::kern {
KLightLock m_lock;
public:
constexpr KServerSession() : m_parent(), m_request_list(), m_current_request(), m_lock() { /* ... */ }
virtual ~KServerSession() { /* ... */ }
virtual void Destroy() override;

View file

@ -57,8 +57,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KSession() { /* ... */ }
void Initialize(KClientPort *client_port, uintptr_t name);
virtual void Finalize() override;

View file

@ -131,7 +131,6 @@ namespace ams::kern {
size_t m_size;
public:
constexpr KSessionRequest() : m_mappings(), m_thread(), m_server(), m_event(), m_address(), m_size() { /* ... */ }
virtual ~KSessionRequest() { /* ... */ }
static KSessionRequest *Create() {
KSessionRequest *req = KSessionRequest::Allocate();

View file

@ -41,8 +41,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KSharedMemory() { /* ... */ }
Result Initialize(KProcess *owner, size_t size, ams::svc::MemoryPermission own_perm, ams::svc::MemoryPermission rem_perm);
virtual void Finalize() override;

View file

@ -33,7 +33,6 @@ namespace ams::kern {
ThreadListNode *m_thread_list_tail;
protected:
constexpr ALWAYS_INLINE explicit KSynchronizationObject() : KAutoObjectWithList(), m_thread_list_head(), m_thread_list_tail() { MESOSPHERE_ASSERT_THIS(); }
virtual ~KSynchronizationObject() { MESOSPHERE_ASSERT_THIS(); }
virtual void OnFinalizeSynchronizationObject() { MESOSPHERE_ASSERT_THIS(); }

View file

@ -239,10 +239,7 @@ namespace ams::kern {
public:
constexpr KThread() : m_wait_result(svc::ResultNoSynchronizationObject()), m_debug_exception_result(ResultSuccess()) { /* ... */ }
virtual ~KThread() { /* ... */ }
Result Initialize(KThreadFunction func, uintptr_t arg, void *kern_stack_top, KProcessAddress user_stack_top, s32 prio, s32 virt_core, KProcess *owner, ThreadType type);
private:
static Result InitializeThread(KThread *thread, KThreadFunction func, uintptr_t arg, KProcessAddress user_stack_top, s32 prio, s32 virt_core, KProcess *owner, ThreadType type);
public:

View file

@ -35,8 +35,6 @@ namespace ams::kern {
/* ... */
}
virtual ~KTransferMemory() { /* ... */ }
Result Initialize(KProcessAddress addr, size_t size, ams::svc::MemoryPermission own_perm);
virtual void Finalize() override;

View file

@ -28,7 +28,6 @@ namespace ams::kern {
KEvent *m_parent;
public:
constexpr explicit KWritableEvent() : m_parent(nullptr) { /* ... */ }
virtual ~KWritableEvent() { /* ... */ }
virtual void Destroy() override;

View file

@ -74,7 +74,6 @@ namespace ams::kern {
};
public:
constexpr KAutoObjectWithSlabHeapAndContainer() : Base() { /* ... */ }
virtual ~KAutoObjectWithSlabHeapAndContainer() { /* ... */ }
virtual void Destroy() override {
const bool is_initialized = this->IsInitialized();