diff options
author | 2024-11-05 14:33:29 +0000 | |
---|---|---|
committer | 2024-11-11 08:33:23 +0000 | |
commit | 01df4b3a9bb31f21f451452f0ce47632dd8916ad (patch) | |
tree | 2414f41e33f7c1ec468ea7c6f141267a6387d537 /runtime/class_linker.h | |
parent | 8a2ca0019489d3e1c5a79789af68fb05822af9cb (diff) |
Avoid `strlen()` for `ClassLinker::FindClass()`...
... and related functions in most cases.
Note that the `CompilerDriver` previously resolved the
`ClassLoader` and `TransactionAbortError` using the provided
class loaders. We're now using the `ClassLoader` from the
class roots and resolving the `TransactionAbortError` in the
BCP class loader.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Bug: 338123769
Change-Id: I38e480cdcdb8bf02c958e4d0773437f5766f6be0
Diffstat (limited to 'runtime/class_linker.h')
-rw-r--r-- | runtime/class_linker.h | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/runtime/class_linker.h b/runtime/class_linker.h index ef8241ad2f..d1c82776cc 100644 --- a/runtime/class_linker.h +++ b/runtime/class_linker.h @@ -207,6 +207,15 @@ class ClassLinker { // If class_loader is null, searches boot_class_path_. EXPORT ObjPtr<mirror::Class> FindClass(Thread* self, const char* descriptor, + size_t descriptor_length, + Handle<mirror::ClassLoader> class_loader) + REQUIRES_SHARED(Locks::mutator_lock_) + REQUIRES(!Locks::dex_lock_); + + // Helper overload that retrieves the descriptor and its length from the `dex_file`. + EXPORT ObjPtr<mirror::Class> FindClass(Thread* self, + const DexFile& dex_file, + dex::TypeIndex type_index, Handle<mirror::ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_); @@ -216,7 +225,7 @@ class ClassLinker { ObjPtr<mirror::Class> FindSystemClass(Thread* self, const char* descriptor) REQUIRES_SHARED(Locks::mutator_lock_) REQUIRES(!Locks::dex_lock_) { - return FindClass(self, descriptor, ScopedNullHandle<mirror::ClassLoader>()); + return FindClass(self, descriptor, strlen(descriptor), ScopedNullHandle<mirror::ClassLoader>()); } // Finds the array class given for the element class. @@ -321,7 +330,7 @@ class ClassLinker { REQUIRES_SHARED(Locks::mutator_lock_); // Look up a resolved type with the given descriptor associated with the given ClassLoader. - ObjPtr<mirror::Class> LookupResolvedType(const char* descriptor, + ObjPtr<mirror::Class> LookupResolvedType(std::string_view descriptor, ObjPtr<mirror::ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_); @@ -1102,6 +1111,7 @@ class ClassLinker { ObjPtr<mirror::Class> CreateArrayClass(Thread* self, const char* descriptor, + size_t descriptor_length, size_t hash, Handle<mirror::ClassLoader> class_loader) REQUIRES_SHARED(Locks::mutator_lock_) |