From 961dbc4a173eb424f79ddca1ac9a90214addcc19 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 8 Mar 2022 16:24:23 +0000 Subject: Optimizing: Do not resolve field type for `get` opcodes. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 161898207 Change-Id: Ia4b9cd5d03dfc9d1eb32b59840279171f2d42a56 --- compiler/optimizing/instruction_builder.cc | 32 +++++++++++++++++------------- 1 file changed, 18 insertions(+), 14 deletions(-) (limited to 'compiler/optimizing/instruction_builder.cc') diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index 2454125589..e0bdd0963c 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -2225,22 +2225,26 @@ ArtField* HInstructionBuilder::ResolveField(uint16_t field_idx, bool is_static, return nullptr; } - if (is_put && - resolved_field->IsFinal() && - (compiling_class.Get() != resolved_field->GetDeclaringClass())) { - // Final fields can only be updated within their own class. - // TODO: Only allow it in constructors. b/34966607. - return nullptr; - } + if (is_put) { + if (resolved_field->IsFinal() && + (compiling_class.Get() != resolved_field->GetDeclaringClass())) { + // Final fields can only be updated within their own class. + // TODO: Only allow it in constructors. b/34966607. + return nullptr; + } - StackArtFieldHandleScope<1> rhs(soa.Self()); - ReflectiveHandle resolved_field_handle(rhs.NewHandle(resolved_field)); - if (resolved_field->ResolveType().IsNull()) { - // ArtField::ResolveType() may fail as evidenced with a dexing bug (b/78788577). - soa.Self()->ClearException(); - return nullptr; // Failure + // Note: We do not need to resolve the field type for `get` opcodes. + StackArtFieldHandleScope<1> rhs(soa.Self()); + ReflectiveHandle resolved_field_handle(rhs.NewHandle(resolved_field)); + if (resolved_field->ResolveType().IsNull()) { + // ArtField::ResolveType() may fail as evidenced with a dexing bug (b/78788577). + soa.Self()->ClearException(); + return nullptr; // Failure + } + resolved_field = resolved_field_handle.Get(); } - return resolved_field_handle.Get(); + + return resolved_field; } void HInstructionBuilder::BuildStaticFieldAccess(const Instruction& instruction, -- cgit v1.2.3-59-g8ed1b