Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/shared/markBitMap.inline.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_INLINE_HPP25#define SHARE_VM_GC_SHARED_CMBITMAP_INLINE_HPP2627#include "gc_implementation/shared/markBitMap.hpp"28#include "utilities/bitMap.inline.hpp"2930inline HeapWord* MarkBitMapRO::getNextMarkedWordAddress(const HeapWord* addr,31const HeapWord* limit) const {32// First we must round addr *up* to a possible object boundary.33addr = (HeapWord*)align_size_up((intptr_t)addr,34HeapWordSize << _shifter);35size_t addrOffset = heapWordToOffset(addr);36assert(limit != NULL, "limit must not be NULL");37size_t limitOffset = heapWordToOffset(limit);38size_t nextOffset = _bm.get_next_one_offset(addrOffset, limitOffset);39HeapWord* nextAddr = offsetToHeapWord(nextOffset);40assert(nextAddr >= addr, "get_next_one postcondition");41assert(nextAddr == limit || isMarked(nextAddr),42"get_next_one postcondition");43return nextAddr;44}4546inline bool MarkBitMapRO::iterate(BitMapClosure* cl, MemRegion mr) {47HeapWord* start_addr = MAX2(startWord(), mr.start());48HeapWord* end_addr = MIN2(endWord(), mr.end());4950if (end_addr > start_addr) {51// Right-open interval [start-offset, end-offset).52BitMap::idx_t start_offset = heapWordToOffset(start_addr);53BitMap::idx_t end_offset = heapWordToOffset(end_addr);5455start_offset = _bm.get_next_one_offset(start_offset, end_offset);56while (start_offset < end_offset) {57if (!cl->do_bit(start_offset)) {58return false;59}60HeapWord* next_addr = MIN2(nextObject(offsetToHeapWord(start_offset)), end_addr);61BitMap::idx_t next_offset = heapWordToOffset(next_addr);62start_offset = _bm.get_next_one_offset(next_offset, end_offset);63}64}65return true;66}6768// The argument addr should be the start address of a valid object69HeapWord* MarkBitMapRO::nextObject(HeapWord* addr) {70oop obj = (oop) addr;71HeapWord* res = addr + obj->size();72assert(offsetToHeapWord(heapWordToOffset(res)) == res, "sanity");73return res;74}7576#define check_mark(addr) \77assert(_bmStartWord <= (addr) && (addr) < (_bmStartWord + _bmWordSize), \78"outside underlying space?"); \79/* assert(G1CollectedHeap::heap()->is_in_exact(addr), \80err_msg("Trying to access not available bitmap "PTR_FORMAT \81" corresponding to "PTR_FORMAT" (%u)", \82p2i(this), p2i(addr), G1CollectedHeap::heap()->addr_to_region(addr))); */8384inline void MarkBitMap::mark(HeapWord* addr) {85check_mark(addr);86_bm.set_bit(heapWordToOffset(addr));87}8889inline void MarkBitMap::clear(HeapWord* addr) {90check_mark(addr);91_bm.clear_bit(heapWordToOffset(addr));92}9394inline bool MarkBitMap::parMark(HeapWord* addr) {95check_mark(addr);96return _bm.par_set_bit(heapWordToOffset(addr));97}9899#undef check_mark100101#endif // SHARE_VM_GC_SHARED_CMBITMAP_INLINE_HPP102103104