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 | |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 19 | #include <iomanip> |
Nicolas Geoffray | 896f8f7 | 2015-03-30 15:44:25 +0100 | [diff] [blame] | 20 | #include <stdint.h> |
| 21 | |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 22 | #include "art_method.h" |
David Sehr | 9c4a015 | 2018-04-05 12:23:54 -0700 | [diff] [blame] | 23 | #include "base/indenter.h" |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 24 | #include "base/stats.h" |
David Srbecky | f6ba5b3 | 2018-06-23 22:05:49 +0100 | [diff] [blame] | 25 | #include "oat_quick_method_header.h" |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 26 | #include "scoped_thread_state_change-inl.h" |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 27 | |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 28 | namespace art { |
| 29 | |
David Srbecky | 6ee06e9 | 2018-07-25 21:45:54 +0100 | [diff] [blame] | 30 | CodeInfo::CodeInfo(const OatQuickMethodHeader* header, DecodeFlags flags) |
| 31 | : CodeInfo(header->GetOptimizedCodeInfoPtr(), flags) { |
David Srbecky | f6ba5b3 | 2018-06-23 22:05:49 +0100 | [diff] [blame] | 32 | } |
| 33 | |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 34 | template<typename Accessor> |
| 35 | ALWAYS_INLINE static void DecodeTable(BitTable<Accessor>& table, |
| 36 | BitMemoryReader& reader, |
| 37 | const uint8_t* data) { |
| 38 | bool is_deduped = reader.ReadBit(); |
| 39 | if (is_deduped) { |
| 40 | // 'data' points to the start of the reader's data. |
| 41 | uint32_t current_bit_offset = reader.GetBitOffset(); |
| 42 | uint32_t bit_offset_backwards = DecodeVarintBits(reader) - current_bit_offset; |
| 43 | uint32_t byte_offset_backwards = BitsToBytesRoundUp(bit_offset_backwards); |
| 44 | BitMemoryReader reader2(data - byte_offset_backwards, |
| 45 | byte_offset_backwards * kBitsPerByte - bit_offset_backwards); |
| 46 | table.Decode(reader2); |
| 47 | } else { |
| 48 | table.Decode(reader); |
| 49 | } |
| 50 | } |
| 51 | |
David Srbecky | 6ee06e9 | 2018-07-25 21:45:54 +0100 | [diff] [blame] | 52 | void CodeInfo::Decode(const uint8_t* data, DecodeFlags flags) { |
David Srbecky | 3aaaa21 | 2018-07-30 16:46:53 +0100 | [diff] [blame] | 53 | BitMemoryReader reader(data); |
| 54 | packed_frame_size_ = DecodeVarintBits(reader); |
| 55 | core_spill_mask_ = DecodeVarintBits(reader); |
| 56 | fp_spill_mask_ = DecodeVarintBits(reader); |
| 57 | number_of_dex_registers_ = DecodeVarintBits(reader); |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 58 | DecodeTable(stack_maps_, reader, data); |
David Srbecky | a2d29a3 | 2018-08-03 11:06:38 +0100 | [diff] [blame] | 59 | DecodeTable(register_masks_, reader, data); |
| 60 | DecodeTable(stack_masks_, reader, data); |
| 61 | if (flags & DecodeFlags::GcMasksOnly) { |
| 62 | return; |
| 63 | } |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 64 | DecodeTable(inline_infos_, reader, data); |
David Srbecky | 8cd5454 | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 65 | DecodeTable(method_infos_, reader, data); |
David Srbecky | 6ee06e9 | 2018-07-25 21:45:54 +0100 | [diff] [blame] | 66 | if (flags & DecodeFlags::InlineInfoOnly) { |
| 67 | return; |
| 68 | } |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 69 | DecodeTable(dex_register_masks_, reader, data); |
| 70 | DecodeTable(dex_register_maps_, reader, data); |
| 71 | DecodeTable(dex_register_catalog_, reader, data); |
David Srbecky | 3aaaa21 | 2018-07-30 16:46:53 +0100 | [diff] [blame] | 72 | size_in_bits_ = reader.GetBitOffset(); |
David Srbecky | 078d7ba | 2018-06-21 15:36:48 +0100 | [diff] [blame] | 73 | } |
| 74 | |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 75 | template<typename Accessor> |
| 76 | ALWAYS_INLINE static void DedupeTable(BitMemoryWriter<std::vector<uint8_t>>& writer, |
| 77 | BitMemoryReader& reader, |
| 78 | CodeInfo::DedupeMap* dedupe_map) { |
| 79 | bool is_deduped = reader.ReadBit(); |
| 80 | DCHECK(!is_deduped); |
| 81 | BitTable<Accessor> bit_table(reader); |
| 82 | BitMemoryRegion region = reader.Tail(bit_table.BitSize()); |
| 83 | auto it = dedupe_map->insert(std::make_pair(region, writer.GetBitOffset() + 1 /* dedupe bit */)); |
| 84 | if (it.second /* new bit table */ || region.size_in_bits() < 32) { |
| 85 | writer.WriteBit(false); // Is not deduped. |
| 86 | writer.WriteRegion(region); |
| 87 | } else { |
| 88 | writer.WriteBit(true); // Is deduped. |
| 89 | EncodeVarintBits(writer, writer.GetBitOffset() - it.first->second); |
| 90 | } |
| 91 | } |
| 92 | |
| 93 | size_t CodeInfo::Dedupe(std::vector<uint8_t>* out, const uint8_t* in, DedupeMap* dedupe_map) { |
| 94 | // Remember the current offset in the output buffer so that we can return it later. |
| 95 | const size_t result = out->size(); |
David Srbecky | 3aaaa21 | 2018-07-30 16:46:53 +0100 | [diff] [blame] | 96 | BitMemoryReader reader(in); |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 97 | BitMemoryWriter<std::vector<uint8_t>> writer(out, /* bit_offset */ out->size() * kBitsPerByte); |
David Srbecky | 3aaaa21 | 2018-07-30 16:46:53 +0100 | [diff] [blame] | 98 | EncodeVarintBits(writer, DecodeVarintBits(reader)); // packed_frame_size_. |
| 99 | EncodeVarintBits(writer, DecodeVarintBits(reader)); // core_spill_mask_. |
| 100 | EncodeVarintBits(writer, DecodeVarintBits(reader)); // fp_spill_mask_. |
| 101 | EncodeVarintBits(writer, DecodeVarintBits(reader)); // number_of_dex_registers_. |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 102 | DedupeTable<StackMap>(writer, reader, dedupe_map); |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 103 | DedupeTable<RegisterMask>(writer, reader, dedupe_map); |
| 104 | DedupeTable<MaskInfo>(writer, reader, dedupe_map); |
David Srbecky | a2d29a3 | 2018-08-03 11:06:38 +0100 | [diff] [blame] | 105 | DedupeTable<InlineInfo>(writer, reader, dedupe_map); |
| 106 | DedupeTable<MethodInfo>(writer, reader, dedupe_map); |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 107 | DedupeTable<MaskInfo>(writer, reader, dedupe_map); |
| 108 | DedupeTable<DexRegisterMapInfo>(writer, reader, dedupe_map); |
| 109 | DedupeTable<DexRegisterInfo>(writer, reader, dedupe_map); |
| 110 | return result; |
| 111 | } |
| 112 | |
David Srbecky | 0b4e5a3 | 2018-06-11 16:25:29 +0100 | [diff] [blame] | 113 | BitTable<StackMap>::const_iterator CodeInfo::BinarySearchNativePc(uint32_t packed_pc) const { |
| 114 | return std::partition_point( |
| 115 | stack_maps_.begin(), |
| 116 | stack_maps_.end(), |
| 117 | [packed_pc](const StackMap& sm) { |
| 118 | return sm.GetPackedNativePc() < packed_pc && sm.GetKind() != StackMap::Kind::Catch; |
| 119 | }); |
| 120 | } |
| 121 | |
| 122 | StackMap CodeInfo::GetStackMapForNativePcOffset(uint32_t pc, InstructionSet isa) const { |
| 123 | auto it = BinarySearchNativePc(StackMap::PackNativePc(pc, isa)); |
| 124 | // Start at the lower bound and iterate over all stack maps with the given native pc. |
| 125 | for (; it != stack_maps_.end() && (*it).GetNativePcOffset(isa) == pc; ++it) { |
| 126 | StackMap::Kind kind = static_cast<StackMap::Kind>((*it).GetKind()); |
| 127 | if (kind == StackMap::Kind::Default || kind == StackMap::Kind::OSR) { |
| 128 | return *it; |
| 129 | } |
| 130 | } |
David Srbecky | a45a85c | 2018-06-21 16:03:12 +0100 | [diff] [blame] | 131 | return stack_maps_.GetInvalidRow(); |
David Srbecky | 0b4e5a3 | 2018-06-11 16:25:29 +0100 | [diff] [blame] | 132 | } |
| 133 | |
David Srbecky | 6de8833 | 2018-06-03 12:00:11 +0100 | [diff] [blame] | 134 | // Scan backward to determine dex register locations at given stack map. |
| 135 | // All registers for a stack map are combined - inlined registers are just appended, |
| 136 | // therefore 'first_dex_register' allows us to select a sub-range to decode. |
| 137 | void CodeInfo::DecodeDexRegisterMap(uint32_t stack_map_index, |
| 138 | uint32_t first_dex_register, |
| 139 | /*out*/ DexRegisterMap* map) const { |
| 140 | // Count remaining work so we know when we have finished. |
| 141 | uint32_t remaining_registers = map->size(); |
| 142 | |
| 143 | // Keep scanning backwards and collect the most recent location of each register. |
| 144 | for (int32_t s = stack_map_index; s >= 0 && remaining_registers != 0; s--) { |
| 145 | StackMap stack_map = GetStackMapAt(s); |
| 146 | DCHECK_LE(stack_map_index - s, kMaxDexRegisterMapSearchDistance) << "Unbounded search"; |
| 147 | |
| 148 | // The mask specifies which registers where modified in this stack map. |
| 149 | // NB: the mask can be shorter than expected if trailing zero bits were removed. |
| 150 | uint32_t mask_index = stack_map.GetDexRegisterMaskIndex(); |
| 151 | if (mask_index == StackMap::kNoValue) { |
| 152 | continue; // Nothing changed at this stack map. |
| 153 | } |
| 154 | BitMemoryRegion mask = dex_register_masks_.GetBitMemoryRegion(mask_index); |
| 155 | if (mask.size_in_bits() <= first_dex_register) { |
| 156 | continue; // Nothing changed after the first register we are interested in. |
| 157 | } |
| 158 | |
| 159 | // The map stores one catalogue index per each modified register location. |
| 160 | uint32_t map_index = stack_map.GetDexRegisterMapIndex(); |
| 161 | DCHECK_NE(map_index, StackMap::kNoValue); |
| 162 | |
| 163 | // Skip initial registers which we are not interested in (to get to inlined registers). |
| 164 | map_index += mask.PopCount(0, first_dex_register); |
| 165 | mask = mask.Subregion(first_dex_register, mask.size_in_bits() - first_dex_register); |
| 166 | |
| 167 | // Update registers that we see for first time (i.e. most recent value). |
| 168 | DexRegisterLocation* regs = map->data(); |
| 169 | const uint32_t end = std::min<uint32_t>(map->size(), mask.size_in_bits()); |
| 170 | const size_t kNumBits = BitSizeOf<uint32_t>(); |
| 171 | for (uint32_t reg = 0; reg < end; reg += kNumBits) { |
| 172 | // Process the mask in chunks of kNumBits for performance. |
| 173 | uint32_t bits = mask.LoadBits(reg, std::min<uint32_t>(end - reg, kNumBits)); |
| 174 | while (bits != 0) { |
| 175 | uint32_t bit = CTZ(bits); |
| 176 | if (regs[reg + bit].GetKind() == DexRegisterLocation::Kind::kInvalid) { |
| 177 | regs[reg + bit] = GetDexRegisterCatalogEntry(dex_register_maps_.Get(map_index)); |
| 178 | remaining_registers--; |
| 179 | } |
| 180 | map_index++; |
| 181 | bits ^= 1u << bit; // Clear the bit. |
| 182 | } |
| 183 | } |
| 184 | } |
| 185 | |
| 186 | // Set any remaining registers to None (which is the default state at first stack map). |
| 187 | if (remaining_registers != 0) { |
| 188 | DexRegisterLocation* regs = map->data(); |
| 189 | for (uint32_t r = 0; r < map->size(); r++) { |
| 190 | if (regs[r].GetKind() == DexRegisterLocation::Kind::kInvalid) { |
| 191 | regs[r] = DexRegisterLocation::None(); |
| 192 | } |
| 193 | } |
| 194 | } |
| 195 | } |
| 196 | |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 197 | template<typename Accessor> |
| 198 | static void AddTableSizeStats(const char* table_name, |
David Srbecky | cf7833e | 2018-06-14 16:45:22 +0100 | [diff] [blame] | 199 | const BitTable<Accessor>& table, |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 200 | /*out*/ Stats* parent) { |
| 201 | Stats* table_stats = parent->Child(table_name); |
| 202 | table_stats->AddBits(table.BitSize()); |
| 203 | table_stats->Child("Header")->AddBits(table.HeaderBitSize()); |
| 204 | const char* const* column_names = GetBitTableColumnNames<Accessor>(); |
| 205 | for (size_t c = 0; c < table.NumColumns(); c++) { |
| 206 | if (table.NumColumnBits(c) > 0) { |
| 207 | Stats* column_stats = table_stats->Child(column_names[c]); |
| 208 | column_stats->AddBits(table.NumRows() * table.NumColumnBits(c), table.NumRows()); |
| 209 | } |
| 210 | } |
| 211 | } |
| 212 | |
| 213 | void CodeInfo::AddSizeStats(/*out*/ Stats* parent) const { |
| 214 | Stats* stats = parent->Child("CodeInfo"); |
David Srbecky | a38e6cf | 2018-06-26 18:13:49 +0100 | [diff] [blame] | 215 | stats->AddBytes(Size()); |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 216 | AddTableSizeStats<StackMap>("StackMaps", stack_maps_, stats); |
| 217 | AddTableSizeStats<RegisterMask>("RegisterMasks", register_masks_, stats); |
| 218 | AddTableSizeStats<MaskInfo>("StackMasks", stack_masks_, stats); |
David Srbecky | a2d29a3 | 2018-08-03 11:06:38 +0100 | [diff] [blame] | 219 | AddTableSizeStats<InlineInfo>("InlineInfos", inline_infos_, stats); |
| 220 | AddTableSizeStats<MethodInfo>("MethodInfo", method_infos_, stats); |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 221 | AddTableSizeStats<MaskInfo>("DexRegisterMasks", dex_register_masks_, stats); |
| 222 | AddTableSizeStats<DexRegisterMapInfo>("DexRegisterMaps", dex_register_maps_, stats); |
| 223 | AddTableSizeStats<DexRegisterInfo>("DexRegisterCatalog", dex_register_catalog_, stats); |
| 224 | } |
| 225 | |
David Srbecky | e140212 | 2018-06-13 18:20:45 +0100 | [diff] [blame] | 226 | void DexRegisterMap::Dump(VariableIndentationOutputStream* vios) const { |
| 227 | if (HasAnyLiveDexRegisters()) { |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 228 | ScopedIndentation indent1(vios); |
David Srbecky | e140212 | 2018-06-13 18:20:45 +0100 | [diff] [blame] | 229 | for (size_t i = 0; i < size(); ++i) { |
| 230 | DexRegisterLocation reg = (*this)[i]; |
| 231 | if (reg.IsLive()) { |
| 232 | vios->Stream() << "v" << i << ":" << reg << " "; |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 233 | } |
| 234 | } |
| 235 | vios->Stream() << "\n"; |
| 236 | } |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 237 | } |
| 238 | |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 239 | template<typename Accessor> |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 240 | static void DumpTable(VariableIndentationOutputStream* vios, |
| 241 | const char* table_name, |
David Srbecky | cf7833e | 2018-06-14 16:45:22 +0100 | [diff] [blame] | 242 | const BitTable<Accessor>& table, |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 243 | bool verbose, |
| 244 | bool is_mask = false) { |
| 245 | if (table.NumRows() != 0) { |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 246 | vios->Stream() << table_name << " BitSize=" << table.BitSize(); |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 247 | vios->Stream() << " Rows=" << table.NumRows() << " Bits={"; |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 248 | const char* const* column_names = GetBitTableColumnNames<Accessor>(); |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 249 | for (size_t c = 0; c < table.NumColumns(); c++) { |
| 250 | vios->Stream() << (c != 0 ? " " : ""); |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 251 | vios->Stream() << column_names[c] << "=" << table.NumColumnBits(c); |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 252 | } |
| 253 | vios->Stream() << "}\n"; |
| 254 | if (verbose) { |
| 255 | ScopedIndentation indent1(vios); |
| 256 | for (size_t r = 0; r < table.NumRows(); r++) { |
| 257 | vios->Stream() << "[" << std::right << std::setw(3) << r << "]={"; |
| 258 | for (size_t c = 0; c < table.NumColumns(); c++) { |
| 259 | vios->Stream() << (c != 0 ? " " : ""); |
| 260 | if (is_mask) { |
| 261 | BitMemoryRegion bits = table.GetBitMemoryRegion(r, c); |
| 262 | for (size_t b = 0, e = bits.size_in_bits(); b < e; b++) { |
| 263 | vios->Stream() << bits.LoadBit(e - b - 1); |
| 264 | } |
| 265 | } else { |
| 266 | vios->Stream() << std::right << std::setw(8) << static_cast<int32_t>(table.Get(r, c)); |
| 267 | } |
| 268 | } |
| 269 | vios->Stream() << "}\n"; |
| 270 | } |
| 271 | } |
| 272 | } |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 273 | } |
| 274 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 275 | void CodeInfo::Dump(VariableIndentationOutputStream* vios, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 276 | uint32_t code_offset, |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 277 | bool verbose, |
David Srbecky | 8cd5454 | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 278 | InstructionSet instruction_set) const { |
David Srbecky | b73323c | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 279 | vios->Stream() << "CodeInfo\n"; |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 280 | ScopedIndentation indent1(vios); |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 281 | DumpTable<StackMap>(vios, "StackMaps", stack_maps_, verbose); |
| 282 | DumpTable<RegisterMask>(vios, "RegisterMasks", register_masks_, verbose); |
| 283 | DumpTable<MaskInfo>(vios, "StackMasks", stack_masks_, verbose, true /* is_mask */); |
David Srbecky | a2d29a3 | 2018-08-03 11:06:38 +0100 | [diff] [blame] | 284 | DumpTable<InlineInfo>(vios, "InlineInfos", inline_infos_, verbose); |
| 285 | DumpTable<MethodInfo>(vios, "MethodInfo", method_infos_, verbose); |
David Srbecky | 86decb6 | 2018-06-05 06:41:10 +0100 | [diff] [blame] | 286 | DumpTable<MaskInfo>(vios, "DexRegisterMasks", dex_register_masks_, verbose, true /* is_mask */); |
| 287 | DumpTable<DexRegisterMapInfo>(vios, "DexRegisterMaps", dex_register_maps_, verbose); |
| 288 | DumpTable<DexRegisterInfo>(vios, "DexRegisterCatalog", dex_register_catalog_, verbose); |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 289 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 290 | // Display stack maps along with (live) Dex register maps. |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 291 | if (verbose) { |
David Srbecky | 93bd361 | 2018-07-02 19:30:18 +0100 | [diff] [blame] | 292 | for (StackMap stack_map : stack_maps_) { |
David Srbecky | 8cd5454 | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 293 | stack_map.Dump(vios, *this, code_offset, instruction_set); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 294 | } |
| 295 | } |
| 296 | } |
| 297 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 298 | void StackMap::Dump(VariableIndentationOutputStream* vios, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 299 | const CodeInfo& code_info, |
| 300 | uint32_t code_offset, |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 301 | InstructionSet instruction_set) const { |
David Srbecky | 052f8ca | 2018-04-26 15:42:54 +0100 | [diff] [blame] | 302 | const uint32_t pc_offset = GetNativePcOffset(instruction_set); |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 303 | vios->Stream() |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 304 | << "StackMap[" << Row() << "]" |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 305 | << std::hex |
David Srbecky | 71ec1cc | 2018-05-18 15:57:25 +0100 | [diff] [blame] | 306 | << " (native_pc=0x" << code_offset + pc_offset |
| 307 | << ", dex_pc=0x" << GetDexPc() |
David Srbecky | 052f8ca | 2018-04-26 15:42:54 +0100 | [diff] [blame] | 308 | << ", register_mask=0x" << code_info.GetRegisterMaskOf(*this) |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 309 | << std::dec |
| 310 | << ", stack_mask=0b"; |
David Srbecky | 052f8ca | 2018-04-26 15:42:54 +0100 | [diff] [blame] | 311 | BitMemoryRegion stack_mask = code_info.GetStackMaskOf(*this); |
David Srbecky | 4b59d10 | 2018-05-29 21:46:10 +0000 | [diff] [blame] | 312 | for (size_t i = 0, e = stack_mask.size_in_bits(); i < e; ++i) { |
David Srbecky | 45aa598 | 2016-03-18 02:15:09 +0000 | [diff] [blame] | 313 | vios->Stream() << stack_mask.LoadBit(e - i - 1); |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 314 | } |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 315 | vios->Stream() << ")\n"; |
David Srbecky | e140212 | 2018-06-13 18:20:45 +0100 | [diff] [blame] | 316 | code_info.GetDexRegisterMapOf(*this).Dump(vios); |
David Srbecky | 93bd361 | 2018-07-02 19:30:18 +0100 | [diff] [blame] | 317 | for (InlineInfo inline_info : code_info.GetInlineInfosOf(*this)) { |
David Srbecky | 8cd5454 | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 318 | inline_info.Dump(vios, code_info, *this); |
Nicolas Geoffray | 12bdb72 | 2015-06-17 09:44:43 +0100 | [diff] [blame] | 319 | } |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 320 | } |
| 321 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 322 | void InlineInfo::Dump(VariableIndentationOutputStream* vios, |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 323 | const CodeInfo& code_info, |
David Srbecky | 8cd5454 | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 324 | const StackMap& stack_map) const { |
David Srbecky | 6e69e52 | 2018-06-03 12:00:14 +0100 | [diff] [blame] | 325 | uint32_t depth = Row() - stack_map.GetInlineInfoIndex(); |
| 326 | vios->Stream() |
| 327 | << "InlineInfo[" << Row() << "]" |
| 328 | << " (depth=" << depth |
| 329 | << std::hex |
| 330 | << ", dex_pc=0x" << GetDexPc(); |
| 331 | if (EncodesArtMethod()) { |
| 332 | ScopedObjectAccess soa(Thread::Current()); |
| 333 | vios->Stream() << ", method=" << GetArtMethod()->PrettyMethod(); |
| 334 | } else { |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 335 | vios->Stream() |
David Srbecky | 6e69e52 | 2018-06-03 12:00:14 +0100 | [diff] [blame] | 336 | << std::dec |
David Srbecky | 8cd5454 | 2018-07-15 23:58:44 +0100 | [diff] [blame] | 337 | << ", method_index=" << code_info.GetMethodIndexOf(*this); |
David Srbecky | 6e69e52 | 2018-06-03 12:00:14 +0100 | [diff] [blame] | 338 | } |
| 339 | vios->Stream() << ")\n"; |
David Srbecky | 93bd361 | 2018-07-02 19:30:18 +0100 | [diff] [blame] | 340 | code_info.GetInlineDexRegisterMapOf(stack_map, *this).Dump(vios); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 341 | } |
| 342 | |
| 343 | } // namespace art |