From faf9f0d53573025dc5ae5ff6c4412396030cf1da Mon Sep 17 00:00:00 2001 From: Razvan A Lupusoru Date: Fri, 29 Aug 2014 17:56:46 -0700 Subject: [PATCH] ART: Allow oatdump to print vr stack locations For both debugging and performance analysis, it is necessary to understand stack layout. This patch adds capability to oatdump to print out the offsets of the locals, ins, method*, and out VRs. Change-Id: I73512f59e4fd2d2b12725a6c76d602182c46ff78 Signed-off-by: Razvan A Lupusoru --- oatdump/oatdump.cc | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc index 1feb27ded..931ee562f 100644 --- a/oatdump/oatdump.cc +++ b/oatdump/oatdump.cc @@ -396,6 +396,7 @@ class OatDumper { *indent2_os << StringPrintf("\nvmap_table: %p (offset=0x%08x)\n", oat_method.GetVmapTable(), oat_method.GetVmapTableOffset()); DumpVmap(*indent2_os, oat_method); + DumpVregLocations(*indent2_os, oat_method, code_item); *indent2_os << StringPrintf("mapping_table: %p (offset=0x%08x)\n", oat_method.GetMappingTable(), oat_method.GetMappingTableOffset()); if (dump_raw_mapping_table_) { @@ -492,6 +493,45 @@ class OatDumper { } } + void DumpVregLocations(std::ostream& os, const OatFile::OatMethod& oat_method, + const DexFile::CodeItem* code_item) { + if (code_item != nullptr) { + size_t num_locals_ins = code_item->registers_size_; + size_t num_ins = code_item->ins_size_; + size_t num_locals = num_locals_ins - num_ins; + size_t num_outs = code_item->outs_size_; + + os << "vr_stack_locations:"; + for (size_t reg = 0; reg <= num_locals_ins; reg++) { + // For readability, delimit the different kinds of VRs. + if (reg == num_locals_ins) { + os << "\n\tmethod*:"; + } else if (reg == num_locals && num_ins > 0) { + os << "\n\tins:"; + } else if (reg == 0 && num_locals > 0) { + os << "\n\tlocals:"; + } + + uint32_t offset = StackVisitor::GetVRegOffset(code_item, oat_method.GetCoreSpillMask(), + oat_method.GetFpSpillMask(), + oat_method.GetFrameSizeInBytes(), reg, + GetInstructionSet()); + os << " v" << reg << "[sp + #" << offset << "]"; + } + + for (size_t out_reg = 0; out_reg < num_outs; out_reg++) { + if (out_reg == 0) { + os << "\n\touts:"; + } + + uint32_t offset = StackVisitor::GetOutVROffset(out_reg, GetInstructionSet()); + os << " v" << out_reg << "[sp + #" << offset << "]"; + } + + os << "\n"; + } + } + void DescribeVReg(std::ostream& os, const OatFile::OatMethod& oat_method, const DexFile::CodeItem* code_item, size_t reg, VRegKind kind) { const uint8_t* raw_table = oat_method.GetVmapTable(); -- 2.11.0