summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_builder.cc
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2024-04-09 12:49:48 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2024-04-11 15:10:07 +0000
commite8da7cd1d0e7d3535c82f8d05adcef3edd43cd40 (patch)
treef39114f368998a7b6415bb905fa71dc04dc3b232 /compiler/optimizing/instruction_builder.cc
parent69dc24557f951ce2513d0ea77f35a499fa58467b (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/instruction_builder.cc')
-rw-r--r--compiler/optimizing/instruction_builder.cc17
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index c3918683ce..3e9c42ba70 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -60,7 +60,7 @@ class SamePackageCompare {
const DexFile* dex_file = dex_compilation_unit_.GetDexFile();
uint32_t referrers_method_idx = dex_compilation_unit_.GetDexMethodIndex();
referrers_descriptor_ =
- dex_file->StringByTypeIdx(dex_file->GetMethodId(referrers_method_idx).class_idx_);
+ dex_file->GetMethodDeclaringClassDescriptor(dex_file->GetMethodId(referrers_method_idx));
referrers_package_length_ = PackageLength(referrers_descriptor_);
}
std::string temp;
@@ -2439,7 +2439,7 @@ HNewArray* HInstructionBuilder::BuildFilledNewArray(uint32_t dex_pc,
HInstruction* length = graph_->GetIntConstant(number_of_operands, dex_pc);
HNewArray* new_array = BuildNewArray(dex_pc, type_index, length);
- const char* descriptor = dex_file_->StringByTypeIdx(type_index);
+ const char* descriptor = dex_file_->GetTypeDescriptor(type_index);
DCHECK_EQ(descriptor[0], '[') << descriptor;
char primitive = descriptor[1];
DCHECK(primitive == 'I'
@@ -2657,14 +2657,11 @@ bool HInstructionBuilder::LoadClassNeedsAccessCheck(dex::TypeIndex type_index,
return true;
}
} else {
- uint32_t outer_utf16_length;
- const char* outer_descriptor =
- outer_dex_file->StringByTypeIdx(outer_class_def.class_idx_, &outer_utf16_length);
- uint32_t target_utf16_length;
- const char* target_descriptor =
- inner_dex_file->StringByTypeIdx(type_index, &target_utf16_length);
- if (outer_utf16_length != target_utf16_length ||
- strcmp(outer_descriptor, target_descriptor) != 0) {
+ const std::string_view outer_descriptor =
+ outer_dex_file->GetTypeDescriptorView(outer_class_def.class_idx_);
+ const std::string_view target_descriptor =
+ inner_dex_file->GetTypeDescriptorView(type_index);
+ if (outer_descriptor != target_descriptor) {
return true;
}
}