From 02ca05a5a6e3f5028c6c2987a81be481d07bc617 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 12 May 2020 13:58:51 +0100 Subject: Move HandleCache to HGraph. This avoids passing the `VariableSizedHandleScope*` argument around and eliminates HGraph::inexact_object_rti_ and its initialization. The latter shall allow running Optimizing gtests that do not require type information without creating a Runtime in future. (To be implemented in a separate CL.) Test: m test-art-host-gtest Test: testrunner.py --host --optmizing Test: aosp_taimen-userdebug boots. Change-Id: I36fe9bc556c6d610d644c8c14cc74c9985a14d64 --- compiler/optimizing/optimizing_unit_test.h | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) (limited to 'compiler/optimizing/optimizing_unit_test.h') diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h index eb262bc123..2c757f8535 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -117,10 +117,9 @@ class OptimizingUnitTestHelper { void ResetPoolAndAllocator() { pool_and_allocator_.reset(new ArenaPoolAndAllocator()); - handles_.reset(); // When getting rid of the old HGraph, we can also reset handles_. } - HGraph* CreateGraph() { + HGraph* CreateGraph(VariableSizedHandleScope* handles = nullptr) { ArenaAllocator* const allocator = pool_and_allocator_->GetAllocator(); // Reserve a big array of 0s so the dex file constructor can offsets from the header. @@ -140,6 +139,7 @@ class OptimizingUnitTestHelper { return new (allocator) HGraph( allocator, pool_and_allocator_->GetArenaStack(), + handles, *dex_files_.back(), /*method_idx*/-1, kRuntimeISA); @@ -147,8 +147,9 @@ class OptimizingUnitTestHelper { // Create a control-flow graph from Dex instructions. HGraph* CreateCFG(const std::vector& data, - DataType::Type return_type = DataType::Type::kInt32) { - HGraph* graph = CreateGraph(); + DataType::Type return_type = DataType::Type::kInt32, + VariableSizedHandleScope* handles = nullptr) { + HGraph* graph = CreateGraph(handles); // The code item data might not aligned to 4 bytes, copy it to ensure that. const size_t code_item_size = data.size() * sizeof(data.front()); @@ -158,13 +159,9 @@ class OptimizingUnitTestHelper { const dex::CodeItem* code_item = reinterpret_cast(aligned_data); { - ScopedObjectAccess soa(Thread::Current()); - if (handles_ == nullptr) { - handles_.reset(new VariableSizedHandleScope(soa.Self())); - } const DexCompilationUnit* dex_compilation_unit = new (graph->GetAllocator()) DexCompilationUnit( - handles_->NewHandle(nullptr), + /* class_loader= */ Handle(), // Invalid handle. /* class_linker= */ nullptr, graph->GetDexFile(), code_item, @@ -172,9 +169,9 @@ class OptimizingUnitTestHelper { /* method_idx= */ dex::kDexNoIndex, /* access_flags= */ 0u, /* verified_method= */ nullptr, - handles_->NewHandle(nullptr)); + /* dex_cache= */ Handle()); // Invalid handle. CodeItemDebugInfoAccessor accessor(graph->GetDexFile(), code_item, /*dex_method_idx*/ 0u); - HGraphBuilder builder(graph, dex_compilation_unit, accessor, handles_.get(), return_type); + HGraphBuilder builder(graph, dex_compilation_unit, accessor, return_type); bool graph_built = (builder.BuildGraph() == kAnalysisSuccess); return graph_built ? graph : nullptr; } @@ -205,7 +202,6 @@ class OptimizingUnitTestHelper { std::vector> dex_files_; std::unique_ptr pool_and_allocator_; - std::unique_ptr handles_; }; class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {}; -- cgit v1.2.3-59-g8ed1b