src/hotspot/share/gc/z/c2/zBarrierSetC2.cpp
changeset 59025 b398685dd029
parent 58965 86c8b22945a1
child 59324 5e8f9713e343
equal deleted inserted replaced
59024:b046ba510bbc 59025:b398685dd029
   176   }
   176   }
   177 
   177 
   178   return size;
   178   return size;
   179 }
   179 }
   180 
   180 
   181 static bool barrier_needed(C2Access& access) {
   181 static void set_barrier_data(C2Access& access) {
   182   return ZBarrierSet::barrier_needed(access.decorators(), access.type());
   182   if (ZBarrierSet::barrier_needed(access.decorators(), access.type())) {
       
   183     if (access.decorators() & ON_WEAK_OOP_REF) {
       
   184       access.set_barrier_data(ZLoadBarrierWeak);
       
   185     } else {
       
   186       access.set_barrier_data(ZLoadBarrierStrong);
       
   187     }
       
   188   }
   183 }
   189 }
   184 
   190 
   185 Node* ZBarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const {
   191 Node* ZBarrierSetC2::load_at_resolved(C2Access& access, const Type* val_type) const {
   186   Node* result = BarrierSetC2::load_at_resolved(access, val_type);
   192   set_barrier_data(access);
   187   if (barrier_needed(access) && access.raw_access()->is_Mem()) {
   193   return BarrierSetC2::load_at_resolved(access, val_type);
   188     if ((access.decorators() & ON_WEAK_OOP_REF) != 0) {
       
   189       access.raw_access()->as_Load()->set_barrier_data(ZLoadBarrierWeak);
       
   190     } else {
       
   191       access.raw_access()->as_Load()->set_barrier_data(ZLoadBarrierStrong);
       
   192     }
       
   193   }
       
   194 
       
   195   return result;
       
   196 }
   194 }
   197 
   195 
   198 Node* ZBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
   196 Node* ZBarrierSetC2::atomic_cmpxchg_val_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
   199                                                     Node* new_val, const Type* val_type) const {
   197                                                     Node* new_val, const Type* val_type) const {
   200   Node* result = BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, val_type);
   198   set_barrier_data(access);
   201   if (barrier_needed(access)) {
   199   return BarrierSetC2::atomic_cmpxchg_val_at_resolved(access, expected_val, new_val, val_type);
   202     access.raw_access()->as_LoadStore()->set_barrier_data(ZLoadBarrierStrong);
       
   203   }
       
   204   return result;
       
   205 }
   200 }
   206 
   201 
   207 Node* ZBarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
   202 Node* ZBarrierSetC2::atomic_cmpxchg_bool_at_resolved(C2AtomicParseAccess& access, Node* expected_val,
   208                                                      Node* new_val, const Type* value_type) const {
   203                                                      Node* new_val, const Type* value_type) const {
   209   Node* result = BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type);
   204   set_barrier_data(access);
   210   if (barrier_needed(access)) {
   205   return BarrierSetC2::atomic_cmpxchg_bool_at_resolved(access, expected_val, new_val, value_type);
   211     access.raw_access()->as_LoadStore()->set_barrier_data(ZLoadBarrierStrong);
       
   212   }
       
   213   return result;
       
   214 }
   206 }
   215 
   207 
   216 Node* ZBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const {
   208 Node* ZBarrierSetC2::atomic_xchg_at_resolved(C2AtomicParseAccess& access, Node* new_val, const Type* val_type) const {
   217   Node* result = BarrierSetC2::atomic_xchg_at_resolved(access, new_val, val_type);
   209   set_barrier_data(access);
   218   if (barrier_needed(access)) {
   210   return BarrierSetC2::atomic_xchg_at_resolved(access, new_val, val_type);
   219     access.raw_access()->as_LoadStore()->set_barrier_data(ZLoadBarrierStrong);
       
   220   }
       
   221   return result;
       
   222 }
   211 }
   223 
   212 
   224 bool ZBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type,
   213 bool ZBarrierSetC2::array_copy_requires_gc_barriers(bool tightly_coupled_alloc, BasicType type,
   225                                                     bool is_clone, ArrayCopyPhase phase) const {
   214                                                     bool is_clone, ArrayCopyPhase phase) const {
   226   return type == T_OBJECT || type == T_ARRAY;
   215   return type == T_OBJECT || type == T_ARRAY;