diff options
author | Vladimir Marko <vmarko@google.com> | 2017-10-09 14:12:23 +0100 |
---|---|---|
committer | Vladimir Marko <vmarko@google.com> | 2017-10-11 09:44:26 +0100 |
commit | 69d310e0317e2fce97bf8c9c133c5c2c0332e61d (patch) | |
tree | fba05a1530e6fc4a2e6950303c1f7c6b0ffbb936 /compiler/optimizing/optimizing_unit_test.h | |
parent | e764d2e50c544c2cb98ee61a15d613161ac6bd17 (diff) |
Use ScopedArenaAllocator for building HGraph.
Memory needed to compile the two most expensive methods for
aosp_angler-userdebug boot image:
BatteryStats.dumpCheckinLocked() : 21.1MiB -> 20.2MiB
BatteryStats.dumpLocked(): 42.0MiB -> 40.3MiB
This is because all the memory previously used by the graph
builder is reused by later passes.
And finish the "arena"->"allocator" renaming; make renamed
allocator pointers that are members of classes const when
appropriate (and make a few more members around them const).
Test: m test-art-host-gtest
Test: testrunner.py --host
Bug: 64312607
Change-Id: Ia50aafc80c05941ae5b96984ba4f31ed4c78255e
Diffstat (limited to 'compiler/optimizing/optimizing_unit_test.h')
-rw-r--r-- | compiler/optimizing/optimizing_unit_test.h | 21 |
1 files changed, 17 insertions, 4 deletions
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h index 5632f9a453..9aba91205c 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -22,7 +22,9 @@ #include "common_compiler_test.h" #include "dex_file.h" #include "dex_instruction.h" -#include "handle_scope.h" +#include "handle_scope-inl.h" +#include "mirror/class_loader.h" +#include "mirror/dex_cache.h" #include "nodes.h" #include "scoped_thread_state_change.h" #include "ssa_builder.h" @@ -123,8 +125,7 @@ class OptimizingUnitTest : public CommonCompilerTest { // Create a control-flow graph from Dex instructions. HGraph* CreateCFG(const uint16_t* data, DataType::Type return_type = DataType::Type::kInt32) { - const DexFile::CodeItem* item = - reinterpret_cast<const DexFile::CodeItem*>(data); + const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(data); HGraph* graph = CreateGraph(); { @@ -132,7 +133,19 @@ class OptimizingUnitTest : public CommonCompilerTest { if (handles_ == nullptr) { handles_.reset(new VariableSizedHandleScope(soa.Self())); } - HGraphBuilder builder(graph, *item, handles_.get(), return_type); + const DexFile* dex_file = graph->GetAllocator()->Alloc<DexFile>(); + const DexCompilationUnit* dex_compilation_unit = + new (graph->GetAllocator()) DexCompilationUnit( + handles_->NewHandle<mirror::ClassLoader>(nullptr), + /* class_linker */ nullptr, + *dex_file, + code_item, + /* class_def_index */ DexFile::kDexNoIndex16, + /* method_idx */ dex::kDexNoIndex, + /* access_flags */ 0u, + /* verified_method */ nullptr, + handles_->NewHandle<mirror::DexCache>(nullptr)); + HGraphBuilder builder(graph, dex_compilation_unit, *code_item, handles_.get(), return_type); bool graph_built = (builder.BuildGraph() == kAnalysisSuccess); return graph_built ? graph : nullptr; } |