From 32b8c8f33ad68982357c1fa3d0f132d06b070ab5 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Thu, 2 Dec 2021 11:50:03 +0000 Subject: Expand sharpening's ComputeLoadClassKind to cover cross-dex cases We can handle some extra cross-dex cases in order to expand the support. Bug: 154012332 Test: ART tests Change-Id: Ic3220d809086b4b3007bf5b6d63789ffb1b91fb9 --- compiler/optimizing/sharpening.cc | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 1fd76f7029..cb9edc0127 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -275,15 +275,18 @@ HLoadClass::LoadKind HSharpening::ComputeLoadClassKind( } HLoadClass::LoadKind load_kind = codegen->GetSupportedLoadClassKind(desired_load_kind); + // If we cannot reference this class due to .bss requirements, we're forced to bail. if (!IsSameDexFile(load_class->GetDexFile(), *dex_compilation_unit.GetDexFile())) { - if (load_kind == HLoadClass::LoadKind::kRuntimeCall || - load_kind == HLoadClass::LoadKind::kBssEntry || + if (load_kind == HLoadClass::LoadKind::kRuntimeCall) { + return HLoadClass::LoadKind::kInvalid; + } + + if (load_kind == HLoadClass::LoadKind::kBssEntry || load_kind == HLoadClass::LoadKind::kBssEntryPublic || load_kind == HLoadClass::LoadKind::kBssEntryPackage) { - // We actually cannot reference this class, we're forced to bail. - // We cannot reference this class with Bss, as the entrypoint will lookup the class - // in the caller's dex file, but that dex file does not reference the class. - return HLoadClass::LoadKind::kInvalid; + if (!codegen->GetCompilerOptions().WithinOatFile(&load_class->GetDexFile())) { + return HLoadClass::LoadKind::kInvalid; + } } } return load_kind; -- cgit v1.2.3-59-g8ed1b