X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/863527832a75ecd15e2b6057661763f0279b2b0d..a92d7b716f51a53dea7f59db8524d4add713b910:/src/mc/PageStore.hpp diff --git a/src/mc/PageStore.hpp b/src/mc/PageStore.hpp index 2ec8ec99e0..80332eaebc 100644 --- a/src/mc/PageStore.hpp +++ b/src/mc/PageStore.hpp @@ -13,7 +13,7 @@ #include #include -#include +#include "xbt/base.h" #include "src/mc/mc_mmu.h" #include "src/mc/mc_forward.hpp" @@ -23,11 +23,10 @@ namespace mc { /** @brief Storage for snapshot memory pages * - * The first (lower) layer of the per-page snapshot mechanism is a page - * store: its responsibility is to store immutable shareable - * reference-counted memory pages independently of the snapshotting - * logic. Snapshot management and representation, soft-dirty tracking is - * handled to an higher layer. READMORE + * The first (lower) layer of the per-page snapshot mechanism is a page store: + * its responsibility is to store immutable sharable reference-counted memory + * pages independently of the snapshotting logic. Snapshot management and + * representation is handled to an higher layer. READMORE * * Data structure: * @@ -112,8 +111,7 @@ public: // Methods /** @brief Decrement the reference count for a given page * - * Decrement the reference count of this page. Used when a snapshot is - * destroyed. + * Decrement the reference count of this page. Used when a snapshot is destroyed. * * If the reference count reaches zero, the page is recycled: * it is added to the `free_pages_` list and removed from the `hash_index_`. @@ -138,7 +136,7 @@ public: // Methods /** @brief Get a page from its page number * - * @param Number of the memory page in the store + * @param pageno Number of the memory page in the store * @return Start of the page */ const void* get_page(std::size_t pageno) const; @@ -159,37 +157,33 @@ public: // Debug/test methods }; -inline __attribute__((always_inline)) -void PageStore::unref_page(std::size_t pageno) { +XBT_ALWAYS_INLINE void PageStore::unref_page(std::size_t pageno) +{ if ((--this->page_counts_[pageno]) == 0) this->remove_page(pageno); } -inline __attribute__((always_inline)) -void PageStore::ref_page(size_t pageno) +XBT_ALWAYS_INLINE void PageStore::ref_page(size_t pageno) { ++this->page_counts_[pageno]; } -inline __attribute__((always_inline)) -const void* PageStore::get_page(std::size_t pageno) const +XBT_ALWAYS_INLINE const void* PageStore::get_page(std::size_t pageno) const { return (void*) simgrid::mc::mmu::join(pageno, (std::uintptr_t) this->memory_); } -inline __attribute__((always_inline)) -std::size_t PageStore::get_ref(std::size_t pageno) +XBT_ALWAYS_INLINE std::size_t PageStore::get_ref(std::size_t pageno) { return this->page_counts_[pageno]; } -inline __attribute__((always_inline)) -std::size_t PageStore::size() { +XBT_ALWAYS_INLINE std::size_t PageStore::size() +{ return this->top_index_ - this->free_pages_.size(); } -inline __attribute__((always_inline)) -std::size_t PageStore::capacity() +XBT_ALWAYS_INLINE std::size_t PageStore::capacity() { return this->capacity_; }