Revert "Optimize register mask and stack mask in stack maps."

This reverts commit ffaf87a429766ed80e6afee5bebea93db539620b.

Reason for revert: Breaks exception_test32 on target
for CMS and heap poisoning configs.

Change-Id: I127c17f693e28211a799f73a50e73105edee7e4c
diff --git a/runtime/stack_map.h b/runtime/stack_map.h
index 02d8713..91cecf0 100644
--- a/runtime/stack_map.h
+++ b/runtime/stack_map.h
@@ -799,24 +799,6 @@
   }
 };
 
-// Register masks tend to have many tailing zero bits,
-// therefore it is worth encoding them as value+shift.
-class RegisterMask : public BitTable<2>::Accessor {
- public:
-  enum Field {
-    kValue,
-    kShift,
-    kCount,
-  };
-
-  RegisterMask(const BitTable<kCount>* table, uint32_t row)
-    : BitTable<kCount>::Accessor(table, row) {}
-
-  ALWAYS_INLINE uint32_t GetMask() const {
-    return Get<kValue>() << Get<kShift>();
-  }
-};
-
 /**
  * Wrapper around all compiler information collected for a method.
  * The information is of the form:
@@ -851,22 +833,24 @@
     return DexRegisterLocationCatalog(location_catalog_);
   }
 
+  ALWAYS_INLINE size_t GetNumberOfStackMaskBits() const {
+    return stack_mask_bits_;
+  }
+
   ALWAYS_INLINE StackMap GetStackMapAt(size_t index) const {
     return StackMap(&stack_maps_, index);
   }
 
   BitMemoryRegion GetStackMask(size_t index) const {
-    return stack_masks_.GetBitMemoryRegion(index);
+    return stack_masks_.Subregion(index * stack_mask_bits_, stack_mask_bits_);
   }
 
   BitMemoryRegion GetStackMaskOf(const StackMap& stack_map) const {
-    uint32_t index = stack_map.GetStackMaskIndex();
-    return (index == StackMap::kNoValue) ? BitMemoryRegion() : GetStackMask(index);
+    return GetStackMask(stack_map.GetStackMaskIndex());
   }
 
   uint32_t GetRegisterMaskOf(const StackMap& stack_map) const {
-    uint32_t index = stack_map.GetRegisterMaskIndex();
-    return (index == StackMap::kNoValue) ? 0 : RegisterMask(&register_masks_, index).GetMask();
+    return register_masks_.Get(stack_map.GetRegisterMaskIndex());
   }
 
   uint32_t GetNumberOfLocationCatalogEntries() const {
@@ -1061,8 +1045,8 @@
     invoke_infos_.Decode(bit_region, &bit_offset);
     inline_infos_.Decode(bit_region, &bit_offset);
     register_masks_.Decode(bit_region, &bit_offset);
-    stack_masks_.Decode(bit_region, &bit_offset);
-    CHECK_EQ(BitsToBytesRoundUp(bit_offset), non_header_size);
+    stack_mask_bits_ = DecodeVarintBits(bit_region, &bit_offset);
+    stack_masks_ = bit_region.Subregion(bit_offset, non_header_size * kBitsPerByte - bit_offset);
   }
 
   size_t size_;
@@ -1072,8 +1056,9 @@
   BitTable<StackMap::Field::kCount> stack_maps_;
   BitTable<InvokeInfo::Field::kCount> invoke_infos_;
   BitTable<InlineInfo::Field::kCount> inline_infos_;
-  BitTable<RegisterMask::Field::kCount> register_masks_;
-  BitTable<1> stack_masks_;
+  BitTable<1> register_masks_;
+  uint32_t stack_mask_bits_ = 0;
+  BitMemoryRegion stack_masks_;
 
   friend class OatDumper;
 };