< prev index next >

src/hotspot/share/memory/metaspace/chunkManager.cpp

Print this page




 491       }
 492     }
 493 
 494     if (chunk == NULL) {
 495       return NULL;
 496     }
 497 
 498     // Remove the chunk as the head of the list.
 499     free_list->remove_chunk(chunk);
 500 
 501     log_trace(gc, metaspace, freelist)("ChunkManager::free_chunks_get: free_list: " PTR_FORMAT " chunks left: " SSIZE_FORMAT ".",
 502                                        p2i(free_list), free_list->count());
 503 
 504   } else {
 505     chunk = humongous_dictionary()->get_chunk(word_size);
 506 
 507     if (chunk == NULL) {
 508       return NULL;
 509     }
 510 
 511     log_debug(gc, metaspace, alloc)("Free list allocate humongous chunk size " SIZE_FORMAT " for requested size " SIZE_FORMAT " waste " SIZE_FORMAT,
 512                                     chunk->word_size(), word_size, chunk->word_size() - word_size);
 513   }
 514 
 515   // Chunk has been removed from the chunk manager; update counters.
 516   account_for_removed_chunk(chunk);
 517   do_update_in_use_info_for_chunk(chunk, true);
 518   chunk->container()->inc_container_count();
 519   chunk->inc_use_count();
 520 
 521   // Remove it from the links to this freelist
 522   chunk->set_next(NULL);
 523   chunk->set_prev(NULL);
 524 
 525   // Run some verifications (some more if we did a chunk split)
 526 #ifdef ASSERT
 527   if (VerifyMetaspace) {
 528     locked_verify();
 529     VirtualSpaceNode* const vsn = chunk->container();
 530     vsn->verify();
 531     if (we_did_split_a_chunk) {


 533     }
 534   }
 535 #endif
 536 
 537   return chunk;
 538 }
 539 
 540 Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) {
 541   assert_lock_strong(MetaspaceExpand_lock);
 542   slow_locked_verify();
 543 
 544   // Take from the beginning of the list
 545   Metachunk* chunk = free_chunks_get(word_size);
 546   if (chunk == NULL) {
 547     return NULL;
 548   }
 549 
 550   assert((word_size <= chunk->word_size()) ||
 551          (list_index(chunk->word_size()) == HumongousIndex),
 552          "Non-humongous variable sized chunk");
 553   LogTarget(Debug, gc, metaspace, freelist) lt;
 554   if (lt.is_enabled()) {
 555     size_t list_count;
 556     if (list_index(word_size) < HumongousIndex) {
 557       ChunkList* list = find_free_chunks_list(word_size);
 558       list_count = list->count();
 559     } else {
 560       list_count = humongous_dictionary()->total_count();
 561     }
 562     LogStream ls(lt);
 563     ls.print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk " PTR_FORMAT "  size " SIZE_FORMAT " count " SIZE_FORMAT " ",
 564              p2i(this), p2i(chunk), chunk->word_size(), list_count);
 565     ResourceMark rm;
 566     locked_print_free_chunks(&ls);
 567   }
 568 
 569   return chunk;
 570 }
 571 
 572 void ChunkManager::return_single_chunk(Metachunk* chunk) {
 573   const ChunkIndex index = chunk->get_chunk_type();




 491       }
 492     }
 493 
 494     if (chunk == NULL) {
 495       return NULL;
 496     }
 497 
 498     // Remove the chunk as the head of the list.
 499     free_list->remove_chunk(chunk);
 500 
 501     log_trace(gc, metaspace, freelist)("ChunkManager::free_chunks_get: free_list: " PTR_FORMAT " chunks left: " SSIZE_FORMAT ".",
 502                                        p2i(free_list), free_list->count());
 503 
 504   } else {
 505     chunk = humongous_dictionary()->get_chunk(word_size);
 506 
 507     if (chunk == NULL) {
 508       return NULL;
 509     }
 510 
 511     log_trace(gc, metaspace, alloc)("Free list allocate humongous chunk size " SIZE_FORMAT " for requested size " SIZE_FORMAT " waste " SIZE_FORMAT,
 512                                     chunk->word_size(), word_size, chunk->word_size() - word_size);
 513   }
 514 
 515   // Chunk has been removed from the chunk manager; update counters.
 516   account_for_removed_chunk(chunk);
 517   do_update_in_use_info_for_chunk(chunk, true);
 518   chunk->container()->inc_container_count();
 519   chunk->inc_use_count();
 520 
 521   // Remove it from the links to this freelist
 522   chunk->set_next(NULL);
 523   chunk->set_prev(NULL);
 524 
 525   // Run some verifications (some more if we did a chunk split)
 526 #ifdef ASSERT
 527   if (VerifyMetaspace) {
 528     locked_verify();
 529     VirtualSpaceNode* const vsn = chunk->container();
 530     vsn->verify();
 531     if (we_did_split_a_chunk) {


 533     }
 534   }
 535 #endif
 536 
 537   return chunk;
 538 }
 539 
 540 Metachunk* ChunkManager::chunk_freelist_allocate(size_t word_size) {
 541   assert_lock_strong(MetaspaceExpand_lock);
 542   slow_locked_verify();
 543 
 544   // Take from the beginning of the list
 545   Metachunk* chunk = free_chunks_get(word_size);
 546   if (chunk == NULL) {
 547     return NULL;
 548   }
 549 
 550   assert((word_size <= chunk->word_size()) ||
 551          (list_index(chunk->word_size()) == HumongousIndex),
 552          "Non-humongous variable sized chunk");
 553   LogTarget(Trace, gc, metaspace, freelist) lt;
 554   if (lt.is_enabled()) {
 555     size_t list_count;
 556     if (list_index(word_size) < HumongousIndex) {
 557       ChunkList* list = find_free_chunks_list(word_size);
 558       list_count = list->count();
 559     } else {
 560       list_count = humongous_dictionary()->total_count();
 561     }
 562     LogStream ls(lt);
 563     ls.print("ChunkManager::chunk_freelist_allocate: " PTR_FORMAT " chunk " PTR_FORMAT "  size " SIZE_FORMAT " count " SIZE_FORMAT " ",
 564              p2i(this), p2i(chunk), chunk->word_size(), list_count);
 565     ResourceMark rm;
 566     locked_print_free_chunks(&ls);
 567   }
 568 
 569   return chunk;
 570 }
 571 
 572 void ChunkManager::return_single_chunk(Metachunk* chunk) {
 573   const ChunkIndex index = chunk->get_chunk_type();


< prev index next >