< prev index next >

src/hotspot/share/gc/shared/collectedHeap.hpp

Print this page




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_SHARED_COLLECTEDHEAP_HPP
  26 #define SHARE_GC_SHARED_COLLECTEDHEAP_HPP
  27 
  28 #include "gc/shared/gcCause.hpp"
  29 #include "gc/shared/gcWhen.hpp"
  30 #include "gc/shared/verifyOption.hpp"
  31 #include "memory/allocation.hpp"
  32 #include "memory/universe.hpp"
  33 #include "memory/heapInspection.hpp"

  34 #include "runtime/handles.hpp"
  35 #include "runtime/perfData.hpp"
  36 #include "runtime/safepoint.hpp"
  37 #include "services/memoryUsage.hpp"
  38 #include "utilities/debug.hpp"
  39 #include "utilities/events.hpp"
  40 #include "utilities/formatBuffer.hpp"
  41 #include "utilities/growableArray.hpp"
  42 
  43 // A "CollectedHeap" is an implementation of a java heap for HotSpot.  This
  44 // is an abstract class: there may be many different kinds of heaps.  This
  45 // class defines the functions that a heap must implement, and contains
  46 // infrastructure common to all heaps.
  47 
  48 class AbstractGangTask;
  49 class AdaptiveSizePolicy;
  50 class BarrierSet;
  51 class GCHeapSummary;
  52 class GCTimer;
  53 class GCTracer;


 395       increment_total_full_collections();
 396     }
 397   }
 398 
 399   void increment_total_full_collections() { _total_full_collections++; }
 400 
 401   // Return the SoftRefPolicy for the heap;
 402   virtual SoftRefPolicy* soft_ref_policy() = 0;
 403 
 404   virtual MemoryUsage memory_usage();
 405   virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
 406   virtual GrowableArray<MemoryPool*> memory_pools() = 0;
 407 
 408   // Iterate over all objects, calling "cl.do_object" on each.
 409   virtual void object_iterate(ObjectClosure* cl) = 0;
 410 
 411   virtual ParallelObjectIterator* parallel_object_iterator(uint thread_num) {
 412     return NULL;
 413   }
 414 
 415   // Run given task. Possibly in parallel if the GC supports it.
 416   virtual void run_task(AbstractGangTask* task) = 0;
 417 
 418   // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
 419   virtual void keep_alive(oop obj) {}
 420 
 421   // Returns the longest time (in ms) that has elapsed since the last
 422   // time that any part of the heap was examined by a garbage collection.
 423   virtual jlong millis_since_last_gc() = 0;
 424 
 425   // Perform any cleanup actions necessary before allowing a verification.
 426   virtual void prepare_for_verify() = 0;
 427 
 428   // Generate any dumps preceding or following a full gc
 429  private:
 430   void full_gc_dump(GCTimer* timer, bool before);
 431 
 432   virtual void initialize_serviceability() = 0;
 433 
 434  public:
 435   void pre_full_gc_dump(GCTimer* timer);
 436   void post_full_gc_dump(GCTimer* timer);
 437 


 443   // Print heap information on the given outputStream.
 444   virtual void print_on(outputStream* st) const = 0;
 445   // The default behavior is to call print_on() on tty.
 446   virtual void print() const;
 447 
 448   // Print more detailed heap information on the given
 449   // outputStream. The default behavior is to call print_on(). It is
 450   // up to each subclass to override it and add any additional output
 451   // it needs.
 452   virtual void print_extended_on(outputStream* st) const {
 453     print_on(st);
 454   }
 455 
 456   virtual void print_on_error(outputStream* st) const;
 457 
 458   // Used to print information about locations in the hs_err file.
 459   virtual bool print_location(outputStream* st, void* addr) const = 0;
 460 
 461   // Iterator for all GC threads (other than VM thread)
 462   virtual void gc_threads_do(ThreadClosure* tc) const = 0;



 463 
 464   // Print any relevant tracing info that flags imply.
 465   // Default implementation does nothing.
 466   virtual void print_tracing_info() const = 0;
 467 
 468   void print_heap_before_gc();
 469   void print_heap_after_gc();
 470 
 471   // Registering and unregistering an nmethod (compiled code) with the heap.
 472   virtual void register_nmethod(nmethod* nm) = 0;
 473   virtual void unregister_nmethod(nmethod* nm) = 0;
 474   // Callback for when nmethod is about to be deleted.
 475   virtual void flush_nmethod(nmethod* nm) = 0;
 476   virtual void verify_nmethod(nmethod* nm) = 0;
 477 
 478   void trace_heap_before_gc(const GCTracer* gc_tracer);
 479   void trace_heap_after_gc(const GCTracer* gc_tracer);
 480 
 481   // Heap verification
 482   virtual void verify(VerifyOption option) = 0;




  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *
  23  */
  24 
  25 #ifndef SHARE_GC_SHARED_COLLECTEDHEAP_HPP
  26 #define SHARE_GC_SHARED_COLLECTEDHEAP_HPP
  27 
  28 #include "gc/shared/gcCause.hpp"
  29 #include "gc/shared/gcWhen.hpp"
  30 #include "gc/shared/verifyOption.hpp"
  31 #include "memory/allocation.hpp"

  32 #include "memory/heapInspection.hpp"
  33 #include "memory/universe.hpp"
  34 #include "runtime/handles.hpp"
  35 #include "runtime/perfData.hpp"
  36 #include "runtime/safepoint.hpp"
  37 #include "services/memoryUsage.hpp"
  38 #include "utilities/debug.hpp"
  39 #include "utilities/events.hpp"
  40 #include "utilities/formatBuffer.hpp"
  41 #include "utilities/growableArray.hpp"
  42 
  43 // A "CollectedHeap" is an implementation of a java heap for HotSpot.  This
  44 // is an abstract class: there may be many different kinds of heaps.  This
  45 // class defines the functions that a heap must implement, and contains
  46 // infrastructure common to all heaps.
  47 
  48 class AbstractGangTask;
  49 class AdaptiveSizePolicy;
  50 class BarrierSet;
  51 class GCHeapSummary;
  52 class GCTimer;
  53 class GCTracer;


 395       increment_total_full_collections();
 396     }
 397   }
 398 
 399   void increment_total_full_collections() { _total_full_collections++; }
 400 
 401   // Return the SoftRefPolicy for the heap;
 402   virtual SoftRefPolicy* soft_ref_policy() = 0;
 403 
 404   virtual MemoryUsage memory_usage();
 405   virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
 406   virtual GrowableArray<MemoryPool*> memory_pools() = 0;
 407 
 408   // Iterate over all objects, calling "cl.do_object" on each.
 409   virtual void object_iterate(ObjectClosure* cl) = 0;
 410 
 411   virtual ParallelObjectIterator* parallel_object_iterator(uint thread_num) {
 412     return NULL;
 413   }
 414 



 415   // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
 416   virtual void keep_alive(oop obj) {}
 417 
 418   // Returns the longest time (in ms) that has elapsed since the last
 419   // time that any part of the heap was examined by a garbage collection.
 420   virtual jlong millis_since_last_gc() = 0;
 421 
 422   // Perform any cleanup actions necessary before allowing a verification.
 423   virtual void prepare_for_verify() = 0;
 424 
 425   // Generate any dumps preceding or following a full gc
 426  private:
 427   void full_gc_dump(GCTimer* timer, bool before);
 428 
 429   virtual void initialize_serviceability() = 0;
 430 
 431  public:
 432   void pre_full_gc_dump(GCTimer* timer);
 433   void post_full_gc_dump(GCTimer* timer);
 434 


 440   // Print heap information on the given outputStream.
 441   virtual void print_on(outputStream* st) const = 0;
 442   // The default behavior is to call print_on() on tty.
 443   virtual void print() const;
 444 
 445   // Print more detailed heap information on the given
 446   // outputStream. The default behavior is to call print_on(). It is
 447   // up to each subclass to override it and add any additional output
 448   // it needs.
 449   virtual void print_extended_on(outputStream* st) const {
 450     print_on(st);
 451   }
 452 
 453   virtual void print_on_error(outputStream* st) const;
 454 
 455   // Used to print information about locations in the hs_err file.
 456   virtual bool print_location(outputStream* st, void* addr) const = 0;
 457 
 458   // Iterator for all GC threads (other than VM thread)
 459   virtual void gc_threads_do(ThreadClosure* tc) const = 0;
 460 
 461   // Run given task. Possibly in parallel if the GC supports it.
 462   virtual void run_task(AbstractGangTask* task) = 0;
 463 
 464   // Print any relevant tracing info that flags imply.
 465   // Default implementation does nothing.
 466   virtual void print_tracing_info() const = 0;
 467 
 468   void print_heap_before_gc();
 469   void print_heap_after_gc();
 470 
 471   // Registering and unregistering an nmethod (compiled code) with the heap.
 472   virtual void register_nmethod(nmethod* nm) = 0;
 473   virtual void unregister_nmethod(nmethod* nm) = 0;
 474   // Callback for when nmethod is about to be deleted.
 475   virtual void flush_nmethod(nmethod* nm) = 0;
 476   virtual void verify_nmethod(nmethod* nm) = 0;
 477 
 478   void trace_heap_before_gc(const GCTracer* gc_tracer);
 479   void trace_heap_after_gc(const GCTracer* gc_tracer);
 480 
 481   // Heap verification
 482   virtual void verify(VerifyOption option) = 0;


< prev index next >