Path: blob/master/src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp
40975 views
/*1* Copyright (c) 2018, 2021, Red Hat, Inc. 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_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP25#define SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP2627#include "gc/shared/c2/barrierSetC2.hpp"28#include "gc/shenandoah/c2/shenandoahSupport.hpp"29#include "utilities/growableArray.hpp"3031class ShenandoahBarrierSetC2State : public ResourceObj {32private:33GrowableArray<ShenandoahIUBarrierNode*>* _iu_barriers;34GrowableArray<ShenandoahLoadReferenceBarrierNode*>* _load_reference_barriers;3536public:37ShenandoahBarrierSetC2State(Arena* comp_arena);3839int iu_barriers_count() const;40ShenandoahIUBarrierNode* iu_barrier(int idx) const;41void add_iu_barrier(ShenandoahIUBarrierNode* n);42void remove_iu_barrier(ShenandoahIUBarrierNode * n);4344int load_reference_barriers_count() const;45ShenandoahLoadReferenceBarrierNode* load_reference_barrier(int idx) const;46void add_load_reference_barrier(ShenandoahLoadReferenceBarrierNode* n);47void remove_load_reference_barrier(ShenandoahLoadReferenceBarrierNode * n);48};4950class ShenandoahBarrierSetC2 : public BarrierSetC2 {51private:52void shenandoah_eliminate_wb_pre(Node* call, PhaseIterGVN* igvn) const;5354bool satb_can_remove_pre_barrier(GraphKit* kit, PhaseTransform* phase, Node* adr,55BasicType bt, uint adr_idx) const;56void satb_write_barrier_pre(GraphKit* kit, bool do_load,57Node* obj,58Node* adr,59uint alias_idx,60Node* val,61const TypeOopPtr* val_type,62Node* pre_val,63BasicType bt) const;6465void shenandoah_write_barrier_pre(GraphKit* kit,66bool do_load,67Node* obj,68Node* adr,69uint alias_idx,70Node* val,71const TypeOopPtr* val_type,72Node* pre_val,73BasicType bt) const;7475Node* shenandoah_iu_barrier(GraphKit* kit, Node* obj) const;7677void insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset,78Node* pre_val, bool need_mem_bar) const;7980static bool clone_needs_barrier(Node* src, PhaseGVN& gvn);8182protected:83virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const;84virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const;85virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val,86Node* new_val, const Type* val_type) const;87virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,88Node* new_val, const Type* value_type) const;89virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;9091public:92static ShenandoahBarrierSetC2* bsc2();9394static bool is_shenandoah_wb_pre_call(Node* call);95static bool is_shenandoah_lrb_call(Node* call);96static bool is_shenandoah_marking_if(PhaseTransform *phase, Node* n);97static bool is_shenandoah_state_load(Node* n);98static bool has_only_shenandoah_wb_pre_uses(Node* n);99100ShenandoahBarrierSetC2State* state() const;101102static const TypeFunc* write_ref_field_pre_entry_Type();103static const TypeFunc* shenandoah_clone_barrier_Type();104static const TypeFunc* shenandoah_load_reference_barrier_Type();105virtual bool has_load_barrier_nodes() const { return true; }106107// This is the entry-point for the backend to perform accesses through the Access API.108virtual void clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const;109110// These are general helper methods used by C2111virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const;112113// Support for GC barriers emitted during parsing114virtual bool is_gc_barrier_node(Node* node) const;115virtual Node* step_over_gc_barrier(Node* c) const;116virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const;117virtual bool optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const;118virtual bool strip_mined_loops_expanded(LoopOptsMode mode) const { return mode == LoopOptsShenandoahExpand || mode == LoopOptsShenandoahPostExpand; }119virtual bool is_gc_specific_loop_opts_pass(LoopOptsMode mode) const { return mode == LoopOptsShenandoahExpand || mode == LoopOptsShenandoahPostExpand; }120121// Support for macro expanded GC barriers122virtual void register_potential_barrier_node(Node* node) const;123virtual void unregister_potential_barrier_node(Node* node) const;124virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const;125virtual void enqueue_useful_gc_barrier(PhaseIterGVN* igvn, Node* node) const;126virtual void eliminate_useless_gc_barriers(Unique_Node_List &useful, Compile* C) const;127128// Allow barrier sets to have shared state that is preserved across a compilation unit.129// This could for example comprise macro nodes to be expanded during macro expansion.130virtual void* create_barrier_state(Arena* comp_arena) const;131// If the BarrierSetC2 state has kept macro nodes in its compilation unit state to be132// expanded later, then now is the time to do so.133virtual bool expand_macro_nodes(PhaseMacroExpand* macro) const;134135#ifdef ASSERT136virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) const;137#endif138139virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const;140virtual bool final_graph_reshaping(Compile* compile, Node* n, uint opcode) const;141142virtual bool escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const;143virtual bool escape_add_final_edges(ConnectionGraph* conn_graph, PhaseGVN* gvn, Node* n, uint opcode) const;144virtual bool escape_has_out_with_unsafe_object(Node* n) const;145146virtual bool matcher_find_shared_post_visit(Matcher* matcher, Node* n, uint opcode) const;147virtual bool matcher_is_store_load_barrier(Node* x, uint xop) const;148};149150#endif // SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP151152153