From e7a9194558379ee24fde82fcaeaee29542df1520 Mon Sep 17 00:00:00 2001 From: David Srbecky Date: Wed, 1 Aug 2018 17:23:53 +0100 Subject: Simplify StackMapStream encoding. Test: test-art-host-gtest-stack_map_test Change-Id: Ife021d03e4e486043ec609f9af8673ace7bde497 --- compiler/optimizing/stack_map_test.cc | 60 ++++++++++------------------------- 1 file changed, 17 insertions(+), 43 deletions(-) (limited to 'compiler/optimizing/stack_map_test.cc') diff --git a/compiler/optimizing/stack_map_test.cc b/compiler/optimizing/stack_map_test.cc index 16a9216311..a281bb30f4 100644 --- a/compiler/optimizing/stack_map_test.cc +++ b/compiler/optimizing/stack_map_test.cc @@ -62,12 +62,9 @@ TEST(StackMapTest, Test1) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo code_info(region); + CodeInfo code_info(memory.data()); ASSERT_EQ(1u, code_info.GetNumberOfStackMaps()); uint32_t number_of_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); @@ -151,12 +148,9 @@ TEST(StackMapTest, Test2) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo code_info(region); + CodeInfo code_info(memory.data()); ASSERT_EQ(4u, code_info.GetNumberOfStackMaps()); uint32_t number_of_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); @@ -324,12 +318,9 @@ TEST(StackMapTest, TestDeduplicateInlineInfoDexRegisterMap) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo code_info(region); + CodeInfo code_info(memory.data()); ASSERT_EQ(1u, code_info.GetNumberOfStackMaps()); uint32_t number_of_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); @@ -382,12 +373,9 @@ TEST(StackMapTest, TestNonLiveDexRegisters) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo code_info(region); + CodeInfo code_info(memory.data()); ASSERT_EQ(1u, code_info.GetNumberOfStackMaps()); uint32_t number_of_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); @@ -444,12 +432,9 @@ TEST(StackMapTest, TestShareDexRegisterMap) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo ci(region); + CodeInfo ci(memory.data()); // Verify first stack map. StackMap sm0 = ci.GetStackMapAt(0); @@ -495,12 +480,9 @@ TEST(StackMapTest, TestNoDexRegisterMap) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo code_info(region); + CodeInfo code_info(memory.data()); ASSERT_EQ(2u, code_info.GetNumberOfStackMaps()); uint32_t number_of_catalog_entries = code_info.GetNumberOfLocationCatalogEntries(); @@ -597,12 +579,9 @@ TEST(StackMapTest, InlineTest) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo ci(region); + CodeInfo ci(memory.data()); { // Verify first stack map. @@ -744,12 +723,9 @@ TEST(StackMapTest, TestDeduplicateStackMask) { stream.EndStackMapEntry(); stream.EndMethod(); - size_t size = stream.PrepareForFillIn(); - void* memory = allocator.Alloc(size, kArenaAllocMisc); - MemoryRegion region(memory, size); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); - CodeInfo code_info(region); + CodeInfo code_info(memory.data()); ASSERT_EQ(2u, code_info.GetNumberOfStackMaps()); StackMap stack_map1 = code_info.GetStackMapForNativePcOffset(4 * kPcAlign); @@ -771,9 +747,7 @@ TEST(StackMapTest, TestDedupeBitTables) { stream.EndStackMapEntry(); stream.EndMethod(); - std::vector memory(stream.PrepareForFillIn()); - MemoryRegion region(memory.data(), memory.size()); - stream.FillInCodeInfo(region); + ScopedArenaVector memory = stream.Encode(); std::vector out; CodeInfo::DedupeMap dedupe_map; -- cgit v1.2.3-59-g8ed1b