< prev index next >

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

Print this page


   1 /*
   2  * Copyright (c) 2001, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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 "runtime/handles.hpp"
  33 #include "runtime/perfData.hpp"
  34 #include "runtime/safepoint.hpp"
  35 #include "services/memoryUsage.hpp"
  36 #include "utilities/debug.hpp"
  37 #include "utilities/events.hpp"
  38 #include "utilities/formatBuffer.hpp"
  39 #include "utilities/growableArray.hpp"
  40 
  41 // A "CollectedHeap" is an implementation of a java heap for HotSpot.  This
  42 // is an abstract class: there may be many different kinds of heaps.  This
  43 // class defines the functions that a heap must implement, and contains
  44 // infrastructure common to all heaps.
  45 
  46 class AdaptiveSizePolicy;
  47 class BarrierSet;
  48 class GCHeapSummary;
  49 class GCTimer;


 365   // Total number of GC collections (started)
 366   unsigned int total_collections() const { return _total_collections; }
 367   unsigned int total_full_collections() const { return _total_full_collections;}
 368 
 369   // Increment total number of GC collections (started)
 370   void increment_total_collections(bool full = false) {
 371     _total_collections++;
 372     if (full) {
 373       increment_total_full_collections();
 374     }
 375   }
 376 
 377   void increment_total_full_collections() { _total_full_collections++; }
 378 
 379   // Return the SoftRefPolicy for the heap;
 380   virtual SoftRefPolicy* soft_ref_policy() = 0;
 381 
 382   virtual MemoryUsage memory_usage();
 383   virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
 384   virtual GrowableArray<MemoryPool*> memory_pools() = 0;



 385 
 386   // Iterate over all objects, calling "cl.do_object" on each.
 387   virtual void object_iterate(ObjectClosure* cl) = 0;
 388 
 389   // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
 390   virtual void keep_alive(oop obj) {}
 391 
 392   // Returns the longest time (in ms) that has elapsed since the last
 393   // time that any part of the heap was examined by a garbage collection.
 394   virtual jlong millis_since_last_gc() = 0;
 395 
 396   // Perform any cleanup actions necessary before allowing a verification.
 397   virtual void prepare_for_verify() = 0;
 398 
 399   // Generate any dumps preceding or following a full gc
 400  private:
 401   void full_gc_dump(GCTimer* timer, bool before);
 402 
 403   virtual void initialize_serviceability() = 0;
 404 


   1 /*
   2  * Copyright (c) 2001, 2020, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  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/objectMarker.hpp"
  31 #include "gc/shared/verifyOption.hpp"
  32 #include "memory/allocation.hpp"
  33 #include "runtime/handles.hpp"
  34 #include "runtime/perfData.hpp"
  35 #include "runtime/safepoint.hpp"
  36 #include "services/memoryUsage.hpp"
  37 #include "utilities/debug.hpp"
  38 #include "utilities/events.hpp"
  39 #include "utilities/formatBuffer.hpp"
  40 #include "utilities/growableArray.hpp"
  41 
  42 // A "CollectedHeap" is an implementation of a java heap for HotSpot.  This
  43 // is an abstract class: there may be many different kinds of heaps.  This
  44 // class defines the functions that a heap must implement, and contains
  45 // infrastructure common to all heaps.
  46 
  47 class AdaptiveSizePolicy;
  48 class BarrierSet;
  49 class GCHeapSummary;
  50 class GCTimer;


 366   // Total number of GC collections (started)
 367   unsigned int total_collections() const { return _total_collections; }
 368   unsigned int total_full_collections() const { return _total_full_collections;}
 369 
 370   // Increment total number of GC collections (started)
 371   void increment_total_collections(bool full = false) {
 372     _total_collections++;
 373     if (full) {
 374       increment_total_full_collections();
 375     }
 376   }
 377 
 378   void increment_total_full_collections() { _total_full_collections++; }
 379 
 380   // Return the SoftRefPolicy for the heap;
 381   virtual SoftRefPolicy* soft_ref_policy() = 0;
 382 
 383   virtual MemoryUsage memory_usage();
 384   virtual GrowableArray<GCMemoryManager*> memory_managers() = 0;
 385   virtual GrowableArray<MemoryPool*> memory_pools() = 0;
 386 
 387   // ObjectMarker for JVMTI heap walk
 388   virtual ObjectMarker* object_marker();
 389 
 390   // Iterate over all objects, calling "cl.do_object" on each.
 391   virtual void object_iterate(ObjectClosure* cl) = 0;
 392 
 393   // Keep alive an object that was loaded with AS_NO_KEEPALIVE.
 394   virtual void keep_alive(oop obj) {}
 395 
 396   // Returns the longest time (in ms) that has elapsed since the last
 397   // time that any part of the heap was examined by a garbage collection.
 398   virtual jlong millis_since_last_gc() = 0;
 399 
 400   // Perform any cleanup actions necessary before allowing a verification.
 401   virtual void prepare_for_verify() = 0;
 402 
 403   // Generate any dumps preceding or following a full gc
 404  private:
 405   void full_gc_dump(GCTimer* timer, bool before);
 406 
 407   virtual void initialize_serviceability() = 0;
 408 


< prev index next >