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_RUNTIME_STACK_MAP_H_ |
| 18 | #define ART_RUNTIME_STACK_MAP_H_ |
| 19 | |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 20 | #include "arch/code_offset.h" |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 21 | #include "base/bit_vector.h" |
Vladimir Marko | 80afd02 | 2015-05-19 18:08:00 +0100 | [diff] [blame] | 22 | #include "base/bit_utils.h" |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 23 | #include "dex_file.h" |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 24 | #include "memory_region.h" |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 25 | #include "leb128.h" |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 26 | |
| 27 | namespace art { |
| 28 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 29 | class VariableIndentationOutputStream; |
| 30 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 31 | // Size of a frame slot, in bytes. This constant is a signed value, |
| 32 | // to please the compiler in arithmetic operations involving int32_t |
| 33 | // (signed) values. |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 34 | static constexpr ssize_t kFrameSlotSize = 4; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 35 | |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 36 | // Size of Dex virtual registers. |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 37 | static constexpr size_t kVRegSize = 4; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 38 | |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 39 | class ArtMethod; |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 40 | class CodeInfo; |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 41 | class StackMapEncoding; |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 42 | struct CodeInfoEncoding; |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 43 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 44 | /** |
| 45 | * Classes in the following file are wrapper on stack map information backed |
| 46 | * by a MemoryRegion. As such they read and write to the region, they don't have |
| 47 | * their own fields. |
| 48 | */ |
| 49 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 50 | // Dex register location container used by DexRegisterMap and StackMapStream. |
| 51 | class DexRegisterLocation { |
| 52 | public: |
| 53 | /* |
| 54 | * The location kind used to populate the Dex register information in a |
| 55 | * StackMapStream can either be: |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 56 | * - kStack: vreg stored on the stack, value holds the stack offset; |
| 57 | * - kInRegister: vreg stored in low 32 bits of a core physical register, |
| 58 | * value holds the register number; |
| 59 | * - kInRegisterHigh: vreg stored in high 32 bits of a core physical register, |
| 60 | * value holds the register number; |
| 61 | * - kInFpuRegister: vreg stored in low 32 bits of an FPU register, |
| 62 | * value holds the register number; |
| 63 | * - kInFpuRegisterHigh: vreg stored in high 32 bits of an FPU register, |
| 64 | * value holds the register number; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 65 | * - kConstant: value holds the constant; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 66 | * |
| 67 | * In addition, DexRegisterMap also uses these values: |
| 68 | * - kInStackLargeOffset: value holds a "large" stack offset (greater than |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 69 | * or equal to 128 bytes); |
| 70 | * - kConstantLargeValue: value holds a "large" constant (lower than 0, or |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 71 | * or greater than or equal to 32); |
| 72 | * - kNone: the register has no location, meaning it has not been set. |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 73 | */ |
| 74 | enum class Kind : uint8_t { |
| 75 | // Short location kinds, for entries fitting on one byte (3 bits |
| 76 | // for the kind, 5 bits for the value) in a DexRegisterMap. |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 77 | kInStack = 0, // 0b000 |
| 78 | kInRegister = 1, // 0b001 |
| 79 | kInRegisterHigh = 2, // 0b010 |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 80 | kInFpuRegister = 3, // 0b011 |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 81 | kInFpuRegisterHigh = 4, // 0b100 |
| 82 | kConstant = 5, // 0b101 |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 83 | |
| 84 | // Large location kinds, requiring a 5-byte encoding (1 byte for the |
| 85 | // kind, 4 bytes for the value). |
| 86 | |
| 87 | // Stack location at a large offset, meaning that the offset value |
| 88 | // divided by the stack frame slot size (4 bytes) cannot fit on a |
| 89 | // 5-bit unsigned integer (i.e., this offset value is greater than |
| 90 | // or equal to 2^5 * 4 = 128 bytes). |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 91 | kInStackLargeOffset = 6, // 0b110 |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 92 | |
| 93 | // Large constant, that cannot fit on a 5-bit signed integer (i.e., |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 94 | // lower than 0, or greater than or equal to 2^5 = 32). |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 95 | kConstantLargeValue = 7, // 0b111 |
| 96 | |
| 97 | // Entries with no location are not stored and do not need own marker. |
| 98 | kNone = static_cast<uint8_t>(-1), |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 99 | |
| 100 | kLastLocationKind = kConstantLargeValue |
| 101 | }; |
| 102 | |
| 103 | static_assert( |
| 104 | sizeof(Kind) == 1u, |
| 105 | "art::DexRegisterLocation::Kind has a size different from one byte."); |
| 106 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 107 | static bool IsShortLocationKind(Kind kind) { |
| 108 | switch (kind) { |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 109 | case Kind::kInStack: |
| 110 | case Kind::kInRegister: |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 111 | case Kind::kInRegisterHigh: |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 112 | case Kind::kInFpuRegister: |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 113 | case Kind::kInFpuRegisterHigh: |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 114 | case Kind::kConstant: |
| 115 | return true; |
| 116 | |
| 117 | case Kind::kInStackLargeOffset: |
| 118 | case Kind::kConstantLargeValue: |
| 119 | return false; |
| 120 | |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 121 | case Kind::kNone: |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 122 | LOG(FATAL) << "Unexpected location kind"; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 123 | } |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 124 | UNREACHABLE(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 125 | } |
| 126 | |
| 127 | // Convert `kind` to a "surface" kind, i.e. one that doesn't include |
| 128 | // any value with a "large" qualifier. |
| 129 | // TODO: Introduce another enum type for the surface kind? |
| 130 | static Kind ConvertToSurfaceKind(Kind kind) { |
| 131 | switch (kind) { |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 132 | case Kind::kInStack: |
| 133 | case Kind::kInRegister: |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 134 | case Kind::kInRegisterHigh: |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 135 | case Kind::kInFpuRegister: |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 136 | case Kind::kInFpuRegisterHigh: |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 137 | case Kind::kConstant: |
| 138 | return kind; |
| 139 | |
| 140 | case Kind::kInStackLargeOffset: |
| 141 | return Kind::kInStack; |
| 142 | |
| 143 | case Kind::kConstantLargeValue: |
| 144 | return Kind::kConstant; |
| 145 | |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 146 | case Kind::kNone: |
| 147 | return kind; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 148 | } |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 149 | UNREACHABLE(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 150 | } |
| 151 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 152 | // Required by art::StackMapStream::LocationCatalogEntriesIndices. |
| 153 | DexRegisterLocation() : kind_(Kind::kNone), value_(0) {} |
| 154 | |
| 155 | DexRegisterLocation(Kind kind, int32_t value) : kind_(kind), value_(value) {} |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 156 | |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 157 | static DexRegisterLocation None() { |
| 158 | return DexRegisterLocation(Kind::kNone, 0); |
| 159 | } |
| 160 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 161 | // Get the "surface" kind of the location, i.e., the one that doesn't |
| 162 | // include any value with a "large" qualifier. |
| 163 | Kind GetKind() const { |
| 164 | return ConvertToSurfaceKind(kind_); |
| 165 | } |
| 166 | |
| 167 | // Get the value of the location. |
| 168 | int32_t GetValue() const { return value_; } |
| 169 | |
| 170 | // Get the actual kind of the location. |
| 171 | Kind GetInternalKind() const { return kind_; } |
| 172 | |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 173 | bool operator==(DexRegisterLocation other) const { |
| 174 | return kind_ == other.kind_ && value_ == other.value_; |
| 175 | } |
| 176 | |
| 177 | bool operator!=(DexRegisterLocation other) const { |
| 178 | return !(*this == other); |
| 179 | } |
| 180 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 181 | private: |
| 182 | Kind kind_; |
| 183 | int32_t value_; |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 184 | |
| 185 | friend class DexRegisterLocationHashFn; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 186 | }; |
| 187 | |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 188 | std::ostream& operator<<(std::ostream& stream, const DexRegisterLocation::Kind& kind); |
| 189 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 190 | /** |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 191 | * Store information on unique Dex register locations used in a method. |
| 192 | * The information is of the form: |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 193 | * |
| 194 | * [DexRegisterLocation+]. |
| 195 | * |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 196 | * DexRegisterLocations are either 1- or 5-byte wide (see art::DexRegisterLocation::Kind). |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 197 | */ |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 198 | class DexRegisterLocationCatalog { |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 199 | public: |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 200 | explicit DexRegisterLocationCatalog(MemoryRegion region) : region_(region) {} |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 201 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 202 | // Short (compressed) location, fitting on one byte. |
| 203 | typedef uint8_t ShortLocation; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 204 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 205 | void SetRegisterInfo(size_t offset, const DexRegisterLocation& dex_register_location) { |
| 206 | DexRegisterLocation::Kind kind = ComputeCompressedKind(dex_register_location); |
| 207 | int32_t value = dex_register_location.GetValue(); |
| 208 | if (DexRegisterLocation::IsShortLocationKind(kind)) { |
| 209 | // Short location. Compress the kind and the value as a single byte. |
| 210 | if (kind == DexRegisterLocation::Kind::kInStack) { |
| 211 | // Instead of storing stack offsets expressed in bytes for |
| 212 | // short stack locations, store slot offsets. A stack offset |
| 213 | // is a multiple of 4 (kFrameSlotSize). This means that by |
| 214 | // dividing it by 4, we can fit values from the [0, 128) |
| 215 | // interval in a short stack location, and not just values |
| 216 | // from the [0, 32) interval. |
| 217 | DCHECK_EQ(value % kFrameSlotSize, 0); |
| 218 | value /= kFrameSlotSize; |
| 219 | } |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 220 | DCHECK(IsShortValue(value)) << value; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 221 | region_.StoreUnaligned<ShortLocation>(offset, MakeShortLocation(kind, value)); |
| 222 | } else { |
| 223 | // Large location. Write the location on one byte and the value |
| 224 | // on 4 bytes. |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 225 | DCHECK(!IsShortValue(value)) << value; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 226 | if (kind == DexRegisterLocation::Kind::kInStackLargeOffset) { |
| 227 | // Also divide large stack offsets by 4 for the sake of consistency. |
| 228 | DCHECK_EQ(value % kFrameSlotSize, 0); |
| 229 | value /= kFrameSlotSize; |
| 230 | } |
| 231 | // Data can be unaligned as the written Dex register locations can |
| 232 | // either be 1-byte or 5-byte wide. Use |
| 233 | // art::MemoryRegion::StoreUnaligned instead of |
| 234 | // art::MemoryRegion::Store to prevent unligned word accesses on ARM. |
| 235 | region_.StoreUnaligned<DexRegisterLocation::Kind>(offset, kind); |
| 236 | region_.StoreUnaligned<int32_t>(offset + sizeof(DexRegisterLocation::Kind), value); |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 237 | } |
| 238 | } |
| 239 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 240 | // Find the offset of the location catalog entry number `location_catalog_entry_index`. |
| 241 | size_t FindLocationOffset(size_t location_catalog_entry_index) const { |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 242 | size_t offset = kFixedSize; |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 243 | // Skip the first `location_catalog_entry_index - 1` entries. |
| 244 | for (uint16_t i = 0; i < location_catalog_entry_index; ++i) { |
| 245 | // Read the first next byte and inspect its first 3 bits to decide |
| 246 | // whether it is a short or a large location. |
| 247 | DexRegisterLocation::Kind kind = ExtractKindAtOffset(offset); |
| 248 | if (DexRegisterLocation::IsShortLocationKind(kind)) { |
| 249 | // Short location. Skip the current byte. |
| 250 | offset += SingleShortEntrySize(); |
| 251 | } else { |
| 252 | // Large location. Skip the 5 next bytes. |
| 253 | offset += SingleLargeEntrySize(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 254 | } |
| 255 | } |
| 256 | return offset; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 257 | } |
| 258 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 259 | // Get the internal kind of entry at `location_catalog_entry_index`. |
| 260 | DexRegisterLocation::Kind GetLocationInternalKind(size_t location_catalog_entry_index) const { |
| 261 | if (location_catalog_entry_index == kNoLocationEntryIndex) { |
| 262 | return DexRegisterLocation::Kind::kNone; |
| 263 | } |
| 264 | return ExtractKindAtOffset(FindLocationOffset(location_catalog_entry_index)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 265 | } |
| 266 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 267 | // Get the (surface) kind and value of entry at `location_catalog_entry_index`. |
| 268 | DexRegisterLocation GetDexRegisterLocation(size_t location_catalog_entry_index) const { |
| 269 | if (location_catalog_entry_index == kNoLocationEntryIndex) { |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 270 | return DexRegisterLocation::None(); |
| 271 | } |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 272 | size_t offset = FindLocationOffset(location_catalog_entry_index); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 273 | // Read the first byte and inspect its first 3 bits to get the location. |
| 274 | ShortLocation first_byte = region_.LoadUnaligned<ShortLocation>(offset); |
| 275 | DexRegisterLocation::Kind kind = ExtractKindFromShortLocation(first_byte); |
| 276 | if (DexRegisterLocation::IsShortLocationKind(kind)) { |
| 277 | // Short location. Extract the value from the remaining 5 bits. |
| 278 | int32_t value = ExtractValueFromShortLocation(first_byte); |
| 279 | if (kind == DexRegisterLocation::Kind::kInStack) { |
| 280 | // Convert the stack slot (short) offset to a byte offset value. |
| 281 | value *= kFrameSlotSize; |
| 282 | } |
| 283 | return DexRegisterLocation(kind, value); |
| 284 | } else { |
| 285 | // Large location. Read the four next bytes to get the value. |
| 286 | int32_t value = region_.LoadUnaligned<int32_t>(offset + sizeof(DexRegisterLocation::Kind)); |
| 287 | if (kind == DexRegisterLocation::Kind::kInStackLargeOffset) { |
| 288 | // Convert the stack slot (large) offset to a byte offset value. |
| 289 | value *= kFrameSlotSize; |
| 290 | } |
| 291 | return DexRegisterLocation(kind, value); |
| 292 | } |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 293 | } |
| 294 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 295 | // Compute the compressed kind of `location`. |
| 296 | static DexRegisterLocation::Kind ComputeCompressedKind(const DexRegisterLocation& location) { |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 297 | DexRegisterLocation::Kind kind = location.GetInternalKind(); |
| 298 | switch (kind) { |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 299 | case DexRegisterLocation::Kind::kInStack: |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 300 | return IsShortStackOffsetValue(location.GetValue()) |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 301 | ? DexRegisterLocation::Kind::kInStack |
| 302 | : DexRegisterLocation::Kind::kInStackLargeOffset; |
| 303 | |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 304 | case DexRegisterLocation::Kind::kInRegister: |
| 305 | case DexRegisterLocation::Kind::kInRegisterHigh: |
| 306 | DCHECK_GE(location.GetValue(), 0); |
| 307 | DCHECK_LT(location.GetValue(), 1 << kValueBits); |
| 308 | return kind; |
| 309 | |
| 310 | case DexRegisterLocation::Kind::kInFpuRegister: |
| 311 | case DexRegisterLocation::Kind::kInFpuRegisterHigh: |
| 312 | DCHECK_GE(location.GetValue(), 0); |
| 313 | DCHECK_LT(location.GetValue(), 1 << kValueBits); |
| 314 | return kind; |
| 315 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 316 | case DexRegisterLocation::Kind::kConstant: |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 317 | return IsShortConstantValue(location.GetValue()) |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 318 | ? DexRegisterLocation::Kind::kConstant |
| 319 | : DexRegisterLocation::Kind::kConstantLargeValue; |
| 320 | |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 321 | case DexRegisterLocation::Kind::kConstantLargeValue: |
| 322 | case DexRegisterLocation::Kind::kInStackLargeOffset: |
| 323 | case DexRegisterLocation::Kind::kNone: |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 324 | LOG(FATAL) << "Unexpected location kind " << kind; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 325 | } |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 326 | UNREACHABLE(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 327 | } |
| 328 | |
| 329 | // Can `location` be turned into a short location? |
| 330 | static bool CanBeEncodedAsShortLocation(const DexRegisterLocation& location) { |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 331 | DexRegisterLocation::Kind kind = location.GetInternalKind(); |
| 332 | switch (kind) { |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 333 | case DexRegisterLocation::Kind::kInStack: |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 334 | return IsShortStackOffsetValue(location.GetValue()); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 335 | |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 336 | case DexRegisterLocation::Kind::kInRegister: |
| 337 | case DexRegisterLocation::Kind::kInRegisterHigh: |
| 338 | case DexRegisterLocation::Kind::kInFpuRegister: |
| 339 | case DexRegisterLocation::Kind::kInFpuRegisterHigh: |
| 340 | return true; |
| 341 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 342 | case DexRegisterLocation::Kind::kConstant: |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 343 | return IsShortConstantValue(location.GetValue()); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 344 | |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 345 | case DexRegisterLocation::Kind::kConstantLargeValue: |
| 346 | case DexRegisterLocation::Kind::kInStackLargeOffset: |
| 347 | case DexRegisterLocation::Kind::kNone: |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 348 | LOG(FATAL) << "Unexpected location kind " << kind; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 349 | } |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 350 | UNREACHABLE(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 351 | } |
| 352 | |
| 353 | static size_t EntrySize(const DexRegisterLocation& location) { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 354 | return CanBeEncodedAsShortLocation(location) ? SingleShortEntrySize() : SingleLargeEntrySize(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 355 | } |
| 356 | |
| 357 | static size_t SingleShortEntrySize() { |
| 358 | return sizeof(ShortLocation); |
| 359 | } |
| 360 | |
| 361 | static size_t SingleLargeEntrySize() { |
| 362 | return sizeof(DexRegisterLocation::Kind) + sizeof(int32_t); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 363 | } |
| 364 | |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 365 | size_t Size() const { |
| 366 | return region_.size(); |
| 367 | } |
| 368 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 369 | void Dump(VariableIndentationOutputStream* vios, const CodeInfo& code_info); |
Roland Levillain | 0396ed7 | 2015-05-27 15:12:19 +0100 | [diff] [blame] | 370 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 371 | // Special (invalid) Dex register location catalog entry index meaning |
| 372 | // that there is no location for a given Dex register (i.e., it is |
| 373 | // mapped to a DexRegisterLocation::Kind::kNone location). |
| 374 | static constexpr size_t kNoLocationEntryIndex = -1; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 375 | |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 376 | private: |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 377 | static constexpr int kFixedSize = 0; |
| 378 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 379 | // Width of the kind "field" in a short location, in bits. |
| 380 | static constexpr size_t kKindBits = 3; |
| 381 | // Width of the value "field" in a short location, in bits. |
| 382 | static constexpr size_t kValueBits = 5; |
| 383 | |
| 384 | static constexpr uint8_t kKindMask = (1 << kKindBits) - 1; |
| 385 | static constexpr int32_t kValueMask = (1 << kValueBits) - 1; |
| 386 | static constexpr size_t kKindOffset = 0; |
| 387 | static constexpr size_t kValueOffset = kKindBits; |
| 388 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 389 | static bool IsShortStackOffsetValue(int32_t value) { |
| 390 | DCHECK_EQ(value % kFrameSlotSize, 0); |
| 391 | return IsShortValue(value / kFrameSlotSize); |
| 392 | } |
| 393 | |
| 394 | static bool IsShortConstantValue(int32_t value) { |
| 395 | return IsShortValue(value); |
| 396 | } |
| 397 | |
| 398 | static bool IsShortValue(int32_t value) { |
| 399 | return IsUint<kValueBits>(value); |
| 400 | } |
| 401 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 402 | static ShortLocation MakeShortLocation(DexRegisterLocation::Kind kind, int32_t value) { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 403 | uint8_t kind_integer_value = static_cast<uint8_t>(kind); |
| 404 | DCHECK(IsUint<kKindBits>(kind_integer_value)) << kind_integer_value; |
| 405 | DCHECK(IsShortValue(value)) << value; |
| 406 | return (kind_integer_value & kKindMask) << kKindOffset |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 407 | | (value & kValueMask) << kValueOffset; |
| 408 | } |
| 409 | |
| 410 | static DexRegisterLocation::Kind ExtractKindFromShortLocation(ShortLocation location) { |
| 411 | uint8_t kind = (location >> kKindOffset) & kKindMask; |
| 412 | DCHECK_LE(kind, static_cast<uint8_t>(DexRegisterLocation::Kind::kLastLocationKind)); |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 413 | // We do not encode kNone locations in the stack map. |
| 414 | DCHECK_NE(kind, static_cast<uint8_t>(DexRegisterLocation::Kind::kNone)); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 415 | return static_cast<DexRegisterLocation::Kind>(kind); |
| 416 | } |
| 417 | |
| 418 | static int32_t ExtractValueFromShortLocation(ShortLocation location) { |
| 419 | return (location >> kValueOffset) & kValueMask; |
| 420 | } |
| 421 | |
| 422 | // Extract a location kind from the byte at position `offset`. |
| 423 | DexRegisterLocation::Kind ExtractKindAtOffset(size_t offset) const { |
| 424 | ShortLocation first_byte = region_.LoadUnaligned<ShortLocation>(offset); |
| 425 | return ExtractKindFromShortLocation(first_byte); |
| 426 | } |
| 427 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 428 | MemoryRegion region_; |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 429 | |
| 430 | friend class CodeInfo; |
| 431 | friend class StackMapStream; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 432 | }; |
| 433 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 434 | /* Information on Dex register locations for a specific PC, mapping a |
| 435 | * stack map's Dex register to a location entry in a DexRegisterLocationCatalog. |
| 436 | * The information is of the form: |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 437 | * |
| 438 | * [live_bit_mask, entries*] |
| 439 | * |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 440 | * where entries are concatenated unsigned integer values encoded on a number |
| 441 | * of bits (fixed per DexRegisterMap instances of a CodeInfo object) depending |
| 442 | * on the number of entries in the Dex register location catalog |
| 443 | * (see DexRegisterMap::SingleEntrySizeInBits). The map is 1-byte aligned. |
| 444 | */ |
| 445 | class DexRegisterMap { |
| 446 | public: |
| 447 | explicit DexRegisterMap(MemoryRegion region) : region_(region) {} |
Nicolas Geoffray | 012fc4e | 2016-01-08 15:58:19 +0000 | [diff] [blame] | 448 | DexRegisterMap() {} |
| 449 | |
| 450 | bool IsValid() const { return region_.pointer() != nullptr; } |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 451 | |
| 452 | // Get the surface kind of Dex register `dex_register_number`. |
| 453 | DexRegisterLocation::Kind GetLocationKind(uint16_t dex_register_number, |
| 454 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 455 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 456 | const CodeInfoEncoding& enc) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 457 | return DexRegisterLocation::ConvertToSurfaceKind( |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 458 | GetLocationInternalKind(dex_register_number, number_of_dex_registers, code_info, enc)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 459 | } |
| 460 | |
| 461 | // Get the internal kind of Dex register `dex_register_number`. |
| 462 | DexRegisterLocation::Kind GetLocationInternalKind(uint16_t dex_register_number, |
| 463 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 464 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 465 | const CodeInfoEncoding& enc) const; |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 466 | |
| 467 | // Get the Dex register location `dex_register_number`. |
| 468 | DexRegisterLocation GetDexRegisterLocation(uint16_t dex_register_number, |
| 469 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 470 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 471 | const CodeInfoEncoding& enc) const; |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 472 | |
| 473 | int32_t GetStackOffsetInBytes(uint16_t dex_register_number, |
| 474 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 475 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 476 | const CodeInfoEncoding& enc) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 477 | DexRegisterLocation location = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 478 | GetDexRegisterLocation(dex_register_number, number_of_dex_registers, code_info, enc); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 479 | DCHECK(location.GetKind() == DexRegisterLocation::Kind::kInStack); |
| 480 | // GetDexRegisterLocation returns the offset in bytes. |
| 481 | return location.GetValue(); |
| 482 | } |
| 483 | |
| 484 | int32_t GetConstant(uint16_t dex_register_number, |
| 485 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 486 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 487 | const CodeInfoEncoding& enc) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 488 | DexRegisterLocation location = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 489 | GetDexRegisterLocation(dex_register_number, number_of_dex_registers, code_info, enc); |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 490 | DCHECK_EQ(location.GetKind(), DexRegisterLocation::Kind::kConstant); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 491 | return location.GetValue(); |
| 492 | } |
| 493 | |
| 494 | int32_t GetMachineRegister(uint16_t dex_register_number, |
| 495 | uint16_t number_of_dex_registers, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 496 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 497 | const CodeInfoEncoding& enc) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 498 | DexRegisterLocation location = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 499 | GetDexRegisterLocation(dex_register_number, number_of_dex_registers, code_info, enc); |
David Brazdil | d9cb68e | 2015-08-25 13:52:43 +0100 | [diff] [blame] | 500 | DCHECK(location.GetInternalKind() == DexRegisterLocation::Kind::kInRegister || |
| 501 | location.GetInternalKind() == DexRegisterLocation::Kind::kInRegisterHigh || |
| 502 | location.GetInternalKind() == DexRegisterLocation::Kind::kInFpuRegister || |
| 503 | location.GetInternalKind() == DexRegisterLocation::Kind::kInFpuRegisterHigh) |
David Srbecky | 7dc1178 | 2016-02-25 13:23:56 +0000 | [diff] [blame] | 504 | << location.GetInternalKind(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 505 | return location.GetValue(); |
| 506 | } |
| 507 | |
| 508 | // Get the index of the entry in the Dex register location catalog |
| 509 | // corresponding to `dex_register_number`. |
| 510 | size_t GetLocationCatalogEntryIndex(uint16_t dex_register_number, |
| 511 | uint16_t number_of_dex_registers, |
| 512 | size_t number_of_location_catalog_entries) const { |
| 513 | if (!IsDexRegisterLive(dex_register_number)) { |
| 514 | return DexRegisterLocationCatalog::kNoLocationEntryIndex; |
| 515 | } |
| 516 | |
| 517 | if (number_of_location_catalog_entries == 1) { |
| 518 | // We do not allocate space for location maps in the case of a |
| 519 | // single-entry location catalog, as it is useless. The only valid |
| 520 | // entry index is 0; |
| 521 | return 0; |
| 522 | } |
| 523 | |
| 524 | // The bit offset of the beginning of the map locations. |
| 525 | size_t map_locations_offset_in_bits = |
| 526 | GetLocationMappingDataOffset(number_of_dex_registers) * kBitsPerByte; |
| 527 | size_t index_in_dex_register_map = GetIndexInDexRegisterMap(dex_register_number); |
| 528 | DCHECK_LT(index_in_dex_register_map, GetNumberOfLiveDexRegisters(number_of_dex_registers)); |
| 529 | // The bit size of an entry. |
| 530 | size_t map_entry_size_in_bits = SingleEntrySizeInBits(number_of_location_catalog_entries); |
| 531 | // The bit offset where `index_in_dex_register_map` is located. |
| 532 | size_t entry_offset_in_bits = |
| 533 | map_locations_offset_in_bits + index_in_dex_register_map * map_entry_size_in_bits; |
| 534 | size_t location_catalog_entry_index = |
| 535 | region_.LoadBits(entry_offset_in_bits, map_entry_size_in_bits); |
| 536 | DCHECK_LT(location_catalog_entry_index, number_of_location_catalog_entries); |
| 537 | return location_catalog_entry_index; |
| 538 | } |
| 539 | |
| 540 | // Map entry at `index_in_dex_register_map` to `location_catalog_entry_index`. |
| 541 | void SetLocationCatalogEntryIndex(size_t index_in_dex_register_map, |
| 542 | size_t location_catalog_entry_index, |
| 543 | uint16_t number_of_dex_registers, |
| 544 | size_t number_of_location_catalog_entries) { |
| 545 | DCHECK_LT(index_in_dex_register_map, GetNumberOfLiveDexRegisters(number_of_dex_registers)); |
| 546 | DCHECK_LT(location_catalog_entry_index, number_of_location_catalog_entries); |
| 547 | |
| 548 | if (number_of_location_catalog_entries == 1) { |
| 549 | // We do not allocate space for location maps in the case of a |
| 550 | // single-entry location catalog, as it is useless. |
| 551 | return; |
| 552 | } |
| 553 | |
| 554 | // The bit offset of the beginning of the map locations. |
| 555 | size_t map_locations_offset_in_bits = |
| 556 | GetLocationMappingDataOffset(number_of_dex_registers) * kBitsPerByte; |
| 557 | // The bit size of an entry. |
| 558 | size_t map_entry_size_in_bits = SingleEntrySizeInBits(number_of_location_catalog_entries); |
| 559 | // The bit offset where `index_in_dex_register_map` is located. |
| 560 | size_t entry_offset_in_bits = |
| 561 | map_locations_offset_in_bits + index_in_dex_register_map * map_entry_size_in_bits; |
| 562 | region_.StoreBits(entry_offset_in_bits, location_catalog_entry_index, map_entry_size_in_bits); |
| 563 | } |
| 564 | |
| 565 | void SetLiveBitMask(uint16_t number_of_dex_registers, |
| 566 | const BitVector& live_dex_registers_mask) { |
| 567 | size_t live_bit_mask_offset_in_bits = GetLiveBitMaskOffset() * kBitsPerByte; |
| 568 | for (uint16_t i = 0; i < number_of_dex_registers; ++i) { |
| 569 | region_.StoreBit(live_bit_mask_offset_in_bits + i, live_dex_registers_mask.IsBitSet(i)); |
| 570 | } |
| 571 | } |
| 572 | |
| 573 | bool IsDexRegisterLive(uint16_t dex_register_number) const { |
| 574 | size_t live_bit_mask_offset_in_bits = GetLiveBitMaskOffset() * kBitsPerByte; |
| 575 | return region_.LoadBit(live_bit_mask_offset_in_bits + dex_register_number); |
| 576 | } |
| 577 | |
| 578 | size_t GetNumberOfLiveDexRegisters(uint16_t number_of_dex_registers) const { |
| 579 | size_t number_of_live_dex_registers = 0; |
| 580 | for (size_t i = 0; i < number_of_dex_registers; ++i) { |
| 581 | if (IsDexRegisterLive(i)) { |
| 582 | ++number_of_live_dex_registers; |
| 583 | } |
| 584 | } |
| 585 | return number_of_live_dex_registers; |
| 586 | } |
| 587 | |
| 588 | static size_t GetLiveBitMaskOffset() { |
| 589 | return kFixedSize; |
| 590 | } |
| 591 | |
| 592 | // Compute the size of the live register bit mask (in bytes), for a |
| 593 | // method having `number_of_dex_registers` Dex registers. |
| 594 | static size_t GetLiveBitMaskSize(uint16_t number_of_dex_registers) { |
| 595 | return RoundUp(number_of_dex_registers, kBitsPerByte) / kBitsPerByte; |
| 596 | } |
| 597 | |
| 598 | static size_t GetLocationMappingDataOffset(uint16_t number_of_dex_registers) { |
| 599 | return GetLiveBitMaskOffset() + GetLiveBitMaskSize(number_of_dex_registers); |
| 600 | } |
| 601 | |
| 602 | size_t GetLocationMappingDataSize(uint16_t number_of_dex_registers, |
| 603 | size_t number_of_location_catalog_entries) const { |
| 604 | size_t location_mapping_data_size_in_bits = |
| 605 | GetNumberOfLiveDexRegisters(number_of_dex_registers) |
| 606 | * SingleEntrySizeInBits(number_of_location_catalog_entries); |
| 607 | return RoundUp(location_mapping_data_size_in_bits, kBitsPerByte) / kBitsPerByte; |
| 608 | } |
| 609 | |
| 610 | // Return the size of a map entry in bits. Note that if |
| 611 | // `number_of_location_catalog_entries` equals 1, this function returns 0, |
| 612 | // which is fine, as there is no need to allocate a map for a |
| 613 | // single-entry location catalog; the only valid location catalog entry index |
| 614 | // for a live register in this case is 0 and there is no need to |
| 615 | // store it. |
| 616 | static size_t SingleEntrySizeInBits(size_t number_of_location_catalog_entries) { |
| 617 | // Handle the case of 0, as we cannot pass 0 to art::WhichPowerOf2. |
| 618 | return number_of_location_catalog_entries == 0 |
| 619 | ? 0u |
| 620 | : WhichPowerOf2(RoundUpToPowerOfTwo(number_of_location_catalog_entries)); |
| 621 | } |
| 622 | |
| 623 | // Return the size of the DexRegisterMap object, in bytes. |
| 624 | size_t Size() const { |
| 625 | return region_.size(); |
| 626 | } |
| 627 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 628 | void Dump(VariableIndentationOutputStream* vios, |
| 629 | const CodeInfo& code_info, uint16_t number_of_dex_registers) const; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 630 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 631 | private: |
| 632 | // Return the index in the Dex register map corresponding to the Dex |
| 633 | // register number `dex_register_number`. |
| 634 | size_t GetIndexInDexRegisterMap(uint16_t dex_register_number) const { |
| 635 | if (!IsDexRegisterLive(dex_register_number)) { |
| 636 | return kInvalidIndexInDexRegisterMap; |
| 637 | } |
| 638 | return GetNumberOfLiveDexRegisters(dex_register_number); |
| 639 | } |
| 640 | |
| 641 | // Special (invalid) Dex register map entry index meaning that there |
| 642 | // is no index in the map for a given Dex register (i.e., it must |
| 643 | // have been mapped to a DexRegisterLocation::Kind::kNone location). |
| 644 | static constexpr size_t kInvalidIndexInDexRegisterMap = -1; |
| 645 | |
| 646 | static constexpr int kFixedSize = 0; |
| 647 | |
| 648 | MemoryRegion region_; |
| 649 | |
| 650 | friend class CodeInfo; |
| 651 | friend class StackMapStream; |
| 652 | }; |
| 653 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 654 | // Represents bit range of bit-packed integer field. |
| 655 | // We reuse the idea from ULEB128p1 to support encoding of -1 (aka 0xFFFFFFFF). |
| 656 | // If min_value is set to -1, we implicitly subtract one from any loaded value, |
| 657 | // and add one to any stored value. This is generalized to any negative values. |
| 658 | // In other words, min_value acts as a base and the stored value is added to it. |
| 659 | struct FieldEncoding { |
| 660 | FieldEncoding(size_t start_offset, size_t end_offset, int32_t min_value = 0) |
| 661 | : start_offset_(start_offset), end_offset_(end_offset), min_value_(min_value) { |
| 662 | DCHECK_LE(start_offset_, end_offset_); |
| 663 | DCHECK_LE(BitSize(), 32u); |
| 664 | } |
| 665 | |
| 666 | ALWAYS_INLINE size_t BitSize() const { return end_offset_ - start_offset_; } |
| 667 | |
| 668 | ALWAYS_INLINE int32_t Load(const MemoryRegion& region) const { |
| 669 | DCHECK_LE(end_offset_, region.size_in_bits()); |
| 670 | const size_t bit_count = BitSize(); |
| 671 | if (bit_count == 0) { |
| 672 | // Do not touch any memory if the range is empty. |
| 673 | return min_value_; |
| 674 | } |
| 675 | uint8_t* address = region.start() + start_offset_ / kBitsPerByte; |
| 676 | const uint32_t shift = start_offset_ & (kBitsPerByte - 1); |
| 677 | // Load the value (reading only the strictly needed bytes). |
| 678 | const uint32_t load_bit_count = shift + bit_count; |
| 679 | uint32_t value = *address++ >> shift; |
| 680 | if (load_bit_count > 8) { |
| 681 | value |= static_cast<uint32_t>(*address++) << (8 - shift); |
| 682 | if (load_bit_count > 16) { |
| 683 | value |= static_cast<uint32_t>(*address++) << (16 - shift); |
| 684 | if (load_bit_count > 24) { |
| 685 | value |= static_cast<uint32_t>(*address++) << (24 - shift); |
| 686 | if (load_bit_count > 32) { |
| 687 | value |= static_cast<uint32_t>(*address++) << (32 - shift); |
| 688 | } |
| 689 | } |
| 690 | } |
| 691 | } |
| 692 | // Clear unwanted most significant bits. |
| 693 | uint32_t clear_bit_count = 32 - bit_count; |
| 694 | value = (value << clear_bit_count) >> clear_bit_count; |
| 695 | return value + min_value_; |
| 696 | } |
| 697 | |
| 698 | ALWAYS_INLINE void Store(MemoryRegion region, int32_t value) const { |
| 699 | region.StoreBits(start_offset_, value - min_value_, BitSize()); |
| 700 | DCHECK_EQ(Load(region), value); |
| 701 | } |
| 702 | |
| 703 | private: |
| 704 | size_t start_offset_; |
| 705 | size_t end_offset_; |
| 706 | int32_t min_value_; |
| 707 | }; |
| 708 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 709 | class StackMapEncoding { |
| 710 | public: |
| 711 | StackMapEncoding() {} |
| 712 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 713 | // Set stack map bit layout based on given sizes. |
| 714 | // Returns the size of stack map in bytes. |
| 715 | size_t SetFromSizes(size_t native_pc_max, |
| 716 | size_t dex_pc_max, |
| 717 | size_t dex_register_map_size, |
| 718 | size_t inline_info_size, |
| 719 | size_t register_mask_max, |
| 720 | size_t stack_mask_bit_size) { |
| 721 | size_t bit_offset = 0; |
| 722 | DCHECK_EQ(kNativePcBitOffset, bit_offset); |
| 723 | bit_offset += MinimumBitsToStore(native_pc_max); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 724 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 725 | dex_pc_bit_offset_ = dchecked_integral_cast<uint8_t>(bit_offset); |
| 726 | bit_offset += MinimumBitsToStore(1 /* kNoDexPc */ + dex_pc_max); |
| 727 | |
| 728 | // We also need +1 for kNoDexRegisterMap, but since the size is strictly |
| 729 | // greater than any offset we might try to encode, we already implicitly have it. |
| 730 | dex_register_map_bit_offset_ = dchecked_integral_cast<uint8_t>(bit_offset); |
| 731 | bit_offset += MinimumBitsToStore(dex_register_map_size); |
| 732 | |
| 733 | // We also need +1 for kNoInlineInfo, but since the inline_info_size is strictly |
| 734 | // greater than the offset we might try to encode, we already implicitly have it. |
| 735 | // If inline_info_size is zero, we can encode only kNoInlineInfo (in zero bits). |
| 736 | inline_info_bit_offset_ = dchecked_integral_cast<uint8_t>(bit_offset); |
| 737 | if (inline_info_size != 0) { |
| 738 | bit_offset += MinimumBitsToStore(dex_register_map_size + inline_info_size); |
| 739 | } |
| 740 | |
| 741 | register_mask_bit_offset_ = dchecked_integral_cast<uint8_t>(bit_offset); |
| 742 | bit_offset += MinimumBitsToStore(register_mask_max); |
| 743 | |
| 744 | stack_mask_bit_offset_ = dchecked_integral_cast<uint8_t>(bit_offset); |
| 745 | bit_offset += stack_mask_bit_size; |
| 746 | |
| 747 | return RoundUp(bit_offset, kBitsPerByte) / kBitsPerByte; |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 748 | } |
| 749 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 750 | ALWAYS_INLINE FieldEncoding GetNativePcEncoding() const { |
| 751 | return FieldEncoding(kNativePcBitOffset, dex_pc_bit_offset_); |
| 752 | } |
| 753 | ALWAYS_INLINE FieldEncoding GetDexPcEncoding() const { |
| 754 | return FieldEncoding(dex_pc_bit_offset_, dex_register_map_bit_offset_, -1 /* min_value */); |
| 755 | } |
| 756 | ALWAYS_INLINE FieldEncoding GetDexRegisterMapEncoding() const { |
| 757 | return FieldEncoding(dex_register_map_bit_offset_, inline_info_bit_offset_, -1 /* min_value */); |
| 758 | } |
| 759 | ALWAYS_INLINE FieldEncoding GetInlineInfoEncoding() const { |
| 760 | return FieldEncoding(inline_info_bit_offset_, register_mask_bit_offset_, -1 /* min_value */); |
| 761 | } |
| 762 | ALWAYS_INLINE FieldEncoding GetRegisterMaskEncoding() const { |
| 763 | return FieldEncoding(register_mask_bit_offset_, stack_mask_bit_offset_); |
| 764 | } |
| 765 | ALWAYS_INLINE size_t GetStackMaskBitOffset() const { |
| 766 | // The end offset is not encoded. It is implicitly the end of stack map entry. |
| 767 | return stack_mask_bit_offset_; |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 768 | } |
| 769 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 770 | void Dump(VariableIndentationOutputStream* vios) const; |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 771 | |
| 772 | private: |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 773 | static constexpr size_t kNativePcBitOffset = 0; |
| 774 | uint8_t dex_pc_bit_offset_; |
| 775 | uint8_t dex_register_map_bit_offset_; |
| 776 | uint8_t inline_info_bit_offset_; |
| 777 | uint8_t register_mask_bit_offset_; |
| 778 | uint8_t stack_mask_bit_offset_; |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 779 | }; |
| 780 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 781 | /** |
| 782 | * A Stack Map holds compilation information for a specific PC necessary for: |
| 783 | * - Mapping it to a dex PC, |
| 784 | * - Knowing which stack entries are objects, |
| 785 | * - Knowing which registers hold objects, |
| 786 | * - Knowing the inlining information, |
| 787 | * - Knowing the values of dex registers. |
| 788 | * |
| 789 | * The information is of the form: |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 790 | * |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 791 | * [native_pc_offset, dex_pc, dex_register_map_offset, inlining_info_offset, register_mask, |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 792 | * stack_mask]. |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 793 | */ |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 794 | class StackMap { |
| 795 | public: |
Nicolas Geoffray | e12997f | 2015-05-22 14:01:33 +0100 | [diff] [blame] | 796 | StackMap() {} |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 797 | explicit StackMap(MemoryRegion region) : region_(region) {} |
Nicolas Geoffray | e12997f | 2015-05-22 14:01:33 +0100 | [diff] [blame] | 798 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 799 | ALWAYS_INLINE bool IsValid() const { return region_.pointer() != nullptr; } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 800 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 801 | ALWAYS_INLINE uint32_t GetDexPc(const StackMapEncoding& encoding) const { |
| 802 | return encoding.GetDexPcEncoding().Load(region_); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 803 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 804 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 805 | ALWAYS_INLINE void SetDexPc(const StackMapEncoding& encoding, uint32_t dex_pc) { |
| 806 | encoding.GetDexPcEncoding().Store(region_, dex_pc); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 807 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 808 | |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 809 | ALWAYS_INLINE uint32_t GetNativePcOffset(const StackMapEncoding& encoding, |
| 810 | InstructionSet instruction_set) const { |
| 811 | CodeOffset offset( |
| 812 | CodeOffset::FromCompressedOffset(encoding.GetNativePcEncoding().Load(region_))); |
| 813 | return offset.Uint32Value(instruction_set); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 814 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 815 | |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 816 | ALWAYS_INLINE void SetNativePcCodeOffset(const StackMapEncoding& encoding, |
| 817 | CodeOffset native_pc_offset) { |
| 818 | encoding.GetNativePcEncoding().Store(region_, native_pc_offset.CompressedValue()); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 819 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 820 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 821 | ALWAYS_INLINE uint32_t GetDexRegisterMapOffset(const StackMapEncoding& encoding) const { |
| 822 | return encoding.GetDexRegisterMapEncoding().Load(region_); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 823 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 824 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 825 | ALWAYS_INLINE void SetDexRegisterMapOffset(const StackMapEncoding& encoding, uint32_t offset) { |
| 826 | encoding.GetDexRegisterMapEncoding().Store(region_, offset); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 827 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 828 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 829 | ALWAYS_INLINE uint32_t GetInlineDescriptorOffset(const StackMapEncoding& encoding) const { |
| 830 | return encoding.GetInlineInfoEncoding().Load(region_); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 831 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 832 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 833 | ALWAYS_INLINE void SetInlineDescriptorOffset(const StackMapEncoding& encoding, uint32_t offset) { |
| 834 | encoding.GetInlineInfoEncoding().Store(region_, offset); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 835 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 836 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 837 | ALWAYS_INLINE uint32_t GetRegisterMask(const StackMapEncoding& encoding) const { |
| 838 | return encoding.GetRegisterMaskEncoding().Load(region_); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 839 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 840 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 841 | ALWAYS_INLINE void SetRegisterMask(const StackMapEncoding& encoding, uint32_t mask) { |
| 842 | encoding.GetRegisterMaskEncoding().Store(region_, mask); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 843 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 844 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 845 | ALWAYS_INLINE size_t GetNumberOfStackMaskBits(const StackMapEncoding& encoding) const { |
| 846 | return region_.size_in_bits() - encoding.GetStackMaskBitOffset(); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 847 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 848 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 849 | ALWAYS_INLINE bool GetStackMaskBit(const StackMapEncoding& encoding, size_t index) const { |
| 850 | return region_.LoadBit(encoding.GetStackMaskBitOffset() + index); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 851 | } |
| 852 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 853 | ALWAYS_INLINE void SetStackMaskBit(const StackMapEncoding& encoding, size_t index, bool value) { |
| 854 | region_.StoreBit(encoding.GetStackMaskBitOffset() + index, value); |
| 855 | } |
| 856 | |
| 857 | ALWAYS_INLINE bool HasDexRegisterMap(const StackMapEncoding& encoding) const { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 858 | return GetDexRegisterMapOffset(encoding) != kNoDexRegisterMap; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 859 | } |
| 860 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 861 | ALWAYS_INLINE bool HasInlineInfo(const StackMapEncoding& encoding) const { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 862 | return GetInlineDescriptorOffset(encoding) != kNoInlineInfo; |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 863 | } |
| 864 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 865 | ALWAYS_INLINE bool Equals(const StackMap& other) const { |
| 866 | return region_.pointer() == other.region_.pointer() && region_.size() == other.region_.size(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 867 | } |
| 868 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 869 | void Dump(VariableIndentationOutputStream* vios, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 870 | const CodeInfo& code_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 871 | const CodeInfoEncoding& encoding, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 872 | uint32_t code_offset, |
| 873 | uint16_t number_of_dex_registers, |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 874 | InstructionSet instruction_set, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 875 | const std::string& header_suffix = "") const; |
| 876 | |
Roland Levillain | 442b46a | 2015-02-18 16:54:21 +0000 | [diff] [blame] | 877 | // Special (invalid) offset for the DexRegisterMapOffset field meaning |
| 878 | // that there is no Dex register map for this stack map. |
| 879 | static constexpr uint32_t kNoDexRegisterMap = -1; |
| 880 | |
| 881 | // Special (invalid) offset for the InlineDescriptorOffset field meaning |
| 882 | // that there is no inline info for this stack map. |
| 883 | static constexpr uint32_t kNoInlineInfo = -1; |
| 884 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 885 | private: |
Nicolas Geoffray | 896f8f7 | 2015-03-30 15:44:25 +0100 | [diff] [blame] | 886 | static constexpr int kFixedSize = 0; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 887 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 888 | MemoryRegion region_; |
| 889 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 890 | friend class StackMapStream; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 891 | }; |
| 892 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 893 | class InlineInfoEncoding { |
| 894 | public: |
| 895 | void SetFromSizes(size_t method_index_max, |
| 896 | size_t dex_pc_max, |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 897 | size_t extra_data_max, |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 898 | size_t dex_register_map_size) { |
| 899 | total_bit_size_ = kMethodIndexBitOffset; |
| 900 | total_bit_size_ += MinimumBitsToStore(method_index_max); |
| 901 | |
| 902 | dex_pc_bit_offset_ = dchecked_integral_cast<uint8_t>(total_bit_size_); |
Vladimir Marko | 87f3fcb | 2016-04-28 15:52:11 +0100 | [diff] [blame] | 903 | // Note: We're not encoding the dex pc if there is none. That's the case |
| 904 | // for an intrinsified native method, such as String.charAt(). |
| 905 | if (dex_pc_max != DexFile::kDexNoIndex) { |
| 906 | total_bit_size_ += MinimumBitsToStore(1 /* kNoDexPc */ + dex_pc_max); |
| 907 | } |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 908 | |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 909 | extra_data_bit_offset_ = dchecked_integral_cast<uint8_t>(total_bit_size_); |
| 910 | total_bit_size_ += MinimumBitsToStore(extra_data_max); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 911 | |
| 912 | // We also need +1 for kNoDexRegisterMap, but since the size is strictly |
| 913 | // greater than any offset we might try to encode, we already implicitly have it. |
| 914 | dex_register_map_bit_offset_ = dchecked_integral_cast<uint8_t>(total_bit_size_); |
| 915 | total_bit_size_ += MinimumBitsToStore(dex_register_map_size); |
| 916 | } |
| 917 | |
| 918 | ALWAYS_INLINE FieldEncoding GetMethodIndexEncoding() const { |
| 919 | return FieldEncoding(kMethodIndexBitOffset, dex_pc_bit_offset_); |
| 920 | } |
| 921 | ALWAYS_INLINE FieldEncoding GetDexPcEncoding() const { |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 922 | return FieldEncoding(dex_pc_bit_offset_, extra_data_bit_offset_, -1 /* min_value */); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 923 | } |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 924 | ALWAYS_INLINE FieldEncoding GetExtraDataEncoding() const { |
| 925 | return FieldEncoding(extra_data_bit_offset_, dex_register_map_bit_offset_); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 926 | } |
| 927 | ALWAYS_INLINE FieldEncoding GetDexRegisterMapEncoding() const { |
| 928 | return FieldEncoding(dex_register_map_bit_offset_, total_bit_size_, -1 /* min_value */); |
| 929 | } |
| 930 | ALWAYS_INLINE size_t GetEntrySize() const { |
| 931 | return RoundUp(total_bit_size_, kBitsPerByte) / kBitsPerByte; |
| 932 | } |
| 933 | |
| 934 | void Dump(VariableIndentationOutputStream* vios) const; |
| 935 | |
| 936 | private: |
| 937 | static constexpr uint8_t kIsLastBitOffset = 0; |
| 938 | static constexpr uint8_t kMethodIndexBitOffset = 1; |
| 939 | uint8_t dex_pc_bit_offset_; |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 940 | uint8_t extra_data_bit_offset_; |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 941 | uint8_t dex_register_map_bit_offset_; |
| 942 | uint8_t total_bit_size_; |
| 943 | }; |
| 944 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 945 | /** |
| 946 | * Inline information for a specific PC. The information is of the form: |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 947 | * |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 948 | * [is_last, |
| 949 | * method_index (or ArtMethod high bits), |
| 950 | * dex_pc, |
| 951 | * extra_data (ArtMethod low bits or 1), |
| 952 | * dex_register_map_offset]+. |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 953 | */ |
| 954 | class InlineInfo { |
| 955 | public: |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 956 | explicit InlineInfo(MemoryRegion region) : region_(region) { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 957 | } |
| 958 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 959 | ALWAYS_INLINE uint32_t GetDepth(const InlineInfoEncoding& encoding) const { |
| 960 | size_t depth = 0; |
| 961 | while (!GetRegionAtDepth(encoding, depth++).LoadBit(0)) { } // Check is_last bit. |
| 962 | return depth; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 963 | } |
| 964 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 965 | ALWAYS_INLINE void SetDepth(const InlineInfoEncoding& encoding, uint32_t depth) { |
| 966 | DCHECK_GT(depth, 0u); |
| 967 | for (size_t d = 0; d < depth; ++d) { |
| 968 | GetRegionAtDepth(encoding, d).StoreBit(0, d == depth - 1); // Set is_last bit. |
| 969 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 970 | } |
| 971 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 972 | ALWAYS_INLINE uint32_t GetMethodIndexAtDepth(const InlineInfoEncoding& encoding, |
| 973 | uint32_t depth) const { |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 974 | DCHECK(!EncodesArtMethodAtDepth(encoding, depth)); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 975 | return encoding.GetMethodIndexEncoding().Load(GetRegionAtDepth(encoding, depth)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 976 | } |
| 977 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 978 | ALWAYS_INLINE void SetMethodIndexAtDepth(const InlineInfoEncoding& encoding, |
| 979 | uint32_t depth, |
| 980 | uint32_t index) { |
| 981 | encoding.GetMethodIndexEncoding().Store(GetRegionAtDepth(encoding, depth), index); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 982 | } |
| 983 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 984 | ALWAYS_INLINE uint32_t GetDexPcAtDepth(const InlineInfoEncoding& encoding, |
| 985 | uint32_t depth) const { |
| 986 | return encoding.GetDexPcEncoding().Load(GetRegionAtDepth(encoding, depth)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 987 | } |
| 988 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 989 | ALWAYS_INLINE void SetDexPcAtDepth(const InlineInfoEncoding& encoding, |
| 990 | uint32_t depth, |
| 991 | uint32_t dex_pc) { |
| 992 | encoding.GetDexPcEncoding().Store(GetRegionAtDepth(encoding, depth), dex_pc); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 993 | } |
| 994 | |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 995 | ALWAYS_INLINE bool EncodesArtMethodAtDepth(const InlineInfoEncoding& encoding, |
| 996 | uint32_t depth) const { |
| 997 | return (encoding.GetExtraDataEncoding().Load(GetRegionAtDepth(encoding, depth)) & 1) == 0; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 998 | } |
| 999 | |
Nicolas Geoffray | 5d37c15 | 2017-01-12 13:25:19 +0000 | [diff] [blame] | 1000 | ALWAYS_INLINE void SetExtraDataAtDepth(const InlineInfoEncoding& encoding, |
| 1001 | uint32_t depth, |
| 1002 | uint32_t extra_data) { |
| 1003 | encoding.GetExtraDataEncoding().Store(GetRegionAtDepth(encoding, depth), extra_data); |
| 1004 | } |
| 1005 | |
| 1006 | ALWAYS_INLINE ArtMethod* GetArtMethodAtDepth(const InlineInfoEncoding& encoding, |
| 1007 | uint32_t depth) const { |
| 1008 | uint32_t low_bits = encoding.GetExtraDataEncoding().Load(GetRegionAtDepth(encoding, depth)); |
| 1009 | uint32_t high_bits = encoding.GetMethodIndexEncoding().Load(GetRegionAtDepth(encoding, depth)); |
| 1010 | if (high_bits == 0) { |
| 1011 | return reinterpret_cast<ArtMethod*>(low_bits); |
| 1012 | } else { |
| 1013 | uint64_t address = high_bits; |
| 1014 | address = address << 32; |
| 1015 | return reinterpret_cast<ArtMethod*>(address | low_bits); |
| 1016 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1017 | } |
| 1018 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1019 | ALWAYS_INLINE uint32_t GetDexRegisterMapOffsetAtDepth(const InlineInfoEncoding& encoding, |
| 1020 | uint32_t depth) const { |
| 1021 | return encoding.GetDexRegisterMapEncoding().Load(GetRegionAtDepth(encoding, depth)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1022 | } |
| 1023 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1024 | ALWAYS_INLINE void SetDexRegisterMapOffsetAtDepth(const InlineInfoEncoding& encoding, |
| 1025 | uint32_t depth, |
| 1026 | uint32_t offset) { |
| 1027 | encoding.GetDexRegisterMapEncoding().Store(GetRegionAtDepth(encoding, depth), offset); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1028 | } |
| 1029 | |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1030 | ALWAYS_INLINE bool HasDexRegisterMapAtDepth(const InlineInfoEncoding& encoding, |
| 1031 | uint32_t depth) const { |
| 1032 | return GetDexRegisterMapOffsetAtDepth(encoding, depth) != StackMap::kNoDexRegisterMap; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1033 | } |
| 1034 | |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 1035 | void Dump(VariableIndentationOutputStream* vios, |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1036 | const CodeInfo& info, |
| 1037 | uint16_t* number_of_dex_registers) const; |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 1038 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1039 | private: |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1040 | ALWAYS_INLINE MemoryRegion GetRegionAtDepth(const InlineInfoEncoding& encoding, |
| 1041 | uint32_t depth) const { |
| 1042 | size_t entry_size = encoding.GetEntrySize(); |
| 1043 | DCHECK_GT(entry_size, 0u); |
| 1044 | return region_.Subregion(depth * entry_size, entry_size); |
| 1045 | } |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 1046 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1047 | MemoryRegion region_; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1048 | }; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1049 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1050 | // Most of the fields are encoded as ULEB128 to save space. |
| 1051 | struct CodeInfoEncoding { |
| 1052 | uint32_t non_header_size; |
| 1053 | uint32_t number_of_stack_maps; |
| 1054 | uint32_t stack_map_size_in_bytes; |
| 1055 | uint32_t number_of_location_catalog_entries; |
| 1056 | StackMapEncoding stack_map_encoding; |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1057 | InlineInfoEncoding inline_info_encoding; |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1058 | uint8_t header_size; |
| 1059 | |
| 1060 | CodeInfoEncoding() { } |
| 1061 | |
| 1062 | explicit CodeInfoEncoding(const void* data) { |
| 1063 | const uint8_t* ptr = reinterpret_cast<const uint8_t*>(data); |
| 1064 | non_header_size = DecodeUnsignedLeb128(&ptr); |
| 1065 | number_of_stack_maps = DecodeUnsignedLeb128(&ptr); |
| 1066 | stack_map_size_in_bytes = DecodeUnsignedLeb128(&ptr); |
| 1067 | number_of_location_catalog_entries = DecodeUnsignedLeb128(&ptr); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1068 | static_assert(alignof(StackMapEncoding) == 1, |
| 1069 | "StackMapEncoding should not require alignment"); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1070 | stack_map_encoding = *reinterpret_cast<const StackMapEncoding*>(ptr); |
| 1071 | ptr += sizeof(StackMapEncoding); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1072 | if (stack_map_encoding.GetInlineInfoEncoding().BitSize() > 0) { |
| 1073 | static_assert(alignof(InlineInfoEncoding) == 1, |
| 1074 | "InlineInfoEncoding should not require alignment"); |
| 1075 | inline_info_encoding = *reinterpret_cast<const InlineInfoEncoding*>(ptr); |
| 1076 | ptr += sizeof(InlineInfoEncoding); |
| 1077 | } else { |
Roland Levillain | 7cbd27f | 2016-08-11 23:53:33 +0100 | [diff] [blame] | 1078 | inline_info_encoding = InlineInfoEncoding{}; // NOLINT. |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1079 | } |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1080 | header_size = dchecked_integral_cast<uint8_t>(ptr - reinterpret_cast<const uint8_t*>(data)); |
| 1081 | } |
| 1082 | |
| 1083 | template<typename Vector> |
| 1084 | void Compress(Vector* dest) const { |
| 1085 | EncodeUnsignedLeb128(dest, non_header_size); |
| 1086 | EncodeUnsignedLeb128(dest, number_of_stack_maps); |
| 1087 | EncodeUnsignedLeb128(dest, stack_map_size_in_bytes); |
| 1088 | EncodeUnsignedLeb128(dest, number_of_location_catalog_entries); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1089 | const uint8_t* stack_map_ptr = reinterpret_cast<const uint8_t*>(&stack_map_encoding); |
| 1090 | dest->insert(dest->end(), stack_map_ptr, stack_map_ptr + sizeof(StackMapEncoding)); |
| 1091 | if (stack_map_encoding.GetInlineInfoEncoding().BitSize() > 0) { |
| 1092 | const uint8_t* inline_info_ptr = reinterpret_cast<const uint8_t*>(&inline_info_encoding); |
| 1093 | dest->insert(dest->end(), inline_info_ptr, inline_info_ptr + sizeof(InlineInfoEncoding)); |
| 1094 | } |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1095 | } |
| 1096 | }; |
| 1097 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1098 | /** |
| 1099 | * Wrapper around all compiler information collected for a method. |
| 1100 | * The information is of the form: |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 1101 | * |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1102 | * [CodeInfoEncoding, StackMap+, DexRegisterLocationCatalog+, DexRegisterMap+, InlineInfo*] |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 1103 | * |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1104 | * where CodeInfoEncoding is of the form: |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 1105 | * |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1106 | * [non_header_size, number_of_stack_maps, stack_map_size_in_bytes, |
| 1107 | * number_of_location_catalog_entries, StackMapEncoding] |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1108 | */ |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1109 | class CodeInfo { |
| 1110 | public: |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1111 | explicit CodeInfo(MemoryRegion region) : region_(region) { |
| 1112 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1113 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1114 | explicit CodeInfo(const void* data) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1115 | CodeInfoEncoding encoding = CodeInfoEncoding(data); |
| 1116 | region_ = MemoryRegion(const_cast<void*>(data), |
| 1117 | encoding.header_size + encoding.non_header_size); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1118 | } |
| 1119 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1120 | CodeInfoEncoding ExtractEncoding() const { |
Mathieu Chartier | 01c7814 | 2017-01-05 10:17:55 -0800 | [diff] [blame] | 1121 | CodeInfoEncoding encoding(region_.start()); |
| 1122 | AssertValidStackMap(encoding); |
| 1123 | return encoding; |
Nicolas Geoffray | 896f8f7 | 2015-03-30 15:44:25 +0100 | [diff] [blame] | 1124 | } |
| 1125 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1126 | bool HasInlineInfo(const CodeInfoEncoding& encoding) const { |
| 1127 | return encoding.stack_map_encoding.GetInlineInfoEncoding().BitSize() > 0; |
Nicolas Geoffray | 896f8f7 | 2015-03-30 15:44:25 +0100 | [diff] [blame] | 1128 | } |
| 1129 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1130 | DexRegisterLocationCatalog GetDexRegisterLocationCatalog(const CodeInfoEncoding& encoding) const { |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1131 | return DexRegisterLocationCatalog(region_.Subregion( |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1132 | GetDexRegisterLocationCatalogOffset(encoding), |
| 1133 | GetDexRegisterLocationCatalogSize(encoding))); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1134 | } |
| 1135 | |
Mingyao Yang | ccfa885 | 2017-01-18 14:51:59 -0800 | [diff] [blame] | 1136 | ALWAYS_INLINE StackMap GetStackMapAt(size_t i, const CodeInfoEncoding& encoding) const { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1137 | size_t stack_map_size = encoding.stack_map_size_in_bytes; |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1138 | return StackMap(GetStackMaps(encoding).Subregion(i * stack_map_size, stack_map_size)); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1139 | } |
| 1140 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1141 | uint32_t GetNumberOfLocationCatalogEntries(const CodeInfoEncoding& encoding) const { |
| 1142 | return encoding.number_of_location_catalog_entries; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1143 | } |
| 1144 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1145 | uint32_t GetDexRegisterLocationCatalogSize(const CodeInfoEncoding& encoding) const { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1146 | return ComputeDexRegisterLocationCatalogSize(GetDexRegisterLocationCatalogOffset(encoding), |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1147 | GetNumberOfLocationCatalogEntries(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1148 | } |
| 1149 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1150 | uint32_t GetNumberOfStackMaps(const CodeInfoEncoding& encoding) const { |
| 1151 | return encoding.number_of_stack_maps; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1152 | } |
| 1153 | |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1154 | // Get the size of all the stack maps of this CodeInfo object, in bytes. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1155 | size_t GetStackMapsSize(const CodeInfoEncoding& encoding) const { |
| 1156 | return encoding.stack_map_size_in_bytes * GetNumberOfStackMaps(encoding); |
Roland Levillain | 29ba1b0 | 2015-03-13 11:45:07 +0000 | [diff] [blame] | 1157 | } |
| 1158 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1159 | uint32_t GetDexRegisterLocationCatalogOffset(const CodeInfoEncoding& encoding) const { |
| 1160 | return GetStackMapsOffset(encoding) + GetStackMapsSize(encoding); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 1161 | } |
| 1162 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1163 | size_t GetDexRegisterMapsOffset(const CodeInfoEncoding& encoding) const { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1164 | return GetDexRegisterLocationCatalogOffset(encoding) |
| 1165 | + GetDexRegisterLocationCatalogSize(encoding); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 1166 | } |
| 1167 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1168 | uint32_t GetStackMapsOffset(const CodeInfoEncoding& encoding) const { |
| 1169 | return encoding.header_size; |
Nicolas Geoffray | 6530baf | 2015-05-26 15:22:58 +0100 | [diff] [blame] | 1170 | } |
| 1171 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1172 | DexRegisterMap GetDexRegisterMapOf(StackMap stack_map, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1173 | const CodeInfoEncoding& encoding, |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1174 | uint32_t number_of_dex_registers) const { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1175 | if (!stack_map.HasDexRegisterMap(encoding.stack_map_encoding)) { |
Nicolas Geoffray | 012fc4e | 2016-01-08 15:58:19 +0000 | [diff] [blame] | 1176 | return DexRegisterMap(); |
| 1177 | } else { |
| 1178 | uint32_t offset = GetDexRegisterMapsOffset(encoding) |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1179 | + stack_map.GetDexRegisterMapOffset(encoding.stack_map_encoding); |
| 1180 | size_t size = ComputeDexRegisterMapSizeOf(encoding, offset, number_of_dex_registers); |
Nicolas Geoffray | 012fc4e | 2016-01-08 15:58:19 +0000 | [diff] [blame] | 1181 | return DexRegisterMap(region_.Subregion(offset, size)); |
| 1182 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1183 | } |
| 1184 | |
Mathieu Chartier | 5e7c6a9 | 2017-01-17 16:38:30 -0800 | [diff] [blame^] | 1185 | size_t GetDexRegisterMapsSize(const CodeInfoEncoding& encoding, |
| 1186 | uint32_t number_of_dex_registers) const { |
| 1187 | size_t total = 0; |
| 1188 | for (size_t i = 0, e = GetNumberOfStackMaps(encoding); i < e; ++i) { |
| 1189 | StackMap stack_map = GetStackMapAt(i, encoding); |
| 1190 | DexRegisterMap map(GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers)); |
| 1191 | total += map.Size(); |
| 1192 | } |
| 1193 | return total; |
| 1194 | } |
| 1195 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1196 | // Return the `DexRegisterMap` pointed by `inline_info` at depth `depth`. |
| 1197 | DexRegisterMap GetDexRegisterMapAtDepth(uint8_t depth, |
| 1198 | InlineInfo inline_info, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1199 | const CodeInfoEncoding& encoding, |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1200 | uint32_t number_of_dex_registers) const { |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1201 | if (!inline_info.HasDexRegisterMapAtDepth(encoding.inline_info_encoding, depth)) { |
Nicolas Geoffray | 012fc4e | 2016-01-08 15:58:19 +0000 | [diff] [blame] | 1202 | return DexRegisterMap(); |
| 1203 | } else { |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1204 | uint32_t offset = GetDexRegisterMapsOffset(encoding) + |
| 1205 | inline_info.GetDexRegisterMapOffsetAtDepth(encoding.inline_info_encoding, depth); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1206 | size_t size = ComputeDexRegisterMapSizeOf(encoding, offset, number_of_dex_registers); |
Nicolas Geoffray | 012fc4e | 2016-01-08 15:58:19 +0000 | [diff] [blame] | 1207 | return DexRegisterMap(region_.Subregion(offset, size)); |
| 1208 | } |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 1209 | } |
| 1210 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1211 | InlineInfo GetInlineInfoOf(StackMap stack_map, const CodeInfoEncoding& encoding) const { |
| 1212 | DCHECK(stack_map.HasInlineInfo(encoding.stack_map_encoding)); |
| 1213 | uint32_t offset = stack_map.GetInlineDescriptorOffset(encoding.stack_map_encoding) |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1214 | + GetDexRegisterMapsOffset(encoding); |
David Srbecky | 61b28a1 | 2016-02-25 21:55:03 +0000 | [diff] [blame] | 1215 | return InlineInfo(region_.Subregion(offset, region_.size() - offset)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1216 | } |
| 1217 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1218 | StackMap GetStackMapForDexPc(uint32_t dex_pc, const CodeInfoEncoding& encoding) const { |
| 1219 | for (size_t i = 0, e = GetNumberOfStackMaps(encoding); i < e; ++i) { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1220 | StackMap stack_map = GetStackMapAt(i, encoding); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1221 | if (stack_map.GetDexPc(encoding.stack_map_encoding) == dex_pc) { |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1222 | return stack_map; |
| 1223 | } |
| 1224 | } |
Nicolas Geoffray | e12997f | 2015-05-22 14:01:33 +0100 | [diff] [blame] | 1225 | return StackMap(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1226 | } |
| 1227 | |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1228 | // Searches the stack map list backwards because catch stack maps are stored |
| 1229 | // at the end. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1230 | StackMap GetCatchStackMapForDexPc(uint32_t dex_pc, const CodeInfoEncoding& encoding) const { |
| 1231 | for (size_t i = GetNumberOfStackMaps(encoding); i > 0; --i) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1232 | StackMap stack_map = GetStackMapAt(i - 1, encoding); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1233 | if (stack_map.GetDexPc(encoding.stack_map_encoding) == dex_pc) { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1234 | return stack_map; |
| 1235 | } |
| 1236 | } |
| 1237 | return StackMap(); |
| 1238 | } |
| 1239 | |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1240 | StackMap GetOsrStackMapForDexPc(uint32_t dex_pc, const CodeInfoEncoding& encoding) const { |
| 1241 | size_t e = GetNumberOfStackMaps(encoding); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1242 | if (e == 0) { |
| 1243 | // There cannot be OSR stack map if there is no stack map. |
| 1244 | return StackMap(); |
| 1245 | } |
| 1246 | // Walk over all stack maps. If two consecutive stack maps are identical, then we |
| 1247 | // have found a stack map suitable for OSR. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1248 | const StackMapEncoding& stack_map_encoding = encoding.stack_map_encoding; |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1249 | for (size_t i = 0; i < e - 1; ++i) { |
| 1250 | StackMap stack_map = GetStackMapAt(i, encoding); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1251 | if (stack_map.GetDexPc(stack_map_encoding) == dex_pc) { |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1252 | StackMap other = GetStackMapAt(i + 1, encoding); |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1253 | if (other.GetDexPc(stack_map_encoding) == dex_pc && |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 1254 | other.GetNativePcOffset(stack_map_encoding, kRuntimeISA) == |
| 1255 | stack_map.GetNativePcOffset(stack_map_encoding, kRuntimeISA)) { |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1256 | DCHECK_EQ(other.GetDexRegisterMapOffset(stack_map_encoding), |
| 1257 | stack_map.GetDexRegisterMapOffset(stack_map_encoding)); |
| 1258 | DCHECK(!stack_map.HasInlineInfo(stack_map_encoding)); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1259 | if (i < e - 2) { |
| 1260 | // Make sure there are not three identical stack maps following each other. |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 1261 | DCHECK_NE( |
| 1262 | stack_map.GetNativePcOffset(stack_map_encoding, kRuntimeISA), |
| 1263 | GetStackMapAt(i + 2, encoding).GetNativePcOffset(stack_map_encoding, kRuntimeISA)); |
Nicolas Geoffray | b331feb | 2016-02-05 16:51:53 +0000 | [diff] [blame] | 1264 | } |
| 1265 | return stack_map; |
| 1266 | } |
| 1267 | } |
| 1268 | } |
| 1269 | return StackMap(); |
| 1270 | } |
| 1271 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1272 | StackMap GetStackMapForNativePcOffset(uint32_t native_pc_offset, |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1273 | const CodeInfoEncoding& encoding) const { |
David Brazdil | 77a48ae | 2015-09-15 12:34:04 +0000 | [diff] [blame] | 1274 | // TODO: Safepoint stack maps are sorted by native_pc_offset but catch stack |
| 1275 | // maps are not. If we knew that the method does not have try/catch, |
| 1276 | // we could do binary search. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1277 | for (size_t i = 0, e = GetNumberOfStackMaps(encoding); i < e; ++i) { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 1278 | StackMap stack_map = GetStackMapAt(i, encoding); |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 1279 | if (stack_map.GetNativePcOffset(encoding.stack_map_encoding, kRuntimeISA) == |
| 1280 | native_pc_offset) { |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1281 | return stack_map; |
| 1282 | } |
| 1283 | } |
Nicolas Geoffray | e12997f | 2015-05-22 14:01:33 +0100 | [diff] [blame] | 1284 | return StackMap(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1285 | } |
| 1286 | |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 1287 | // Dump this CodeInfo object on `os`. `code_offset` is the (absolute) |
| 1288 | // native PC of the compiled method and `number_of_dex_registers` the |
| 1289 | // number of Dex virtual registers used in this method. If |
| 1290 | // `dump_stack_maps` is true, also dump the stack maps and the |
| 1291 | // associated Dex register maps. |
Vladimir Marko | 8f1e08a | 2015-06-26 12:06:30 +0100 | [diff] [blame] | 1292 | void Dump(VariableIndentationOutputStream* vios, |
Roland Levillain | f2650d1 | 2015-05-28 14:53:28 +0100 | [diff] [blame] | 1293 | uint32_t code_offset, |
| 1294 | uint16_t number_of_dex_registers, |
Mathieu Chartier | a2f526f | 2017-01-19 14:48:48 -0800 | [diff] [blame] | 1295 | bool dump_stack_maps, |
| 1296 | InstructionSet instruction_set) const; |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 1297 | |
Mathieu Chartier | 01c7814 | 2017-01-05 10:17:55 -0800 | [diff] [blame] | 1298 | // Check that the code info has valid stack map and abort if it does not. |
| 1299 | void AssertValidStackMap(const CodeInfoEncoding& encoding) const { |
| 1300 | if (region_.size() != 0 && region_.size() < GetStackMapsSize(encoding)) { |
| 1301 | LOG(FATAL) << region_.size() << "\n" |
| 1302 | << encoding.header_size << "\n" |
| 1303 | << encoding.non_header_size << "\n" |
| 1304 | << encoding.number_of_location_catalog_entries << "\n" |
| 1305 | << encoding.number_of_stack_maps << "\n" |
| 1306 | << encoding.stack_map_size_in_bytes; |
| 1307 | } |
| 1308 | } |
| 1309 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1310 | private: |
Mingyao Yang | ccfa885 | 2017-01-18 14:51:59 -0800 | [diff] [blame] | 1311 | ALWAYS_INLINE MemoryRegion GetStackMaps(const CodeInfoEncoding& encoding) const { |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1312 | return region_.size() == 0 |
| 1313 | ? MemoryRegion() |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1314 | : region_.Subregion(GetStackMapsOffset(encoding), GetStackMapsSize(encoding)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1315 | } |
| 1316 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1317 | // Compute the size of the Dex register map associated to the stack map at |
| 1318 | // `dex_register_map_offset_in_code_info`. |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1319 | size_t ComputeDexRegisterMapSizeOf(const CodeInfoEncoding& encoding, |
| 1320 | uint32_t dex_register_map_offset_in_code_info, |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1321 | uint16_t number_of_dex_registers) const { |
| 1322 | // Offset where the actual mapping data starts within art::DexRegisterMap. |
| 1323 | size_t location_mapping_data_offset_in_dex_register_map = |
| 1324 | DexRegisterMap::GetLocationMappingDataOffset(number_of_dex_registers); |
| 1325 | // Create a temporary art::DexRegisterMap to be able to call |
| 1326 | // art::DexRegisterMap::GetNumberOfLiveDexRegisters and |
| 1327 | DexRegisterMap dex_register_map_without_locations( |
| 1328 | MemoryRegion(region_.Subregion(dex_register_map_offset_in_code_info, |
| 1329 | location_mapping_data_offset_in_dex_register_map))); |
| 1330 | size_t number_of_live_dex_registers = |
| 1331 | dex_register_map_without_locations.GetNumberOfLiveDexRegisters(number_of_dex_registers); |
| 1332 | size_t location_mapping_data_size_in_bits = |
David Srbecky | 09ed098 | 2016-02-12 21:58:43 +0000 | [diff] [blame] | 1333 | DexRegisterMap::SingleEntrySizeInBits(GetNumberOfLocationCatalogEntries(encoding)) |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1334 | * number_of_live_dex_registers; |
| 1335 | size_t location_mapping_data_size_in_bytes = |
| 1336 | RoundUp(location_mapping_data_size_in_bits, kBitsPerByte) / kBitsPerByte; |
| 1337 | size_t dex_register_map_size = |
| 1338 | location_mapping_data_offset_in_dex_register_map + location_mapping_data_size_in_bytes; |
| 1339 | return dex_register_map_size; |
| 1340 | } |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 1341 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1342 | // Compute the size of a Dex register location catalog starting at offset `origin` |
| 1343 | // in `region_` and containing `number_of_dex_locations` entries. |
| 1344 | size_t ComputeDexRegisterLocationCatalogSize(uint32_t origin, |
| 1345 | uint32_t number_of_dex_locations) const { |
| 1346 | // TODO: Ideally, we would like to use art::DexRegisterLocationCatalog::Size or |
| 1347 | // art::DexRegisterLocationCatalog::FindLocationOffset, but the |
| 1348 | // DexRegisterLocationCatalog is not yet built. Try to factor common code. |
| 1349 | size_t offset = origin + DexRegisterLocationCatalog::kFixedSize; |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 1350 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 1351 | // Skip the first `number_of_dex_locations - 1` entries. |
| 1352 | for (uint16_t i = 0; i < number_of_dex_locations; ++i) { |
| 1353 | // Read the first next byte and inspect its first 3 bits to decide |
| 1354 | // whether it is a short or a large location. |
| 1355 | DexRegisterLocationCatalog::ShortLocation first_byte = |
| 1356 | region_.LoadUnaligned<DexRegisterLocationCatalog::ShortLocation>(offset); |
| 1357 | DexRegisterLocation::Kind kind = |
| 1358 | DexRegisterLocationCatalog::ExtractKindFromShortLocation(first_byte); |
| 1359 | if (DexRegisterLocation::IsShortLocationKind(kind)) { |
| 1360 | // Short location. Skip the current byte. |
| 1361 | offset += DexRegisterLocationCatalog::SingleShortEntrySize(); |
| 1362 | } else { |
| 1363 | // Large location. Skip the 5 next bytes. |
| 1364 | offset += DexRegisterLocationCatalog::SingleLargeEntrySize(); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 1365 | } |
| 1366 | } |
| 1367 | size_t size = offset - origin; |
| 1368 | return size; |
| 1369 | } |
| 1370 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1371 | MemoryRegion region_; |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 1372 | friend class StackMapStream; |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1373 | }; |
| 1374 | |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 1375 | #undef ELEMENT_BYTE_OFFSET_AFTER |
| 1376 | #undef ELEMENT_BIT_OFFSET_AFTER |
| 1377 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 1378 | } // namespace art |
| 1379 | |
| 1380 | #endif // ART_RUNTIME_STACK_MAP_H_ |