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
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index eb262bc..2c757f8 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -117,10 +117,9 @@
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 @@
return new (allocator) HGraph(
allocator,
pool_and_allocator_->GetArenaStack(),
+ handles,
*dex_files_.back(),
/*method_idx*/-1,
kRuntimeISA);
@@ -147,8 +147,9 @@
// 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 @@
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 @@
/* 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 @@
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 {};