diff options
author | 2024-04-09 12:49:48 +0000 | |
---|---|---|
committer | 2024-04-11 15:10:07 +0000 | |
commit | e8da7cd1d0e7d3535c82f8d05adcef3edd43cd40 (patch) | |
tree | f39114f368998a7b6415bb905fa71dc04dc3b232 /compiler/optimizing/sharpening.cc | |
parent | 69dc24557f951ce2513d0ea77f35a499fa58467b (diff) |
Clean up string data access in `DexFile`.
The `*ByIdx()` and `*ByTypeIdx()` functions were doing
validity checks that were needed only for processing the
debug data, so move the checks to these callers. Replace
these functions with new overloads of other functions to
provide consistent naming.
In a few cases, rewrite calls to these functions to fetch
and work with a `string_view` instead.
Rename `GetStringLength()` to `GetStringUtf16Length()` and
change its return type to `uint32_t`.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Change-Id: I561899606f6e5ec5f23aa4be617349dacdb376e3
Diffstat (limited to 'compiler/optimizing/sharpening.cc')
-rw-r--r-- | compiler/optimizing/sharpening.cc | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/compiler/optimizing/sharpening.cc b/compiler/optimizing/sharpening.cc index 5a697e32a1..e900b3ef3a 100644 --- a/compiler/optimizing/sharpening.cc +++ b/compiler/optimizing/sharpening.cc @@ -54,7 +54,7 @@ static bool BootImageAOTCanEmbedMethod(ArtMethod* method, const CompilerOptions& ObjPtr<mirror::Class> klass = method->GetDeclaringClass(); DCHECK(klass != nullptr); const DexFile& dex_file = klass->GetDexFile(); - return compiler_options.IsImageClass(dex_file.StringByTypeIdx(klass->GetDexTypeIndex())); + return compiler_options.IsImageClass(dex_file.GetTypeDescriptor(klass->GetDexTypeIndex())); } HInvokeStaticOrDirect::DispatchInfo HSharpening::SharpenLoadMethod( @@ -173,7 +173,7 @@ HLoadClass::LoadKind HSharpening::ComputeLoadClassKind( auto is_class_in_current_boot_image = [&]() { return (compiler_options.IsBootImage() || compiler_options.IsBootImageExtension()) && - compiler_options.IsImageClass(dex_file.StringByTypeIdx(type_index)); + compiler_options.IsImageClass(dex_file.GetTypeDescriptor(type_index)); }; bool is_in_boot_image = false; @@ -210,12 +210,12 @@ HLoadClass::LoadKind HSharpening::ComputeLoadClassKind( const char* slash_pos = strrchr(descriptor, '/'); return (slash_pos != nullptr) ? static_cast<size_t>(slash_pos - descriptor) : 0u; }; - const char* klass_descriptor = dex_file.StringByTypeIdx(type_index); + const char* klass_descriptor = dex_file.GetTypeDescriptor(type_index); const uint32_t klass_package_length = package_length(klass_descriptor); const DexFile* referrer_dex_file = dex_compilation_unit.GetDexFile(); const dex::TypeIndex referrer_type_index = referrer_dex_file->GetClassDef(dex_compilation_unit.GetClassDefIndex()).class_idx_; - const char* referrer_descriptor = referrer_dex_file->StringByTypeIdx(referrer_type_index); + const char* referrer_descriptor = referrer_dex_file->GetTypeDescriptor(referrer_type_index); const uint32_t referrer_package_length = package_length(referrer_descriptor); bool same_package = (referrer_package_length == klass_package_length) && @@ -240,7 +240,7 @@ HLoadClass::LoadKind HSharpening::ComputeLoadClassKind( is_in_boot_image = true; desired_load_kind = HLoadClass::LoadKind::kBootImageRelRo; } else if ((klass != nullptr) && - compiler_options.IsImageClass(dex_file.StringByTypeIdx(type_index))) { + compiler_options.IsImageClass(dex_file.GetTypeDescriptor(type_index))) { is_in_boot_image = true; desired_load_kind = HLoadClass::LoadKind::kBootImageLinkTimePcRelative; } else { @@ -317,7 +317,7 @@ static inline bool CanUseTypeCheckBitstring(ObjPtr<mirror::Class> klass, CodeGen if (compiler_options.IsJitCompiler()) { // If we're JITting, try to assign a type check bitstring (fall through). } else if (codegen->GetCompilerOptions().IsBootImage()) { - const char* descriptor = klass->GetDexFile().StringByTypeIdx(klass->GetDexTypeIndex()); + const char* descriptor = klass->GetDexFile().GetTypeDescriptor(klass->GetDexTypeIndex()); if (!codegen->GetCompilerOptions().IsImageClass(descriptor)) { return false; } |