< prev index next >

src/hotspot/share/gc/shenandoah/c2/shenandoahBarrierSetC2.hpp

Print this page

  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_C2_SHENANDOAHBARRIERSETC2_HPP
 26 #define SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP
 27 
 28 #include "gc/shared/c2/barrierSetC2.hpp"
 29 #include "gc/shenandoah/c2/shenandoahSupport.hpp"
 30 #include "utilities/growableArray.hpp"
 31 
 32 class ShenandoahBarrierSetC2State : public ArenaObj {
 33 private:
 34   GrowableArray<ShenandoahLoadReferenceBarrierNode*>* _load_reference_barriers;











 35 
 36 public:
 37   ShenandoahBarrierSetC2State(Arena* comp_arena);
 38 
 39   int load_reference_barriers_count() const;
 40   ShenandoahLoadReferenceBarrierNode* load_reference_barrier(int idx) const;
 41   void add_load_reference_barrier(ShenandoahLoadReferenceBarrierNode* n);
 42   void remove_load_reference_barrier(ShenandoahLoadReferenceBarrierNode * n);
 43 };









 44 
 45 class ShenandoahBarrierSetC2 : public BarrierSetC2 {
 46 private:
 47   void shenandoah_eliminate_wb_pre(Node* call, PhaseIterGVN* igvn) const;
 48 
 49   bool satb_can_remove_pre_barrier(GraphKit* kit, PhaseValues* phase, Node* adr,
 50                                    BasicType bt, uint adr_idx) const;
 51   void satb_write_barrier_pre(GraphKit* kit, bool do_load,
 52                               Node* obj,
 53                               Node* adr,
 54                               uint alias_idx,
 55                               Node* val,
 56                               const TypeOopPtr* val_type,
 57                               Node* pre_val,
 58                               BasicType bt) const;
 59 
 60   void shenandoah_write_barrier_pre(GraphKit* kit,
 61                                     bool do_load,
 62                                     Node* obj,
 63                                     Node* adr,
 64                                     uint alias_idx,
 65                                     Node* val,
 66                                     const TypeOopPtr* val_type,
 67                                     Node* pre_val,
 68                                     BasicType bt) const;
 69 
 70   void post_barrier(GraphKit* kit,
 71                     Node* ctl,
 72                     Node* store,
 73                     Node* obj,
 74                     Node* adr,
 75                     uint adr_idx,
 76                     Node* val,
 77                     BasicType bt,
 78                     bool use_precise) const;
 79 
 80   void insert_pre_barrier(GraphKit* kit, Node* base_oop, Node* offset,
 81                           Node* pre_val, bool need_mem_bar) const;
 82 
 83   static bool clone_needs_barrier(Node* src, PhaseGVN& gvn);
 84 
 85 protected:
 86   virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const;
 87   virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const;
 88   virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
 89                                                Node* new_val, const Type* val_type) const;
 90   virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
 91                                                 Node* new_val, const Type* value_type) const;
 92   virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;
 93 
 94 public:
 95   static ShenandoahBarrierSetC2* bsc2();
 96 
 97   static bool is_shenandoah_wb_pre_call(Node* call);
 98   static bool is_shenandoah_clone_call(Node* call);
 99   static bool is_shenandoah_lrb_call(Node* call);
100   static bool is_shenandoah_marking_if(PhaseValues* phase, Node* n);
101   static bool is_shenandoah_state_load(Node* n);
102   static bool has_only_shenandoah_wb_pre_uses(Node* n);
103 
104   ShenandoahBarrierSetC2State* state() const;
105 
106   static const TypeFunc* write_barrier_pre_Type();
107   static const TypeFunc* clone_barrier_Type();
108   static const TypeFunc* load_reference_barrier_Type();
109   virtual bool has_load_barrier_nodes() const { return true; }
110 
111   // This is the entry-point for the backend to perform accesses through the Access API.
112   virtual void clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const;
113 
114   // These are general helper methods used by C2
115   virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const;
116 
117   // Support for GC barriers emitted during parsing
118   virtual bool is_gc_pre_barrier_node(Node* node) const;
119   virtual bool is_gc_barrier_node(Node* node) const;
120   virtual Node* step_over_gc_barrier(Node* c) const;
121   virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const;
122   virtual bool optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const;
123   virtual bool strip_mined_loops_expanded(LoopOptsMode mode) const { return mode == LoopOptsShenandoahExpand; }
124   virtual bool is_gc_specific_loop_opts_pass(LoopOptsMode mode) const { return mode == LoopOptsShenandoahExpand; }
125 
126   // Support for macro expanded GC barriers
127   virtual void register_potential_barrier_node(Node* node) const;
128   virtual void unregister_potential_barrier_node(Node* node) const;
129   virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const;
130   virtual void enqueue_useful_gc_barrier(PhaseIterGVN* igvn, Node* node) const;
131   virtual void eliminate_useless_gc_barriers(Unique_Node_List &useful, Compile* C) const;
132 
133   // Allow barrier sets to have shared state that is preserved across a compilation unit.
134   // This could for example comprise macro nodes to be expanded during macro expansion.
135   virtual void* create_barrier_state(Arena* comp_arena) const;
136   // If the BarrierSetC2 state has kept macro nodes in its compilation unit state to be
137   // expanded later, then now is the time to do so.
138   virtual bool expand_macro_nodes(PhaseMacroExpand* macro) const;
139 
140 #ifdef ASSERT
141   virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) const;

