< prev index next >

src/hotspot/share/gc/shared/c2/barrierSetC2.hpp

Print this page

130   Node* raw_access() const        { return _raw_access; }
131 
132   uint8_t barrier_data() const        { return _barrier_data; }
133   void set_barrier_data(uint8_t data) { _barrier_data = data; }
134 
135   void set_raw_access(Node* raw_access) { _raw_access = raw_access; }
136   virtual void set_memory() {} // no-op for normal accesses, but not for atomic accesses.
137 
138   MemNode::MemOrd mem_node_mo() const;
139   bool needs_cpu_membar() const;
140 
141   virtual PhaseGVN& gvn() const = 0;
142   virtual bool is_parse_access() const { return false; }
143   virtual bool is_opt_access() const { return false; }
144 };
145 
146 // C2Access for parse time calls to the BarrierSetC2 backend.
147 class C2ParseAccess: public C2Access {
148 protected:
149   GraphKit*         _kit;


150 
151   void* barrier_set_state() const;
152 
153 public:
154   C2ParseAccess(GraphKit* kit, DecoratorSet decorators,
155                 BasicType type, Node* base, C2AccessValuePtr& addr) :

156     C2Access(decorators, type, base, addr),
157     _kit(kit) {


158     fixup_decorators();
159   }
160 
161   GraphKit* kit() const           { return _kit; }


162 
163   virtual PhaseGVN& gvn() const;
164   virtual bool is_parse_access() const { return true; }
165 };
166 
167 // This class wraps a bunch of context parameters that are passed around in the
168 // BarrierSetC2 backend hierarchy, for atomic accesses, to reduce boiler plate.
169 class C2AtomicParseAccess: public C2ParseAccess {
170   Node* _memory;
171   uint  _alias_idx;
172 
173 public:
174   C2AtomicParseAccess(GraphKit* kit, DecoratorSet decorators, BasicType type,
175                  Node* base, C2AccessValuePtr& addr, uint alias_idx) :
176     C2ParseAccess(kit, decorators, type, base, addr),
177     _memory(nullptr),
178     _alias_idx(alias_idx) {}
179 
180   // Set the memory node based on the current memory slice.
181   virtual void set_memory();

285   virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
286                                                 Node* new_val, const Type* value_type) const;
287   virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;
288   virtual Node* atomic_add_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;
289   void pin_atomic_op(C2AtomicParseAccess& access) const;
290   void clone_in_runtime(PhaseMacroExpand* phase, ArrayCopyNode* ac,
291                         address call_addr, const char* call_name) const;
292 
293 public:
294   // This is the entry-point for the backend to perform accesses through the Access API.
295   virtual Node* store_at(C2Access& access, C2AccessValue& val) const;
296   virtual Node* load_at(C2Access& access, const Type* val_type) const;
297 
298   virtual Node* atomic_cmpxchg_val_at(C2AtomicParseAccess& access, Node* expected_val,
299                                       Node* new_val, const Type* val_type) const;
300   virtual Node* atomic_cmpxchg_bool_at(C2AtomicParseAccess& access, Node* expected_val,
301                                        Node* new_val, const Type* val_type) const;
302   virtual Node* atomic_xchg_at(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const;
303   virtual Node* atomic_add_at(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const;
304 
305   virtual void clone(GraphKit* kit, Node* src, Node* dst, Node* size, bool is_array) const;
306 
307   virtual Node* obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobig_false, Node* size_in_bytes,
308                              Node*& i_o, Node*& needgc_ctrl,
309                              Node*& fast_oop_ctrl, Node*& fast_oop_rawmem,
310                              intx prefetch_lines) const;
311 
312   virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { return nullptr; }
313 
314   // These are general helper methods used by C2
315   enum ArrayCopyPhase {
316     Parsing,
317     Optimization,
318     Expansion
319   };
320 
321   virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const { return false; }
322   virtual void clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const;
323 
324   // Support for GC barriers emitted during parsing
325   virtual bool has_load_barrier_nodes() const { return false; }
326   virtual bool is_gc_pre_barrier_node(Node* node) const { return false; }
327   virtual bool is_gc_barrier_node(Node* node) const { return false; }
328   virtual Node* step_over_gc_barrier(Node* c) const { return c; }
329 
330   // Support for macro expanded GC barriers
331   virtual void register_potential_barrier_node(Node* node) const { }
332   virtual void unregister_potential_barrier_node(Node* node) const { }
333   virtual void eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const { }
334   virtual void eliminate_gc_barrier_data(Node* node) const { }
335   virtual void enqueue_useful_gc_barrier(PhaseIterGVN* igvn, Node* node) const {}
336   virtual void eliminate_useless_gc_barriers(Unique_Node_List &useful, Compile* C) const {}
337 
338   // Allow barrier sets to have shared state that is preserved across a compilation unit.
339   // This could for example comprise macro nodes to be expanded during macro expansion.
340   virtual void* create_barrier_state(Arena* comp_arena) const { return nullptr; }
341   // If the BarrierSetC2 state has barrier nodes in its compilation
342   // unit state to be expanded later, then now is the time to do so.
343   virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const { return false; }
344   virtual void final_refinement(Compile* C) const { }
345   virtual bool optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const { return false; }
346   virtual bool strip_mined_loops_expanded(LoopOptsMode mode) const { return false; }
347   virtual bool is_gc_specific_loop_opts_pass(LoopOptsMode mode) const { return false; }
348   // Estimated size of the node barrier in number of C2 Ideal nodes.
349   // This is used to guide heuristics in C2, e.g. whether to unroll a loop.
350   virtual uint estimated_barrier_size(const Node* node) const { return 0; }
351   // Whether the given store can be used to initialize a newly allocated object.
352   virtual bool can_initialize_object(const StoreNode* store) const { return true; }
353 

130   Node* raw_access() const        { return _raw_access; }
131 
132   uint8_t barrier_data() const        { return _barrier_data; }
133   void set_barrier_data(uint8_t data) { _barrier_data = data; }
134 
135   void set_raw_access(Node* raw_access) { _raw_access = raw_access; }
136   virtual void set_memory() {} // no-op for normal accesses, but not for atomic accesses.
137 
138   MemNode::MemOrd mem_node_mo() const;
139   bool needs_cpu_membar() const;
140 
141   virtual PhaseGVN& gvn() const = 0;
142   virtual bool is_parse_access() const { return false; }
143   virtual bool is_opt_access() const { return false; }
144 };
145 
146 // C2Access for parse time calls to the BarrierSetC2 backend.
147 class C2ParseAccess: public C2Access {
148 protected:
149   GraphKit*         _kit;
150   Node* _ctl;
151   const InlineTypeNode* _vt; // For flat, atomic accesses that might require GC barriers on oop fields
152 
153   void* barrier_set_state() const;
154 
155 public:
156   C2ParseAccess(GraphKit* kit, DecoratorSet decorators,
157                 BasicType type, Node* base, C2AccessValuePtr& addr,
158                 Node* ctl = nullptr, const InlineTypeNode* vt = nullptr) :
159     C2Access(decorators, type, base, addr),
160     _kit(kit),
161     _ctl(ctl),
162     _vt (vt) {
163     fixup_decorators();
164   }
165 
166   GraphKit* kit() const           { return _kit; }
167   Node* control() const;
168   const InlineTypeNode* vt() const { return _vt; }
169 
170   virtual PhaseGVN& gvn() const;
171   virtual bool is_parse_access() const { return true; }
172 };
173 
174 // This class wraps a bunch of context parameters that are passed around in the
175 // BarrierSetC2 backend hierarchy, for atomic accesses, to reduce boiler plate.
176 class C2AtomicParseAccess: public C2ParseAccess {
177   Node* _memory;
178   uint  _alias_idx;
179 
180 public:
181   C2AtomicParseAccess(GraphKit* kit, DecoratorSet decorators, BasicType type,
182                  Node* base, C2AccessValuePtr& addr, uint alias_idx) :
183     C2ParseAccess(kit, decorators, type, base, addr),
184     _memory(nullptr),
185     _alias_idx(alias_idx) {}
186 
187   // Set the memory node based on the current memory slice.
188   virtual void set_memory();

292   virtual Node* atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
293                                                 Node* new_val, const Type* value_type) const;
294   virtual Node* atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;
295   virtual Node* atomic_add_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const;
296   void pin_atomic_op(C2AtomicParseAccess& access) const;
297   void clone_in_runtime(PhaseMacroExpand* phase, ArrayCopyNode* ac,
298                         address call_addr, const char* call_name) const;
299 
300 public:
301   // This is the entry-point for the backend to perform accesses through the Access API.
302   virtual Node* store_at(C2Access& access, C2AccessValue& val) const;
303   virtual Node* load_at(C2Access& access, const Type* val_type) const;
304 
305   virtual Node* atomic_cmpxchg_val_at(C2AtomicParseAccess& access, Node* expected_val,
306                                       Node* new_val, const Type* val_type) const;
307   virtual Node* atomic_cmpxchg_bool_at(C2AtomicParseAccess& access, Node* expected_val,
308                                        Node* new_val, const Type* val_type) const;
309   virtual Node* atomic_xchg_at(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const;
310   virtual Node* atomic_add_at(C2AtomicParseAccess& access, Node* new_val, const Type* value_type) const;
311 
312   virtual void clone(GraphKit* kit, Node* src_base, Node* dst_base, Node* size, bool is_array) const;
313 
314   virtual Node* obj_allocate(PhaseMacroExpand* macro, Node* mem, Node* toobig_false, Node* size_in_bytes,
315                              Node*& i_o, Node*& needgc_ctrl,
316                              Node*& fast_oop_ctrl, Node*& fast_oop_rawmem,
317                              intx prefetch_lines) const;
318 
319   virtual Node* ideal_node(PhaseGVN* phase, Node* n, bool can_reshape) const { return nullptr; }
320 
321   // These are general helper methods used by C2
322   enum ArrayCopyPhase {
323     Parsing,
324     Optimization,
325     Expansion
326   };
327 
328   virtual bool array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type, bool is_clone, bool is_clone_instance, ArrayCopyPhase phase) const { return false; }
329   virtual void clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const;
330 
331   // Support for GC barriers emitted during parsing
332   virtual bool has_load_barrier_nodes() const { return false; }
333   virtual bool is_gc_pre_barrier_node(Node* node) const { return false; }
334   virtual bool is_gc_barrier_node(Node* node) const { return false; }
335   virtual Node* step_over_gc_barrier(Node* c) const { return c; }
336 
337   // Support for macro expanded GC barriers
338   virtual void register_potential_barrier_node(Node* node) const { }
339   virtual void unregister_potential_barrier_node(Node* node) const { }
340   virtual void eliminate_gc_barrier(PhaseIterGVN* igvn, Node* node) const { }
341   virtual void eliminate_gc_barrier_data(Node* node) const { }
342   virtual void enqueue_useful_gc_barrier(PhaseIterGVN* igvn, Node* node) const {}
343   virtual void eliminate_useless_gc_barriers(Unique_Node_List &useful, Compile* C) const {}
344 
345   // Allow barrier sets to have shared state that is preserved across a compilation unit.
346   // This could for example comprise macro nodes to be expanded during macro expansion.
347   virtual void* create_barrier_state(Arena* comp_arena) const { return nullptr; }
348   // If the BarrierSetC2 state has barrier nodes in its compilation
349   // unit state to be expanded later, then now is the time to do so.
350   virtual bool expand_barriers(Compile* C, PhaseIterGVN& igvn) const { return false; }
351   virtual void final_refinement(Compile* C) const { }
352   virtual bool optimize_loops(PhaseIdealLoop* phase, LoopOptsMode mode, VectorSet& visited, Node_Stack& nstack, Node_List& worklist) const { return false; }
353   virtual bool strip_mined_loops_expanded(LoopOptsMode mode) const { return false; }
354   virtual bool is_gc_specific_loop_opts_pass(LoopOptsMode mode) const { return false; }
355   // Estimated size of the node barrier in number of C2 Ideal nodes.
356   // This is used to guide heuristics in C2, e.g. whether to unroll a loop.
357   virtual uint estimated_barrier_size(const Node* node) const { return 0; }
358   // Whether the given store can be used to initialize a newly allocated object.
359   virtual bool can_initialize_object(const StoreNode* store) const { return true; }
360 
< prev index next >