Use dex cache from compilation unit in HInstructionBuilder.
Avoid calling costly ClassLinker::FindDexCache() from
HInstructionBuilder, the dex cache is already available in
the compilation unit. Compiling Nexus 5 boot image on host
under perf(1) shows that the time spent in FindDexCache()
is reduced from about 2% to well under 0.2%, 90% of the
remaining hits coming from ReferenceTypePropagation which
doesn't have access to the compilation unit.
Change-Id: Id9df61c79db9a67e3f12c857f32a4ca80e5420c3
diff --git a/compiler/driver/compiler_driver.h b/compiler/driver/compiler_driver.h
index 4308eac..d63dffa 100644
--- a/compiler/driver/compiler_driver.h
+++ b/compiler/driver/compiler_driver.h
@@ -195,25 +195,26 @@
// Callbacks from compiler to see what runtime checks must be generated.
- bool CanAssumeTypeIsPresentInDexCache(const DexFile& dex_file, uint32_t type_idx);
+ bool CanAssumeTypeIsPresentInDexCache(Handle<mirror::DexCache> dex_cache,
+ uint32_t type_idx)
+ SHARED_REQUIRES(Locks::mutator_lock_);
bool CanAssumeStringIsPresentInDexCache(const DexFile& dex_file, uint32_t string_idx)
REQUIRES(!Locks::mutator_lock_);
// Are runtime access checks necessary in the compiled code?
- bool CanAccessTypeWithoutChecks(uint32_t referrer_idx, const DexFile& dex_file,
- uint32_t type_idx, bool* type_known_final = nullptr,
- bool* type_known_abstract = nullptr,
- bool* equals_referrers_class = nullptr)
- REQUIRES(!Locks::mutator_lock_);
+ bool CanAccessTypeWithoutChecks(uint32_t referrer_idx,
+ Handle<mirror::DexCache> dex_cache,
+ uint32_t type_idx)
+ SHARED_REQUIRES(Locks::mutator_lock_);
// Are runtime access and instantiable checks necessary in the code?
// out_is_finalizable is set to whether the type is finalizable.
bool CanAccessInstantiableTypeWithoutChecks(uint32_t referrer_idx,
- const DexFile& dex_file,
+ Handle<mirror::DexCache> dex_cache,
uint32_t type_idx,
bool* out_is_finalizable)
- REQUIRES(!Locks::mutator_lock_);
+ SHARED_REQUIRES(Locks::mutator_lock_);
bool CanEmbedTypeInCode(const DexFile& dex_file, uint32_t type_idx,
bool* is_type_initialized, bool* use_direct_type_ptr,
@@ -368,14 +369,6 @@
SHARED_REQUIRES(Locks::mutator_lock_);
- // Can we fastpath static field access? Computes field's offset, volatility and whether the
- // field is within the referrer (which can avoid checking class initialization).
- bool ComputeStaticFieldInfo(uint32_t field_idx, const DexCompilationUnit* mUnit, bool is_put,
- MemberOffset* field_offset, uint32_t* storage_index,
- bool* is_referrers_class, bool* is_volatile, bool* is_initialized,
- Primitive::Type* type)
- REQUIRES(!Locks::mutator_lock_);
-
// Can we fastpath a interface, super class or virtual method call? Computes method's vtable
// index.
bool ComputeInvokeInfo(const DexCompilationUnit* mUnit, const uint32_t dex_pc,