diff options
| author | Vladimir Marko <vmarko@google.com> | 2014-04-11 16:32:51 +0100 |
|---|---|---|
| committer | Vladimir Marko <vmarko@google.com> | 2014-04-14 18:03:41 +0100 |
| commit | d3c5bebcb52a67cb06e7ab303eaf45f230c08b60 (patch) | |
| tree | 85df477ba745b1e2c85ab1d167b0297236060f2f /oatdump | |
| parent | 043a7a6182870964021476484b1534106ff20600 (diff) | |
| download | art-d3c5bebcb52a67cb06e7ab303eaf45f230c08b60.tar.gz art-d3c5bebcb52a67cb06e7ab303eaf45f230c08b60.tar.bz2 art-d3c5bebcb52a67cb06e7ab303eaf45f230c08b60.zip | |
Avoid allocating OatFile::OatClass on the heap.
Avoid allocating a BitVector for OatFile::OatClass::bitmap_
with kOatClassSomeCompiled methods. That makes the OatClass
copy-constructible as it doesn't own any memory. We use that
in OatFile::OatDexFile::GetOatClass() to return the result
by value thus avoiding one or two heap allocations per call.
Change-Id: Ic7098109028a5b49e39ef626f877de86e732ed18
Diffstat (limited to 'oatdump')
| -rw-r--r-- | oatdump/oatdump.cc | 22 |
1 files changed, 10 insertions, 12 deletions
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 915c415c6a..3c07f56cb6 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -215,10 +215,9 @@ class OatDumper { dex_file->FindClassDef(mh.GetDeclaringClassDescriptor()); if (class_def != NULL) { uint16_t class_def_index = dex_file->GetIndexForClassDef(*class_def); - const OatFile::OatClass* oat_class = oat_dex_file->GetOatClass(class_def_index); - CHECK(oat_class != NULL); + const OatFile::OatClass oat_class = oat_dex_file->GetOatClass(class_def_index); size_t method_index = m->GetMethodIndex(); - return oat_class->GetOatMethod(method_index).GetQuickCode(); + return oat_class.GetOatMethod(method_index).GetQuickCode(); } } } @@ -246,18 +245,18 @@ class OatDumper { class_def_index < dex_file->NumClassDefs(); class_def_index++) { const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index); - UniquePtr<const OatFile::OatClass> oat_class(oat_dex_file->GetOatClass(class_def_index)); + const OatFile::OatClass oat_class = oat_dex_file->GetOatClass(class_def_index); const byte* class_data = dex_file->GetClassData(class_def); if (class_data != NULL) { ClassDataItemIterator it(*dex_file, class_data); SkipAllFields(it); uint32_t class_method_index = 0; while (it.HasNextDirectMethod()) { - AddOffsets(oat_class->GetOatMethod(class_method_index++)); + AddOffsets(oat_class.GetOatMethod(class_method_index++)); it.Next(); } while (it.HasNextVirtualMethod()) { - AddOffsets(oat_class->GetOatMethod(class_method_index++)); + AddOffsets(oat_class.GetOatMethod(class_method_index++)); it.Next(); } } @@ -299,15 +298,14 @@ class OatDumper { class_def_index++) { const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index); const char* descriptor = dex_file->GetClassDescriptor(class_def); - UniquePtr<const OatFile::OatClass> oat_class(oat_dex_file.GetOatClass(class_def_index)); - CHECK(oat_class.get() != NULL); + const OatFile::OatClass oat_class = oat_dex_file.GetOatClass(class_def_index); os << StringPrintf("%zd: %s (type_idx=%d)", class_def_index, descriptor, class_def.class_idx_) - << " (" << oat_class->GetStatus() << ")" - << " (" << oat_class->GetType() << ")\n"; - // TODO: include bitmap here if type is kOatClassBitmap? + << " (" << oat_class.GetStatus() << ")" + << " (" << oat_class.GetType() << ")\n"; + // TODO: include bitmap here if type is kOatClassSomeCompiled? Indenter indent_filter(os.rdbuf(), kIndentChar, kIndentBy1Count); std::ostream indented_os(&indent_filter); - DumpOatClass(indented_os, *oat_class.get(), *(dex_file.get()), class_def); + DumpOatClass(indented_os, oat_class, *(dex_file.get()), class_def); } os << std::flush; |
