summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
Diffstat (limited to 'compiler')
-rw-r--r--compiler/optimizing/stack_map_stream.cc45
-rw-r--r--compiler/optimizing/stack_map_stream.h4
-rw-r--r--compiler/optimizing/stack_map_test.cc84
3 files changed, 67 insertions, 66 deletions
diff --git a/compiler/optimizing/stack_map_stream.cc b/compiler/optimizing/stack_map_stream.cc
index d99beac59f..d80e2fc0e3 100644
--- a/compiler/optimizing/stack_map_stream.cc
+++ b/compiler/optimizing/stack_map_stream.cc
@@ -65,7 +65,7 @@ void StackMapStream::BeginStackMapEntry(uint32_t dex_pc,
// and it might modify the data before that. Therefore, just store the pointer.
// See ClearSpillSlotsFromLoopPhisInStackMap in code_generator.h.
lazy_stack_masks_.push_back(stack_mask);
- current_inline_infos_ = 0;
+ current_inline_infos_.clear();
current_dex_registers_.clear();
expected_num_dex_registers_ = num_dex_registers;
@@ -84,9 +84,7 @@ void StackMapStream::BeginStackMapEntry(uint32_t dex_pc,
CHECK_EQ(seen_stack_mask.LoadBit(b), stack_mask != nullptr && stack_mask->IsBitSet(b));
}
CHECK_EQ(stack_map.HasInlineInfo(), (inlining_depth != 0));
- if (inlining_depth != 0) {
- CHECK_EQ(code_info.GetInlineInfoOf(stack_map).GetDepth(), inlining_depth);
- }
+ CHECK_EQ(code_info.GetInlineDepthOf(stack_map), inlining_depth);
CHECK_EQ(stack_map.HasDexRegisterMap(), (num_dex_registers != 0));
});
}
@@ -97,9 +95,11 @@ void StackMapStream::EndStackMapEntry() {
in_stack_map_ = false;
DCHECK_EQ(expected_num_dex_registers_, current_dex_registers_.size());
- // Mark the last inline info as last in the list for the stack map.
- if (current_inline_infos_ > 0) {
- inline_infos_[inline_infos_.size() - 1].is_last = InlineInfo::kLast;
+ // Generate index into the InlineInfo table.
+ if (!current_inline_infos_.empty()) {
+ current_inline_infos_.back().is_last = InlineInfo::kLast;
+ current_stack_map_.inline_info_index =
+ inline_infos_.Dedup(current_inline_infos_.data(), current_inline_infos_.size());
}
stack_maps_.Add(current_stack_map_);
@@ -162,30 +162,27 @@ void StackMapStream::BeginInlineInfoEntry(ArtMethod* method,
uint32_t dex_method_index = method->GetDexMethodIndexUnchecked();
entry.method_info_index = method_infos_.Dedup(&dex_method_index);
}
- if (current_inline_infos_++ == 0) {
- current_stack_map_.inline_info_index = inline_infos_.size();
- }
- inline_infos_.Add(entry);
+ current_inline_infos_.push_back(entry);
current_dex_registers_.clear();
expected_num_dex_registers_ = num_dex_registers;
if (kVerifyStackMaps) {
size_t stack_map_index = stack_maps_.size();
- size_t depth = current_inline_infos_ - 1;
+ size_t depth = current_inline_infos_.size() - 1;
dchecks_.emplace_back([=](const CodeInfo& code_info) {
StackMap stack_map = code_info.GetStackMapAt(stack_map_index);
- InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map);
- CHECK_EQ(inline_info.GetDexPcAtDepth(depth), dex_pc);
+ InlineInfo inline_info = code_info.GetInlineInfoAtDepth(stack_map, depth);
+ CHECK_EQ(inline_info.GetDexPc(), dex_pc);
bool encode_art_method = EncodeArtMethodInInlineInfo(method);
- CHECK_EQ(inline_info.EncodesArtMethodAtDepth(depth), encode_art_method);
+ CHECK_EQ(inline_info.EncodesArtMethod(), encode_art_method);
if (encode_art_method) {
- CHECK_EQ(inline_info.GetArtMethodAtDepth(depth), method);
+ CHECK_EQ(inline_info.GetArtMethod(), method);
} else {
- CHECK_EQ(method_infos_[inline_info.GetMethodIndexIdxAtDepth(depth)],
+ CHECK_EQ(method_infos_[inline_info.GetMethodIndexIdx()],
method->GetDexMethodIndexUnchecked());
}
- CHECK_EQ(inline_info.HasDexRegisterMapAtDepth(depth), (num_dex_registers != 0));
+ CHECK_EQ(inline_info.HasDexRegisterMap(), (num_dex_registers != 0));
});
}
}
@@ -222,9 +219,9 @@ void StackMapStream::CreateDexRegisterMap() {
}
uint32_t map_index = dex_register_maps_.Dedup(temp_dex_register_map_.data(),
temp_dex_register_map_.size());
- if (current_inline_infos_ > 0) {
- inline_infos_[inline_infos_.size() - 1].dex_register_mask_index = mask_index;
- inline_infos_[inline_infos_.size() - 1].dex_register_map_index = map_index;
+ if (!current_inline_infos_.empty()) {
+ current_inline_infos_.back().dex_register_mask_index = mask_index;
+ current_inline_infos_.back().dex_register_map_index = map_index;
} else {
current_stack_map_.dex_register_mask_index = mask_index;
current_stack_map_.dex_register_map_index = map_index;
@@ -232,7 +229,7 @@ void StackMapStream::CreateDexRegisterMap() {
if (kVerifyStackMaps) {
size_t stack_map_index = stack_maps_.size();
- int32_t depth = current_inline_infos_ - 1;
+ int32_t depth = current_inline_infos_.size() - 1;
// We need to make copy of the current registers for later (when the check is run).
auto expected_dex_registers = std::make_shared<std::vector<DexRegisterLocation>>(
current_dex_registers_.begin(), current_dex_registers_.end());
@@ -241,9 +238,7 @@ void StackMapStream::CreateDexRegisterMap() {
size_t num_dex_registers = expected_dex_registers->size();
DexRegisterMap map = (depth == -1)
? code_info.GetDexRegisterMapOf(stack_map, num_dex_registers)
- : code_info.GetDexRegisterMapAtDepth(depth,
- code_info.GetInlineInfoOf(stack_map),
- num_dex_registers);
+ : code_info.GetDexRegisterMapAtDepth(depth, stack_map, num_dex_registers);
CHECK_EQ(map.size(), num_dex_registers);
for (size_t r = 0; r < num_dex_registers; r++) {
CHECK_EQ(expected_dex_registers->at(r), map.Get(r));
diff --git a/compiler/optimizing/stack_map_stream.h b/compiler/optimizing/stack_map_stream.h
index c758bca951..d634c703ff 100644
--- a/compiler/optimizing/stack_map_stream.h
+++ b/compiler/optimizing/stack_map_stream.h
@@ -53,7 +53,7 @@ class StackMapStream : public ValueObject {
lazy_stack_masks_(allocator->Adapter(kArenaAllocStackMapStream)),
in_stack_map_(false),
in_inline_info_(false),
- current_inline_infos_(0),
+ current_inline_infos_(allocator->Adapter(kArenaAllocStackMapStream)),
current_dex_registers_(allocator->Adapter(kArenaAllocStackMapStream)),
temp_dex_register_mask_(allocator, 32, true, kArenaAllocStackMapStream),
temp_dex_register_map_(allocator->Adapter(kArenaAllocStackMapStream)) {
@@ -157,7 +157,7 @@ class StackMapStream : public ValueObject {
bool in_stack_map_;
bool in_inline_info_;
StackMapEntry current_stack_map_;
- uint32_t current_inline_infos_;
+ ScopedArenaVector<InlineInfoEntry> current_inline_infos_;
ScopedArenaVector<DexRegisterLocation> current_dex_registers_;
size_t expected_num_dex_registers_;
diff --git a/compiler/optimizing/stack_map_test.cc b/compiler/optimizing/stack_map_test.cc
index 262c240bc7..77aa3ef965 100644
--- a/compiler/optimizing/stack_map_test.cc
+++ b/compiler/optimizing/stack_map_test.cc
@@ -189,12 +189,13 @@ TEST(StackMapTest, Test2) {
ASSERT_EQ(-2, location1.GetValue());
ASSERT_TRUE(stack_map.HasInlineInfo());
- InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map);
- ASSERT_EQ(2u, inline_info.GetDepth());
- ASSERT_EQ(3u, inline_info.GetDexPcAtDepth(0));
- ASSERT_EQ(2u, inline_info.GetDexPcAtDepth(1));
- ASSERT_TRUE(inline_info.EncodesArtMethodAtDepth(0));
- ASSERT_TRUE(inline_info.EncodesArtMethodAtDepth(1));
+ InlineInfo inline_info0 = code_info.GetInlineInfoAtDepth(stack_map, 0);
+ InlineInfo inline_info1 = code_info.GetInlineInfoAtDepth(stack_map, 1);
+ ASSERT_EQ(2u, code_info.GetInlineDepthOf(stack_map));
+ ASSERT_EQ(3u, inline_info0.GetDexPc());
+ ASSERT_EQ(2u, inline_info1.GetDexPc());
+ ASSERT_TRUE(inline_info0.EncodesArtMethod());
+ ASSERT_TRUE(inline_info1.EncodesArtMethod());
}
// Second stack map.
@@ -361,8 +362,8 @@ TEST(StackMapTest, TestDeduplicateInlineInfoDexRegisterMap) {
// Test that the inline info dex register map deduplicated to the same offset as the stack map
// one.
ASSERT_TRUE(stack_map.HasInlineInfo());
- InlineInfo inline_info = code_info.GetInlineInfoOf(stack_map);
- EXPECT_EQ(inline_info.GetDexRegisterMapIndexAtDepth(0),
+ InlineInfo inline_info = code_info.GetInlineInfoAtDepth(stack_map, 0);
+ EXPECT_EQ(inline_info.GetDexRegisterMapIndex(),
stack_map.GetDexRegisterMapIndex());
}
}
@@ -605,17 +606,18 @@ TEST(StackMapTest, InlineTest) {
ASSERT_EQ(0, dex_registers0.GetStackOffsetInBytes(0));
ASSERT_EQ(4, dex_registers0.GetConstant(1));
- InlineInfo if0 = ci.GetInlineInfoOf(sm0);
- ASSERT_EQ(2u, if0.GetDepth());
- ASSERT_EQ(2u, if0.GetDexPcAtDepth(0));
- ASSERT_TRUE(if0.EncodesArtMethodAtDepth(0));
- ASSERT_EQ(3u, if0.GetDexPcAtDepth(1));
- ASSERT_TRUE(if0.EncodesArtMethodAtDepth(1));
+ InlineInfo if0_0 = ci.GetInlineInfoAtDepth(sm0, 0);
+ InlineInfo if0_1 = ci.GetInlineInfoAtDepth(sm0, 1);
+ ASSERT_EQ(2u, ci.GetInlineDepthOf(sm0));
+ ASSERT_EQ(2u, if0_0.GetDexPc());
+ ASSERT_TRUE(if0_0.EncodesArtMethod());
+ ASSERT_EQ(3u, if0_1.GetDexPc());
+ ASSERT_TRUE(if0_1.EncodesArtMethod());
- DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(0, if0, 1);
+ DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(0, sm0, 1);
ASSERT_EQ(8, dex_registers1.GetStackOffsetInBytes(0));
- DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(1, if0, 3);
+ DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(1, sm0, 3);
ASSERT_EQ(16, dex_registers2.GetStackOffsetInBytes(0));
ASSERT_EQ(20, dex_registers2.GetConstant(1));
ASSERT_EQ(15, dex_registers2.GetMachineRegister(2));
@@ -629,24 +631,26 @@ TEST(StackMapTest, InlineTest) {
ASSERT_EQ(56, dex_registers0.GetStackOffsetInBytes(0));
ASSERT_EQ(0, dex_registers0.GetConstant(1));
- InlineInfo if1 = ci.GetInlineInfoOf(sm1);
- ASSERT_EQ(3u, if1.GetDepth());
- ASSERT_EQ(2u, if1.GetDexPcAtDepth(0));
- ASSERT_TRUE(if1.EncodesArtMethodAtDepth(0));
- ASSERT_EQ(3u, if1.GetDexPcAtDepth(1));
- ASSERT_TRUE(if1.EncodesArtMethodAtDepth(1));
- ASSERT_EQ(5u, if1.GetDexPcAtDepth(2));
- ASSERT_TRUE(if1.EncodesArtMethodAtDepth(2));
-
- DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(0, if1, 1);
+ InlineInfo if1_0 = ci.GetInlineInfoAtDepth(sm1, 0);
+ InlineInfo if1_1 = ci.GetInlineInfoAtDepth(sm1, 1);
+ InlineInfo if1_2 = ci.GetInlineInfoAtDepth(sm1, 2);
+ ASSERT_EQ(3u, ci.GetInlineDepthOf(sm1));
+ ASSERT_EQ(2u, if1_0.GetDexPc());
+ ASSERT_TRUE(if1_0.EncodesArtMethod());
+ ASSERT_EQ(3u, if1_1.GetDexPc());
+ ASSERT_TRUE(if1_1.EncodesArtMethod());
+ ASSERT_EQ(5u, if1_2.GetDexPc());
+ ASSERT_TRUE(if1_2.EncodesArtMethod());
+
+ DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(0, sm1, 1);
ASSERT_EQ(12, dex_registers1.GetStackOffsetInBytes(0));
- DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(1, if1, 3);
+ DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(1, sm1, 3);
ASSERT_EQ(80, dex_registers2.GetStackOffsetInBytes(0));
ASSERT_EQ(10, dex_registers2.GetConstant(1));
ASSERT_EQ(5, dex_registers2.GetMachineRegister(2));
- ASSERT_FALSE(if1.HasDexRegisterMapAtDepth(2));
+ ASSERT_FALSE(if1_2.HasDexRegisterMap());
}
{
@@ -667,21 +671,23 @@ TEST(StackMapTest, InlineTest) {
ASSERT_EQ(56, dex_registers0.GetStackOffsetInBytes(0));
ASSERT_EQ(0, dex_registers0.GetConstant(1));
- InlineInfo if2 = ci.GetInlineInfoOf(sm3);
- ASSERT_EQ(3u, if2.GetDepth());
- ASSERT_EQ(2u, if2.GetDexPcAtDepth(0));
- ASSERT_TRUE(if2.EncodesArtMethodAtDepth(0));
- ASSERT_EQ(5u, if2.GetDexPcAtDepth(1));
- ASSERT_TRUE(if2.EncodesArtMethodAtDepth(1));
- ASSERT_EQ(10u, if2.GetDexPcAtDepth(2));
- ASSERT_TRUE(if2.EncodesArtMethodAtDepth(2));
+ InlineInfo if2_0 = ci.GetInlineInfoAtDepth(sm3, 0);
+ InlineInfo if2_1 = ci.GetInlineInfoAtDepth(sm3, 1);
+ InlineInfo if2_2 = ci.GetInlineInfoAtDepth(sm3, 2);
+ ASSERT_EQ(3u, ci.GetInlineDepthOf(sm3));
+ ASSERT_EQ(2u, if2_0.GetDexPc());
+ ASSERT_TRUE(if2_0.EncodesArtMethod());
+ ASSERT_EQ(5u, if2_1.GetDexPc());
+ ASSERT_TRUE(if2_1.EncodesArtMethod());
+ ASSERT_EQ(10u, if2_2.GetDexPc());
+ ASSERT_TRUE(if2_2.EncodesArtMethod());
- ASSERT_FALSE(if2.HasDexRegisterMapAtDepth(0));
+ ASSERT_FALSE(if2_0.HasDexRegisterMap());
- DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(1, if2, 1);
+ DexRegisterMap dex_registers1 = ci.GetDexRegisterMapAtDepth(1, sm3, 1);
ASSERT_EQ(2, dex_registers1.GetMachineRegister(0));
- DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(2, if2, 2);
+ DexRegisterMap dex_registers2 = ci.GetDexRegisterMapAtDepth(2, sm3, 2);
ASSERT_FALSE(dex_registers2.IsDexRegisterLive(0));
ASSERT_EQ(3, dex_registers2.GetMachineRegister(1));
}