From 6ad7f65d19f36eea905b14ae0753114287ff2c09 Mon Sep 17 00:00:00 2001 From: Matthew Parkinson Date: Fri, 18 Mar 2022 14:55:31 +0000 Subject: [PATCH] Remove unused code. --- src/ds/dllist.h | 209 -------------------------------------------- src/ds/invalidptr.h | 53 ----------- src/mem/metaslab.h | 1 - 3 files changed, 263 deletions(-) delete mode 100644 src/ds/dllist.h delete mode 100644 src/ds/invalidptr.h diff --git a/src/ds/dllist.h b/src/ds/dllist.h deleted file mode 100644 index 95bb8e5..0000000 --- a/src/ds/dllist.h +++ /dev/null @@ -1,209 +0,0 @@ -#pragma once - -#include "address.h" -#include "helpers.h" -#include "invalidptr.h" -#include "ptrwrap.h" - -#include -#include - -namespace snmalloc -{ - template< - class T, - template typename Ptr = Pointer, - class Terminator = std::nullptr_t, - void on_clear(Ptr) = ignore> - class DLList final - { - private: - static_assert( - std::is_same>::value, - "T->prev must be a Ptr"); - static_assert( - std::is_same>::value, - "T->next must be a Ptr"); - - Ptr head = Terminator(); - Ptr tail = Terminator(); - - public: - ~DLList() - { - clear(); - } - - DLList() = default; - - DLList(DLList&& o) noexcept - { - head = o.head; - tail = o.tail; - - o.head = nullptr; - o.tail = nullptr; - } - - DLList& operator=(DLList&& o) noexcept - { - head = o.head; - tail = o.tail; - - o.head = nullptr; - o.tail = nullptr; - return *this; - } - - SNMALLOC_FAST_PATH bool is_empty() - { - return head == Terminator(); - } - - SNMALLOC_FAST_PATH Ptr get_head() - { - return head; - } - - Ptr get_tail() - { - return tail; - } - - SNMALLOC_FAST_PATH Ptr pop() - { - Ptr item = head; - - if (item != Terminator()) - remove(item); - - return item; - } - - Ptr pop_tail() - { - Ptr item = tail; - - if (item != Terminator()) - remove(item); - - return item; - } - - void insert(Ptr item) - { - debug_check_not_contains(item); - - item->next = head; - item->prev = Terminator(); - - if (head != Terminator()) - head->prev = item; - else - tail = item; - - head = item; - - if constexpr (DEBUG) - debug_check(); - } - - void insert_back(Ptr item) - { - debug_check_not_contains(item); - - item->prev = tail; - item->next = Terminator(); - - if (tail != Terminator()) - tail->next = item; - else - head = item; - - tail = item; - - debug_check(); - } - - SNMALLOC_FAST_PATH void remove(Ptr item) - { - debug_check_contains(item); - - if (item->next != Terminator()) - item->next->prev = item->prev; - else - tail = item->prev; - - if (item->prev != Terminator()) - item->prev->next = item->next; - else - head = item->next; - - debug_check(); - } - - void clear() - { - while (head != nullptr) - { - auto c = head; - remove(c); - on_clear(c); - } - } - - void debug_check_contains(Ptr item) - { - if constexpr (DEBUG) - { - debug_check(); - Ptr curr = head; - - while (curr != item) - { - SNMALLOC_ASSERT(curr != Terminator()); - curr = curr->next; - } - } - else - { - UNUSED(item); - } - } - - void debug_check_not_contains(Ptr item) - { - if constexpr (DEBUG) - { - debug_check(); - Ptr curr = head; - - while (curr != Terminator()) - { - SNMALLOC_ASSERT(curr != item); - curr = curr->next; - } - } - else - { - UNUSED(item); - } - } - - void debug_check() - { - if constexpr (DEBUG) - { - Ptr item = head; - Ptr prev = Terminator(); - - while (item != Terminator()) - { - SNMALLOC_ASSERT(item->prev == prev); - prev = item; - item = item->next; - } - } - } - }; -} // namespace snmalloc diff --git a/src/ds/invalidptr.h b/src/ds/invalidptr.h deleted file mode 100644 index 1a75f0b..0000000 --- a/src/ds/invalidptr.h +++ /dev/null @@ -1,53 +0,0 @@ -#pragma once - -#include "address.h" - -namespace snmalloc -{ - /** - * Invalid pointer class. This is similar to `std::nullptr_t`, but allows - * other values. - */ - template - struct InvalidPointer - { - /** - * Equality comparison. Two invalid pointer values with the same sentinel - * are always the same, invalid pointer values with different sentinels are - * always different. - */ - template - constexpr bool operator==(const InvalidPointer&) - { - return Sentinel == OtherSentinel; - } - /** - * Equality comparison. Two invalid pointer values with the same sentinel - * are always the same, invalid pointer values with different sentinels are - * always different. - */ - template - constexpr bool operator!=(const InvalidPointer&) - { - return Sentinel != OtherSentinel; - } - /** - * Implicit conversion, creates a pointer with the value of the sentinel. - * On CHERI and other provenance-tracking systems, this is a - * provenance-free integer and so will trap if dereferenced, on other - * systems the sentinel should be a value in unmapped memory. - */ - template - operator T*() const - { - return reinterpret_cast(Sentinel); - } - /** - * Implicit conversion to an address, returns the sentinel value. - */ - operator address_t() const - { - return Sentinel; - } - }; -} // namespace snmalloc diff --git a/src/mem/metaslab.h b/src/mem/metaslab.h index 947b22d..e386f16 100644 --- a/src/mem/metaslab.h +++ b/src/mem/metaslab.h @@ -1,6 +1,5 @@ #pragma once -#include "../ds/dllist.h" #include "../ds/helpers.h" #include "../ds/seqset.h" #include "../mem/remoteallocator.h"