1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker * Copyright (C) 2015 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker *
4*795d594fSAndroid Build Coastguard Worker * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker *
8*795d594fSAndroid Build Coastguard Worker * http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker *
10*795d594fSAndroid Build Coastguard Worker * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker */
16*795d594fSAndroid Build Coastguard Worker
17*795d594fSAndroid Build Coastguard Worker #include "stack_map.h"
18*795d594fSAndroid Build Coastguard Worker
19*795d594fSAndroid Build Coastguard Worker #include <iomanip>
20*795d594fSAndroid Build Coastguard Worker #include <stdint.h>
21*795d594fSAndroid Build Coastguard Worker
22*795d594fSAndroid Build Coastguard Worker #include "art_method.h"
23*795d594fSAndroid Build Coastguard Worker #include "base/indenter.h"
24*795d594fSAndroid Build Coastguard Worker #include "base/stats-inl.h"
25*795d594fSAndroid Build Coastguard Worker #include "oat_quick_method_header.h"
26*795d594fSAndroid Build Coastguard Worker #include "scoped_thread_state_change-inl.h"
27*795d594fSAndroid Build Coastguard Worker
28*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
29*795d594fSAndroid Build Coastguard Worker
30*795d594fSAndroid Build Coastguard Worker // The callback is used to inform the caller about memory bounds of the bit-tables.
31*795d594fSAndroid Build Coastguard Worker template<typename DecodeCallback>
CodeInfo(const uint8_t * data,size_t * num_read_bits,DecodeCallback callback)32*795d594fSAndroid Build Coastguard Worker CodeInfo::CodeInfo(const uint8_t* data, size_t* num_read_bits, DecodeCallback callback) {
33*795d594fSAndroid Build Coastguard Worker BitMemoryReader reader(data);
34*795d594fSAndroid Build Coastguard Worker std::array<uint32_t, kNumHeaders> header = reader.ReadInterleavedVarints<kNumHeaders>();
35*795d594fSAndroid Build Coastguard Worker ForEachHeaderField([this, &header](size_t i, auto member_pointer) ALWAYS_INLINE {
36*795d594fSAndroid Build Coastguard Worker this->*member_pointer = header[i];
37*795d594fSAndroid Build Coastguard Worker });
38*795d594fSAndroid Build Coastguard Worker ForEachBitTableField([this, &reader, &callback](size_t i, auto member_pointer) ALWAYS_INLINE {
39*795d594fSAndroid Build Coastguard Worker auto& table = this->*member_pointer;
40*795d594fSAndroid Build Coastguard Worker if (LIKELY(HasBitTable(i))) {
41*795d594fSAndroid Build Coastguard Worker if (UNLIKELY(IsBitTableDeduped(i))) {
42*795d594fSAndroid Build Coastguard Worker ssize_t bit_offset = reader.NumberOfReadBits() - reader.ReadVarint();
43*795d594fSAndroid Build Coastguard Worker BitMemoryReader reader2(reader.data(), bit_offset); // The offset is negative.
44*795d594fSAndroid Build Coastguard Worker table.Decode(reader2);
45*795d594fSAndroid Build Coastguard Worker callback(i, &table, reader2.GetReadRegion());
46*795d594fSAndroid Build Coastguard Worker } else {
47*795d594fSAndroid Build Coastguard Worker ssize_t bit_offset = reader.NumberOfReadBits();
48*795d594fSAndroid Build Coastguard Worker table.Decode(reader);
49*795d594fSAndroid Build Coastguard Worker callback(i, &table, reader.GetReadRegion().Subregion(bit_offset));
50*795d594fSAndroid Build Coastguard Worker }
51*795d594fSAndroid Build Coastguard Worker }
52*795d594fSAndroid Build Coastguard Worker });
53*795d594fSAndroid Build Coastguard Worker if (num_read_bits != nullptr) {
54*795d594fSAndroid Build Coastguard Worker *num_read_bits = reader.NumberOfReadBits();
55*795d594fSAndroid Build Coastguard Worker }
56*795d594fSAndroid Build Coastguard Worker }
57*795d594fSAndroid Build Coastguard Worker
CodeInfo(const uint8_t * data,size_t * num_read_bits)58*795d594fSAndroid Build Coastguard Worker CodeInfo::CodeInfo(const uint8_t* data, size_t* num_read_bits)
59*795d594fSAndroid Build Coastguard Worker : CodeInfo(data, num_read_bits, [](size_t, auto*, BitMemoryRegion) ALWAYS_INLINE {}) {}
60*795d594fSAndroid Build Coastguard Worker
CodeInfo(const OatQuickMethodHeader * header)61*795d594fSAndroid Build Coastguard Worker CodeInfo::CodeInfo(const OatQuickMethodHeader* header)
62*795d594fSAndroid Build Coastguard Worker : CodeInfo(header->GetOptimizedCodeInfoPtr()) {}
63*795d594fSAndroid Build Coastguard Worker
DecodeGcMasksOnly(const OatQuickMethodHeader * header)64*795d594fSAndroid Build Coastguard Worker CodeInfo CodeInfo::DecodeGcMasksOnly(const OatQuickMethodHeader* header) {
65*795d594fSAndroid Build Coastguard Worker CodeInfo code_info(header->GetOptimizedCodeInfoPtr());
66*795d594fSAndroid Build Coastguard Worker CodeInfo copy; // Copy to dead-code-eliminate all fields that we do not need.
67*795d594fSAndroid Build Coastguard Worker copy.stack_maps_ = code_info.stack_maps_;
68*795d594fSAndroid Build Coastguard Worker copy.register_masks_ = code_info.register_masks_;
69*795d594fSAndroid Build Coastguard Worker copy.stack_masks_ = code_info.stack_masks_;
70*795d594fSAndroid Build Coastguard Worker return copy;
71*795d594fSAndroid Build Coastguard Worker }
72*795d594fSAndroid Build Coastguard Worker
DecodeInlineInfoOnly(const OatQuickMethodHeader * header)73*795d594fSAndroid Build Coastguard Worker CodeInfo CodeInfo::DecodeInlineInfoOnly(const OatQuickMethodHeader* header) {
74*795d594fSAndroid Build Coastguard Worker CodeInfo code_info(header->GetOptimizedCodeInfoPtr());
75*795d594fSAndroid Build Coastguard Worker CodeInfo copy; // Copy to dead-code-eliminate all fields that we do not need.
76*795d594fSAndroid Build Coastguard Worker copy.number_of_dex_registers_ = code_info.number_of_dex_registers_;
77*795d594fSAndroid Build Coastguard Worker copy.stack_maps_ = code_info.stack_maps_;
78*795d594fSAndroid Build Coastguard Worker copy.inline_infos_ = code_info.inline_infos_;
79*795d594fSAndroid Build Coastguard Worker copy.method_infos_ = code_info.method_infos_;
80*795d594fSAndroid Build Coastguard Worker return copy;
81*795d594fSAndroid Build Coastguard Worker }
82*795d594fSAndroid Build Coastguard Worker
GetStackMapForNativePcOffset(uintptr_t pc,InstructionSet isa) const83*795d594fSAndroid Build Coastguard Worker StackMap CodeInfo::GetStackMapForNativePcOffset(uintptr_t pc, InstructionSet isa) const {
84*795d594fSAndroid Build Coastguard Worker uint32_t packed_pc = StackMap::PackNativePc(pc, isa);
85*795d594fSAndroid Build Coastguard Worker // Binary search. All catch stack maps are stored separately at the end.
86*795d594fSAndroid Build Coastguard Worker auto it = std::partition_point(
87*795d594fSAndroid Build Coastguard Worker stack_maps_.begin(),
88*795d594fSAndroid Build Coastguard Worker stack_maps_.end(),
89*795d594fSAndroid Build Coastguard Worker [packed_pc](const StackMap& sm) {
90*795d594fSAndroid Build Coastguard Worker return sm.GetPackedNativePc() < packed_pc && sm.GetKind() != StackMap::Kind::Catch;
91*795d594fSAndroid Build Coastguard Worker });
92*795d594fSAndroid Build Coastguard Worker // Start at the lower bound and iterate over all stack maps with the given native pc.
93*795d594fSAndroid Build Coastguard Worker for (; it != stack_maps_.end() && (*it).GetNativePcOffset(isa) == pc; ++it) {
94*795d594fSAndroid Build Coastguard Worker StackMap::Kind kind = static_cast<StackMap::Kind>((*it).GetKind());
95*795d594fSAndroid Build Coastguard Worker if (kind == StackMap::Kind::Default || kind == StackMap::Kind::OSR) {
96*795d594fSAndroid Build Coastguard Worker return *it;
97*795d594fSAndroid Build Coastguard Worker }
98*795d594fSAndroid Build Coastguard Worker }
99*795d594fSAndroid Build Coastguard Worker return stack_maps_.GetInvalidRow();
100*795d594fSAndroid Build Coastguard Worker }
101*795d594fSAndroid Build Coastguard Worker
102*795d594fSAndroid Build Coastguard Worker // Scan backward to determine dex register locations at given stack map.
103*795d594fSAndroid Build Coastguard Worker // All registers for a stack map are combined - inlined registers are just appended,
104*795d594fSAndroid Build Coastguard Worker // therefore 'first_dex_register' allows us to select a sub-range to decode.
DecodeDexRegisterMap(uint32_t stack_map_index,uint32_t first_dex_register,DexRegisterMap * map) const105*795d594fSAndroid Build Coastguard Worker void CodeInfo::DecodeDexRegisterMap(uint32_t stack_map_index,
106*795d594fSAndroid Build Coastguard Worker uint32_t first_dex_register,
107*795d594fSAndroid Build Coastguard Worker /*out*/ DexRegisterMap* map) const {
108*795d594fSAndroid Build Coastguard Worker // Count remaining work so we know when we have finished.
109*795d594fSAndroid Build Coastguard Worker uint32_t remaining_registers = map->size();
110*795d594fSAndroid Build Coastguard Worker
111*795d594fSAndroid Build Coastguard Worker // Keep scanning backwards and collect the most recent location of each register.
112*795d594fSAndroid Build Coastguard Worker for (int32_t s = stack_map_index; s >= 0 && remaining_registers != 0; s--) {
113*795d594fSAndroid Build Coastguard Worker StackMap stack_map = GetStackMapAt(s);
114*795d594fSAndroid Build Coastguard Worker DCHECK_LE(stack_map_index - s, kMaxDexRegisterMapSearchDistance) << "Unbounded search";
115*795d594fSAndroid Build Coastguard Worker
116*795d594fSAndroid Build Coastguard Worker // The mask specifies which registers where modified in this stack map.
117*795d594fSAndroid Build Coastguard Worker // NB: the mask can be shorter than expected if trailing zero bits were removed.
118*795d594fSAndroid Build Coastguard Worker uint32_t mask_index = stack_map.GetDexRegisterMaskIndex();
119*795d594fSAndroid Build Coastguard Worker if (mask_index == StackMap::kNoValue) {
120*795d594fSAndroid Build Coastguard Worker continue; // Nothing changed at this stack map.
121*795d594fSAndroid Build Coastguard Worker }
122*795d594fSAndroid Build Coastguard Worker BitMemoryRegion mask = dex_register_masks_.GetBitMemoryRegion(mask_index);
123*795d594fSAndroid Build Coastguard Worker if (mask.size_in_bits() <= first_dex_register) {
124*795d594fSAndroid Build Coastguard Worker continue; // Nothing changed after the first register we are interested in.
125*795d594fSAndroid Build Coastguard Worker }
126*795d594fSAndroid Build Coastguard Worker
127*795d594fSAndroid Build Coastguard Worker // The map stores one catalogue index per each modified register location.
128*795d594fSAndroid Build Coastguard Worker uint32_t map_index = stack_map.GetDexRegisterMapIndex();
129*795d594fSAndroid Build Coastguard Worker DCHECK_NE(map_index, StackMap::kNoValue);
130*795d594fSAndroid Build Coastguard Worker
131*795d594fSAndroid Build Coastguard Worker // Skip initial registers which we are not interested in (to get to inlined registers).
132*795d594fSAndroid Build Coastguard Worker map_index += mask.PopCount(0, first_dex_register);
133*795d594fSAndroid Build Coastguard Worker mask = mask.Subregion(first_dex_register, mask.size_in_bits() - first_dex_register);
134*795d594fSAndroid Build Coastguard Worker
135*795d594fSAndroid Build Coastguard Worker // Update registers that we see for first time (i.e. most recent value).
136*795d594fSAndroid Build Coastguard Worker DexRegisterLocation* regs = map->data();
137*795d594fSAndroid Build Coastguard Worker const uint32_t end = std::min<uint32_t>(map->size(), mask.size_in_bits());
138*795d594fSAndroid Build Coastguard Worker const size_t kNumBits = BitSizeOf<uint32_t>();
139*795d594fSAndroid Build Coastguard Worker for (uint32_t reg = 0; reg < end; reg += kNumBits) {
140*795d594fSAndroid Build Coastguard Worker // Process the mask in chunks of kNumBits for performance.
141*795d594fSAndroid Build Coastguard Worker uint32_t bits = mask.LoadBits(reg, std::min<uint32_t>(end - reg, kNumBits));
142*795d594fSAndroid Build Coastguard Worker while (bits != 0) {
143*795d594fSAndroid Build Coastguard Worker uint32_t bit = CTZ(bits);
144*795d594fSAndroid Build Coastguard Worker if (regs[reg + bit].GetKind() == DexRegisterLocation::Kind::kInvalid) {
145*795d594fSAndroid Build Coastguard Worker regs[reg + bit] = GetDexRegisterCatalogEntry(dex_register_maps_.Get(map_index));
146*795d594fSAndroid Build Coastguard Worker remaining_registers--;
147*795d594fSAndroid Build Coastguard Worker }
148*795d594fSAndroid Build Coastguard Worker map_index++;
149*795d594fSAndroid Build Coastguard Worker bits ^= 1u << bit; // Clear the bit.
150*795d594fSAndroid Build Coastguard Worker }
151*795d594fSAndroid Build Coastguard Worker }
152*795d594fSAndroid Build Coastguard Worker }
153*795d594fSAndroid Build Coastguard Worker
154*795d594fSAndroid Build Coastguard Worker // Set any remaining registers to None (which is the default state at first stack map).
155*795d594fSAndroid Build Coastguard Worker if (remaining_registers != 0) {
156*795d594fSAndroid Build Coastguard Worker DexRegisterLocation* regs = map->data();
157*795d594fSAndroid Build Coastguard Worker for (uint32_t r = 0; r < map->size(); r++) {
158*795d594fSAndroid Build Coastguard Worker if (regs[r].GetKind() == DexRegisterLocation::Kind::kInvalid) {
159*795d594fSAndroid Build Coastguard Worker regs[r] = DexRegisterLocation::None();
160*795d594fSAndroid Build Coastguard Worker }
161*795d594fSAndroid Build Coastguard Worker }
162*795d594fSAndroid Build Coastguard Worker }
163*795d594fSAndroid Build Coastguard Worker }
164*795d594fSAndroid Build Coastguard Worker
165*795d594fSAndroid Build Coastguard Worker // Decode the CodeInfo while collecting size statistics.
CollectSizeStats(const uint8_t * code_info_data,Stats & stats)166*795d594fSAndroid Build Coastguard Worker void CodeInfo::CollectSizeStats(const uint8_t* code_info_data, /*out*/ Stats& stats) {
167*795d594fSAndroid Build Coastguard Worker BitMemoryReader reader(code_info_data);
168*795d594fSAndroid Build Coastguard Worker reader.ReadInterleavedVarints<kNumHeaders>();
169*795d594fSAndroid Build Coastguard Worker stats["Header"].AddBits(reader.NumberOfReadBits());
170*795d594fSAndroid Build Coastguard Worker size_t num_bits;
171*795d594fSAndroid Build Coastguard Worker CodeInfo code_info(code_info_data, &num_bits, [&](size_t i, auto* table, BitMemoryRegion region) {
172*795d594fSAndroid Build Coastguard Worker if (!code_info.IsBitTableDeduped(i)) {
173*795d594fSAndroid Build Coastguard Worker Stats& table_stats = stats[table->GetName()];
174*795d594fSAndroid Build Coastguard Worker table_stats.AddBits(region.size_in_bits());
175*795d594fSAndroid Build Coastguard Worker table_stats["Header"].AddBits(region.size_in_bits() - table->DataBitSize());
176*795d594fSAndroid Build Coastguard Worker const char* const* column_names = table->GetColumnNames();
177*795d594fSAndroid Build Coastguard Worker for (size_t c = 0; c < table->NumColumns(); c++) {
178*795d594fSAndroid Build Coastguard Worker if (table->NumColumnBits(c) > 0) {
179*795d594fSAndroid Build Coastguard Worker Stats& column_stats = table_stats[column_names[c]];
180*795d594fSAndroid Build Coastguard Worker column_stats.AddBits(table->NumRows() * table->NumColumnBits(c), table->NumRows());
181*795d594fSAndroid Build Coastguard Worker }
182*795d594fSAndroid Build Coastguard Worker }
183*795d594fSAndroid Build Coastguard Worker }
184*795d594fSAndroid Build Coastguard Worker });
185*795d594fSAndroid Build Coastguard Worker stats.AddBytes(BitsToBytesRoundUp(num_bits));
186*795d594fSAndroid Build Coastguard Worker }
187*795d594fSAndroid Build Coastguard Worker
Dump(VariableIndentationOutputStream * vios) const188*795d594fSAndroid Build Coastguard Worker void DexRegisterMap::Dump(VariableIndentationOutputStream* vios) const {
189*795d594fSAndroid Build Coastguard Worker if (HasAnyLiveDexRegisters()) {
190*795d594fSAndroid Build Coastguard Worker ScopedIndentation indent1(vios);
191*795d594fSAndroid Build Coastguard Worker for (size_t i = 0; i < size(); ++i) {
192*795d594fSAndroid Build Coastguard Worker DexRegisterLocation reg = (*this)[i];
193*795d594fSAndroid Build Coastguard Worker if (reg.IsLive()) {
194*795d594fSAndroid Build Coastguard Worker vios->Stream() << "v" << i << ":" << reg << " ";
195*795d594fSAndroid Build Coastguard Worker }
196*795d594fSAndroid Build Coastguard Worker }
197*795d594fSAndroid Build Coastguard Worker vios->Stream() << "\n";
198*795d594fSAndroid Build Coastguard Worker }
199*795d594fSAndroid Build Coastguard Worker }
200*795d594fSAndroid Build Coastguard Worker
Dump(VariableIndentationOutputStream * vios,uint32_t code_offset,bool verbose,InstructionSet instruction_set) const201*795d594fSAndroid Build Coastguard Worker void CodeInfo::Dump(VariableIndentationOutputStream* vios,
202*795d594fSAndroid Build Coastguard Worker uint32_t code_offset,
203*795d594fSAndroid Build Coastguard Worker bool verbose,
204*795d594fSAndroid Build Coastguard Worker InstructionSet instruction_set) const {
205*795d594fSAndroid Build Coastguard Worker vios->Stream() << "CodeInfo"
206*795d594fSAndroid Build Coastguard Worker << " CodeSize:" << code_size_
207*795d594fSAndroid Build Coastguard Worker << " FrameSize:" << packed_frame_size_ * kStackAlignment
208*795d594fSAndroid Build Coastguard Worker << " CoreSpillMask:" << std::hex << core_spill_mask_
209*795d594fSAndroid Build Coastguard Worker << " FpSpillMask:" << std::hex << fp_spill_mask_
210*795d594fSAndroid Build Coastguard Worker << " NumberOfDexRegisters:" << std::dec << number_of_dex_registers_
211*795d594fSAndroid Build Coastguard Worker << "\n";
212*795d594fSAndroid Build Coastguard Worker ScopedIndentation indent1(vios);
213*795d594fSAndroid Build Coastguard Worker ForEachBitTableField([this, &vios, verbose](size_t, auto member_pointer) {
214*795d594fSAndroid Build Coastguard Worker const auto& table = this->*member_pointer;
215*795d594fSAndroid Build Coastguard Worker if (table.NumRows() != 0) {
216*795d594fSAndroid Build Coastguard Worker vios->Stream() << table.GetName() << " BitSize=" << table.DataBitSize();
217*795d594fSAndroid Build Coastguard Worker vios->Stream() << " Rows=" << table.NumRows() << " Bits={";
218*795d594fSAndroid Build Coastguard Worker const char* const* column_names = table.GetColumnNames();
219*795d594fSAndroid Build Coastguard Worker for (size_t c = 0; c < table.NumColumns(); c++) {
220*795d594fSAndroid Build Coastguard Worker vios->Stream() << (c != 0 ? " " : "");
221*795d594fSAndroid Build Coastguard Worker vios->Stream() << column_names[c] << "=" << table.NumColumnBits(c);
222*795d594fSAndroid Build Coastguard Worker }
223*795d594fSAndroid Build Coastguard Worker vios->Stream() << "}\n";
224*795d594fSAndroid Build Coastguard Worker if (verbose) {
225*795d594fSAndroid Build Coastguard Worker ScopedIndentation indent1(vios);
226*795d594fSAndroid Build Coastguard Worker for (size_t r = 0; r < table.NumRows(); r++) {
227*795d594fSAndroid Build Coastguard Worker vios->Stream() << "[" << std::right << std::setw(3) << r << "]={";
228*795d594fSAndroid Build Coastguard Worker for (size_t c = 0; c < table.NumColumns(); c++) {
229*795d594fSAndroid Build Coastguard Worker vios->Stream() << (c != 0 ? " " : "");
230*795d594fSAndroid Build Coastguard Worker if (&table == static_cast<const void*>(&stack_masks_) ||
231*795d594fSAndroid Build Coastguard Worker &table == static_cast<const void*>(&dex_register_masks_)) {
232*795d594fSAndroid Build Coastguard Worker BitMemoryRegion bits = table.GetBitMemoryRegion(r, c);
233*795d594fSAndroid Build Coastguard Worker for (size_t b = 0, e = bits.size_in_bits(); b < e; b++) {
234*795d594fSAndroid Build Coastguard Worker vios->Stream() << bits.LoadBit(e - b - 1);
235*795d594fSAndroid Build Coastguard Worker }
236*795d594fSAndroid Build Coastguard Worker } else {
237*795d594fSAndroid Build Coastguard Worker vios->Stream() << std::right << std::setw(8) << static_cast<int32_t>(table.Get(r, c));
238*795d594fSAndroid Build Coastguard Worker }
239*795d594fSAndroid Build Coastguard Worker }
240*795d594fSAndroid Build Coastguard Worker vios->Stream() << "}\n";
241*795d594fSAndroid Build Coastguard Worker }
242*795d594fSAndroid Build Coastguard Worker }
243*795d594fSAndroid Build Coastguard Worker }
244*795d594fSAndroid Build Coastguard Worker });
245*795d594fSAndroid Build Coastguard Worker
246*795d594fSAndroid Build Coastguard Worker // Display stack maps along with (live) Dex register maps.
247*795d594fSAndroid Build Coastguard Worker if (verbose) {
248*795d594fSAndroid Build Coastguard Worker for (StackMap stack_map : stack_maps_) {
249*795d594fSAndroid Build Coastguard Worker stack_map.Dump(vios, *this, code_offset, instruction_set);
250*795d594fSAndroid Build Coastguard Worker }
251*795d594fSAndroid Build Coastguard Worker }
252*795d594fSAndroid Build Coastguard Worker }
253*795d594fSAndroid Build Coastguard Worker
Dump(VariableIndentationOutputStream * vios,const CodeInfo & code_info,uint32_t code_offset,InstructionSet instruction_set) const254*795d594fSAndroid Build Coastguard Worker void StackMap::Dump(VariableIndentationOutputStream* vios,
255*795d594fSAndroid Build Coastguard Worker const CodeInfo& code_info,
256*795d594fSAndroid Build Coastguard Worker uint32_t code_offset,
257*795d594fSAndroid Build Coastguard Worker InstructionSet instruction_set) const {
258*795d594fSAndroid Build Coastguard Worker const uint32_t pc_offset = GetNativePcOffset(instruction_set);
259*795d594fSAndroid Build Coastguard Worker vios->Stream()
260*795d594fSAndroid Build Coastguard Worker << "StackMap[" << Row() << "]"
261*795d594fSAndroid Build Coastguard Worker << std::hex
262*795d594fSAndroid Build Coastguard Worker << " (native_pc=0x" << code_offset + pc_offset
263*795d594fSAndroid Build Coastguard Worker << ", dex_pc=0x" << GetDexPc()
264*795d594fSAndroid Build Coastguard Worker << ", register_mask=0x" << code_info.GetRegisterMaskOf(*this)
265*795d594fSAndroid Build Coastguard Worker << std::dec
266*795d594fSAndroid Build Coastguard Worker << ", stack_mask=0b";
267*795d594fSAndroid Build Coastguard Worker BitMemoryRegion stack_mask = code_info.GetStackMaskOf(*this);
268*795d594fSAndroid Build Coastguard Worker for (size_t i = 0, e = stack_mask.size_in_bits(); i < e; ++i) {
269*795d594fSAndroid Build Coastguard Worker vios->Stream() << stack_mask.LoadBit(e - i - 1);
270*795d594fSAndroid Build Coastguard Worker }
271*795d594fSAndroid Build Coastguard Worker switch (static_cast<Kind>(GetKind())) {
272*795d594fSAndroid Build Coastguard Worker case Kind::Default: break;
273*795d594fSAndroid Build Coastguard Worker case Kind::Catch: vios->Stream() << ", Catch"; break;
274*795d594fSAndroid Build Coastguard Worker case Kind::OSR: vios->Stream() << ", OSR"; break;
275*795d594fSAndroid Build Coastguard Worker case Kind::Debug: vios->Stream() << ", Debug"; break;
276*795d594fSAndroid Build Coastguard Worker }
277*795d594fSAndroid Build Coastguard Worker vios->Stream() << ")\n";
278*795d594fSAndroid Build Coastguard Worker code_info.GetDexRegisterMapOf(*this).Dump(vios);
279*795d594fSAndroid Build Coastguard Worker for (InlineInfo inline_info : code_info.GetInlineInfosOf(*this)) {
280*795d594fSAndroid Build Coastguard Worker inline_info.Dump(vios, code_info, *this);
281*795d594fSAndroid Build Coastguard Worker }
282*795d594fSAndroid Build Coastguard Worker }
283*795d594fSAndroid Build Coastguard Worker
Dump(VariableIndentationOutputStream * vios,const CodeInfo & code_info,const StackMap & stack_map) const284*795d594fSAndroid Build Coastguard Worker void InlineInfo::Dump(VariableIndentationOutputStream* vios,
285*795d594fSAndroid Build Coastguard Worker const CodeInfo& code_info,
286*795d594fSAndroid Build Coastguard Worker const StackMap& stack_map) const {
287*795d594fSAndroid Build Coastguard Worker uint32_t depth = Row() - stack_map.GetInlineInfoIndex();
288*795d594fSAndroid Build Coastguard Worker vios->Stream()
289*795d594fSAndroid Build Coastguard Worker << "InlineInfo[" << Row() << "]"
290*795d594fSAndroid Build Coastguard Worker << " (depth=" << depth
291*795d594fSAndroid Build Coastguard Worker << std::hex
292*795d594fSAndroid Build Coastguard Worker << ", dex_pc=0x" << GetDexPc();
293*795d594fSAndroid Build Coastguard Worker if (EncodesArtMethod()) {
294*795d594fSAndroid Build Coastguard Worker ScopedObjectAccess soa(Thread::Current());
295*795d594fSAndroid Build Coastguard Worker vios->Stream() << ", method=" << GetArtMethod()->PrettyMethod();
296*795d594fSAndroid Build Coastguard Worker } else {
297*795d594fSAndroid Build Coastguard Worker MethodInfo method_info = code_info.GetMethodInfoOf(*this);
298*795d594fSAndroid Build Coastguard Worker vios->Stream() << std::dec << ", method_index=" << method_info.GetMethodIndex();
299*795d594fSAndroid Build Coastguard Worker if (method_info.HasDexFileIndex()) {
300*795d594fSAndroid Build Coastguard Worker vios->Stream() << ", is_in_bootclasspath=" << std::boolalpha
301*795d594fSAndroid Build Coastguard Worker << (method_info.GetDexFileIndexKind() == MethodInfo::kKindBCP)
302*795d594fSAndroid Build Coastguard Worker << std::noboolalpha << ", dex_file_index=" << std::dec
303*795d594fSAndroid Build Coastguard Worker << method_info.GetDexFileIndex();
304*795d594fSAndroid Build Coastguard Worker }
305*795d594fSAndroid Build Coastguard Worker }
306*795d594fSAndroid Build Coastguard Worker vios->Stream() << ")\n";
307*795d594fSAndroid Build Coastguard Worker code_info.GetInlineDexRegisterMapOf(stack_map, *this).Dump(vios);
308*795d594fSAndroid Build Coastguard Worker }
309*795d594fSAndroid Build Coastguard Worker
310*795d594fSAndroid Build Coastguard Worker } // namespace art
311