diff options
author | Jeff Hao <jeffhao@google.com> | 2015-05-15 00:56:57 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-05-15 00:56:57 +0000 |
commit | 88bf23f0c78c803ef7eb3e9cdf7a89e8f364a10c (patch) | |
tree | 6ae978312004ec73e0316ac1ff3c57015fbfad97 /runtime | |
parent | 1cfce8c3081c55ab195c34edcebdc1a8139e7356 (diff) | |
parent | a32474e8fe607eeee783cf681b70efbcb569de12 (diff) | |
download | art-88bf23f0c78c803ef7eb3e9cdf7a89e8f364a10c.zip art-88bf23f0c78c803ef7eb3e9cdf7a89e8f364a10c.tar.gz art-88bf23f0c78c803ef7eb3e9cdf7a89e8f364a10c.tar.bz2 |
Merge "In hprof, use an address within string for char array of empty string." into mnc-dev
Diffstat (limited to 'runtime')
-rw-r--r-- | runtime/hprof/hprof.cc | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/runtime/hprof/hprof.cc b/runtime/hprof/hprof.cc index 868cb23..efead51 100644 --- a/runtime/hprof/hprof.cc +++ b/runtime/hprof/hprof.cc @@ -1150,13 +1150,20 @@ void Hprof::DumpHeapInstanceObject(mirror::Object* obj, mirror::Class* klass) { // Output native value character array for strings. if (orig_klass->IsStringClass()) { mirror::String* s = obj->AsString(); - __ AddObjectId(reinterpret_cast<mirror::Object*>(s->GetValue())); + mirror::Object* value; + if (s->GetLength() == 0) { + // If string is empty, use an object-aligned address within the string for the value. + value = reinterpret_cast<mirror::Object*>(reinterpret_cast<uintptr_t>(s) + kObjectAlignment); + } else { + value = reinterpret_cast<mirror::Object*>(s->GetValue()); + } + __ AddObjectId(value); // Patch the instance field length. __ UpdateU4(size_patch_offset, output_->Length() - (size_patch_offset + 4)); __ AddU1(HPROF_PRIMITIVE_ARRAY_DUMP); - __ AddObjectId(reinterpret_cast<mirror::Object*>(s->GetValue())); + __ AddObjectId(value); __ AddU4(StackTraceSerialNumber(obj)); __ AddU4(s->GetLength()); __ AddU1(hprof_basic_char); |