Use store barrier instead of full barrier.

Make use of ANDROID_MEMBAR_STORE when appropriate.  In mterp, define a
new SMP_DMB_ST macro that will (soon) expand into "dmb st" on ARMv7-A
platforms configured for SMP.

Bug 3003477.

Change-Id: I03c09e93e1374d1c668588c9ad52f5c08d3d2435
diff --git a/vm/mterp/armv4t/platform.S b/vm/mterp/armv4t/platform.S
index eca940a..30b7f5c 100644
--- a/vm/mterp/armv4t/platform.S
+++ b/vm/mterp/armv4t/platform.S
@@ -42,3 +42,9 @@
  */
 .macro  SMP_DMB
 .endm
+
+/*
+ * Macro for data memory barrier; not meaningful pre-ARMv6K.
+ */
+.macro  SMP_DMB_ST
+.endm
diff --git a/vm/mterp/armv5te/OP_RETURN_VOID_BARRIER.S b/vm/mterp/armv5te/OP_RETURN_VOID_BARRIER.S
index 3358941..1f51b62 100644
--- a/vm/mterp/armv5te/OP_RETURN_VOID_BARRIER.S
+++ b/vm/mterp/armv5te/OP_RETURN_VOID_BARRIER.S
@@ -1,3 +1,3 @@
 %verify "executed"
-    SMP_DMB                             @ TODO: want "DMB ST"
+    SMP_DMB_ST
     b       common_returnFromMethod
diff --git a/vm/mterp/armv5te/platform.S b/vm/mterp/armv5te/platform.S
index 9f59c8b..17bec6f 100644
--- a/vm/mterp/armv5te/platform.S
+++ b/vm/mterp/armv5te/platform.S
@@ -39,3 +39,9 @@
  */
 .macro  SMP_DMB
 .endm
+
+/*
+ * Macro for data memory barrier; not meaningful pre-ARMv6K.
+ */
+.macro  SMP_DMB_ST
+.endm
diff --git a/vm/mterp/armv7-a/platform.S b/vm/mterp/armv7-a/platform.S
index 6419da1..b9cdb07 100644
--- a/vm/mterp/armv7-a/platform.S
+++ b/vm/mterp/armv7-a/platform.S
@@ -39,8 +39,7 @@
 #endif
 
 /*
- * Macro for data memory barrier; not meaningful pre-ARMv6K.
- * If the argument is nonzero, emit barrier; otherwise, emit nothing.
+ * Macro for data memory barrier.
  */
 .macro  SMP_DMB
 #if ANDROID_SMP != 0
@@ -49,3 +48,14 @@
     /* not SMP */
 #endif
 .endm
+
+/*
+ * Macro for data memory barrier (store/store variant).
+ */
+.macro  SMP_DMB_ST
+#if ANDROID_SMP != 0
+    dmb                                 @ TODO: want "dmb st" here
+#else
+    /* not SMP */
+#endif
+.endm
diff --git a/vm/mterp/c/OP_RETURN_VOID_BARRIER.c b/vm/mterp/c/OP_RETURN_VOID_BARRIER.c
index 2c031eb..312402e 100644
--- a/vm/mterp/c/OP_RETURN_VOID_BARRIER.c
+++ b/vm/mterp/c/OP_RETURN_VOID_BARRIER.c
@@ -3,6 +3,6 @@
 #ifndef NDEBUG
     retval.j = 0xababababULL;   /* placate valgrind */
 #endif
-    ANDROID_MEMBAR_FULL();      /* TODO: use a store/store barrier */
+    ANDROID_MEMBAR_STORE();
     GOTO_returnFromMethod();
 OP_END
diff --git a/vm/mterp/out/InterpAsm-armv4t.S b/vm/mterp/out/InterpAsm-armv4t.S
index e1218d1..a8a0ddc 100644
--- a/vm/mterp/out/InterpAsm-armv4t.S
+++ b/vm/mterp/out/InterpAsm-armv4t.S
@@ -249,6 +249,12 @@
 .macro  SMP_DMB
 .endm
 
+/*
+ * Macro for data memory barrier; not meaningful pre-ARMv6K.
+ */
+.macro  SMP_DMB_ST
+.endm
+
 /* File: armv5te/entry.S */
 /*
  * Copyright (C) 2008 The Android Open Source Project
@@ -7774,7 +7780,7 @@
     .balign 64
 .L_OP_RETURN_VOID_BARRIER: /* 0xf1 */
 /* File: armv5te/OP_RETURN_VOID_BARRIER.S */
