Path: blob/master/src/hotspot/share/gc/z/zBarrier.hpp
40957 views
/*1* Copyright (c) 2015, 2021, 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*/2223#ifndef SHARE_GC_Z_ZBARRIER_HPP24#define SHARE_GC_Z_ZBARRIER_HPP2526#include "memory/allocation.hpp"27#include "memory/iterator.hpp"28#include "oops/oop.hpp"2930typedef bool (*ZBarrierFastPath)(uintptr_t);31typedef uintptr_t (*ZBarrierSlowPath)(uintptr_t);3233class ZBarrier : public AllStatic {34private:35static const bool GCThread = true;36static const bool AnyThread = false;3738static const bool Follow = true;39static const bool DontFollow = false;4041static const bool Strong = false;42static const bool Finalizable = true;4344static const bool Publish = true;45static const bool Overflow = false;4647template <ZBarrierFastPath fast_path> static void self_heal(volatile oop* p, uintptr_t addr, uintptr_t heal_addr);4849template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path> static oop barrier(volatile oop* p, oop o);50template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path> static oop weak_barrier(volatile oop* p, oop o);51template <ZBarrierFastPath fast_path, ZBarrierSlowPath slow_path> static void root_barrier(oop* p, oop o);5253static bool is_good_or_null_fast_path(uintptr_t addr);54static bool is_weak_good_or_null_fast_path(uintptr_t addr);55static bool is_marked_or_null_fast_path(uintptr_t addr);5657static bool during_mark();58static bool during_relocate();59template <bool finalizable> static bool should_mark_through(uintptr_t addr);60template <bool gc_thread, bool follow, bool finalizable, bool publish> static uintptr_t mark(uintptr_t addr);61static uintptr_t remap(uintptr_t addr);62static uintptr_t relocate(uintptr_t addr);63static uintptr_t relocate_or_mark(uintptr_t addr);64static uintptr_t relocate_or_mark_no_follow(uintptr_t addr);65static uintptr_t relocate_or_remap(uintptr_t addr);6667static uintptr_t load_barrier_on_oop_slow_path(uintptr_t addr);68static uintptr_t load_barrier_on_invisible_root_oop_slow_path(uintptr_t addr);6970static uintptr_t weak_load_barrier_on_oop_slow_path(uintptr_t addr);71static uintptr_t weak_load_barrier_on_weak_oop_slow_path(uintptr_t addr);72static uintptr_t weak_load_barrier_on_phantom_oop_slow_path(uintptr_t addr);7374static uintptr_t keep_alive_barrier_on_oop_slow_path(uintptr_t addr);75static uintptr_t keep_alive_barrier_on_weak_oop_slow_path(uintptr_t addr);76static uintptr_t keep_alive_barrier_on_phantom_oop_slow_path(uintptr_t addr);7778static uintptr_t mark_barrier_on_oop_slow_path(uintptr_t addr);79static uintptr_t mark_barrier_on_finalizable_oop_slow_path(uintptr_t addr);8081static void verify_on_weak(volatile oop* referent_addr) NOT_DEBUG_RETURN;8283public:84// Load barrier85static oop load_barrier_on_oop(oop o);86static oop load_barrier_on_oop_field(volatile oop* p);87static oop load_barrier_on_oop_field_preloaded(volatile oop* p, oop o);88static void load_barrier_on_oop_array(volatile oop* p, size_t length);89static void load_barrier_on_oop_fields(oop o);90static oop load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o);91static oop load_barrier_on_phantom_oop_field_preloaded(volatile oop* p, oop o);92static void load_barrier_on_root_oop_field(oop* p);93static void load_barrier_on_invisible_root_oop_field(oop* p);9495// Weak load barrier96static oop weak_load_barrier_on_oop_field(volatile oop* p);97static oop weak_load_barrier_on_oop_field_preloaded(volatile oop* p, oop o);98static oop weak_load_barrier_on_weak_oop(oop o);99static oop weak_load_barrier_on_weak_oop_field(volatile oop* p);100static oop weak_load_barrier_on_weak_oop_field_preloaded(volatile oop* p, oop o);101static oop weak_load_barrier_on_phantom_oop(oop o);102static oop weak_load_barrier_on_phantom_oop_field(volatile oop* p);103static oop weak_load_barrier_on_phantom_oop_field_preloaded(volatile oop* p, oop o);104105// Is alive barrier106static bool is_alive_barrier_on_weak_oop(oop o);107static bool is_alive_barrier_on_phantom_oop(oop o);108109// Keep alive barrier110static void keep_alive_barrier_on_oop(oop o);111static void keep_alive_barrier_on_weak_oop_field(volatile oop* p);112static void keep_alive_barrier_on_phantom_oop_field(volatile oop* p);113static void keep_alive_barrier_on_phantom_root_oop_field(oop* p);114115// Mark barrier116static void mark_barrier_on_oop_field(volatile oop* p, bool finalizable);117static void mark_barrier_on_oop_array(volatile oop* p, size_t length, bool finalizable);118static void mark_barrier_on_invisible_root_oop_field(oop* p);119120// Narrow oop variants, never used.121static oop load_barrier_on_oop_field(volatile narrowOop* p);122static oop load_barrier_on_oop_field_preloaded(volatile narrowOop* p, oop o);123static void load_barrier_on_oop_array(volatile narrowOop* p, size_t length);124static oop load_barrier_on_weak_oop_field_preloaded(volatile narrowOop* p, oop o);125static oop load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o);126static oop weak_load_barrier_on_oop_field_preloaded(volatile narrowOop* p, oop o);127static oop weak_load_barrier_on_weak_oop_field_preloaded(volatile narrowOop* p, oop o);128static oop weak_load_barrier_on_phantom_oop_field_preloaded(volatile narrowOop* p, oop o);129};130131class ZLoadBarrierOopClosure : public BasicOopIterateClosure {132public:133virtual void do_oop(oop* p);134virtual void do_oop(narrowOop* p);135};136137#endif // SHARE_GC_Z_ZBARRIER_HPP138139140