diff options
author | Hans Boehm <hboehm@google.com> | 2014-06-27 14:50:10 -0700 |
---|---|---|
committer | Hans Boehm <hboehm@google.com> | 2014-07-11 15:37:05 -0700 |
commit | 48f5c47907654350ce30a8dfdda0e977f5d3d39f (patch) | |
tree | c535d2af13e6fb175ba4ab0d9d044b5c9d2f8489 /compiler/dex/quick/gen_invoke.cc | |
parent | 438b9039c77b2c9556f362e8cbbefcf21c55b527 (diff) | |
download | android_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/gen_invoke.cc')
-rwxr-xr-x | compiler/dex/quick/gen_invoke.cc | 13 |
1 files changed, 5 insertions, 8 deletions
diff --git a/compiler/dex/quick/gen_invoke.cc b/compiler/dex/quick/gen_invoke.cc index 6c0dfe80a6..56986b4b6f 100755 --- a/compiler/dex/quick/gen_invoke.cc +++ b/compiler/dex/quick/gen_invoke.cc @@ -1711,10 +1711,7 @@ bool Mir2Lir::GenInlinedUnsafeGet(CallInfo* info, } if (is_volatile) { - // 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); } if (is_long) { @@ -1737,8 +1734,7 @@ bool Mir2Lir::GenInlinedUnsafePut(CallInfo* info, bool is_long, rl_src_offset = NarrowRegLoc(rl_src_offset); // ignore high half in info->args[3] RegLocation rl_src_value = info->args[4]; // value to store if (is_volatile || is_ordered) { - // There might have been a store before this volatile one so insert StoreStore barrier. - GenMemBarrier(kStoreStore); + GenMemBarrier(kAnyStore); } RegLocation rl_object = LoadValue(rl_src_obj, kRefReg); RegLocation rl_offset = LoadValue(rl_src_offset, kCoreReg); @@ -1767,8 +1763,9 @@ bool Mir2Lir::GenInlinedUnsafePut(CallInfo* info, bool is_long, FreeTemp(rl_offset.reg); if (is_volatile) { - // A load might follow the volatile store so insert a StoreLoad barrier. - GenMemBarrier(kStoreLoad); + // Prevent reordering with a subsequent volatile load. + // May also be needed to address store atomicity issues. + GenMemBarrier(kAnyAny); } if (is_object) { MarkGCCard(rl_value.reg, rl_object.reg); |