Reduce dex2oat memory usage from VariableHandleScope.

Pack more handles in FixedSizeHandleScope<>s to reduce the
per-Handle<> overhead.

Measured compilation of a big app using heaptrack:
  before:
    3571397 calls to allocation functions with 2.59MB peak
    consumption from art::MutableHandle<>
    art::ReferenceTypePropagation::HandleCache::NewHandle<>(art::ObjPtr<>)
  after:
    1139808 calls to allocation functions with 1.54MB peak
    consumption from art::MutableHandle<>
    art::ReferenceTypePropagation::HandleCache::NewHandle<>(art::ObjPtr<>)

Test: Rely on TreeHugger.
Bug: 34053922
Change-Id: I160990f3a89aadffc9e6753da30b448937f8eaf0
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h
index adb7d8a..f6720bd 100644
--- a/runtime/handle_scope.h
+++ b/runtime/handle_scope.h
@@ -250,7 +250,7 @@
   StackReference<mirror::Object> storage_[kNumReferences];
 
   // Position new handles will be created.
-  size_t pos_ = 0;
+  uint32_t pos_ = 0;
 
   template<size_t kNumRefs> friend class StackHandleScope;
   friend class VariableSizedHandleScope;
@@ -299,12 +299,20 @@
   void VisitRoots(Visitor& visitor) REQUIRES_SHARED(Locks::mutator_lock_);
 
  private:
-  static constexpr size_t kNumReferencesPerScope = 4;
+  static constexpr size_t kLocalScopeSize = 64u;
+  static constexpr size_t kSizeOfReferencesPerScope =
+      kLocalScopeSize
+          - /* BaseHandleScope::link_ */ sizeof(BaseHandleScope*)
+          - /* BaseHandleScope::number_of_references_ */ sizeof(int32_t)
+          - /* FixedSizeHandleScope<>::pos_ */ sizeof(uint32_t);
+  static constexpr size_t kNumReferencesPerScope =
+      kSizeOfReferencesPerScope / sizeof(StackReference<mirror::Object>);
 
   Thread* const self_;
 
   // Linked list of fixed size handle scopes.
   using LocalScopeType = FixedSizeHandleScope<kNumReferencesPerScope>;
+  static_assert(sizeof(LocalScopeType) == kLocalScopeSize, "Unexpected size of LocalScopeType");
   LocalScopeType* current_scope_;
 
   DISALLOW_COPY_AND_ASSIGN(VariableSizedHandleScope);