summaryrefslogtreecommitdiff
path: root/compiler/optimizing/builder.cc
diff options
context:
space:
mode:
author Calin Juravle <calin@google.com> 2015-05-14 15:15:42 +0100
committer Calin Juravle <calin@google.com> 2015-05-19 15:54:19 +0100
commit3cd4fc8bbb40a57d2ffde85f543c124f53237c1d (patch)
tree97eee6cc70206f605e251ad85f6f2941f4eb0383 /compiler/optimizing/builder.cc
parent2f9d1379fdebcdeeac52eaeff25ad5697c6b6ffb (diff)
Eliminate redundant constructor barriers when inlining.
Bug: 20410297 Change-Id: I2097743d00eb795d050d390b1918e38c7f41d506
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r--compiler/optimizing/builder.cc14
1 files changed, 6 insertions, 8 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index a5c6f23343..c4eaabf899 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -539,11 +539,6 @@ void HGraphBuilder::Binop_22b(const Instruction& instruction, bool reverse) {
}
static bool RequiresConstructorBarrier(const DexCompilationUnit* cu, const CompilerDriver& driver) {
- // dex compilation unit is null only when unit testing.
- if (cu == nullptr) {
- return false;
- }
-
Thread* self = Thread::Current();
return cu->IsConstructor()
&& driver.RequiresConstructorBarrier(self, cu->GetDexFile(), cu->GetClassDefIndex());
@@ -551,9 +546,12 @@ static bool RequiresConstructorBarrier(const DexCompilationUnit* cu, const Compi
void HGraphBuilder::BuildReturn(const Instruction& instruction, Primitive::Type type) {
if (type == Primitive::kPrimVoid) {
- // Note that we might insert redundant barriers when inlining `super` calls.
- // TODO: add a data flow analysis to get rid of duplicate barriers.
- if (RequiresConstructorBarrier(dex_compilation_unit_, *compiler_driver_)) {
+ if (graph_->ShouldGenerateConstructorBarrier()) {
+ // The compilation unit is null during testing.
+ if (dex_compilation_unit_ != nullptr) {
+ DCHECK(RequiresConstructorBarrier(dex_compilation_unit_, *compiler_driver_))
+ << "Inconsistent use of ShouldGenerateConstructorBarrier. Should not generate a barrier.";
+ }
current_block_->AddInstruction(new (arena_) HMemoryBarrier(kStoreStore));
}
current_block_->AddInstruction(new (arena_) HReturnVoid());