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