RFR (M): JDK-8076314: Remove the static instance variable SharedHeap:: _sh

Bengt Rutisson bengt.rutisson at oracle.com
Tue Mar 31 13:14:39 UTC 2015

Hi all,

Could I have a couple of reviews for this change?


This is another step towards getting rid of SharedHeap. There used to be 
an instance variable in SharedHeap to keep track of the actual instance 
being used (which would be of type GenCollectedHeap or G1CollectedHeap).

The SharedHeap::heap() would return this value and was mostly used in 

I've changed so that we use the specific instance in most cases. That is 
either GenCollectedHeap::heap() or G1CollectedHeap::heap().

A couple of other changes were needed to avoid the use of 

- The field  _thread_holds_heap_lock_for_gc was only used by G1 and was 
thus moved to G1CollectedHeap. It brought with it the method 
heap_lock_held_for_gc() and I introduced set_heap_lock_held_for_gc() to 
set the value. All of these are only used in asserts so I put them in an 
#ifndef PRODUCT section. This also meant that I had to implement 
doit_prologue() and doit_epilogue() for VM_G1OperationWithAllocRequest 
to make sure that the state of _thread_holds_heap_lock_for_gc got set 

- The ageTable::compute_tenuring_threshold() method used the 
SharedHeap::heap() only to look up the perf counters for GC. Instead of 
having compute_tenuring_threshold() look that up I now pass in the 
correct counters from the callers.

- The Threads::possibly_parallel_oops_do() method used the 
SharedHeap::heap() only to check if we were to execute in parallel. I 
moved the lookup of this to the callers and now just pass in an is_par 

- I simplified the VM_CGC_Operation::doit() a bit since even before my 
change the heap returned could never be NULL.


More information about the hotspot-gc-dev mailing list