Several fixes for proper creation and use of vmap tables

Change-Id: I7696115af4263df18ede0777ae14de7a3a7ada3b
diff --git a/src/compiled_method.cc b/src/compiled_method.cc
index 2846ab3..082600f 100644
--- a/src/compiled_method.cc
+++ b/src/compiled_method.cc
@@ -13,6 +13,7 @@
                                std::vector<uint32_t>& mapping_table,
                                std::vector<uint16_t>& vmap_table) {
   CHECK_NE(short_code.size(), 0U);
+  CHECK_GE(vmap_table.size(), 1U);  // should always contain an entry for LR
 
   size_t code_byte_count = short_code.size() * sizeof(short_code[0]);
   std::vector<uint8_t> byte_code(code_byte_count);
@@ -31,6 +32,7 @@
                                     vmap_table.begin(),
                                     vmap_table.end());
   DCHECK_EQ(vmap_table.size() + 1, length_prefixed_vmap_table.size());
+  DCHECK_EQ(vmap_table.size(), length_prefixed_vmap_table[0]);
 
   instruction_set_ = instruction_set;
   code_ = byte_code;
@@ -40,6 +42,8 @@
   fp_spill_mask_ = fp_spill_mask;
   mapping_table_ = length_prefixed_mapping_table;
   vmap_table_ = length_prefixed_vmap_table;
+
+  DCHECK_EQ(vmap_table_[0], static_cast<uint32_t>(__builtin_popcount(core_spill_mask) + __builtin_popcount(fp_spill_mask)));
 }
 
 CompiledMethod::CompiledMethod(InstructionSet instruction_set,