diff options
author | Hiroshi Yamauchi <yamauchi@google.com> | 2015-04-24 17:11:24 +0000 |
---|---|---|
committer | Gerrit Code Review <noreply-gerritcodereview@google.com> | 2015-04-24 17:11:25 +0000 |
commit | 1681b2cf4a78ff88ec8ca9d836137e6a914e7023 (patch) | |
tree | 94b71a14e7604a38f29541b896b7b7213b97876f /libart | |
parent | 69f8fc656f04661f9c32176ebfd093e42bae53d4 (diff) | |
parent | 28da248e817762ef6e2709a8379228867862d97a (diff) | |
download | libcore-1681b2cf4a78ff88ec8ca9d836137e6a914e7023.zip libcore-1681b2cf4a78ff88ec8ca9d836137e6a914e7023.tar.gz libcore-1681b2cf4a78ff88ec8ca9d836137e6a914e7023.tar.bz2 |
Merge "Fix hashCode() for the read barrier lock word change."
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); } |