diff options
author | 2024-04-09 12:49:48 +0000 | |
---|---|---|
committer | 2024-04-11 15:10:07 +0000 | |
commit | e8da7cd1d0e7d3535c82f8d05adcef3edd43cd40 (patch) | |
tree | f39114f368998a7b6415bb905fa71dc04dc3b232 /runtime/entrypoints/entrypoint_utils-inl.h | |
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 'runtime/entrypoints/entrypoint_utils-inl.h')
-rw-r--r-- | runtime/entrypoints/entrypoint_utils-inl.h | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/runtime/entrypoints/entrypoint_utils-inl.h b/runtime/entrypoints/entrypoint_utils-inl.h index 6cda30ee9d..b0d0ab4b07 100644 --- a/runtime/entrypoints/entrypoint_utils-inl.h +++ b/runtime/entrypoints/entrypoint_utils-inl.h @@ -485,15 +485,14 @@ EXPLICIT_FIND_FIELD_FROM_CODE_TEMPLATE_DECL(StaticPrimitiveWrite); static inline bool IsStringInit(const DexFile* dex_file, uint32_t method_idx) REQUIRES_SHARED(Locks::mutator_lock_) { const dex::MethodId& method_id = dex_file->GetMethodId(method_idx); - const char* class_name = dex_file->StringByTypeIdx(method_id.class_idx_); - const char* method_name = dex_file->GetMethodName(method_id); + const std::string_view class_name = dex_file->GetTypeDescriptorView(method_id.class_idx_); + const std::string_view method_name = dex_file->GetMethodNameView(method_id); // Instead of calling ResolveMethod() which has suspend point and can trigger // GC, look up the method symbolically. // Compare method's class name and method name against string init. // It's ok since it's not allowed to create your own java/lang/String. // TODO: verify that assumption. - if ((strcmp(class_name, "Ljava/lang/String;") == 0) && - (strcmp(method_name, "<init>") == 0)) { + if (class_name == "Ljava/lang/String;" && method_name == "<init>") { return true; } return false; |