From cb1b00aedd94785e7599f18065a0b97b314e64f6 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 28 Jan 2015 14:50:01 +0000 Subject: Use the non access check entrypoint when possible. Change-Id: I0b53d63141395e26816d5d2ce3fa6a297bb39b54 --- compiler/optimizing/builder.cc | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'compiler/optimizing/builder.cc') diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index 955deaa0ae..4b97a621ac 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -847,7 +847,10 @@ void HGraphBuilder::BuildFilledNewArray(uint32_t dex_pc, uint32_t* args, uint32_t register_index) { HInstruction* length = GetIntConstant(number_of_vreg_arguments); - HInstruction* object = new (arena_) HNewArray(length, dex_pc, type_index); + QuickEntrypointEnum entrypoint = NeedsAccessCheck(type_index) + ? kQuickAllocArrayWithAccessCheck + : kQuickAllocArray; + HInstruction* object = new (arena_) HNewArray(length, dex_pc, type_index, entrypoint); current_block_->AddInstruction(object); const char* descriptor = dex_file_->StringByTypeIdx(type_index); @@ -987,6 +990,11 @@ bool HGraphBuilder::BuildTypeCheck(const Instruction& instruction, return true; } +bool HGraphBuilder::NeedsAccessCheck(uint32_t type_index) const { + return !compiler_driver_->CanAccessInstantiableTypeWithoutChecks( + dex_compilation_unit_->GetDexMethodIndex(), *dex_file_, type_index); +} + void HGraphBuilder::BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc) { SwitchTable table(instruction, dex_pc, false); @@ -1772,16 +1780,24 @@ bool HGraphBuilder::AnalyzeDexInstruction(const Instruction& instruction, uint32 } case Instruction::NEW_INSTANCE: { - current_block_->AddInstruction( - new (arena_) HNewInstance(dex_pc, instruction.VRegB_21c())); + uint16_t type_index = instruction.VRegB_21c(); + QuickEntrypointEnum entrypoint = NeedsAccessCheck(type_index) + ? kQuickAllocObjectWithAccessCheck + : kQuickAllocObject; + + current_block_->AddInstruction(new (arena_) HNewInstance(dex_pc, type_index, entrypoint)); UpdateLocal(instruction.VRegA(), current_block_->GetLastInstruction()); break; } case Instruction::NEW_ARRAY: { + uint16_t type_index = instruction.VRegC_22c(); HInstruction* length = LoadLocal(instruction.VRegB_22c(), Primitive::kPrimInt); + QuickEntrypointEnum entrypoint = NeedsAccessCheck(type_index) + ? kQuickAllocArrayWithAccessCheck + : kQuickAllocArray; current_block_->AddInstruction( - new (arena_) HNewArray(length, dex_pc, instruction.VRegC_22c())); + new (arena_) HNewArray(length, dex_pc, type_index, entrypoint)); UpdateLocal(instruction.VRegA_22c(), current_block_->GetLastInstruction()); break; } -- cgit v1.2.3-59-g8ed1b