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 | #include "stack_map.h" |
| 18 | #include "stack_map_stream.h" |
| 19 | #include "utils/arena_bit_vector.h" |
| 20 | |
| 21 | #include "gtest/gtest.h" |
| 22 | |
| 23 | namespace art { |
| 24 | |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 25 | static bool SameBits(MemoryRegion region, const BitVector& bit_vector) { |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 26 | for (size_t i = 0; i < region.size_in_bits(); ++i) { |
| 27 | if (region.LoadBit(i) != bit_vector.IsBitSet(i)) { |
| 28 | return false; |
| 29 | } |
| 30 | } |
| 31 | return true; |
| 32 | } |
| 33 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 34 | using Kind = DexRegisterLocation::Kind; |
| 35 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 36 | TEST(StackMapTest, Test1) { |
| 37 | ArenaPool pool; |
| 38 | ArenaAllocator arena(&pool); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 39 | StackMapStream stream(&arena); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 40 | |
| 41 | ArenaBitVector sp_mask(&arena, 0, false); |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 42 | size_t number_of_dex_registers = 2; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 43 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 44 | stream.AddDexRegisterEntry(Kind::kInStack, 0); // Short location. |
| 45 | stream.AddDexRegisterEntry(Kind::kConstant, -2); // Short location. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 46 | stream.EndStackMapEntry(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 47 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 48 | size_t size = stream.PrepareForFillIn(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 49 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 50 | MemoryRegion region(memory, size); |
| 51 | stream.FillIn(region); |
| 52 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 53 | CodeInfo code_info(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 54 | StackMapEncoding encoding = code_info.ExtractEncoding(); |
| 55 | ASSERT_EQ(0u, encoding.NumberOfBytesForStackMask()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 56 | ASSERT_EQ(1u, code_info.GetNumberOfStackMaps()); |
| 57 | |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 58 | uint32_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 59 | ASSERT_EQ(2u, number_of_location_catalog_entries); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 60 | DexRegisterLocationCatalog location_catalog = code_info.GetDexRegisterLocationCatalog(encoding); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 61 | // The Dex register location catalog contains: |
| 62 | // - one 1-byte short Dex register location, and |
| 63 | // - one 5-byte large Dex register location. |
| 64 | size_t expected_location_catalog_size = 1u + 5u; |
| 65 | ASSERT_EQ(expected_location_catalog_size, location_catalog.Size()); |
| 66 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 67 | StackMap stack_map = code_info.GetStackMapAt(0, encoding); |
| 68 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0, encoding))); |
| 69 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64, encoding))); |
| 70 | ASSERT_EQ(0u, stack_map.GetDexPc(encoding)); |
| 71 | ASSERT_EQ(64u, stack_map.GetNativePcOffset(encoding)); |
| 72 | ASSERT_EQ(0x3u, stack_map.GetRegisterMask(encoding)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 73 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 74 | MemoryRegion stack_mask = stack_map.GetStackMask(encoding); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 75 | ASSERT_TRUE(SameBits(stack_mask, sp_mask)); |
| 76 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 77 | ASSERT_TRUE(stack_map.HasDexRegisterMap(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 78 | DexRegisterMap dex_register_map = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 79 | code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 80 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(0)); |
| 81 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(1)); |
| 82 | ASSERT_EQ(2u, dex_register_map.GetNumberOfLiveDexRegisters(number_of_dex_registers)); |
| 83 | // The Dex register map contains: |
| 84 | // - one 1-byte live bit mask, and |
| 85 | // - one 1-byte set of location catalog entry indices composed of two 2-bit values. |
| 86 | size_t expected_dex_register_map_size = 1u + 1u; |
| 87 | ASSERT_EQ(expected_dex_register_map_size, dex_register_map.Size()); |
| 88 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 89 | ASSERT_EQ(Kind::kInStack, dex_register_map.GetLocationKind( |
| 90 | 0, number_of_dex_registers, code_info, encoding)); |
| 91 | ASSERT_EQ(Kind::kConstant, dex_register_map.GetLocationKind( |
| 92 | 1, number_of_dex_registers, code_info, encoding)); |
| 93 | ASSERT_EQ(Kind::kInStack, dex_register_map.GetLocationInternalKind( |
| 94 | 0, number_of_dex_registers, code_info, encoding)); |
| 95 | ASSERT_EQ(Kind::kConstantLargeValue, dex_register_map.GetLocationInternalKind( |
| 96 | 1, number_of_dex_registers, code_info, encoding)); |
| 97 | ASSERT_EQ(0, dex_register_map.GetStackOffsetInBytes( |
| 98 | 0, number_of_dex_registers, code_info, encoding)); |
| 99 | ASSERT_EQ(-2, dex_register_map.GetConstant(1, number_of_dex_registers, code_info, encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 100 | |
| 101 | size_t index0 = dex_register_map.GetLocationCatalogEntryIndex( |
| 102 | 0, number_of_dex_registers, number_of_location_catalog_entries); |
| 103 | size_t index1 = dex_register_map.GetLocationCatalogEntryIndex( |
| 104 | 1, number_of_dex_registers, number_of_location_catalog_entries); |
| 105 | ASSERT_EQ(0u, index0); |
| 106 | ASSERT_EQ(1u, index1); |
| 107 | DexRegisterLocation location0 = location_catalog.GetDexRegisterLocation(index0); |
| 108 | DexRegisterLocation location1 = location_catalog.GetDexRegisterLocation(index1); |
| 109 | ASSERT_EQ(Kind::kInStack, location0.GetKind()); |
| 110 | ASSERT_EQ(Kind::kConstant, location1.GetKind()); |
| 111 | ASSERT_EQ(Kind::kInStack, location0.GetInternalKind()); |
| 112 | ASSERT_EQ(Kind::kConstantLargeValue, location1.GetInternalKind()); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 113 | ASSERT_EQ(0, location0.GetValue()); |
| 114 | ASSERT_EQ(-2, location1.GetValue()); |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 115 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 116 | ASSERT_FALSE(stack_map.HasInlineInfo(encoding)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 117 | } |
| 118 | |
| 119 | TEST(StackMapTest, Test2) { |
| 120 | ArenaPool pool; |
| 121 | ArenaAllocator arena(&pool); |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 122 | StackMapStream stream(&arena); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 123 | |
| 124 | ArenaBitVector sp_mask1(&arena, 0, true); |
| 125 | sp_mask1.SetBit(2); |
| 126 | sp_mask1.SetBit(4); |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 127 | size_t number_of_dex_registers = 2; |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 128 | size_t number_of_dex_registers_in_inline_info = 0; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 129 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask1, number_of_dex_registers, 2); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 130 | stream.AddDexRegisterEntry(Kind::kInStack, 0); // Short location. |
| 131 | stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location. |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 132 | stream.BeginInlineInfoEntry(82, 3, kDirect, number_of_dex_registers_in_inline_info); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 133 | stream.EndInlineInfoEntry(); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 134 | stream.BeginInlineInfoEntry(42, 2, kStatic, number_of_dex_registers_in_inline_info); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 135 | stream.EndInlineInfoEntry(); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 136 | stream.EndStackMapEntry(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 137 | |
| 138 | ArenaBitVector sp_mask2(&arena, 0, true); |
| 139 | sp_mask2.SetBit(3); |
David Brazdil | f10a25f | 2015-06-02 14:29:52 +0100 | [diff] [blame] | 140 | sp_mask2.SetBit(8); |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 141 | stream.BeginStackMapEntry(1, 128, 0xFF, &sp_mask2, number_of_dex_registers, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 142 | stream.AddDexRegisterEntry(Kind::kInRegister, 18); // Short location. |
| 143 | stream.AddDexRegisterEntry(Kind::kInFpuRegister, 3); // Short location. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 144 | stream.EndStackMapEntry(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 145 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 146 | size_t size = stream.PrepareForFillIn(); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 147 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 148 | MemoryRegion region(memory, size); |
| 149 | stream.FillIn(region); |
| 150 | |
Nicolas Geoffray | 3946844 | 2014-09-02 15:17:15 +0100 | [diff] [blame] | 151 | CodeInfo code_info(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 152 | StackMapEncoding encoding = code_info.ExtractEncoding(); |
| 153 | ASSERT_EQ(2u, encoding.NumberOfBytesForStackMask()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 154 | ASSERT_EQ(2u, code_info.GetNumberOfStackMaps()); |
| 155 | |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 156 | uint32_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 157 | ASSERT_EQ(4u, number_of_location_catalog_entries); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 158 | DexRegisterLocationCatalog location_catalog = code_info.GetDexRegisterLocationCatalog(encoding); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 159 | // The Dex register location catalog contains: |
| 160 | // - three 1-byte short Dex register locations, and |
| 161 | // - one 5-byte large Dex register location. |
| 162 | size_t expected_location_catalog_size = 3u * 1u + 5u; |
| 163 | ASSERT_EQ(expected_location_catalog_size, location_catalog.Size()); |
| 164 | |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 165 | // First stack map. |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 166 | { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 167 | StackMap stack_map = code_info.GetStackMapAt(0, encoding); |
| 168 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0, encoding))); |
| 169 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64, encoding))); |
| 170 | ASSERT_EQ(0u, stack_map.GetDexPc(encoding)); |
| 171 | ASSERT_EQ(64u, stack_map.GetNativePcOffset(encoding)); |
| 172 | ASSERT_EQ(0x3u, stack_map.GetRegisterMask(encoding)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 173 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 174 | MemoryRegion stack_mask = stack_map.GetStackMask(encoding); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 175 | ASSERT_TRUE(SameBits(stack_mask, sp_mask1)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 176 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 177 | ASSERT_TRUE(stack_map.HasDexRegisterMap(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 178 | DexRegisterMap dex_register_map = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 179 | code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 180 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(0)); |
| 181 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(1)); |
| 182 | ASSERT_EQ(2u, dex_register_map.GetNumberOfLiveDexRegisters(number_of_dex_registers)); |
| 183 | // The Dex register map contains: |
| 184 | // - one 1-byte live bit mask, and |
| 185 | // - one 1-byte set of location catalog entry indices composed of two 2-bit values. |
| 186 | size_t expected_dex_register_map_size = 1u + 1u; |
| 187 | ASSERT_EQ(expected_dex_register_map_size, dex_register_map.Size()); |
| 188 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 189 | ASSERT_EQ(Kind::kInStack, dex_register_map.GetLocationKind( |
| 190 | 0, number_of_dex_registers, code_info, encoding)); |
| 191 | ASSERT_EQ(Kind::kConstant, dex_register_map.GetLocationKind( |
| 192 | 1, number_of_dex_registers, code_info, encoding)); |
| 193 | ASSERT_EQ(Kind::kInStack, dex_register_map.GetLocationInternalKind( |
| 194 | 0, number_of_dex_registers, code_info, encoding)); |
| 195 | ASSERT_EQ(Kind::kConstantLargeValue, dex_register_map.GetLocationInternalKind( |
| 196 | 1, number_of_dex_registers, code_info, encoding)); |
| 197 | ASSERT_EQ(0, dex_register_map.GetStackOffsetInBytes( |
| 198 | 0, number_of_dex_registers, code_info, encoding)); |
| 199 | ASSERT_EQ(-2, dex_register_map.GetConstant(1, number_of_dex_registers, code_info, encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 200 | |
| 201 | size_t index0 = dex_register_map.GetLocationCatalogEntryIndex( |
| 202 | 0, number_of_dex_registers, number_of_location_catalog_entries); |
| 203 | size_t index1 = dex_register_map.GetLocationCatalogEntryIndex( |
| 204 | 1, number_of_dex_registers, number_of_location_catalog_entries); |
| 205 | ASSERT_EQ(0u, index0); |
| 206 | ASSERT_EQ(1u, index1); |
| 207 | DexRegisterLocation location0 = location_catalog.GetDexRegisterLocation(index0); |
| 208 | DexRegisterLocation location1 = location_catalog.GetDexRegisterLocation(index1); |
| 209 | ASSERT_EQ(Kind::kInStack, location0.GetKind()); |
| 210 | ASSERT_EQ(Kind::kConstant, location1.GetKind()); |
| 211 | ASSERT_EQ(Kind::kInStack, location0.GetInternalKind()); |
| 212 | ASSERT_EQ(Kind::kConstantLargeValue, location1.GetInternalKind()); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 213 | ASSERT_EQ(0, location0.GetValue()); |
| 214 | ASSERT_EQ(-2, location1.GetValue()); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 215 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 216 | ASSERT_TRUE(stack_map.HasInlineInfo(encoding)); |
| 217 | InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map, encoding); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 218 | ASSERT_EQ(2u, inline_info.GetDepth()); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 219 | ASSERT_EQ(82u, inline_info.GetMethodIndexAtDepth(0)); |
| 220 | ASSERT_EQ(42u, inline_info.GetMethodIndexAtDepth(1)); |
| 221 | ASSERT_EQ(3u, inline_info.GetDexPcAtDepth(0)); |
| 222 | ASSERT_EQ(2u, inline_info.GetDexPcAtDepth(1)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 223 | ASSERT_EQ(kDirect, inline_info.GetInvokeTypeAtDepth(0)); |
| 224 | ASSERT_EQ(kStatic, inline_info.GetInvokeTypeAtDepth(1)); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 225 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 226 | |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 227 | // Second stack map. |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 228 | { |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 229 | StackMap stack_map = code_info.GetStackMapAt(1, encoding); |
| 230 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(1u, encoding))); |
| 231 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(128u, encoding))); |
| 232 | ASSERT_EQ(1u, stack_map.GetDexPc(encoding)); |
| 233 | ASSERT_EQ(128u, stack_map.GetNativePcOffset(encoding)); |
| 234 | ASSERT_EQ(0xFFu, stack_map.GetRegisterMask(encoding)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 235 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 236 | MemoryRegion stack_mask = stack_map.GetStackMask(encoding); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 237 | ASSERT_TRUE(SameBits(stack_mask, sp_mask2)); |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 238 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 239 | ASSERT_TRUE(stack_map.HasDexRegisterMap(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 240 | DexRegisterMap dex_register_map = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 241 | code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 242 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(0)); |
| 243 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(1)); |
| 244 | ASSERT_EQ(2u, dex_register_map.GetNumberOfLiveDexRegisters(number_of_dex_registers)); |
| 245 | // The Dex register map contains: |
| 246 | // - one 1-byte live bit mask, and |
| 247 | // - one 1-byte set of location catalog entry indices composed of two 2-bit values. |
| 248 | size_t expected_dex_register_map_size = 1u + 1u; |
| 249 | ASSERT_EQ(expected_dex_register_map_size, dex_register_map.Size()); |
| 250 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 251 | ASSERT_EQ(Kind::kInRegister, dex_register_map.GetLocationKind( |
| 252 | 0, number_of_dex_registers, code_info, encoding)); |
| 253 | ASSERT_EQ(Kind::kInFpuRegister, dex_register_map.GetLocationKind( |
| 254 | 1, number_of_dex_registers, code_info, encoding)); |
| 255 | ASSERT_EQ(Kind::kInRegister, dex_register_map.GetLocationInternalKind( |
| 256 | 0, number_of_dex_registers, code_info, encoding)); |
| 257 | ASSERT_EQ(Kind::kInFpuRegister, dex_register_map.GetLocationInternalKind( |
| 258 | 1, number_of_dex_registers, code_info, encoding)); |
| 259 | ASSERT_EQ(18, dex_register_map.GetMachineRegister( |
| 260 | 0, number_of_dex_registers, code_info, encoding)); |
| 261 | ASSERT_EQ(3, dex_register_map.GetMachineRegister( |
| 262 | 1, number_of_dex_registers, code_info, encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 263 | |
| 264 | size_t index0 = dex_register_map.GetLocationCatalogEntryIndex( |
| 265 | 0, number_of_dex_registers, number_of_location_catalog_entries); |
| 266 | size_t index1 = dex_register_map.GetLocationCatalogEntryIndex( |
| 267 | 1, number_of_dex_registers, number_of_location_catalog_entries); |
| 268 | ASSERT_EQ(2u, index0); |
| 269 | ASSERT_EQ(3u, index1); |
| 270 | DexRegisterLocation location0 = location_catalog.GetDexRegisterLocation(index0); |
| 271 | DexRegisterLocation location1 = location_catalog.GetDexRegisterLocation(index1); |
| 272 | ASSERT_EQ(Kind::kInRegister, location0.GetKind()); |
| 273 | ASSERT_EQ(Kind::kInFpuRegister, location1.GetKind()); |
| 274 | ASSERT_EQ(Kind::kInRegister, location0.GetInternalKind()); |
| 275 | ASSERT_EQ(Kind::kInFpuRegister, location1.GetInternalKind()); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 276 | ASSERT_EQ(18, location0.GetValue()); |
| 277 | ASSERT_EQ(3, location1.GetValue()); |
Roland Levillain | 12baf47 | 2015-03-05 12:41:42 +0000 | [diff] [blame] | 278 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 279 | ASSERT_FALSE(stack_map.HasInlineInfo(encoding)); |
Roland Levillain | a2d8ec6 | 2015-03-12 15:25:29 +0000 | [diff] [blame] | 280 | } |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 281 | } |
| 282 | |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 283 | TEST(StackMapTest, TestNonLiveDexRegisters) { |
| 284 | ArenaPool pool; |
| 285 | ArenaAllocator arena(&pool); |
| 286 | StackMapStream stream(&arena); |
| 287 | |
| 288 | ArenaBitVector sp_mask(&arena, 0, false); |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 289 | uint32_t number_of_dex_registers = 2; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 290 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 291 | stream.AddDexRegisterEntry(Kind::kNone, 0); // No location. |
| 292 | stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 293 | stream.EndStackMapEntry(); |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 294 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 295 | size_t size = stream.PrepareForFillIn(); |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 296 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 297 | MemoryRegion region(memory, size); |
| 298 | stream.FillIn(region); |
| 299 | |
| 300 | CodeInfo code_info(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 301 | StackMapEncoding encoding = code_info.ExtractEncoding(); |
| 302 | ASSERT_EQ(0u, encoding.NumberOfBytesForStackMask()); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 303 | ASSERT_EQ(1u, code_info.GetNumberOfStackMaps()); |
| 304 | |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 305 | uint32_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 306 | ASSERT_EQ(1u, number_of_location_catalog_entries); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 307 | DexRegisterLocationCatalog location_catalog = code_info.GetDexRegisterLocationCatalog(encoding); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 308 | // The Dex register location catalog contains: |
| 309 | // - one 5-byte large Dex register location. |
| 310 | size_t expected_location_catalog_size = 5u; |
| 311 | ASSERT_EQ(expected_location_catalog_size, location_catalog.Size()); |
| 312 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 313 | StackMap stack_map = code_info.GetStackMapAt(0, encoding); |
| 314 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0, encoding))); |
| 315 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64, encoding))); |
| 316 | ASSERT_EQ(0u, stack_map.GetDexPc(encoding)); |
| 317 | ASSERT_EQ(64u, stack_map.GetNativePcOffset(encoding)); |
| 318 | ASSERT_EQ(0x3u, stack_map.GetRegisterMask(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 319 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 320 | ASSERT_TRUE(stack_map.HasDexRegisterMap(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 321 | DexRegisterMap dex_register_map = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 322 | code_info.GetDexRegisterMapOf(stack_map, encoding, number_of_dex_registers); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 323 | ASSERT_FALSE(dex_register_map.IsDexRegisterLive(0)); |
| 324 | ASSERT_TRUE(dex_register_map.IsDexRegisterLive(1)); |
| 325 | ASSERT_EQ(1u, dex_register_map.GetNumberOfLiveDexRegisters(number_of_dex_registers)); |
| 326 | // The Dex register map contains: |
| 327 | // - one 1-byte live bit mask. |
| 328 | // No space is allocated for the sole location catalog entry index, as it is useless. |
| 329 | size_t expected_dex_register_map_size = 1u + 0u; |
| 330 | ASSERT_EQ(expected_dex_register_map_size, dex_register_map.Size()); |
| 331 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 332 | ASSERT_EQ(Kind::kNone, dex_register_map.GetLocationKind( |
| 333 | 0, number_of_dex_registers, code_info, encoding)); |
| 334 | ASSERT_EQ(Kind::kConstant, dex_register_map.GetLocationKind( |
| 335 | 1, number_of_dex_registers, code_info, encoding)); |
| 336 | ASSERT_EQ(Kind::kNone, dex_register_map.GetLocationInternalKind( |
| 337 | 0, number_of_dex_registers, code_info, encoding)); |
| 338 | ASSERT_EQ(Kind::kConstantLargeValue, dex_register_map.GetLocationInternalKind( |
| 339 | 1, number_of_dex_registers, code_info, encoding)); |
| 340 | ASSERT_EQ(-2, dex_register_map.GetConstant(1, number_of_dex_registers, code_info, encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 341 | |
| 342 | size_t index0 = dex_register_map.GetLocationCatalogEntryIndex( |
| 343 | 0, number_of_dex_registers, number_of_location_catalog_entries); |
| 344 | size_t index1 = dex_register_map.GetLocationCatalogEntryIndex( |
| 345 | 1, number_of_dex_registers, number_of_location_catalog_entries); |
| 346 | ASSERT_EQ(DexRegisterLocationCatalog::kNoLocationEntryIndex, index0); |
| 347 | ASSERT_EQ(0u, index1); |
| 348 | DexRegisterLocation location0 = location_catalog.GetDexRegisterLocation(index0); |
| 349 | DexRegisterLocation location1 = location_catalog.GetDexRegisterLocation(index1); |
| 350 | ASSERT_EQ(Kind::kNone, location0.GetKind()); |
| 351 | ASSERT_EQ(Kind::kConstant, location1.GetKind()); |
| 352 | ASSERT_EQ(Kind::kNone, location0.GetInternalKind()); |
| 353 | ASSERT_EQ(Kind::kConstantLargeValue, location1.GetInternalKind()); |
| 354 | ASSERT_EQ(0, location0.GetValue()); |
| 355 | ASSERT_EQ(-2, location1.GetValue()); |
| 356 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 357 | ASSERT_FALSE(stack_map.HasInlineInfo(encoding)); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 358 | } |
| 359 | |
| 360 | // Generate a stack map whose dex register offset is |
| 361 | // StackMap::kNoDexRegisterMapSmallEncoding, and ensure we do |
| 362 | // not treat it as kNoDexRegisterMap. |
| 363 | TEST(StackMapTest, DexRegisterMapOffsetOverflow) { |
| 364 | ArenaPool pool; |
| 365 | ArenaAllocator arena(&pool); |
| 366 | StackMapStream stream(&arena); |
| 367 | |
| 368 | ArenaBitVector sp_mask(&arena, 0, false); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 369 | uint32_t number_of_dex_registers = 1024; |
| 370 | // Create the first stack map (and its Dex register map). |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 371 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 372 | uint32_t number_of_dex_live_registers_in_dex_register_map_0 = number_of_dex_registers - 8; |
| 373 | for (uint32_t i = 0; i < number_of_dex_live_registers_in_dex_register_map_0; ++i) { |
| 374 | // Use two different Dex register locations to populate this map, |
| 375 | // as using a single value (in the whole CodeInfo object) would |
| 376 | // make this Dex register mapping data empty (see |
| 377 | // art::DexRegisterMap::SingleEntrySizeInBits). |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 378 | stream.AddDexRegisterEntry(Kind::kConstant, i % 2); // Short location. |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 379 | } |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 380 | stream.EndStackMapEntry(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 381 | // Create the second stack map (and its Dex register map). |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 382 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 383 | for (uint32_t i = 0; i < number_of_dex_registers; ++i) { |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 384 | stream.AddDexRegisterEntry(Kind::kConstant, 0); // Short location. |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 385 | } |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 386 | stream.EndStackMapEntry(); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 387 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 388 | size_t size = stream.PrepareForFillIn(); |
Nicolas Geoffray | 004c230 | 2015-03-20 10:06:38 +0000 | [diff] [blame] | 389 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 390 | MemoryRegion region(memory, size); |
| 391 | stream.FillIn(region); |
| 392 | |
| 393 | CodeInfo code_info(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 394 | StackMapEncoding encoding = code_info.ExtractEncoding(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 395 | // The location catalog contains two entries (DexRegisterLocation(kConstant, 0) |
| 396 | // and DexRegisterLocation(kConstant, 1)), therefore the location catalog index |
| 397 | // has a size of 1 bit. |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 398 | uint32_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 399 | ASSERT_EQ(2u, number_of_location_catalog_entries); |
| 400 | ASSERT_EQ(1u, DexRegisterMap::SingleEntrySizeInBits(number_of_location_catalog_entries)); |
| 401 | |
| 402 | // The first Dex register map contains: |
| 403 | // - a live register bit mask for 1024 registers (that is, 128 bytes of |
| 404 | // data); and |
| 405 | // - Dex register mapping information for 1016 1-bit Dex (live) register |
| 406 | // locations (that is, 127 bytes of data). |
| 407 | // Hence it has a size of 255 bytes, and therefore... |
| 408 | ASSERT_EQ(128u, DexRegisterMap::GetLiveBitMaskSize(number_of_dex_registers)); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 409 | StackMap stack_map0 = code_info.GetStackMapAt(0, encoding); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 410 | DexRegisterMap dex_register_map0 = |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 411 | code_info.GetDexRegisterMapOf(stack_map0, encoding, number_of_dex_registers); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 412 | ASSERT_EQ(127u, dex_register_map0.GetLocationMappingDataSize(number_of_dex_registers, |
| 413 | number_of_location_catalog_entries)); |
| 414 | ASSERT_EQ(255u, dex_register_map0.Size()); |
| 415 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 416 | StackMap stack_map1 = code_info.GetStackMapAt(1, encoding); |
| 417 | ASSERT_TRUE(stack_map1.HasDexRegisterMap(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 418 | // ...the offset of the second Dex register map (relative to the |
| 419 | // beginning of the Dex register maps region) is 255 (i.e., |
| 420 | // kNoDexRegisterMapSmallEncoding). |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 421 | ASSERT_NE(stack_map1.GetDexRegisterMapOffset(encoding), StackMap::kNoDexRegisterMap); |
| 422 | ASSERT_EQ(stack_map1.GetDexRegisterMapOffset(encoding), 0xFFu); |
Nicolas Geoffray | fead4e4 | 2015-03-13 14:39:40 +0000 | [diff] [blame] | 423 | } |
| 424 | |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 425 | TEST(StackMapTest, TestShareDexRegisterMap) { |
| 426 | ArenaPool pool; |
| 427 | ArenaAllocator arena(&pool); |
| 428 | StackMapStream stream(&arena); |
| 429 | |
| 430 | ArenaBitVector sp_mask(&arena, 0, false); |
| 431 | uint32_t number_of_dex_registers = 2; |
| 432 | // First stack map. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 433 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 434 | stream.AddDexRegisterEntry(Kind::kInRegister, 0); // Short location. |
| 435 | stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 436 | stream.EndStackMapEntry(); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 437 | // Second stack map, which should share the same dex register map. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 438 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 439 | stream.AddDexRegisterEntry(Kind::kInRegister, 0); // Short location. |
| 440 | stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 441 | stream.EndStackMapEntry(); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 442 | // Third stack map (doesn't share the dex register map). |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 443 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 444 | stream.AddDexRegisterEntry(Kind::kInRegister, 2); // Short location. |
| 445 | stream.AddDexRegisterEntry(Kind::kConstant, -2); // Large location. |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 446 | stream.EndStackMapEntry(); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 447 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 448 | size_t size = stream.PrepareForFillIn(); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 449 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 450 | MemoryRegion region(memory, size); |
| 451 | stream.FillIn(region); |
| 452 | |
| 453 | CodeInfo ci(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 454 | StackMapEncoding encoding = ci.ExtractEncoding(); |
| 455 | |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 456 | // Verify first stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 457 | StackMap sm0 = ci.GetStackMapAt(0, encoding); |
| 458 | DexRegisterMap dex_registers0 = ci.GetDexRegisterMapOf(sm0, encoding, number_of_dex_registers); |
| 459 | ASSERT_EQ(0, dex_registers0.GetMachineRegister(0, number_of_dex_registers, ci, encoding)); |
| 460 | ASSERT_EQ(-2, dex_registers0.GetConstant(1, number_of_dex_registers, ci, encoding)); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 461 | |
| 462 | // Verify second stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 463 | StackMap sm1 = ci.GetStackMapAt(1, encoding); |
| 464 | DexRegisterMap dex_registers1 = ci.GetDexRegisterMapOf(sm1, encoding, number_of_dex_registers); |
| 465 | ASSERT_EQ(0, dex_registers1.GetMachineRegister(0, number_of_dex_registers, ci, encoding)); |
| 466 | ASSERT_EQ(-2, dex_registers1.GetConstant(1, number_of_dex_registers, ci, encoding)); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 467 | |
| 468 | // Verify third stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 469 | StackMap sm2 = ci.GetStackMapAt(2, encoding); |
| 470 | DexRegisterMap dex_registers2 = ci.GetDexRegisterMapOf(sm2, encoding, number_of_dex_registers); |
| 471 | ASSERT_EQ(2, dex_registers2.GetMachineRegister(0, number_of_dex_registers, ci, encoding)); |
| 472 | ASSERT_EQ(-2, dex_registers2.GetConstant(1, number_of_dex_registers, ci, encoding)); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 473 | |
| 474 | // Verify dex register map offsets. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 475 | ASSERT_EQ(sm0.GetDexRegisterMapOffset(encoding), sm1.GetDexRegisterMapOffset(encoding)); |
| 476 | ASSERT_NE(sm0.GetDexRegisterMapOffset(encoding), sm2.GetDexRegisterMapOffset(encoding)); |
| 477 | ASSERT_NE(sm1.GetDexRegisterMapOffset(encoding), sm2.GetDexRegisterMapOffset(encoding)); |
Calin Juravle | 6ae7096 | 2015-03-18 16:31:28 +0000 | [diff] [blame] | 478 | } |
| 479 | |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 480 | TEST(StackMapTest, TestNoDexRegisterMap) { |
| 481 | ArenaPool pool; |
| 482 | ArenaAllocator arena(&pool); |
| 483 | StackMapStream stream(&arena); |
| 484 | |
| 485 | ArenaBitVector sp_mask(&arena, 0, false); |
| 486 | uint32_t number_of_dex_registers = 0; |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 487 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask, number_of_dex_registers, 0); |
| 488 | stream.EndStackMapEntry(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 489 | |
Calin Juravle | 4f46ac5 | 2015-04-23 18:47:21 +0100 | [diff] [blame] | 490 | size_t size = stream.PrepareForFillIn(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 491 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 492 | MemoryRegion region(memory, size); |
| 493 | stream.FillIn(region); |
| 494 | |
| 495 | CodeInfo code_info(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 496 | StackMapEncoding encoding = code_info.ExtractEncoding(); |
| 497 | ASSERT_EQ(0u, encoding.NumberOfBytesForStackMask()); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 498 | ASSERT_EQ(1u, code_info.GetNumberOfStackMaps()); |
| 499 | |
Roland Levillain | 1c1da43 | 2015-07-16 11:54:44 +0100 | [diff] [blame] | 500 | uint32_t number_of_location_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 501 | ASSERT_EQ(0u, number_of_location_catalog_entries); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 502 | DexRegisterLocationCatalog location_catalog = code_info.GetDexRegisterLocationCatalog(encoding); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 503 | ASSERT_EQ(0u, location_catalog.Size()); |
| 504 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 505 | StackMap stack_map = code_info.GetStackMapAt(0, encoding); |
| 506 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForDexPc(0, encoding))); |
| 507 | ASSERT_TRUE(stack_map.Equals(code_info.GetStackMapForNativePcOffset(64, encoding))); |
| 508 | ASSERT_EQ(0u, stack_map.GetDexPc(encoding)); |
| 509 | ASSERT_EQ(64u, stack_map.GetNativePcOffset(encoding)); |
| 510 | ASSERT_EQ(0x3u, stack_map.GetRegisterMask(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 511 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 512 | ASSERT_FALSE(stack_map.HasDexRegisterMap(encoding)); |
| 513 | ASSERT_FALSE(stack_map.HasInlineInfo(encoding)); |
Roland Levillain | a552e1c | 2015-03-26 15:01:03 +0000 | [diff] [blame] | 514 | } |
| 515 | |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 516 | TEST(StackMapTest, InlineTest) { |
| 517 | ArenaPool pool; |
| 518 | ArenaAllocator arena(&pool); |
| 519 | StackMapStream stream(&arena); |
| 520 | |
| 521 | ArenaBitVector sp_mask1(&arena, 0, true); |
| 522 | sp_mask1.SetBit(2); |
| 523 | sp_mask1.SetBit(4); |
| 524 | |
| 525 | // First stack map. |
| 526 | stream.BeginStackMapEntry(0, 64, 0x3, &sp_mask1, 2, 2); |
| 527 | stream.AddDexRegisterEntry(Kind::kInStack, 0); |
| 528 | stream.AddDexRegisterEntry(Kind::kConstant, 4); |
| 529 | |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 530 | stream.BeginInlineInfoEntry(42, 2, kStatic, 1); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 531 | stream.AddDexRegisterEntry(Kind::kInStack, 8); |
| 532 | stream.EndInlineInfoEntry(); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 533 | stream.BeginInlineInfoEntry(82, 3, kStatic, 3); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 534 | stream.AddDexRegisterEntry(Kind::kInStack, 16); |
| 535 | stream.AddDexRegisterEntry(Kind::kConstant, 20); |
| 536 | stream.AddDexRegisterEntry(Kind::kInRegister, 15); |
| 537 | stream.EndInlineInfoEntry(); |
| 538 | |
| 539 | stream.EndStackMapEntry(); |
| 540 | |
| 541 | // Second stack map. |
| 542 | stream.BeginStackMapEntry(2, 22, 0x3, &sp_mask1, 2, 3); |
| 543 | stream.AddDexRegisterEntry(Kind::kInStack, 56); |
| 544 | stream.AddDexRegisterEntry(Kind::kConstant, 0); |
| 545 | |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 546 | stream.BeginInlineInfoEntry(42, 2, kDirect, 1); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 547 | stream.AddDexRegisterEntry(Kind::kInStack, 12); |
| 548 | stream.EndInlineInfoEntry(); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 549 | stream.BeginInlineInfoEntry(82, 3, kStatic, 3); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 550 | stream.AddDexRegisterEntry(Kind::kInStack, 80); |
| 551 | stream.AddDexRegisterEntry(Kind::kConstant, 10); |
| 552 | stream.AddDexRegisterEntry(Kind::kInRegister, 5); |
| 553 | stream.EndInlineInfoEntry(); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 554 | stream.BeginInlineInfoEntry(52, 5, kVirtual, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 555 | stream.EndInlineInfoEntry(); |
| 556 | |
| 557 | stream.EndStackMapEntry(); |
| 558 | |
| 559 | // Third stack map. |
| 560 | stream.BeginStackMapEntry(4, 56, 0x3, &sp_mask1, 2, 0); |
| 561 | stream.AddDexRegisterEntry(Kind::kNone, 0); |
| 562 | stream.AddDexRegisterEntry(Kind::kConstant, 4); |
| 563 | stream.EndStackMapEntry(); |
| 564 | |
| 565 | // Fourth stack map. |
| 566 | stream.BeginStackMapEntry(6, 78, 0x3, &sp_mask1, 2, 3); |
| 567 | stream.AddDexRegisterEntry(Kind::kInStack, 56); |
| 568 | stream.AddDexRegisterEntry(Kind::kConstant, 0); |
| 569 | |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 570 | stream.BeginInlineInfoEntry(42, 2, kVirtual, 0); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 571 | stream.EndInlineInfoEntry(); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 572 | stream.BeginInlineInfoEntry(52, 5, kInterface, 1); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 573 | stream.AddDexRegisterEntry(Kind::kInRegister, 2); |
| 574 | stream.EndInlineInfoEntry(); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 575 | stream.BeginInlineInfoEntry(52, 10, kStatic, 2); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 576 | stream.AddDexRegisterEntry(Kind::kNone, 0); |
| 577 | stream.AddDexRegisterEntry(Kind::kInRegister, 3); |
| 578 | stream.EndInlineInfoEntry(); |
| 579 | |
| 580 | stream.EndStackMapEntry(); |
| 581 | |
| 582 | size_t size = stream.PrepareForFillIn(); |
| 583 | void* memory = arena.Alloc(size, kArenaAllocMisc); |
| 584 | MemoryRegion region(memory, size); |
| 585 | stream.FillIn(region); |
| 586 | |
| 587 | CodeInfo ci(region); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 588 | StackMapEncoding encoding = ci.ExtractEncoding(); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 589 | |
| 590 | { |
| 591 | // Verify first stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 592 | StackMap sm0 = ci.GetStackMapAt(0, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 593 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 594 | DexRegisterMap dex_registers0 = ci.GetDexRegisterMapOf(sm0, encoding, 2); |
| 595 | ASSERT_EQ(0, dex_registers0.GetStackOffsetInBytes(0, 2, ci, encoding)); |
| 596 | ASSERT_EQ(4, dex_registers0.GetConstant(1, 2, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 597 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 598 | InlineInfo if0 = ci.GetInlineInfoOf(sm0, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 599 | ASSERT_EQ(2u, if0.GetDepth()); |
| 600 | ASSERT_EQ(2u, if0.GetDexPcAtDepth(0)); |
| 601 | ASSERT_EQ(42u, if0.GetMethodIndexAtDepth(0)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 602 | ASSERT_EQ(kStatic, if0.GetInvokeTypeAtDepth(0)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 603 | ASSERT_EQ(3u, if0.GetDexPcAtDepth(1)); |
| 604 | ASSERT_EQ(82u, if0.GetMethodIndexAtDepth(1)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 605 | ASSERT_EQ(kStatic, if0.GetInvokeTypeAtDepth(1)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 606 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 607 | DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(0, if0, encoding, 1); |
| 608 | ASSERT_EQ(8, dex_registers1.GetStackOffsetInBytes(0, 1, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 609 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 610 | DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(1, if0, encoding, 3); |
| 611 | ASSERT_EQ(16, dex_registers2.GetStackOffsetInBytes(0, 3, ci, encoding)); |
| 612 | ASSERT_EQ(20, dex_registers2.GetConstant(1, 3, ci, encoding)); |
| 613 | ASSERT_EQ(15, dex_registers2.GetMachineRegister(2, 3, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 614 | } |
| 615 | |
| 616 | { |
| 617 | // Verify second stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 618 | StackMap sm1 = ci.GetStackMapAt(1, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 619 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 620 | DexRegisterMap dex_registers0 = ci.GetDexRegisterMapOf(sm1, encoding, 2); |
| 621 | ASSERT_EQ(56, dex_registers0.GetStackOffsetInBytes(0, 2, ci, encoding)); |
| 622 | ASSERT_EQ(0, dex_registers0.GetConstant(1, 2, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 623 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 624 | InlineInfo if1 = ci.GetInlineInfoOf(sm1, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 625 | ASSERT_EQ(3u, if1.GetDepth()); |
| 626 | ASSERT_EQ(2u, if1.GetDexPcAtDepth(0)); |
| 627 | ASSERT_EQ(42u, if1.GetMethodIndexAtDepth(0)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 628 | ASSERT_EQ(kDirect, if1.GetInvokeTypeAtDepth(0)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 629 | ASSERT_EQ(3u, if1.GetDexPcAtDepth(1)); |
| 630 | ASSERT_EQ(82u, if1.GetMethodIndexAtDepth(1)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 631 | ASSERT_EQ(kStatic, if1.GetInvokeTypeAtDepth(1)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 632 | ASSERT_EQ(5u, if1.GetDexPcAtDepth(2)); |
| 633 | ASSERT_EQ(52u, if1.GetMethodIndexAtDepth(2)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 634 | ASSERT_EQ(kVirtual, if1.GetInvokeTypeAtDepth(2)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 635 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 636 | DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(0, if1, encoding, 1); |
| 637 | ASSERT_EQ(12, dex_registers1.GetStackOffsetInBytes(0, 1, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 638 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 639 | DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(1, if1, encoding, 3); |
| 640 | ASSERT_EQ(80, dex_registers2.GetStackOffsetInBytes(0, 3, ci, encoding)); |
| 641 | ASSERT_EQ(10, dex_registers2.GetConstant(1, 3, ci, encoding)); |
| 642 | ASSERT_EQ(5, dex_registers2.GetMachineRegister(2, 3, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 643 | |
| 644 | ASSERT_FALSE(if1.HasDexRegisterMapAtDepth(2)); |
| 645 | } |
| 646 | |
| 647 | { |
| 648 | // Verify third stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 649 | StackMap sm2 = ci.GetStackMapAt(2, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 650 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 651 | DexRegisterMap dex_registers0 = ci.GetDexRegisterMapOf(sm2, encoding, 2); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 652 | ASSERT_FALSE(dex_registers0.IsDexRegisterLive(0)); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 653 | ASSERT_EQ(4, dex_registers0.GetConstant(1, 2, ci, encoding)); |
| 654 | ASSERT_FALSE(sm2.HasInlineInfo(encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 655 | } |
| 656 | |
| 657 | { |
| 658 | // Verify fourth stack map. |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 659 | StackMap sm3 = ci.GetStackMapAt(3, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 660 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 661 | DexRegisterMap dex_registers0 = ci.GetDexRegisterMapOf(sm3, encoding, 2); |
| 662 | ASSERT_EQ(56, dex_registers0.GetStackOffsetInBytes(0, 2, ci, encoding)); |
| 663 | ASSERT_EQ(0, dex_registers0.GetConstant(1, 2, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 664 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 665 | InlineInfo if2 = ci.GetInlineInfoOf(sm3, encoding); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 666 | ASSERT_EQ(3u, if2.GetDepth()); |
| 667 | ASSERT_EQ(2u, if2.GetDexPcAtDepth(0)); |
| 668 | ASSERT_EQ(42u, if2.GetMethodIndexAtDepth(0)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 669 | ASSERT_EQ(kVirtual, if2.GetInvokeTypeAtDepth(0)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 670 | ASSERT_EQ(5u, if2.GetDexPcAtDepth(1)); |
| 671 | ASSERT_EQ(52u, if2.GetMethodIndexAtDepth(1)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 672 | ASSERT_EQ(kInterface, if2.GetInvokeTypeAtDepth(1)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 673 | ASSERT_EQ(10u, if2.GetDexPcAtDepth(2)); |
| 674 | ASSERT_EQ(52u, if2.GetMethodIndexAtDepth(2)); |
Nicolas Geoffray | b176d7c | 2015-05-20 18:48:31 +0100 | [diff] [blame] | 675 | ASSERT_EQ(kStatic, if2.GetInvokeTypeAtDepth(2)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 676 | |
| 677 | ASSERT_FALSE(if2.HasDexRegisterMapAtDepth(0)); |
| 678 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 679 | DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(1, if2, encoding, 1); |
| 680 | ASSERT_EQ(2, dex_registers1.GetMachineRegister(0, 1, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 681 | |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 682 | DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(2, if2, encoding, 2); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 683 | ASSERT_FALSE(dex_registers2.IsDexRegisterLive(0)); |
David Brazdil | f677ebf | 2015-05-29 16:29:43 +0100 | [diff] [blame] | 684 | ASSERT_EQ(3, dex_registers2.GetMachineRegister(1, 2, ci, encoding)); |
Nicolas Geoffray | b1d0f3f | 2015-05-14 12:41:51 +0100 | [diff] [blame] | 685 | } |
| 686 | } |
| 687 | |
Nicolas Geoffray | 99ea58c | 2014-07-02 15:08:17 +0100 | [diff] [blame] | 688 | } // namespace art |