diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2014-11-06 08:59:20 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2014-11-07 15:32:37 +0000 |
commit | 6f5c41f9e409bc4da53b5d7c385202255e391e72 (patch) | |
tree | bea48b3f23fdac7d566dd3b32dde1f86014b5a02 /compiler/optimizing/builder.cc | |
parent | 86fe4e41720cab85e3e40c45c0436521e56b25d5 (diff) | |
download | android_art-6f5c41f9e409bc4da53b5d7c385202255e391e72.tar.gz android_art-6f5c41f9e409bc4da53b5d7c385202255e391e72.tar.bz2 android_art-6f5c41f9e409bc4da53b5d7c385202255e391e72.zip |
Implement instanceof in optimizing.
- Only fast-path for now: null or same class.
- Use pQuickInstanceofNonTrivial for slow path.
Change-Id: Ic5196b94bef792f081f3cb4d15157058e1381e6b
Diffstat (limited to 'compiler/optimizing/builder.cc')
-rw-r--r-- | compiler/optimizing/builder.cc | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index fc7333fa25..05213a18be 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -1260,7 +1260,7 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 return false; } current_block_->AddInstruction( - new (arena_) HLoadClass(instruction.VRegB_21c(), is_referrers_class, dex_offset)); + new (arena_) HLoadClass(type_index, is_referrers_class, dex_offset)); UpdateLocal(instruction.VRegA_21c(), current_block_->GetLastInstruction()); break; } @@ -1282,6 +1282,29 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 break; } + case Instruction::INSTANCE_OF: { + uint16_t type_index = instruction.VRegC_22c(); + bool type_known_final; + bool type_known_abstract; + bool is_referrers_class; + bool can_access = compiler_driver_->CanAccessTypeWithoutChecks( + dex_compilation_unit_->GetDexMethodIndex(), *dex_file_, type_index, + &type_known_final, &type_known_abstract, &is_referrers_class); + if (!can_access) { + return false; + } + HInstruction* object = LoadLocal(instruction.VRegB_22c(), Primitive::kPrimNot); + HLoadClass* cls = new (arena_) HLoadClass(type_index, is_referrers_class, dex_offset); + current_block_->AddInstruction(cls); + // The class needs a temporary before being used by the type check. + Temporaries temps(graph_, 1); + temps.Add(cls); + current_block_->AddInstruction( + new (arena_) HTypeCheck(object, cls, type_known_final, dex_offset)); + UpdateLocal(instruction.VRegA_22c(), current_block_->GetLastInstruction()); + break; + } + default: return false; } |