summaryrefslogtreecommitdiffstats
path: root/compiler/dex/quick/mips/utility_mips.cc
diff options
context:
space:
mode:
authorHans Boehm <hboehm@google.com>2014-06-27 14:50:10 -0700
committerHans Boehm <hboehm@google.com>2014-07-11 15:37:05 -0700
commit48f5c47907654350ce30a8dfdda0e977f5d3d39f (patch)
treec535d2af13e6fb175ba4ab0d9d044b5c9d2f8489 /compiler/dex/quick/mips/utility_mips.cc
parent438b9039c77b2c9556f362e8cbbefcf21c55b527 (diff)
downloadandroid_art-48f5c47907654350ce30a8dfdda0e977f5d3d39f.tar.gz
android_art-48f5c47907654350ce30a8dfdda0e977f5d3d39f.tar.bz2
android_art-48f5c47907654350ce30a8dfdda0e977f5d3d39f.zip
Replace memory barriers to better reflect Java needs.
Replaces barriers that enforce ordering of one access type (e.g. Load) with respect to another (e.g. store) with more general ones that better reflect both Java requirements and actual hardware barrier/fence instructions. The old code was inconsistent and unclear about which barriers implied which others. Sometimes multiple barriers were generated and then eliminated; sometimes it was assumed that certain barriers implied others. The new barriers closely parallel those in C++11, though, for now, we use something closer to the old naming. Bug: 14685856 Change-Id: Ie1c80afe3470057fc6f2b693a9831dfe83add831
Diffstat (limited to 'compiler/dex/quick/mips/utility_mips.cc')
-rw-r--r--compiler/dex/quick/mips/utility_mips.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/dex/quick/mips/utility_mips.cc b/compiler/dex/quick/mips/utility_mips.cc
index 129a696625..75d3c5d4bf 100644
--- a/compiler/dex/quick/mips/utility_mips.cc
+++ b/compiler/dex/quick/mips/utility_mips.cc
@@ -563,10 +563,7 @@ LIR* MipsMir2Lir::LoadBaseDisp(RegStorage r_base, int displacement, RegStorage r
load = LoadBaseDispBody(r_base, displacement, r_dest, size);
if (UNLIKELY(is_volatile == kVolatile)) {
- // Without context sensitive analysis, we must issue the most conservative barriers.
- // In this case, either a load or store may follow so we issue both barriers.
- GenMemBarrier(kLoadLoad);
- GenMemBarrier(kLoadStore);
+ GenMemBarrier(kLoadAny);
}
return load;
@@ -658,8 +655,8 @@ LIR* MipsMir2Lir::StoreBaseDisp(RegStorage r_base, int displacement, RegStorage
OpSize size, VolatileKind is_volatile) {
if (is_volatile == kVolatile) {
DCHECK(size != k64 && size != kDouble);
- // There might have been a store before this volatile one so insert StoreStore barrier.
- GenMemBarrier(kStoreStore);
+ // Ensure that prior accesses become visible to other threads first.
+ GenMemBarrier(kAnyStore);
}
// TODO: base this on target.
@@ -670,8 +667,9 @@ LIR* MipsMir2Lir::StoreBaseDisp(RegStorage r_base, int displacement, RegStorage
store = StoreBaseDispBody(r_base, displacement, r_src, size);
if (UNLIKELY(is_volatile == kVolatile)) {
- // A load might follow the volatile store so insert a StoreLoad barrier.
- GenMemBarrier(kStoreLoad);
+ // Preserve order with respect to any subsequent volatile loads.
+ // We need StoreLoad, but that generally requires the most expensive barrier.
+ GenMemBarrier(kAnyAny);
}
return store;