aoqi@0: /* aoqi@0: * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: #ifndef SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPARALLELCOMPACT_HPP aoqi@0: #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPARALLELCOMPACT_HPP aoqi@0: aoqi@0: #include "gc_implementation/parallelScavenge/objectStartArray.hpp" aoqi@0: #include "gc_implementation/parallelScavenge/parMarkBitMap.hpp" aoqi@0: #include "gc_implementation/parallelScavenge/psCompactionManager.hpp" aoqi@0: #include "gc_implementation/shared/collectorCounters.hpp" aoqi@0: #include "gc_implementation/shared/markSweep.hpp" aoqi@0: #include "gc_implementation/shared/mutableSpace.hpp" aoqi@0: #include "memory/sharedHeap.hpp" aoqi@0: #include "oops/oop.hpp" aoqi@0: aoqi@0: class ParallelScavengeHeap; aoqi@0: class PSAdaptiveSizePolicy; aoqi@0: class PSYoungGen; aoqi@0: class PSOldGen; aoqi@0: class ParCompactionManager; aoqi@0: class ParallelTaskTerminator; aoqi@0: class PSParallelCompact; aoqi@0: class GCTaskManager; aoqi@0: class GCTaskQueue; aoqi@0: class PreGCValues; aoqi@0: class MoveAndUpdateClosure; aoqi@0: class RefProcTaskExecutor; aoqi@0: class ParallelOldTracer; aoqi@0: class STWGCTimer; aoqi@0: aoqi@0: // The SplitInfo class holds the information needed to 'split' a source region aoqi@0: // so that the live data can be copied to two destination *spaces*. Normally, aoqi@0: // all the live data in a region is copied to a single destination space (e.g., aoqi@0: // everything live in a region in eden is copied entirely into the old gen). aoqi@0: // However, when the heap is nearly full, all the live data in eden may not fit aoqi@0: // into the old gen. Copying only some of the regions from eden to old gen aoqi@0: // requires finding a region that does not contain a partial object (i.e., no aoqi@0: // live object crosses the region boundary) somewhere near the last object that aoqi@0: // does fit into the old gen. Since it's not always possible to find such a aoqi@0: // region, splitting is necessary for predictable behavior. aoqi@0: // aoqi@0: // A region is always split at the end of the partial object. This avoids aoqi@0: // additional tests when calculating the new location of a pointer, which is a aoqi@0: // very hot code path. The partial object and everything to its left will be aoqi@0: // copied to another space (call it dest_space_1). The live data to the right aoqi@0: // of the partial object will be copied either within the space itself, or to a aoqi@0: // different destination space (distinct from dest_space_1). aoqi@0: // aoqi@0: // Split points are identified during the summary phase, when region aoqi@0: // destinations are computed: data about the split, including the aoqi@0: // partial_object_size, is recorded in a SplitInfo record and the aoqi@0: // partial_object_size field in the summary data is set to zero. The zeroing is aoqi@0: // possible (and necessary) since the partial object will move to a different aoqi@0: // destination space than anything to its right, thus the partial object should aoqi@0: // not affect the locations of any objects to its right. aoqi@0: // aoqi@0: // The recorded data is used during the compaction phase, but only rarely: when aoqi@0: // the partial object on the split region will be copied across a destination aoqi@0: // region boundary. This test is made once each time a region is filled, and is aoqi@0: // a simple address comparison, so the overhead is negligible (see aoqi@0: // PSParallelCompact::first_src_addr()). aoqi@0: // aoqi@0: // Notes: aoqi@0: // aoqi@0: // Only regions with partial objects are split; a region without a partial aoqi@0: // object does not need any extra bookkeeping. aoqi@0: // aoqi@0: // At most one region is split per space, so the amount of data required is aoqi@0: // constant. aoqi@0: // aoqi@0: // A region is split only when the destination space would overflow. Once that aoqi@0: // happens, the destination space is abandoned and no other data (even from aoqi@0: // other source spaces) is targeted to that destination space. Abandoning the aoqi@0: // destination space may leave a somewhat large unused area at the end, if a aoqi@0: // large object caused the overflow. aoqi@0: // aoqi@0: // Future work: aoqi@0: // aoqi@0: // More bookkeeping would be required to continue to use the destination space. aoqi@0: // The most general solution would allow data from regions in two different aoqi@0: // source spaces to be "joined" in a single destination region. At the very aoqi@0: // least, additional code would be required in next_src_region() to detect the aoqi@0: // join and skip to an out-of-order source region. If the join region was also aoqi@0: // the last destination region to which a split region was copied (the most aoqi@0: // likely case), then additional work would be needed to get fill_region() to aoqi@0: // stop iteration and switch to a new source region at the right point. Basic aoqi@0: // idea would be to use a fake value for the top of the source space. It is aoqi@0: // doable, if a bit tricky. aoqi@0: // aoqi@0: // A simpler (but less general) solution would fill the remainder of the aoqi@0: // destination region with a dummy object and continue filling the next aoqi@0: // destination region. aoqi@0: aoqi@0: class SplitInfo aoqi@0: { aoqi@0: public: aoqi@0: // Return true if this split info is valid (i.e., if a split has been aoqi@0: // recorded). The very first region cannot have a partial object and thus is aoqi@0: // never split, so 0 is the 'invalid' value. aoqi@0: bool is_valid() const { return _src_region_idx > 0; } aoqi@0: aoqi@0: // Return true if this split holds data for the specified source region. aoqi@0: inline bool is_split(size_t source_region) const; aoqi@0: aoqi@0: // The index of the split region, the size of the partial object on that aoqi@0: // region and the destination of the partial object. aoqi@0: size_t src_region_idx() const { return _src_region_idx; } aoqi@0: size_t partial_obj_size() const { return _partial_obj_size; } aoqi@0: HeapWord* destination() const { return _destination; } aoqi@0: aoqi@0: // The destination count of the partial object referenced by this split aoqi@0: // (either 1 or 2). This must be added to the destination count of the aoqi@0: // remainder of the source region. aoqi@0: unsigned int destination_count() const { return _destination_count; } aoqi@0: aoqi@0: // If a word within the partial object will be written to the first word of a aoqi@0: // destination region, this is the address of the destination region; aoqi@0: // otherwise this is NULL. aoqi@0: HeapWord* dest_region_addr() const { return _dest_region_addr; } aoqi@0: aoqi@0: // If a word within the partial object will be written to the first word of a aoqi@0: // destination region, this is the address of that word within the partial aoqi@0: // object; otherwise this is NULL. aoqi@0: HeapWord* first_src_addr() const { return _first_src_addr; } aoqi@0: aoqi@0: // Record the data necessary to split the region src_region_idx. aoqi@0: void record(size_t src_region_idx, size_t partial_obj_size, aoqi@0: HeapWord* destination); aoqi@0: aoqi@0: void clear(); aoqi@0: aoqi@0: DEBUG_ONLY(void verify_clear();) aoqi@0: aoqi@0: private: aoqi@0: size_t _src_region_idx; aoqi@0: size_t _partial_obj_size; aoqi@0: HeapWord* _destination; aoqi@0: unsigned int _destination_count; aoqi@0: HeapWord* _dest_region_addr; aoqi@0: HeapWord* _first_src_addr; aoqi@0: }; aoqi@0: aoqi@0: inline bool SplitInfo::is_split(size_t region_idx) const aoqi@0: { aoqi@0: return _src_region_idx == region_idx && is_valid(); aoqi@0: } aoqi@0: aoqi@0: class SpaceInfo aoqi@0: { aoqi@0: public: aoqi@0: MutableSpace* space() const { return _space; } aoqi@0: aoqi@0: // Where the free space will start after the collection. Valid only after the aoqi@0: // summary phase completes. aoqi@0: HeapWord* new_top() const { return _new_top; } aoqi@0: aoqi@0: // Allows new_top to be set. aoqi@0: HeapWord** new_top_addr() { return &_new_top; } aoqi@0: aoqi@0: // Where the smallest allowable dense prefix ends (used only for perm gen). aoqi@0: HeapWord* min_dense_prefix() const { return _min_dense_prefix; } aoqi@0: aoqi@0: // Where the dense prefix ends, or the compacted region begins. aoqi@0: HeapWord* dense_prefix() const { return _dense_prefix; } aoqi@0: aoqi@0: // The start array for the (generation containing the) space, or NULL if there aoqi@0: // is no start array. aoqi@0: ObjectStartArray* start_array() const { return _start_array; } aoqi@0: aoqi@0: SplitInfo& split_info() { return _split_info; } aoqi@0: aoqi@0: void set_space(MutableSpace* s) { _space = s; } aoqi@0: void set_new_top(HeapWord* addr) { _new_top = addr; } aoqi@0: void set_min_dense_prefix(HeapWord* addr) { _min_dense_prefix = addr; } aoqi@0: void set_dense_prefix(HeapWord* addr) { _dense_prefix = addr; } aoqi@0: void set_start_array(ObjectStartArray* s) { _start_array = s; } aoqi@0: aoqi@0: void publish_new_top() const { _space->set_top(_new_top); } aoqi@0: aoqi@0: private: aoqi@0: MutableSpace* _space; aoqi@0: HeapWord* _new_top; aoqi@0: HeapWord* _min_dense_prefix; aoqi@0: HeapWord* _dense_prefix; aoqi@0: ObjectStartArray* _start_array; aoqi@0: SplitInfo _split_info; aoqi@0: }; aoqi@0: aoqi@0: class ParallelCompactData aoqi@0: { aoqi@0: public: aoqi@0: // Sizes are in HeapWords, unless indicated otherwise. aoqi@0: static const size_t Log2RegionSize; aoqi@0: static const size_t RegionSize; aoqi@0: static const size_t RegionSizeBytes; aoqi@0: aoqi@0: // Mask for the bits in a size_t to get an offset within a region. aoqi@0: static const size_t RegionSizeOffsetMask; aoqi@0: // Mask for the bits in a pointer to get an offset within a region. aoqi@0: static const size_t RegionAddrOffsetMask; aoqi@0: // Mask for the bits in a pointer to get the address of the start of a region. aoqi@0: static const size_t RegionAddrMask; aoqi@0: aoqi@0: static const size_t Log2BlockSize; aoqi@0: static const size_t BlockSize; aoqi@0: static const size_t BlockSizeBytes; aoqi@0: aoqi@0: static const size_t BlockSizeOffsetMask; aoqi@0: static const size_t BlockAddrOffsetMask; aoqi@0: static const size_t BlockAddrMask; aoqi@0: aoqi@0: static const size_t BlocksPerRegion; aoqi@0: static const size_t Log2BlocksPerRegion; aoqi@0: aoqi@0: class RegionData aoqi@0: { aoqi@0: public: aoqi@0: // Destination address of the region. aoqi@0: HeapWord* destination() const { return _destination; } aoqi@0: aoqi@0: // The first region containing data destined for this region. aoqi@0: size_t source_region() const { return _source_region; } aoqi@0: aoqi@0: // The object (if any) starting in this region and ending in a different aoqi@0: // region that could not be updated during the main (parallel) compaction aoqi@0: // phase. This is different from _partial_obj_addr, which is an object that aoqi@0: // extends onto a source region. However, the two uses do not overlap in aoqi@0: // time, so the same field is used to save space. aoqi@0: HeapWord* deferred_obj_addr() const { return _partial_obj_addr; } aoqi@0: aoqi@0: // The starting address of the partial object extending onto the region. aoqi@0: HeapWord* partial_obj_addr() const { return _partial_obj_addr; } aoqi@0: aoqi@0: // Size of the partial object extending onto the region (words). aoqi@0: size_t partial_obj_size() const { return _partial_obj_size; } aoqi@0: aoqi@0: // Size of live data that lies within this region due to objects that start aoqi@0: // in this region (words). This does not include the partial object aoqi@0: // extending onto the region (if any), or the part of an object that extends aoqi@0: // onto the next region (if any). aoqi@0: size_t live_obj_size() const { return _dc_and_los & los_mask; } aoqi@0: aoqi@0: // Total live data that lies within the region (words). aoqi@0: size_t data_size() const { return partial_obj_size() + live_obj_size(); } aoqi@0: aoqi@0: // The destination_count is the number of other regions to which data from aoqi@0: // this region will be copied. At the end of the summary phase, the valid aoqi@0: // values of destination_count are aoqi@0: // aoqi@0: // 0 - data from the region will be compacted completely into itself, or the aoqi@0: // region is empty. The region can be claimed and then filled. aoqi@0: // 1 - data from the region will be compacted into 1 other region; some aoqi@0: // data from the region may also be compacted into the region itself. aoqi@0: // 2 - data from the region will be copied to 2 other regions. aoqi@0: // aoqi@0: // During compaction as regions are emptied, the destination_count is aoqi@0: // decremented (atomically) and when it reaches 0, it can be claimed and aoqi@0: // then filled. aoqi@0: // aoqi@0: // A region is claimed for processing by atomically changing the aoqi@0: // destination_count to the claimed value (dc_claimed). After a region has aoqi@0: // been filled, the destination_count should be set to the completed value aoqi@0: // (dc_completed). aoqi@0: inline uint destination_count() const; aoqi@0: inline uint destination_count_raw() const; aoqi@0: aoqi@0: // Whether the block table for this region has been filled. aoqi@0: inline bool blocks_filled() const; aoqi@0: aoqi@0: // Number of times the block table was filled. aoqi@0: DEBUG_ONLY(inline size_t blocks_filled_count() const;) aoqi@0: aoqi@0: // The location of the java heap data that corresponds to this region. aoqi@0: inline HeapWord* data_location() const; aoqi@0: aoqi@0: // The highest address referenced by objects in this region. aoqi@0: inline HeapWord* highest_ref() const; aoqi@0: aoqi@0: // Whether this region is available to be claimed, has been claimed, or has aoqi@0: // been completed. aoqi@0: // aoqi@0: // Minor subtlety: claimed() returns true if the region is marked aoqi@0: // completed(), which is desirable since a region must be claimed before it aoqi@0: // can be completed. aoqi@0: bool available() const { return _dc_and_los < dc_one; } aoqi@0: bool claimed() const { return _dc_and_los >= dc_claimed; } aoqi@0: bool completed() const { return _dc_and_los >= dc_completed; } aoqi@0: aoqi@0: // These are not atomic. aoqi@0: void set_destination(HeapWord* addr) { _destination = addr; } aoqi@0: void set_source_region(size_t region) { _source_region = region; } aoqi@0: void set_deferred_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; } aoqi@0: void set_partial_obj_addr(HeapWord* addr) { _partial_obj_addr = addr; } aoqi@0: void set_partial_obj_size(size_t words) { aoqi@0: _partial_obj_size = (region_sz_t) words; aoqi@0: } aoqi@0: inline void set_blocks_filled(); aoqi@0: aoqi@0: inline void set_destination_count(uint count); aoqi@0: inline void set_live_obj_size(size_t words); aoqi@0: inline void set_data_location(HeapWord* addr); aoqi@0: inline void set_completed(); aoqi@0: inline bool claim_unsafe(); aoqi@0: aoqi@0: // These are atomic. aoqi@0: inline void add_live_obj(size_t words); aoqi@0: inline void set_highest_ref(HeapWord* addr); aoqi@0: inline void decrement_destination_count(); aoqi@0: inline bool claim(); aoqi@0: aoqi@0: private: aoqi@0: // The type used to represent object sizes within a region. aoqi@0: typedef uint region_sz_t; aoqi@0: aoqi@0: // Constants for manipulating the _dc_and_los field, which holds both the aoqi@0: // destination count and live obj size. The live obj size lives at the aoqi@0: // least significant end so no masking is necessary when adding. aoqi@0: static const region_sz_t dc_shift; // Shift amount. aoqi@0: static const region_sz_t dc_mask; // Mask for destination count. aoqi@0: static const region_sz_t dc_one; // 1, shifted appropriately. aoqi@0: static const region_sz_t dc_claimed; // Region has been claimed. aoqi@0: static const region_sz_t dc_completed; // Region has been completed. aoqi@0: static const region_sz_t los_mask; // Mask for live obj size. aoqi@0: aoqi@0: HeapWord* _destination; aoqi@0: size_t _source_region; aoqi@0: HeapWord* _partial_obj_addr; aoqi@0: region_sz_t _partial_obj_size; aoqi@0: region_sz_t volatile _dc_and_los; aoqi@0: bool _blocks_filled; aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: size_t _blocks_filled_count; // Number of block table fills. aoqi@0: aoqi@0: // These enable optimizations that are only partially implemented. Use aoqi@0: // debug builds to prevent the code fragments from breaking. aoqi@0: HeapWord* _data_location; aoqi@0: HeapWord* _highest_ref; aoqi@0: #endif // #ifdef ASSERT aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: public: aoqi@0: uint _pushed; // 0 until region is pushed onto a stack aoqi@0: private: aoqi@0: #endif aoqi@0: }; aoqi@0: aoqi@0: // "Blocks" allow shorter sections of the bitmap to be searched. Each Block aoqi@0: // holds an offset, which is the amount of live data in the Region to the left aoqi@0: // of the first live object that starts in the Block. aoqi@0: class BlockData aoqi@0: { aoqi@0: public: aoqi@0: typedef unsigned short int blk_ofs_t; aoqi@0: aoqi@0: blk_ofs_t offset() const { return _offset; } aoqi@0: void set_offset(size_t val) { _offset = (blk_ofs_t)val; } aoqi@0: aoqi@0: private: aoqi@0: blk_ofs_t _offset; aoqi@0: }; aoqi@0: aoqi@0: public: aoqi@0: ParallelCompactData(); aoqi@0: bool initialize(MemRegion covered_region); aoqi@0: aoqi@0: size_t region_count() const { return _region_count; } aoqi@0: size_t reserved_byte_size() const { return _reserved_byte_size; } aoqi@0: aoqi@0: // Convert region indices to/from RegionData pointers. aoqi@0: inline RegionData* region(size_t region_idx) const; aoqi@0: inline size_t region(const RegionData* const region_ptr) const; aoqi@0: aoqi@0: size_t block_count() const { return _block_count; } aoqi@0: inline BlockData* block(size_t block_idx) const; aoqi@0: inline size_t block(const BlockData* block_ptr) const; aoqi@0: aoqi@0: void add_obj(HeapWord* addr, size_t len); aoqi@0: void add_obj(oop p, size_t len) { add_obj((HeapWord*)p, len); } aoqi@0: aoqi@0: // Fill in the regions covering [beg, end) so that no data moves; i.e., the aoqi@0: // destination of region n is simply the start of region n. The argument beg aoqi@0: // must be region-aligned; end need not be. aoqi@0: void summarize_dense_prefix(HeapWord* beg, HeapWord* end); aoqi@0: aoqi@0: HeapWord* summarize_split_space(size_t src_region, SplitInfo& split_info, aoqi@0: HeapWord* destination, HeapWord* target_end, aoqi@0: HeapWord** target_next); aoqi@0: bool summarize(SplitInfo& split_info, aoqi@0: HeapWord* source_beg, HeapWord* source_end, aoqi@0: HeapWord** source_next, aoqi@0: HeapWord* target_beg, HeapWord* target_end, aoqi@0: HeapWord** target_next); aoqi@0: aoqi@0: void clear(); aoqi@0: void clear_range(size_t beg_region, size_t end_region); aoqi@0: void clear_range(HeapWord* beg, HeapWord* end) { aoqi@0: clear_range(addr_to_region_idx(beg), addr_to_region_idx(end)); aoqi@0: } aoqi@0: aoqi@0: // Return the number of words between addr and the start of the region aoqi@0: // containing addr. aoqi@0: inline size_t region_offset(const HeapWord* addr) const; aoqi@0: aoqi@0: // Convert addresses to/from a region index or region pointer. aoqi@0: inline size_t addr_to_region_idx(const HeapWord* addr) const; aoqi@0: inline RegionData* addr_to_region_ptr(const HeapWord* addr) const; aoqi@0: inline HeapWord* region_to_addr(size_t region) const; aoqi@0: inline HeapWord* region_to_addr(size_t region, size_t offset) const; aoqi@0: inline HeapWord* region_to_addr(const RegionData* region) const; aoqi@0: aoqi@0: inline HeapWord* region_align_down(HeapWord* addr) const; aoqi@0: inline HeapWord* region_align_up(HeapWord* addr) const; aoqi@0: inline bool is_region_aligned(HeapWord* addr) const; aoqi@0: aoqi@0: // Analogous to region_offset() for blocks. aoqi@0: size_t block_offset(const HeapWord* addr) const; aoqi@0: size_t addr_to_block_idx(const HeapWord* addr) const; aoqi@0: size_t addr_to_block_idx(const oop obj) const { aoqi@0: return addr_to_block_idx((HeapWord*) obj); aoqi@0: } aoqi@0: inline BlockData* addr_to_block_ptr(const HeapWord* addr) const; aoqi@0: inline HeapWord* block_to_addr(size_t block) const; aoqi@0: inline size_t region_to_block_idx(size_t region) const; aoqi@0: aoqi@0: inline HeapWord* block_align_down(HeapWord* addr) const; aoqi@0: inline HeapWord* block_align_up(HeapWord* addr) const; aoqi@0: inline bool is_block_aligned(HeapWord* addr) const; aoqi@0: aoqi@0: // Return the address one past the end of the partial object. aoqi@0: HeapWord* partial_obj_end(size_t region_idx) const; aoqi@0: aoqi@0: // Return the location of the object after compaction. aoqi@0: HeapWord* calc_new_pointer(HeapWord* addr); aoqi@0: aoqi@0: HeapWord* calc_new_pointer(oop p) { aoqi@0: return calc_new_pointer((HeapWord*) p); aoqi@0: } aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: void verify_clear(const PSVirtualSpace* vspace); aoqi@0: void verify_clear(); aoqi@0: #endif // #ifdef ASSERT aoqi@0: aoqi@0: private: aoqi@0: bool initialize_block_data(); aoqi@0: bool initialize_region_data(size_t region_size); aoqi@0: PSVirtualSpace* create_vspace(size_t count, size_t element_size); aoqi@0: aoqi@0: private: aoqi@0: HeapWord* _region_start; aoqi@0: #ifdef ASSERT aoqi@0: HeapWord* _region_end; aoqi@0: #endif // #ifdef ASSERT aoqi@0: aoqi@0: PSVirtualSpace* _region_vspace; aoqi@0: size_t _reserved_byte_size; aoqi@0: RegionData* _region_data; aoqi@0: size_t _region_count; aoqi@0: aoqi@0: PSVirtualSpace* _block_vspace; aoqi@0: BlockData* _block_data; aoqi@0: size_t _block_count; aoqi@0: }; aoqi@0: aoqi@0: inline uint aoqi@0: ParallelCompactData::RegionData::destination_count_raw() const aoqi@0: { aoqi@0: return _dc_and_los & dc_mask; aoqi@0: } aoqi@0: aoqi@0: inline uint aoqi@0: ParallelCompactData::RegionData::destination_count() const aoqi@0: { aoqi@0: return destination_count_raw() >> dc_shift; aoqi@0: } aoqi@0: aoqi@0: inline bool aoqi@0: ParallelCompactData::RegionData::blocks_filled() const aoqi@0: { aoqi@0: return _blocks_filled; aoqi@0: } aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: inline size_t aoqi@0: ParallelCompactData::RegionData::blocks_filled_count() const aoqi@0: { aoqi@0: return _blocks_filled_count; aoqi@0: } aoqi@0: #endif // #ifdef ASSERT aoqi@0: aoqi@0: inline void aoqi@0: ParallelCompactData::RegionData::set_blocks_filled() aoqi@0: { aoqi@0: _blocks_filled = true; aoqi@0: // Debug builds count the number of times the table was filled. aoqi@0: DEBUG_ONLY(Atomic::inc_ptr(&_blocks_filled_count)); aoqi@0: } aoqi@0: aoqi@0: inline void aoqi@0: ParallelCompactData::RegionData::set_destination_count(uint count) aoqi@0: { aoqi@0: assert(count <= (dc_completed >> dc_shift), "count too large"); aoqi@0: const region_sz_t live_sz = (region_sz_t) live_obj_size(); aoqi@0: _dc_and_los = (count << dc_shift) | live_sz; aoqi@0: } aoqi@0: aoqi@0: inline void ParallelCompactData::RegionData::set_live_obj_size(size_t words) aoqi@0: { aoqi@0: assert(words <= los_mask, "would overflow"); aoqi@0: _dc_and_los = destination_count_raw() | (region_sz_t)words; aoqi@0: } aoqi@0: aoqi@0: inline void ParallelCompactData::RegionData::decrement_destination_count() aoqi@0: { aoqi@0: assert(_dc_and_los < dc_claimed, "already claimed"); aoqi@0: assert(_dc_and_los >= dc_one, "count would go negative"); aoqi@0: Atomic::add((int)dc_mask, (volatile int*)&_dc_and_los); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* ParallelCompactData::RegionData::data_location() const aoqi@0: { aoqi@0: DEBUG_ONLY(return _data_location;) aoqi@0: NOT_DEBUG(return NULL;) aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* ParallelCompactData::RegionData::highest_ref() const aoqi@0: { aoqi@0: DEBUG_ONLY(return _highest_ref;) aoqi@0: NOT_DEBUG(return NULL;) aoqi@0: } aoqi@0: aoqi@0: inline void ParallelCompactData::RegionData::set_data_location(HeapWord* addr) aoqi@0: { aoqi@0: DEBUG_ONLY(_data_location = addr;) aoqi@0: } aoqi@0: aoqi@0: inline void ParallelCompactData::RegionData::set_completed() aoqi@0: { aoqi@0: assert(claimed(), "must be claimed first"); aoqi@0: _dc_and_los = dc_completed | (region_sz_t) live_obj_size(); aoqi@0: } aoqi@0: aoqi@0: // MT-unsafe claiming of a region. Should only be used during single threaded aoqi@0: // execution. aoqi@0: inline bool ParallelCompactData::RegionData::claim_unsafe() aoqi@0: { aoqi@0: if (available()) { aoqi@0: _dc_and_los |= dc_claimed; aoqi@0: return true; aoqi@0: } aoqi@0: return false; aoqi@0: } aoqi@0: aoqi@0: inline void ParallelCompactData::RegionData::add_live_obj(size_t words) aoqi@0: { aoqi@0: assert(words <= (size_t)los_mask - live_obj_size(), "overflow"); aoqi@0: Atomic::add((int) words, (volatile int*) &_dc_and_los); aoqi@0: } aoqi@0: aoqi@0: inline void ParallelCompactData::RegionData::set_highest_ref(HeapWord* addr) aoqi@0: { aoqi@0: #ifdef ASSERT aoqi@0: HeapWord* tmp = _highest_ref; aoqi@0: while (addr > tmp) { aoqi@0: tmp = (HeapWord*)Atomic::cmpxchg_ptr(addr, &_highest_ref, tmp); aoqi@0: } aoqi@0: #endif // #ifdef ASSERT aoqi@0: } aoqi@0: aoqi@0: inline bool ParallelCompactData::RegionData::claim() aoqi@0: { aoqi@0: const int los = (int) live_obj_size(); aoqi@0: const int old = Atomic::cmpxchg(dc_claimed | los, aoqi@0: (volatile int*) &_dc_and_los, los); aoqi@0: return old == los; aoqi@0: } aoqi@0: aoqi@0: inline ParallelCompactData::RegionData* aoqi@0: ParallelCompactData::region(size_t region_idx) const aoqi@0: { aoqi@0: assert(region_idx <= region_count(), "bad arg"); aoqi@0: return _region_data + region_idx; aoqi@0: } aoqi@0: aoqi@0: inline size_t aoqi@0: ParallelCompactData::region(const RegionData* const region_ptr) const aoqi@0: { aoqi@0: assert(region_ptr >= _region_data, "bad arg"); aoqi@0: assert(region_ptr <= _region_data + region_count(), "bad arg"); aoqi@0: return pointer_delta(region_ptr, _region_data, sizeof(RegionData)); aoqi@0: } aoqi@0: aoqi@0: inline ParallelCompactData::BlockData* aoqi@0: ParallelCompactData::block(size_t n) const { aoqi@0: assert(n < block_count(), "bad arg"); aoqi@0: return _block_data + n; aoqi@0: } aoqi@0: aoqi@0: inline size_t aoqi@0: ParallelCompactData::region_offset(const HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr <= _region_end, "bad addr"); aoqi@0: return (size_t(addr) & RegionAddrOffsetMask) >> LogHeapWordSize; aoqi@0: } aoqi@0: aoqi@0: inline size_t aoqi@0: ParallelCompactData::addr_to_region_idx(const HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr <= _region_end, "bad addr"); aoqi@0: return pointer_delta(addr, _region_start) >> Log2RegionSize; aoqi@0: } aoqi@0: aoqi@0: inline ParallelCompactData::RegionData* aoqi@0: ParallelCompactData::addr_to_region_ptr(const HeapWord* addr) const aoqi@0: { aoqi@0: return region(addr_to_region_idx(addr)); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::region_to_addr(size_t region) const aoqi@0: { aoqi@0: assert(region <= _region_count, "region out of range"); aoqi@0: return _region_start + (region << Log2RegionSize); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::region_to_addr(const RegionData* region) const aoqi@0: { aoqi@0: return region_to_addr(pointer_delta(region, _region_data, aoqi@0: sizeof(RegionData))); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::region_to_addr(size_t region, size_t offset) const aoqi@0: { aoqi@0: assert(region <= _region_count, "region out of range"); aoqi@0: assert(offset < RegionSize, "offset too big"); // This may be too strict. aoqi@0: return region_to_addr(region) + offset; aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::region_align_down(HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr < _region_end + RegionSize, "bad addr"); aoqi@0: return (HeapWord*)(size_t(addr) & RegionAddrMask); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::region_align_up(HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr <= _region_end, "bad addr"); aoqi@0: return region_align_down(addr + RegionSizeOffsetMask); aoqi@0: } aoqi@0: aoqi@0: inline bool aoqi@0: ParallelCompactData::is_region_aligned(HeapWord* addr) const aoqi@0: { aoqi@0: return region_offset(addr) == 0; aoqi@0: } aoqi@0: aoqi@0: inline size_t aoqi@0: ParallelCompactData::block_offset(const HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr <= _region_end, "bad addr"); aoqi@0: return (size_t(addr) & BlockAddrOffsetMask) >> LogHeapWordSize; aoqi@0: } aoqi@0: aoqi@0: inline size_t aoqi@0: ParallelCompactData::addr_to_block_idx(const HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr <= _region_end, "bad addr"); aoqi@0: return pointer_delta(addr, _region_start) >> Log2BlockSize; aoqi@0: } aoqi@0: aoqi@0: inline ParallelCompactData::BlockData* aoqi@0: ParallelCompactData::addr_to_block_ptr(const HeapWord* addr) const aoqi@0: { aoqi@0: return block(addr_to_block_idx(addr)); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::block_to_addr(size_t block) const aoqi@0: { aoqi@0: assert(block < _block_count, "block out of range"); aoqi@0: return _region_start + (block << Log2BlockSize); aoqi@0: } aoqi@0: aoqi@0: inline size_t aoqi@0: ParallelCompactData::region_to_block_idx(size_t region) const aoqi@0: { aoqi@0: return region << Log2BlocksPerRegion; aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::block_align_down(HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr < _region_end + RegionSize, "bad addr"); aoqi@0: return (HeapWord*)(size_t(addr) & BlockAddrMask); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* aoqi@0: ParallelCompactData::block_align_up(HeapWord* addr) const aoqi@0: { aoqi@0: assert(addr >= _region_start, "bad addr"); aoqi@0: assert(addr <= _region_end, "bad addr"); aoqi@0: return block_align_down(addr + BlockSizeOffsetMask); aoqi@0: } aoqi@0: aoqi@0: inline bool aoqi@0: ParallelCompactData::is_block_aligned(HeapWord* addr) const aoqi@0: { aoqi@0: return block_offset(addr) == 0; aoqi@0: } aoqi@0: aoqi@0: // Abstract closure for use with ParMarkBitMap::iterate(), which will invoke the aoqi@0: // do_addr() method. aoqi@0: // aoqi@0: // The closure is initialized with the number of heap words to process aoqi@0: // (words_remaining()), and becomes 'full' when it reaches 0. The do_addr() aoqi@0: // methods in subclasses should update the total as words are processed. Since aoqi@0: // only one subclass actually uses this mechanism to terminate iteration, the aoqi@0: // default initial value is > 0. The implementation is here and not in the aoqi@0: // single subclass that uses it to avoid making is_full() virtual, and thus aoqi@0: // adding a virtual call per live object. aoqi@0: aoqi@0: class ParMarkBitMapClosure: public StackObj { aoqi@0: public: aoqi@0: typedef ParMarkBitMap::idx_t idx_t; aoqi@0: typedef ParMarkBitMap::IterationStatus IterationStatus; aoqi@0: aoqi@0: public: aoqi@0: inline ParMarkBitMapClosure(ParMarkBitMap* mbm, ParCompactionManager* cm, aoqi@0: size_t words = max_uintx); aoqi@0: aoqi@0: inline ParCompactionManager* compaction_manager() const; aoqi@0: inline ParMarkBitMap* bitmap() const; aoqi@0: inline size_t words_remaining() const; aoqi@0: inline bool is_full() const; aoqi@0: inline HeapWord* source() const; aoqi@0: aoqi@0: inline void set_source(HeapWord* addr); aoqi@0: aoqi@0: virtual IterationStatus do_addr(HeapWord* addr, size_t words) = 0; aoqi@0: aoqi@0: protected: aoqi@0: inline void decrement_words_remaining(size_t words); aoqi@0: aoqi@0: private: aoqi@0: ParMarkBitMap* const _bitmap; aoqi@0: ParCompactionManager* const _compaction_manager; aoqi@0: DEBUG_ONLY(const size_t _initial_words_remaining;) // Useful in debugger. aoqi@0: size_t _words_remaining; // Words left to copy. aoqi@0: aoqi@0: protected: aoqi@0: HeapWord* _source; // Next addr that would be read. aoqi@0: }; aoqi@0: aoqi@0: inline aoqi@0: ParMarkBitMapClosure::ParMarkBitMapClosure(ParMarkBitMap* bitmap, aoqi@0: ParCompactionManager* cm, aoqi@0: size_t words): aoqi@0: _bitmap(bitmap), _compaction_manager(cm) aoqi@0: #ifdef ASSERT aoqi@0: , _initial_words_remaining(words) aoqi@0: #endif aoqi@0: { aoqi@0: _words_remaining = words; aoqi@0: _source = NULL; aoqi@0: } aoqi@0: aoqi@0: inline ParCompactionManager* ParMarkBitMapClosure::compaction_manager() const { aoqi@0: return _compaction_manager; aoqi@0: } aoqi@0: aoqi@0: inline ParMarkBitMap* ParMarkBitMapClosure::bitmap() const { aoqi@0: return _bitmap; aoqi@0: } aoqi@0: aoqi@0: inline size_t ParMarkBitMapClosure::words_remaining() const { aoqi@0: return _words_remaining; aoqi@0: } aoqi@0: aoqi@0: inline bool ParMarkBitMapClosure::is_full() const { aoqi@0: return words_remaining() == 0; aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* ParMarkBitMapClosure::source() const { aoqi@0: return _source; aoqi@0: } aoqi@0: aoqi@0: inline void ParMarkBitMapClosure::set_source(HeapWord* addr) { aoqi@0: _source = addr; aoqi@0: } aoqi@0: aoqi@0: inline void ParMarkBitMapClosure::decrement_words_remaining(size_t words) { aoqi@0: assert(_words_remaining >= words, "processed too many words"); aoqi@0: _words_remaining -= words; aoqi@0: } aoqi@0: aoqi@0: // The UseParallelOldGC collector is a stop-the-world garbage collector that aoqi@0: // does parts of the collection using parallel threads. The collection includes aoqi@0: // the tenured generation and the young generation. The permanent generation is aoqi@0: // collected at the same time as the other two generations but the permanent aoqi@0: // generation is collect by a single GC thread. The permanent generation is aoqi@0: // collected serially because of the requirement that during the processing of a aoqi@0: // klass AAA, any objects reference by AAA must already have been processed. aoqi@0: // This requirement is enforced by a left (lower address) to right (higher aoqi@0: // address) sliding compaction. aoqi@0: // aoqi@0: // There are four phases of the collection. aoqi@0: // aoqi@0: // - marking phase aoqi@0: // - summary phase aoqi@0: // - compacting phase aoqi@0: // - clean up phase aoqi@0: // aoqi@0: // Roughly speaking these phases correspond, respectively, to aoqi@0: // - mark all the live objects aoqi@0: // - calculate the destination of each object at the end of the collection aoqi@0: // - move the objects to their destination aoqi@0: // - update some references and reinitialize some variables aoqi@0: // aoqi@0: // These three phases are invoked in PSParallelCompact::invoke_no_policy(). The aoqi@0: // marking phase is implemented in PSParallelCompact::marking_phase() and does a aoqi@0: // complete marking of the heap. The summary phase is implemented in aoqi@0: // PSParallelCompact::summary_phase(). The move and update phase is implemented aoqi@0: // in PSParallelCompact::compact(). aoqi@0: // aoqi@0: // A space that is being collected is divided into regions and with each region aoqi@0: // is associated an object of type ParallelCompactData. Each region is of a aoqi@0: // fixed size and typically will contain more than 1 object and may have parts aoqi@0: // of objects at the front and back of the region. aoqi@0: // aoqi@0: // region -----+---------------------+---------- aoqi@0: // objects covered [ AAA )[ BBB )[ CCC )[ DDD ) aoqi@0: // aoqi@0: // The marking phase does a complete marking of all live objects in the heap. aoqi@0: // The marking also compiles the size of the data for all live objects covered aoqi@0: // by the region. This size includes the part of any live object spanning onto aoqi@0: // the region (part of AAA if it is live) from the front, all live objects aoqi@0: // contained in the region (BBB and/or CCC if they are live), and the part of aoqi@0: // any live objects covered by the region that extends off the region (part of aoqi@0: // DDD if it is live). The marking phase uses multiple GC threads and marking aoqi@0: // is done in a bit array of type ParMarkBitMap. The marking of the bit map is aoqi@0: // done atomically as is the accumulation of the size of the live objects aoqi@0: // covered by a region. aoqi@0: // aoqi@0: // The summary phase calculates the total live data to the left of each region aoqi@0: // XXX. Based on that total and the bottom of the space, it can calculate the aoqi@0: // starting location of the live data in XXX. The summary phase calculates for aoqi@0: // each region XXX quantites such as aoqi@0: // aoqi@0: // - the amount of live data at the beginning of a region from an object aoqi@0: // entering the region. aoqi@0: // - the location of the first live data on the region aoqi@0: // - a count of the number of regions receiving live data from XXX. aoqi@0: // aoqi@0: // See ParallelCompactData for precise details. The summary phase also aoqi@0: // calculates the dense prefix for the compaction. The dense prefix is a aoqi@0: // portion at the beginning of the space that is not moved. The objects in the aoqi@0: // dense prefix do need to have their object references updated. See method aoqi@0: // summarize_dense_prefix(). aoqi@0: // aoqi@0: // The summary phase is done using 1 GC thread. aoqi@0: // aoqi@0: // The compaction phase moves objects to their new location and updates all aoqi@0: // references in the object. aoqi@0: // aoqi@0: // A current exception is that objects that cross a region boundary are moved aoqi@0: // but do not have their references updated. References are not updated because aoqi@0: // it cannot easily be determined if the klass pointer KKK for the object AAA aoqi@0: // has been updated. KKK likely resides in a region to the left of the region aoqi@0: // containing AAA. These AAA's have there references updated at the end in a aoqi@0: // clean up phase. See the method PSParallelCompact::update_deferred_objects(). aoqi@0: // An alternate strategy is being investigated for this deferral of updating. aoqi@0: // aoqi@0: // Compaction is done on a region basis. A region that is ready to be filled is aoqi@0: // put on a ready list and GC threads take region off the list and fill them. A aoqi@0: // region is ready to be filled if it empty of live objects. Such a region may aoqi@0: // have been initially empty (only contained dead objects) or may have had all aoqi@0: // its live objects copied out already. A region that compacts into itself is aoqi@0: // also ready for filling. The ready list is initially filled with empty aoqi@0: // regions and regions compacting into themselves. There is always at least 1 aoqi@0: // region that can be put on the ready list. The regions are atomically added aoqi@0: // and removed from the ready list. aoqi@0: aoqi@0: class PSParallelCompact : AllStatic { aoqi@0: public: aoqi@0: // Convenient access to type names. aoqi@0: typedef ParMarkBitMap::idx_t idx_t; aoqi@0: typedef ParallelCompactData::RegionData RegionData; aoqi@0: typedef ParallelCompactData::BlockData BlockData; aoqi@0: aoqi@0: typedef enum { aoqi@0: old_space_id, eden_space_id, aoqi@0: from_space_id, to_space_id, last_space_id aoqi@0: } SpaceId; aoqi@0: aoqi@0: public: aoqi@0: // Inline closure decls aoqi@0: // aoqi@0: class IsAliveClosure: public BoolObjectClosure { aoqi@0: public: aoqi@0: virtual bool do_object_b(oop p); aoqi@0: }; aoqi@0: aoqi@0: class KeepAliveClosure: public OopClosure { aoqi@0: private: aoqi@0: ParCompactionManager* _compaction_manager; aoqi@0: protected: aoqi@0: template inline void do_oop_work(T* p); aoqi@0: public: aoqi@0: KeepAliveClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } aoqi@0: virtual void do_oop(oop* p); aoqi@0: virtual void do_oop(narrowOop* p); aoqi@0: }; aoqi@0: aoqi@0: class FollowStackClosure: public VoidClosure { aoqi@0: private: aoqi@0: ParCompactionManager* _compaction_manager; aoqi@0: public: aoqi@0: FollowStackClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } aoqi@0: virtual void do_void(); aoqi@0: }; aoqi@0: aoqi@0: class AdjustPointerClosure: public OopClosure { aoqi@0: public: aoqi@0: virtual void do_oop(oop* p); aoqi@0: virtual void do_oop(narrowOop* p); aoqi@0: // do not walk from thread stacks to the code cache on this phase aoqi@0: virtual void do_code_blob(CodeBlob* cb) const { } aoqi@0: }; aoqi@0: aoqi@0: class AdjustKlassClosure : public KlassClosure { aoqi@0: public: aoqi@0: void do_klass(Klass* klass); aoqi@0: }; aoqi@0: aoqi@0: friend class KeepAliveClosure; aoqi@0: friend class FollowStackClosure; aoqi@0: friend class AdjustPointerClosure; aoqi@0: friend class AdjustKlassClosure; aoqi@0: friend class FollowKlassClosure; aoqi@0: friend class InstanceClassLoaderKlass; aoqi@0: friend class RefProcTaskProxy; aoqi@0: aoqi@0: private: aoqi@0: static STWGCTimer _gc_timer; aoqi@0: static ParallelOldTracer _gc_tracer; aoqi@0: static elapsedTimer _accumulated_time; aoqi@0: static unsigned int _total_invocations; aoqi@0: static unsigned int _maximum_compaction_gc_num; aoqi@0: static jlong _time_of_last_gc; // ms aoqi@0: static CollectorCounters* _counters; aoqi@0: static ParMarkBitMap _mark_bitmap; aoqi@0: static ParallelCompactData _summary_data; aoqi@0: static IsAliveClosure _is_alive_closure; aoqi@0: static SpaceInfo _space_info[last_space_id]; aoqi@0: static bool _print_phases; aoqi@0: static AdjustPointerClosure _adjust_pointer_closure; aoqi@0: static AdjustKlassClosure _adjust_klass_closure; aoqi@0: aoqi@0: // Reference processing (used in ...follow_contents) aoqi@0: static ReferenceProcessor* _ref_processor; aoqi@0: aoqi@0: // Updated location of intArrayKlassObj. aoqi@0: static Klass* _updated_int_array_klass_obj; aoqi@0: aoqi@0: // Values computed at initialization and used by dead_wood_limiter(). aoqi@0: static double _dwl_mean; aoqi@0: static double _dwl_std_dev; aoqi@0: static double _dwl_first_term; aoqi@0: static double _dwl_adjustment; aoqi@0: #ifdef ASSERT aoqi@0: static bool _dwl_initialized; aoqi@0: #endif // #ifdef ASSERT aoqi@0: brutisso@6904: brutisso@6904: public: brutisso@6904: static ParallelOldTracer* gc_tracer() { return &_gc_tracer; } brutisso@6904: aoqi@0: private: aoqi@0: aoqi@0: static void initialize_space_info(); aoqi@0: aoqi@0: // Return true if details about individual phases should be printed. aoqi@0: static inline bool print_phases(); aoqi@0: aoqi@0: // Clear the marking bitmap and summary data that cover the specified space. aoqi@0: static void clear_data_covering_space(SpaceId id); aoqi@0: aoqi@0: static void pre_compact(PreGCValues* pre_gc_values); aoqi@0: static void post_compact(); aoqi@0: aoqi@0: // Mark live objects aoqi@0: static void marking_phase(ParCompactionManager* cm, aoqi@0: bool maximum_heap_compaction, aoqi@0: ParallelOldTracer *gc_tracer); aoqi@0: aoqi@0: template aoqi@0: static inline void follow_root(ParCompactionManager* cm, T* p); aoqi@0: aoqi@0: // Compute the dense prefix for the designated space. This is an experimental aoqi@0: // implementation currently not used in production. aoqi@0: static HeapWord* compute_dense_prefix_via_density(const SpaceId id, aoqi@0: bool maximum_compaction); aoqi@0: aoqi@0: // Methods used to compute the dense prefix. aoqi@0: aoqi@0: // Compute the value of the normal distribution at x = density. The mean and aoqi@0: // standard deviation are values saved by initialize_dead_wood_limiter(). aoqi@0: static inline double normal_distribution(double density); aoqi@0: aoqi@0: // Initialize the static vars used by dead_wood_limiter(). aoqi@0: static void initialize_dead_wood_limiter(); aoqi@0: aoqi@0: // Return the percentage of space that can be treated as "dead wood" (i.e., aoqi@0: // not reclaimed). aoqi@0: static double dead_wood_limiter(double density, size_t min_percent); aoqi@0: aoqi@0: // Find the first (left-most) region in the range [beg, end) that has at least aoqi@0: // dead_words of dead space to the left. The argument beg must be the first aoqi@0: // region in the space that is not completely live. aoqi@0: static RegionData* dead_wood_limit_region(const RegionData* beg, aoqi@0: const RegionData* end, aoqi@0: size_t dead_words); aoqi@0: aoqi@0: // Return a pointer to the first region in the range [beg, end) that is not aoqi@0: // completely full. aoqi@0: static RegionData* first_dead_space_region(const RegionData* beg, aoqi@0: const RegionData* end); aoqi@0: aoqi@0: // Return a value indicating the benefit or 'yield' if the compacted region aoqi@0: // were to start (or equivalently if the dense prefix were to end) at the aoqi@0: // candidate region. Higher values are better. aoqi@0: // aoqi@0: // The value is based on the amount of space reclaimed vs. the costs of (a) aoqi@0: // updating references in the dense prefix plus (b) copying objects and aoqi@0: // updating references in the compacted region. aoqi@0: static inline double reclaimed_ratio(const RegionData* const candidate, aoqi@0: HeapWord* const bottom, aoqi@0: HeapWord* const top, aoqi@0: HeapWord* const new_top); aoqi@0: aoqi@0: // Compute the dense prefix for the designated space. aoqi@0: static HeapWord* compute_dense_prefix(const SpaceId id, aoqi@0: bool maximum_compaction); aoqi@0: aoqi@0: // Return true if dead space crosses onto the specified Region; bit must be aoqi@0: // the bit index corresponding to the first word of the Region. aoqi@0: static inline bool dead_space_crosses_boundary(const RegionData* region, aoqi@0: idx_t bit); aoqi@0: aoqi@0: // Summary phase utility routine to fill dead space (if any) at the dense aoqi@0: // prefix boundary. Should only be called if the the dense prefix is aoqi@0: // non-empty. aoqi@0: static void fill_dense_prefix_end(SpaceId id); aoqi@0: aoqi@0: // Clear the summary data source_region field for the specified addresses. aoqi@0: static void clear_source_region(HeapWord* beg_addr, HeapWord* end_addr); aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: // Routines to provoke splitting a young gen space (ParallelOldGCSplitALot). aoqi@0: aoqi@0: // Fill the region [start, start + words) with live object(s). Only usable aoqi@0: // for the old and permanent generations. aoqi@0: static void fill_with_live_objects(SpaceId id, HeapWord* const start, aoqi@0: size_t words); aoqi@0: // Include the new objects in the summary data. aoqi@0: static void summarize_new_objects(SpaceId id, HeapWord* start); aoqi@0: aoqi@0: // Add live objects to a survivor space since it's rare that both survivors aoqi@0: // are non-empty. aoqi@0: static void provoke_split_fill_survivor(SpaceId id); aoqi@0: aoqi@0: // Add live objects and/or choose the dense prefix to provoke splitting. aoqi@0: static void provoke_split(bool & maximum_compaction); aoqi@0: #endif aoqi@0: aoqi@0: static void summarize_spaces_quick(); aoqi@0: static void summarize_space(SpaceId id, bool maximum_compaction); aoqi@0: static void summary_phase(ParCompactionManager* cm, bool maximum_compaction); aoqi@0: aoqi@0: // Adjust addresses in roots. Does not adjust addresses in heap. aoqi@0: static void adjust_roots(); aoqi@0: aoqi@0: DEBUG_ONLY(static void write_block_fill_histogram(outputStream* const out);) aoqi@0: aoqi@0: // Move objects to new locations. aoqi@0: static void compact_perm(ParCompactionManager* cm); aoqi@0: static void compact(); aoqi@0: aoqi@0: // Add available regions to the stack and draining tasks to the task queue. aoqi@0: static void enqueue_region_draining_tasks(GCTaskQueue* q, aoqi@0: uint parallel_gc_threads); aoqi@0: aoqi@0: // Add dense prefix update tasks to the task queue. aoqi@0: static void enqueue_dense_prefix_tasks(GCTaskQueue* q, aoqi@0: uint parallel_gc_threads); aoqi@0: aoqi@0: // Add region stealing tasks to the task queue. aoqi@0: static void enqueue_region_stealing_tasks( aoqi@0: GCTaskQueue* q, aoqi@0: ParallelTaskTerminator* terminator_ptr, aoqi@0: uint parallel_gc_threads); aoqi@0: aoqi@0: // If objects are left in eden after a collection, try to move the boundary aoqi@0: // and absorb them into the old gen. Returns true if eden was emptied. aoqi@0: static bool absorb_live_data_from_eden(PSAdaptiveSizePolicy* size_policy, aoqi@0: PSYoungGen* young_gen, aoqi@0: PSOldGen* old_gen); aoqi@0: aoqi@0: // Reset time since last full gc aoqi@0: static void reset_millis_since_last_gc(); aoqi@0: aoqi@0: public: aoqi@0: class MarkAndPushClosure: public OopClosure { aoqi@0: private: aoqi@0: ParCompactionManager* _compaction_manager; aoqi@0: public: aoqi@0: MarkAndPushClosure(ParCompactionManager* cm) : _compaction_manager(cm) { } aoqi@0: virtual void do_oop(oop* p); aoqi@0: virtual void do_oop(narrowOop* p); aoqi@0: }; aoqi@0: aoqi@0: // The one and only place to start following the classes. aoqi@0: // Should only be applied to the ClassLoaderData klasses list. aoqi@0: class FollowKlassClosure : public KlassClosure { aoqi@0: private: aoqi@0: MarkAndPushClosure* _mark_and_push_closure; aoqi@0: public: aoqi@0: FollowKlassClosure(MarkAndPushClosure* mark_and_push_closure) : aoqi@0: _mark_and_push_closure(mark_and_push_closure) { } aoqi@0: void do_klass(Klass* klass); aoqi@0: }; aoqi@0: aoqi@0: PSParallelCompact(); aoqi@0: aoqi@0: // Convenient accessor for Universe::heap(). aoqi@0: static ParallelScavengeHeap* gc_heap() { aoqi@0: return (ParallelScavengeHeap*)Universe::heap(); aoqi@0: } aoqi@0: aoqi@0: static void invoke(bool maximum_heap_compaction); aoqi@0: static bool invoke_no_policy(bool maximum_heap_compaction); aoqi@0: aoqi@0: static void post_initialize(); aoqi@0: // Perform initialization for PSParallelCompact that requires aoqi@0: // allocations. This should be called during the VM initialization aoqi@0: // at a pointer where it would be appropriate to return a JNI_ENOMEM aoqi@0: // in the event of a failure. aoqi@0: static bool initialize(); aoqi@0: aoqi@0: // Closure accessors aoqi@0: static OopClosure* adjust_pointer_closure() { return (OopClosure*)&_adjust_pointer_closure; } aoqi@0: static KlassClosure* adjust_klass_closure() { return (KlassClosure*)&_adjust_klass_closure; } aoqi@0: static BoolObjectClosure* is_alive_closure() { return (BoolObjectClosure*)&_is_alive_closure; } aoqi@0: aoqi@0: // Public accessors aoqi@0: static elapsedTimer* accumulated_time() { return &_accumulated_time; } aoqi@0: static unsigned int total_invocations() { return _total_invocations; } aoqi@0: static CollectorCounters* counters() { return _counters; } aoqi@0: aoqi@0: // Used to add tasks aoqi@0: static GCTaskManager* const gc_task_manager(); aoqi@0: static Klass* updated_int_array_klass_obj() { aoqi@0: return _updated_int_array_klass_obj; aoqi@0: } aoqi@0: aoqi@0: // Marking support aoqi@0: static inline bool mark_obj(oop obj); aoqi@0: static inline bool is_marked(oop obj); aoqi@0: // Check mark and maybe push on marking stack aoqi@0: template static inline void mark_and_push(ParCompactionManager* cm, aoqi@0: T* p); aoqi@0: template static inline void adjust_pointer(T* p); aoqi@0: aoqi@0: static inline void follow_klass(ParCompactionManager* cm, Klass* klass); aoqi@0: aoqi@0: static void follow_class_loader(ParCompactionManager* cm, aoqi@0: ClassLoaderData* klass); aoqi@0: aoqi@0: // Compaction support. aoqi@0: // Return true if p is in the range [beg_addr, end_addr). aoqi@0: static inline bool is_in(HeapWord* p, HeapWord* beg_addr, HeapWord* end_addr); aoqi@0: static inline bool is_in(oop* p, HeapWord* beg_addr, HeapWord* end_addr); aoqi@0: aoqi@0: // Convenience wrappers for per-space data kept in _space_info. aoqi@0: static inline MutableSpace* space(SpaceId space_id); aoqi@0: static inline HeapWord* new_top(SpaceId space_id); aoqi@0: static inline HeapWord* dense_prefix(SpaceId space_id); aoqi@0: static inline ObjectStartArray* start_array(SpaceId space_id); aoqi@0: aoqi@0: // Move and update the live objects in the specified space. aoqi@0: static void move_and_update(ParCompactionManager* cm, SpaceId space_id); aoqi@0: aoqi@0: // Process the end of the given region range in the dense prefix. aoqi@0: // This includes saving any object not updated. aoqi@0: static void dense_prefix_regions_epilogue(ParCompactionManager* cm, aoqi@0: size_t region_start_index, aoqi@0: size_t region_end_index, aoqi@0: idx_t exiting_object_offset, aoqi@0: idx_t region_offset_start, aoqi@0: idx_t region_offset_end); aoqi@0: aoqi@0: // Update a region in the dense prefix. For each live object aoqi@0: // in the region, update it's interior references. For each aoqi@0: // dead object, fill it with deadwood. Dead space at the end aoqi@0: // of a region range will be filled to the start of the next aoqi@0: // live object regardless of the region_index_end. None of the aoqi@0: // objects in the dense prefix move and dead space is dead aoqi@0: // (holds only dead objects that don't need any processing), so aoqi@0: // dead space can be filled in any order. aoqi@0: static void update_and_deadwood_in_dense_prefix(ParCompactionManager* cm, aoqi@0: SpaceId space_id, aoqi@0: size_t region_index_start, aoqi@0: size_t region_index_end); aoqi@0: aoqi@0: // Return the address of the count + 1st live word in the range [beg, end). aoqi@0: static HeapWord* skip_live_words(HeapWord* beg, HeapWord* end, size_t count); aoqi@0: aoqi@0: // Return the address of the word to be copied to dest_addr, which must be aoqi@0: // aligned to a region boundary. aoqi@0: static HeapWord* first_src_addr(HeapWord* const dest_addr, aoqi@0: SpaceId src_space_id, aoqi@0: size_t src_region_idx); aoqi@0: aoqi@0: // Determine the next source region, set closure.source() to the start of the aoqi@0: // new region return the region index. Parameter end_addr is the address one aoqi@0: // beyond the end of source range just processed. If necessary, switch to a aoqi@0: // new source space and set src_space_id (in-out parameter) and src_space_top aoqi@0: // (out parameter) accordingly. aoqi@0: static size_t next_src_region(MoveAndUpdateClosure& closure, aoqi@0: SpaceId& src_space_id, aoqi@0: HeapWord*& src_space_top, aoqi@0: HeapWord* end_addr); aoqi@0: aoqi@0: // Decrement the destination count for each non-empty source region in the aoqi@0: // range [beg_region, region(region_align_up(end_addr))). If the destination aoqi@0: // count for a region goes to 0 and it needs to be filled, enqueue it. aoqi@0: static void decrement_destination_counts(ParCompactionManager* cm, aoqi@0: SpaceId src_space_id, aoqi@0: size_t beg_region, aoqi@0: HeapWord* end_addr); aoqi@0: aoqi@0: // Fill a region, copying objects from one or more source regions. aoqi@0: static void fill_region(ParCompactionManager* cm, size_t region_idx); aoqi@0: static void fill_and_update_region(ParCompactionManager* cm, size_t region) { aoqi@0: fill_region(cm, region); aoqi@0: } aoqi@0: aoqi@0: // Fill in the block table for the specified region. aoqi@0: static void fill_blocks(size_t region_idx); aoqi@0: aoqi@0: // Update the deferred objects in the space. aoqi@0: static void update_deferred_objects(ParCompactionManager* cm, SpaceId id); aoqi@0: aoqi@0: static ParMarkBitMap* mark_bitmap() { return &_mark_bitmap; } aoqi@0: static ParallelCompactData& summary_data() { return _summary_data; } aoqi@0: aoqi@0: // Reference Processing aoqi@0: static ReferenceProcessor* const ref_processor() { return _ref_processor; } aoqi@0: aoqi@0: static STWGCTimer* gc_timer() { return &_gc_timer; } aoqi@0: aoqi@0: // Return the SpaceId for the given address. aoqi@0: static SpaceId space_id(HeapWord* addr); aoqi@0: aoqi@0: // Time since last full gc (in milliseconds). aoqi@0: static jlong millis_since_last_gc(); aoqi@0: aoqi@0: static void print_on_error(outputStream* st); aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: // Debugging support. aoqi@0: static const char* space_names[last_space_id]; aoqi@0: static void print_region_ranges(); aoqi@0: static void print_dense_prefix_stats(const char* const algorithm, aoqi@0: const SpaceId id, aoqi@0: const bool maximum_compaction, aoqi@0: HeapWord* const addr); aoqi@0: static void summary_phase_msg(SpaceId dst_space_id, aoqi@0: HeapWord* dst_beg, HeapWord* dst_end, aoqi@0: SpaceId src_space_id, aoqi@0: HeapWord* src_beg, HeapWord* src_end); aoqi@0: #endif // #ifndef PRODUCT aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: // Sanity check the new location of a word in the heap. aoqi@0: static inline void check_new_location(HeapWord* old_addr, HeapWord* new_addr); aoqi@0: // Verify that all the regions have been emptied. aoqi@0: static void verify_complete(SpaceId space_id); aoqi@0: #endif // #ifdef ASSERT aoqi@0: }; aoqi@0: aoqi@0: inline bool PSParallelCompact::mark_obj(oop obj) { aoqi@0: const int obj_size = obj->size(); aoqi@0: if (mark_bitmap()->mark_obj(obj, obj_size)) { aoqi@0: _summary_data.add_obj(obj, obj_size); fujie@124: #ifdef MIPS64 aoqi@8019: if (UseSyncLevel >= 2000) OrderAccess::fence(); fujie@124: #endif aoqi@0: return true; aoqi@0: } else { aoqi@0: return false; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: inline bool PSParallelCompact::is_marked(oop obj) { aoqi@0: return mark_bitmap()->is_marked(obj); aoqi@0: } aoqi@0: aoqi@0: template aoqi@0: inline void PSParallelCompact::follow_root(ParCompactionManager* cm, T* p) { aoqi@0: assert(!Universe::heap()->is_in_reserved(p), aoqi@0: "roots shouldn't be things within the heap"); aoqi@0: aoqi@0: T heap_oop = oopDesc::load_heap_oop(p); aoqi@0: if (!oopDesc::is_null(heap_oop)) { aoqi@0: oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); aoqi@0: if (mark_bitmap()->is_unmarked(obj)) { aoqi@0: if (mark_obj(obj)) { aoqi@0: obj->follow_contents(cm); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: cm->follow_marking_stacks(); aoqi@0: } aoqi@0: aoqi@0: template aoqi@0: inline void PSParallelCompact::mark_and_push(ParCompactionManager* cm, T* p) { aoqi@0: T heap_oop = oopDesc::load_heap_oop(p); aoqi@0: if (!oopDesc::is_null(heap_oop)) { aoqi@0: oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); aoqi@0: if (mark_bitmap()->is_unmarked(obj) && mark_obj(obj)) { aoqi@0: cm->push(obj); fujie@124: #ifdef MIPS64 aoqi@8019: if (UseSyncLevel >= 2000) OrderAccess::fence(); fujie@124: #endif aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: template aoqi@0: inline void PSParallelCompact::adjust_pointer(T* p) { aoqi@0: T heap_oop = oopDesc::load_heap_oop(p); aoqi@0: if (!oopDesc::is_null(heap_oop)) { aoqi@0: oop obj = oopDesc::decode_heap_oop_not_null(heap_oop); aoqi@0: oop new_obj = (oop)summary_data().calc_new_pointer(obj); aoqi@0: assert(new_obj != NULL, // is forwarding ptr? aoqi@0: "should be forwarded"); aoqi@0: // Just always do the update unconditionally? aoqi@0: if (new_obj != NULL) { aoqi@0: assert(Universe::heap()->is_in_reserved(new_obj), aoqi@0: "should be in object space"); aoqi@0: oopDesc::encode_store_heap_oop_not_null(p, new_obj); aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: inline void PSParallelCompact::follow_klass(ParCompactionManager* cm, Klass* klass) { aoqi@0: oop holder = klass->klass_holder(); aoqi@0: PSParallelCompact::mark_and_push(cm, &holder); aoqi@0: } aoqi@0: aoqi@0: template aoqi@0: inline void PSParallelCompact::KeepAliveClosure::do_oop_work(T* p) { aoqi@0: mark_and_push(_compaction_manager, p); aoqi@0: } aoqi@0: aoqi@0: inline bool PSParallelCompact::print_phases() { aoqi@0: return _print_phases; aoqi@0: } aoqi@0: aoqi@0: inline double PSParallelCompact::normal_distribution(double density) { aoqi@0: assert(_dwl_initialized, "uninitialized"); aoqi@0: const double squared_term = (density - _dwl_mean) / _dwl_std_dev; aoqi@0: return _dwl_first_term * exp(-0.5 * squared_term * squared_term); aoqi@0: } aoqi@0: aoqi@0: inline bool aoqi@0: PSParallelCompact::dead_space_crosses_boundary(const RegionData* region, aoqi@0: idx_t bit) aoqi@0: { aoqi@0: assert(bit > 0, "cannot call this for the first bit/region"); aoqi@0: assert(_summary_data.region_to_addr(region) == _mark_bitmap.bit_to_addr(bit), aoqi@0: "sanity check"); aoqi@0: aoqi@0: // Dead space crosses the boundary if (1) a partial object does not extend aoqi@0: // onto the region, (2) an object does not start at the beginning of the aoqi@0: // region, and (3) an object does not end at the end of the prior region. aoqi@0: return region->partial_obj_size() == 0 && aoqi@0: !_mark_bitmap.is_obj_beg(bit) && aoqi@0: !_mark_bitmap.is_obj_end(bit - 1); aoqi@0: } aoqi@0: aoqi@0: inline bool aoqi@0: PSParallelCompact::is_in(HeapWord* p, HeapWord* beg_addr, HeapWord* end_addr) { aoqi@0: return p >= beg_addr && p < end_addr; aoqi@0: } aoqi@0: aoqi@0: inline bool aoqi@0: PSParallelCompact::is_in(oop* p, HeapWord* beg_addr, HeapWord* end_addr) { aoqi@0: return is_in((HeapWord*)p, beg_addr, end_addr); aoqi@0: } aoqi@0: aoqi@0: inline MutableSpace* PSParallelCompact::space(SpaceId id) { aoqi@0: assert(id < last_space_id, "id out of range"); aoqi@0: return _space_info[id].space(); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* PSParallelCompact::new_top(SpaceId id) { aoqi@0: assert(id < last_space_id, "id out of range"); aoqi@0: return _space_info[id].new_top(); aoqi@0: } aoqi@0: aoqi@0: inline HeapWord* PSParallelCompact::dense_prefix(SpaceId id) { aoqi@0: assert(id < last_space_id, "id out of range"); aoqi@0: return _space_info[id].dense_prefix(); aoqi@0: } aoqi@0: aoqi@0: inline ObjectStartArray* PSParallelCompact::start_array(SpaceId id) { aoqi@0: assert(id < last_space_id, "id out of range"); aoqi@0: return _space_info[id].start_array(); aoqi@0: } aoqi@0: aoqi@0: #ifdef ASSERT aoqi@0: inline void aoqi@0: PSParallelCompact::check_new_location(HeapWord* old_addr, HeapWord* new_addr) aoqi@0: { aoqi@0: assert(old_addr >= new_addr || space_id(old_addr) != space_id(new_addr), aoqi@0: "must move left or to a different space"); aoqi@0: assert(is_object_aligned((intptr_t)old_addr) && is_object_aligned((intptr_t)new_addr), aoqi@0: "checking alignment"); aoqi@0: } aoqi@0: #endif // ASSERT aoqi@0: aoqi@0: class MoveAndUpdateClosure: public ParMarkBitMapClosure { aoqi@0: public: aoqi@0: inline MoveAndUpdateClosure(ParMarkBitMap* bitmap, ParCompactionManager* cm, aoqi@0: ObjectStartArray* start_array, aoqi@0: HeapWord* destination, size_t words); aoqi@0: aoqi@0: // Accessors. aoqi@0: HeapWord* destination() const { return _destination; } aoqi@0: aoqi@0: // If the object will fit (size <= words_remaining()), copy it to the current aoqi@0: // destination, update the interior oops and the start array and return either aoqi@0: // full (if the closure is full) or incomplete. If the object will not fit, aoqi@0: // return would_overflow. aoqi@0: virtual IterationStatus do_addr(HeapWord* addr, size_t size); aoqi@0: aoqi@0: // Copy enough words to fill this closure, starting at source(). Interior aoqi@0: // oops and the start array are not updated. Return full. aoqi@0: IterationStatus copy_until_full(); aoqi@0: aoqi@0: // Copy enough words to fill this closure or to the end of an object, aoqi@0: // whichever is smaller, starting at source(). Interior oops and the start aoqi@0: // array are not updated. aoqi@0: void copy_partial_obj(); aoqi@0: aoqi@0: protected: aoqi@0: // Update variables to indicate that word_count words were processed. aoqi@0: inline void update_state(size_t word_count); aoqi@0: aoqi@0: protected: aoqi@0: ObjectStartArray* const _start_array; aoqi@0: HeapWord* _destination; // Next addr to be written. aoqi@0: }; aoqi@0: aoqi@0: inline aoqi@0: MoveAndUpdateClosure::MoveAndUpdateClosure(ParMarkBitMap* bitmap, aoqi@0: ParCompactionManager* cm, aoqi@0: ObjectStartArray* start_array, aoqi@0: HeapWord* destination, aoqi@0: size_t words) : aoqi@0: ParMarkBitMapClosure(bitmap, cm, words), _start_array(start_array) aoqi@0: { aoqi@0: _destination = destination; aoqi@0: } aoqi@0: aoqi@0: inline void MoveAndUpdateClosure::update_state(size_t words) aoqi@0: { aoqi@0: decrement_words_remaining(words); aoqi@0: _source += words; aoqi@0: _destination += words; aoqi@0: } aoqi@0: aoqi@0: class UpdateOnlyClosure: public ParMarkBitMapClosure { aoqi@0: private: aoqi@0: const PSParallelCompact::SpaceId _space_id; aoqi@0: ObjectStartArray* const _start_array; aoqi@0: aoqi@0: public: aoqi@0: UpdateOnlyClosure(ParMarkBitMap* mbm, aoqi@0: ParCompactionManager* cm, aoqi@0: PSParallelCompact::SpaceId space_id); aoqi@0: aoqi@0: // Update the object. aoqi@0: virtual IterationStatus do_addr(HeapWord* addr, size_t words); aoqi@0: aoqi@0: inline void do_addr(HeapWord* addr); aoqi@0: }; aoqi@0: aoqi@0: inline void UpdateOnlyClosure::do_addr(HeapWord* addr) aoqi@0: { aoqi@0: _start_array->allocate_block(addr); aoqi@0: oop(addr)->update_contents(compaction_manager()); aoqi@0: } aoqi@0: aoqi@0: class FillClosure: public ParMarkBitMapClosure aoqi@0: { aoqi@0: public: aoqi@0: FillClosure(ParCompactionManager* cm, PSParallelCompact::SpaceId space_id) : aoqi@0: ParMarkBitMapClosure(PSParallelCompact::mark_bitmap(), cm), aoqi@0: _start_array(PSParallelCompact::start_array(space_id)) aoqi@0: { aoqi@0: assert(space_id == PSParallelCompact::old_space_id, aoqi@0: "cannot use FillClosure in the young gen"); aoqi@0: } aoqi@0: aoqi@0: virtual IterationStatus do_addr(HeapWord* addr, size_t size) { aoqi@0: CollectedHeap::fill_with_objects(addr, size); aoqi@0: HeapWord* const end = addr + size; aoqi@0: do { aoqi@0: _start_array->allocate_block(addr); aoqi@0: addr += oop(addr)->size(); aoqi@0: } while (addr < end); aoqi@0: return ParMarkBitMap::incomplete; aoqi@0: } aoqi@0: aoqi@0: private: aoqi@0: ObjectStartArray* const _start_array; aoqi@0: }; aoqi@0: aoqi@0: #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSPARALLELCOMPACT_HPP