Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2014 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 | #ifndef ART_COMPILER_OPTIMIZING_STACK_MAP_STREAM_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_STACK_MAP_STREAM_H_ |
| 19 | |
| 20 | #include "base/bit_vector.h" |
Ian Rogers | 0279ebb | 2014-10-08 17:27:48 -0700 | [diff] [blame] | 21 | #include "base/value_object.h" |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 22 | #include "memory_region.h" |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 23 | #include "nodes.h" |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 24 | #include "stack_map.h" |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 25 | #include "utils/growable_array.h" |
| 26 | |
| 27 | namespace art { |
| 28 | |
| 29 | /** |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 30 | * Collects and builds stack maps for a method. All the stack maps |
| 31 | * for a method are placed in a CodeInfo object. |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 32 | */ |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 33 | class StackMapStream : public ValueObject { |
| 34 | public: |
| 35 | explicit StackMapStream(ArenaAllocator* allocator) |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 36 | : allocator_(allocator), |
| 37 | stack_maps_(allocator, 10), |
| 38 | dex_register_locations_(allocator, 10 * 4), |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 39 | inline_infos_(allocator, 2), |
Andreas Gampe | 8eddd2a | 2014-07-28 14:53:22 -0700 | [diff] [blame] | 40 | stack_mask_max_(-1), |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 41 | dex_pc_max_(0), |
| 42 | native_pc_offset_max_(0), |
Andreas Gampe | 8eddd2a | 2014-07-28 14:53:22 -0700 | [diff] [blame] | 43 | number_of_stack_maps_with_inline_info_(0) {} |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 44 | |
| 45 | // Compute bytes needed to encode a mask with the given maximum element. |
| 46 | static uint32_t StackMaskEncodingSize(int max_element) { |
| 47 | int number_of_bits = max_element + 1; // Need room for max element too. |
| 48 | return RoundUp(number_of_bits, kBitsPerByte) / kBitsPerByte; |
| 49 | } |
| 50 | |
| 51 | // See runtime/stack_map.h to know what these fields contain. |
| 52 | struct StackMapEntry { |
| 53 | uint32_t dex_pc; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 54 | uint32_t native_pc_offset; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 55 | uint32_t register_mask; |
| 56 | BitVector* sp_mask; |
| 57 | uint32_t num_dex_registers; |
| 58 | uint8_t inlining_depth; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 59 | size_t dex_register_locations_start_index; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 60 | size_t inline_infos_start_index; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 61 | BitVector* live_dex_registers_mask; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 62 | }; |
| 63 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 64 | struct InlineInfoEntry { |
| 65 | uint32_t method_index; |
| 66 | }; |
| 67 | |
| 68 | void AddStackMapEntry(uint32_t dex_pc, |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 69 | uint32_t native_pc_offset, |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 70 | uint32_t register_mask, |
| 71 | BitVector* sp_mask, |
| 72 | uint32_t num_dex_registers, |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 73 | uint8_t inlining_depth) { |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 74 | StackMapEntry entry; |
| 75 | entry.dex_pc = dex_pc; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 76 | entry.native_pc_offset = native_pc_offset; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 77 | entry.register_mask = register_mask; |
| 78 | entry.sp_mask = sp_mask; |
| 79 | entry.num_dex_registers = num_dex_registers; |
| 80 | entry.inlining_depth = inlining_depth; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 81 | entry.dex_register_locations_start_index = dex_register_locations_.Size(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 82 | entry.inline_infos_start_index = inline_infos_.Size(); |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 83 | if (num_dex_registers != 0) { |
| 84 | entry.live_dex_registers_mask = |
| 85 | new (allocator_) ArenaBitVector(allocator_, num_dex_registers, true); |
| 86 | } else { |
| 87 | entry.live_dex_registers_mask = nullptr; |
| 88 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 89 | stack_maps_.Add(entry); |
| 90 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 91 | if (sp_mask != nullptr) { |
| 92 | stack_mask_max_ = std::max(stack_mask_max_, sp_mask->GetHighestBitSet()); |
| 93 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 94 | if (inlining_depth > 0) { |
| 95 | number_of_stack_maps_with_inline_info_++; |
| 96 | } |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 97 | |
| 98 | dex_pc_max_ = std::max(dex_pc_max_, dex_pc); |
| 99 | native_pc_offset_max_ = std::max(native_pc_offset_max_, native_pc_offset); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 100 | } |
| 101 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 102 | void AddInlineInfoEntry(uint32_t method_index) { |
| 103 | InlineInfoEntry entry; |
| 104 | entry.method_index = method_index; |
| 105 | inline_infos_.Add(entry); |
| 106 | } |
| 107 | |
| 108 | size_t ComputeNeededSize() const { |
Roland Levillain | ede7bf8 | 2015-03-13 12:23:04 +0000 | [diff] [blame] | 109 | size_t size = CodeInfo::kFixedSize |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 110 | + ComputeStackMapsSize() |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 111 | + ComputeDexRegisterMapsSize() |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 112 | + ComputeInlineInfoSize(); |
Nicolas Geoffray | aec8f93 | 2015-03-18 10:42:22 +0000 | [diff] [blame] | 113 | // Note: use RoundUp to word-size here if you want CodeInfo objects to be word aligned. |
| 114 | return size; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 115 | } |
| 116 | |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 117 | size_t ComputeStackMaskSize() const { |
| 118 | return StackMaskEncodingSize(stack_mask_max_); |
| 119 | } |
| 120 | |
| 121 | size_t ComputeStackMapsSize() const { |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 122 | return stack_maps_.Size() * StackMap::ComputeStackMapSize( |
| 123 | ComputeStackMaskSize(), |
| 124 | ComputeInlineInfoSize(), |
| 125 | ComputeDexRegisterMapsSize(), |
| 126 | dex_pc_max_, |
| 127 | native_pc_offset_max_); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 128 | } |
| 129 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 130 | // Compute the size of the Dex register map of `entry`. |
| 131 | size_t ComputeDexRegisterMapSize(const StackMapEntry& entry) const { |
| 132 | size_t size = DexRegisterMap::kFixedSize; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 133 | // Add the bit mask for the dex register liveness. |
| 134 | size += DexRegisterMap::LiveBitMaskSize(entry.num_dex_registers); |
| 135 | for (size_t dex_register_number = 0, index_in_dex_register_locations = 0; |
| 136 | dex_register_number < entry.num_dex_registers; |
| 137 | ++dex_register_number) { |
| 138 | if (entry.live_dex_registers_mask->IsBitSet(dex_register_number)) { |
| 139 | DexRegisterLocation dex_register_location = dex_register_locations_.Get( |
| 140 | entry.dex_register_locations_start_index + index_in_dex_register_locations); |
| 141 | size += DexRegisterMap::EntrySize(dex_register_location); |
| 142 | index_in_dex_register_locations++; |
| 143 | } |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 144 | } |
| 145 | return size; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 146 | } |
| 147 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 148 | // Compute the size of all the Dex register maps. |
| 149 | size_t ComputeDexRegisterMapsSize() const { |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 150 | size_t size = 0; |
| 151 | for (size_t i = 0; i < stack_maps_.Size(); ++i) { |
| 152 | size += ComputeDexRegisterMapSize(stack_maps_.Get(i)); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 153 | } |
Roland Levillain | ede7bf8 | 2015-03-13 12:23:04 +0000 | [diff] [blame] | 154 | return size; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 155 | } |
| 156 | |
| 157 | // Compute the size of all the inline information pieces. |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 158 | size_t ComputeInlineInfoSize() const { |
| 159 | return inline_infos_.Size() * InlineInfo::SingleEntrySize() |
| 160 | // For encoding the depth. |
| 161 | + (number_of_stack_maps_with_inline_info_ * InlineInfo::kFixedSize); |
| 162 | } |
| 163 | |
Roland Levillain | 9ac0e4d | 2015-03-12 18:33:05 +0000 | [diff] [blame] | 164 | size_t ComputeDexRegisterMapsStart() const { |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 165 | return CodeInfo::kFixedSize + ComputeStackMapsSize(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 166 | } |
| 167 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 168 | size_t ComputeInlineInfoStart() const { |
Roland Levillain | 9ac0e4d | 2015-03-12 18:33:05 +0000 | [diff] [blame] | 169 | return ComputeDexRegisterMapsStart() + ComputeDexRegisterMapsSize(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 170 | } |
| 171 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 172 | void FillIn(MemoryRegion region) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 173 | CodeInfo code_info(region); |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 174 | DCHECK_EQ(region.size(), ComputeNeededSize()); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 175 | code_info.SetOverallSize(region.size()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 176 | |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 177 | size_t stack_mask_size = ComputeStackMaskSize(); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 178 | |
| 179 | size_t dex_register_map_size = ComputeDexRegisterMapsSize(); |
| 180 | size_t inline_info_size = ComputeInlineInfoSize(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 181 | |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 182 | MemoryRegion dex_register_locations_region = region.Subregion( |
Roland Levillain | 9ac0e4d | 2015-03-12 18:33:05 +0000 | [diff] [blame] | 183 | ComputeDexRegisterMapsStart(), |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 184 | dex_register_map_size); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 185 | |
| 186 | MemoryRegion inline_infos_region = region.Subregion( |
| 187 | ComputeInlineInfoStart(), |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 188 | inline_info_size); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 189 | |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 190 | code_info.SetEncoding( |
| 191 | inline_info_size, dex_register_map_size, dex_pc_max_, native_pc_offset_max_); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 192 | code_info.SetNumberOfStackMaps(stack_maps_.Size()); |
| 193 | code_info.SetStackMaskSize(stack_mask_size); |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 194 | DCHECK_EQ(code_info.StackMapsSize(), ComputeStackMapsSize()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 195 | |
| 196 | uintptr_t next_dex_register_map_offset = 0; |
| 197 | uintptr_t next_inline_info_offset = 0; |
| 198 | for (size_t i = 0, e = stack_maps_.Size(); i < e; ++i) { |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 199 | StackMap stack_map = code_info.GetStackMapAt(i); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 200 | StackMapEntry entry = stack_maps_.Get(i); |
| 201 | |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 202 | stack_map.SetDexPc(code_info, entry.dex_pc); |
| 203 | stack_map.SetNativePcOffset(code_info, entry.native_pc_offset); |
| 204 | stack_map.SetRegisterMask(code_info, entry.register_mask); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 205 | if (entry.sp_mask != nullptr) { |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 206 | stack_map.SetStackMask(code_info, *entry.sp_mask); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 207 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 208 | |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 209 | if (entry.num_dex_registers != 0) { |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 210 | // Set the Dex register map. |
| 211 | MemoryRegion register_region = |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 212 | dex_register_locations_region.Subregion( |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 213 | next_dex_register_map_offset, |
| 214 | ComputeDexRegisterMapSize(entry)); |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 215 | next_dex_register_map_offset += register_region.size(); |
| 216 | DexRegisterMap dex_register_map(register_region); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 217 | stack_map.SetDexRegisterMapOffset( |
| 218 | code_info, register_region.start() - dex_register_locations_region.start()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 219 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 220 | // Offset in `dex_register_map` where to store the next register entry. |
| 221 | size_t offset = DexRegisterMap::kFixedSize; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 222 | dex_register_map.SetLiveBitMask(offset, |
| 223 | entry.num_dex_registers, |
| 224 | *entry.live_dex_registers_mask); |
| 225 | offset += DexRegisterMap::LiveBitMaskSize(entry.num_dex_registers); |
| 226 | for (size_t dex_register_number = 0, index_in_dex_register_locations = 0; |
| 227 | dex_register_number < entry.num_dex_registers; |
| 228 | ++dex_register_number) { |
| 229 | if (entry.live_dex_registers_mask->IsBitSet(dex_register_number)) { |
| 230 | DexRegisterLocation dex_register_location = dex_register_locations_.Get( |
| 231 | entry.dex_register_locations_start_index + index_in_dex_register_locations); |
| 232 | dex_register_map.SetRegisterInfo(offset, dex_register_location); |
| 233 | offset += DexRegisterMap::EntrySize(dex_register_location); |
| 234 | ++index_in_dex_register_locations; |
| 235 | } |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 236 | } |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 237 | // Ensure we reached the end of the Dex registers region. |
| 238 | DCHECK_EQ(offset, register_region.size()); |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 239 | } else { |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 240 | stack_map.SetDexRegisterMapOffset(code_info, StackMap::kNoDexRegisterMap); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 241 | } |
| 242 | |
| 243 | // Set the inlining info. |
| 244 | if (entry.inlining_depth != 0) { |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 245 | MemoryRegion inline_region = inline_infos_region.Subregion( |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 246 | next_inline_info_offset, |
| 247 | InlineInfo::kFixedSize + entry.inlining_depth * InlineInfo::SingleEntrySize()); |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 248 | next_inline_info_offset += inline_region.size(); |
| 249 | InlineInfo inline_info(inline_region); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 250 | |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 251 | // Currently relative to the dex register map. |
| 252 | stack_map.SetInlineDescriptorOffset( |
| 253 | code_info, inline_region.start() - dex_register_locations_region.start()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 254 | |
| 255 | inline_info.SetDepth(entry.inlining_depth); |
Andreas Gampe | 277ccbd | 2014-11-03 21:36:10 -0800 | [diff] [blame] | 256 | for (size_t j = 0; j < entry.inlining_depth; ++j) { |
| 257 | InlineInfoEntry inline_entry = inline_infos_.Get(j + entry.inline_infos_start_index); |
| 258 | inline_info.SetMethodReferenceIndexAtDepth(j, inline_entry.method_index); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 259 | } |
| 260 | } else { |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 261 | if (inline_info_size != 0) { |
| 262 | stack_map.SetInlineDescriptorOffset(code_info, StackMap::kNoInlineInfo); |
| 263 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 264 | } |
| 265 | } |
| 266 | } |
| 267 | |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 268 | void AddDexRegisterEntry(uint16_t dex_register, DexRegisterLocation::Kind kind, int32_t value) { |
| 269 | if (kind != DexRegisterLocation::Kind::kNone) { |
| 270 | // Ensure we only use non-compressed location kind at this stage. |
| 271 | DCHECK(DexRegisterLocation::IsShortLocationKind(kind)) |
| 272 | << DexRegisterLocation::PrettyDescriptor(kind); |
| 273 | dex_register_locations_.Add(DexRegisterLocation(kind, value)); |
| 274 | stack_maps_.Get(stack_maps_.Size() - 1).live_dex_registers_mask->SetBit(dex_register); |
| 275 | } |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 276 | } |
| 277 | |
Nicolas Geoffray | eeefa12 | 2015-03-13 18:52:59 +0000 | [diff] [blame] | 278 | private: |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 279 | ArenaAllocator* allocator_; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 280 | GrowableArray<StackMapEntry> stack_maps_; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 281 | GrowableArray<DexRegisterLocation> dex_register_locations_; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 282 | GrowableArray<InlineInfoEntry> inline_infos_; |
| 283 | int stack_mask_max_; |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame^] | 284 | uint32_t dex_pc_max_; |
| 285 | uint32_t native_pc_offset_max_; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 286 | size_t number_of_stack_maps_with_inline_info_; |
| 287 | |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 288 | ART_FRIEND_TEST(StackMapTest, Test1); |
| 289 | ART_FRIEND_TEST(StackMapTest, Test2); |
| 290 | ART_FRIEND_TEST(StackMapTest, TestNonLiveDexRegisters); |
| 291 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 292 | DISALLOW_COPY_AND_ASSIGN(StackMapStream); |
| 293 | }; |
| 294 | |
| 295 | } // namespace art |
| 296 | |
| 297 | #endif // ART_COMPILER_OPTIMIZING_STACK_MAP_STREAM_H_ |