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