| 1 | /* |
| 2 | * Copyright (c) 2018, 2019, Oracle and/or its affiliates. All rights reserved. |
| 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
| 4 | * |
| 5 | * This code is free software; you can redistribute it and/or modify it |
| 6 | * under the terms of the GNU General Public License version 2 only, as |
| 7 | * published by the Free Software Foundation. |
| 8 | * |
| 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
| 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
| 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
| 12 | * version 2 for more details (a copy is included in the LICENSE file that |
| 13 | * accompanied this code). |
| 14 | * |
| 15 | * You should have received a copy of the GNU General Public License version |
| 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
| 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
| 18 | * |
| 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
| 20 | * or visit www.oracle.com if you need additional information or have any |
| 21 | * questions. |
| 22 | * |
| 23 | */ |
| 24 | |
| 25 | #ifndef SHARE_GC_SHARED_MARKBITMAP_INLINE_HPP |
| 26 | #define SHARE_GC_SHARED_MARKBITMAP_INLINE_HPP |
| 27 | |
| 28 | #include "gc/shared/collectedHeap.hpp" |
| 29 | #include "gc/shared/markBitMap.hpp" |
| 30 | #include "memory/memRegion.hpp" |
| 31 | #include "utilities/align.hpp" |
| 32 | #include "utilities/bitMap.inline.hpp" |
| 33 | |
| 34 | inline HeapWord* MarkBitMap::get_next_marked_addr(const HeapWord* addr, |
| 35 | const HeapWord* limit) const { |
| 36 | assert(limit != NULL, "limit must not be NULL" ); |
| 37 | // Round addr up to a possible object boundary to be safe. |
| 38 | size_t const addr_offset = addr_to_offset(align_up(addr, HeapWordSize << _shifter)); |
| 39 | size_t const limit_offset = addr_to_offset(limit); |
| 40 | size_t const nextOffset = _bm.get_next_one_offset(addr_offset, limit_offset); |
| 41 | return offset_to_addr(nextOffset); |
| 42 | } |
| 43 | |
| 44 | inline void MarkBitMap::mark(HeapWord* addr) { |
| 45 | check_mark(addr); |
| 46 | _bm.set_bit(addr_to_offset(addr)); |
| 47 | } |
| 48 | |
| 49 | inline void MarkBitMap::clear(HeapWord* addr) { |
| 50 | check_mark(addr); |
| 51 | _bm.clear_bit(addr_to_offset(addr)); |
| 52 | } |
| 53 | |
| 54 | inline bool MarkBitMap::par_mark(HeapWord* addr) { |
| 55 | check_mark(addr); |
| 56 | return _bm.par_set_bit(addr_to_offset(addr)); |
| 57 | } |
| 58 | |
| 59 | inline bool MarkBitMap::par_mark(oop obj) { |
| 60 | return par_mark((HeapWord*) obj); |
| 61 | } |
| 62 | |
| 63 | inline bool MarkBitMap::is_marked(oop obj) const{ |
| 64 | return is_marked((HeapWord*) obj); |
| 65 | } |
| 66 | |
| 67 | inline void MarkBitMap::clear(oop obj) { |
| 68 | clear((HeapWord*) obj); |
| 69 | } |
| 70 | |
| 71 | #endif // SHARE_GC_SHARED_MARKBITMAP_INLINE_HPP |
| 72 | |