diff options
author | Guillaume "Vermeille" Sanchez <guillaumesa@google.com> | 2015-04-20 14:41:30 +0100 |
---|---|---|
committer | Guillaume "Vermeille" Sanchez <guillaumesa@google.com> | 2015-04-23 17:53:17 +0100 |
commit | af88835231c2508509eb19aa2d21b92879351962 (patch) | |
tree | 4ef1c8fb3c5b78175767999a888b0c2cb1ea6485 /compiler/optimizing/code_generator_arm64.cc | |
parent | da93333d568f3c5bd8eeb58341d10a332e1d42bf (diff) | |
download | art-af88835231c2508509eb19aa2d21b92879351962.zip art-af88835231c2508509eb19aa2d21b92879351962.tar.gz art-af88835231c2508509eb19aa2d21b92879351962.tar.bz2 |
Remove unnecessary null checks in CheckCast and InstanceOf
Change-Id: I6fd81cabd8673be360f369e6318df0de8b18b634
Diffstat (limited to 'compiler/optimizing/code_generator_arm64.cc')
-rw-r--r-- | compiler/optimizing/code_generator_arm64.cc | 14 |
1 files changed, 9 insertions, 5 deletions
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index f6ec729..3619656 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -1373,8 +1373,10 @@ void InstructionCodeGeneratorARM64::VisitCheckCast(HCheckCast* instruction) { instruction, locations->InAt(1), LocationFrom(obj_cls), instruction->GetDexPc()); codegen_->AddSlowPath(slow_path); - // TODO: avoid this check if we know obj is not null. - __ Cbz(obj, slow_path->GetExitLabel()); + // Avoid null check if we know obj is not null. + if (instruction->MustDoNullCheck()) { + __ Cbz(obj, slow_path->GetExitLabel()); + } // Compare the class of `obj` with `cls`. __ Ldr(obj_cls, HeapOperand(obj, mirror::Object::ClassOffset())); __ Cmp(obj_cls, cls); @@ -1821,9 +1823,11 @@ void InstructionCodeGeneratorARM64::VisitInstanceOf(HInstanceOf* instruction) { vixl::Label done; // Return 0 if `obj` is null. - // TODO: Avoid this check if we know `obj` is not null. - __ Mov(out, 0); - __ Cbz(obj, &done); + // Avoid null check if we know `obj` is not null. + if (instruction->MustDoNullCheck()) { + __ Mov(out, 0); + __ Cbz(obj, &done); + } // Compare the class of `obj` with `cls`. __ Ldr(out, HeapOperand(obj, mirror::Object::ClassOffset())); |