diff options
author | Calin Juravle <calin@google.com> | 2015-04-20 14:49:09 +0100 |
---|---|---|
committer | Calin Juravle <calin@google.com> | 2015-04-20 14:49:21 +0100 |
commit | 0c25d1048154495ae0523ba2f5063385eb15aa5f (patch) | |
tree | 28f34fec11f70ea72dd929e3a98130c257cb37aa /compiler/optimizing/builder.cc | |
parent | 27df758e2e7baebb6e3f393f9732fd0d064420c8 (diff) | |
download | art-0c25d1048154495ae0523ba2f5063385eb15aa5f.tar.gz art-0c25d1048154495ae0523ba2f5063385eb15aa5f.tar.bz2 art-0c25d1048154495ae0523ba2f5063385eb15aa5f.zip |
optimizing: fix gtests
by taking into account that the compilation unit is null during tests.
Change-Id: I01a28ce8f03c927ff679b84bcdf2464fa97e0924
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r-- | compiler/optimizing/builder.cc | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index fff2906a04..818d671b5b 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -520,17 +520,22 @@ void HGraphBuilder::Binop_22b(const Instruction& instruction, bool reverse) { UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction()); } -static bool RequiresConstructorBarrier(const DexCompilationUnit& cu, const CompilerDriver& driver) { +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()); + return cu->IsConstructor() + && driver.RequiresConstructorBarrier(self, cu->GetDexFile(), cu->GetClassDefIndex()); } 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 (RequiresConstructorBarrier(dex_compilation_unit_, *compiler_driver_)) { current_block_->AddInstruction(new (arena_) HMemoryBarrier(kStoreStore)); } current_block_->AddInstruction(new (arena_) HReturnVoid()); |