summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
diff options
context:
space:
mode:
author Igor Murashkin <iam@google.com> 2017-04-11 18:39:59 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2017-04-11 18:40:01 +0000
commite2dfd30e752ed94944cb6f614f1a4cf18d038677 (patch)
tree259f65bf636e726fda89d9933886f6d11be9aee7 /compiler/optimizing/instruction_builder.cc
parent07f8d8619f9a90fad17c261c3025a6eb6c0c94c1 (diff)
parent032cacdbf32c50d3c43590600ed1e171a35fa93c (diff)
Merge "optimizing: do not illegally remove constructor barriers after inlining"
Diffstat (limited to 'compiler/optimizing/instruction_builder.cc')
-rw-r--r--compiler/optimizing/instruction_builder.cc14
1 files changed, 8 insertions, 6 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 88f67fae04..978c6a2d71 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -589,6 +589,11 @@ void HInstructionBuilder::Binop_22b(const Instruction& instruction, bool reverse
}
static bool RequiresConstructorBarrier(const DexCompilationUnit* cu, CompilerDriver* driver) {
+ // Can be null in unit tests only.
+ if (UNLIKELY(cu == nullptr)) {
+ return false;
+ }
+
Thread* self = Thread::Current();
return cu->IsConstructor()
&& driver->RequiresConstructorBarrier(self, cu->GetDexFile(), cu->GetClassDefIndex());
@@ -634,12 +639,9 @@ void HInstructionBuilder::BuildReturn(const Instruction& instruction,
Primitive::Type type,
uint32_t dex_pc) {
if (type == Primitive::kPrimVoid) {
- 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.";
- }
+ // This may insert additional redundant constructor fences from the super constructors.
+ // TODO: remove redundant constructor fences (b/36656456).
+ if (RequiresConstructorBarrier(dex_compilation_unit_, compiler_driver_)) {
AppendInstruction(new (arena_) HMemoryBarrier(kStoreStore, dex_pc));
}
AppendInstruction(new (arena_) HReturnVoid(dex_pc));