142 #endif
143 
144   virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const;
145   virtual bool final_graph_reshaping(Compile* compile, Node* n, uint opcode, Unique_Node_List& dead_nodes) const;































































146 
147   virtual bool escape_add_to_con_graph(ConnectionGraph* conn_graph, PhaseGVN* gvn, Unique_Node_List* delayed_worklist, Node* n, uint opcode) const;
148   virtual bool escape_add_final_edges(ConnectionGraph* conn_graph, PhaseGVN* gvn, Node* n, uint opcode) const;
149   virtual bool escape_has_out_with_unsafe_object(Node* n) const;


150 
151   virtual bool matcher_find_shared_post_visit(Matcher* matcher, Node* n, uint opcode) const;
152   virtual bool matcher_is_store_load_barrier(Node* x, uint xop) const;









153 };
154 
155 #endif // SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP

  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_C2_SHENANDOAHBARRIERSETC2_HPP
 26 #define SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP
 27 
 28 #include "gc/shared/c2/barrierSetC2.hpp"
 29 #include "shenandoahBarrierSetC2.hpp"
 30 #include "utilities/growableArray.hpp"
 31 
 32 static const uint8_t ShenandoahBarrierStrong          = 1 << 0;
 33 static const uint8_t ShenandoahBarrierWeak            = 1 << 1;
 34 static const uint8_t ShenandoahBarrierPhantom         = 1 << 2;
 35 static const uint8_t ShenandoahBarrierNative          = 1 << 3;
 36 static const uint8_t ShenandoahBarrierElided          = 1 << 4;
 37 static const uint8_t ShenandoahBarrierSATB            = 1 << 5;
 38 static const uint8_t ShenandoahBarrierCardMark        = 1 << 6;
 39 static const uint8_t ShenandoahBarrierCardMarkNotNull = 1 << 7;
 40 
 41 class ShenandoahBarrierStubC2;
 42 
 43 class ShenandoahBarrierSetC2State : public BarrierSetC2State {
 44   GrowableArray<ShenandoahBarrierStubC2*>* _stubs;
 45   int _stubs_start_offset;
 46 
 47 public:
 48   explicit ShenandoahBarrierSetC2State(Arena* comp_arena);
 49 
 50   bool needs_liveness_data(const MachNode* mach) const override;
 51   bool needs_livein_data() const override;
 52 
 53   GrowableArray<ShenandoahBarrierStubC2*>* stubs() {
 54     return _stubs;
 55   }
 56 
 57   void set_stubs_start_offset(int offset) {
 58     _stubs_start_offset = offset;
 59   }
 60 
 61   int stubs_start_offset() {
 62     return _stubs_start_offset;
 63   }};
 64 
 65 class ShenandoahBarrierSetC2 : public BarrierSetC2 {




































 66 
 67   static bool clone_needs_barrier(Node* src, PhaseGVN& gvn);
 68 
 69 protected:
 70   virtual Node* load_at_resolved(C2Access& access, const Type* val_type) const;
 71   virtual Node* store_at_resolved(C2Access& access, C2AccessValue& val) const;
 72   virtual Node* atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
 73                                                Node* new_val, const Type* val_type) const;
 74   virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
 75                                                 Node* new_val, const Type* value_type) const;
 76   virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;
 77 
 78 public:
 79   static ShenandoahBarrierSetC2* bsc2();
 80 

 81   static bool is_shenandoah_clone_call(Node* call);




 82 
 83   ShenandoahBarrierSetC2State* state() const;
 84 

 85   static const TypeFunc* clone_barrier_Type();


 86 
 87   // This is the entry-point for the backend to perform accesses through the Access API.
 88   virtual void clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const;
 89 
 90   // These are general helper methods used by C2
 91   virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const;
 92 
 93   // Support for GC barriers emitted during parsing

 94   virtual bool is_gc_barrier_node(Node* node) const;

 95   virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const;



 96 
 97   // Support for macro expanded GC barriers


 98   virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const;
 99   virtual void eliminate_gc_barrier_data(Node* node) const;

100 
101   // Allow barrier sets to have shared state that is preserved across a compilation unit.
102   // This could for example comprise macro nodes to be expanded during macro expansion.
103   virtual void* create_barrier_state(Arena* comp_arena) const;



