summaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorVladimir Marko <vmarko@google.com>2021-03-11 10:38:34 +0000
committerVladimir Marko <vmarko@google.com>2021-03-18 11:11:01 +0000
commitc9f4a3762b6c59714393aeca3662d96117e3b72f (patch)
tree1bbcb78df1bedbd5219ecd82ceef6c86810260c5 /compiler
parente3ca16f035ca100bad8225d5dc2cf9ccd1090a41 (diff)
Allocate LSEVisitor on the arena stack.
Use a simple wrapper to allocate the LSEVisitor on the arena stack. This allows adding additional members to the class without running into stack frame size errors with clang. Make the pre-allocated buffer for `store_records_` a member of LSEVisitor as originally intended. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I88b8ca5f9c765cc26e884e9f29cb2c870c799e13
Diffstat (limited to 'compiler')
-rw-r--r--compiler/optimizing/load_store_elimination.cc27
1 files changed, 23 insertions, 4 deletions
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc
index 7495601c92..b1ec62a12d 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -1251,6 +1251,7 @@ class LSEVisitor final : private HGraphDelegateVisitor {
};
// Small pre-allocated initial buffer avoids initializing a large one until it's really needed.
static constexpr size_t kStoreRecordsInitialBufferSize = 16;
+ std::pair<HInstruction*, StoreRecord> store_records_buffer_[kStoreRecordsInitialBufferSize];
ScopedArenaHashMap<HInstruction*, StoreRecord> store_records_;
// Replacements for Phi placeholders.
@@ -1441,8 +1442,7 @@ LSEVisitor::LSEVisitor(HGraph* graph,
/*expandable=*/false,
kArenaAllocLSE),
loads_requiring_loop_phi_(allocator_.Adapter(kArenaAllocLSE)),
- store_records_(allocator_.AllocArray<std::pair<HInstruction*, StoreRecord>>(
- kStoreRecordsInitialBufferSize, kArenaAllocLSE),
+ store_records_(store_records_buffer_,
kStoreRecordsInitialBufferSize,
allocator_.Adapter(kArenaAllocLSE)),
phi_placeholder_replacements_(num_phi_placeholders_,
@@ -3763,6 +3763,24 @@ void LSEVisitor::FinishFullLSE() {
}
}
+// The LSEVisitor is a ValueObject (indirectly through base classes) and therefore
+// cannot be directly allocated with an arena allocator, so we need to wrap it.
+class LSEVisitorWrapper : public DeletableArenaObject<kArenaAllocLSE> {
+ public:
+ LSEVisitorWrapper(HGraph* graph,
+ const HeapLocationCollector& heap_location_collector,
+ bool perform_partial_lse,
+ OptimizingCompilerStats* stats)
+ : lse_visitor_(graph, heap_location_collector, perform_partial_lse, stats) {}
+
+ void Run() {
+ lse_visitor_.Run();
+ }
+
+ private:
+ LSEVisitor lse_visitor_;
+};
+
bool LoadStoreElimination::Run(bool enable_partial_lse) {
if (graph_->IsDebuggable() || graph_->HasTryCatch()) {
// Debugger may set heap values or trigger deoptimization of callers.
@@ -3789,8 +3807,9 @@ bool LoadStoreElimination::Run(bool enable_partial_lse) {
return false;
}
- LSEVisitor lse_visitor(graph_, heap_location_collector, enable_partial_lse, stats_);
- lse_visitor.Run();
+ std::unique_ptr<LSEVisitorWrapper> lse_visitor(new (&allocator) LSEVisitorWrapper(
+ graph_, heap_location_collector, enable_partial_lse, stats_));
+ lse_visitor->Run();
return true;
}