summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorMathieu Chartier <mathieuc@google.com>2013-10-31 10:35:05 -0700
committerMathieu Chartier <mathieuc@google.com>2013-10-31 13:33:51 -0700
commit4e6a31eb97f22f4480827474b30b9e64f396eace (patch)
tree3afe222c60314a22be8bb8de61cb245e1af2dc92 /compiler
parent1b8cb967143d5c46db1db8ac940a73d111be3628 (diff)
downloadart-4e6a31eb97f22f4480827474b30b9e64f396eace.zip
art-4e6a31eb97f22f4480827474b30b9e64f396eace.tar.gz
art-4e6a31eb97f22f4480827474b30b9e64f396eace.tar.bz2
Lazily compute object identity hash codes.
Before, we computed identity hashcodes whenever we inflated a monitor. This caused issues since it meant that we would have all of these hash codes in the image, causing locks to excessively inflate during application run time. This change makes it so that we lazily compute hash codes. When a thin lock gets inflated, we assign a hash code of 0 assigned to it. This value signifies no hash code. When we try to get the identity hash code of an object with an inflated monitor, it gets computed if it is 0. Change-Id: Iae6acd1960515a36e74644e5b1323ff336731806
Diffstat (limited to 'compiler')
-rw-r--r--compiler/image_writer.cc9
1 files changed, 7 insertions, 2 deletions
diff --git a/compiler/image_writer.cc b/compiler/image_writer.cc
index af60a38..75be2c9 100644
--- a/compiler/image_writer.cc
+++ b/compiler/image_writer.cc
@@ -504,7 +504,11 @@ void ImageWriter::CopyAndFixupObjectsCallback(Object* object, void* arg) {
Monitor* monitor = lw.FatLockMonitor();
CHECK(monitor != nullptr);
CHECK(!monitor->IsLocked());
- copy->SetLockWord(LockWord::FromHashCode(monitor->GetHashCode()));
+ if (monitor->HasHashCode()) {
+ copy->SetLockWord(LockWord::FromHashCode(monitor->GetHashCode()));
+ } else {
+ copy->SetLockWord(LockWord());
+ }
break;
}
case LockWord::kThinLocked: {
@@ -512,9 +516,10 @@ void ImageWriter::CopyAndFixupObjectsCallback(Object* object, void* arg) {
break;
}
case LockWord::kUnlocked:
- // Fall-through.
+ break;
case LockWord::kHashCode:
// Do nothing since we can just keep the same hash code.
+ CHECK_NE(lw.GetHashCode(), 0);
break;
default:
LOG(FATAL) << "Unreachable.";