-    SMP_DMB                             @ TODO: want "DMB ST"
+    SMP_DMB_ST
     b       common_returnFromMethod
 
 /* ------------------------------ */
diff --git a/vm/mterp/out/InterpAsm-armv5te-vfp.S b/vm/mterp/out/InterpAsm-armv5te-vfp.S
index 0d9cb26..8c3a986 100644
--- a/vm/mterp/out/InterpAsm-armv5te-vfp.S
+++ b/vm/mterp/out/InterpAsm-armv5te-vfp.S
@@ -249,6 +249,12 @@
 .macro  SMP_DMB
 .endm
 
+/*
+ * Macro for data memory barrier; not meaningful pre-ARMv6K.
+ */
+.macro  SMP_DMB_ST
+.endm
+
 /* File: armv5te/entry.S */
 /*
  * Copyright (C) 2008 The Android Open Source Project
@@ -7454,7 +7460,7 @@
     .balign 64
 .L_OP_RETURN_VOID_BARRIER: /* 0xf1 */
 /* File: armv5te/OP_RETURN_VOID_BARRIER.S */
-    SMP_DMB                             @ TODO: want "DMB ST"
+    SMP_DMB_ST
     b       common_returnFromMethod
 
 /* ------------------------------ */
diff --git a/vm/mterp/out/InterpAsm-armv5te.S b/vm/mterp/out/InterpAsm-armv5te.S
index 1b6a104..9990d1c 100644
--- a/vm/mterp/out/InterpAsm-armv5te.S
+++ b/vm/mterp/out/InterpAsm-armv5te.S
@@ -249,6 +249,12 @@
 .macro  SMP_DMB
 .endm
 
+/*
+ * Macro for data memory barrier; not meaningful pre-ARMv6K.
+ */
+.macro  SMP_DMB_ST
+.endm
+
 /* File: armv5te/entry.S */
 /*
  * Copyright (C) 2008 The Android Open Source Project
@@ -7776,7 +7782,7 @@
     .balign 64
 .L_OP_RETURN_VOID_BARRIER: /* 0xf1 */
 /* File: armv5te/OP_RETURN_VOID_BARRIER.S */
-    SMP_DMB                             @ TODO: want "DMB ST"
+    SMP_DMB_ST
     b       common_returnFromMethod
 
 /* ------------------------------ */
diff --git a/vm/mterp/out/InterpAsm-armv7-a-neon.S b/vm/mterp/out/InterpAsm-armv7-a-neon.S
index 0359279..0af2046 100644
--- a/vm/mterp/out/InterpAsm-armv7-a-neon.S
+++ b/vm/mterp/out/InterpAsm-armv7-a-neon.S
@@ -248,8 +248,7 @@
 #endif
 
 /*
- * Macro for data memory barrier; not meaningful pre-ARMv6K.
- * If the argument is nonzero, emit barrier; otherwise, emit nothing.
+ * Macro for data memory barrier.
  */
 .macro  SMP_DMB
 #if ANDROID_SMP != 0
@@ -259,6 +258,17 @@
 #endif
 .endm
 
+/*
+ * Macro for data memory barrier (store/store variant).
+ */
+.macro  SMP_DMB_ST
+#if ANDROID_SMP != 0
+    dmb                                 @ TODO: want "dmb st" here
+#else
+    /* not SMP */
+#endif
+.endm
+
 /* File: armv5te/entry.S */
 /*
  * Copyright (C) 2008 The Android Open Source Project
@@ -7408,7 +7418,7 @@
     .balign 64
 .L_OP_RETURN_VOID_BARRIER: /* 0xf1 */
 /* File: armv5te/OP_RETURN_VOID_BARRIER.S */
-    SMP_DMB                             @ TODO: want "DMB ST"
+    SMP_DMB_ST
     b       common_returnFromMethod
 
 /* ------------------------------ */
diff --git a/vm/mterp/out/InterpAsm-armv7-a.S b/vm/mterp/out/InterpAsm-armv7-a.S
index 744e29b..dc5c051 100644
--- a/vm/mterp/out/InterpAsm-armv7-a.S
+++ b/vm/mterp/out/InterpAsm-armv7-a.S
@@ -248,8 +248,7 @@
 #endif
 
 /*
- * Macro for data memory barrier; not meaningful pre-ARMv6K.
- * If the argument is nonzero, emit barrier; otherwise, emit nothing.
+ * Macro for data memory barrier.
  */
 .macro  SMP_DMB
 #if ANDROID_SMP != 0
@@ -259,6 +258,17 @@
 #endif
 .endm
 
