Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2015 The Android Open Source Project |
| 3 | * |
| 4 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | * you may not use this file except in compliance with the License. |
| 6 | * You may obtain a copy of the License at |
| 7 | * |
| 8 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 9 | * |
| 10 | * Unless required by applicable law or agreed to in writing, software |
| 11 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | * See the License for the specific language governing permissions and |
| 14 | * limitations under the License. |
| 15 | */ |
| 16 | |
| 17 | #include "stack_map.h" |
| 18 | |
Nicolas Geoffray | 896f8f7 | 2015-03-30 15:44:25 +0100 | [diff] [blame] | 19 | #include <stdint.h> |
| 20 | |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 21 | #include "art_method.h" |
David Sehr | 9c4a015 | 2018-04-05 12:23:54 -0700 | [diff] [blame^] | 22 | #include "base/indenter.h" |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 23 | #include "scoped_thread_state_change-inl.h" |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 24 | |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 25 | namespace art { |
| 26 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 27 | constexpr size_t DexRegisterLocationCatalog::kNoLocationEntryIndex; |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 28 | constexpr uint32_t StackMap::kNoDexRegisterMap; |
| 29 | constexpr uint32_t StackMap::kNoInlineInfo; |
| 30 | |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 31 | std::ostream& operator<<(std::ostream& stream, const DexRegisterLocation::Kind& kind) { |
| 32 | using Kind = DexRegisterLocation::Kind; |
| 33 | switch (kind) { |
| 34 | case Kind::kNone: |
| 35 | return stream << "none"; |
| 36 | case Kind::kInStack: |
| 37 | return stream << "in stack"; |
| 38 | case Kind::kInRegister: |
| 39 | return stream << "in register"; |
| 40 | case Kind::kInRegisterHigh: |
| 41 | return stream << "in register high"; |
| 42 | case Kind::kInFpuRegister: |
| 43 | return stream << "in fpu register"; |
| 44 | case Kind::kInFpuRegisterHigh: |
| 45 | return stream << "in fpu register high"; |
| 46 | case Kind::kConstant: |
| 47 | return stream << "as constant"; |
| 48 | case Kind::kInStackLargeOffset: |
| 49 | return stream << "in stack (large offset)"; |
| 50 | case Kind::kConstantLargeValue: |
| 51 | return stream << "as constant (large value)"; |
| 52 | } |
| 53 | return stream << "Kind<" << static_cast<uint32_t>(kind) << ">"; |
| 54 | } |
| 55 | |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 56 | DexRegisterLocation::Kind DexRegisterMap::GetLocationInternalKind( |
| 57 | uint16_t dex_register_number, |
| 58 | uint16_t number_of_dex_registers, |
| 59 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 60 | const CodeInfoEncoding& enc) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 61 | DexRegisterLocationCatalog dex_register_location_catalog = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 62 | code_info.GetDexRegisterLocationCatalog(enc); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 63 | size_t location_catalog_entry_index = GetLocationCatalogEntryIndex( |
| 64 | dex_register_number, |
| 65 | number_of_dex_registers, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 66 | code_info.GetNumberOfLocationCatalogEntries(enc)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 67 | return dex_register_location_catalog.GetLocationInternalKind(location_catalog_entry_index); |
| 68 | } |
| 69 | |
| 70 | DexRegisterLocation DexRegisterMap::GetDexRegisterLocation(uint16_t dex_register_number, |
| 71 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 72 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 73 | const CodeInfoEncoding& enc) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 74 | DexRegisterLocationCatalog dex_register_location_catalog = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 75 | code_info.GetDexRegisterLocationCatalog(enc); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 76 | size_t location_catalog_entry_index = GetLocationCatalogEntryIndex( |
| 77 | dex_register_number, |
| 78 | number_of_dex_registers, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 79 | code_info.GetNumberOfLocationCatalogEntries(enc)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 80 | return dex_register_location_catalog.GetDexRegisterLocation(location_catalog_entry_index); |
| 81 | } |
| 82 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 83 | static void DumpRegisterMapping(std::ostream& os, |
| 84 | size_t dex_register_num, |
| 85 | DexRegisterLocation location, |
| 86 | const std::string& prefix = "v", |
| 87 | const std::string& suffix = "") { |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 88 | os << prefix << dex_register_num << ": " |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 89 | << location.GetInternalKind() |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 90 | << " (" << location.GetValue() << ")" << suffix << '\n'; |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 91 | } |
| 92 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 93 | void StackMapEncoding::Dump(VariableIndentationOutputStream* vios) const { |
| 94 | vios->Stream() |
| 95 | << "StackMapEncoding" |
| 96 | << " (native_pc_bit_offset=" << static_cast<uint32_t>(kNativePcBitOffset) |
| 97 | << ", dex_pc_bit_offset=" << static_cast<uint32_t>(dex_pc_bit_offset_) |
| 98 | << ", dex_register_map_bit_offset=" << static_cast<uint32_t>(dex_register_map_bit_offset_) |
| 99 | << ", inline_info_bit_offset=" << static_cast<uint32_t>(inline_info_bit_offset_) |
Mathieu Chartier | 1a20b68 | 2017-01-31 14:25:16 -0800 | [diff] [blame] | 100 | << ", register_mask_bit_offset=" << static_cast<uint32_t>(register_mask_index_bit_offset_) |
David Srbecky | 45aa598 | 2016-03-18 02:15:09 +0000 | [diff] [blame] | 101 | << ", stack_mask_index_bit_offset=" << static_cast<uint32_t>(stack_mask_index_bit_offset_) |
| 102 | << ", total_bit_size=" << static_cast<uint32_t>(total_bit_size_) |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 103 | << ")\n"; |
| 104 | } |
| 105 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 106 | void InlineInfoEncoding::Dump(VariableIndentationOutputStream* vios) const { |
| 107 | vios->Stream() |
| 108 | << "InlineInfoEncoding" |
| 109 | << " (method_index_bit_offset=" << static_cast<uint32_t>(kMethodIndexBitOffset) |
| 110 | << ", dex_pc_bit_offset=" << static_cast<uint32_t>(dex_pc_bit_offset_) |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 111 | << ", extra_data_bit_offset=" << static_cast<uint32_t>(extra_data_bit_offset_) |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 112 | << ", dex_register_map_bit_offset=" << static_cast<uint32_t>(dex_register_map_bit_offset_) |
| 113 | << ", total_bit_size=" << static_cast<uint32_t>(total_bit_size_) |
| 114 | << ")\n"; |
| 115 | } |
| 116 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 117 | void CodeInfo::Dump(VariableIndentationOutputStream* vios, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 118 | uint32_t code_offset, |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 119 | uint16_t number_of_dex_registers, |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 120 | bool dump_stack_maps, |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 121 | InstructionSet instruction_set, |
| 122 | const MethodInfo& method_info) const { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 123 | CodeInfoEncoding encoding = ExtractEncoding(); |
| 124 | size_t number_of_stack_maps = GetNumberOfStackMaps(encoding); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 125 | vios->Stream() |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 126 | << "Optimized CodeInfo (number_of_dex_registers=" << number_of_dex_registers |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 127 | << ", number_of_stack_maps=" << number_of_stack_maps |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 128 | << ")\n"; |
| 129 | ScopedIndentation indent1(vios); |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 130 | encoding.stack_map.encoding.Dump(vios); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 131 | if (HasInlineInfo(encoding)) { |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 132 | encoding.inline_info.encoding.Dump(vios); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 133 | } |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 134 | // Display the Dex register location catalog. |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 135 | GetDexRegisterLocationCatalog(encoding).Dump(vios, *this); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 136 | // Display stack maps along with (live) Dex register maps. |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 137 | if (dump_stack_maps) { |
| 138 | for (size_t i = 0; i < number_of_stack_maps; ++i) { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 139 | StackMap stack_map = GetStackMapAt(i, encoding); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 140 | stack_map.Dump(vios, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 141 | *this, |
| 142 | encoding, |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 143 | method_info, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 144 | code_offset, |
| 145 | number_of_dex_registers, |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 146 | instruction_set, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 147 | " " + std::to_string(i)); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 148 | } |
| 149 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 150 | // TODO: Dump the stack map's inline information? We need to know more from the caller: |
| 151 | // we need to know the number of dex registers for each inlined method. |
| 152 | } |
| 153 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 154 | void DexRegisterLocationCatalog::Dump(VariableIndentationOutputStream* vios, |
| 155 | const CodeInfo& code_info) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 156 | CodeInfoEncoding encoding = code_info.ExtractEncoding(); |
| 157 | size_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(encoding); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 158 | size_t location_catalog_size_in_bytes = code_info.GetDexRegisterLocationCatalogSize(encoding); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 159 | vios->Stream() |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 160 | << "DexRegisterLocationCatalog (number_of_entries=" << number_of_location_catalog_entries |
| 161 | << ", size_in_bytes=" << location_catalog_size_in_bytes << ")\n"; |
| 162 | for (size_t i = 0; i < number_of_location_catalog_entries; ++i) { |
| 163 | DexRegisterLocation location = GetDexRegisterLocation(i); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 164 | ScopedIndentation indent1(vios); |
| 165 | DumpRegisterMapping(vios->Stream(), i, location, "entry "); |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 166 | } |
| 167 | } |
| 168 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 169 | void DexRegisterMap::Dump(VariableIndentationOutputStream* vios, |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 170 | const CodeInfo& code_info, |
| 171 | uint16_t number_of_dex_registers) const { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 172 | CodeInfoEncoding encoding = code_info.ExtractEncoding(); |
| 173 | size_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 174 | // TODO: Display the bit mask of live Dex registers. |
| 175 | for (size_t j = 0; j < number_of_dex_registers; ++j) { |
| 176 | if (IsDexRegisterLive(j)) { |
| 177 | size_t location_catalog_entry_index = GetLocationCatalogEntryIndex( |
| 178 | j, number_of_dex_registers, number_of_location_catalog_entries); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 179 | DexRegisterLocation location = GetDexRegisterLocation(j, |
| 180 | number_of_dex_registers, |
| 181 | code_info, |
| 182 | encoding); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 183 | ScopedIndentation indent1(vios); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 184 | DumpRegisterMapping( |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 185 | vios->Stream(), j, location, "v", |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 186 | "\t[entry " + std::to_string(static_cast<int>(location_catalog_entry_index)) + "]"); |
| 187 | } |
| 188 | } |
| 189 | } |
| 190 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 191 | void StackMap::Dump(VariableIndentationOutputStream* vios, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 192 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 193 | const CodeInfoEncoding& encoding, |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 194 | const MethodInfo& method_info, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 195 | uint32_t code_offset, |
| 196 | uint16_t number_of_dex_registers, |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 197 | InstructionSet instruction_set, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 198 | const std::string& header_suffix) const { |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 199 | StackMapEncoding stack_map_encoding = encoding.stack_map.encoding; |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 200 | const uint32_t pc_offset = GetNativePcOffset(stack_map_encoding, instruction_set); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 201 | vios->Stream() |
| 202 | << "StackMap" << header_suffix |
| 203 | << std::hex |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 204 | << " [native_pc=0x" << code_offset + pc_offset << "]" |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 205 | << " [entry_size=0x" << encoding.stack_map.encoding.BitSize() << " bits]" |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 206 | << " (dex_pc=0x" << GetDexPc(stack_map_encoding) |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 207 | << ", native_pc_offset=0x" << pc_offset |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 208 | << ", dex_register_map_offset=0x" << GetDexRegisterMapOffset(stack_map_encoding) |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 209 | << ", inline_info_offset=0x" << GetInlineInfoIndex(stack_map_encoding) |
Mathieu Chartier | 1a20b68 | 2017-01-31 14:25:16 -0800 | [diff] [blame] | 210 | << ", register_mask=0x" << code_info.GetRegisterMaskOf(encoding, *this) |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 211 | << std::dec |
| 212 | << ", stack_mask=0b"; |
David Srbecky | 45aa598 | 2016-03-18 02:15:09 +0000 | [diff] [blame] | 213 | BitMemoryRegion stack_mask = code_info.GetStackMaskOf(encoding, *this); |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 214 | for (size_t i = 0, e = encoding.stack_mask.encoding.BitSize(); i < e; ++i) { |
David Srbecky | 45aa598 | 2016-03-18 02:15:09 +0000 | [diff] [blame] | 215 | vios->Stream() << stack_mask.LoadBit(e - i - 1); |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 216 | } |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 217 | vios->Stream() << ")\n"; |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 218 | if (HasDexRegisterMap(stack_map_encoding)) { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 219 | DexRegisterMap dex_register_map = code_info.GetDexRegisterMapOf( |
| 220 | *this, encoding, number_of_dex_registers); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 221 | dex_register_map.Dump(vios, code_info, number_of_dex_registers); |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 222 | } |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 223 | if (HasInlineInfo(stack_map_encoding)) { |
Nicolas Geoffray | 12bdb72 | 2015-06-17 09:44:43 +0100 | [diff] [blame] | 224 | InlineInfo inline_info = code_info.GetInlineInfoOf(*this, encoding); |
| 225 | // We do not know the length of the dex register maps of inlined frames |
| 226 | // at this level, so we just pass null to `InlineInfo::Dump` to tell |
| 227 | // it not to look at these maps. |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 228 | inline_info.Dump(vios, code_info, method_info, nullptr); |
Nicolas Geoffray | 12bdb72 | 2015-06-17 09:44:43 +0100 | [diff] [blame] | 229 | } |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 230 | } |
| 231 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 232 | void InlineInfo::Dump(VariableIndentationOutputStream* vios, |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 233 | const CodeInfo& code_info, |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 234 | const MethodInfo& method_info, |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 235 | uint16_t number_of_dex_registers[]) const { |
Mathieu Chartier | 575d3e6 | 2017-02-06 11:00:40 -0800 | [diff] [blame] | 236 | InlineInfoEncoding inline_info_encoding = code_info.ExtractEncoding().inline_info.encoding; |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 237 | vios->Stream() << "InlineInfo with depth " |
| 238 | << static_cast<uint32_t>(GetDepth(inline_info_encoding)) |
| 239 | << "\n"; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 240 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 241 | for (size_t i = 0; i < GetDepth(inline_info_encoding); ++i) { |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 242 | vios->Stream() |
| 243 | << " At depth " << i |
| 244 | << std::hex |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 245 | << " (dex_pc=0x" << GetDexPcAtDepth(inline_info_encoding, i); |
| 246 | if (EncodesArtMethodAtDepth(inline_info_encoding, i)) { |
| 247 | ScopedObjectAccess soa(Thread::Current()); |
| 248 | vios->Stream() << ", method=" << GetArtMethodAtDepth(inline_info_encoding, i)->PrettyMethod(); |
| 249 | } else { |
| 250 | vios->Stream() |
| 251 | << std::dec |
Mathieu Chartier | cbcedbf | 2017-03-12 22:24:50 -0700 | [diff] [blame] | 252 | << ", method_index=" << GetMethodIndexAtDepth(inline_info_encoding, method_info, i); |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 253 | } |
| 254 | vios->Stream() << ")\n"; |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 255 | if (HasDexRegisterMapAtDepth(inline_info_encoding, i) && (number_of_dex_registers != nullptr)) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 256 | CodeInfoEncoding encoding = code_info.ExtractEncoding(); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 257 | DexRegisterMap dex_register_map = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 258 | code_info.GetDexRegisterMapAtDepth(i, *this, encoding, number_of_dex_registers[i]); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 259 | ScopedIndentation indent1(vios); |
| 260 | dex_register_map.Dump(vios, code_info, number_of_dex_registers[i]); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 261 | } |
| 262 | } |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 263 | } |
| 264 | |
| 265 | } // namespace art |