diff options
Diffstat (limited to 'compiler/optimizing/builder.cc')
| -rw-r--r-- | compiler/optimizing/builder.cc | 31 |
1 files changed, 25 insertions, 6 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc index 9c2facb75e..4b97a621ac 100644 --- a/compiler/optimizing/builder.cc +++ b/compiler/optimizing/builder.cc @@ -161,7 +161,7 @@ void HGraphBuilder::InitializeParameters(uint16_t number_of_parameters) { if (!dex_compilation_unit_->IsStatic()) { // Add the implicit 'this' argument, not expressed in the signature. HParameterValue* parameter = - new (arena_) HParameterValue(parameter_index++, Primitive::kPrimNot); + new (arena_) HParameterValue(parameter_index++, Primitive::kPrimNot, true); entry_block_->AddInstruction(parameter); HLocal* local = GetLocalAt(locals_index++); entry_block_->AddInstruction(new (arena_) HStoreLocal(local, parameter)); @@ -613,9 +613,12 @@ bool HGraphBuilder::BuildInvoke(const Instruction& instruction, // Sharpening to kDirect only works if we compile PIC. DCHECK((optimized_invoke_type == invoke_type) || (optimized_invoke_type != kDirect) || compiler_driver_->GetCompilerOptions().GetCompilePic()); + bool is_recursive = + (target_method.dex_method_index == outer_compilation_unit_->GetDexMethodIndex()); + DCHECK(!is_recursive || (target_method.dex_file == outer_compilation_unit_->GetDexFile())); invoke = new (arena_) HInvokeStaticOrDirect( arena_, number_of_arguments, return_type, dex_pc, target_method.dex_method_index, - optimized_invoke_type); + is_recursive, optimized_invoke_type); } size_t start_index = 0; @@ -844,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); @@ -984,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); @@ -1769,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; } |