Path: blob/master/src/hotspot/share/gc/g1/g1BarrierSet.inline.hpp
40957 views
/*1* Copyright (c) 2016, 2020, 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_GC_G1_G1BARRIERSET_INLINE_HPP25#define SHARE_GC_G1_G1BARRIERSET_INLINE_HPP2627#include "gc/g1/g1BarrierSet.hpp"2829#include "gc/g1/g1CardTable.hpp"30#include "gc/shared/accessBarrierSupport.inline.hpp"31#include "oops/access.inline.hpp"32#include "oops/compressedOops.inline.hpp"33#include "oops/oop.hpp"3435template <DecoratorSet decorators, typename T>36inline void G1BarrierSet::write_ref_field_pre(T* field) {37if (HasDecorator<decorators, IS_DEST_UNINITIALIZED>::value ||38HasDecorator<decorators, AS_NO_KEEPALIVE>::value) {39return;40}4142T heap_oop = RawAccess<MO_RELAXED>::oop_load(field);43if (!CompressedOops::is_null(heap_oop)) {44enqueue(CompressedOops::decode_not_null(heap_oop));45}46}4748template <DecoratorSet decorators, typename T>49inline void G1BarrierSet::write_ref_field_post(T* field, oop new_val) {50volatile CardValue* byte = _card_table->byte_for(field);51if (*byte != G1CardTable::g1_young_card_val()) {52// Take a slow path for cards in old53write_ref_field_post_slow(byte);54}55}5657inline void G1BarrierSet::enqueue_if_weak(DecoratorSet decorators, oop value) {58assert((decorators & ON_UNKNOWN_OOP_REF) == 0, "Reference strength must be known");59// Loading from a weak or phantom reference needs enqueueing, as60// the object may not have been reachable (part of the snapshot)61// when marking started.62const bool on_strong_oop_ref = (decorators & ON_STRONG_OOP_REF) != 0;63const bool peek = (decorators & AS_NO_KEEPALIVE) != 0;64const bool needs_enqueue = (!peek && !on_strong_oop_ref);6566if (needs_enqueue && value != NULL) {67enqueue(value);68}69}7071template <DecoratorSet decorators, typename BarrierSetT>72template <typename T>73inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::74oop_load_not_in_heap(T* addr) {75oop value = ModRef::oop_load_not_in_heap(addr);76enqueue_if_weak(decorators, value);77return value;78}7980template <DecoratorSet decorators, typename BarrierSetT>81template <typename T>82inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::83oop_load_in_heap(T* addr) {84oop value = ModRef::oop_load_in_heap(addr);85enqueue_if_weak(decorators, value);86return value;87}8889template <DecoratorSet decorators, typename BarrierSetT>90inline oop G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::91oop_load_in_heap_at(oop base, ptrdiff_t offset) {92oop value = ModRef::oop_load_in_heap_at(base, offset);93enqueue_if_weak(AccessBarrierSupport::resolve_possibly_unknown_oop_ref_strength<decorators>(base, offset), value);94return value;95}9697template <DecoratorSet decorators, typename BarrierSetT>98template <typename T>99inline void G1BarrierSet::AccessBarrier<decorators, BarrierSetT>::100oop_store_not_in_heap(T* addr, oop new_value) {101// Apply SATB barriers for all non-heap references, to allow102// concurrent scanning of such references.103G1BarrierSet *bs = barrier_set_cast<G1BarrierSet>(BarrierSet::barrier_set());104bs->write_ref_field_pre<decorators>(addr);105Raw::oop_store(addr, new_value);106}107108#endif // SHARE_GC_G1_G1BARRIERSET_INLINE_HPP109110111