104 
105 #ifdef ASSERT
106   virtual void verify_gc_barriers(Compile* compile, CompilePhase phase) const;
107   static void report_verify_failure(bool failed, const char* msg, Node* n);
108 #endif
109 
110   int estimate_stub_size() const /* override */;
111   void emit_stubs(CodeBuffer& cb) const /* override */;
112   void late_barrier_analysis() const /* override*/ {
113     compute_liveness_at_stubs();
114   }
115 
116 };
117 
118 class ShenandoahBarrierStubC2 : public BarrierStubC2 {
119 protected:
120   explicit ShenandoahBarrierStubC2(const MachNode* node) : BarrierStubC2(node) {}
121   void register_stub();
122 public:
123   virtual void emit_code(MacroAssembler& masm) = 0;
124 };
125 
126 class ShenandoahLoadRefBarrierStubC2 : public ShenandoahBarrierStubC2 {
127   Register _obj;
128   Register _addr;
129   Register _tmp1;
130   Register _tmp2;
131   Register _tmp3;
132   bool _narrow;
133   ShenandoahLoadRefBarrierStubC2(const MachNode* node, Register obj, Register addr, Register tmp1, Register tmp2, Register tmp3, bool narrow) :
134     ShenandoahBarrierStubC2(node), _obj(obj), _addr(addr), _tmp1(tmp1), _tmp2(tmp2), _tmp3(tmp3), _narrow(narrow) {}
135 public:
136   static bool needs_barrier(const MachNode* node) {
137     return (node->barrier_data() & (ShenandoahBarrierStrong | ShenandoahBarrierWeak | ShenandoahBarrierPhantom | ShenandoahBarrierNative)) != 0;
138   }
139   static ShenandoahLoadRefBarrierStubC2* create(const MachNode* node, Register obj, Register addr, Register tmp1, Register tmp2, Register tmp3, bool narrow);
140   void emit_code(MacroAssembler& masm) override;
141 };
142 
143 class ShenandoahSATBBarrierStubC2 : public ShenandoahBarrierStubC2 {
144   Register _addr;
145   Register _preval;
146   Register _tmp;
147   ShenandoahSATBBarrierStubC2(const MachNode* node, Register addr, Register preval, Register tmp) :
148     ShenandoahBarrierStubC2(node), _addr(addr), _preval(preval), _tmp(tmp) {}
149 
150 public:
151   static bool needs_barrier(const MachNode* node) {
152     return (node->barrier_data() & ShenandoahBarrierSATB) != 0;
153   }
154   static ShenandoahSATBBarrierStubC2* create(const MachNode* node, Register addr, Register preval, Register tmp = noreg);
155 
156   void emit_code(MacroAssembler& masm) override;
157 };
158 
159 class ShenandoahCASBarrierSlowStubC2 : public ShenandoahBarrierStubC2 {
160   Register _addr_reg;
161   Address  _addr;
162   Register _expected;
163   Register _new_val;
164   Register _result;
165   Register _tmp1;
166   Register _tmp2;
167   bool     _cae;
168   bool     _acquire;
169   bool     _release;
170   bool     _weak;
171 
172   explicit ShenandoahCASBarrierSlowStubC2(const MachNode* node, Register addr_reg, Address addr, Register expected, Register new_val, Register result, Register tmp1, Register tmp2, bool cae, bool acquire, bool release, bool weak) :
173     ShenandoahBarrierStubC2(node),
174     _addr_reg(addr_reg), _addr(addr), _expected(expected), _new_val(new_val), _result(result), _tmp1(tmp1), _tmp2(tmp2), _cae(cae), _acquire(acquire), _release(release),  _weak(weak) {}
175 
176 public:
177   static ShenandoahCASBarrierSlowStubC2* create(const MachNode* node, Register addr, Register expected, Register new_val, Register result, Register tmp, bool cae, bool acquire, bool release, bool weak);
178   static ShenandoahCASBarrierSlowStubC2* create(const MachNode* node, Address addr, Register expected, Register new_val, Register result, Register tmp1, Register tmp2, bool cae);
179   void emit_code(MacroAssembler& masm) override;
180 };
181 
182 class ShenandoahCASBarrierMidStubC2 : public ShenandoahBarrierStubC2 {
183   ShenandoahCASBarrierSlowStubC2* _slow_stub;
184   Register _expected;
185   Register _result;
186   Register _tmp;
187   bool _cae;
188   ShenandoahCASBarrierMidStubC2(const MachNode* node, ShenandoahCASBarrierSlowStubC2* slow_stub, Register expected, Register result, Register tmp, bool cae) :
189     ShenandoahBarrierStubC2(node), _slow_stub(slow_stub), _expected(expected), _result(result), _tmp(tmp), _cae(cae) {}
190 public:
191   static ShenandoahCASBarrierMidStubC2* create(const MachNode* node, ShenandoahCASBarrierSlowStubC2* slow_stub, Register expected, Register result, Register tmp, bool cae);
192   void emit_code(MacroAssembler& masm) override;
193 };
194 
195 #endif // SHARE_GC_SHENANDOAH_C2_SHENANDOAHBARRIERSETC2_HPP
< prev index next >