mirror of
https://github.com/openjdk/jdk.git
synced 2026-02-27 02:30:06 +00:00
8076314: Remove the static instance variable SharedHeap:: _sh
Reviewed-by: pliden, jmasa
This commit is contained in:
parent
473bf6175f
commit
bedce0572a
@ -673,10 +673,10 @@ void FreeListSpace_DCTOC::walk_mem_region_with_cl(MemRegion mr,
|
||||
HeapWord* bottom, \
|
||||
HeapWord* top, \
|
||||
ClosureType* cl) { \
|
||||
bool is_par = SharedHeap::heap()->n_par_threads() > 0; \
|
||||
bool is_par = GenCollectedHeap::heap()->n_par_threads() > 0; \
|
||||
if (is_par) { \
|
||||
assert(SharedHeap::heap()->n_par_threads() == \
|
||||
SharedHeap::heap()->workers()->active_workers(), "Mismatch"); \
|
||||
assert(GenCollectedHeap::heap()->n_par_threads() == \
|
||||
GenCollectedHeap::heap()->workers()->active_workers(), "Mismatch"); \
|
||||
walk_mem_region_with_cl_par(mr, bottom, top, cl); \
|
||||
} else { \
|
||||
walk_mem_region_with_cl_nopar(mr, bottom, top, cl); \
|
||||
@ -1907,11 +1907,11 @@ CompactibleFreeListSpace::splitChunkAndReturnRemainder(FreeChunk* chunk,
|
||||
assert(chunk->is_free() && ffc->is_free(), "Error");
|
||||
_bt.split_block((HeapWord*)chunk, chunk->size(), new_size);
|
||||
if (rem_sz < SmallForDictionary) {
|
||||
bool is_par = (SharedHeap::heap()->n_par_threads() > 0);
|
||||
bool is_par = (GenCollectedHeap::heap()->n_par_threads() > 0);
|
||||
if (is_par) _indexedFreeListParLocks[rem_sz]->lock();
|
||||
assert(!is_par ||
|
||||
(SharedHeap::heap()->n_par_threads() ==
|
||||
SharedHeap::heap()->workers()->active_workers()), "Mismatch");
|
||||
(GenCollectedHeap::heap()->n_par_threads() ==
|
||||
GenCollectedHeap::heap()->workers()->active_workers()), "Mismatch");
|
||||
returnChunkToFreeList(ffc);
|
||||
split(size, rem_sz);
|
||||
if (is_par) _indexedFreeListParLocks[rem_sz]->unlock();
|
||||
@ -1982,7 +1982,7 @@ void CompactibleFreeListSpace::save_marks() {
|
||||
|
||||
bool CompactibleFreeListSpace::no_allocs_since_save_marks() {
|
||||
assert(_promoInfo.tracking(), "No preceding save_marks?");
|
||||
assert(SharedHeap::heap()->n_par_threads() == 0,
|
||||
assert(GenCollectedHeap::heap()->n_par_threads() == 0,
|
||||
"Shouldn't be called if using parallel gc.");
|
||||
return _promoInfo.noPromotions();
|
||||
}
|
||||
@ -1991,7 +1991,7 @@ bool CompactibleFreeListSpace::no_allocs_since_save_marks() {
|
||||
\
|
||||
void CompactibleFreeListSpace:: \
|
||||
oop_since_save_marks_iterate##nv_suffix(OopClosureType* blk) { \
|
||||
assert(SharedHeap::heap()->n_par_threads() == 0, \
|
||||
assert(GenCollectedHeap::heap()->n_par_threads() == 0, \
|
||||
"Shouldn't be called (yet) during parallel part of gc."); \
|
||||
_promoInfo.promoted_oops_iterate##nv_suffix(blk); \
|
||||
/* \
|
||||
|
||||
@ -2128,6 +2128,7 @@ void G1CollectedHeap::reset_gc_time_stamps(HeapRegion* hr) {
|
||||
}
|
||||
|
||||
#ifndef PRODUCT
|
||||
|
||||
class CheckGCTimeStampsHRClosure : public HeapRegionClosure {
|
||||
private:
|
||||
unsigned _gc_time_stamp;
|
||||
@ -3336,8 +3337,6 @@ void G1CollectedHeap::print_all_rsets() {
|
||||
#endif // PRODUCT
|
||||
|
||||
G1CollectedHeap* G1CollectedHeap::heap() {
|
||||
assert(_sh->kind() == CollectedHeap::G1CollectedHeap,
|
||||
"not a garbage-first heap");
|
||||
return _g1h;
|
||||
}
|
||||
|
||||
@ -6163,8 +6162,6 @@ void G1CollectedHeap::wait_while_free_regions_coming() {
|
||||
}
|
||||
|
||||
void G1CollectedHeap::set_region_short_lived_locked(HeapRegion* hr) {
|
||||
assert(heap_lock_held_for_gc(),
|
||||
"the heap lock should already be held by or for this thread");
|
||||
_young_list->push_region(hr);
|
||||
}
|
||||
|
||||
|
||||
@ -1460,7 +1460,7 @@ void G1CollectorPolicy::update_survivors_policy() {
|
||||
_max_survivor_regions = (uint) ceil(max_survivor_regions_d);
|
||||
|
||||
_tenuring_threshold = _survivors_age_table.compute_tenuring_threshold(
|
||||
HeapRegion::GrainWords * _max_survivor_regions);
|
||||
HeapRegion::GrainWords * _max_survivor_regions, counters());
|
||||
}
|
||||
|
||||
bool G1CollectorPolicy::force_initial_mark_if_outside_cycle(
|
||||
|
||||
@ -61,9 +61,8 @@ void G1MarkSweep::invoke_at_safepoint(ReferenceProcessor* rp,
|
||||
bool clear_all_softrefs) {
|
||||
assert(SafepointSynchronize::is_at_safepoint(), "must be at a safepoint");
|
||||
|
||||
SharedHeap* sh = SharedHeap::heap();
|
||||
#ifdef ASSERT
|
||||
if (sh->collector_policy()->should_clear_all_soft_refs()) {
|
||||
if (G1CollectedHeap::heap()->collector_policy()->should_clear_all_soft_refs()) {
|
||||
assert(clear_all_softrefs, "Policy should have been checked earler");
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -253,7 +253,8 @@ void G1RootProcessor::process_java_roots(OopClosure* strong_roots,
|
||||
|
||||
{
|
||||
G1GCParPhaseTimesTracker x(phase_times, G1GCPhaseTimes::ThreadRoots, worker_i);
|
||||
Threads::possibly_parallel_oops_do(strong_roots, thread_stack_clds, strong_code);
|
||||
bool is_par = _g1h->n_par_threads() > 0;
|
||||
Threads::possibly_parallel_oops_do(is_par, strong_roots, thread_stack_clds, strong_code);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -225,15 +225,10 @@ void VM_CGC_Operation::release_and_notify_pending_list_lock() {
|
||||
|
||||
void VM_CGC_Operation::doit() {
|
||||
TraceCPUTime tcpu(G1Log::finer(), true, gclog_or_tty);
|
||||
GCTraceTime t(_printGCMessage, G1Log::fine(), true, G1CollectedHeap::heap()->gc_timer_cm(), G1CollectedHeap::heap()->concurrent_mark()->concurrent_gc_id());
|
||||
SharedHeap* sh = SharedHeap::heap();
|
||||
// This could go away if CollectedHeap gave access to _gc_is_active...
|
||||
if (sh != NULL) {
|
||||
IsGCActiveMark x;
|
||||
_cl->do_void();
|
||||
} else {
|
||||
_cl->do_void();
|
||||
}
|
||||
G1CollectedHeap* g1h = G1CollectedHeap::heap();
|
||||
GCTraceTime t(_printGCMessage, G1Log::fine(), true, g1h->gc_timer_cm(), g1h->concurrent_mark()->concurrent_gc_id());
|
||||
IsGCActiveMark x;
|
||||
_cl->do_void();
|
||||
}
|
||||
|
||||
bool VM_CGC_Operation::doit_prologue() {
|
||||
@ -244,14 +239,12 @@ bool VM_CGC_Operation::doit_prologue() {
|
||||
}
|
||||
|
||||
Heap_lock->lock();
|
||||
SharedHeap::heap()->_thread_holds_heap_lock_for_gc = true;
|
||||
return true;
|
||||
}
|
||||
|
||||
void VM_CGC_Operation::doit_epilogue() {
|
||||
// Note the relative order of the unlocks must match that in
|
||||
// VM_GC_Operation::doit_epilogue()
|
||||
SharedHeap::heap()->_thread_holds_heap_lock_for_gc = false;
|
||||
Heap_lock->unlock();
|
||||
if (_needs_pll) {
|
||||
release_and_notify_pending_list_lock();
|
||||
|
||||
@ -79,7 +79,7 @@ void ageTable::merge_par(ageTable* subTable) {
|
||||
}
|
||||
}
|
||||
|
||||
uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
|
||||
uint ageTable::compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters) {
|
||||
size_t desired_survivor_size = (size_t)((((double) survivor_capacity)*TargetSurvivorRatio)/100);
|
||||
uint result;
|
||||
|
||||
@ -126,9 +126,6 @@ uint ageTable::compute_tenuring_threshold(size_t survivor_capacity) {
|
||||
age++;
|
||||
}
|
||||
if (UsePerfData) {
|
||||
SharedHeap* sh = SharedHeap::heap();
|
||||
CollectorPolicy* policy = sh->collector_policy();
|
||||
GCPolicyCounters* gc_counters = policy->counters();
|
||||
gc_counters->tenuring_threshold()->set_value(result);
|
||||
gc_counters->desired_survivor_size()->set_value(
|
||||
desired_survivor_size*oopSize);
|
||||
|
||||
@ -29,6 +29,8 @@
|
||||
#include "oops/oop.hpp"
|
||||
#include "runtime/perfData.hpp"
|
||||
|
||||
class GCPolicyCounters;
|
||||
|
||||
/* Copyright (c) 1992-2009 Oracle and/or its affiliates, and Stanford University.
|
||||
See the LICENSE file for license information. */
|
||||
|
||||
@ -69,7 +71,7 @@ class ageTable VALUE_OBJ_CLASS_SPEC {
|
||||
void merge_par(ageTable* subTable);
|
||||
|
||||
// calculate new tenuring threshold based on age information
|
||||
uint compute_tenuring_threshold(size_t survivor_capacity);
|
||||
uint compute_tenuring_threshold(size_t survivor_capacity, GCPolicyCounters* gc_counters);
|
||||
|
||||
private:
|
||||
PerfVariable* _perf_sizes[table_size];
|
||||
|
||||
@ -116,8 +116,6 @@ bool VM_GC_Operation::doit_prologue() {
|
||||
_prologue_succeeded = false;
|
||||
} else {
|
||||
_prologue_succeeded = true;
|
||||
SharedHeap* sh = SharedHeap::heap();
|
||||
if (sh != NULL) sh->_thread_holds_heap_lock_for_gc = true;
|
||||
}
|
||||
return _prologue_succeeded;
|
||||
}
|
||||
@ -126,8 +124,6 @@ bool VM_GC_Operation::doit_prologue() {
|
||||
void VM_GC_Operation::doit_epilogue() {
|
||||
assert(Thread::current()->is_Java_thread(), "just checking");
|
||||
// Release the Heap_lock first.
|
||||
SharedHeap* sh = SharedHeap::heap();
|
||||
if (sh != NULL) sh->_thread_holds_heap_lock_for_gc = false;
|
||||
Heap_lock->unlock();
|
||||
release_and_notify_pending_list_lock();
|
||||
}
|
||||
|
||||
@ -459,12 +459,12 @@ void CardTableModRefBS::non_clean_card_iterate_possibly_parallel(Space* sp,
|
||||
// equal to active_workers. When a different mechanism for shutting
|
||||
// off parallelism is used, then active_workers can be used in
|
||||
// place of n_par_threads.
|
||||
int n_threads = SharedHeap::heap()->n_par_threads();
|
||||
int n_threads = GenCollectedHeap::heap()->n_par_threads();
|
||||
bool is_par = n_threads > 0;
|
||||
if (is_par) {
|
||||
#if INCLUDE_ALL_GCS
|
||||
assert(SharedHeap::heap()->n_par_threads() ==
|
||||
SharedHeap::heap()->workers()->active_workers(), "Mismatch");
|
||||
assert(GenCollectedHeap::heap()->n_par_threads() ==
|
||||
GenCollectedHeap::heap()->workers()->active_workers(), "Mismatch");
|
||||
non_clean_card_iterate_parallel_work(sp, mr, cl, ct, n_threads);
|
||||
#else // INCLUDE_ALL_GCS
|
||||
fatal("Parallel gc not supported here.");
|
||||
|
||||
@ -167,10 +167,10 @@ ClearNoncleanCardWrapper::ClearNoncleanCardWrapper(
|
||||
// Cannot yet substitute active_workers for n_par_threads
|
||||
// in the case where parallelism is being turned off by
|
||||
// setting n_par_threads to 0.
|
||||
_is_par = (SharedHeap::heap()->n_par_threads() > 0);
|
||||
_is_par = (GenCollectedHeap::heap()->n_par_threads() > 0);
|
||||
assert(!_is_par ||
|
||||
(SharedHeap::heap()->n_par_threads() ==
|
||||
SharedHeap::heap()->workers()->active_workers()), "Mismatch");
|
||||
(GenCollectedHeap::heap()->n_par_threads() ==
|
||||
GenCollectedHeap::heap()->workers()->active_workers()), "Mismatch");
|
||||
}
|
||||
|
||||
bool ClearNoncleanCardWrapper::is_word_aligned(jbyte* entry) {
|
||||
|
||||
@ -550,8 +550,9 @@ HeapWord* DefNewGeneration::expand_and_allocate(size_t size,
|
||||
|
||||
void DefNewGeneration::adjust_desired_tenuring_threshold() {
|
||||
// Set the desired survivor size to half the real survivor space
|
||||
GCPolicyCounters* gc_counters = GenCollectedHeap::heap()->collector_policy()->counters();
|
||||
_tenuring_threshold =
|
||||
age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize);
|
||||
age_table()->compute_tenuring_threshold(to()->capacity()/HeapWordSize, gc_counters);
|
||||
}
|
||||
|
||||
void DefNewGeneration::collect(bool full,
|
||||
|
||||
@ -606,7 +606,8 @@ void GenCollectedHeap::process_roots(bool activate_scope,
|
||||
// Only process code roots from thread stacks if we aren't visiting the entire CodeCache anyway
|
||||
CodeBlobClosure* roots_from_code_p = (so & SO_AllCodeCache) ? NULL : code_roots;
|
||||
|
||||
Threads::possibly_parallel_oops_do(strong_roots, roots_from_clds_p, roots_from_code_p);
|
||||
bool is_par = n_par_threads() > 0;
|
||||
Threads::possibly_parallel_oops_do(is_par, strong_roots, roots_from_clds_p, roots_from_code_p);
|
||||
|
||||
if (!_process_strong_tasks->is_task_claimed(GCH_PS_Universe_oops_do)) {
|
||||
Universe::oops_do(strong_roots);
|
||||
|
||||
@ -35,13 +35,10 @@
|
||||
#include "utilities/copy.hpp"
|
||||
#include "utilities/workgroup.hpp"
|
||||
|
||||
SharedHeap* SharedHeap::_sh;
|
||||
|
||||
SharedHeap::SharedHeap() :
|
||||
CollectedHeap(),
|
||||
_workers(NULL)
|
||||
{
|
||||
_sh = this; // ch is static, should be set only once.
|
||||
if (UseConcMarkSweepGC || UseG1GC) {
|
||||
_workers = new FlexibleWorkGang("GC Thread", ParallelGCThreads,
|
||||
/* are_GC_task_threads */true,
|
||||
@ -54,13 +51,6 @@ SharedHeap::SharedHeap() :
|
||||
}
|
||||
}
|
||||
|
||||
bool SharedHeap::heap_lock_held_for_gc() {
|
||||
Thread* t = Thread::current();
|
||||
return Heap_lock->owned_by_self()
|
||||
|| ( (t->is_GC_task_thread() || t->is_VM_thread())
|
||||
&& _thread_holds_heap_lock_for_gc);
|
||||
}
|
||||
|
||||
void SharedHeap::set_par_threads(uint t) {
|
||||
assert(t == 0 || !UseSerialGC, "Cannot have parallel threads");
|
||||
_n_par_threads = t;
|
||||
|
||||
@ -105,11 +105,6 @@ class SharedHeap : public CollectedHeap {
|
||||
friend class VM_CGC_Operation;
|
||||
|
||||
protected:
|
||||
// There should be only a single instance of "SharedHeap" in a program.
|
||||
// This is enforced with the protected constructor below, which will also
|
||||
// set the static pointer "_sh" to that instance.
|
||||
static SharedHeap* _sh;
|
||||
|
||||
// If we're doing parallel GC, use this gang of threads.
|
||||
FlexibleWorkGang* _workers;
|
||||
|
||||
@ -117,17 +112,7 @@ protected:
|
||||
// function.
|
||||
SharedHeap();
|
||||
|
||||
// Returns true if the calling thread holds the heap lock,
|
||||
// or the calling thread is a par gc thread and the heap_lock is held
|
||||
// by the vm thread doing a gc operation.
|
||||
bool heap_lock_held_for_gc();
|
||||
// True if the heap_lock is held by the a non-gc thread invoking a gc
|
||||
// operation.
|
||||
bool _thread_holds_heap_lock_for_gc;
|
||||
|
||||
public:
|
||||
static SharedHeap* heap() { return _sh; }
|
||||
|
||||
void set_barrier_set(BarrierSet* bs);
|
||||
|
||||
// Does operations required after initialization has been done.
|
||||
|
||||
@ -754,13 +754,9 @@ bool Thread::claim_oops_do_par_case(int strong_roots_parity) {
|
||||
return true;
|
||||
} else {
|
||||
guarantee(res == strong_roots_parity, "Or else what?");
|
||||
assert(SharedHeap::heap()->workers()->active_workers() > 0,
|
||||
"Should only fail when parallel.");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
assert(SharedHeap::heap()->workers()->active_workers() > 0,
|
||||
"Should only fail when parallel.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -4066,20 +4062,7 @@ void Threads::assert_all_threads_claimed() {
|
||||
}
|
||||
#endif // PRODUCT
|
||||
|
||||
void Threads::possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
|
||||
// Introduce a mechanism allowing parallel threads to claim threads as
|
||||
// root groups. Overhead should be small enough to use all the time,
|
||||
// even in sequential code.
|
||||
SharedHeap* sh = SharedHeap::heap();
|
||||
// Cannot yet substitute active_workers for n_par_threads
|
||||
// because of G1CollectedHeap::verify() use of
|
||||
// SharedHeap::process_roots(). n_par_threads == 0 will
|
||||
// turn off parallelism in process_roots while active_workers
|
||||
// is being used for parallelism elsewhere.
|
||||
bool is_par = sh->n_par_threads() > 0;
|
||||
assert(!is_par ||
|
||||
(SharedHeap::heap()->n_par_threads() ==
|
||||
SharedHeap::heap()->workers()->active_workers()), "Mismatch");
|
||||
void Threads::possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf) {
|
||||
int cp = Threads::thread_claim_parity();
|
||||
ALL_JAVA_THREADS(p) {
|
||||
if (p->claim_oops_do(is_par, cp)) {
|
||||
|
||||
@ -1894,7 +1894,7 @@ class Threads: AllStatic {
|
||||
// This version may only be called by sequential code.
|
||||
static void oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
|
||||
// This version may be called by sequential or parallel code.
|
||||
static void possibly_parallel_oops_do(OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
|
||||
static void possibly_parallel_oops_do(bool is_par, OopClosure* f, CLDClosure* cld_f, CodeBlobClosure* cf);
|
||||
// This creates a list of GCTasks, one per thread.
|
||||
static void create_thread_roots_tasks(GCTaskQueue* q);
|
||||
// This creates a list of GCTasks, one per thread, for marking objects.
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user