196
197 return false;
198 }
199
200 Node* G1BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const {
201 DecoratorSet decorators = access.decorators();
202 bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
203 bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
204 bool no_keepalive = (decorators & AS_NO_KEEPALIVE) != 0;
205 // If we are reading the value of the referent field of a Reference object, we
206 // need to record the referent in an SATB log buffer using the pre-barrier
207 // mechanism. Also we need to add a memory barrier to prevent commoning reads
208 // from this field across safepoints, since GC can change its value.
209 bool need_read_barrier = ((on_weak || on_phantom) && !no_keepalive);
210 if (access.is_oop() && need_read_barrier) {
211 access.set_barrier_data(G1C2BarrierPre);
212 }
213 return CardTableBarrierSetC2::load_at_resolved(access, val_type);
214 }
215
216 void G1BarrierSetC2::eliminate_gc_barrier(PhaseMacroExpand* macro, Node* node) const {
217 eliminate_gc_barrier_data(node);
218 }
219
220 void G1BarrierSetC2::eliminate_gc_barrier_data(Node* node) const {
221 if (node->is_LoadStore()) {
222 LoadStoreNode* loadstore = node->as_LoadStore();
223 loadstore->set_barrier_data(0);
224 } else if (node->is_Mem()) {
225 MemNode* mem = node->as_Mem();
226 mem->set_barrier_data(0);
227 }
228 }
229
230 static void refine_barrier_by_new_val_type(const Node* n) {
231 if (n->Opcode() != Op_StoreP &&
232 n->Opcode() != Op_StoreN) {
233 return;
234 }
235 MemNode* store = n->as_Mem();
236 const Node* newval = n->in(MemNode::ValueIn);
237 assert(newval != nullptr, "");
238 const Type* newval_bottom = newval->bottom_type();
239 TypePtr::PTR newval_type = newval_bottom->make_ptr()->ptr();
|
196
197 return false;
198 }
199
200 Node* G1BarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const {
201 DecoratorSet decorators = access.decorators();
202 bool on_weak = (decorators & ON_WEAK_OOP_REF) != 0;
203 bool on_phantom = (decorators & ON_PHANTOM_OOP_REF) != 0;
204 bool no_keepalive = (decorators & AS_NO_KEEPALIVE) != 0;
205 // If we are reading the value of the referent field of a Reference object, we
206 // need to record the referent in an SATB log buffer using the pre-barrier
207 // mechanism. Also we need to add a memory barrier to prevent commoning reads
208 // from this field across safepoints, since GC can change its value.
209 bool need_read_barrier = ((on_weak || on_phantom) && !no_keepalive);
210 if (access.is_oop() && need_read_barrier) {
211 access.set_barrier_data(G1C2BarrierPre);
212 }
213 return CardTableBarrierSetC2::load_at_resolved(access, val_type);
214 }
215
216 void G1BarrierSetC2::eliminate_gc_barrier(PhaseIterGVN* igvn, Node* node) const {
217 eliminate_gc_barrier_data(node);
218 }
219 void G1BarrierSetC2::eliminate_gc_barrier_data(Node* node) const {
220 if (node->is_LoadStore()) {
221 LoadStoreNode* loadstore = node->as_LoadStore();
222 loadstore->set_barrier_data(0);
223 } else if (node->is_Mem()) {
224 MemNode* mem = node->as_Mem();
225 mem->set_barrier_data(0);
226 }
227 }
228
229 static void refine_barrier_by_new_val_type(const Node* n) {
230 if (n->Opcode() != Op_StoreP &&
231 n->Opcode() != Op_StoreN) {
232 return;
233 }
234 MemNode* store = n->as_Mem();
235 const Node* newval = n->in(MemNode::ValueIn);
236 assert(newval != nullptr, "");
237 const Type* newval_bottom = newval->bottom_type();
238 TypePtr::PTR newval_type = newval_bottom->make_ptr()->ptr();
|