8209691: Allow MemBar on single memory slice
authorroland
Wed, 22 Aug 2018 10:29:17 +0200
changeset 51566 904cf5407ac7
parent 51565 7e5f08c619e3
child 51567 0c4f2b26849e
child 56877 b37a3b5b5a29
8209691: Allow MemBar on single memory slice Reviewed-by: kvn, vlivanov
src/hotspot/share/adlc/formssel.cpp
src/hotspot/share/adlc/formssel.hpp
src/hotspot/share/adlc/output_c.cpp
src/hotspot/share/adlc/output_h.cpp
src/hotspot/share/opto/machnode.cpp
src/hotspot/share/opto/machnode.hpp
src/hotspot/share/opto/matcher.cpp
src/hotspot/share/opto/node.hpp
--- a/src/hotspot/share/adlc/formssel.cpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/adlc/formssel.cpp	Wed Aug 22 10:29:17 2018 +0200
@@ -641,22 +641,6 @@
 }
 
 
-bool InstructForm::is_wide_memory_kill(FormDict &globals) const {
-  if( _matrule == NULL ) return false;
-  if( !_matrule->_opType ) return false;
-
-  if( strcmp(_matrule->_opType,"MemBarRelease") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarAcquire") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarReleaseLock") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarAcquireLock") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarStoreStore") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"MemBarVolatile") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"StoreFence") == 0 ) return true;
-  if( strcmp(_matrule->_opType,"LoadFence") == 0 ) return true;
-
-  return false;
-}
-
 int InstructForm::memory_operand(FormDict &globals) const {
   // Machine independent loads must be checked for anti-dependences
   // Check if instruction has a USE of a memory operand class, or a def.
@@ -1171,6 +1155,9 @@
   else if (is_ideal_nop()) {
     return "MachNopNode";
   }
+  else if( is_ideal_membar()) {
+    return "MachMemBarNode";
+  }
   else if (is_ideal_jump()) {
     return "MachJumpNode";
   }
@@ -4116,7 +4103,8 @@
     !strcmp(_opType,"StoreFence") ||
     !strcmp(_opType,"MemBarVolatile") ||
     !strcmp(_opType,"MemBarCPUOrder") ||
-    !strcmp(_opType,"MemBarStoreStore");
+    !strcmp(_opType,"MemBarStoreStore") ||
+    !strcmp(_opType,"OnSpinWait");
 }
 
 bool MatchRule::is_ideal_loadPC() const {
--- a/src/hotspot/share/adlc/formssel.hpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/adlc/formssel.hpp	Wed Aug 22 10:29:17 2018 +0200
@@ -191,7 +191,6 @@
   // loads from memory, so must check for anti-dependence
   virtual bool        needs_anti_dependence_check(FormDict &globals) const;
   virtual int         memory_operand(FormDict &globals) const;
-          bool        is_wide_memory_kill(FormDict &globals) const;
 
   enum memory_operand_type {
     NO_MEMORY_OPERAND = -1,
--- a/src/hotspot/share/adlc/output_c.cpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/adlc/output_c.cpp	Wed Aug 22 10:29:17 2018 +0200
@@ -3263,10 +3263,6 @@
 
     // Analyze machine instructions that either USE or DEF memory.
     int memory_operand = instr->memory_operand(_globalNames);
-    // Some guys kill all of memory
-    if ( instr->is_wide_memory_kill(_globalNames) ) {
-      memory_operand = InstructForm::MANY_MEMORY_OPERANDS;
-    }
 
     if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) {
       if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) {
--- a/src/hotspot/share/adlc/output_h.cpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/adlc/output_h.cpp	Wed Aug 22 10:29:17 2018 +0200
@@ -2002,10 +2002,6 @@
 
     // Analyze machine instructions that either USE or DEF memory.
     int memory_operand = instr->memory_operand(_globalNames);
-    // Some guys kill all of memory
-    if ( instr->is_wide_memory_kill(_globalNames) ) {
-      memory_operand = InstructForm::MANY_MEMORY_OPERANDS;
-    }
     if ( memory_operand != InstructForm::NO_MEMORY_OPERAND ) {
       if( memory_operand == InstructForm::MANY_MEMORY_OPERANDS ) {
         fprintf(fp,"  virtual const TypePtr *adr_type() const;\n");
--- a/src/hotspot/share/opto/machnode.cpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/opto/machnode.cpp	Wed Aug 22 10:29:17 2018 +0200
@@ -811,6 +811,13 @@
   return &jvms_for_throw;
 }
 
+uint MachMemBarNode::size_of() const { return sizeof(*this); }
+
+const TypePtr *MachMemBarNode::adr_type() const {
+  return _adr_type;
+}
+
+
 //=============================================================================
 #ifndef PRODUCT
 void labelOper::int_format(PhaseRegAlloc *ra, const MachNode *node, outputStream *st) const {
--- a/src/hotspot/share/opto/machnode.hpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/opto/machnode.hpp	Wed Aug 22 10:29:17 2018 +0200
@@ -1000,6 +1000,19 @@
   virtual JVMState* jvms() const;
 };
 
+class MachMemBarNode : public MachNode {
+  virtual uint size_of() const; // Size is bigger
+public:
+  const TypePtr* _adr_type;     // memory effects
+  MachMemBarNode() : MachNode() {
+    init_class_id(Class_MachMemBar);
+    _adr_type = TypePtr::BOTTOM; // the default: all of memory
+  }
+
+  void set_adr_type(const TypePtr* atp) { _adr_type = atp; }
+  virtual const TypePtr *adr_type() const;
+};
+
 
 //------------------------------MachTempNode-----------------------------------
 // Node used by the adlc to construct inputs to represent temporary registers
--- a/src/hotspot/share/opto/matcher.cpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/opto/matcher.cpp	Wed Aug 22 10:29:17 2018 +0200
@@ -1002,6 +1002,9 @@
             m = n->is_SafePoint() ? match_sfpt(n->as_SafePoint()):match_tree(n);
             if (C->failing())  return NULL;
             if (m == NULL) { Matcher::soft_match_failure(); return NULL; }
+            if (n->is_MemBar()) {
+              m->as_MachMemBar()->set_adr_type(n->adr_type());
+            }
           } else {                  // Nothing the matcher cares about
             if (n->is_Proj() && n->in(0) != NULL && n->in(0)->is_Multi()) {       // Projections?
               // Convert to machine-dependent projection
--- a/src/hotspot/share/opto/node.hpp	Wed Aug 29 11:25:51 2018 +0100
+++ b/src/hotspot/share/opto/node.hpp	Wed Aug 22 10:29:17 2018 +0200
@@ -107,6 +107,7 @@
 class MachSpillCopyNode;
 class MachTempNode;
 class MachMergeNode;
+class MachMemBarNode;
 class Matcher;
 class MemBarNode;
 class MemBarStoreStoreNode;
@@ -659,6 +660,7 @@
       DEFINE_CLASS_ID(MachConstant,     Mach, 5)
         DEFINE_CLASS_ID(MachJump,       MachConstant, 0)
       DEFINE_CLASS_ID(MachMerge,        Mach, 6)
+      DEFINE_CLASS_ID(MachMemBar,       Mach, 7)
 
     DEFINE_CLASS_ID(Type,  Node, 2)
       DEFINE_CLASS_ID(Phi,   Type, 0)
@@ -852,6 +854,7 @@
   DEFINE_CLASS_QUERY(MachSafePoint)
   DEFINE_CLASS_QUERY(MachSpillCopy)
   DEFINE_CLASS_QUERY(MachTemp)
+  DEFINE_CLASS_QUERY(MachMemBar)
   DEFINE_CLASS_QUERY(MachMerge)
   DEFINE_CLASS_QUERY(Mem)
   DEFINE_CLASS_QUERY(MemBar)