From 38e9b0c97323368a5b3edd1cb24ab9a5fb38e06d Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Fri, 11 Oct 2024 14:54:33 +0000 Subject: verifier: Cache types by type index. Speed up `RegType` lookup in `RegTypeCache` by adding a cache based on `dex::TypeIndex` for types referenced by the current dex file. This slows down the construction of the `RegTypeCache` but the benefits of faster lookup outweigh the slower construction now that we're constructing the `RegTypeCache` only once per class and not once per method. Remove the `MethodParamListDescriptorIterator` as it was providing only descriptors from the resolved method's dex file and we can get the same descriptors from the current dex file based on the invoke's `dex::ProtoIndex`. This also allows using the new `TypeIndex`-based cache for this work. Clean up the `RegTypeCache` interface by inlining functions `FindClass()` and `InsertClass()` to the only remaining user `FromClass()` and update tests to use `FromClass()` instead. Move the descriptor retrieval from callers to `FromClass()`. Avoid some unnecessary string copy with `AddString()` in `RegTypeCache::FromClass()`. Add a TODO comment to avoid the string copy in `RegTypeCache::From()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: Iea429a33983104165c2ad2cf108d2b7d88f8b9e7 --- dex2oat/verifier_deps_test.cc | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'dex2oat') diff --git a/dex2oat/verifier_deps_test.cc b/dex2oat/verifier_deps_test.cc index 46e40902de..686f18803c 100644 --- a/dex2oat/verifier_deps_test.cc +++ b/dex2oat/verifier_deps_test.cc @@ -162,14 +162,14 @@ class VerifierDepsTest : public CommonCompilerDriverTest { method.GetInvokeType(class_def->access_flags_)); CHECK(resolved_method != nullptr); if (method_name == resolved_method->GetName()) { - RegTypeCache reg_types(soa.Self(), class_linker_, Runtime::Current()->GetArenaPool()); + ArenaPool* arena_pool = Runtime::Current()->GetArenaPool(); + RegTypeCache reg_types( + soa.Self(), class_linker_, arena_pool, class_loader_handle, primary_dex_file_); std::unique_ptr verifier( MethodVerifier::CreateVerifier(soa.Self(), ®_types, callbacks_->GetVerifierDeps(), - primary_dex_file_, dex_cache_handle, - class_loader_handle, *class_def, method.GetCodeItem(), method.GetIndex(), -- cgit v1.2.3-59-g8ed1b