Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [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 | */ |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 16 | #include "stack_map_stream.h" |
| 17 | |
| 18 | namespace art { |
| 19 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 20 | void StackMapStream::BeginStackMapEntry(uint32_t dex_pc, |
| 21 | uint32_t native_pc_offset, |
| 22 | uint32_t register_mask, |
| 23 | BitVector* sp_mask, |
| 24 | uint32_t num_dex_registers, |
| 25 | uint8_t inlining_depth) { |
| 26 | DCHECK_EQ(0u, current_entry_.dex_pc) << "EndStackMapEntry not called after BeginStackMapEntry"; |
Calin Juravle | b5c4693 | 2015-10-06 17:09:49 +0100 | [diff] [blame] | 27 | DCHECK_NE(dex_pc, static_cast<uint32_t>(-1)) << "invalid dex_pc"; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 28 | current_entry_.dex_pc = dex_pc; |
| 29 | current_entry_.native_pc_offset = native_pc_offset; |
| 30 | current_entry_.register_mask = register_mask; |
| 31 | current_entry_.sp_mask = sp_mask; |
| 32 | current_entry_.num_dex_registers = num_dex_registers; |
| 33 | current_entry_.inlining_depth = inlining_depth; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 34 | current_entry_.dex_register_locations_start_index = dex_register_locations_.size(); |
| 35 | current_entry_.inline_infos_start_index = inline_infos_.size(); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 36 | current_entry_.dex_register_map_hash = 0; |
| 37 | current_entry_.same_dex_register_map_as_ = kNoSameDexMapFound; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 38 | if (num_dex_registers != 0) { |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 39 | current_entry_.live_dex_registers_mask = |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 40 | ArenaBitVector::Create(allocator_, num_dex_registers, true, kArenaAllocStackMapStream); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 41 | } else { |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 42 | current_entry_.live_dex_registers_mask = nullptr; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 43 | } |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 44 | |
| 45 | if (sp_mask != nullptr) { |
| 46 | stack_mask_max_ = std::max(stack_mask_max_, sp_mask->GetHighestBitSet()); |
| 47 | } |
| 48 | if (inlining_depth > 0) { |
| 49 | number_of_stack_maps_with_inline_info_++; |
| 50 | } |
| 51 | |
| 52 | dex_pc_max_ = std::max(dex_pc_max_, dex_pc); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 53 | register_mask_max_ = std::max(register_mask_max_, register_mask); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 54 | current_dex_register_ = 0; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 55 | } |
| 56 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 57 | void StackMapStream::EndStackMapEntry() { |
| 58 | current_entry_.same_dex_register_map_as_ = FindEntryWithTheSameDexMap(); |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 59 | stack_maps_.push_back(current_entry_); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 60 | current_entry_ = StackMapEntry(); |
| 61 | } |
| 62 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 63 | void StackMapStream::AddDexRegisterEntry(DexRegisterLocation::Kind kind, int32_t value) { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 64 | if (kind != DexRegisterLocation::Kind::kNone) { |
| 65 | // Ensure we only use non-compressed location kind at this stage. |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 66 | DCHECK(DexRegisterLocation::IsShortLocationKind(kind)) << kind; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 67 | DexRegisterLocation location(kind, value); |
| 68 | |
| 69 | // Look for Dex register `location` in the location catalog (using the |
| 70 | // companion hash map of locations to indices). Use its index if it |
| 71 | // is already in the location catalog. If not, insert it (in the |
| 72 | // location catalog and the hash map) and use the newly created index. |
| 73 | auto it = location_catalog_entries_indices_.Find(location); |
| 74 | if (it != location_catalog_entries_indices_.end()) { |
| 75 | // Retrieve the index from the hash map. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 76 | dex_register_locations_.push_back(it->second); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 77 | } else { |
| 78 | // Create a new entry in the location catalog and the hash map. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 79 | size_t index = location_catalog_entries_.size(); |
| 80 | location_catalog_entries_.push_back(location); |
| 81 | dex_register_locations_.push_back(index); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 82 | location_catalog_entries_indices_.Insert(std::make_pair(location, index)); |
| 83 | } |
| 84 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 85 | if (in_inline_frame_) { |
| 86 | // TODO: Support sharing DexRegisterMap across InlineInfo. |
| 87 | DCHECK_LT(current_dex_register_, current_inline_info_.num_dex_registers); |
| 88 | current_inline_info_.live_dex_registers_mask->SetBit(current_dex_register_); |
| 89 | } else { |
| 90 | DCHECK_LT(current_dex_register_, current_entry_.num_dex_registers); |
| 91 | current_entry_.live_dex_registers_mask->SetBit(current_dex_register_); |
| 92 | current_entry_.dex_register_map_hash += (1 << |
| 93 | (current_dex_register_ % (sizeof(current_entry_.dex_register_map_hash) * kBitsPerByte))); |
| 94 | current_entry_.dex_register_map_hash += static_cast<uint32_t>(value); |
| 95 | current_entry_.dex_register_map_hash += static_cast<uint32_t>(kind); |
| 96 | } |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 97 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 98 | current_dex_register_++; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 99 | } |
| 100 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 101 | void StackMapStream::BeginInlineInfoEntry(uint32_t method_index, |
| 102 | uint32_t dex_pc, |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 103 | InvokeType invoke_type, |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 104 | uint32_t num_dex_registers) { |
| 105 | DCHECK(!in_inline_frame_); |
| 106 | in_inline_frame_ = true; |
| 107 | current_inline_info_.method_index = method_index; |
| 108 | current_inline_info_.dex_pc = dex_pc; |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 109 | current_inline_info_.invoke_type = invoke_type; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 110 | current_inline_info_.num_dex_registers = num_dex_registers; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 111 | current_inline_info_.dex_register_locations_start_index = dex_register_locations_.size(); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 112 | if (num_dex_registers != 0) { |
| 113 | current_inline_info_.live_dex_registers_mask = |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 114 | ArenaBitVector::Create(allocator_, num_dex_registers, true, kArenaAllocStackMapStream); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 115 | } else { |
| 116 | current_inline_info_.live_dex_registers_mask = nullptr; |
| 117 | } |
| 118 | current_dex_register_ = 0; |
| 119 | } |
| 120 | |
| 121 | void StackMapStream::EndInlineInfoEntry() { |
| 122 | DCHECK(in_inline_frame_); |
| 123 | DCHECK_EQ(current_dex_register_, current_inline_info_.num_dex_registers) |
| 124 | << "Inline information contains less registers than expected"; |
| 125 | in_inline_frame_ = false; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 126 | inline_infos_.push_back(current_inline_info_); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 127 | current_inline_info_ = InlineInfoEntry(); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 128 | } |
| 129 | |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 130 | uint32_t StackMapStream::ComputeMaxNativePcOffset() const { |
| 131 | uint32_t max_native_pc_offset = 0u; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 132 | for (const StackMapEntry& entry : stack_maps_) { |
| 133 | max_native_pc_offset = std::max(max_native_pc_offset, entry.native_pc_offset); |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 134 | } |
| 135 | return max_native_pc_offset; |
| 136 | } |
| 137 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 138 | size_t StackMapStream::PrepareForFillIn() { |
| 139 | int stack_mask_number_of_bits = stack_mask_max_ + 1; // Need room for max element too. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 140 | inline_info_size_ = ComputeInlineInfoSize(); |
| 141 | dex_register_maps_size_ = ComputeDexRegisterMapsSize(); |
Vladimir Marko | bd8c725 | 2015-06-12 10:06:32 +0100 | [diff] [blame] | 142 | uint32_t max_native_pc_offset = ComputeMaxNativePcOffset(); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 143 | size_t stack_map_size = stack_map_encoding_.SetFromSizes(max_native_pc_offset, |
| 144 | dex_pc_max_, |
| 145 | dex_register_maps_size_, |
| 146 | inline_info_size_, |
| 147 | register_mask_max_, |
| 148 | stack_mask_number_of_bits); |
| 149 | stack_maps_size_ = stack_maps_.size() * stack_map_size; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 150 | dex_register_location_catalog_size_ = ComputeDexRegisterLocationCatalogSize(); |
| 151 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 152 | size_t non_header_size = |
| 153 | stack_maps_size_ + |
| 154 | dex_register_location_catalog_size_ + |
| 155 | dex_register_maps_size_ + |
| 156 | inline_info_size_; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 157 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 158 | // Prepare the CodeInfo variable-sized encoding. |
| 159 | CodeInfoEncoding code_info_encoding; |
| 160 | code_info_encoding.non_header_size = non_header_size; |
| 161 | code_info_encoding.stack_map_encoding = stack_map_encoding_; |
| 162 | code_info_encoding.number_of_stack_maps = stack_maps_.size(); |
| 163 | code_info_encoding.stack_map_size_in_bytes = stack_map_size; |
| 164 | code_info_encoding.number_of_location_catalog_entries = location_catalog_entries_.size(); |
| 165 | code_info_encoding.Compress(&code_info_encoding_); |
| 166 | |
Nicolas Geoffray | 6530baf | 2015-05-26 15:22:58 +0100 | [diff] [blame] | 167 | // TODO: Move the catalog at the end. It is currently too expensive at runtime |
| 168 | // to compute its size (note that we do not encode that size in the CodeInfo). |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 169 | dex_register_location_catalog_start_ = code_info_encoding_.size() + stack_maps_size_; |
Nicolas Geoffray | 6530baf | 2015-05-26 15:22:58 +0100 | [diff] [blame] | 170 | dex_register_maps_start_ = |
| 171 | dex_register_location_catalog_start_ + dex_register_location_catalog_size_; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 172 | inline_infos_start_ = dex_register_maps_start_ + dex_register_maps_size_; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 173 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 174 | needed_size_ = code_info_encoding_.size() + non_header_size; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 175 | return needed_size_; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 176 | } |
| 177 | |
| 178 | size_t StackMapStream::ComputeDexRegisterLocationCatalogSize() const { |
| 179 | size_t size = DexRegisterLocationCatalog::kFixedSize; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 180 | for (const DexRegisterLocation& dex_register_location : location_catalog_entries_) { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 181 | size += DexRegisterLocationCatalog::EntrySize(dex_register_location); |
| 182 | } |
| 183 | return size; |
| 184 | } |
| 185 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 186 | size_t StackMapStream::ComputeDexRegisterMapSize(uint32_t num_dex_registers, |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 187 | const BitVector* live_dex_registers_mask) const { |
| 188 | // For num_dex_registers == 0u live_dex_registers_mask may be null. |
| 189 | if (num_dex_registers == 0u) { |
| 190 | return 0u; // No register map will be emitted. |
| 191 | } |
| 192 | DCHECK(live_dex_registers_mask != nullptr); |
| 193 | |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 194 | // Size of the map in bytes. |
| 195 | size_t size = DexRegisterMap::kFixedSize; |
| 196 | // Add the live bit mask for the Dex register liveness. |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 197 | size += DexRegisterMap::GetLiveBitMaskSize(num_dex_registers); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 198 | // Compute the size of the set of live Dex register entries. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 199 | size_t number_of_live_dex_registers = live_dex_registers_mask->NumSetBits(); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 200 | size_t map_entries_size_in_bits = |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 201 | DexRegisterMap::SingleEntrySizeInBits(location_catalog_entries_.size()) |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 202 | * number_of_live_dex_registers; |
| 203 | size_t map_entries_size_in_bytes = |
| 204 | RoundUp(map_entries_size_in_bits, kBitsPerByte) / kBitsPerByte; |
| 205 | size += map_entries_size_in_bytes; |
| 206 | return size; |
| 207 | } |
| 208 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 209 | size_t StackMapStream::ComputeDexRegisterMapsSize() const { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 210 | size_t size = 0; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 211 | size_t inline_info_index = 0; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 212 | for (const StackMapEntry& entry : stack_maps_) { |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 213 | if (entry.same_dex_register_map_as_ == kNoSameDexMapFound) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 214 | size += ComputeDexRegisterMapSize(entry.num_dex_registers, entry.live_dex_registers_mask); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 215 | } else { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 216 | // Entries with the same dex map will have the same offset. |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 217 | } |
| 218 | for (size_t j = 0; j < entry.inlining_depth; ++j) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 219 | InlineInfoEntry inline_entry = inline_infos_[inline_info_index++]; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 220 | size += ComputeDexRegisterMapSize(inline_entry.num_dex_registers, |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 221 | inline_entry.live_dex_registers_mask); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 222 | } |
| 223 | } |
| 224 | return size; |
| 225 | } |
| 226 | |
| 227 | size_t StackMapStream::ComputeInlineInfoSize() const { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 228 | return inline_infos_.size() * InlineInfo::SingleEntrySize() |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 229 | // For encoding the depth. |
| 230 | + (number_of_stack_maps_with_inline_info_ * InlineInfo::kFixedSize); |
| 231 | } |
| 232 | |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 233 | void StackMapStream::FillIn(MemoryRegion region) { |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 234 | DCHECK_EQ(0u, current_entry_.dex_pc) << "EndStackMapEntry not called after BeginStackMapEntry"; |
| 235 | DCHECK_NE(0u, needed_size_) << "PrepareForFillIn not called before FillIn"; |
| 236 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 237 | DCHECK_EQ(region.size(), needed_size_); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 238 | |
| 239 | // Note that the memory region does not have to be zeroed when we JIT code |
| 240 | // because we do not use the arena allocator there. |
| 241 | |
| 242 | // Write the CodeInfo header. |
| 243 | region.CopyFrom(0, MemoryRegion(code_info_encoding_.data(), code_info_encoding_.size())); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 244 | |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 245 | MemoryRegion dex_register_locations_region = region.Subregion( |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 246 | dex_register_maps_start_, dex_register_maps_size_); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 247 | |
| 248 | MemoryRegion inline_infos_region = region.Subregion( |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 249 | inline_infos_start_, inline_info_size_); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 250 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 251 | CodeInfo code_info(region); |
| 252 | CodeInfoEncoding encoding = code_info.ExtractEncoding(); |
| 253 | DCHECK_EQ(code_info.GetStackMapsSize(encoding), stack_maps_size_); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 254 | |
| 255 | // Set the Dex register location catalog. |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 256 | MemoryRegion dex_register_location_catalog_region = region.Subregion( |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 257 | dex_register_location_catalog_start_, dex_register_location_catalog_size_); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 258 | DexRegisterLocationCatalog dex_register_location_catalog(dex_register_location_catalog_region); |
| 259 | // Offset in `dex_register_location_catalog` where to store the next |
| 260 | // register location. |
| 261 | size_t location_catalog_offset = DexRegisterLocationCatalog::kFixedSize; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 262 | for (DexRegisterLocation dex_register_location : location_catalog_entries_) { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 263 | dex_register_location_catalog.SetRegisterInfo(location_catalog_offset, dex_register_location); |
| 264 | location_catalog_offset += DexRegisterLocationCatalog::EntrySize(dex_register_location); |
| 265 | } |
| 266 | // Ensure we reached the end of the Dex registers location_catalog. |
| 267 | DCHECK_EQ(location_catalog_offset, dex_register_location_catalog_region.size()); |
| 268 | |
Vladimir Marko | f6a35de | 2016-03-21 12:01:50 +0000 | [diff] [blame] | 269 | ArenaBitVector empty_bitmask(allocator_, 0, /* expandable */ false, kArenaAllocStackMapStream); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 270 | uintptr_t next_dex_register_map_offset = 0; |
| 271 | uintptr_t next_inline_info_offset = 0; |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 272 | for (size_t i = 0, e = stack_maps_.size(); i < e; ++i) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 273 | StackMap stack_map = code_info.GetStackMapAt(i, encoding); |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 274 | StackMapEntry entry = stack_maps_[i]; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 275 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 276 | stack_map.SetDexPc(stack_map_encoding_, entry.dex_pc); |
| 277 | stack_map.SetNativePcOffset(stack_map_encoding_, entry.native_pc_offset); |
| 278 | stack_map.SetRegisterMask(stack_map_encoding_, entry.register_mask); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 279 | size_t number_of_stack_mask_bits = stack_map.GetNumberOfStackMaskBits(stack_map_encoding_); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 280 | if (entry.sp_mask != nullptr) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 281 | for (size_t bit = 0; bit < number_of_stack_mask_bits; bit++) { |
| 282 | stack_map.SetStackMaskBit(stack_map_encoding_, bit, entry.sp_mask->IsBitSet(bit)); |
| 283 | } |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 284 | } else { |
| 285 | // The MemoryRegion does not have to be zeroed, so make sure we clear the bits. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 286 | for (size_t bit = 0; bit < number_of_stack_mask_bits; bit++) { |
| 287 | stack_map.SetStackMaskBit(stack_map_encoding_, bit, false); |
| 288 | } |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 289 | } |
| 290 | |
Nicolas Geoffray | 012fc4e | 2016-01-08 15:58:19 +0000 | [diff] [blame] | 291 | if (entry.num_dex_registers == 0 || (entry.live_dex_registers_mask->NumSetBits() == 0)) { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 292 | // No dex map available. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 293 | stack_map.SetDexRegisterMapOffset(stack_map_encoding_, StackMap::kNoDexRegisterMap); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 294 | } else { |
| 295 | // Search for an entry with the same dex map. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 296 | if (entry.same_dex_register_map_as_ != kNoSameDexMapFound) { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 297 | // If we have a hit reuse the offset. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 298 | stack_map.SetDexRegisterMapOffset( |
| 299 | stack_map_encoding_, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 300 | code_info.GetStackMapAt(entry.same_dex_register_map_as_, encoding) |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 301 | .GetDexRegisterMapOffset(stack_map_encoding_)); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 302 | } else { |
| 303 | // New dex registers maps should be added to the stack map. |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 304 | MemoryRegion register_region = dex_register_locations_region.Subregion( |
| 305 | next_dex_register_map_offset, |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 306 | ComputeDexRegisterMapSize(entry.num_dex_registers, entry.live_dex_registers_mask)); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 307 | next_dex_register_map_offset += register_region.size(); |
| 308 | DexRegisterMap dex_register_map(register_region); |
| 309 | stack_map.SetDexRegisterMapOffset( |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 310 | stack_map_encoding_, register_region.start() - dex_register_locations_region.start()); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 311 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 312 | // Set the dex register location. |
| 313 | FillInDexRegisterMap(dex_register_map, |
| 314 | entry.num_dex_registers, |
| 315 | *entry.live_dex_registers_mask, |
| 316 | entry.dex_register_locations_start_index); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 317 | } |
| 318 | } |
| 319 | |
| 320 | // Set the inlining info. |
| 321 | if (entry.inlining_depth != 0) { |
| 322 | MemoryRegion inline_region = inline_infos_region.Subregion( |
| 323 | next_inline_info_offset, |
| 324 | InlineInfo::kFixedSize + entry.inlining_depth * InlineInfo::SingleEntrySize()); |
| 325 | next_inline_info_offset += inline_region.size(); |
| 326 | InlineInfo inline_info(inline_region); |
| 327 | |
| 328 | // Currently relative to the dex register map. |
| 329 | stack_map.SetInlineDescriptorOffset( |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 330 | stack_map_encoding_, inline_region.start() - dex_register_locations_region.start()); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 331 | |
| 332 | inline_info.SetDepth(entry.inlining_depth); |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 333 | DCHECK_LE(entry.inline_infos_start_index + entry.inlining_depth, inline_infos_.size()); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 334 | for (size_t depth = 0; depth < entry.inlining_depth; ++depth) { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 335 | InlineInfoEntry inline_entry = inline_infos_[depth + entry.inline_infos_start_index]; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 336 | inline_info.SetMethodIndexAtDepth(depth, inline_entry.method_index); |
| 337 | inline_info.SetDexPcAtDepth(depth, inline_entry.dex_pc); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 338 | inline_info.SetInvokeTypeAtDepth(depth, inline_entry.invoke_type); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 339 | if (inline_entry.num_dex_registers == 0) { |
| 340 | // No dex map available. |
| 341 | inline_info.SetDexRegisterMapOffsetAtDepth(depth, StackMap::kNoDexRegisterMap); |
| 342 | DCHECK(inline_entry.live_dex_registers_mask == nullptr); |
| 343 | } else { |
| 344 | MemoryRegion register_region = dex_register_locations_region.Subregion( |
| 345 | next_dex_register_map_offset, |
| 346 | ComputeDexRegisterMapSize(inline_entry.num_dex_registers, |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 347 | inline_entry.live_dex_registers_mask)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 348 | next_dex_register_map_offset += register_region.size(); |
| 349 | DexRegisterMap dex_register_map(register_region); |
| 350 | inline_info.SetDexRegisterMapOffsetAtDepth( |
| 351 | depth, register_region.start() - dex_register_locations_region.start()); |
| 352 | |
| 353 | FillInDexRegisterMap(dex_register_map, |
| 354 | inline_entry.num_dex_registers, |
| 355 | *inline_entry.live_dex_registers_mask, |
| 356 | inline_entry.dex_register_locations_start_index); |
| 357 | } |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 358 | } |
| 359 | } else { |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 360 | if (inline_info_size_ != 0) { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 361 | stack_map.SetInlineDescriptorOffset(stack_map_encoding_, StackMap::kNoInlineInfo); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 362 | } |
| 363 | } |
| 364 | } |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 365 | |
| 366 | // Verify all written data in debug build. |
| 367 | if (kIsDebugBuild) { |
| 368 | CheckCodeInfo(region); |
| 369 | } |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 370 | } |
| 371 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 372 | void StackMapStream::FillInDexRegisterMap(DexRegisterMap dex_register_map, |
| 373 | uint32_t num_dex_registers, |
| 374 | const BitVector& live_dex_registers_mask, |
| 375 | uint32_t start_index_in_dex_register_locations) const { |
| 376 | dex_register_map.SetLiveBitMask(num_dex_registers, live_dex_registers_mask); |
| 377 | // Set the dex register location mapping data. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 378 | size_t number_of_live_dex_registers = live_dex_registers_mask.NumSetBits(); |
| 379 | DCHECK_LE(number_of_live_dex_registers, dex_register_locations_.size()); |
| 380 | DCHECK_LE(start_index_in_dex_register_locations, |
| 381 | dex_register_locations_.size() - number_of_live_dex_registers); |
| 382 | for (size_t index_in_dex_register_locations = 0; |
| 383 | index_in_dex_register_locations != number_of_live_dex_registers; |
| 384 | ++index_in_dex_register_locations) { |
| 385 | size_t location_catalog_entry_index = dex_register_locations_[ |
| 386 | start_index_in_dex_register_locations + index_in_dex_register_locations]; |
| 387 | dex_register_map.SetLocationCatalogEntryIndex( |
| 388 | index_in_dex_register_locations, |
| 389 | location_catalog_entry_index, |
| 390 | num_dex_registers, |
| 391 | location_catalog_entries_.size()); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 392 | } |
| 393 | } |
| 394 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 395 | size_t StackMapStream::FindEntryWithTheSameDexMap() { |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 396 | size_t current_entry_index = stack_maps_.size(); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 397 | auto entries_it = dex_map_hash_to_stack_map_indices_.find(current_entry_.dex_register_map_hash); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 398 | if (entries_it == dex_map_hash_to_stack_map_indices_.end()) { |
| 399 | // We don't have a perfect hash functions so we need a list to collect all stack maps |
| 400 | // which might have the same dex register map. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 401 | ArenaVector<uint32_t> stack_map_indices(allocator_->Adapter(kArenaAllocStackMapStream)); |
| 402 | stack_map_indices.push_back(current_entry_index); |
| 403 | dex_map_hash_to_stack_map_indices_.Put(current_entry_.dex_register_map_hash, |
| 404 | std::move(stack_map_indices)); |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 405 | return kNoSameDexMapFound; |
| 406 | } |
| 407 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 408 | // We might have collisions, so we need to check whether or not we really have a match. |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 409 | for (uint32_t test_entry_index : entries_it->second) { |
| 410 | if (HaveTheSameDexMaps(GetStackMap(test_entry_index), current_entry_)) { |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 411 | return test_entry_index; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 412 | } |
| 413 | } |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 414 | entries_it->second.push_back(current_entry_index); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 415 | return kNoSameDexMapFound; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 416 | } |
| 417 | |
| 418 | bool StackMapStream::HaveTheSameDexMaps(const StackMapEntry& a, const StackMapEntry& b) const { |
| 419 | if (a.live_dex_registers_mask == nullptr && b.live_dex_registers_mask == nullptr) { |
| 420 | return true; |
| 421 | } |
| 422 | if (a.live_dex_registers_mask == nullptr || b.live_dex_registers_mask == nullptr) { |
| 423 | return false; |
| 424 | } |
| 425 | if (a.num_dex_registers != b.num_dex_registers) { |
| 426 | return false; |
| 427 | } |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 428 | if (a.num_dex_registers != 0u) { |
| 429 | DCHECK(a.live_dex_registers_mask != nullptr); |
| 430 | DCHECK(b.live_dex_registers_mask != nullptr); |
| 431 | if (!a.live_dex_registers_mask->Equal(b.live_dex_registers_mask)) { |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 432 | return false; |
| 433 | } |
Vladimir Marko | 225b646 | 2015-09-28 12:17:40 +0100 | [diff] [blame] | 434 | size_t number_of_live_dex_registers = a.live_dex_registers_mask->NumSetBits(); |
| 435 | DCHECK_LE(number_of_live_dex_registers, dex_register_locations_.size()); |
| 436 | DCHECK_LE(a.dex_register_locations_start_index, |
| 437 | dex_register_locations_.size() - number_of_live_dex_registers); |
| 438 | DCHECK_LE(b.dex_register_locations_start_index, |
| 439 | dex_register_locations_.size() - number_of_live_dex_registers); |
| 440 | auto a_begin = dex_register_locations_.begin() + a.dex_register_locations_start_index; |
| 441 | auto b_begin = dex_register_locations_.begin() + b.dex_register_locations_start_index; |
| 442 | if (!std::equal(a_begin, a_begin + number_of_live_dex_registers, b_begin)) { |
| 443 | return false; |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 444 | } |
| 445 | } |
| 446 | return true; |
| 447 | } |
| 448 | |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 449 | // Helper for CheckCodeInfo - check that register map has the expected content. |
| 450 | void StackMapStream::CheckDexRegisterMap(const CodeInfo& code_info, |
| 451 | const DexRegisterMap& dex_register_map, |
| 452 | size_t num_dex_registers, |
| 453 | BitVector* live_dex_registers_mask, |
| 454 | size_t dex_register_locations_index) const { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 455 | CodeInfoEncoding encoding = code_info.ExtractEncoding(); |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 456 | for (size_t reg = 0; reg < num_dex_registers; reg++) { |
| 457 | // Find the location we tried to encode. |
| 458 | DexRegisterLocation expected = DexRegisterLocation::None(); |
| 459 | if (live_dex_registers_mask->IsBitSet(reg)) { |
| 460 | size_t catalog_index = dex_register_locations_[dex_register_locations_index++]; |
| 461 | expected = location_catalog_entries_[catalog_index]; |
| 462 | } |
| 463 | // Compare to the seen location. |
| 464 | if (expected.GetKind() == DexRegisterLocation::Kind::kNone) { |
| 465 | DCHECK(!dex_register_map.IsValid() || !dex_register_map.IsDexRegisterLive(reg)); |
| 466 | } else { |
| 467 | DCHECK(dex_register_map.IsDexRegisterLive(reg)); |
| 468 | DexRegisterLocation seen = dex_register_map.GetDexRegisterLocation( |
| 469 | reg, num_dex_registers, code_info, encoding); |
| 470 | DCHECK_EQ(expected.GetKind(), seen.GetKind()); |
| 471 | DCHECK_EQ(expected.GetValue(), seen.GetValue()); |
| 472 | } |
| 473 | } |
| 474 | if (num_dex_registers == 0) { |
| 475 | DCHECK(!dex_register_map.IsValid()); |
| 476 | } |
| 477 | } |
| 478 | |
| 479 | // Check that all StackMapStream inputs are correctly encoded by trying to read them back. |
| 480 | void StackMapStream::CheckCodeInfo(MemoryRegion region) const { |
| 481 | CodeInfo code_info(region); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 482 | CodeInfoEncoding encoding = code_info.ExtractEncoding(); |
| 483 | DCHECK_EQ(code_info.GetNumberOfStackMaps(encoding), stack_maps_.size()); |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 484 | for (size_t s = 0; s < stack_maps_.size(); ++s) { |
| 485 | const StackMap stack_map = code_info.GetStackMapAt(s, encoding); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 486 | const StackMapEncoding& stack_map_encoding = encoding.stack_map_encoding; |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 487 | StackMapEntry entry = stack_maps_[s]; |
| 488 | |
| 489 | // Check main stack map fields. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 490 | DCHECK_EQ(stack_map.GetNativePcOffset(stack_map_encoding), entry.native_pc_offset); |
| 491 | DCHECK_EQ(stack_map.GetDexPc(stack_map_encoding), entry.dex_pc); |
| 492 | DCHECK_EQ(stack_map.GetRegisterMask(stack_map_encoding), entry.register_mask); |
| 493 | size_t num_stack_mask_bits = stack_map.GetNumberOfStackMaskBits(stack_map_encoding); |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 494 | if (entry.sp_mask != nullptr) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 495 | DCHECK_GE(num_stack_mask_bits, entry.sp_mask->GetNumberOfBits()); |
| 496 | for (size_t b = 0; b < num_stack_mask_bits; b++) { |
| 497 | DCHECK_EQ(stack_map.GetStackMaskBit(stack_map_encoding, b), entry.sp_mask->IsBitSet(b)); |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 498 | } |
| 499 | } else { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 500 | for (size_t b = 0; b < num_stack_mask_bits; b++) { |
| 501 | DCHECK_EQ(stack_map.GetStackMaskBit(stack_map_encoding, b), 0u); |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 502 | } |
| 503 | } |
| 504 | |
| 505 | CheckDexRegisterMap(code_info, |
| 506 | code_info.GetDexRegisterMapOf( |
| 507 | stack_map, encoding, entry.num_dex_registers), |
| 508 | entry.num_dex_registers, |
| 509 | entry.live_dex_registers_mask, |
| 510 | entry.dex_register_locations_start_index); |
| 511 | |
| 512 | // Check inline info. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 513 | DCHECK_EQ(stack_map.HasInlineInfo(stack_map_encoding), (entry.inlining_depth != 0)); |
David Srbecky | 1bbdfd7 | 2016-02-24 16:39:26 +0000 | [diff] [blame] | 514 | if (entry.inlining_depth != 0) { |
| 515 | InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map, encoding); |
| 516 | DCHECK_EQ(inline_info.GetDepth(), entry.inlining_depth); |
| 517 | for (size_t d = 0; d < entry.inlining_depth; ++d) { |
| 518 | size_t inline_info_index = entry.inline_infos_start_index + d; |
| 519 | DCHECK_LT(inline_info_index, inline_infos_.size()); |
| 520 | InlineInfoEntry inline_entry = inline_infos_[inline_info_index]; |
| 521 | DCHECK_EQ(inline_info.GetDexPcAtDepth(d), inline_entry.dex_pc); |
| 522 | DCHECK_EQ(inline_info.GetMethodIndexAtDepth(d), inline_entry.method_index); |
| 523 | DCHECK_EQ(inline_info.GetInvokeTypeAtDepth(d), inline_entry.invoke_type); |
| 524 | |
| 525 | CheckDexRegisterMap(code_info, |
| 526 | code_info.GetDexRegisterMapAtDepth( |
| 527 | d, inline_info, encoding, inline_entry.num_dex_registers), |
| 528 | inline_entry.num_dex_registers, |
| 529 | inline_entry.live_dex_registers_mask, |
| 530 | inline_entry.dex_register_locations_start_index); |
| 531 | } |
| 532 | } |
| 533 | } |
| 534 | } |
| 535 | |
Calin Juravle | c416d33 | 2015-04-23 16:01:43 +0100 | [diff] [blame] | 536 | } // namespace art |