diff options
author | Vladimir Marko <vmarko@google.com> | 2020-05-12 13:58:51 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2020-05-13 08:00:22 +0000 |
commit | 02ca05a5a6e3f5028c6c2987a81be481d07bc617 (patch) | |
tree | a364c4a46c573fdfddf607b0e78e5fd3f455c17f /compiler/optimizing/optimizing_unit_test.h | |
parent | 5868adaefe72cc8bcdcd8325c40f712375a506d1 (diff) |
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
Diffstat (limited to 'compiler/optimizing/optimizing_unit_test.h')
-rw-r--r-- | compiler/optimizing/optimizing_unit_test.h | 20 |
1 files changed, 8 insertions, 12 deletions
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<uint16_t>& 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<const dex::CodeItem*>(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<mirror::ClassLoader>(nullptr), + /* class_loader= */ Handle<mirror::ClassLoader>(), // 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<mirror::DexCache>(nullptr)); + /* dex_cache= */ Handle<mirror::DexCache>()); // 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<std::unique_ptr<const StandardDexFile>> dex_files_; std::unique_ptr<ArenaPoolAndAllocator> pool_and_allocator_; - std::unique_ptr<VariableSizedHandleScope> handles_; }; class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {}; |