Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shared/markBitMap.hpp
38920 views
/*1* Copyright (c) 2015, 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_SHARED_CMBITMAP_HPP25#define SHARE_VM_GC_SHARED_CMBITMAP_HPP2627#include "memory/memRegion.hpp"28#include "oops/oop.inline.hpp"29#include "utilities/bitMap.hpp"30#include "utilities/globalDefinitions.hpp"3132// A generic CM bit map. This is essentially a wrapper around the BitMap33// class, with one bit per (1<<_shifter) HeapWords.3435class MarkBitMapRO VALUE_OBJ_CLASS_SPEC {36protected:37MemRegion _covered; // The heap area covered by this bitmap.38HeapWord* _bmStartWord; // base address of range covered by map39size_t _bmWordSize; // map size (in #HeapWords covered)40const int _shifter; // map to char or bit41BitMap _bm; // the bit map itself4243public:44// constructor45MarkBitMapRO(int shifter);4647// inquiries48HeapWord* startWord() const { return _bmStartWord; }49// the following is one past the last word in space50HeapWord* endWord() const { return _bmStartWord + _bmWordSize; }5152// read marks5354bool isMarked(HeapWord* addr) const {55assert(_bmStartWord <= addr && addr < (_bmStartWord + _bmWordSize),56"outside underlying space?");57return _bm.at(heapWordToOffset(addr));58}5960// iteration61inline bool iterate(BitMapClosure* cl, MemRegion mr);6263// Return the address corresponding to the next marked bit at or after64// "addr", and before "limit", if "limit" is non-NULL. If there is no65// such bit, returns "limit" if that is non-NULL, or else "endWord()".66inline HeapWord* getNextMarkedWordAddress(const HeapWord* addr,67const HeapWord* limit = NULL) const;6869// conversion utilities70HeapWord* offsetToHeapWord(size_t offset) const {71return _bmStartWord + (offset << _shifter);72}73size_t heapWordToOffset(const HeapWord* addr) const {74return pointer_delta(addr, _bmStartWord) >> _shifter;75}7677// The argument addr should be the start address of a valid object78inline HeapWord* nextObject(HeapWord* addr);7980void print_on_error(outputStream* st, const char* prefix) const;8182// debugging83NOT_PRODUCT(bool covers(MemRegion rs) const;)84};8586class MarkBitMap : public MarkBitMapRO {87private:88// Clear bitmap range89void do_clear(MemRegion mr, bool large);9091public:92static size_t compute_size(size_t heap_size);93// Returns the amount of bytes on the heap between two marks in the bitmap.94static size_t mark_distance();95// Returns how many bytes (or bits) of the heap a single byte (or bit) of the96// mark bitmap corresponds to. This is the same as the mark distance above. static size_t heap_map_factor() {97static size_t heap_map_factor() {98return mark_distance();99}100101MarkBitMap() : MarkBitMapRO(LogMinObjAlignment) {}102103// Initializes the underlying BitMap to cover the given area.104void initialize(MemRegion heap, MemRegion bitmap);105106// Write marks.107inline void mark(HeapWord* addr);108inline void clear(HeapWord* addr);109inline bool parMark(HeapWord* addr);110111// Clear range. For larger regions, use *_large.112void clear() { do_clear(_covered, true); }113void clear_range(MemRegion mr) { do_clear(mr, false); }114void clear_range_large(MemRegion mr) { do_clear(mr, true); }115};116117#endif // SHARE_VM_GC_SHARED_CMBITMAP_HPP118119120