ART: Add pointer-size template to some reflection functions
The unstarted runtime may run code for a different pointer size,
even when no transaction is active (e.g., during startup). To
retain performance when the runtime is up and executing under
normal conditions, add a template parameter and use sizeof(void*)
in places where it is adequate.
For maintainability, it is necessary to drop the default for
the transaction template parameter. Implicit conversions from
bool to size_t may lead to incorrect code and hard to diagnose
problems. So instead ensure that all callers must give all
template parameter values.
Test: m test-art-host
Change-Id: I3076883422c8553ede4de5642409c5684a5a9aa8
diff --git a/runtime/mirror/field.h b/runtime/mirror/field.h
index edaddbd..2bd6132 100644
--- a/runtime/mirror/field.h
+++ b/runtime/mirror/field.h
@@ -92,7 +92,7 @@
// Slow, try to use only for PrettyField and such.
ArtField* GetArtField() SHARED_REQUIRES(Locks::mutator_lock_);
- template <bool kTransactionActive = false>
+ template <size_t kPointerSize, bool kTransactionActive = false>
static mirror::Field* CreateFromArtField(Thread* self, ArtField* field,
bool force_resolve)
SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!Roles::uninterruptible_);