< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahHeap.cpp

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


  51 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
  52 #include "gc/shenandoah/shenandoahNormalMode.hpp"
  53 #include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
  54 #include "gc/shenandoah/shenandoahPacer.inline.hpp"
  55 #include "gc/shenandoah/shenandoahParallelCleaning.inline.hpp"
  56 #include "gc/shenandoah/shenandoahPassiveMode.hpp"
  57 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
  58 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  59 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
  60 #include "gc/shenandoah/shenandoahTraversalMode.hpp"
  61 #include "gc/shenandoah/shenandoahUtils.hpp"
  62 #include "gc/shenandoah/shenandoahVerifier.hpp"
  63 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  64 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  65 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
  66 #include "gc/shenandoah/shenandoahWorkerPolicy.hpp"
  67 #if INCLUDE_JFR
  68 #include "gc/shenandoah/shenandoahJfrSupport.hpp"
  69 #endif
  70 
  71 #include "memory/metaspace.hpp"


  72 #include "oops/compressedOops.inline.hpp"
  73 #include "runtime/globals.hpp"
  74 #include "runtime/interfaceSupport.inline.hpp"
  75 #include "runtime/safepointMechanism.hpp"
  76 #include "runtime/vmThread.hpp"
  77 #include "services/mallocTracker.hpp"
  78 
  79 #ifdef ASSERT
  80 template <class T>
  81 void ShenandoahAssertToSpaceClosure::do_oop_work(T* p) {
  82   T o = RawAccess<>::oop_load(p);
  83   if (! CompressedOops::is_null(o)) {
  84     oop obj = CompressedOops::decode_not_null(o);
  85     shenandoah_assert_not_forwarded(p, obj);
  86   }
  87 }
  88 
  89 void ShenandoahAssertToSpaceClosure::do_oop(narrowOop* p) { do_oop_work(p); }
  90 void ShenandoahAssertToSpaceClosure::do_oop(oop* p)       { do_oop_work(p); }
  91 #endif


 856       increase_used(actual*HeapWordSize);
 857     }
 858   }
 859 
 860   return result;
 861 }
 862 
 863 HeapWord* ShenandoahHeap::allocate_memory_under_lock(ShenandoahAllocRequest& req, bool& in_new_region) {
 864   ShenandoahHeapLocker locker(lock());
 865   return _free_set->allocate(req, in_new_region);
 866 }
 867 
 868 HeapWord* ShenandoahHeap::mem_allocate(size_t size,
 869                                         bool*  gc_overhead_limit_was_exceeded) {
 870   ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared(size);
 871   return allocate_memory(req);
 872 }
 873 
 874 MetaWord* ShenandoahHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
 875                                                              size_t size,
 876                                                              Metaspace::MetadataType mdtype) {
 877   MetaWord* result;
 878 
 879   // Inform metaspace OOM to GC heuristics if class unloading is possible.
 880   if (heuristics()->can_unload_classes()) {
 881     ShenandoahHeuristics* h = heuristics();
 882     h->record_metaspace_oom();
 883   }
 884 
 885   // Expand and retry allocation
 886   result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype);
 887   if (result != NULL) {
 888     return result;
 889   }
 890 
 891   // Start full GC
 892   collect(GCCause::_metadata_GC_clear_soft_refs);
 893 
 894   // Retry allocation
 895   result = loader_data->metaspace_non_null()->allocate(size, mdtype);
 896   if (result != NULL) {


1970   }
1971 
1972   {
1973     ShenandoahGCPhase phase(full_gc ?
1974                             ShenandoahPhaseTimings::full_gc_purge_par :
1975                             ShenandoahPhaseTimings::purge_par);
1976     ShenandoahIsAliveSelector is_alive;
1977     uint num_workers = _workers->active_workers();
1978     ShenandoahClassUnloadingTask unlink_task(is_alive.is_alive_closure(), num_workers, purged_class);
1979     _workers->run_task(&unlink_task);
1980   }
1981 
1982   {
1983     ShenandoahGCPhase phase(full_gc ?
1984                             ShenandoahPhaseTimings::full_gc_purge_cldg :
1985                             ShenandoahPhaseTimings::purge_cldg);
1986     ClassLoaderDataGraph::purge();
1987   }
1988   // Resize and verify metaspace
1989   MetaspaceGC::compute_new_size();
1990   MetaspaceUtils::verify_metrics();
1991 }
1992 
1993 // Process leftover weak oops: update them, if needed or assert they do not
1994 // need updating otherwise.
1995 // Weak processor API requires us to visit the oops, even if we are not doing
1996 // anything to them.
1997 void ShenandoahHeap::stw_process_weak_roots(bool full_gc) {
1998   ShenandoahGCPhase root_phase(full_gc ?
1999                                ShenandoahPhaseTimings::full_gc_purge :
2000                                ShenandoahPhaseTimings::purge);
2001   uint num_workers = _workers->active_workers();
2002   ShenandoahPhaseTimings::Phase timing_phase = full_gc ?
2003                                                ShenandoahPhaseTimings::full_gc_purge_par :
2004                                                ShenandoahPhaseTimings::purge_par;
2005   // Cleanup weak roots
2006   ShenandoahGCPhase phase(timing_phase);
2007   if (has_forwarded_objects()) {
2008     ShenandoahForwardedIsAliveClosure is_alive;
2009     ShenandoahUpdateRefsClosure keep_alive;
2010     ShenandoahParallelWeakRootsCleaningTask<ShenandoahForwardedIsAliveClosure, ShenandoahUpdateRefsClosure>




  51 #include "gc/shenandoah/shenandoahMonitoringSupport.hpp"
  52 #include "gc/shenandoah/shenandoahNormalMode.hpp"
  53 #include "gc/shenandoah/shenandoahOopClosures.inline.hpp"
  54 #include "gc/shenandoah/shenandoahPacer.inline.hpp"
  55 #include "gc/shenandoah/shenandoahParallelCleaning.inline.hpp"
  56 #include "gc/shenandoah/shenandoahPassiveMode.hpp"
  57 #include "gc/shenandoah/shenandoahRootProcessor.inline.hpp"
  58 #include "gc/shenandoah/shenandoahStringDedup.hpp"
  59 #include "gc/shenandoah/shenandoahTaskqueue.hpp"
  60 #include "gc/shenandoah/shenandoahTraversalMode.hpp"
  61 #include "gc/shenandoah/shenandoahUtils.hpp"
  62 #include "gc/shenandoah/shenandoahVerifier.hpp"
  63 #include "gc/shenandoah/shenandoahCodeRoots.hpp"
  64 #include "gc/shenandoah/shenandoahVMOperations.hpp"
  65 #include "gc/shenandoah/shenandoahWorkGroup.hpp"
  66 #include "gc/shenandoah/shenandoahWorkerPolicy.hpp"
  67 #if INCLUDE_JFR
  68 #include "gc/shenandoah/shenandoahJfrSupport.hpp"
  69 #endif
  70 
  71 
  72 #include "memory/metaspace/classLoaderMetaspace.hpp"
  73 #include "memory/metaspace/metaspaceEnums.hpp"
  74 #include "oops/compressedOops.inline.hpp"
  75 #include "runtime/globals.hpp"
  76 #include "runtime/interfaceSupport.inline.hpp"
  77 #include "runtime/safepointMechanism.hpp"
  78 #include "runtime/vmThread.hpp"
  79 #include "services/mallocTracker.hpp"
  80 
  81 #ifdef ASSERT
  82 template <class T>
  83 void ShenandoahAssertToSpaceClosure::do_oop_work(T* p) {
  84   T o = RawAccess<>::oop_load(p);
  85   if (! CompressedOops::is_null(o)) {
  86     oop obj = CompressedOops::decode_not_null(o);
  87     shenandoah_assert_not_forwarded(p, obj);
  88   }
  89 }
  90 
  91 void ShenandoahAssertToSpaceClosure::do_oop(narrowOop* p) { do_oop_work(p); }
  92 void ShenandoahAssertToSpaceClosure::do_oop(oop* p)       { do_oop_work(p); }
  93 #endif


 858       increase_used(actual*HeapWordSize);
 859     }
 860   }
 861 
 862   return result;
 863 }
 864 
 865 HeapWord* ShenandoahHeap::allocate_memory_under_lock(ShenandoahAllocRequest& req, bool& in_new_region) {
 866   ShenandoahHeapLocker locker(lock());
 867   return _free_set->allocate(req, in_new_region);
 868 }
 869 
 870 HeapWord* ShenandoahHeap::mem_allocate(size_t size,
 871                                         bool*  gc_overhead_limit_was_exceeded) {
 872   ShenandoahAllocRequest req = ShenandoahAllocRequest::for_shared(size);
 873   return allocate_memory(req);
 874 }
 875 
 876 MetaWord* ShenandoahHeap::satisfy_failed_metadata_allocation(ClassLoaderData* loader_data,
 877                                                              size_t size,
 878                                                              metaspace::MetadataType mdtype) {
 879   MetaWord* result;
 880 
 881   // Inform metaspace OOM to GC heuristics if class unloading is possible.
 882   if (heuristics()->can_unload_classes()) {
 883     ShenandoahHeuristics* h = heuristics();
 884     h->record_metaspace_oom();
 885   }
 886 
 887   // Expand and retry allocation
 888   result = loader_data->metaspace_non_null()->expand_and_allocate(size, mdtype);
 889   if (result != NULL) {
 890     return result;
 891   }
 892 
 893   // Start full GC
 894   collect(GCCause::_metadata_GC_clear_soft_refs);
 895 
 896   // Retry allocation
 897   result = loader_data->metaspace_non_null()->allocate(size, mdtype);
 898   if (result != NULL) {


1972   }
1973 
1974   {
1975     ShenandoahGCPhase phase(full_gc ?
1976                             ShenandoahPhaseTimings::full_gc_purge_par :
1977                             ShenandoahPhaseTimings::purge_par);
1978     ShenandoahIsAliveSelector is_alive;
1979     uint num_workers = _workers->active_workers();
1980     ShenandoahClassUnloadingTask unlink_task(is_alive.is_alive_closure(), num_workers, purged_class);
1981     _workers->run_task(&unlink_task);
1982   }
1983 
1984   {
1985     ShenandoahGCPhase phase(full_gc ?
1986                             ShenandoahPhaseTimings::full_gc_purge_cldg :
1987                             ShenandoahPhaseTimings::purge_cldg);
1988     ClassLoaderDataGraph::purge();
1989   }
1990   // Resize and verify metaspace
1991   MetaspaceGC::compute_new_size();

1992 }
1993 
1994 // Process leftover weak oops: update them, if needed or assert they do not
1995 // need updating otherwise.
1996 // Weak processor API requires us to visit the oops, even if we are not doing
1997 // anything to them.
1998 void ShenandoahHeap::stw_process_weak_roots(bool full_gc) {
1999   ShenandoahGCPhase root_phase(full_gc ?
2000                                ShenandoahPhaseTimings::full_gc_purge :
2001                                ShenandoahPhaseTimings::purge);
2002   uint num_workers = _workers->active_workers();
2003   ShenandoahPhaseTimings::Phase timing_phase = full_gc ?
2004                                                ShenandoahPhaseTimings::full_gc_purge_par :
2005                                                ShenandoahPhaseTimings::purge_par;
2006   // Cleanup weak roots
2007   ShenandoahGCPhase phase(timing_phase);
2008   if (has_forwarded_objects()) {
2009     ShenandoahForwardedIsAliveClosure is_alive;
2010     ShenandoahUpdateRefsClosure keep_alive;
2011     ShenandoahParallelWeakRootsCleaningTask<ShenandoahForwardedIsAliveClosure, ShenandoahUpdateRefsClosure>


< prev index next >