Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/parallelScavenge/psOldGen.hpp
38920 views
/*1* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP25#define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP2627#include "gc_implementation/parallelScavenge/objectStartArray.hpp"28#include "gc_implementation/parallelScavenge/psGenerationCounters.hpp"29#include "gc_implementation/parallelScavenge/psVirtualspace.hpp"30#include "gc_implementation/shared/mutableSpace.hpp"31#include "gc_implementation/shared/spaceCounters.hpp"32#include "runtime/safepoint.hpp"3334class PSMarkSweepDecorator;3536class PSOldGen : public CHeapObj<mtGC> {37friend class VMStructs;38friend class PSPromotionManager; // Uses the cas_allocate methods39friend class ParallelScavengeHeap;40friend class AdjoiningGenerations;4142protected:43MemRegion _reserved; // Used for simple containment tests44PSVirtualSpace* _virtual_space; // Controls mapping and unmapping of virtual mem45ObjectStartArray _start_array; // Keeps track of where objects start in a 512b block46MutableSpace* _object_space; // Where all the objects live47PSMarkSweepDecorator* _object_mark_sweep; // The mark sweep view of _object_space48const char* const _name; // Name of this generation.4950// Performance Counters51PSGenerationCounters* _gen_counters;52SpaceCounters* _space_counters;5354// Sizing information, in bytes, set in constructor55const size_t _init_gen_size;56const size_t _min_gen_size;57const size_t _max_gen_size;5859// Used when initializing the _name field.60static inline const char* select_name();6162HeapWord* allocate_noexpand(size_t word_size) {63// We assume the heap lock is held here.64assert_locked_or_safepoint(Heap_lock);65HeapWord* res = object_space()->allocate(word_size);66if (res != NULL) {67_start_array.allocate_block(res);68}69return res;70}7172// Support for MT garbage collection. CAS allocation is lower overhead than grabbing73// and releasing the heap lock, which is held during gc's anyway. This method is not74// safe for use at the same time as allocate_noexpand()!75HeapWord* cas_allocate_noexpand(size_t word_size) {76assert(SafepointSynchronize::is_at_safepoint(), "Must only be called at safepoint");77HeapWord* res = object_space()->cas_allocate(word_size);78if (res != NULL) {79_start_array.allocate_block(res);80}81return res;82}8384// Support for MT garbage collection. See above comment.85HeapWord* cas_allocate(size_t word_size) {86HeapWord* res = cas_allocate_noexpand(word_size);87return (res == NULL) ? expand_and_cas_allocate(word_size) : res;88}8990HeapWord* expand_and_allocate(size_t word_size);91HeapWord* expand_and_cas_allocate(size_t word_size);92void expand(size_t bytes);93bool expand_by(size_t bytes);94bool expand_to_reserved();9596void shrink(size_t bytes);9798void post_resize();99100public:101// Initialize the generation.102PSOldGen(ReservedSpace rs, size_t alignment,103size_t initial_size, size_t min_size, size_t max_size,104const char* perf_data_name, int level);105106PSOldGen(size_t initial_size, size_t min_size, size_t max_size,107const char* perf_data_name, int level);108109virtual void initialize(ReservedSpace rs, size_t alignment,110const char* perf_data_name, int level);111void initialize_virtual_space(ReservedSpace rs, size_t alignment);112virtual void initialize_work(const char* perf_data_name, int level);113virtual void initialize_performance_counters(const char* perf_data_name, int level);114115MemRegion reserved() const { return _reserved; }116virtual size_t max_gen_size() { return _max_gen_size; }117size_t min_gen_size() { return _min_gen_size; }118119// Returns limit on the maximum size of the generation. This120// is the same as _max_gen_size for PSOldGen but need not be121// for a derived class.122virtual size_t gen_size_limit();123124bool is_in(const void* p) const {125return _virtual_space->contains((void *)p);126}127128bool is_in_reserved(const void* p) const {129return reserved().contains(p);130}131132MutableSpace* object_space() const { return _object_space; }133PSMarkSweepDecorator* object_mark_sweep() const { return _object_mark_sweep; }134ObjectStartArray* start_array() { return &_start_array; }135PSVirtualSpace* virtual_space() const { return _virtual_space;}136137// Has the generation been successfully allocated?138bool is_allocated();139140// MarkSweep methods141virtual void precompact();142void adjust_pointers();143void compact();144145// Size info146size_t capacity_in_bytes() const { return object_space()->capacity_in_bytes(); }147size_t used_in_bytes() const { return object_space()->used_in_bytes(); }148size_t free_in_bytes() const { return object_space()->free_in_bytes(); }149150size_t capacity_in_words() const { return object_space()->capacity_in_words(); }151size_t used_in_words() const { return object_space()->used_in_words(); }152size_t free_in_words() const { return object_space()->free_in_words(); }153154// Includes uncommitted memory155size_t contiguous_available() const;156157bool is_maximal_no_gc() const {158return virtual_space()->uncommitted_size() == 0;159}160161// Calculating new sizes162void resize(size_t desired_free_space);163164// Allocation. We report all successful allocations to the size policy165// Note that the perm gen does not use this method, and should not!166HeapWord* allocate(size_t word_size);167168// Iteration.169void oop_iterate_no_header(OopClosure* cl) { object_space()->oop_iterate_no_header(cl); }170void object_iterate(ObjectClosure* cl) { object_space()->object_iterate(cl); }171172// Debugging - do not use for time critical operations173virtual void print() const;174virtual void print_on(outputStream* st) const;175void print_used_change(size_t prev_used) const;176177void verify();178void verify_object_start_array();179180// These should not used181virtual void reset_after_change();182183// These should not used184virtual size_t available_for_expansion();185virtual size_t available_for_contraction();186187void space_invariants() PRODUCT_RETURN;188189// Performace Counter support190void update_counters();191192// Printing support193virtual const char* name() const { return _name; }194195// Debugging support196// Save the tops of all spaces for later use during mangling.197void record_spaces_top() PRODUCT_RETURN;198};199200#endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSOLDGEN_HPP201202203