< prev index next >

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

Print this page

  31 #include "opto/convertnode.hpp"
  32 #include "opto/graphKit.hpp"
  33 #include "opto/idealKit.hpp"
  34 #include "opto/macro.hpp"
  35 #include "opto/narrowptrnode.hpp"
  36 #include "opto/output.hpp"
  37 #include "opto/regalloc.hpp"
  38 #include "opto/runtime.hpp"
  39 #include "utilities/macros.hpp"
  40 #include CPU_HEADER(gc/shared/barrierSetAssembler)
  41 
  42 // By default this is a no-op.
  43 void BarrierSetC2::resolve_address(C2Access& access) const { }
  44 
  45 void* C2ParseAccess::barrier_set_state() const {
  46   return _kit->barrier_set_state();
  47 }
  48 
  49 PhaseGVN& C2ParseAccess::gvn() const { return _kit->gvn(); }
  50 




  51 bool C2Access::needs_cpu_membar() const {
  52   bool mismatched   = (_decorators & C2_MISMATCHED) != 0;
  53   bool is_unordered = (_decorators & MO_UNORDERED) != 0;
  54 
  55   bool anonymous = (_decorators & C2_UNSAFE_ACCESS) != 0;
  56   bool in_heap   = (_decorators & IN_HEAP) != 0;
  57   bool in_native = (_decorators & IN_NATIVE) != 0;
  58   bool is_mixed  = !in_heap && !in_native;
  59 
  60   bool is_write  = (_decorators & C2_WRITE_ACCESS) != 0;
  61   bool is_read   = (_decorators & C2_READ_ACCESS) != 0;
  62   bool is_atomic = is_read && is_write;
  63 
  64   if (is_atomic) {
  65     // Atomics always need to be wrapped in CPU membars
  66     return true;
  67   }
  68 
  69   if (anonymous) {
  70     // We will need memory barriers unless we can determine a unique

 184   DecoratorSet decorators = access.decorators();
 185 
 186   Node* adr = access.addr().node();
 187   const TypePtr* adr_type = access.addr().type();
 188 
 189   bool mismatched = (decorators & C2_MISMATCHED) != 0;
 190   bool requires_atomic_access = (decorators & MO_UNORDERED) == 0;
 191   bool unaligned = (decorators & C2_UNALIGNED) != 0;
 192   bool control_dependent = (decorators & C2_CONTROL_DEPENDENT_LOAD) != 0;
 193   bool unknown_control = (decorators & C2_UNKNOWN_CONTROL_LOAD) != 0;
 194   bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0;
 195   bool immutable = (decorators & C2_IMMUTABLE_MEMORY) != 0;
 196 
 197   MemNode::MemOrd mo = access.mem_node_mo();
 198   LoadNode::ControlDependency dep = unknown_control ? LoadNode::UnknownControl : LoadNode::DependsOnlyOnTest;
 199 
 200   Node* load;
 201   if (access.is_parse_access()) {
 202     C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
 203     GraphKit* kit = parse_access.kit();
 204     Node* control = control_dependent ? kit->control() : nullptr;
 205 
 206     if (immutable) {
 207       Compile* C = Compile::current();
 208       Node* mem = kit->immutable_memory();
 209       load = LoadNode::make(kit->gvn(), control, mem, adr,
 210                             adr_type, val_type, access.type(), mo, dep, requires_atomic_access,
 211                             unaligned, mismatched, unsafe, access.barrier_data());
 212       load = kit->gvn().transform(load);
 213     } else {
 214       load = kit->make_load(control, adr, val_type, access.type(), mo,
 215                             dep, requires_atomic_access, unaligned, mismatched, unsafe,
 216                             access.barrier_data());
 217     }
 218   } else {
 219     assert(access.is_opt_access(), "either parse or opt access");
 220     C2OptAccess& opt_access = static_cast<C2OptAccess&>(access);
 221     Node* control = control_dependent ? opt_access.ctl() : nullptr;
 222     MergeMemNode* mm = opt_access.mem();
 223     PhaseGVN& gvn = opt_access.gvn();
 224     Node* mem = mm->memory_at(gvn.C->get_alias_index(adr_type));

 846   assert(size->bottom_type()->base() == Type_X,
 847          "Should be of object size type (int for 32 bits, long for 64 bits)");
 848 
 849   // The native clone we are calling here expects the object size in words.
 850   // Add header/offset size to payload size to get object size.
 851   Node* const base_offset = phase->MakeConX(arraycopy_payload_base_offset(ac->is_clone_array()) >> LogBytesPerLong);
 852   Node* const full_size = phase->transform_later(new AddXNode(size, base_offset));
 853   // HeapAccess<>::clone expects size in heap words.
 854   // For 64-bits platforms, this is a no-operation.
 855   // For 32-bits platforms, we need to multiply full_size by HeapWordsPerLong (2).
 856   Node* const full_size_in_heap_words = phase->transform_later(new LShiftXNode(full_size, phase->intcon(LogHeapWordsPerLong)));
 857 
 858   Node* const call = phase->make_leaf_call(ctrl,
 859                                            mem,
 860                                            clone_type(),
 861                                            clone_addr,
 862                                            clone_name,
 863                                            TypeRawPtr::BOTTOM,
 864                                            src, dst, full_size_in_heap_words XTOP);
 865   phase->transform_later(call);
 866   phase->igvn().replace_node(ac, call);
 867 }
 868 
 869 void BarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
 870   Node* ctrl = ac->in(TypeFunc::Control);
 871   Node* mem = ac->in(TypeFunc::Memory);
 872   Node* src = ac->in(ArrayCopyNode::Src);
 873   Node* src_offset = ac->in(ArrayCopyNode::SrcPos);
 874   Node* dest = ac->in(ArrayCopyNode::Dest);
 875   Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
 876   Node* length = ac->in(ArrayCopyNode::Length);
 877 
 878   Node* payload_src = phase->basic_plus_adr(src, src_offset);
 879   Node* payload_dst = phase->basic_plus_adr(dest, dest_offset);
 880 
 881   const char* copyfunc_name = "arraycopy";
 882   address     copyfunc_addr = phase->basictype2arraycopy(T_LONG, nullptr, nullptr, true, copyfunc_name, true);
 883 
 884   const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
 885   const TypeFunc* call_type = OptoRuntime::fast_arraycopy_Type();
 886 
 887   Node* call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP);
 888   phase->transform_later(call);
 889 
 890   phase->igvn().replace_node(ac, call);
 891 }
 892 
 893 #undef XTOP
 894 
 895 static bool block_has_safepoint(const Block* block, uint from, uint to) {
 896   for (uint i = from; i < to; i++) {
 897     if (block->get_node(i)->is_MachSafePoint()) {
 898       // Safepoint found
 899       return true;
 900     }
 901   }
 902 
 903   // Safepoint not found
 904   return false;
 905 }
 906 
 907 static bool block_has_safepoint(const Block* block) {
 908   return block_has_safepoint(block, 0, block->number_of_nodes());
 909 }
 910 

  31 #include "opto/convertnode.hpp"
  32 #include "opto/graphKit.hpp"
  33 #include "opto/idealKit.hpp"
  34 #include "opto/macro.hpp"
  35 #include "opto/narrowptrnode.hpp"
  36 #include "opto/output.hpp"
  37 #include "opto/regalloc.hpp"
  38 #include "opto/runtime.hpp"
  39 #include "utilities/macros.hpp"
  40 #include CPU_HEADER(gc/shared/barrierSetAssembler)
  41 
  42 // By default this is a no-op.
  43 void BarrierSetC2::resolve_address(C2Access& access) const { }
  44 
  45 void* C2ParseAccess::barrier_set_state() const {
  46   return _kit->barrier_set_state();
  47 }
  48 
  49 PhaseGVN& C2ParseAccess::gvn() const { return _kit->gvn(); }
  50 
  51 Node* C2ParseAccess::control() const {
  52   return _ctl == nullptr ? _kit->control() : _ctl;
  53 }
  54 
  55 bool C2Access::needs_cpu_membar() const {
  56   bool mismatched   = (_decorators & C2_MISMATCHED) != 0;
  57   bool is_unordered = (_decorators & MO_UNORDERED) != 0;
  58 
  59   bool anonymous = (_decorators & C2_UNSAFE_ACCESS) != 0;
  60   bool in_heap   = (_decorators & IN_HEAP) != 0;
  61   bool in_native = (_decorators & IN_NATIVE) != 0;
  62   bool is_mixed  = !in_heap && !in_native;
  63 
  64   bool is_write  = (_decorators & C2_WRITE_ACCESS) != 0;
  65   bool is_read   = (_decorators & C2_READ_ACCESS) != 0;
  66   bool is_atomic = is_read && is_write;
  67 
  68   if (is_atomic) {
  69     // Atomics always need to be wrapped in CPU membars
  70     return true;
  71   }
  72 
  73   if (anonymous) {
  74     // We will need memory barriers unless we can determine a unique

 188   DecoratorSet decorators = access.decorators();
 189 
 190   Node* adr = access.addr().node();
 191   const TypePtr* adr_type = access.addr().type();
 192 
 193   bool mismatched = (decorators & C2_MISMATCHED) != 0;
 194   bool requires_atomic_access = (decorators & MO_UNORDERED) == 0;
 195   bool unaligned = (decorators & C2_UNALIGNED) != 0;
 196   bool control_dependent = (decorators & C2_CONTROL_DEPENDENT_LOAD) != 0;
 197   bool unknown_control = (decorators & C2_UNKNOWN_CONTROL_LOAD) != 0;
 198   bool unsafe = (decorators & C2_UNSAFE_ACCESS) != 0;
 199   bool immutable = (decorators & C2_IMMUTABLE_MEMORY) != 0;
 200 
 201   MemNode::MemOrd mo = access.mem_node_mo();
 202   LoadNode::ControlDependency dep = unknown_control ? LoadNode::UnknownControl : LoadNode::DependsOnlyOnTest;
 203 
 204   Node* load;
 205   if (access.is_parse_access()) {
 206     C2ParseAccess& parse_access = static_cast<C2ParseAccess&>(access);
 207     GraphKit* kit = parse_access.kit();
 208     Node* control = control_dependent ? parse_access.control() : nullptr;
 209 
 210     if (immutable) {
 211       Compile* C = Compile::current();
 212       Node* mem = kit->immutable_memory();
 213       load = LoadNode::make(kit->gvn(), control, mem, adr,
 214                             adr_type, val_type, access.type(), mo, dep, requires_atomic_access,
 215                             unaligned, mismatched, unsafe, access.barrier_data());
 216       load = kit->gvn().transform(load);
 217     } else {
 218       load = kit->make_load(control, adr, val_type, access.type(), mo,
 219                             dep, requires_atomic_access, unaligned, mismatched, unsafe,
 220                             access.barrier_data());
 221     }
 222   } else {
 223     assert(access.is_opt_access(), "either parse or opt access");
 224     C2OptAccess& opt_access = static_cast<C2OptAccess&>(access);
 225     Node* control = control_dependent ? opt_access.ctl() : nullptr;
 226     MergeMemNode* mm = opt_access.mem();
 227     PhaseGVN& gvn = opt_access.gvn();
 228     Node* mem = mm->memory_at(gvn.C->get_alias_index(adr_type));

 850   assert(size->bottom_type()->base() == Type_X,
 851          "Should be of object size type (int for 32 bits, long for 64 bits)");
 852 
 853   // The native clone we are calling here expects the object size in words.
 854   // Add header/offset size to payload size to get object size.
 855   Node* const base_offset = phase->MakeConX(arraycopy_payload_base_offset(ac->is_clone_array()) >> LogBytesPerLong);
 856   Node* const full_size = phase->transform_later(new AddXNode(size, base_offset));
 857   // HeapAccess<>::clone expects size in heap words.
 858   // For 64-bits platforms, this is a no-operation.
 859   // For 32-bits platforms, we need to multiply full_size by HeapWordsPerLong (2).
 860   Node* const full_size_in_heap_words = phase->transform_later(new LShiftXNode(full_size, phase->intcon(LogHeapWordsPerLong)));
 861 
 862   Node* const call = phase->make_leaf_call(ctrl,
 863                                            mem,
 864                                            clone_type(),
 865                                            clone_addr,
 866                                            clone_name,
 867                                            TypeRawPtr::BOTTOM,
 868                                            src, dst, full_size_in_heap_words XTOP);
 869   phase->transform_later(call);
 870   phase->replace_node(ac, call);
 871 }
 872 
 873 void BarrierSetC2::clone_at_expansion(PhaseMacroExpand* phase, ArrayCopyNode* ac) const {
 874   Node* ctrl = ac->in(TypeFunc::Control);
 875   Node* mem = ac->in(TypeFunc::Memory);
 876   Node* src = ac->in(ArrayCopyNode::Src);
 877   Node* src_offset = ac->in(ArrayCopyNode::SrcPos);
 878   Node* dest = ac->in(ArrayCopyNode::Dest);
 879   Node* dest_offset = ac->in(ArrayCopyNode::DestPos);
 880   Node* length = ac->in(ArrayCopyNode::Length);
 881 
 882   Node* payload_src = phase->basic_plus_adr(src, src_offset);
 883   Node* payload_dst = phase->basic_plus_adr(dest, dest_offset);
 884 
 885   const char* copyfunc_name = "arraycopy";
 886   address     copyfunc_addr = phase->basictype2arraycopy(T_LONG, nullptr, nullptr, true, copyfunc_name, true);
 887 
 888   const TypePtr* raw_adr_type = TypeRawPtr::BOTTOM;
 889   const TypeFunc* call_type = OptoRuntime::fast_arraycopy_Type();
 890 
 891   Node* call = phase->make_leaf_call(ctrl, mem, call_type, copyfunc_addr, copyfunc_name, raw_adr_type, payload_src, payload_dst, length XTOP);
 892   phase->transform_later(call);
 893 
 894   phase->replace_node(ac, call);
 895 }
 896 
 897 #undef XTOP
 898 
 899 static bool block_has_safepoint(const Block* block, uint from, uint to) {
 900   for (uint i = from; i < to; i++) {
 901     if (block->get_node(i)->is_MachSafePoint()) {
 902       // Safepoint found
 903       return true;
 904     }
 905   }
 906 
 907   // Safepoint not found
 908   return false;
 909 }
 910 
 911 static bool block_has_safepoint(const Block* block) {
 912   return block_has_safepoint(block, 0, block->number_of_nodes());
 913 }
 914 
< prev index next >