blob: 89035a36833a440ccac0b31741a19ead96f22b5f [file] [log] [blame]
Calin Juravlec416d332015-04-23 16:01:43 +01001/*
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 Juravlec416d332015-04-23 16:01:43 +010016#include "stack_map_stream.h"
17
18namespace art {
19
Calin Juravle4f46ac52015-04-23 18:47:21 +010020void 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";
27 current_entry_.dex_pc = dex_pc;
28 current_entry_.native_pc_offset = native_pc_offset;
29 current_entry_.register_mask = register_mask;
30 current_entry_.sp_mask = sp_mask;
31 current_entry_.num_dex_registers = num_dex_registers;
32 current_entry_.inlining_depth = inlining_depth;
33 current_entry_.dex_register_locations_start_index = dex_register_locations_.Size();
34 current_entry_.inline_infos_start_index = inline_infos_.Size();
35 current_entry_.dex_register_map_hash = 0;
36 current_entry_.same_dex_register_map_as_ = kNoSameDexMapFound;
Calin Juravlec416d332015-04-23 16:01:43 +010037 if (num_dex_registers != 0) {
Calin Juravle4f46ac52015-04-23 18:47:21 +010038 current_entry_.live_dex_registers_mask =
Calin Juravlec416d332015-04-23 16:01:43 +010039 new (allocator_) ArenaBitVector(allocator_, num_dex_registers, true);
40 } else {
Calin Juravle4f46ac52015-04-23 18:47:21 +010041 current_entry_.live_dex_registers_mask = nullptr;
Calin Juravlec416d332015-04-23 16:01:43 +010042 }
Calin Juravlec416d332015-04-23 16:01:43 +010043
44 if (sp_mask != nullptr) {
45 stack_mask_max_ = std::max(stack_mask_max_, sp_mask->GetHighestBitSet());
46 }
47 if (inlining_depth > 0) {
48 number_of_stack_maps_with_inline_info_++;
49 }
50
51 dex_pc_max_ = std::max(dex_pc_max_, dex_pc);
52 native_pc_offset_max_ = std::max(native_pc_offset_max_, native_pc_offset);
53 register_mask_max_ = std::max(register_mask_max_, register_mask);
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +010054 current_dex_register_ = 0;
Calin Juravlec416d332015-04-23 16:01:43 +010055}
56
Calin Juravle4f46ac52015-04-23 18:47:21 +010057void StackMapStream::EndStackMapEntry() {
58 current_entry_.same_dex_register_map_as_ = FindEntryWithTheSameDexMap();
59 stack_maps_.Add(current_entry_);
60 current_entry_ = StackMapEntry();
61}
62
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +010063void StackMapStream::AddDexRegisterEntry(DexRegisterLocation::Kind kind, int32_t value) {
Calin Juravlec416d332015-04-23 16:01:43 +010064 if (kind != DexRegisterLocation::Kind::kNone) {
65 // Ensure we only use non-compressed location kind at this stage.
66 DCHECK(DexRegisterLocation::IsShortLocationKind(kind))
67 << DexRegisterLocation::PrettyDescriptor(kind);
68 DexRegisterLocation location(kind, value);
69
70 // Look for Dex register `location` in the location catalog (using the
71 // companion hash map of locations to indices). Use its index if it
72 // is already in the location catalog. If not, insert it (in the
73 // location catalog and the hash map) and use the newly created index.
74 auto it = location_catalog_entries_indices_.Find(location);
75 if (it != location_catalog_entries_indices_.end()) {
76 // Retrieve the index from the hash map.
77 dex_register_locations_.Add(it->second);
78 } else {
79 // Create a new entry in the location catalog and the hash map.
80 size_t index = location_catalog_entries_.Size();
81 location_catalog_entries_.Add(location);
82 dex_register_locations_.Add(index);
83 location_catalog_entries_indices_.Insert(std::make_pair(location, index));
84 }
85
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +010086 if (in_inline_frame_) {
87 // TODO: Support sharing DexRegisterMap across InlineInfo.
88 DCHECK_LT(current_dex_register_, current_inline_info_.num_dex_registers);
89 current_inline_info_.live_dex_registers_mask->SetBit(current_dex_register_);
90 } else {
91 DCHECK_LT(current_dex_register_, current_entry_.num_dex_registers);
92 current_entry_.live_dex_registers_mask->SetBit(current_dex_register_);
93 current_entry_.dex_register_map_hash += (1 <<
94 (current_dex_register_ % (sizeof(current_entry_.dex_register_map_hash) * kBitsPerByte)));
95 current_entry_.dex_register_map_hash += static_cast<uint32_t>(value);
96 current_entry_.dex_register_map_hash += static_cast<uint32_t>(kind);
97 }
Calin Juravlec416d332015-04-23 16:01:43 +010098 }
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +010099 current_dex_register_++;
Calin Juravlec416d332015-04-23 16:01:43 +0100100}
101
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100102void StackMapStream::BeginInlineInfoEntry(uint32_t method_index,
103 uint32_t dex_pc,
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;
109 current_inline_info_.num_dex_registers = num_dex_registers;
110 current_inline_info_.dex_register_locations_start_index = dex_register_locations_.Size();
111 if (num_dex_registers != 0) {
112 current_inline_info_.live_dex_registers_mask =
113 new (allocator_) ArenaBitVector(allocator_, num_dex_registers, true);
114 } else {
115 current_inline_info_.live_dex_registers_mask = nullptr;
116 }
117 current_dex_register_ = 0;
118}
119
120void StackMapStream::EndInlineInfoEntry() {
121 DCHECK(in_inline_frame_);
122 DCHECK_EQ(current_dex_register_, current_inline_info_.num_dex_registers)
123 << "Inline information contains less registers than expected";
124 in_inline_frame_ = false;
125 inline_infos_.Add(current_inline_info_);
126 current_inline_info_ = InlineInfoEntry();
Calin Juravlec416d332015-04-23 16:01:43 +0100127}
128
Calin Juravle4f46ac52015-04-23 18:47:21 +0100129size_t StackMapStream::PrepareForFillIn() {
130 int stack_mask_number_of_bits = stack_mask_max_ + 1; // Need room for max element too.
131 stack_mask_size_ = RoundUp(stack_mask_number_of_bits, kBitsPerByte) / kBitsPerByte;
132 inline_info_size_ = ComputeInlineInfoSize();
133 dex_register_maps_size_ = ComputeDexRegisterMapsSize();
134 stack_maps_size_ = stack_maps_.Size()
135 * StackMap::ComputeStackMapSize(stack_mask_size_,
136 inline_info_size_,
137 dex_register_maps_size_,
138 dex_pc_max_,
139 native_pc_offset_max_,
140 register_mask_max_);
141 dex_register_location_catalog_size_ = ComputeDexRegisterLocationCatalogSize();
142
Calin Juravlec416d332015-04-23 16:01:43 +0100143 // Note: use RoundUp to word-size here if you want CodeInfo objects to be word aligned.
Calin Juravle4f46ac52015-04-23 18:47:21 +0100144 needed_size_ = CodeInfo::kFixedSize
145 + dex_register_location_catalog_size_
146 + stack_maps_size_
147 + dex_register_maps_size_
148 + inline_info_size_;
Calin Juravlec416d332015-04-23 16:01:43 +0100149
Calin Juravle4f46ac52015-04-23 18:47:21 +0100150 dex_register_location_catalog_start_ = CodeInfo::kFixedSize;
151 stack_maps_start_ = dex_register_location_catalog_start_ + dex_register_location_catalog_size_;
152 dex_register_maps_start_ = stack_maps_start_ + stack_maps_size_;
153 inline_infos_start_ = dex_register_maps_start_ + dex_register_maps_size_;
Calin Juravlec416d332015-04-23 16:01:43 +0100154
Calin Juravle4f46ac52015-04-23 18:47:21 +0100155 return needed_size_;
Calin Juravlec416d332015-04-23 16:01:43 +0100156}
157
158size_t StackMapStream::ComputeDexRegisterLocationCatalogSize() const {
159 size_t size = DexRegisterLocationCatalog::kFixedSize;
160 for (size_t location_catalog_entry_index = 0;
161 location_catalog_entry_index < location_catalog_entries_.Size();
162 ++location_catalog_entry_index) {
163 DexRegisterLocation dex_register_location =
164 location_catalog_entries_.Get(location_catalog_entry_index);
165 size += DexRegisterLocationCatalog::EntrySize(dex_register_location);
166 }
167 return size;
168}
169
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100170size_t StackMapStream::ComputeDexRegisterMapSize(uint32_t num_dex_registers,
171 const BitVector& live_dex_registers_mask) const {
Calin Juravlec416d332015-04-23 16:01:43 +0100172 // Size of the map in bytes.
173 size_t size = DexRegisterMap::kFixedSize;
174 // Add the live bit mask for the Dex register liveness.
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100175 size += DexRegisterMap::GetLiveBitMaskSize(num_dex_registers);
Calin Juravlec416d332015-04-23 16:01:43 +0100176 // Compute the size of the set of live Dex register entries.
177 size_t number_of_live_dex_registers = 0;
178 for (size_t dex_register_number = 0;
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100179 dex_register_number < num_dex_registers;
Calin Juravlec416d332015-04-23 16:01:43 +0100180 ++dex_register_number) {
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100181 if (live_dex_registers_mask.IsBitSet(dex_register_number)) {
Calin Juravlec416d332015-04-23 16:01:43 +0100182 ++number_of_live_dex_registers;
183 }
184 }
185 size_t map_entries_size_in_bits =
186 DexRegisterMap::SingleEntrySizeInBits(location_catalog_entries_.Size())
187 * number_of_live_dex_registers;
188 size_t map_entries_size_in_bytes =
189 RoundUp(map_entries_size_in_bits, kBitsPerByte) / kBitsPerByte;
190 size += map_entries_size_in_bytes;
191 return size;
192}
193
Calin Juravle4f46ac52015-04-23 18:47:21 +0100194size_t StackMapStream::ComputeDexRegisterMapsSize() const {
Calin Juravlec416d332015-04-23 16:01:43 +0100195 size_t size = 0;
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100196 size_t inline_info_index = 0;
Calin Juravlec416d332015-04-23 16:01:43 +0100197 for (size_t i = 0; i < stack_maps_.Size(); ++i) {
Calin Juravle4f46ac52015-04-23 18:47:21 +0100198 StackMapEntry entry = stack_maps_.Get(i);
199 if (entry.same_dex_register_map_as_ == kNoSameDexMapFound) {
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100200 size += ComputeDexRegisterMapSize(entry.num_dex_registers, *entry.live_dex_registers_mask);
201 } else {
Calin Juravlec416d332015-04-23 16:01:43 +0100202 // Entries with the same dex map will have the same offset.
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100203 }
204 for (size_t j = 0; j < entry.inlining_depth; ++j) {
205 InlineInfoEntry inline_entry = inline_infos_.Get(inline_info_index++);
206 size += ComputeDexRegisterMapSize(inline_entry.num_dex_registers,
207 *inline_entry.live_dex_registers_mask);
Calin Juravlec416d332015-04-23 16:01:43 +0100208 }
209 }
210 return size;
211}
212
213size_t StackMapStream::ComputeInlineInfoSize() const {
214 return inline_infos_.Size() * InlineInfo::SingleEntrySize()
215 // For encoding the depth.
216 + (number_of_stack_maps_with_inline_info_ * InlineInfo::kFixedSize);
217}
218
Calin Juravlec416d332015-04-23 16:01:43 +0100219void StackMapStream::FillIn(MemoryRegion region) {
Calin Juravle4f46ac52015-04-23 18:47:21 +0100220 DCHECK_EQ(0u, current_entry_.dex_pc) << "EndStackMapEntry not called after BeginStackMapEntry";
221 DCHECK_NE(0u, needed_size_) << "PrepareForFillIn not called before FillIn";
222
Calin Juravlec416d332015-04-23 16:01:43 +0100223 CodeInfo code_info(region);
Calin Juravle4f46ac52015-04-23 18:47:21 +0100224 DCHECK_EQ(region.size(), needed_size_);
Calin Juravlec416d332015-04-23 16:01:43 +0100225 code_info.SetOverallSize(region.size());
226
Calin Juravlec416d332015-04-23 16:01:43 +0100227 MemoryRegion dex_register_locations_region = region.Subregion(
Calin Juravle4f46ac52015-04-23 18:47:21 +0100228 dex_register_maps_start_, dex_register_maps_size_);
Calin Juravlec416d332015-04-23 16:01:43 +0100229
230 MemoryRegion inline_infos_region = region.Subregion(
Calin Juravle4f46ac52015-04-23 18:47:21 +0100231 inline_infos_start_, inline_info_size_);
Calin Juravlec416d332015-04-23 16:01:43 +0100232
Calin Juravle4f46ac52015-04-23 18:47:21 +0100233 code_info.SetEncoding(inline_info_size_,
234 dex_register_maps_size_,
Calin Juravlec416d332015-04-23 16:01:43 +0100235 dex_pc_max_,
236 native_pc_offset_max_,
237 register_mask_max_);
238 code_info.SetNumberOfStackMaps(stack_maps_.Size());
Calin Juravle4f46ac52015-04-23 18:47:21 +0100239 code_info.SetStackMaskSize(stack_mask_size_);
240 DCHECK_EQ(code_info.GetStackMapsSize(), stack_maps_size_);
Calin Juravlec416d332015-04-23 16:01:43 +0100241
242 // Set the Dex register location catalog.
Calin Juravle4f46ac52015-04-23 18:47:21 +0100243 code_info.SetNumberOfDexRegisterLocationCatalogEntries(location_catalog_entries_.Size());
Calin Juravlec416d332015-04-23 16:01:43 +0100244 MemoryRegion dex_register_location_catalog_region = region.Subregion(
Calin Juravle4f46ac52015-04-23 18:47:21 +0100245 dex_register_location_catalog_start_, dex_register_location_catalog_size_);
Calin Juravlec416d332015-04-23 16:01:43 +0100246 DexRegisterLocationCatalog dex_register_location_catalog(dex_register_location_catalog_region);
247 // Offset in `dex_register_location_catalog` where to store the next
248 // register location.
249 size_t location_catalog_offset = DexRegisterLocationCatalog::kFixedSize;
250 for (size_t i = 0, e = location_catalog_entries_.Size(); i < e; ++i) {
251 DexRegisterLocation dex_register_location = location_catalog_entries_.Get(i);
252 dex_register_location_catalog.SetRegisterInfo(location_catalog_offset, dex_register_location);
253 location_catalog_offset += DexRegisterLocationCatalog::EntrySize(dex_register_location);
254 }
255 // Ensure we reached the end of the Dex registers location_catalog.
256 DCHECK_EQ(location_catalog_offset, dex_register_location_catalog_region.size());
257
258 uintptr_t next_dex_register_map_offset = 0;
259 uintptr_t next_inline_info_offset = 0;
260 for (size_t i = 0, e = stack_maps_.Size(); i < e; ++i) {
261 StackMap stack_map = code_info.GetStackMapAt(i);
262 StackMapEntry entry = stack_maps_.Get(i);
263
264 stack_map.SetDexPc(code_info, entry.dex_pc);
265 stack_map.SetNativePcOffset(code_info, entry.native_pc_offset);
266 stack_map.SetRegisterMask(code_info, entry.register_mask);
267 if (entry.sp_mask != nullptr) {
268 stack_map.SetStackMask(code_info, *entry.sp_mask);
269 }
270
271 if (entry.num_dex_registers == 0) {
272 // No dex map available.
273 stack_map.SetDexRegisterMapOffset(code_info, StackMap::kNoDexRegisterMap);
274 } else {
275 // Search for an entry with the same dex map.
Calin Juravle4f46ac52015-04-23 18:47:21 +0100276 if (entry.same_dex_register_map_as_ != kNoSameDexMapFound) {
Calin Juravlec416d332015-04-23 16:01:43 +0100277 // If we have a hit reuse the offset.
278 stack_map.SetDexRegisterMapOffset(code_info,
Calin Juravle4f46ac52015-04-23 18:47:21 +0100279 code_info.GetStackMapAt(entry.same_dex_register_map_as_)
280 .GetDexRegisterMapOffset(code_info));
Calin Juravlec416d332015-04-23 16:01:43 +0100281 } else {
282 // New dex registers maps should be added to the stack map.
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100283 MemoryRegion register_region = dex_register_locations_region.Subregion(
284 next_dex_register_map_offset,
285 ComputeDexRegisterMapSize(entry.num_dex_registers, *entry.live_dex_registers_mask));
Calin Juravlec416d332015-04-23 16:01:43 +0100286 next_dex_register_map_offset += register_region.size();
287 DexRegisterMap dex_register_map(register_region);
288 stack_map.SetDexRegisterMapOffset(
289 code_info, register_region.start() - dex_register_locations_region.start());
290
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100291 // Set the dex register location.
292 FillInDexRegisterMap(dex_register_map,
293 entry.num_dex_registers,
294 *entry.live_dex_registers_mask,
295 entry.dex_register_locations_start_index);
Calin Juravlec416d332015-04-23 16:01:43 +0100296 }
297 }
298
299 // Set the inlining info.
300 if (entry.inlining_depth != 0) {
301 MemoryRegion inline_region = inline_infos_region.Subregion(
302 next_inline_info_offset,
303 InlineInfo::kFixedSize + entry.inlining_depth * InlineInfo::SingleEntrySize());
304 next_inline_info_offset += inline_region.size();
305 InlineInfo inline_info(inline_region);
306
307 // Currently relative to the dex register map.
308 stack_map.SetInlineDescriptorOffset(
309 code_info, inline_region.start() - dex_register_locations_region.start());
310
311 inline_info.SetDepth(entry.inlining_depth);
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100312 for (size_t depth = 0; depth < entry.inlining_depth; ++depth) {
313 InlineInfoEntry inline_entry = inline_infos_.Get(depth + entry.inline_infos_start_index);
314 inline_info.SetMethodIndexAtDepth(depth, inline_entry.method_index);
315 inline_info.SetDexPcAtDepth(depth, inline_entry.dex_pc);
316 if (inline_entry.num_dex_registers == 0) {
317 // No dex map available.
318 inline_info.SetDexRegisterMapOffsetAtDepth(depth, StackMap::kNoDexRegisterMap);
319 DCHECK(inline_entry.live_dex_registers_mask == nullptr);
320 } else {
321 MemoryRegion register_region = dex_register_locations_region.Subregion(
322 next_dex_register_map_offset,
323 ComputeDexRegisterMapSize(inline_entry.num_dex_registers,
324 *inline_entry.live_dex_registers_mask));
325 next_dex_register_map_offset += register_region.size();
326 DexRegisterMap dex_register_map(register_region);
327 inline_info.SetDexRegisterMapOffsetAtDepth(
328 depth, register_region.start() - dex_register_locations_region.start());
329
330 FillInDexRegisterMap(dex_register_map,
331 inline_entry.num_dex_registers,
332 *inline_entry.live_dex_registers_mask,
333 inline_entry.dex_register_locations_start_index);
334 }
Calin Juravlec416d332015-04-23 16:01:43 +0100335 }
336 } else {
Calin Juravle4f46ac52015-04-23 18:47:21 +0100337 if (inline_info_size_ != 0) {
Calin Juravlec416d332015-04-23 16:01:43 +0100338 stack_map.SetInlineDescriptorOffset(code_info, StackMap::kNoInlineInfo);
339 }
340 }
341 }
342}
343
Nicolas Geoffrayb1d0f3f2015-05-14 12:41:51 +0100344void StackMapStream::FillInDexRegisterMap(DexRegisterMap dex_register_map,
345 uint32_t num_dex_registers,
346 const BitVector& live_dex_registers_mask,
347 uint32_t start_index_in_dex_register_locations) const {
348 dex_register_map.SetLiveBitMask(num_dex_registers, live_dex_registers_mask);
349 // Set the dex register location mapping data.
350 for (size_t dex_register_number = 0, index_in_dex_register_locations = 0;
351 dex_register_number < num_dex_registers;
352 ++dex_register_number) {
353 if (live_dex_registers_mask.IsBitSet(dex_register_number)) {
354 size_t location_catalog_entry_index = dex_register_locations_.Get(
355 start_index_in_dex_register_locations + index_in_dex_register_locations);
356 dex_register_map.SetLocationCatalogEntryIndex(
357 index_in_dex_register_locations,
358 location_catalog_entry_index,
359 num_dex_registers,
360 location_catalog_entries_.Size());
361 ++index_in_dex_register_locations;
362 }
363 }
364}
365
Calin Juravle4f46ac52015-04-23 18:47:21 +0100366size_t StackMapStream::FindEntryWithTheSameDexMap() {
367 size_t current_entry_index = stack_maps_.Size();
368 auto entries_it = dex_map_hash_to_stack_map_indices_.find(current_entry_.dex_register_map_hash);
Calin Juravlec416d332015-04-23 16:01:43 +0100369 if (entries_it == dex_map_hash_to_stack_map_indices_.end()) {
370 // We don't have a perfect hash functions so we need a list to collect all stack maps
371 // which might have the same dex register map.
372 GrowableArray<uint32_t> stack_map_indices(allocator_, 1);
Calin Juravle4f46ac52015-04-23 18:47:21 +0100373 stack_map_indices.Add(current_entry_index);
374 dex_map_hash_to_stack_map_indices_.Put(current_entry_.dex_register_map_hash, stack_map_indices);
Calin Juravlec416d332015-04-23 16:01:43 +0100375 return kNoSameDexMapFound;
376 }
377
Calin Juravle4f46ac52015-04-23 18:47:21 +0100378 // We might have collisions, so we need to check whether or not we really have a match.
Calin Juravlec416d332015-04-23 16:01:43 +0100379 for (size_t i = 0; i < entries_it->second.Size(); i++) {
380 size_t test_entry_index = entries_it->second.Get(i);
Calin Juravle4f46ac52015-04-23 18:47:21 +0100381 if (HaveTheSameDexMaps(stack_maps_.Get(test_entry_index), current_entry_)) {
382 return test_entry_index;
Calin Juravlec416d332015-04-23 16:01:43 +0100383 }
384 }
Calin Juravle4f46ac52015-04-23 18:47:21 +0100385 entries_it->second.Add(current_entry_index);
386 return kNoSameDexMapFound;
Calin Juravlec416d332015-04-23 16:01:43 +0100387}
388
389bool StackMapStream::HaveTheSameDexMaps(const StackMapEntry& a, const StackMapEntry& b) const {
390 if (a.live_dex_registers_mask == nullptr && b.live_dex_registers_mask == nullptr) {
391 return true;
392 }
393 if (a.live_dex_registers_mask == nullptr || b.live_dex_registers_mask == nullptr) {
394 return false;
395 }
396 if (a.num_dex_registers != b.num_dex_registers) {
397 return false;
398 }
399
400 int index_in_dex_register_locations = 0;
401 for (uint32_t i = 0; i < a.num_dex_registers; i++) {
402 if (a.live_dex_registers_mask->IsBitSet(i) != b.live_dex_registers_mask->IsBitSet(i)) {
403 return false;
404 }
405 if (a.live_dex_registers_mask->IsBitSet(i)) {
406 size_t a_loc = dex_register_locations_.Get(
407 a.dex_register_locations_start_index + index_in_dex_register_locations);
408 size_t b_loc = dex_register_locations_.Get(
409 b.dex_register_locations_start_index + index_in_dex_register_locations);
410 if (a_loc != b_loc) {
411 return false;
412 }
413 ++index_in_dex_register_locations;
414 }
415 }
416 return true;
417}
418
419} // namespace art