From d16363a93053de0f32252c7897d839a46aff14ae Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 1 Feb 2017 14:09:13 +0000 Subject: Revert "Hash-based dex cache type array." Reverting to work around some programs crashing with Check failed: handle_scope_iface.Get() != nullptr. though the reason for the failure not yet understood. Test: m test-art-host Bug: 34839984 Bug: 30627598 Bug: 34659969 Bug: 30419309 This reverts commit ec7862283dd49f5a58d0ac45960ce27c2f7671b8. Change-Id: Ifded663633082f1e59e5b6ff2e026dc559bd6b82 --- compiler/optimizing/instruction_builder.cc | 49 +++++++++++++++--------------- 1 file changed, 25 insertions(+), 24 deletions(-) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 3d911d77ba..cac385ce3c 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -668,10 +668,11 @@ static InvokeType GetInvokeTypeFromOpCode(Instruction::Code opcode) { ArtMethod* HInstructionBuilder::ResolveMethod(uint16_t method_idx, InvokeType invoke_type) { ScopedObjectAccess soa(Thread::Current()); - StackHandleScope<2> hs(soa.Self()); + StackHandleScope<3> hs(soa.Self()); ClassLinker* class_linker = dex_compilation_unit_->GetClassLinker(); - Handle class_loader = dex_compilation_unit_->GetClassLoader(); + Handle class_loader(hs.NewHandle( + soa.Decode(dex_compilation_unit_->GetClassLoader()))); Handle compiling_class(hs.NewHandle(GetCompilingClass())); // We fetch the referenced class eagerly (that is, the class pointed by in the MethodId // at method_idx), as `CanAccessResolvedMethod` expects it be be in the dex cache. @@ -1283,7 +1284,9 @@ bool HInstructionBuilder::BuildInstanceFieldAccess(const Instruction& instructio static mirror::Class* GetClassFrom(CompilerDriver* driver, const DexCompilationUnit& compilation_unit) { ScopedObjectAccess soa(Thread::Current()); - Handle class_loader = compilation_unit.GetClassLoader(); + StackHandleScope<1> hs(soa.Self()); + Handle class_loader(hs.NewHandle( + soa.Decode(compilation_unit.GetClassLoader()))); Handle dex_cache = compilation_unit.GetDexCache(); return driver->ResolveCompilingMethodsClass(soa, dex_cache, class_loader, &compilation_unit); @@ -1299,9 +1302,10 @@ mirror::Class* HInstructionBuilder::GetCompilingClass() const { bool HInstructionBuilder::IsOutermostCompilingClass(dex::TypeIndex type_index) const { ScopedObjectAccess soa(Thread::Current()); - StackHandleScope<2> hs(soa.Self()); + StackHandleScope<3> hs(soa.Self()); Handle dex_cache = dex_compilation_unit_->GetDexCache(); - Handle class_loader = dex_compilation_unit_->GetClassLoader(); + Handle class_loader(hs.NewHandle( + soa.Decode(dex_compilation_unit_->GetClassLoader()))); Handle cls(hs.NewHandle(compiler_driver_->ResolveClass( soa, dex_cache, class_loader, type_index, dex_compilation_unit_))); Handle outer_class(hs.NewHandle(GetOutermostCompilingClass())); @@ -1339,8 +1343,10 @@ bool HInstructionBuilder::BuildStaticFieldAccess(const Instruction& instruction, uint16_t field_index = instruction.VRegB_21c(); ScopedObjectAccess soa(Thread::Current()); + StackHandleScope<3> hs(soa.Self()); Handle dex_cache = dex_compilation_unit_->GetDexCache(); - Handle class_loader = dex_compilation_unit_->GetClassLoader(); + Handle class_loader(hs.NewHandle( + soa.Decode(dex_compilation_unit_->GetClassLoader()))); ArtField* resolved_field = compiler_driver_->ResolveField( soa, dex_cache, class_loader, dex_compilation_unit_, field_index, true); @@ -1351,7 +1357,6 @@ bool HInstructionBuilder::BuildStaticFieldAccess(const Instruction& instruction, return true; } - StackHandleScope<2> hs(soa.Self()); Primitive::Type field_type = resolved_field->GetTypeAsPrimitiveType(); Handle outer_dex_cache = outer_compilation_unit_->GetDexCache(); Handle outer_class(hs.NewHandle(GetOutermostCompilingClass())); @@ -1630,7 +1635,9 @@ HLoadClass* HInstructionBuilder::BuildLoadClass(dex::TypeIndex type_index, const DexCompilationUnit* compilation_unit = outer ? outer_compilation_unit_ : dex_compilation_unit_; const DexFile& dex_file = *compilation_unit->GetDexFile(); - Handle class_loader = dex_compilation_unit_->GetClassLoader(); + StackHandleScope<1> hs(soa.Self()); + Handle class_loader(hs.NewHandle( + soa.Decode(dex_compilation_unit_->GetClassLoader()))); Handle klass = handles_->NewHandle(compiler_driver_->ResolveClass( soa, compilation_unit->GetDexCache(), class_loader, type_index, compilation_unit)); @@ -1685,9 +1692,17 @@ void HInstructionBuilder::BuildTypeCheck(const Instruction& instruction, } } -bool HInstructionBuilder::NeedsAccessCheck(dex::TypeIndex type_index, bool* finalizable) const { +bool HInstructionBuilder::NeedsAccessCheck(dex::TypeIndex type_index, + Handle dex_cache, + bool* finalizable) const { return !compiler_driver_->CanAccessInstantiableTypeWithoutChecks( - LookupReferrerClass(), LookupResolvedType(type_index, *dex_compilation_unit_), finalizable); + dex_compilation_unit_->GetDexMethodIndex(), dex_cache, type_index, finalizable); +} + +bool HInstructionBuilder::NeedsAccessCheck(dex::TypeIndex type_index, bool* finalizable) const { + ScopedObjectAccess soa(Thread::Current()); + Handle dex_cache = dex_compilation_unit_->GetDexCache(); + return NeedsAccessCheck(type_index, dex_cache, finalizable); } bool HInstructionBuilder::CanDecodeQuickenedInfo() const { @@ -2727,18 +2742,4 @@ bool HInstructionBuilder::ProcessDexInstruction(const Instruction& instruction, return true; } // NOLINT(readability/fn_size) -ObjPtr HInstructionBuilder::LookupResolvedType( - dex::TypeIndex type_index, - const DexCompilationUnit& compilation_unit) const { - return ClassLinker::LookupResolvedType( - type_index, compilation_unit.GetDexCache().Get(), compilation_unit.GetClassLoader().Get()); -} - -ObjPtr HInstructionBuilder::LookupReferrerClass() const { - // TODO: Cache the result in a Handle. - const DexFile::MethodId& method_id = - dex_compilation_unit_->GetDexFile()->GetMethodId(dex_compilation_unit_->GetDexMethodIndex()); - return LookupResolvedType(method_id.class_idx_, *dex_compilation_unit_); -} - } // namespace art -- cgit v1.2.3-59-g8ed1b