Make VariableHandleScope consistent between 32 & 64 bit

The number of handles kept in a single bucket by
VariableSizedHandleScope varied between 32bit and 64bit hosts. On 32
bit hosts the bucket size was 13 elements and on 64bit it was 12
elements. This could affect the order objects are visited during heap
walks since they are visited in reverse-bucket order (last bucket
first, then next to last, etc).

This could cause the output of dex2oat to change depending on what
type of executable dex2oat is, breaking consistency requirements.

In order to fix this issue we lock the bucket size at 12 elements.

Test: ./test.py --host -j72
Bug: 122373634
Change-Id: I689392d0eb68ff8b8ebc85d155014b5bd3bb3a6b
diff --git a/runtime/handle_scope.h b/runtime/handle_scope.h
index 1a1c92f..6667aa3 100644
--- a/runtime/handle_scope.h
+++ b/runtime/handle_scope.h
@@ -300,20 +300,17 @@
   void VisitRoots(Visitor& visitor) REQUIRES_SHARED(Locks::mutator_lock_);
 
  private:
-  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>);
+  static constexpr size_t kMaxLocalScopeSize = 64u;
+  // In order to have consistent compilation with both 32bit and 64bit dex2oat
+  // binaries we need this to be an actual constant. We picked this because it
+  // will ensure that we use <64bit internal scopes.
+  static constexpr size_t kNumReferencesPerScope = 12u;
 
   Thread* const self_;
 
   // Linked list of fixed size handle scopes.
   using LocalScopeType = FixedSizeHandleScope<kNumReferencesPerScope>;
-  static_assert(sizeof(LocalScopeType) == kLocalScopeSize, "Unexpected size of LocalScopeType");
+  static_assert(sizeof(LocalScopeType) <= kMaxLocalScopeSize, "Unexpected size of LocalScopeType");
   LocalScopeType* current_scope_;
 
   DISALLOW_COPY_AND_ASSIGN(VariableSizedHandleScope);