From ca6fff898afcb62491458ae8bcd428bfb3043da1 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 3 Oct 2017 14:49:14 +0100 Subject: ART: Use ScopedArenaAllocator for pass-local data. Passes using local ArenaAllocator were hiding their memory usage from the allocation counting, making it difficult to track down where memory was used. Using ScopedArenaAllocator reveals the memory usage. This changes the HGraph constructor which requires a lot of changes in tests. Refactor these tests to limit the amount of work needed the next time we change that constructor. Test: m test-art-host-gtest Test: testrunner.py --host Test: Build with kArenaAllocatorCountAllocations = true. Bug: 64312607 Change-Id: I34939e4086b500d6e827ff3ef2211d1a421ac91a --- compiler/optimizing/live_ranges_test.cc | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) (limited to 'compiler/optimizing/live_ranges_test.cc') diff --git a/compiler/optimizing/live_ranges_test.cc b/compiler/optimizing/live_ranges_test.cc index f9a955fb0a..8087fe0988 100644 --- a/compiler/optimizing/live_ranges_test.cc +++ b/compiler/optimizing/live_ranges_test.cc @@ -29,10 +29,13 @@ namespace art { -class LiveRangesTest : public CommonCompilerTest {}; +class LiveRangesTest : public OptimizingUnitTest { + public: + HGraph* BuildGraph(const uint16_t* data); +}; -static HGraph* BuildGraph(const uint16_t* data, ArenaAllocator* allocator) { - HGraph* graph = CreateCFG(allocator, data); +HGraph* LiveRangesTest::BuildGraph(const uint16_t* data) { + HGraph* graph = CreateCFG(data); // Suspend checks implementation may change in the future, and this test relies // on how instructions are ordered. RemoveSuspendChecks(graph); @@ -58,9 +61,7 @@ TEST_F(LiveRangesTest, CFG1) { Instruction::CONST_4 | 0 | 0, Instruction::RETURN); - ArenaPool pool; - ArenaAllocator allocator(&pool); - HGraph* graph = BuildGraph(data, &allocator); + HGraph* graph = BuildGraph(data); std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); @@ -107,9 +108,7 @@ TEST_F(LiveRangesTest, CFG2) { Instruction::GOTO | 0x100, Instruction::RETURN | 0 << 8); - ArenaPool pool; - ArenaAllocator allocator(&pool); - HGraph* graph = BuildGraph(data, &allocator); + HGraph* graph = BuildGraph(data); std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegen(graph, *features_x86.get(), CompilerOptions()); @@ -158,9 +157,7 @@ TEST_F(LiveRangesTest, CFG3) { Instruction::CONST_4 | 4 << 12 | 0, Instruction::RETURN | 0 << 8); - ArenaPool pool; - ArenaAllocator allocator(&pool); - HGraph* graph = BuildGraph(data, &allocator); + HGraph* graph = BuildGraph(data); std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegen(graph, *features_x86.get(), CompilerOptions()); @@ -236,9 +233,7 @@ TEST_F(LiveRangesTest, Loop1) { Instruction::CONST_4 | 5 << 12 | 1 << 8, Instruction::RETURN | 1 << 8); - ArenaPool pool; - ArenaAllocator allocator(&pool); - HGraph* graph = BuildGraph(data, &allocator); + HGraph* graph = BuildGraph(data); RemoveSuspendChecks(graph); std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); @@ -316,9 +311,7 @@ TEST_F(LiveRangesTest, Loop2) { Instruction::GOTO | 0xFB00, Instruction::RETURN | 0 << 8); - ArenaPool pool; - ArenaAllocator allocator(&pool); - HGraph* graph = BuildGraph(data, &allocator); + HGraph* graph = BuildGraph(data); std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegen(graph, *features_x86.get(), CompilerOptions()); @@ -394,9 +387,7 @@ TEST_F(LiveRangesTest, CFG4) { Instruction::ADD_INT, 1 << 8, Instruction::RETURN); - ArenaPool pool; - ArenaAllocator allocator(&pool); - HGraph* graph = BuildGraph(data, &allocator); + HGraph* graph = BuildGraph(data); std::unique_ptr features_x86( X86InstructionSetFeatures::FromCppDefines()); x86::CodeGeneratorX86 codegen(graph, *features_x86.get(), CompilerOptions()); -- cgit v1.2.3-59-g8ed1b