Store precice set of which constructors require barriers
Fixes bugs where things in the boot image might not have been
calculated even though resolved_clases was true. This only occured
for app and test compiles though.
Fixes test 476-checker-ctor-memory-barrier which was failing due to
inlining something in the boot class path and getting a unexpected
barrier since the barrier defaults to enabled.
No measurable increase in RAM usage.
Bug: 28005874
Change-Id: I4a417819aa129c95f4a83c38df1a66eb77824ea9
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index b0f0893..06b3968 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -567,10 +567,10 @@
UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction());
}
-static bool RequiresConstructorBarrier(const DexCompilationUnit* cu, const CompilerDriver& driver) {
+static bool RequiresConstructorBarrier(const DexCompilationUnit* cu, CompilerDriver* driver) {
Thread* self = Thread::Current();
return cu->IsConstructor()
- && driver.RequiresConstructorBarrier(self, cu->GetDexFile(), cu->GetClassDefIndex());
+ && driver->RequiresConstructorBarrier(self, cu->GetDexFile(), cu->GetClassDefIndex());
}
// Returns true if `block` has only one successor which starts at the next
@@ -616,7 +616,7 @@
if (graph_->ShouldGenerateConstructorBarrier()) {
// The compilation unit is null during testing.
if (dex_compilation_unit_ != nullptr) {
- DCHECK(RequiresConstructorBarrier(dex_compilation_unit_, *compiler_driver_))
+ DCHECK(RequiresConstructorBarrier(dex_compilation_unit_, compiler_driver_))
<< "Inconsistent use of ShouldGenerateConstructorBarrier. Should not generate a barrier.";
}
AppendInstruction(new (arena_) HMemoryBarrier(kStoreStore, dex_pc));