# HG changeset patch # User stefank # Date 1424436882 -3600 # Node ID b570d043f2957383aaae7b74e8a4952382ff45e8 # Parent c5b52635f690aecb2306d047370dcbcd14cd8099 8073543: Circular include dependency between psScavenge.inline.hpp and psPromotionManager.inline.hpp Reviewed-by: brutisso, mgerdin diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/cardTableExtension.cpp Fri Feb 20 13:54:42 2015 +0100 @@ -26,6 +26,8 @@ #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" #include "gc_implementation/parallelScavenge/gcTaskManager.hpp" #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" +#include "gc_implementation/parallelScavenge/psPromotionManager.hpp" +#include "gc_implementation/parallelScavenge/psScavenge.hpp" #include "gc_implementation/parallelScavenge/psTasks.hpp" #include "gc_implementation/parallelScavenge/psYoungGen.hpp" #include "oops/oop.inline.hpp" diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.cpp Fri Feb 20 13:54:42 2015 +0100 @@ -66,6 +66,15 @@ // for work stealing. } +// Helper functions to get around the circular dependency between +// psScavenge.inline.hpp and psPromotionManager.inline.hpp. +bool PSPromotionManager::should_scavenge(oop* p, bool check_to_space) { + return PSScavenge::should_scavenge(p, check_to_space); +} +bool PSPromotionManager::should_scavenge(narrowOop* p, bool check_to_space) { + return PSScavenge::should_scavenge(p, check_to_space); +} + PSPromotionManager* PSPromotionManager::gc_thread_promotion_manager(int index) { assert(index >= 0 && index < (int)ParallelGCThreads, "index out of range"); assert(_manager_array != NULL, "Sanity"); diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.hpp Fri Feb 20 13:54:42 2015 +0100 @@ -203,6 +203,12 @@ inline void process_popped_location_depth(StarTask p); + static bool should_scavenge(oop* p, bool check_to_space = false); + static bool should_scavenge(narrowOop* p, bool check_to_space = false); + + template + void copy_and_push_safe_barrier(T* p); + template inline void claim_or_forward_depth(T* p); TASKQUEUE_STATS_ONLY(inline void record_steal(StarTask& p);) diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psPromotionManager.inline.hpp Fri Feb 20 13:54:42 2015 +0100 @@ -56,7 +56,7 @@ template inline void PSPromotionManager::claim_or_forward_depth(T* p) { - assert(PSScavenge::should_scavenge(p, true), "revisiting object?"); + assert(should_scavenge(p, true), "revisiting object?"); assert(Universe::heap()->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); assert(Universe::heap()->is_in(p), "pointer outside heap"); @@ -98,7 +98,7 @@ // template oop PSPromotionManager::copy_to_survivor_space(oop o) { - assert(PSScavenge::should_scavenge(&o), "Sanity"); + assert(should_scavenge(&o), "Sanity"); oop new_obj = NULL; @@ -257,7 +257,7 @@ // information. if (TraceScavenge) { gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", - PSScavenge::should_scavenge(&new_obj) ? "copying" : "tenuring", + should_scavenge(&new_obj) ? "copying" : "tenuring", new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); } #endif @@ -265,6 +265,40 @@ return new_obj; } +// Attempt to "claim" oop at p via CAS, push the new obj if successful +// This version tests the oop* to make sure it is within the heap before +// attempting marking. +template +inline void PSPromotionManager::copy_and_push_safe_barrier(T* p) { + assert(should_scavenge(p, true), "revisiting object?"); + + oop o = oopDesc::load_decode_heap_oop_not_null(p); + oop new_obj = o->is_forwarded() + ? o->forwardee() + : copy_to_survivor_space(o); + +#ifndef PRODUCT + // This code must come after the CAS test, or it will print incorrect + // information. + if (TraceScavenge && o->is_forwarded()) { + gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", + "forwarding", + new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); + } +#endif + + oopDesc::encode_store_heap_oop_not_null(p, new_obj); + + // We cannot mark without test, as some code passes us pointers + // that are outside the heap. These pointers are either from roots + // or from metadata. + if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && + Universe::heap()->is_in_reserved(p)) { + if (PSScavenge::is_obj_in_young(new_obj)) { + PSScavenge::card_table()->inline_write_ref_field_gc(p, new_obj); + } + } +} inline void PSPromotionManager::process_popped_location_depth(StarTask p) { if (is_oop_masked(p)) { @@ -274,9 +308,9 @@ } else { if (p.is_narrow()) { assert(UseCompressedOops, "Error"); - PSScavenge::copy_and_push_safe_barrier(this, p); + copy_and_push_safe_barrier(p); } else { - PSScavenge::copy_and_push_safe_barrier(this, p); + copy_and_push_safe_barrier(p); } } } diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.cpp Fri Feb 20 13:54:42 2015 +0100 @@ -105,7 +105,7 @@ // Weak refs may be visited more than once. if (PSScavenge::should_scavenge(p, _to_space)) { - PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); + _promotion_manager->copy_and_push_safe_barrier(p); } } virtual void do_oop(oop* p) { PSKeepAliveClosure::do_oop_work(p); } diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.hpp Fri Feb 20 13:54:42 2015 +0100 @@ -144,9 +144,6 @@ template static inline bool should_scavenge(T* p, MutableSpace* to_space); template static inline bool should_scavenge(T* p, bool check_to_space); - template - inline static void copy_and_push_safe_barrier(PSPromotionManager* pm, T* p); - static void copy_and_push_safe_barrier_from_klass(PSPromotionManager* pm, oop* p); // Is an object in the young generation diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp --- a/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp Fri Feb 20 13:54:42 2015 +0100 @@ -27,7 +27,6 @@ #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" -#include "gc_implementation/parallelScavenge/psPromotionManager.hpp" #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" #include "memory/iterator.hpp" @@ -63,42 +62,6 @@ return should_scavenge(p); } -// Attempt to "claim" oop at p via CAS, push the new obj if successful -// This version tests the oop* to make sure it is within the heap before -// attempting marking. -template -inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm, - T* p) { - assert(should_scavenge(p, true), "revisiting object?"); - - oop o = oopDesc::load_decode_heap_oop_not_null(p); - oop new_obj = o->is_forwarded() - ? o->forwardee() - : pm->copy_to_survivor_space(o); - -#ifndef PRODUCT - // This code must come after the CAS test, or it will print incorrect - // information. - if (TraceScavenge && o->is_forwarded()) { - gclog_or_tty->print_cr("{%s %s " PTR_FORMAT " -> " PTR_FORMAT " (%d)}", - "forwarding", - new_obj->klass()->internal_name(), p2i((void *)o), p2i((void *)new_obj), new_obj->size()); - } -#endif - - oopDesc::encode_store_heap_oop_not_null(p, new_obj); - - // We cannot mark without test, as some code passes us pointers - // that are outside the heap. These pointers are either from roots - // or from metadata. - if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && - Universe::heap()->is_in_reserved(p)) { - if (PSScavenge::is_obj_in_young(new_obj)) { - card_table()->inline_write_ref_field_gc(p, new_obj); - } - } -} - template class PSRootsClosure: public OopClosure { private: @@ -108,7 +71,7 @@ template void do_oop_work(T *p) { if (PSScavenge::should_scavenge(p)) { // We never card mark roots, maybe call a func without test? - PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); + _promotion_manager->copy_and_push_safe_barrier(p); } } public: diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp --- a/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/oops/instanceClassLoaderKlass.cpp Fri Feb 20 13:54:42 2015 +0100 @@ -41,7 +41,6 @@ #if INCLUDE_ALL_GCS #include "gc_implementation/parNew/parOopClosures.inline.hpp" #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp" -#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" #include "oops/oop.pcgc.inline.hpp" #endif // INCLUDE_ALL_GCS diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/oops/oop.pcgc.inline.hpp --- a/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/oops/oop.pcgc.inline.hpp Fri Feb 20 13:54:42 2015 +0100 @@ -33,7 +33,6 @@ #include "gc_implementation/parallelScavenge/psCompactionManager.hpp" #include "gc_implementation/parallelScavenge/psParallelCompact.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" -#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" #endif // INCLUDE_ALL_GCS inline void oopDesc::update_contents(ParCompactionManager* cm) { diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/oops/oop.psgc.inline.hpp --- a/hotspot/src/share/vm/oops/oop.psgc.inline.hpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/oops/oop.psgc.inline.hpp Fri Feb 20 13:54:42 2015 +0100 @@ -29,7 +29,6 @@ #if INCLUDE_ALL_GCS #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" -#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" #endif // INCLUDE_ALL_GCS // ParallelScavengeHeap methods diff -r c5b52635f690 -r b570d043f295 hotspot/src/share/vm/runtime/java.cpp --- a/hotspot/src/share/vm/runtime/java.cpp Fri Feb 20 22:22:39 2015 +0100 +++ b/hotspot/src/share/vm/runtime/java.cpp Fri Feb 20 13:54:42 2015 +0100 @@ -67,7 +67,6 @@ #if INCLUDE_ALL_GCS #include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepThread.hpp" #include "gc_implementation/parallelScavenge/psScavenge.hpp" -#include "gc_implementation/parallelScavenge/psScavenge.inline.hpp" #endif // INCLUDE_ALL_GCS #ifdef COMPILER1 #include "c1/c1_Compiler.hpp"