duke@435: /* xdono@631: * Copyright 2001-2008 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: // A "CollectedHeap" is an implementation of a java heap for HotSpot. This duke@435: // is an abstract class: there may be many different kinds of heaps. This duke@435: // class defines the functions that a heap must implement, and contains duke@435: // infrastructure common to all heaps. duke@435: duke@435: class BarrierSet; duke@435: class ThreadClosure; duke@435: class AdaptiveSizePolicy; duke@435: class Thread; duke@435: duke@435: // duke@435: // CollectedHeap duke@435: // SharedHeap duke@435: // GenCollectedHeap duke@435: // G1CollectedHeap duke@435: // ParallelScavengeHeap duke@435: // duke@435: class CollectedHeap : public CHeapObj { duke@435: friend class VMStructs; duke@435: friend class IsGCActiveMark; // Block structured external access to _is_gc_active jmasa@977: friend class constantPoolCacheKlass; // allocate() method inserts is_conc_safe duke@435: duke@435: #ifdef ASSERT duke@435: static int _fire_out_of_memory_count; duke@435: #endif duke@435: jcoomes@916: // Used for filler objects (static, but initialized in ctor). jcoomes@916: static size_t _filler_array_max_size; jcoomes@916: duke@435: protected: duke@435: MemRegion _reserved; duke@435: BarrierSet* _barrier_set; duke@435: bool _is_gc_active; duke@435: unsigned int _total_collections; // ... started duke@435: unsigned int _total_full_collections; // ... started duke@435: NOT_PRODUCT(volatile size_t _promotion_failure_alot_count;) duke@435: NOT_PRODUCT(volatile size_t _promotion_failure_alot_gc_number;) duke@435: duke@435: // Reason for current garbage collection. Should be set to duke@435: // a value reflecting no collection between collections. duke@435: GCCause::Cause _gc_cause; duke@435: GCCause::Cause _gc_lastcause; duke@435: PerfStringVariable* _perf_gc_cause; duke@435: PerfStringVariable* _perf_gc_lastcause; duke@435: duke@435: // Constructor duke@435: CollectedHeap(); duke@435: duke@435: // Create a new tlab duke@435: virtual HeapWord* allocate_new_tlab(size_t size); duke@435: duke@435: // Fix up tlabs to make the heap well-formed again, duke@435: // optionally retiring the tlabs. duke@435: virtual void fill_all_tlabs(bool retire); duke@435: duke@435: // Accumulate statistics on all tlabs. duke@435: virtual void accumulate_statistics_all_tlabs(); duke@435: duke@435: // Reinitialize tlabs before resuming mutators. duke@435: virtual void resize_all_tlabs(); duke@435: duke@435: protected: duke@435: // Allocate from the current thread's TLAB, with broken-out slow path. duke@435: inline static HeapWord* allocate_from_tlab(Thread* thread, size_t size); duke@435: static HeapWord* allocate_from_tlab_slow(Thread* thread, size_t size); duke@435: duke@435: // Allocate an uninitialized block of the given size, or returns NULL if duke@435: // this is impossible. duke@435: inline static HeapWord* common_mem_allocate_noinit(size_t size, bool is_noref, TRAPS); duke@435: duke@435: // Like allocate_init, but the block returned by a successful allocation duke@435: // is guaranteed initialized to zeros. duke@435: inline static HeapWord* common_mem_allocate_init(size_t size, bool is_noref, TRAPS); duke@435: duke@435: // Same as common_mem version, except memory is allocated in the permanent area duke@435: // If there is no permanent area, revert to common_mem_allocate_noinit duke@435: inline static HeapWord* common_permanent_mem_allocate_noinit(size_t size, TRAPS); duke@435: duke@435: // Same as common_mem version, except memory is allocated in the permanent area duke@435: // If there is no permanent area, revert to common_mem_allocate_init duke@435: inline static HeapWord* common_permanent_mem_allocate_init(size_t size, TRAPS); duke@435: duke@435: // Helper functions for (VM) allocation. duke@435: inline static void post_allocation_setup_common(KlassHandle klass, duke@435: HeapWord* obj, size_t size); duke@435: inline static void post_allocation_setup_no_klass_install(KlassHandle klass, duke@435: HeapWord* objPtr, duke@435: size_t size); duke@435: duke@435: inline static void post_allocation_setup_obj(KlassHandle klass, duke@435: HeapWord* obj, size_t size); duke@435: duke@435: inline static void post_allocation_setup_array(KlassHandle klass, duke@435: HeapWord* obj, size_t size, duke@435: int length); duke@435: duke@435: // Clears an allocated object. duke@435: inline static void init_obj(HeapWord* obj, size_t size); duke@435: jcoomes@916: // Filler object utilities. jcoomes@916: static inline size_t filler_array_hdr_size(); jcoomes@916: static inline size_t filler_array_min_size(); jcoomes@916: static inline size_t filler_array_max_size(); jcoomes@916: jcoomes@916: DEBUG_ONLY(static void fill_args_check(HeapWord* start, size_t words);) jcoomes@916: DEBUG_ONLY(static void zap_filler_array(HeapWord* start, size_t words);) jcoomes@916: jcoomes@916: // Fill with a single array; caller must ensure filler_array_min_size() <= jcoomes@916: // words <= filler_array_max_size(). jcoomes@916: static inline void fill_with_array(HeapWord* start, size_t words); jcoomes@916: jcoomes@916: // Fill with a single object (either an int array or a java.lang.Object). jcoomes@916: static inline void fill_with_object_impl(HeapWord* start, size_t words); jcoomes@916: duke@435: // Verification functions duke@435: virtual void check_for_bad_heap_word_value(HeapWord* addr, size_t size) duke@435: PRODUCT_RETURN; duke@435: virtual void check_for_non_bad_heap_word_value(HeapWord* addr, size_t size) duke@435: PRODUCT_RETURN; jmasa@977: debug_only(static void check_for_valid_allocation_state();) duke@435: duke@435: public: duke@435: enum Name { duke@435: Abstract, duke@435: SharedHeap, duke@435: GenCollectedHeap, duke@435: ParallelScavengeHeap, duke@435: G1CollectedHeap duke@435: }; duke@435: duke@435: virtual CollectedHeap::Name kind() const { return CollectedHeap::Abstract; } duke@435: duke@435: /** duke@435: * Returns JNI error code JNI_ENOMEM if memory could not be allocated, duke@435: * and JNI_OK on success. duke@435: */ duke@435: virtual jint initialize() = 0; duke@435: duke@435: // In many heaps, there will be a need to perform some initialization activities duke@435: // after the Universe is fully formed, but before general heap allocation is allowed. duke@435: // This is the correct place to place such initialization methods. duke@435: virtual void post_initialize() = 0; duke@435: duke@435: MemRegion reserved_region() const { return _reserved; } coleenp@548: address base() const { return (address)reserved_region().start(); } duke@435: duke@435: // Future cleanup here. The following functions should specify bytes or duke@435: // heapwords as part of their signature. duke@435: virtual size_t capacity() const = 0; duke@435: virtual size_t used() const = 0; duke@435: duke@435: // Return "true" if the part of the heap that allocates Java duke@435: // objects has reached the maximal committed limit that it can duke@435: // reach, without a garbage collection. duke@435: virtual bool is_maximal_no_gc() const = 0; duke@435: duke@435: virtual size_t permanent_capacity() const = 0; duke@435: virtual size_t permanent_used() const = 0; duke@435: duke@435: // Support for java.lang.Runtime.maxMemory(): return the maximum amount of duke@435: // memory that the vm could make available for storing 'normal' java objects. duke@435: // This is based on the reserved address space, but should not include space duke@435: // that the vm uses internally for bookkeeping or temporary storage (e.g., duke@435: // perm gen space or, in the case of the young gen, one of the survivor duke@435: // spaces). duke@435: virtual size_t max_capacity() const = 0; duke@435: duke@435: // Returns "TRUE" if "p" points into the reserved area of the heap. duke@435: bool is_in_reserved(const void* p) const { duke@435: return _reserved.contains(p); duke@435: } duke@435: duke@435: bool is_in_reserved_or_null(const void* p) const { duke@435: return p == NULL || is_in_reserved(p); duke@435: } duke@435: duke@435: // Returns "TRUE" if "p" points to the head of an allocated object in the duke@435: // heap. Since this method can be expensive in general, we restrict its duke@435: // use to assertion checking only. duke@435: virtual bool is_in(const void* p) const = 0; duke@435: duke@435: bool is_in_or_null(const void* p) const { duke@435: return p == NULL || is_in(p); duke@435: } duke@435: duke@435: // Let's define some terms: a "closed" subset of a heap is one that duke@435: // duke@435: // 1) contains all currently-allocated objects, and duke@435: // duke@435: // 2) is closed under reference: no object in the closed subset duke@435: // references one outside the closed subset. duke@435: // duke@435: // Membership in a heap's closed subset is useful for assertions. duke@435: // Clearly, the entire heap is a closed subset, so the default duke@435: // implementation is to use "is_in_reserved". But this may not be too duke@435: // liberal to perform useful checking. Also, the "is_in" predicate duke@435: // defines a closed subset, but may be too expensive, since "is_in" duke@435: // verifies that its argument points to an object head. The duke@435: // "closed_subset" method allows a heap to define an intermediate duke@435: // predicate, allowing more precise checking than "is_in_reserved" at duke@435: // lower cost than "is_in." duke@435: duke@435: // One important case is a heap composed of disjoint contiguous spaces, duke@435: // such as the Garbage-First collector. Such heaps have a convenient duke@435: // closed subset consisting of the allocated portions of those duke@435: // contiguous spaces. duke@435: duke@435: // Return "TRUE" iff the given pointer points into the heap's defined duke@435: // closed subset (which defaults to the entire heap). duke@435: virtual bool is_in_closed_subset(const void* p) const { duke@435: return is_in_reserved(p); duke@435: } duke@435: duke@435: bool is_in_closed_subset_or_null(const void* p) const { duke@435: return p == NULL || is_in_closed_subset(p); duke@435: } duke@435: duke@435: // Returns "TRUE" if "p" is allocated as "permanent" data. duke@435: // If the heap does not use "permanent" data, returns the same duke@435: // value is_in_reserved() would return. duke@435: // NOTE: this actually returns true if "p" is in reserved space duke@435: // for the space not that it is actually allocated (i.e. in committed duke@435: // space). If you need the more conservative answer use is_permanent(). duke@435: virtual bool is_in_permanent(const void *p) const = 0; duke@435: duke@435: // Returns "TRUE" if "p" is in the committed area of "permanent" data. duke@435: // If the heap does not use "permanent" data, returns the same duke@435: // value is_in() would return. duke@435: virtual bool is_permanent(const void *p) const = 0; duke@435: duke@435: bool is_in_permanent_or_null(const void *p) const { duke@435: return p == NULL || is_in_permanent(p); duke@435: } duke@435: duke@435: // Returns "TRUE" if "p" is a method oop in the duke@435: // current heap, with high probability. This predicate duke@435: // is not stable, in general. duke@435: bool is_valid_method(oop p) const; duke@435: duke@435: void set_gc_cause(GCCause::Cause v) { duke@435: if (UsePerfData) { duke@435: _gc_lastcause = _gc_cause; duke@435: _perf_gc_lastcause->set_value(GCCause::to_string(_gc_lastcause)); duke@435: _perf_gc_cause->set_value(GCCause::to_string(v)); duke@435: } duke@435: _gc_cause = v; duke@435: } duke@435: GCCause::Cause gc_cause() { return _gc_cause; } duke@435: duke@435: // Preload classes into the shared portion of the heap, and then dump duke@435: // that data to a file so that it can be loaded directly by another duke@435: // VM (then terminate). duke@435: virtual void preload_and_dump(TRAPS) { ShouldNotReachHere(); } duke@435: duke@435: // General obj/array allocation facilities. duke@435: inline static oop obj_allocate(KlassHandle klass, int size, TRAPS); duke@435: inline static oop array_allocate(KlassHandle klass, int size, int length, TRAPS); duke@435: inline static oop large_typearray_allocate(KlassHandle klass, int size, int length, TRAPS); duke@435: duke@435: // Special obj/array allocation facilities. duke@435: // Some heaps may want to manage "permanent" data uniquely. These default duke@435: // to the general routines if the heap does not support such handling. duke@435: inline static oop permanent_obj_allocate(KlassHandle klass, int size, TRAPS); duke@435: // permanent_obj_allocate_no_klass_install() does not do the installation of duke@435: // the klass pointer in the newly created object (as permanent_obj_allocate() duke@435: // above does). This allows for a delay in the installation of the klass duke@435: // pointer that is needed during the create of klassKlass's. The duke@435: // method post_allocation_install_obj_klass() is used to install the duke@435: // klass pointer. duke@435: inline static oop permanent_obj_allocate_no_klass_install(KlassHandle klass, duke@435: int size, duke@435: TRAPS); duke@435: inline static void post_allocation_install_obj_klass(KlassHandle klass, duke@435: oop obj, duke@435: int size); duke@435: inline static oop permanent_array_allocate(KlassHandle klass, int size, int length, TRAPS); duke@435: duke@435: // Raw memory allocation facilities duke@435: // The obj and array allocate methods are covers for these methods. duke@435: // The permanent allocation method should default to mem_allocate if duke@435: // permanent memory isn't supported. duke@435: virtual HeapWord* mem_allocate(size_t size, duke@435: bool is_noref, duke@435: bool is_tlab, duke@435: bool* gc_overhead_limit_was_exceeded) = 0; duke@435: virtual HeapWord* permanent_mem_allocate(size_t size) = 0; duke@435: duke@435: // The boundary between a "large" and "small" array of primitives, in words. duke@435: virtual size_t large_typearray_limit() = 0; duke@435: jcoomes@916: // Utilities for turning raw memory into filler objects. jcoomes@916: // jcoomes@916: // min_fill_size() is the smallest region that can be filled. jcoomes@916: // fill_with_objects() can fill arbitrary-sized regions of the heap using jcoomes@916: // multiple objects. fill_with_object() is for regions known to be smaller jcoomes@916: // than the largest array of integers; it uses a single object to fill the jcoomes@916: // region and has slightly less overhead. jcoomes@916: static size_t min_fill_size() { jcoomes@916: return size_t(align_object_size(oopDesc::header_size())); jcoomes@916: } jcoomes@916: jcoomes@916: static void fill_with_objects(HeapWord* start, size_t words); jcoomes@916: jcoomes@916: static void fill_with_object(HeapWord* start, size_t words); jcoomes@916: static void fill_with_object(MemRegion region) { jcoomes@916: fill_with_object(region.start(), region.word_size()); jcoomes@916: } jcoomes@916: static void fill_with_object(HeapWord* start, HeapWord* end) { jcoomes@916: fill_with_object(start, pointer_delta(end, start)); jcoomes@916: } jcoomes@916: duke@435: // Some heaps may offer a contiguous region for shared non-blocking duke@435: // allocation, via inlined code (by exporting the address of the top and duke@435: // end fields defining the extent of the contiguous allocation region.) duke@435: duke@435: // This function returns "true" iff the heap supports this kind of duke@435: // allocation. (Default is "no".) duke@435: virtual bool supports_inline_contig_alloc() const { duke@435: return false; duke@435: } duke@435: // These functions return the addresses of the fields that define the duke@435: // boundaries of the contiguous allocation area. (These fields should be duke@435: // physically near to one another.) duke@435: virtual HeapWord** top_addr() const { duke@435: guarantee(false, "inline contiguous allocation not supported"); duke@435: return NULL; duke@435: } duke@435: virtual HeapWord** end_addr() const { duke@435: guarantee(false, "inline contiguous allocation not supported"); duke@435: return NULL; duke@435: } duke@435: duke@435: // Some heaps may be in an unparseable state at certain times between duke@435: // collections. This may be necessary for efficient implementation of duke@435: // certain allocation-related activities. Calling this function before duke@435: // attempting to parse a heap ensures that the heap is in a parsable duke@435: // state (provided other concurrent activity does not introduce duke@435: // unparsability). It is normally expected, therefore, that this duke@435: // method is invoked with the world stopped. duke@435: // NOTE: if you override this method, make sure you call duke@435: // super::ensure_parsability so that the non-generational duke@435: // part of the work gets done. See implementation of duke@435: // CollectedHeap::ensure_parsability and, for instance, duke@435: // that of GenCollectedHeap::ensure_parsability(). duke@435: // The argument "retire_tlabs" controls whether existing TLABs duke@435: // are merely filled or also retired, thus preventing further duke@435: // allocation from them and necessitating allocation of new TLABs. duke@435: virtual void ensure_parsability(bool retire_tlabs); duke@435: duke@435: // Return an estimate of the maximum allocation that could be performed duke@435: // without triggering any collection or expansion activity. In a duke@435: // generational collector, for example, this is probably the largest duke@435: // allocation that could be supported (without expansion) in the youngest duke@435: // generation. It is "unsafe" because no locks are taken; the result duke@435: // should be treated as an approximation, not a guarantee, for use in duke@435: // heuristic resizing decisions. duke@435: virtual size_t unsafe_max_alloc() = 0; duke@435: duke@435: // Section on thread-local allocation buffers (TLABs) duke@435: // If the heap supports thread-local allocation buffers, it should override duke@435: // the following methods: duke@435: // Returns "true" iff the heap supports thread-local allocation buffers. duke@435: // The default is "no". duke@435: virtual bool supports_tlab_allocation() const { duke@435: return false; duke@435: } duke@435: // The amount of space available for thread-local allocation buffers. duke@435: virtual size_t tlab_capacity(Thread *thr) const { duke@435: guarantee(false, "thread-local allocation buffers not supported"); duke@435: return 0; duke@435: } duke@435: // An estimate of the maximum allocation that could be performed duke@435: // for thread-local allocation buffers without triggering any duke@435: // collection or expansion activity. duke@435: virtual size_t unsafe_max_tlab_alloc(Thread *thr) const { duke@435: guarantee(false, "thread-local allocation buffers not supported"); duke@435: return 0; duke@435: } duke@435: // Can a compiler initialize a new object without store barriers? duke@435: // This permission only extends from the creation of a new object duke@435: // via a TLAB up to the first subsequent safepoint. ysr@777: virtual bool can_elide_tlab_store_barriers() const = 0; ysr@777: duke@435: // If a compiler is eliding store barriers for TLAB-allocated objects, duke@435: // there is probably a corresponding slow path which can produce duke@435: // an object allocated anywhere. The compiler's runtime support duke@435: // promises to call this function on such a slow-path-allocated duke@435: // object before performing initializations that have elided duke@435: // store barriers. Returns new_obj, or maybe a safer copy thereof. duke@435: virtual oop new_store_barrier(oop new_obj); duke@435: duke@435: // Can a compiler elide a store barrier when it writes duke@435: // a permanent oop into the heap? Applies when the compiler duke@435: // is storing x to the heap, where x->is_perm() is true. ysr@777: virtual bool can_elide_permanent_oop_store_barriers() const = 0; duke@435: duke@435: // Does this heap support heap inspection (+PrintClassHistogram?) ysr@777: virtual bool supports_heap_inspection() const = 0; duke@435: duke@435: // Perform a collection of the heap; intended for use in implementing duke@435: // "System.gc". This probably implies as full a collection as the duke@435: // "CollectedHeap" supports. duke@435: virtual void collect(GCCause::Cause cause) = 0; duke@435: duke@435: // This interface assumes that it's being called by the duke@435: // vm thread. It collects the heap assuming that the duke@435: // heap lock is already held and that we are executing in duke@435: // the context of the vm thread. duke@435: virtual void collect_as_vm_thread(GCCause::Cause cause) = 0; duke@435: duke@435: // Returns the barrier set for this heap duke@435: BarrierSet* barrier_set() { return _barrier_set; } duke@435: duke@435: // Returns "true" iff there is a stop-world GC in progress. (I assume duke@435: // that it should answer "false" for the concurrent part of a concurrent duke@435: // collector -- dld). duke@435: bool is_gc_active() const { return _is_gc_active; } duke@435: duke@435: // Total number of GC collections (started) duke@435: unsigned int total_collections() const { return _total_collections; } duke@435: unsigned int total_full_collections() const { return _total_full_collections;} duke@435: duke@435: // Increment total number of GC collections (started) duke@435: // Should be protected but used by PSMarkSweep - cleanup for 1.4.2 duke@435: void increment_total_collections(bool full = false) { duke@435: _total_collections++; duke@435: if (full) { duke@435: increment_total_full_collections(); duke@435: } duke@435: } duke@435: duke@435: void increment_total_full_collections() { _total_full_collections++; } duke@435: duke@435: // Return the AdaptiveSizePolicy for the heap. duke@435: virtual AdaptiveSizePolicy* size_policy() = 0; duke@435: duke@435: // Iterate over all the ref-containing fields of all objects, calling duke@435: // "cl.do_oop" on each. This includes objects in permanent memory. duke@435: virtual void oop_iterate(OopClosure* cl) = 0; duke@435: duke@435: // Iterate over all objects, calling "cl.do_object" on each. duke@435: // This includes objects in permanent memory. duke@435: virtual void object_iterate(ObjectClosure* cl) = 0; duke@435: jmasa@952: // Similar to object_iterate() except iterates only jmasa@952: // over live objects. jmasa@952: virtual void safe_object_iterate(ObjectClosure* cl) = 0; jmasa@952: duke@435: // Behaves the same as oop_iterate, except only traverses duke@435: // interior pointers contained in permanent memory. If there duke@435: // is no permanent memory, does nothing. duke@435: virtual void permanent_oop_iterate(OopClosure* cl) = 0; duke@435: duke@435: // Behaves the same as object_iterate, except only traverses duke@435: // object contained in permanent memory. If there is no duke@435: // permanent memory, does nothing. duke@435: virtual void permanent_object_iterate(ObjectClosure* cl) = 0; duke@435: duke@435: // NOTE! There is no requirement that a collector implement these duke@435: // functions. duke@435: // duke@435: // A CollectedHeap is divided into a dense sequence of "blocks"; that is, duke@435: // each address in the (reserved) heap is a member of exactly duke@435: // one block. The defining characteristic of a block is that it is duke@435: // possible to find its size, and thus to progress forward to the next duke@435: // block. (Blocks may be of different sizes.) Thus, blocks may duke@435: // represent Java objects, or they might be free blocks in a duke@435: // free-list-based heap (or subheap), as long as the two kinds are duke@435: // distinguishable and the size of each is determinable. duke@435: duke@435: // Returns the address of the start of the "block" that contains the duke@435: // address "addr". We say "blocks" instead of "object" since some heaps duke@435: // may not pack objects densely; a chunk may either be an object or a duke@435: // non-object. duke@435: virtual HeapWord* block_start(const void* addr) const = 0; duke@435: duke@435: // Requires "addr" to be the start of a chunk, and returns its size. duke@435: // "addr + size" is required to be the start of a new chunk, or the end duke@435: // of the active area of the heap. duke@435: virtual size_t block_size(const HeapWord* addr) const = 0; duke@435: duke@435: // Requires "addr" to be the start of a block, and returns "TRUE" iff duke@435: // the block is an object. duke@435: virtual bool block_is_obj(const HeapWord* addr) const = 0; duke@435: duke@435: // Returns the longest time (in ms) that has elapsed since the last duke@435: // time that any part of the heap was examined by a garbage collection. duke@435: virtual jlong millis_since_last_gc() = 0; duke@435: duke@435: // Perform any cleanup actions necessary before allowing a verification. duke@435: virtual void prepare_for_verify() = 0; duke@435: duke@435: virtual void print() const = 0; duke@435: virtual void print_on(outputStream* st) const = 0; duke@435: duke@435: // Print all GC threads (other than the VM thread) duke@435: // used by this heap. duke@435: virtual void print_gc_threads_on(outputStream* st) const = 0; duke@435: void print_gc_threads() { print_gc_threads_on(tty); } duke@435: // Iterator for all GC threads (other than VM thread) duke@435: virtual void gc_threads_do(ThreadClosure* tc) const = 0; duke@435: duke@435: // Print any relevant tracing info that flags imply. duke@435: // Default implementation does nothing. duke@435: virtual void print_tracing_info() const = 0; duke@435: duke@435: // Heap verification duke@435: virtual void verify(bool allow_dirty, bool silent) = 0; duke@435: duke@435: // Non product verification and debugging. duke@435: #ifndef PRODUCT duke@435: // Support for PromotionFailureALot. Return true if it's time to cause a duke@435: // promotion failure. The no-argument version uses duke@435: // this->_promotion_failure_alot_count as the counter. duke@435: inline bool promotion_should_fail(volatile size_t* count); duke@435: inline bool promotion_should_fail(); duke@435: duke@435: // Reset the PromotionFailureALot counters. Should be called at the end of a duke@435: // GC in which promotion failure ocurred. duke@435: inline void reset_promotion_should_fail(volatile size_t* count); duke@435: inline void reset_promotion_should_fail(); duke@435: #endif // #ifndef PRODUCT duke@435: duke@435: #ifdef ASSERT duke@435: static int fired_fake_oom() { duke@435: return (CIFireOOMAt > 1 && _fire_out_of_memory_count >= CIFireOOMAt); duke@435: } duke@435: #endif duke@435: }; duke@435: duke@435: // Class to set and reset the GC cause for a CollectedHeap. duke@435: duke@435: class GCCauseSetter : StackObj { duke@435: CollectedHeap* _heap; duke@435: GCCause::Cause _previous_cause; duke@435: public: duke@435: GCCauseSetter(CollectedHeap* heap, GCCause::Cause cause) { duke@435: assert(SafepointSynchronize::is_at_safepoint(), duke@435: "This method manipulates heap state without locking"); duke@435: _heap = heap; duke@435: _previous_cause = _heap->gc_cause(); duke@435: _heap->set_gc_cause(cause); duke@435: } duke@435: duke@435: ~GCCauseSetter() { duke@435: assert(SafepointSynchronize::is_at_safepoint(), duke@435: "This method manipulates heap state without locking"); duke@435: _heap->set_gc_cause(_previous_cause); duke@435: } duke@435: };