src/hotspot/share/opto/memnode.hpp
changeset 58516 d376d86b0a01
parent 58372 43c4fb8ba96b
child 58665 30a5049a36bb
child 58679 9c3209ff7550
child 58751 0f882d53c204
equal deleted inserted replaced
58515:8f849d3ec1e5 58516:d376d86b0a01
    41 class MemNode : public Node {
    41 class MemNode : public Node {
    42 private:
    42 private:
    43   bool _unaligned_access; // Unaligned access from unsafe
    43   bool _unaligned_access; // Unaligned access from unsafe
    44   bool _mismatched_access; // Mismatched access from unsafe: byte read in integer array for instance
    44   bool _mismatched_access; // Mismatched access from unsafe: byte read in integer array for instance
    45   bool _unsafe_access;     // Access of unsafe origin.
    45   bool _unsafe_access;     // Access of unsafe origin.
       
    46   uint8_t _barrier; // Bit field with barrier information
       
    47 
    46 protected:
    48 protected:
    47 #ifdef ASSERT
    49 #ifdef ASSERT
    48   const TypePtr* _adr_type;     // What kind of memory is being addressed?
    50   const TypePtr* _adr_type;     // What kind of memory is being addressed?
    49 #endif
    51 #endif
    50   virtual uint size_of() const;
    52   virtual uint size_of() const;
    60                  release,       // Store has to release or be preceded by MemBarRelease.
    62                  release,       // Store has to release or be preceded by MemBarRelease.
    61                  seqcst,        // LoadStore has to have both acquire and release semantics.
    63                  seqcst,        // LoadStore has to have both acquire and release semantics.
    62                  unset          // The memory ordering is not set (used for testing)
    64                  unset          // The memory ordering is not set (used for testing)
    63   } MemOrd;
    65   } MemOrd;
    64 protected:
    66 protected:
    65   MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at )
    67   MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at ) :
    66     : Node(c0,c1,c2   ), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) {
    68       Node(c0,c1,c2),
       
    69       _unaligned_access(false),
       
    70       _mismatched_access(false),
       
    71       _unsafe_access(false),
       
    72       _barrier(0) {
    67     init_class_id(Class_Mem);
    73     init_class_id(Class_Mem);
    68     debug_only(_adr_type=at; adr_type();)
    74     debug_only(_adr_type=at; adr_type();)
    69   }
    75   }
    70   MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3 )
    76   MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3 ) :
    71     : Node(c0,c1,c2,c3), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) {
    77       Node(c0,c1,c2,c3),
       
    78       _unaligned_access(false),
       
    79       _mismatched_access(false),
       
    80       _unsafe_access(false),
       
    81       _barrier(0) {
    72     init_class_id(Class_Mem);
    82     init_class_id(Class_Mem);
    73     debug_only(_adr_type=at; adr_type();)
    83     debug_only(_adr_type=at; adr_type();)
    74   }
    84   }
    75   MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3, Node *c4)
    85   MemNode( Node *c0, Node *c1, Node *c2, const TypePtr* at, Node *c3, Node *c4) :
    76     : Node(c0,c1,c2,c3,c4), _unaligned_access(false), _mismatched_access(false), _unsafe_access(false) {
    86       Node(c0,c1,c2,c3,c4),
       
    87       _unaligned_access(false),
       
    88       _mismatched_access(false),
       
    89       _unsafe_access(false),
       
    90       _barrier(0) {
    77     init_class_id(Class_Mem);
    91     init_class_id(Class_Mem);
    78     debug_only(_adr_type=at; adr_type();)
    92     debug_only(_adr_type=at; adr_type();)
    79   }
    93   }
    80 
    94 
    81   virtual Node* find_previous_arraycopy(PhaseTransform* phase, Node* ld_alloc, Node*& mem, bool can_see_stored_value) const { return NULL; }
    95   virtual Node* find_previous_arraycopy(PhaseTransform* phase, Node* ld_alloc, Node*& mem, bool can_see_stored_value) const { return NULL; }
   122     return type2aelembytes(memory_type(), true);
   136     return type2aelembytes(memory_type(), true);
   123 #else
   137 #else
   124     return type2aelembytes(memory_type());
   138     return type2aelembytes(memory_type());
   125 #endif
   139 #endif
   126   }
   140   }
       
   141 
       
   142   uint8_t barrier_data() { return _barrier; }
       
   143   void set_barrier_data(uint8_t barrier_data) { _barrier = barrier_data; }
   127 
   144 
   128   // Search through memory states which precede this node (load or store).
   145   // Search through memory states which precede this node (load or store).
   129   // Look for an exact match for the address, with no intervening
   146   // Look for an exact match for the address, with no intervening
   130   // aliased stores.
   147   // aliased stores.
   131   Node* find_previous_store(PhaseTransform* phase);
   148   Node* find_previous_store(PhaseTransform* phase);
   179   // loads that can be reordered, and such requiring acquire semantics to
   196   // loads that can be reordered, and such requiring acquire semantics to
   180   // adhere to the Java specification.  The required behaviour is stored in
   197   // adhere to the Java specification.  The required behaviour is stored in
   181   // this field.
   198   // this field.
   182   const MemOrd _mo;
   199   const MemOrd _mo;
   183 
   200 
   184   uint _barrier; // Bit field with barrier information
       
   185 
       
   186   AllocateNode* is_new_object_mark_load(PhaseGVN *phase) const;
   201   AllocateNode* is_new_object_mark_load(PhaseGVN *phase) const;
   187 
   202 
   188 protected:
   203 protected:
   189   virtual bool cmp(const Node &n) const;
   204   virtual bool cmp(const Node &n) const;
   190   virtual uint size_of() const; // Size is bigger
   205   virtual uint size_of() const; // Size is bigger
   194 
   209 
   195   virtual Node* find_previous_arraycopy(PhaseTransform* phase, Node* ld_alloc, Node*& mem, bool can_see_stored_value) const;
   210   virtual Node* find_previous_arraycopy(PhaseTransform* phase, Node* ld_alloc, Node*& mem, bool can_see_stored_value) const;
   196 public:
   211 public:
   197 
   212 
   198   LoadNode(Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *rt, MemOrd mo, ControlDependency control_dependency)
   213   LoadNode(Node *c, Node *mem, Node *adr, const TypePtr* at, const Type *rt, MemOrd mo, ControlDependency control_dependency)
   199     : MemNode(c,mem,adr,at), _control_dependency(control_dependency), _mo(mo), _barrier(0), _type(rt) {
   214     : MemNode(c,mem,adr,at), _control_dependency(control_dependency), _mo(mo), _type(rt) {
   200     init_class_id(Class_Load);
   215     init_class_id(Class_Load);
   201   }
   216   }
   202   inline bool is_unordered() const { return !is_acquire(); }
   217   inline bool is_unordered() const { return !is_acquire(); }
   203   inline bool is_acquire() const {
   218   inline bool is_acquire() const {
   204     assert(_mo == unordered || _mo == acquire, "unexpected");
   219     assert(_mo == unordered || _mo == acquire, "unexpected");
   262   // Check if the load's memory input is a Phi node with the same control.
   277   // Check if the load's memory input is a Phi node with the same control.
   263   bool is_instance_field_load_with_local_phi(Node* ctrl);
   278   bool is_instance_field_load_with_local_phi(Node* ctrl);
   264 
   279 
   265   Node* convert_to_unsigned_load(PhaseGVN& gvn);
   280   Node* convert_to_unsigned_load(PhaseGVN& gvn);
   266   Node* convert_to_signed_load(PhaseGVN& gvn);
   281   Node* convert_to_signed_load(PhaseGVN& gvn);
   267 
       
   268   void copy_barrier_info(const Node* src) { _barrier = src->as_Load()->_barrier; }
       
   269   uint barrier_data() { return _barrier; }
       
   270   void set_barrier_data(uint barrier_data) { _barrier |= barrier_data; }
       
   271 
   282 
   272   void pin() { _control_dependency = Pinned; }
   283   void pin() { _control_dependency = Pinned; }
   273   bool has_unknown_control_dependency() const { return _control_dependency == UnknownControl; }
   284   bool has_unknown_control_dependency() const { return _control_dependency == UnknownControl; }
   274 
   285 
   275 #ifndef PRODUCT
   286 #ifndef PRODUCT
   818 // Note: is_Mem() method returns 'true' for this class.
   829 // Note: is_Mem() method returns 'true' for this class.
   819 class LoadStoreNode : public Node {
   830 class LoadStoreNode : public Node {
   820 private:
   831 private:
   821   const Type* const _type;      // What kind of value is loaded?
   832   const Type* const _type;      // What kind of value is loaded?
   822   const TypePtr* _adr_type;     // What kind of memory is being addressed?
   833   const TypePtr* _adr_type;     // What kind of memory is being addressed?
   823   bool _has_barrier;
   834   uint8_t _barrier; // Bit field with barrier information
   824   virtual uint size_of() const; // Size is bigger
   835   virtual uint size_of() const; // Size is bigger
   825 public:
   836 public:
   826   LoadStoreNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at, const Type* rt, uint required );
   837   LoadStoreNode( Node *c, Node *mem, Node *adr, Node *val, const TypePtr* at, const Type* rt, uint required );
   827   virtual bool depends_only_on_test() const { return false; }
   838   virtual bool depends_only_on_test() const { return false; }
   828   virtual uint match_edge(uint idx) const { return idx == MemNode::Address || idx == MemNode::ValueIn; }
   839   virtual uint match_edge(uint idx) const { return idx == MemNode::Address || idx == MemNode::ValueIn; }
   831   virtual uint ideal_reg() const;
   842   virtual uint ideal_reg() const;
   832   virtual const class TypePtr *adr_type() const { return _adr_type; }  // returns bottom_type of address
   843   virtual const class TypePtr *adr_type() const { return _adr_type; }  // returns bottom_type of address
   833 
   844 
   834   bool result_not_used() const;
   845   bool result_not_used() const;
   835   MemBarNode* trailing_membar() const;
   846   MemBarNode* trailing_membar() const;
   836   void set_has_barrier() { _has_barrier = true; };
   847 
   837   bool has_barrier() const { return _has_barrier; };
   848   uint8_t barrier_data() { return _barrier; }
       
   849   void set_barrier_data(uint8_t barrier_data) { _barrier = barrier_data; }
   838 };
   850 };
   839 
   851 
   840 class LoadStoreConditionalNode : public LoadStoreNode {
   852 class LoadStoreConditionalNode : public LoadStoreNode {
   841 public:
   853 public:
   842   enum {
   854   enum {
   884 public:
   896 public:
   885   CompareAndSwapNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : LoadStoreConditionalNode(c, mem, adr, val, ex), _mem_ord(mem_ord) {}
   897   CompareAndSwapNode( Node *c, Node *mem, Node *adr, Node *val, Node *ex, MemNode::MemOrd mem_ord) : LoadStoreConditionalNode(c, mem, adr, val, ex), _mem_ord(mem_ord) {}
   886   MemNode::MemOrd order() const {
   898   MemNode::MemOrd order() const {
   887     return _mem_ord;
   899     return _mem_ord;
   888   }
   900   }
       
   901   virtual uint size_of() const { return sizeof(*this); }
   889 };
   902 };
   890 
   903 
   891 class CompareAndExchangeNode : public LoadStoreNode {
   904 class CompareAndExchangeNode : public LoadStoreNode {
   892 private:
   905 private:
   893   const MemNode::MemOrd _mem_ord;
   906   const MemNode::MemOrd _mem_ord;
   901   }
   914   }
   902 
   915 
   903   MemNode::MemOrd order() const {
   916   MemNode::MemOrd order() const {
   904     return _mem_ord;
   917     return _mem_ord;
   905   }
   918   }
       
   919   virtual uint size_of() const { return sizeof(*this); }
   906 };
   920 };
   907 
   921 
   908 //------------------------------CompareAndSwapBNode---------------------------
   922 //------------------------------CompareAndSwapBNode---------------------------
   909 class CompareAndSwapBNode : public CompareAndSwapNode {
   923 class CompareAndSwapBNode : public CompareAndSwapNode {
   910 public:
   924 public: