@@ -84,17 +84,20 @@ namespace snmalloc
8484 class sizeclass_t ;
8585
8686 /* *
87- * Entry stored in the pagemap.
87+ * Entry stored in the pagemap. See docs/AddressSpace.md for the full
88+ * MetaEntry lifecycle.
8889 */
8990 class MetaEntry
9091 {
9192 template <typename Pagemap>
9293 friend class BuddyChunkRep ;
9394
9495 /* *
95- * The pointer to the metaslab, the bottom bit is used to indicate if this
96- * is the first chunk in a PAL allocation, that cannot be combined with
97- * the preceeding chunk.
96+ * In common cases, the pointer to the metaslab. See docs/AddressSpace.md
97+ * for additional details.
98+ *
99+ * The bottom bit is used to indicate if this is the first chunk in a PAL
100+ * allocation, that cannot be combined with the preceeding chunk.
98101 */
99102 uintptr_t meta{0 };
100103
@@ -107,18 +110,12 @@ namespace snmalloc
107110 * representable. It is also true on Windows as you cannot Commit across
108111 * multiple continuous VirtualAllocs.
109112 */
110- static constexpr address_t BOUNDARY_BIT = 1 ;
113+ static constexpr address_t META_BOUNDARY_BIT = 1 << 0 ;
111114
112115 /* *
113- * A bit-packed pointer to the owning allocator (if any), and the sizeclass
114- * of this chunk. The sizeclass here is itself a union between two cases:
115- *
116- * * log_2(size), at least MIN_CHUNK_BITS, for large allocations.
117- *
118- * * a value in [0, NUM_SMALL_SIZECLASSES] for small allocations. These
119- * may be directly passed to the sizeclass (not slab_sizeclass) functions
120- * of sizeclasstable.h
121- *
116+ * In common cases, a bit-packed pointer to the owning allocator (if any),
117+ * and the sizeclass of this chunk. See mem/metaslab.h:MetaEntryRemote for
118+ * details of this case and docs/AddressSpace.md for further details.
122119 */
123120 uintptr_t remote_and_sizeclass{0 };
124121
@@ -160,7 +157,7 @@ namespace snmalloc
160157 [[nodiscard]] SNMALLOC_FAST_PATH Metaslab* get_metaslab () const
161158 {
162159 SNMALLOC_ASSERT (get_remote () != nullptr );
163- return unsafe_from_uintptr<Metaslab>(meta & ~BOUNDARY_BIT );
160+ return unsafe_from_uintptr<Metaslab>(meta & ~META_BOUNDARY_BIT );
164161 }
165162
166163 /* *
@@ -183,24 +180,25 @@ namespace snmalloc
183180 MetaEntry& operator =(const MetaEntry& other)
184181 {
185182 // Don't overwrite the boundary bit with the other's
186- meta = (other.meta & ~BOUNDARY_BIT) | address_cast (meta & BOUNDARY_BIT);
183+ meta = (other.meta & ~META_BOUNDARY_BIT) |
184+ address_cast (meta & META_BOUNDARY_BIT);
187185 remote_and_sizeclass = other.remote_and_sizeclass ;
188186 return *this ;
189187 }
190188
191189 void set_boundary ()
192190 {
193- meta |= BOUNDARY_BIT ;
191+ meta |= META_BOUNDARY_BIT ;
194192 }
195193
196194 [[nodiscard]] bool is_boundary () const
197195 {
198- return meta & BOUNDARY_BIT ;
196+ return meta & META_BOUNDARY_BIT ;
199197 }
200198
201199 bool clear_boundary_bit ()
202200 {
203- return meta &= ~BOUNDARY_BIT ;
201+ return meta &= ~META_BOUNDARY_BIT ;
204202 }
205203 };
206204
0 commit comments