1 /* 2 * Copyright (c) 2021, 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 #include "precompiled.hpp" 26 27 #include "gc/shenandoah/shenandoahHeap.inline.hpp" 28 #include "gc/shenandoah/shenandoahHeapRegion.hpp" 29 #include "gc/shenandoah/shenandoahMarkClosures.hpp" 30 #include "gc/shenandoah/shenandoahMarkingContext.hpp" 31 #include "gc/shenandoah/shenandoahSharedVariables.hpp" 32 33 34 ShenandoahFinalMarkUpdateRegionStateClosure::ShenandoahFinalMarkUpdateRegionStateClosure( 35 ShenandoahMarkingContext *ctx) : 36 _ctx(ctx), _lock(ShenandoahHeap::heap()->lock()) {} 37 38 void ShenandoahFinalMarkUpdateRegionStateClosure::heap_region_do(ShenandoahHeapRegion* r) { 39 if (r->is_active()) { 40 // All allocations past TAMS are implicitly live, adjust the region data. 41 // Bitmaps/TAMS are swapped at this point, so we need to poll complete bitmap. 42 HeapWord *tams = _ctx->top_at_mark_start(r); 43 HeapWord *top = r->top(); 44 if (top > tams) { 45 r->increase_live_data_alloc_words(pointer_delta(top, tams)); 46 } 47 48 // We are about to select the collection set, make sure it knows about 49 // current pinning status. Also, this allows trashing more regions that 50 // now have their pinning status dropped. 51 if (r->is_pinned()) { 52 if (r->pin_count() == 0) { 53 ShenandoahHeapLocker locker(_lock); 54 r->make_unpinned(); 55 } 56 } else { 57 if (r->pin_count() > 0) { 58 ShenandoahHeapLocker locker(_lock); 59 r->make_pinned(); 60 } 61 } 62 63 // Remember limit for updating refs. It's guaranteed that we get no 64 // from-space-refs written from here on. 65 r->set_update_watermark_at_safepoint(r->top()); 66 } else { 67 assert(!r->has_live(), "Region " SIZE_FORMAT " should have no live data", r->index()); 68 assert(_ctx->top_at_mark_start(r) == r->top(), 69 "Region " SIZE_FORMAT " should have correct TAMS", r->index()); 70 } 71 } 72 73 ShenandoahCaptureUpdateWaterMarkForOld::ShenandoahCaptureUpdateWaterMarkForOld(ShenandoahMarkingContext* ctx) : 74 _ctx(ctx), _lock(ShenandoahHeap::heap()->lock()) {} 75 76 void ShenandoahCaptureUpdateWaterMarkForOld::heap_region_do(ShenandoahHeapRegion* r) { 77 // Remember limit for updating refs. It's guaranteed that we get no from-space-refs written from here on. 78 r->set_update_watermark_at_safepoint(r->top()); 79 }