+/*
+ * Macro for data memory barrier (store/store variant).
+ */
+.macro  SMP_DMB_ST
+#if ANDROID_SMP != 0
+    dmb                                 @ TODO: want "dmb st" here
+#else
+    /* not SMP */
+#endif
+.endm
+
 /* File: armv5te/entry.S */
 /*
  * Copyright (C) 2008 The Android Open Source Project
@@ -7408,7 +7418,7 @@
     .balign 64
 .L_OP_RETURN_VOID_BARRIER: /* 0xf1 */
 /* File: armv5te/OP_RETURN_VOID_BARRIER.S */
-    SMP_DMB                             @ TODO: want "DMB ST"
+    SMP_DMB_ST
     b       common_returnFromMethod
 
 /* ------------------------------ */
diff --git a/vm/mterp/out/InterpC-allstubs.c b/vm/mterp/out/InterpC-allstubs.c
index 419c265..6c1d935 100644
--- a/vm/mterp/out/InterpC-allstubs.c
+++ b/vm/mterp/out/InterpC-allstubs.c
@@ -2979,7 +2979,7 @@
 #ifndef NDEBUG
     retval.j = 0xababababULL;   /* placate valgrind */
 #endif
-    ANDROID_MEMBAR_FULL();      /* TODO: use a store/store barrier */
+    ANDROID_MEMBAR_STORE();
     GOTO_returnFromMethod();
 OP_END
 
diff --git a/vm/mterp/out/InterpC-portdbg.c b/vm/mterp/out/InterpC-portdbg.c
index 39bb057..269ccd1 100644
--- a/vm/mterp/out/InterpC-portdbg.c
+++ b/vm/mterp/out/InterpC-portdbg.c
@@ -3340,7 +3340,7 @@
 #ifndef NDEBUG
     retval.j = 0xababababULL;   /* placate valgrind */
 #endif
-    ANDROID_MEMBAR_FULL();      /* TODO: use a store/store barrier */
+    ANDROID_MEMBAR_STORE();
     GOTO_returnFromMethod();
 OP_END
 
diff --git a/vm/mterp/out/InterpC-portstd.c b/vm/mterp/out/InterpC-portstd.c
index 7a9ef41..ad85a5f 100644
--- a/vm/mterp/out/InterpC-portstd.c
+++ b/vm/mterp/out/InterpC-portstd.c
@@ -3090,7 +3090,7 @@
 #ifndef NDEBUG
     retval.j = 0xababababULL;   /* placate valgrind */
 #endif
-    ANDROID_MEMBAR_FULL();      /* TODO: use a store/store barrier */
+    ANDROID_MEMBAR_STORE();
     GOTO_returnFromMethod();
 OP_END
 
diff --git a/vm/mterp/out/InterpC-x86-atom.c b/vm/mterp/out/InterpC-x86-atom.c
index 5165bc4..dfcc8ad 100644
--- a/vm/mterp/out/InterpC-x86-atom.c
+++ b/vm/mterp/out/InterpC-x86-atom.c
@@ -1237,7 +1237,7 @@
 #ifndef NDEBUG
     retval.j = 0xababababULL;   /* placate valgrind */
 #endif
-    ANDROID_MEMBAR_FULL();      /* TODO: use a store/store barrier */
+    ANDROID_MEMBAR_STORE();
     GOTO_returnFromMethod();
 OP_END
 
diff --git a/vm/mterp/out/InterpC-x86.c b/vm/mterp/out/InterpC-x86.c
index 4e3effc..146f4eb 100644
--- a/vm/mterp/out/InterpC-x86.c
+++ b/vm/mterp/out/InterpC-x86.c
@@ -1262,7 +1262,7 @@
 #ifndef NDEBUG
     retval.j = 0xababababULL;   /* placate valgrind */
 #endif
-    ANDROID_MEMBAR_FULL();      /* TODO: use a store/store barrier */
+    ANDROID_MEMBAR_STORE();
     GOTO_returnFromMethod();
 OP_END
 
diff --git a/vm/native/java_lang_reflect_Field.c b/vm/native/java_lang_reflect_Field.c
index 2c4e8a2..09a7499 100644
--- a/vm/native/java_lang_reflect_Field.c
+++ b/vm/native/java_lang_reflect_Field.c
@@ -381,7 +381,7 @@
          * store/store barrier here (JMM requirement).
          */
         if (dvmIsFinalField(&ifield->field)) {
-            ANDROID_MEMBAR_FULL(); /* TODO: replace full bar with store/store */
+            ANDROID_MEMBAR_STORE();
         }
 #endif
     } else {