summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Vladimir Marko <vmarko@google.com> 2024-05-13 11:32:56 +0000
committer VladimĂ­r Marko <vmarko@google.com> 2024-05-14 09:53:49 +0000
commitc9400203bb2faf8b69b0aa8a401bf70e72a94c41 (patch)
tree977d707b805da5bb07c192b242a908cfdc0bc7a5
parent7143edc113406fcd76ea677da88d8dfd6afff6c9 (diff)
Faster `DexFile::FindTypeId()`.
Work with `std::string_view::compare()` instead of slower `CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 338123769 Change-Id: I4c3cc131da457c0a73f83fa2f864491eb2bc7a03
-rw-r--r--libdexfile/dex/dex_file.cc12
-rw-r--r--libdexfile/dex/dex_file.h7
-rw-r--r--libprofile/profile/profile_compilation_info.cc13
-rw-r--r--libprofile/profile/profile_compilation_info.h14
-rw-r--r--openjdkjvmti/ti_redefine.cc8
-rw-r--r--profman/profman.cc7
-rw-r--r--runtime/art_method.cc4
-rw-r--r--runtime/class_linker.cc3
-rw-r--r--runtime/class_linker.h3
-rw-r--r--runtime/hidden_api.cc2
-rw-r--r--runtime/jit/profile_saver.cc4
-rw-r--r--runtime/mirror/class-inl.h7
-rw-r--r--runtime/mirror/class.cc11
-rw-r--r--runtime/mirror/class.h4
-rw-r--r--runtime/oat/aot_class_linker.cc2
-rw-r--r--runtime/oat/aot_class_linker.h2
-rw-r--r--runtime/oat/oat_file.cc2
-rw-r--r--runtime/oat/oat_file.h2
-rw-r--r--runtime/sdk_checker.cc8
-rw-r--r--runtime/sdk_checker.h2
20 files changed, 59 insertions, 58 deletions
diff --git a/libdexfile/dex/dex_file.cc b/libdexfile/dex/dex_file.cc
index 9940cc0458..2b68cfad0d 100644
--- a/libdexfile/dex/dex_file.cc
+++ b/libdexfile/dex/dex_file.cc
@@ -463,15 +463,14 @@ const StringId* DexFile::FindStringId(const char* string) const {
return nullptr;
}
-const TypeId* DexFile::FindTypeId(const char* string) const {
+const TypeId* DexFile::FindTypeId(std::string_view descriptor) const {
int32_t lo = 0;
int32_t hi = NumTypeIds() - 1;
while (hi >= lo) {
int32_t mid = (hi + lo) / 2;
const TypeId& type_id = GetTypeId(dex::TypeIndex(mid));
- const StringId& str_id = GetStringId(type_id.descriptor_idx_);
- const char* str = GetStringData(str_id);
- int compare = CompareModifiedUtf8ToModifiedUtf8AsUtf16CodePointValues(string, str);
+ std::string_view mid_descriptor = GetTypeDescriptorView(type_id);
+ int compare = CompareDescriptors(descriptor, mid_descriptor);
if (compare > 0) {
lo = mid + 1;
} else if (compare < 0) {
@@ -571,9 +570,8 @@ bool DexFile::CreateTypeList(std::string_view signature,
offset++;
} while (c != ';');
}
- // TODO: avoid creating a std::string just to get a 0-terminated char array
- std::string descriptor(signature.data() + start_offset, offset - start_offset);
- const TypeId* type_id = FindTypeId(descriptor.c_str());
+ std::string_view descriptor(signature.data() + start_offset, offset - start_offset);
+ const TypeId* type_id = FindTypeId(descriptor);
if (type_id == nullptr) {
return false;
}
diff --git a/libdexfile/dex/dex_file.h b/libdexfile/dex/dex_file.h
index b79c72079d..6c41849616 100644
--- a/libdexfile/dex/dex_file.h
+++ b/libdexfile/dex/dex_file.h
@@ -359,11 +359,6 @@ class DexFile {
// Looks up a string id for a given modified utf8 string.
const dex::StringId* FindStringId(const char* string) const;
- const dex::TypeId* FindTypeId(const char* string) const;
- const dex::TypeId* FindTypeId(std::string_view string) const {
- return FindTypeId(std::string(string).c_str());
- }
-
// Returns the number of type identifiers in the .dex file.
uint32_t NumTypeIds() const {
DCHECK(header_ != nullptr) << GetLocation();
@@ -394,6 +389,8 @@ class DexFile {
std::string_view GetTypeDescriptorView(const dex::TypeId& type_id) const;
std::string_view GetTypeDescriptorView(dex::TypeIndex type_idx) const;
+ const dex::TypeId* FindTypeId(std::string_view descriptor) const;
+
// Looks up a type for the given string index
const dex::TypeId* FindTypeId(dex::StringIndex string_idx) const;
diff --git a/libprofile/profile/profile_compilation_info.cc b/libprofile/profile/profile_compilation_info.cc
index 39c1438d69..631bf1148b 100644
--- a/libprofile/profile/profile_compilation_info.cc
+++ b/libprofile/profile/profile_compilation_info.cc
@@ -696,12 +696,12 @@ dex::TypeIndex ProfileCompilationInfo::FindOrCreateTypeIndex(const DexFile& dex_
return class_ref.TypeIndex();
}
// Try to find a `TypeId` in the method's dex file.
- const char* descriptor = class_ref.dex_file->GetTypeDescriptor(class_ref.TypeIndex());
+ std::string_view descriptor = class_ref.dex_file->GetTypeDescriptorView(class_ref.TypeIndex());
return FindOrCreateTypeIndex(dex_file, descriptor);
}
dex::TypeIndex ProfileCompilationInfo::FindOrCreateTypeIndex(const DexFile& dex_file,
- const char* descriptor) {
+ std::string_view descriptor) {
const dex::TypeId* type_id = dex_file.FindTypeId(descriptor);
if (type_id != nullptr) {
return dex_file.GetIndexForTypeId(*type_id);
@@ -709,12 +709,11 @@ dex::TypeIndex ProfileCompilationInfo::FindOrCreateTypeIndex(const DexFile& dex_
// Try to find an existing extra descriptor.
uint32_t num_type_ids = dex_file.NumTypeIds();
uint32_t max_artificial_ids = DexFile::kDexNoIndex16 - num_type_ids;
- std::string_view descriptor_view(descriptor);
// Check descriptor length for "extra descriptor". We are using `uint16_t` as prefix.
- if (UNLIKELY(descriptor_view.size() > kMaxExtraDescriptorLength)) {
+ if (UNLIKELY(descriptor.size() > kMaxExtraDescriptorLength)) {
return dex::TypeIndex(); // Invalid.
}
- auto it = extra_descriptors_indexes_.find(descriptor_view);
+ auto it = extra_descriptors_indexes_.find(descriptor);
if (it != extra_descriptors_indexes_.end()) {
return (*it < max_artificial_ids) ? dex::TypeIndex(num_type_ids + *it) : dex::TypeIndex();
}
@@ -723,13 +722,13 @@ dex::TypeIndex ProfileCompilationInfo::FindOrCreateTypeIndex(const DexFile& dex_
return dex::TypeIndex(); // Invalid.
}
// Add the descriptor to extra descriptors and return the artificial type index.
- ExtraDescriptorIndex new_extra_descriptor_index = AddExtraDescriptor(descriptor_view);
+ ExtraDescriptorIndex new_extra_descriptor_index = AddExtraDescriptor(descriptor);
DCHECK_LT(new_extra_descriptor_index, max_artificial_ids);
return dex::TypeIndex(num_type_ids + new_extra_descriptor_index);
}
bool ProfileCompilationInfo::AddClass(const DexFile& dex_file,
- const char* descriptor,
+ std::string_view descriptor,
const ProfileSampleAnnotation& annotation) {
DexFileData* const data = GetOrAddDexFileData(&dex_file, annotation);
if (data == nullptr) { // checksum mismatch
diff --git a/libprofile/profile/profile_compilation_info.h b/libprofile/profile/profile_compilation_info.h
index bb16cf8dea..104198f1fa 100644
--- a/libprofile/profile/profile_compilation_info.h
+++ b/libprofile/profile/profile_compilation_info.h
@@ -336,7 +336,7 @@ class ProfileCompilationInfo {
// The returned type index can be used, if valid, for `AddClass()` or (TODO) as
// a type index for inline caches.
dex::TypeIndex FindOrCreateTypeIndex(const DexFile& dex_file, TypeReference class_ref);
- dex::TypeIndex FindOrCreateTypeIndex(const DexFile& dex_file, const char* descriptor);
+ dex::TypeIndex FindOrCreateTypeIndex(const DexFile& dex_file, std::string_view descriptor);
// Add a class with the specified `type_index` to the profile. The `type_index`
// can be either a normal index for a `TypeId` in the dex file, or an artificial
@@ -371,18 +371,8 @@ class ProfileCompilationInfo {
// Add a class with the specified `descriptor` to the profile.
// Returns `true` on success, `false` on failure.
bool AddClass(const DexFile& dex_file,
- const char* descriptor,
- const ProfileSampleAnnotation& annotation = ProfileSampleAnnotation::kNone);
- bool AddClass(const DexFile& dex_file,
- const std::string& descriptor,
- const ProfileSampleAnnotation& annotation = ProfileSampleAnnotation::kNone) {
- return AddClass(dex_file, descriptor.c_str(), annotation);
- }
- bool AddClass(const DexFile& dex_file,
std::string_view descriptor,
- const ProfileSampleAnnotation& annotation = ProfileSampleAnnotation::kNone) {
- return AddClass(dex_file, std::string(descriptor).c_str(), annotation);
- }
+ const ProfileSampleAnnotation& annotation = ProfileSampleAnnotation::kNone);
// Add multiple type ids for classes in a single dex file. Iterator is for type_ids not
// class_defs.
diff --git a/openjdkjvmti/ti_redefine.cc b/openjdkjvmti/ti_redefine.cc
index a16a560424..fc1828a56e 100644
--- a/openjdkjvmti/ti_redefine.cc
+++ b/openjdkjvmti/ti_redefine.cc
@@ -2552,14 +2552,14 @@ void Redefiner::ClassRedefinition::UpdateMethods(art::ObjPtr<art::mirror::Class>
for (art::ArtMethod& method : mclass->GetDeclaredMethods(image_pointer_size)) {
const art::dex::StringId* new_name_id = dex_file_->FindStringId(method.GetName());
art::dex::TypeIndex method_return_idx =
- dex_file_->GetIndexForTypeId(*dex_file_->FindTypeId(method.GetReturnTypeDescriptor()));
+ dex_file_->GetIndexForTypeId(*dex_file_->FindTypeId(method.GetReturnTypeDescriptorView()));
const auto* old_type_list = method.GetParameterTypeList();
std::vector<art::dex::TypeIndex> new_type_list;
for (uint32_t i = 0; old_type_list != nullptr && i < old_type_list->Size(); i++) {
new_type_list.push_back(
dex_file_->GetIndexForTypeId(
*dex_file_->FindTypeId(
- old_dex_file.GetTypeDescriptor(
+ old_dex_file.GetTypeDescriptorView(
old_dex_file.GetTypeId(
old_type_list->GetTypeItem(i).type_idx_)))));
}
@@ -2587,9 +2587,9 @@ void Redefiner::ClassRedefinition::UpdateFields(art::ObjPtr<art::mirror::Class>
for (auto fields_iter : {mclass->GetIFields(), mclass->GetSFields()}) {
for (art::ArtField& field : fields_iter) {
const art::dex::TypeId* new_declaring_id =
- dex_file_->FindTypeId(field.GetDeclaringClassDescriptor());
+ dex_file_->FindTypeId(field.GetDeclaringClassDescriptorView());
const art::dex::StringId* new_name_id = dex_file_->FindStringId(field.GetName());
- const art::dex::TypeId* new_type_id = dex_file_->FindTypeId(field.GetTypeDescriptor());
+ const art::dex::TypeId* new_type_id = dex_file_->FindTypeId(field.GetTypeDescriptorView());
CHECK(new_name_id != nullptr && new_type_id != nullptr && new_declaring_id != nullptr);
const art::dex::FieldId* new_field_id =
dex_file_->FindFieldId(*new_declaring_id, *new_name_id, *new_type_id);
diff --git a/profman/profman.cc b/profman/profman.cc
index f8266697ed..b56fdf2523 100644
--- a/profman/profman.cc
+++ b/profman/profman.cc
@@ -1260,7 +1260,7 @@ class ProfMan final {
return !receiver_.has_value();
}
- const std::string_view& GetReceiverType() const {
+ std::string_view GetReceiverType() const {
DCHECK(!IsSingleReceiver());
return *receiver_;
}
@@ -1550,9 +1550,8 @@ class ProfMan final {
}
} else {
// Get the type-ref the method code will use.
- std::string receiver_str(segment.GetReceiverType());
- const dex::TypeId *type_id =
- class_ref.dex_file->FindTypeId(receiver_str.c_str());
+ std::string_view receiver_descriptor = segment.GetReceiverType();
+ const dex::TypeId *type_id = class_ref.dex_file->FindTypeId(receiver_descriptor);
if (type_id == nullptr) {
LOG(WARNING) << "Could not find class: "
<< segment.GetReceiverType() << " in dex-file "
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index 2b59f38ed6..40022c9d6d 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -302,7 +302,7 @@ uint32_t ArtMethod::FindDexMethodIndexInOtherDexFile(const DexFile& other_dexfil
if (dexfile == &other_dexfile) {
return dex_method_idx;
}
- const char* mid_declaring_class_descriptor = dexfile->GetTypeDescriptor(mid.class_idx_);
+ std::string_view mid_declaring_class_descriptor = dexfile->GetTypeDescriptorView(mid.class_idx_);
const dex::TypeId* other_type_id = other_dexfile.FindTypeId(mid_declaring_class_descriptor);
if (other_type_id != nullptr) {
const dex::MethodId* other_mid = other_dexfile.FindMethodId(
@@ -488,7 +488,7 @@ static const OatFile::OatMethod FindOatMethodFromDexFileFor(ArtMethod* method, b
// recreate the class_def_index from the descriptor.
const dex::TypeId* declaring_class_type_id =
- dex_file->FindTypeId(method->GetDeclaringClassDescriptor());
+ dex_file->FindTypeId(method->GetDeclaringClassDescriptorView());
CHECK(declaring_class_type_id != nullptr);
dex::TypeIndex declaring_class_type_index = dex_file->GetIndexForTypeId(*declaring_class_type_id);
const dex::ClassDef* declaring_class_type_def =
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index 501470c4b5..03611ebc20 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -11154,7 +11154,8 @@ bool ClassLinker::DenyAccessBasedOnPublicSdk([[maybe_unused]] ArtField* art_fiel
UNREACHABLE();
}
-bool ClassLinker::DenyAccessBasedOnPublicSdk([[maybe_unused]] const char* type_descriptor) const {
+bool ClassLinker::DenyAccessBasedOnPublicSdk(
+ [[maybe_unused]] std::string_view type_descriptor) const {
// Should not be called on ClassLinker, only on AotClassLinker that overrides this.
LOG(FATAL) << "UNREACHABLE";
UNREACHABLE();
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index eabfb4926a..d27664a897 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -64,7 +64,6 @@ class OatFile;
template<class T> class ObjectLock;
class Runtime;
class ScopedObjectAccessAlreadyRunnable;
-class SdkChecker;
template<size_t kNumReferences> class PACKED(4) StackHandleScope;
class Thread;
class VariableSizedHandleScope;
@@ -887,7 +886,7 @@ class EXPORT ClassLinker {
virtual bool DenyAccessBasedOnPublicSdk(ArtField* art_field) const
REQUIRES_SHARED(Locks::mutator_lock_);
// Verifies if the descriptor is accesible according to the SdkChecker (if installed).
- virtual bool DenyAccessBasedOnPublicSdk(const char* type_descriptor) const;
+ virtual bool DenyAccessBasedOnPublicSdk(std::string_view type_descriptor) const;
// Enable or disable public sdk checks.
virtual void SetEnablePublicSdkChecks(bool enabled);
diff --git a/runtime/hidden_api.cc b/runtime/hidden_api.cc
index 495b38404c..cb1c60d93f 100644
--- a/runtime/hidden_api.cc
+++ b/runtime/hidden_api.cc
@@ -261,7 +261,7 @@ MemberSignature::MemberSignature(ArtField* field) {
MemberSignature::MemberSignature(ArtMethod* method) {
DCHECK(method == method->GetInterfaceMethodIfProxy(kRuntimePointerSize))
<< "Caller should have replaced proxy method with interface method";
- class_name_ = method->GetDeclaringClassDescriptor();
+ class_name_ = method->GetDeclaringClassDescriptorView();
member_name_ = method->GetNameView();
type_signature_ = method->GetSignature().ToString();
type_ = kMethod;
diff --git a/runtime/jit/profile_saver.cc b/runtime/jit/profile_saver.cc
index 942d2923fc..abf01f5498 100644
--- a/runtime/jit/profile_saver.cc
+++ b/runtime/jit/profile_saver.cc
@@ -662,7 +662,7 @@ void ProfileSaver::GetClassesAndMethodsHelper::UpdateProfile(const std::set<std:
array_class_descriptor.assign(class_record.array_dimension, '[');
array_class_descriptor += dex_file->GetTypeDescriptorView(class_record.type_index);
dex::TypeIndex type_index =
- profile_info->FindOrCreateTypeIndex(*dex_file, array_class_descriptor.c_str());
+ profile_info->FindOrCreateTypeIndex(*dex_file, array_class_descriptor);
if (type_index.IsValid()) {
profile_info->AddClass(profile_index, type_index);
}
@@ -716,7 +716,7 @@ void ProfileSaver::GetClassesAndMethodsHelper::UpdateProfile(const std::set<std:
array_class_descriptor.assign(dim, '[');
array_class_descriptor += Primitive::Descriptor(enum_cast<Primitive::Type>(i));
dex::TypeIndex type_index =
- profile_info->FindOrCreateTypeIndex(*dex_file, array_class_descriptor.c_str());
+ profile_info->FindOrCreateTypeIndex(*dex_file, array_class_descriptor);
if (type_index.IsValid()) {
profile_info->AddClass(profile_index, type_index);
}
diff --git a/runtime/mirror/class-inl.h b/runtime/mirror/class-inl.h
index 98b108aff3..74776c14d4 100644
--- a/runtime/mirror/class-inl.h
+++ b/runtime/mirror/class-inl.h
@@ -818,6 +818,13 @@ inline const DexFile& Class::GetDexFile() {
return *GetDexCache<kDefaultVerifyFlags, kWithoutReadBarrier>()->GetDexFile();
}
+inline std::string_view Class::GetDescriptorView() {
+ DCHECK(!IsArrayClass());
+ DCHECK(!IsPrimitive());
+ DCHECK(!IsProxyClass());
+ return GetDexFile().GetTypeDescriptorView(GetDexTypeIndex());
+}
+
inline bool Class::DescriptorEquals(const char* match) {
ObjPtr<mirror::Class> klass = this;
while (klass->IsArrayClass()) {
diff --git a/runtime/mirror/class.cc b/runtime/mirror/class.cc
index 61be9a0055..b54e10069d 100644
--- a/runtime/mirror/class.cc
+++ b/runtime/mirror/class.cc
@@ -1817,8 +1817,15 @@ uint32_t Class::Depth() {
}
dex::TypeIndex Class::FindTypeIndexInOtherDexFile(const DexFile& dex_file) {
- std::string temp;
- const dex::TypeId* type_id = dex_file.FindTypeId(GetDescriptor(&temp));
+ std::string_view descriptor;
+ std::optional<std::string> temp;
+ if (IsPrimitive() || IsArrayClass() || IsProxyClass()) {
+ temp.emplace();
+ descriptor = GetDescriptor(&temp.value());
+ } else {
+ descriptor = GetDescriptorView();
+ }
+ const dex::TypeId* type_id = dex_file.FindTypeId(descriptor);
return (type_id == nullptr) ? dex::TypeIndex() : dex_file.GetIndexForTypeId(*type_id);
}
diff --git a/runtime/mirror/class.h b/runtime/mirror/class.h
index 2a95d2227d..17d45b4312 100644
--- a/runtime/mirror/class.h
+++ b/runtime/mirror/class.h
@@ -1226,6 +1226,10 @@ class EXPORT MANAGED Class final : public Object {
void SetSkipAccessChecksFlagOnAllMethods(PointerSize pointer_size)
REQUIRES_SHARED(Locks::mutator_lock_);
+ // Get the descriptor of the class as `std::string_view`. The class must be directly
+ // backed by a `DexFile` - it must not be primitive, array or proxy class.
+ std::string_view GetDescriptorView() REQUIRES_SHARED(Locks::mutator_lock_);
+
// Get the descriptor of the class. In a few cases a std::string is required, rather than
// always create one the storage argument is populated and its internal c_str() returned. We do
// this to avoid memory allocation in the common case.
diff --git a/runtime/oat/aot_class_linker.cc b/runtime/oat/aot_class_linker.cc
index 15bddb9333..e1ca63d44e 100644
--- a/runtime/oat/aot_class_linker.cc
+++ b/runtime/oat/aot_class_linker.cc
@@ -241,7 +241,7 @@ bool AotClassLinker::DenyAccessBasedOnPublicSdk(ArtMethod* art_method) const {
bool AotClassLinker::DenyAccessBasedOnPublicSdk(ArtField* art_field) const {
return sdk_checker_ != nullptr && sdk_checker_->ShouldDenyAccess(art_field);
}
-bool AotClassLinker::DenyAccessBasedOnPublicSdk(const char* type_descriptor) const {
+bool AotClassLinker::DenyAccessBasedOnPublicSdk(std::string_view type_descriptor) const {
return sdk_checker_ != nullptr && sdk_checker_->ShouldDenyAccess(type_descriptor);
}
diff --git a/runtime/oat/aot_class_linker.h b/runtime/oat/aot_class_linker.h
index d74103260b..b046f1e66a 100644
--- a/runtime/oat/aot_class_linker.h
+++ b/runtime/oat/aot_class_linker.h
@@ -47,7 +47,7 @@ class AotClassLinker : public ClassLinker {
REQUIRES_SHARED(Locks::mutator_lock_);
bool DenyAccessBasedOnPublicSdk(ArtField* art_field) const override
REQUIRES_SHARED(Locks::mutator_lock_);
- bool DenyAccessBasedOnPublicSdk(const char* type_descriptor) const override;
+ bool DenyAccessBasedOnPublicSdk(std::string_view type_descriptor) const override;
void SetEnablePublicSdkChecks(bool enabled) override;
// Transaction constraint checks for AOT compilation.
diff --git a/runtime/oat/oat_file.cc b/runtime/oat/oat_file.cc
index 97db7569cf..8a6ab21c76 100644
--- a/runtime/oat/oat_file.cc
+++ b/runtime/oat/oat_file.cc
@@ -2339,7 +2339,7 @@ OatFile::OatClass OatDexFile::GetOatClass(uint16_t class_def_index) const {
}
const dex::ClassDef* OatDexFile::FindClassDef(const DexFile& dex_file,
- const char* descriptor,
+ std::string_view descriptor,
size_t hash) {
const OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
DCHECK_EQ(ComputeModifiedUtf8Hash(descriptor), hash);
diff --git a/runtime/oat/oat_file.h b/runtime/oat/oat_file.h
index 579fb049f0..d37dc76c54 100644
--- a/runtime/oat/oat_file.h
+++ b/runtime/oat/oat_file.h
@@ -604,7 +604,7 @@ class OatDexFile final {
// Looks up a class definition by its class descriptor. Hash must be
// ComputeModifiedUtf8Hash(descriptor).
EXPORT static const dex::ClassDef* FindClassDef(const DexFile& dex_file,
- const char* descriptor,
+ std::string_view descriptor,
size_t hash);
const TypeLookupTable& GetTypeLookupTable() const {
diff --git a/runtime/sdk_checker.cc b/runtime/sdk_checker.cc
index 58a9d081bb..40987e96b5 100644
--- a/runtime/sdk_checker.cc
+++ b/runtime/sdk_checker.cc
@@ -47,7 +47,7 @@ bool SdkChecker::ShouldDenyAccess(ArtMethod* art_method) const {
return false;
}
- const char* declaring_class_descriptor = art_method->GetDeclaringClassDescriptor();
+ std::string_view declaring_class_descriptor = art_method->GetDeclaringClassDescriptorView();
const char* name = art_method->GetName();
bool found = false;
@@ -93,9 +93,9 @@ bool SdkChecker::ShouldDenyAccess(ArtField* art_field) const {
return false;
}
- const char* declaring_class_descriptor = art_field->GetDeclaringClassDescriptor();
+ std::string_view declaring_class_descriptor = art_field->GetDeclaringClassDescriptorView();
const char* name = art_field->GetName();
- const char* type_descriptor = art_field->GetTypeDescriptor();
+ std::string_view type_descriptor = art_field->GetTypeDescriptorView();
bool found = false;
for (const std::unique_ptr<const DexFile>& dex_file : sdk_dex_files_) {
@@ -127,7 +127,7 @@ bool SdkChecker::ShouldDenyAccess(ArtField* art_field) const {
return !found;
}
-bool SdkChecker::ShouldDenyAccess(const char* descriptor) const {
+bool SdkChecker::ShouldDenyAccess(std::string_view descriptor) const {
if (!enabled_) {
return false;
}
diff --git a/runtime/sdk_checker.h b/runtime/sdk_checker.h
index 6bd0b2a15b..08e4479846 100644
--- a/runtime/sdk_checker.h
+++ b/runtime/sdk_checker.h
@@ -59,7 +59,7 @@ class SdkChecker {
bool ShouldDenyAccess(ArtField* art_field) const REQUIRES_SHARED(Locks::mutator_lock_);
// Similar to ShouldDenyAccess(ArtMethod* art_method).
- bool ShouldDenyAccess(const char* type_descriptor) const;
+ bool ShouldDenyAccess(std::string_view type_descriptor) const;
// Enabled/Disable the checks.
void SetEnabled(bool enabled) { enabled_ = enabled; }