diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2015-04-23 20:42:50 -0700 |
---|---|---|
committer | Hiroshi Yamauchi <yamauchi@google.com> | 2015-04-23 20:52:03 -0700 |
commit | 28da248e817762ef6e2709a8379228867862d97a (patch) | |
tree | 87b378408ff6f0680ca08f054e50752b394594b8 /libart | |
parent | 726db7aea4817a43a1fd094d18e57de5b244ee39 (diff) | |
download | libcore-28da248e817762ef6e2709a8379228867862d97a.zip libcore-28da248e817762ef6e2709a8379228867862d97a.tar.gz libcore-28da248e817762ef6e2709a8379228867862d97a.tar.bz2 |
Fix hashCode() for the read barrier lock word change.
Mask the low 28 bits of the lock word.
Bug: 19355854
Bug: 12687968
Change-Id: Ic6db7e23fa1a98b28564880d78e7c7cc0c8c0bdc
Diffstat (limited to 'libart')
-rw-r--r-- | libart/src/main/java/java/lang/Object.java | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libart/src/main/java/java/lang/Object.java b/libart/src/main/java/java/lang/Object.java index 20fdbf9..5b820e3 100644 --- a/libart/src/main/java/java/lang/Object.java +++ b/libart/src/main/java/java/lang/Object.java @@ -274,10 +274,11 @@ public class Object { */ public int hashCode() { int lockWord = shadow$_monitor_; - final int lockWordMask = 0xC0000000; // Top 2 bits. + final int lockWordStateMask = 0xC0000000; // Top 2 bits. final int lockWordStateHash = 0x80000000; // Top 2 bits are value 2 (kStateHash). - if ((lockWord & lockWordMask) == lockWordStateHash) { - return lockWord & ~lockWordMask; + final int lockWordHashMask = 0x0FFFFFFF; // Low 28 bits. + if ((lockWord & lockWordStateMask) == lockWordStateHash) { + return lockWord & lockWordHashMask; } return System.identityHashCode(this); } |