< prev index next >

src/hotspot/share/gc/shenandoah/shenandoahMarkingContext.inline.hpp

Print this page

  1 /*
  2  * Copyright (c) 2018, 2019, Red Hat, Inc. 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_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP
 26 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP
 27 
 28 #include "gc/shenandoah/shenandoahMarkingContext.hpp"
 29 
 30 #include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp"

 31 
 32 inline bool ShenandoahMarkingContext::mark_strong(oop obj, bool& was_upgraded) {
 33   return !allocated_after_mark_start(obj) && _mark_bit_map.mark_strong(cast_from_oop<HeapWord*>(obj), was_upgraded);
 34 }
 35 
 36 inline bool ShenandoahMarkingContext::mark_weak(oop obj) {
 37   return !allocated_after_mark_start(obj) && _mark_bit_map.mark_weak(cast_from_oop<HeapWord *>(obj));
 38 }
 39 
 40 inline bool ShenandoahMarkingContext::is_marked(oop obj) const {
 41   return is_marked(cast_from_oop<HeapWord*>(obj));
 42 }
 43 
 44 inline bool ShenandoahMarkingContext::is_marked(HeapWord* raw_obj) const {
 45   return allocated_after_mark_start(raw_obj) || _mark_bit_map.is_marked(raw_obj);
 46 }
 47 
 48 inline bool ShenandoahMarkingContext::is_marked_strong(oop obj) const {
 49   return is_marked_strong(cast_from_oop<HeapWord*>(obj));
 50 }
 51 
 52 inline bool ShenandoahMarkingContext::is_marked_strong(HeapWord* raw_obj) const {
 53   return allocated_after_mark_start(raw_obj) || _mark_bit_map.is_marked_strong(raw_obj);
 54 }
 55 
 56 inline bool ShenandoahMarkingContext::is_marked_weak(oop obj) const {
 57   return allocated_after_mark_start(obj) || _mark_bit_map.is_marked_weak(cast_from_oop<HeapWord *>(obj));
 58 }
 59 
 60 inline HeapWord* ShenandoahMarkingContext::get_next_marked_addr(HeapWord* start, HeapWord* limit) const {








 61   return _mark_bit_map.get_next_marked_addr(start, limit);
 62 }
 63 
 64 inline bool ShenandoahMarkingContext::allocated_after_mark_start(oop obj) const {
 65   HeapWord* addr = cast_from_oop<HeapWord*>(obj);
 66   return allocated_after_mark_start(addr);
 67 }
 68 
 69 inline bool ShenandoahMarkingContext::allocated_after_mark_start(HeapWord* addr) const {
 70   uintx index = ((uintx) addr) >> ShenandoahHeapRegion::region_size_bytes_shift();
 71   HeapWord* top_at_mark_start = _top_at_mark_starts[index];
 72   bool alloc_after_mark_start = addr >= top_at_mark_start;
 73   return alloc_after_mark_start;
 74 }
 75 
 76 inline void ShenandoahMarkingContext::capture_top_at_mark_start(ShenandoahHeapRegion *r) {





 77   size_t idx = r->index();
 78   HeapWord* old_tams = _top_at_mark_starts_base[idx];
 79   HeapWord* new_tams = r->top();
 80 
 81   assert(new_tams >= old_tams,
 82          "Region " SIZE_FORMAT", TAMS updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT,
 83          idx, p2i(old_tams), p2i(new_tams));
 84   assert(is_bitmap_clear_range(old_tams, new_tams),



 85          "Region " SIZE_FORMAT ", bitmap should be clear while adjusting TAMS: " PTR_FORMAT " -> " PTR_FORMAT,
 86          idx, p2i(old_tams), p2i(new_tams));
 87 



 88   _top_at_mark_starts_base[idx] = new_tams;
 89   _top_bitmaps[idx] = new_tams;
 90 }
 91 
 92 inline void ShenandoahMarkingContext::reset_top_at_mark_start(ShenandoahHeapRegion* r) {
 93   _top_at_mark_starts_base[r->index()] = r->bottom();
 94 }
 95 
 96 inline HeapWord* ShenandoahMarkingContext::top_at_mark_start(ShenandoahHeapRegion* r) const {
 97   return _top_at_mark_starts_base[r->index()];
 98 }
 99 
100 inline void ShenandoahMarkingContext::reset_top_bitmap(ShenandoahHeapRegion* r) {
101   assert(is_bitmap_clear_range(r->bottom(), r->end()),
102          "Region " SIZE_FORMAT " should have no marks in bitmap", r->index());
103   _top_bitmaps[r->index()] = r->bottom();
104 }
105 
106 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP

  1 /*
  2  * Copyright (c) 2018, 2019, Red Hat, Inc. All rights reserved.
  3  * Copyright Amazon.com Inc. or its affiliates. All Rights Reserved.
  4  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  5  *
  6  * This code is free software; you can redistribute it and/or modify it
  7  * under the terms of the GNU General Public License version 2 only, as
  8  * published by the Free Software Foundation.
  9  *
 10  * This code is distributed in the hope that it will be useful, but WITHOUT
 11  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
 12  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
 13  * version 2 for more details (a copy is included in the LICENSE file that
 14  * accompanied this code).
 15  *
 16  * You should have received a copy of the GNU General Public License version
 17  * 2 along with this work; if not, write to the Free Software Foundation,
 18  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 19  *
 20  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
 21  * or visit www.oracle.com if you need additional information or have any
 22  * questions.
 23  *
 24  */
 25 
 26 #ifndef SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP
 27 #define SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP
 28 
 29 #include "gc/shenandoah/shenandoahMarkingContext.hpp"

 30 #include "gc/shenandoah/shenandoahMarkBitMap.inline.hpp"
 31 #include "logging/log.hpp"
 32 
 33 inline bool ShenandoahMarkingContext::mark_strong(oop obj, bool& was_upgraded) {
 34   return !allocated_after_mark_start(obj) && _mark_bit_map.mark_strong(cast_from_oop<HeapWord*>(obj), was_upgraded);
 35 }
 36 
 37 inline bool ShenandoahMarkingContext::mark_weak(oop obj) {
 38   return !allocated_after_mark_start(obj) && _mark_bit_map.mark_weak(cast_from_oop<HeapWord *>(obj));
 39 }
 40 
 41 inline bool ShenandoahMarkingContext::is_marked(oop obj) const {
 42   return is_marked(cast_from_oop<HeapWord*>(obj));
 43 }
 44 
 45 inline bool ShenandoahMarkingContext::is_marked(HeapWord* raw_obj) const {
 46   return allocated_after_mark_start(raw_obj) || _mark_bit_map.is_marked(raw_obj);
 47 }
 48 
 49 inline bool ShenandoahMarkingContext::is_marked_strong(oop obj) const {
 50   return is_marked_strong(cast_from_oop<HeapWord*>(obj));
 51 }
 52 
 53 inline bool ShenandoahMarkingContext::is_marked_strong(HeapWord* raw_obj) const {
 54   return allocated_after_mark_start(raw_obj) || _mark_bit_map.is_marked_strong(raw_obj);
 55 }
 56 
 57 inline bool ShenandoahMarkingContext::is_marked_weak(oop obj) const {
 58   return allocated_after_mark_start(obj) || _mark_bit_map.is_marked_weak(cast_from_oop<HeapWord *>(obj));
 59 }
 60 
 61 inline bool ShenandoahMarkingContext::is_marked_or_old(oop obj) const {
 62   return is_marked(obj) || ShenandoahHeap::heap()->is_old(obj);
 63 }
 64 
 65 inline bool ShenandoahMarkingContext::is_marked_strong_or_old(oop obj) const {
 66   return is_marked_strong(obj) || ShenandoahHeap::heap()->is_old(obj);
 67 }
 68 
 69 inline HeapWord* ShenandoahMarkingContext::get_next_marked_addr(const HeapWord* start, const HeapWord* limit) const {
 70   return _mark_bit_map.get_next_marked_addr(start, limit);
 71 }
 72 
 73 inline bool ShenandoahMarkingContext::allocated_after_mark_start(oop obj) const {
 74   const HeapWord* addr = cast_from_oop<HeapWord*>(obj);
 75   return allocated_after_mark_start(addr);
 76 }
 77 
 78 inline bool ShenandoahMarkingContext::allocated_after_mark_start(const HeapWord* addr) const {
 79   uintx index = ((uintx) addr) >> ShenandoahHeapRegion::region_size_bytes_shift();
 80   HeapWord* top_at_mark_start = _top_at_mark_starts[index];
 81   const bool alloc_after_mark_start = addr >= top_at_mark_start;
 82   return alloc_after_mark_start;
 83 }
 84 
 85 inline void ShenandoahMarkingContext::capture_top_at_mark_start(ShenandoahHeapRegion *r) {
 86   if (!r->is_affiliated()) {
 87     // Non-affiliated regions do not need their TAMS updated
 88     return;
 89   }
 90 
 91   size_t idx = r->index();
 92   HeapWord* old_tams = _top_at_mark_starts_base[idx];
 93   HeapWord* new_tams = r->top();
 94 
 95   assert(new_tams >= old_tams,
 96          "Region " SIZE_FORMAT", TAMS updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT,
 97          idx, p2i(old_tams), p2i(new_tams));
 98   assert((new_tams == r->bottom()) || (old_tams == r->bottom()) || (new_tams >= _top_bitmaps[idx]),
 99          "Region " SIZE_FORMAT", top_bitmaps updates should be monotonic: " PTR_FORMAT " -> " PTR_FORMAT,
100          idx, p2i(_top_bitmaps[idx]), p2i(new_tams));
101   assert(old_tams == r->bottom() || is_bitmap_clear_range(old_tams, new_tams),
102          "Region " SIZE_FORMAT ", bitmap should be clear while adjusting TAMS: " PTR_FORMAT " -> " PTR_FORMAT,
103          idx, p2i(old_tams), p2i(new_tams));
104 
105   log_debug(gc)("Capturing TAMS for %s Region " SIZE_FORMAT ", was: " PTR_FORMAT ", now: " PTR_FORMAT,
106                 r->affiliation_name(), idx, p2i(old_tams), p2i(new_tams));
107 
108   _top_at_mark_starts_base[idx] = new_tams;
109   _top_bitmaps[idx] = new_tams;
110 }
111 
112 inline void ShenandoahMarkingContext::reset_top_at_mark_start(ShenandoahHeapRegion* r) {
113   _top_at_mark_starts_base[r->index()] = r->bottom();
114 }
115 
116 inline HeapWord* ShenandoahMarkingContext::top_at_mark_start(const ShenandoahHeapRegion* r) const {
117   return _top_at_mark_starts_base[r->index()];
118 }
119 
120 inline void ShenandoahMarkingContext::reset_top_bitmap(ShenandoahHeapRegion* r) {
121   assert(is_bitmap_clear_range(r->bottom(), r->end()),
122          "Region " SIZE_FORMAT " should have no marks in bitmap", r->index());
123   _top_bitmaps[r->index()] = r->bottom();
124 }
125 
126 #endif // SHARE_GC_SHENANDOAH_SHENANDOAHMARKINGCONTEXT_INLINE_HPP
< prev index next >