2007-12-01 00:00:00 +00:00
|
|
|
/*
|
2018-01-10 22:48:27 +01:00
|
|
|
* Copyright (c) 2001, 2018, Oracle and/or its affiliates. All rights reserved.
|
2007-12-01 00:00:00 +00:00
|
|
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
|
|
|
*
|
|
|
|
* This code is free software; you can redistribute it and/or modify it
|
|
|
|
* under the terms of the GNU General Public License version 2 only, as
|
|
|
|
* published by the Free Software Foundation.
|
|
|
|
*
|
|
|
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
|
|
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
|
|
|
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
|
|
|
* version 2 for more details (a copy is included in the LICENSE file that
|
|
|
|
* accompanied this code).
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License version
|
|
|
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
|
|
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
|
*
|
2010-05-27 19:08:38 -07:00
|
|
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
|
|
|
* or visit www.oracle.com if you need additional information or have any
|
|
|
|
* questions.
|
2007-12-01 00:00:00 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#ifndef SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
|
|
|
|
#define SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
|
|
|
|
|
|
|
|
#include "gc/parallel/generationSizer.hpp"
|
|
|
|
#include "gc/parallel/objectStartArray.hpp"
|
|
|
|
#include "gc/parallel/psGCAdaptivePolicyCounters.hpp"
|
|
|
|
#include "gc/parallel/psOldGen.hpp"
|
|
|
|
#include "gc/parallel/psYoungGen.hpp"
|
2018-02-26 09:34:12 +01:00
|
|
|
#include "gc/shared/cardTableModRefBS.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/collectedHeap.hpp"
|
|
|
|
#include "gc/shared/collectorPolicy.hpp"
|
|
|
|
#include "gc/shared/gcPolicyCounters.hpp"
|
|
|
|
#include "gc/shared/gcWhen.hpp"
|
2018-02-22 18:36:07 +01:00
|
|
|
#include "gc/shared/softRefPolicy.hpp"
|
2015-05-13 15:16:06 +02:00
|
|
|
#include "gc/shared/strongRootsScope.hpp"
|
2015-12-10 14:57:55 +01:00
|
|
|
#include "memory/metaspace.hpp"
|
2017-11-30 13:40:07 +01:00
|
|
|
#include "utilities/growableArray.hpp"
|
2010-11-23 13:22:55 -08:00
|
|
|
#include "utilities/ostream.hpp"
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
class AdjoiningGenerations;
|
2013-06-10 11:30:51 +02:00
|
|
|
class GCHeapSummary;
|
2007-12-01 00:00:00 +00:00
|
|
|
class GCTaskManager;
|
2017-11-30 13:40:07 +01:00
|
|
|
class MemoryManager;
|
|
|
|
class MemoryPool;
|
2013-06-10 11:30:51 +02:00
|
|
|
class PSAdaptiveSizePolicy;
|
2018-02-26 09:34:12 +01:00
|
|
|
class PSCardTable;
|
2013-06-10 11:30:51 +02:00
|
|
|
class PSHeapSummary;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
class ParallelScavengeHeap : public CollectedHeap {
|
|
|
|
friend class VMStructs;
|
|
|
|
private:
|
|
|
|
static PSYoungGen* _young_gen;
|
|
|
|
static PSOldGen* _old_gen;
|
|
|
|
|
|
|
|
// Sizing policy for entire heap
|
2013-10-21 18:56:20 +02:00
|
|
|
static PSAdaptiveSizePolicy* _size_policy;
|
|
|
|
static PSGCAdaptivePolicyCounters* _gc_policy_counters;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2010-04-13 13:52:10 -07:00
|
|
|
GenerationSizer* _collector_policy;
|
|
|
|
|
2018-02-22 18:36:07 +01:00
|
|
|
SoftRefPolicy _soft_ref_policy;
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// Collection of generations that are adjacent in the
|
|
|
|
// space reserved for the heap.
|
|
|
|
AdjoiningGenerations* _gens;
|
2012-02-16 13:13:53 -08:00
|
|
|
unsigned int _death_march_count;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2013-10-21 18:56:20 +02:00
|
|
|
// The task manager
|
|
|
|
static GCTaskManager* _gc_task_manager;
|
2007-12-01 00:00:00 +00:00
|
|
|
|
2017-11-30 13:40:07 +01:00
|
|
|
GCMemoryManager* _young_manager;
|
|
|
|
GCMemoryManager* _old_manager;
|
|
|
|
|
|
|
|
MemoryPool* _eden_pool;
|
|
|
|
MemoryPool* _survivor_pool;
|
|
|
|
MemoryPool* _old_pool;
|
|
|
|
|
|
|
|
virtual void initialize_serviceability();
|
|
|
|
|
2015-02-11 14:47:21 +01:00
|
|
|
void trace_heap(GCWhen::Type when, const GCTracer* tracer);
|
2013-06-10 11:30:51 +02:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
protected:
|
|
|
|
static inline size_t total_invocations();
|
|
|
|
HeapWord* allocate_new_tlab(size_t size);
|
|
|
|
|
2012-02-16 13:13:53 -08:00
|
|
|
inline bool should_alloc_in_eden(size_t size) const;
|
|
|
|
inline void death_march_check(HeapWord* const result, size_t size);
|
|
|
|
HeapWord* mem_allocate_old_gen(size_t size);
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
public:
|
2015-04-16 15:31:20 +02:00
|
|
|
ParallelScavengeHeap(GenerationSizer* policy) :
|
|
|
|
CollectedHeap(), _collector_policy(policy), _death_march_count(0) { }
|
2013-09-11 16:25:02 +02:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
// For use by VM operations
|
|
|
|
enum CollectionType {
|
|
|
|
Scavenge,
|
|
|
|
MarkSweep
|
|
|
|
};
|
|
|
|
|
2015-04-01 10:49:08 +02:00
|
|
|
virtual Name kind() const {
|
2007-12-01 00:00:00 +00:00
|
|
|
return CollectedHeap::ParallelScavengeHeap;
|
|
|
|
}
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
virtual const char* name() const {
|
|
|
|
return "Parallel";
|
|
|
|
}
|
|
|
|
|
2015-09-08 16:00:34 -04:00
|
|
|
virtual CollectorPolicy* collector_policy() const { return _collector_policy; }
|
2010-04-13 13:52:10 -07:00
|
|
|
|
2018-02-22 18:36:07 +01:00
|
|
|
virtual SoftRefPolicy* soft_ref_policy() { return &_soft_ref_policy; }
|
|
|
|
|
2017-11-30 13:40:07 +01:00
|
|
|
virtual GrowableArray<GCMemoryManager*> memory_managers();
|
|
|
|
virtual GrowableArray<MemoryPool*> memory_pools();
|
|
|
|
|
2013-10-21 18:56:20 +02:00
|
|
|
static PSYoungGen* young_gen() { return _young_gen; }
|
|
|
|
static PSOldGen* old_gen() { return _old_gen; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
virtual PSAdaptiveSizePolicy* size_policy() { return _size_policy; }
|
|
|
|
|
|
|
|
static PSGCAdaptivePolicyCounters* gc_policy_counters() { return _gc_policy_counters; }
|
|
|
|
|
|
|
|
static ParallelScavengeHeap* heap();
|
|
|
|
|
|
|
|
static GCTaskManager* const gc_task_manager() { return _gc_task_manager; }
|
|
|
|
|
2018-02-26 09:34:12 +01:00
|
|
|
CardTableModRefBS* barrier_set();
|
|
|
|
PSCardTable* card_table();
|
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
AdjoiningGenerations* gens() { return _gens; }
|
|
|
|
|
|
|
|
// Returns JNI_OK on success
|
|
|
|
virtual jint initialize();
|
|
|
|
|
|
|
|
void post_initialize();
|
|
|
|
void update_counters();
|
|
|
|
|
2013-11-01 17:09:38 +01:00
|
|
|
// The alignment used for the various areas
|
|
|
|
size_t space_alignment() { return _collector_policy->space_alignment(); }
|
|
|
|
size_t generation_alignment() { return _collector_policy->gen_alignment(); }
|
|
|
|
|
|
|
|
// Return the (conservative) maximum heap alignment
|
|
|
|
static size_t conservative_max_heap_alignment() {
|
|
|
|
return CollectorPolicy::compute_heap_alignment();
|
|
|
|
}
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
size_t capacity() const;
|
|
|
|
size_t used() const;
|
|
|
|
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
// Return "true" if all generations have reached the
|
2007-12-01 00:00:00 +00:00
|
|
|
// maximal committed limit that they can reach, without a garbage
|
|
|
|
// collection.
|
|
|
|
virtual bool is_maximal_no_gc() const;
|
|
|
|
|
2011-05-03 10:30:34 -07:00
|
|
|
// Return true if the reference points to an object that
|
|
|
|
// can be moved in a partial collection. For currently implemented
|
|
|
|
// generational collectors that means during a collection of
|
|
|
|
// the young gen.
|
2017-10-13 15:08:56 +02:00
|
|
|
virtual bool is_scavengable(oop obj);
|
|
|
|
virtual void register_nmethod(nmethod* nm);
|
|
|
|
virtual void verify_nmethod(nmethod* nmethod);
|
2011-05-03 10:30:34 -07:00
|
|
|
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t max_capacity() const;
|
|
|
|
|
|
|
|
// Whether p is in the allocated part of the heap
|
|
|
|
bool is_in(const void* p) const;
|
|
|
|
|
|
|
|
bool is_in_reserved(const void* p) const;
|
|
|
|
|
2013-10-21 18:56:20 +02:00
|
|
|
bool is_in_young(oop p); // reserved part
|
|
|
|
bool is_in_old(oop p); // reserved part
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Memory allocation. "gc_time_limit_was_exceeded" will
|
|
|
|
// be set to true if the adaptive size policy determine that
|
|
|
|
// an excessive amount of time is being spent doing collections
|
|
|
|
// and caused a NULL to be returned. If a NULL is not returned,
|
|
|
|
// "gc_time_limit_was_exceeded" has an undefined meaning.
|
2013-10-21 18:56:20 +02:00
|
|
|
HeapWord* mem_allocate(size_t size, bool* gc_overhead_limit_was_exceeded);
|
2011-06-16 15:51:57 -04:00
|
|
|
|
|
|
|
// Allocation attempt(s) during a safepoint. It should never be called
|
|
|
|
// to allocate a new TLAB as this allocation might be satisfied out
|
|
|
|
// of the old generation.
|
|
|
|
HeapWord* failed_mem_allocate(size_t size);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Support for System.gc()
|
|
|
|
void collect(GCCause::Cause cause);
|
|
|
|
|
|
|
|
// These also should be called by the vm thread at a safepoint (e.g., from a
|
|
|
|
// VM operation).
|
|
|
|
//
|
|
|
|
// The first collects the young generation only, unless the scavenge fails; it
|
|
|
|
// will then attempt a full gc. The second collects the entire heap; if
|
|
|
|
// maximum_compaction is true, it will compact everything and clear all soft
|
|
|
|
// references.
|
|
|
|
inline void invoke_scavenge();
|
6964458: Reimplement class meta-data storage to use native memory
Remove PermGen, allocate meta-data in metaspace linked to class loaders, rewrite GC walking, rewrite and rename metadata to be C++ classes
Co-authored-by: Stefan Karlsson <stefan.karlsson@oracle.com>
Co-authored-by: Mikael Gerdin <mikael.gerdin@oracle.com>
Co-authored-by: Tom Rodriguez <tom.rodriguez@oracle.com>
Reviewed-by: jmasa, stefank, never, coleenp, kvn, brutisso, mgerdin, dholmes, jrose, twisti, roland
2012-09-01 13:25:18 -04:00
|
|
|
|
|
|
|
// Perform a full collection
|
|
|
|
virtual void do_full_collection(bool clear_all_soft_refs);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
bool supports_inline_contig_alloc() const { return !UseNUMA; }
|
2008-04-29 13:51:26 +04:00
|
|
|
|
2016-09-20 15:42:17 -04:00
|
|
|
HeapWord* volatile* top_addr() const { return !UseNUMA ? young_gen()->top_addr() : (HeapWord* volatile*)-1; }
|
2008-04-29 13:51:26 +04:00
|
|
|
HeapWord** end_addr() const { return !UseNUMA ? young_gen()->end_addr() : (HeapWord**)-1; }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
void ensure_parsability(bool retire_tlabs);
|
|
|
|
void accumulate_statistics_all_tlabs();
|
|
|
|
void resize_all_tlabs();
|
|
|
|
|
|
|
|
bool supports_tlab_allocation() const { return true; }
|
|
|
|
|
|
|
|
size_t tlab_capacity(Thread* thr) const;
|
2014-01-27 13:14:53 +01:00
|
|
|
size_t tlab_used(Thread* thr) const;
|
2007-12-01 00:00:00 +00:00
|
|
|
size_t unsafe_max_tlab_alloc(Thread* thr) const;
|
|
|
|
|
|
|
|
void object_iterate(ObjectClosure* cl);
|
2009-01-06 07:05:05 -08:00
|
|
|
void safe_object_iterate(ObjectClosure* cl) { object_iterate(cl); }
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
HeapWord* block_start(const void* addr) const;
|
|
|
|
size_t block_size(const HeapWord* addr) const;
|
|
|
|
bool block_is_obj(const HeapWord* addr) const;
|
|
|
|
|
|
|
|
jlong millis_since_last_gc();
|
|
|
|
|
|
|
|
void prepare_for_verify();
|
2013-06-10 11:30:51 +02:00
|
|
|
PSHeapSummary create_ps_heap_summary();
|
2011-11-08 00:41:28 -05:00
|
|
|
virtual void print_on(outputStream* st) const;
|
2013-04-10 14:26:49 +02:00
|
|
|
virtual void print_on_error(outputStream* st) const;
|
2007-12-01 00:00:00 +00:00
|
|
|
virtual void print_gc_threads_on(outputStream* st) const;
|
|
|
|
virtual void gc_threads_do(ThreadClosure* tc) const;
|
|
|
|
virtual void print_tracing_info() const;
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
void verify(VerifyOption option /* ignored */);
|
2007-12-01 00:00:00 +00:00
|
|
|
|
|
|
|
// Resize the young generation. The reserved space for the
|
|
|
|
// generation may be expanded in preparation for the resize.
|
|
|
|
void resize_young_gen(size_t eden_size, size_t survivor_size);
|
|
|
|
|
|
|
|
// Resize the old generation. The reserved space for the
|
|
|
|
// generation may be expanded in preparation for the resize.
|
|
|
|
void resize_old_gen(size_t desired_free_space);
|
2008-07-09 15:08:55 -07:00
|
|
|
|
|
|
|
// Save the tops of the spaces in all generations
|
|
|
|
void record_gen_tops_before_GC() PRODUCT_RETURN;
|
|
|
|
|
|
|
|
// Mangle the unused parts of all spaces in the heap
|
|
|
|
void gen_mangle_unused_area() PRODUCT_RETURN;
|
2009-09-15 21:53:47 -07:00
|
|
|
|
|
|
|
// Call these in sequential code around the processing of strong roots.
|
2015-04-02 16:07:27 +02:00
|
|
|
class ParStrongRootsScope : public MarkScope {
|
2013-10-21 18:56:20 +02:00
|
|
|
public:
|
2009-09-15 21:53:47 -07:00
|
|
|
ParStrongRootsScope();
|
|
|
|
~ParStrongRootsScope();
|
|
|
|
};
|
2017-11-30 13:40:07 +01:00
|
|
|
|
|
|
|
GCMemoryManager* old_gc_manager() const { return _old_manager; }
|
|
|
|
GCMemoryManager* young_gc_manager() const { return _young_manager; }
|
2007-12-01 00:00:00 +00:00
|
|
|
};
|
|
|
|
|
2015-12-10 14:57:55 +01:00
|
|
|
// Simple class for storing info about the heap at the start of GC, to be used
|
|
|
|
// after GC for comparison/printing.
|
|
|
|
class PreGCValues {
|
|
|
|
public:
|
|
|
|
PreGCValues(ParallelScavengeHeap* heap) :
|
|
|
|
_heap_used(heap->used()),
|
|
|
|
_young_gen_used(heap->young_gen()->used_in_bytes()),
|
|
|
|
_old_gen_used(heap->old_gen()->used_in_bytes()),
|
2018-03-11 07:11:03 +01:00
|
|
|
_metadata_used(MetaspaceUtils::used_bytes()) { };
|
2015-12-10 14:57:55 +01:00
|
|
|
|
|
|
|
size_t heap_used() const { return _heap_used; }
|
|
|
|
size_t young_gen_used() const { return _young_gen_used; }
|
|
|
|
size_t old_gen_used() const { return _old_gen_used; }
|
|
|
|
size_t metadata_used() const { return _metadata_used; }
|
|
|
|
|
|
|
|
private:
|
|
|
|
size_t _heap_used;
|
|
|
|
size_t _young_gen_used;
|
|
|
|
size_t _old_gen_used;
|
|
|
|
size_t _metadata_used;
|
|
|
|
};
|
|
|
|
|
2017-07-04 20:41:33 +02:00
|
|
|
// Class that can be used to print information about the
|
|
|
|
// adaptive size policy at intervals specified by
|
|
|
|
// AdaptiveSizePolicyOutputInterval. Only print information
|
|
|
|
// if an adaptive size policy is in use.
|
|
|
|
class AdaptiveSizePolicyOutput : AllStatic {
|
|
|
|
static bool enabled() {
|
|
|
|
return UseParallelGC &&
|
|
|
|
UseAdaptiveSizePolicy &&
|
|
|
|
log_is_enabled(Debug, gc, ergo);
|
|
|
|
}
|
|
|
|
public:
|
|
|
|
static void print() {
|
|
|
|
if (enabled()) {
|
|
|
|
ParallelScavengeHeap::heap()->size_policy()->print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static void print(AdaptiveSizePolicy* size_policy, uint count) {
|
|
|
|
bool do_print =
|
|
|
|
enabled() &&
|
|
|
|
(AdaptiveSizePolicyOutputInterval > 0) &&
|
|
|
|
(count % AdaptiveSizePolicyOutputInterval) == 0;
|
|
|
|
|
|
|
|
if (do_print) {
|
|
|
|
size_policy->print();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
2015-05-13 15:16:06 +02:00
|
|
|
#endif // SHARE_VM_GC_PARALLEL_PARALLELSCAVENGEHEAP_HPP
|