212 retTL == retTL->parent()->left() || 213 retTL == retTL->parent()->right(), 214 "list is inconsistent"); 215 ) 216 retTL->decrement_count(); 217 218 assert(tc->is_free(), "Should still be a free chunk"); 219 assert(retTL->head() == NULL || retTL->head()->prev() == NULL, 220 "list invariant"); 221 assert(retTL->tail() == NULL || retTL->tail()->next() == NULL, 222 "list invariant"); 223 return retTL; 224 } 225 226 template <class Chunk_t, class FreeList_t> 227 void TreeList<Chunk_t, FreeList_t>::return_chunk_at_tail(TreeChunk<Chunk_t, FreeList_t>* chunk) { 228 assert(chunk != NULL, "returning NULL chunk"); 229 assert(chunk->list() == this, "list should be set for chunk"); 230 assert(tail() != NULL, "The tree list is embedded in the first chunk"); 231 // which means that the list can never be empty. 232 assert(!this->verify_chunk_in_free_list(chunk), "Double entry"); 233 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 234 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 235 236 Chunk_t* fc = tail(); 237 fc->link_after(chunk); 238 this->link_tail(chunk); 239 240 assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); 241 FreeList_t::increment_count(); 242 debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) 243 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 244 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 245 } 246 247 // Add this chunk at the head of the list. "At the head of the list" 248 // is defined to be after the chunk pointer to by head(). This is 249 // because the TreeList<Chunk_t, FreeList_t> is embedded in the first TreeChunk<Chunk_t, FreeList_t> in the 250 // list. See the definition of TreeChunk<Chunk_t, FreeList_t>. 251 template <class Chunk_t, class FreeList_t> 252 void TreeList<Chunk_t, FreeList_t>::return_chunk_at_head(TreeChunk<Chunk_t, FreeList_t>* chunk) { 253 assert(chunk->list() == this, "list should be set for chunk"); 254 assert(head() != NULL, "The tree list is embedded in the first chunk"); 255 assert(chunk != NULL, "returning NULL chunk"); 256 assert(!this->verify_chunk_in_free_list(chunk), "Double entry"); 257 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 258 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 259 260 Chunk_t* fc = head()->next(); 261 if (fc != NULL) { 262 chunk->link_after(fc); 263 } else { 264 assert(tail() == NULL, "List is inconsistent"); 265 this->link_tail(chunk); 266 } 267 head()->link_after(chunk); 268 assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); 269 FreeList_t::increment_count(); 270 debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) 271 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 272 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 273 } 274 275 template <class Chunk_t, class FreeList_t> 276 void TreeChunk<Chunk_t, FreeList_t>::assert_is_mangled() const { | 212 retTL == retTL->parent()->left() || 213 retTL == retTL->parent()->right(), 214 "list is inconsistent"); 215 ) 216 retTL->decrement_count(); 217 218 assert(tc->is_free(), "Should still be a free chunk"); 219 assert(retTL->head() == NULL || retTL->head()->prev() == NULL, 220 "list invariant"); 221 assert(retTL->tail() == NULL || retTL->tail()->next() == NULL, 222 "list invariant"); 223 return retTL; 224 } 225 226 template <class Chunk_t, class FreeList_t> 227 void TreeList<Chunk_t, FreeList_t>::return_chunk_at_tail(TreeChunk<Chunk_t, FreeList_t>* chunk) { 228 assert(chunk != NULL, "returning NULL chunk"); 229 assert(chunk->list() == this, "list should be set for chunk"); 230 assert(tail() != NULL, "The tree list is embedded in the first chunk"); 231 // which means that the list can never be empty. 232 if (FLSVerifyDictionary) { 233 // This is expensive for metaspace 234 assert(!this->verify_chunk_in_free_list(chunk), "Double entry"); 235 } 236 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 237 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 238 239 Chunk_t* fc = tail(); 240 fc->link_after(chunk); 241 this->link_tail(chunk); 242 243 assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); 244 FreeList_t::increment_count(); 245 debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) 246 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 247 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 248 } 249 250 // Add this chunk at the head of the list. "At the head of the list" 251 // is defined to be after the chunk pointer to by head(). This is 252 // because the TreeList<Chunk_t, FreeList_t> is embedded in the first TreeChunk<Chunk_t, FreeList_t> in the 253 // list. See the definition of TreeChunk<Chunk_t, FreeList_t>. 254 template <class Chunk_t, class FreeList_t> 255 void TreeList<Chunk_t, FreeList_t>::return_chunk_at_head(TreeChunk<Chunk_t, FreeList_t>* chunk) { 256 assert(chunk->list() == this, "list should be set for chunk"); 257 assert(head() != NULL, "The tree list is embedded in the first chunk"); 258 assert(chunk != NULL, "returning NULL chunk"); 259 if (FLSVerifyDictionary) { 260 // This is expensive for metaspace 261 assert(!this->verify_chunk_in_free_list(chunk), "Double entry"); 262 } 263 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 264 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 265 266 Chunk_t* fc = head()->next(); 267 if (fc != NULL) { 268 chunk->link_after(fc); 269 } else { 270 assert(tail() == NULL, "List is inconsistent"); 271 this->link_tail(chunk); 272 } 273 head()->link_after(chunk); 274 assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); 275 FreeList_t::increment_count(); 276 debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) 277 assert(head() == NULL || head()->prev() == NULL, "list invariant"); 278 assert(tail() == NULL || tail()->next() == NULL, "list invariant"); 279 } 280 281 template <class Chunk_t, class FreeList_t> 282 void TreeChunk<Chunk_t, FreeList_t>::assert_is_mangled() const { |