< prev index next >

src/hotspot/share/gc/shared/collectedHeap.cpp

Print this page
rev 57511 : [mq]: metaspace-improvement


  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "gc/shared/allocTracer.hpp"
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "gc/shared/gcLocker.inline.hpp"
  32 #include "gc/shared/gcHeapSummary.hpp"
  33 #include "gc/shared/gcTrace.hpp"
  34 #include "gc/shared/gcTraceTime.inline.hpp"
  35 #include "gc/shared/gcVMOperations.hpp"
  36 #include "gc/shared/gcWhen.hpp"
  37 #include "gc/shared/memAllocator.hpp"
  38 #include "logging/log.hpp"
  39 #include "memory/metaspace.hpp"

  40 #include "memory/resourceArea.hpp"
  41 #include "memory/universe.hpp"
  42 #include "oops/instanceMirrorKlass.hpp"
  43 #include "oops/oop.inline.hpp"
  44 #include "runtime/handles.inline.hpp"
  45 #include "runtime/init.hpp"
  46 #include "runtime/thread.inline.hpp"
  47 #include "runtime/threadSMR.hpp"
  48 #include "runtime/vmThread.hpp"
  49 #include "services/heapDumper.hpp"
  50 #include "utilities/align.hpp"
  51 #include "utilities/copy.hpp"
  52 
  53 class ClassLoaderData;
  54 
  55 size_t CollectedHeap::_filler_array_max_size = 0;
  56 
  57 template <>
  58 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) {
  59   st->print_cr("GC heap %s", m.is_before ? "before" : "after");


  88 }
  89 
  90 VirtualSpaceSummary CollectedHeap::create_heap_space_summary() {
  91   size_t capacity_in_words = capacity() / HeapWordSize;
  92 
  93   return VirtualSpaceSummary(
  94     reserved_region().start(), reserved_region().start() + capacity_in_words, reserved_region().end());
  95 }
  96 
  97 GCHeapSummary CollectedHeap::create_heap_summary() {
  98   VirtualSpaceSummary heap_space = create_heap_space_summary();
  99   return GCHeapSummary(heap_space, used());
 100 }
 101 
 102 MetaspaceSummary CollectedHeap::create_metaspace_summary() {
 103   const MetaspaceSizes meta_space(
 104       MetaspaceUtils::committed_bytes(),
 105       MetaspaceUtils::used_bytes(),
 106       MetaspaceUtils::reserved_bytes());
 107   const MetaspaceSizes data_space(
 108       MetaspaceUtils::committed_bytes(Metaspace::NonClassType),
 109       MetaspaceUtils::used_bytes(Metaspace::NonClassType),
 110       MetaspaceUtils::reserved_bytes(Metaspace::NonClassType));
 111   const MetaspaceSizes class_space(
 112       MetaspaceUtils::committed_bytes(Metaspace::ClassType),
 113       MetaspaceUtils::used_bytes(Metaspace::ClassType),
 114       MetaspaceUtils::reserved_bytes(Metaspace::ClassType));
 115 
 116   const MetaspaceChunkFreeListSummary& ms_chunk_free_list_summary =
 117     MetaspaceUtils::chunk_free_list_summary(Metaspace::NonClassType);
 118   const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary =
 119     MetaspaceUtils::chunk_free_list_summary(Metaspace::ClassType);
 120 
 121   return MetaspaceSummary(MetaspaceGC::capacity_until_GC(), meta_space, data_space, class_space,
 122                           ms_chunk_free_list_summary, class_chunk_free_list_summary);
 123 }
 124 
 125 void CollectedHeap::print_heap_before_gc() {
 126   Universe::print_heap_before_gc();
 127   if (_gc_heap_log != NULL) {
 128     _gc_heap_log->log_heap_before(this);
 129   }
 130 }
 131 
 132 void CollectedHeap::print_heap_after_gc() {
 133   Universe::print_heap_after_gc();
 134   if (_gc_heap_log != NULL) {
 135     _gc_heap_log->log_heap_after(this);
 136   }
 137 }
 138 
 139 void CollectedHeap::print() const { print_on(tty); }


 238   switch (cause) {
 239     case GCCause::_heap_inspection:
 240     case GCCause::_heap_dump:
 241     case GCCause::_metadata_GC_threshold : {
 242       HandleMark hm;
 243       do_full_collection(false);        // don't clear all soft refs
 244       break;
 245     }
 246     case GCCause::_metadata_GC_clear_soft_refs: {
 247       HandleMark hm;
 248       do_full_collection(true);         // do clear all soft refs
 249       break;
 250     }
 251     default:
 252       ShouldNotReachHere(); // Unexpected use of this function
 253   }
 254 }
 255 
 256 MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
 257                                                             size_t word_size,
 258                                                             Metaspace::MetadataType mdtype) {
 259   uint loop_count = 0;
 260   uint gc_count = 0;
 261   uint full_gc_count = 0;
 262 
 263   assert(!Heap_lock->owned_by_self(), "Should not be holding the Heap_lock");
 264 
 265   do {
 266     MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
 267     if (result != NULL) {
 268       return result;
 269     }
 270 
 271     if (GCLocker::is_active_and_needs_gc()) {
 272       // If the GCLocker is active, just expand and allocate.
 273       // If that does not succeed, wait if this thread is not
 274       // in a critical section itself.
 275       result = loader_data->metaspace_non_null()->expand_and_allocate(word_size, mdtype);
 276       if (result != NULL) {
 277         return result;
 278       }




  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #include "precompiled.hpp"
  26 #include "classfile/systemDictionary.hpp"
  27 #include "gc/shared/allocTracer.hpp"
  28 #include "gc/shared/barrierSet.hpp"
  29 #include "gc/shared/collectedHeap.hpp"
  30 #include "gc/shared/collectedHeap.inline.hpp"
  31 #include "gc/shared/gcLocker.inline.hpp"
  32 #include "gc/shared/gcHeapSummary.hpp"
  33 #include "gc/shared/gcTrace.hpp"
  34 #include "gc/shared/gcTraceTime.inline.hpp"
  35 #include "gc/shared/gcVMOperations.hpp"
  36 #include "gc/shared/gcWhen.hpp"
  37 #include "gc/shared/memAllocator.hpp"
  38 #include "logging/log.hpp"
  39 #include "memory/metaspace.hpp"
  40 #include "memory/metaspace/classLoaderMetaspace.hpp"
  41 #include "memory/resourceArea.hpp"
  42 #include "memory/universe.hpp"
  43 #include "oops/instanceMirrorKlass.hpp"
  44 #include "oops/oop.inline.hpp"
  45 #include "runtime/handles.inline.hpp"
  46 #include "runtime/init.hpp"
  47 #include "runtime/thread.inline.hpp"
  48 #include "runtime/threadSMR.hpp"
  49 #include "runtime/vmThread.hpp"
  50 #include "services/heapDumper.hpp"
  51 #include "utilities/align.hpp"
  52 #include "utilities/copy.hpp"
  53 
  54 class ClassLoaderData;
  55 
  56 size_t CollectedHeap::_filler_array_max_size = 0;
  57 
  58 template <>
  59 void EventLogBase<GCMessage>::print(outputStream* st, GCMessage& m) {
  60   st->print_cr("GC heap %s", m.is_before ? "before" : "after");


  89 }
  90 
  91 VirtualSpaceSummary CollectedHeap::create_heap_space_summary() {
  92   size_t capacity_in_words = capacity() / HeapWordSize;
  93 
  94   return VirtualSpaceSummary(
  95     reserved_region().start(), reserved_region().start() + capacity_in_words, reserved_region().end());
  96 }
  97 
  98 GCHeapSummary CollectedHeap::create_heap_summary() {
  99   VirtualSpaceSummary heap_space = create_heap_space_summary();
 100   return GCHeapSummary(heap_space, used());
 101 }
 102 
 103 MetaspaceSummary CollectedHeap::create_metaspace_summary() {
 104   const MetaspaceSizes meta_space(
 105       MetaspaceUtils::committed_bytes(),
 106       MetaspaceUtils::used_bytes(),
 107       MetaspaceUtils::reserved_bytes());
 108   const MetaspaceSizes data_space(
 109       MetaspaceUtils::committed_bytes(metaspace::NonClassType),
 110       MetaspaceUtils::used_bytes(metaspace::NonClassType),
 111       MetaspaceUtils::reserved_bytes(metaspace::NonClassType));
 112   const MetaspaceSizes class_space(
 113       MetaspaceUtils::committed_bytes(metaspace::ClassType),
 114       MetaspaceUtils::used_bytes(metaspace::ClassType),
 115       MetaspaceUtils::reserved_bytes(metaspace::ClassType));
 116 
 117   const MetaspaceChunkFreeListSummary& ms_chunk_free_list_summary =
 118     MetaspaceUtils::chunk_free_list_summary(metaspace::NonClassType);
 119   const MetaspaceChunkFreeListSummary& class_chunk_free_list_summary =
 120     MetaspaceUtils::chunk_free_list_summary(metaspace::ClassType);
 121 
 122   return MetaspaceSummary(MetaspaceGC::capacity_until_GC(), meta_space, data_space, class_space,
 123                           ms_chunk_free_list_summary, class_chunk_free_list_summary);
 124 }
 125 
 126 void CollectedHeap::print_heap_before_gc() {
 127   Universe::print_heap_before_gc();
 128   if (_gc_heap_log != NULL) {
 129     _gc_heap_log->log_heap_before(this);
 130   }
 131 }
 132 
 133 void CollectedHeap::print_heap_after_gc() {
 134   Universe::print_heap_after_gc();
 135   if (_gc_heap_log != NULL) {
 136     _gc_heap_log->log_heap_after(this);
 137   }
 138 }
 139 
 140 void CollectedHeap::print() const { print_on(tty); }


 239   switch (cause) {
 240     case GCCause::_heap_inspection:
 241     case GCCause::_heap_dump:
 242     case GCCause::_metadata_GC_threshold : {
 243       HandleMark hm;
 244       do_full_collection(false);        // don't clear all soft refs
 245       break;
 246     }
 247     case GCCause::_metadata_GC_clear_soft_refs: {
 248       HandleMark hm;
 249       do_full_collection(true);         // do clear all soft refs
 250       break;
 251     }
 252     default:
 253       ShouldNotReachHere(); // Unexpected use of this function
 254   }
 255 }
 256 
 257 MetaWord* CollectedHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
 258                                                             size_t word_size,
 259                                                             metaspace::MetadataType mdtype) {
 260   uint loop_count = 0;
 261   uint gc_count = 0;
 262   uint full_gc_count = 0;
 263 
 264   assert(!Heap_lock->owned_by_self(), "Should not be holding the Heap_lock");
 265 
 266   do {
 267     MetaWord* result = loader_data->metaspace_non_null()->allocate(word_size, mdtype);
 268     if (result != NULL) {
 269       return result;
 270     }
 271 
 272     if (GCLocker::is_active_and_needs_gc()) {
 273       // If the GCLocker is active, just expand and allocate.
 274       // If that does not succeed, wait if this thread is not
 275       // in a critical section itself.
 276       result = loader_data->metaspace_non_null()->expand_and_allocate(word_size, mdtype);
 277       if (result != NULL) {
 278         return result;
 279       }


< prev index next >