Remove frame info from OatQuickMethodHeader.

The information has been moved to CodeInfo,
where it is stored in much more compact way.

The old CL which added the data to CodeInfo cost 0.7%.
This CL saves 2.5% of .oat file size so a win overall.

Test: test-art-host-gtest
Change-Id: I07fcf6f2776c96218f995ba3b57a1e6ccbf5e317
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc
index e8e1d40..4824763 100644
--- a/compiler/common_compiler_test.cc
+++ b/compiler/common_compiler_test.cc
@@ -70,12 +70,7 @@
     const uint32_t method_info_offset = method_info.empty() ? 0u
         : vmap_table_offset + method_info.size();
 
-    OatQuickMethodHeader method_header(vmap_table_offset,
-                                       method_info_offset,
-                                       compiled_method->GetFrameSizeInBytes(),
-                                       compiled_method->GetCoreSpillMask(),
-                                       compiled_method->GetFpSpillMask(),
-                                       code_size);
+    OatQuickMethodHeader method_header(vmap_table_offset, method_info_offset, code_size);
 
     header_code_and_maps_chunks_.push_back(std::vector<uint8_t>());
     std::vector<uint8_t>* chunk = &header_code_and_maps_chunks_.back();
diff --git a/compiler/compiled_method.cc b/compiler/compiled_method.cc
index e413718..5b93316 100644
--- a/compiler/compiled_method.cc
+++ b/compiler/compiled_method.cc
@@ -102,17 +102,11 @@
 CompiledMethod::CompiledMethod(CompilerDriver* driver,
                                InstructionSet instruction_set,
                                const ArrayRef<const uint8_t>& quick_code,
-                               const size_t frame_size_in_bytes,
-                               const uint32_t core_spill_mask,
-                               const uint32_t fp_spill_mask,
                                const ArrayRef<const uint8_t>& method_info,
                                const ArrayRef<const uint8_t>& vmap_table,
                                const ArrayRef<const uint8_t>& cfi_info,
                                const ArrayRef<const linker::LinkerPatch>& patches)
     : CompiledCode(driver, instruction_set, quick_code),
-      frame_size_in_bytes_(frame_size_in_bytes),
-      core_spill_mask_(core_spill_mask),
-      fp_spill_mask_(fp_spill_mask),
       method_info_(driver->GetCompiledMethodStorage()->DeduplicateMethodInfo(method_info)),
       vmap_table_(driver->GetCompiledMethodStorage()->DeduplicateVMapTable(vmap_table)),
       cfi_info_(driver->GetCompiledMethodStorage()->DeduplicateCFIInfo(cfi_info)),
@@ -123,9 +117,6 @@
     CompilerDriver* driver,
     InstructionSet instruction_set,
     const ArrayRef<const uint8_t>& quick_code,
-    const size_t frame_size_in_bytes,
-    const uint32_t core_spill_mask,
-    const uint32_t fp_spill_mask,
     const ArrayRef<const uint8_t>& method_info,
     const ArrayRef<const uint8_t>& vmap_table,
     const ArrayRef<const uint8_t>& cfi_info,
@@ -136,9 +127,6 @@
                   driver,
                   instruction_set,
                   quick_code,
-                  frame_size_in_bytes,
-                  core_spill_mask,
-                  fp_spill_mask,
                   method_info,
                   vmap_table,
                   cfi_info, patches);
diff --git a/compiler/compiled_method.h b/compiler/compiled_method.h
index acdce26..aa6fd3e 100644
--- a/compiler/compiled_method.h
+++ b/compiler/compiled_method.h
@@ -112,9 +112,6 @@
   CompiledMethod(CompilerDriver* driver,
                  InstructionSet instruction_set,
                  const ArrayRef<const uint8_t>& quick_code,
-                 const size_t frame_size_in_bytes,
-                 const uint32_t core_spill_mask,
-                 const uint32_t fp_spill_mask,
                  const ArrayRef<const uint8_t>& method_info,
                  const ArrayRef<const uint8_t>& vmap_table,
                  const ArrayRef<const uint8_t>& cfi_info,
@@ -126,9 +123,6 @@
       CompilerDriver* driver,
       InstructionSet instruction_set,
       const ArrayRef<const uint8_t>& quick_code,
-      const size_t frame_size_in_bytes,
-      const uint32_t core_spill_mask,
-      const uint32_t fp_spill_mask,
       const ArrayRef<const uint8_t>& method_info,
       const ArrayRef<const uint8_t>& vmap_table,
       const ArrayRef<const uint8_t>& cfi_info,
@@ -148,18 +142,6 @@
     SetPackedField<IsIntrinsicField>(/* value */ true);
   }
 
-  size_t GetFrameSizeInBytes() const {
-    return frame_size_in_bytes_;
-  }
-
-  uint32_t GetCoreSpillMask() const {
-    return core_spill_mask_;
-  }
-
-  uint32_t GetFpSpillMask() const {
-    return fp_spill_mask_;
-  }
-
   ArrayRef<const uint8_t> GetMethodInfo() const;
 
   ArrayRef<const uint8_t> GetVmapTable() const;
@@ -177,12 +159,6 @@
 
   using IsIntrinsicField = BitField<bool, kIsIntrinsicLsb, kIsIntrinsicSize>;
 
-  // For quick code, the size of the activation used by the code.
-  const size_t frame_size_in_bytes_;
-  // For quick code, a bit mask describing spilled GPR callee-save registers.
-  const uint32_t core_spill_mask_;
-  // For quick code, a bit mask describing spilled FPR callee-save registers.
-  const uint32_t fp_spill_mask_;
   // For quick code, method specific information that is not very dedupe friendly (method indices).
   const LengthPrefixedArray<uint8_t>* const method_info_;
   // For quick code, holds code infos which contain stack maps, inline information, and etc.
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index fcaa0cd..0800ab3 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -619,9 +619,6 @@
       driver_,
       instruction_set,
       ArrayRef<const uint8_t>(),                   // no code
-      0,
-      0,
-      0,
       ArrayRef<const uint8_t>(),                   // method_info
       ArrayRef<const uint8_t>(quicken_data),       // vmap_table
       ArrayRef<const uint8_t>(),                   // cfi data
diff --git a/compiler/driver/compiled_method_storage_test.cc b/compiler/driver/compiled_method_storage_test.cc
index f25ee9b..14d1e19 100644
--- a/compiler/driver/compiled_method_storage_test.cc
+++ b/compiler/driver/compiled_method_storage_test.cc
@@ -84,7 +84,7 @@
         for (auto&& f : cfi_info) {
           for (auto&& p : patches) {
             compiled_methods.push_back(CompiledMethod::SwapAllocCompiledMethod(
-                &driver, InstructionSet::kNone, c, 0u, 0u, 0u, s, v, f, p));
+                &driver, InstructionSet::kNone, c, s, v, f, p));
           }
         }
       }
diff --git a/compiler/exception_test.cc b/compiler/exception_test.cc
index b56a991..90c9e52 100644
--- a/compiler/exception_test.cc
+++ b/compiler/exception_test.cc
@@ -89,7 +89,7 @@
     fake_header_code_and_maps_.resize(code_offset + fake_code_.size());
     MemoryRegion stack_maps_region(&fake_header_code_and_maps_[0], stack_maps_size);
     stack_maps.FillInCodeInfo(stack_maps_region);
-    OatQuickMethodHeader method_header(code_offset, 0u, 4 * sizeof(void*), 0u, 0u, code_size);
+    OatQuickMethodHeader method_header(code_offset, 0u, code_size);
     static_assert(std::is_trivially_copyable<OatQuickMethodHeader>::value, "Cannot use memcpy");
     memcpy(&fake_header_code_and_maps_[code_offset - header_size], &method_header, header_size);
     std::copy(fake_code_.begin(),
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 2f530a9..9398026 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -726,12 +726,6 @@
       GetCompilerDriver(),
       codegen->GetInstructionSet(),
       code_allocator->GetMemory(),
-      // Follow Quick's behavior and set the frame size to zero if it is
-      // considered "empty" (see the definition of
-      // art::CodeGenerator::HasEmptyFrame).
-      codegen->HasEmptyFrame() ? 0 : codegen->GetFrameSize(),
-      codegen->GetCoreSpillMask(),
-      codegen->GetFpuSpillMask(),
       ArrayRef<const uint8_t>(method_info),
       ArrayRef<const uint8_t>(stack_map),
       ArrayRef<const uint8_t>(*codegen->GetAssembler()->cfi().data()),
@@ -1181,9 +1175,6 @@
       GetCompilerDriver(),
       jni_compiled_method.GetInstructionSet(),
       jni_compiled_method.GetCode(),
-      jni_compiled_method.GetFrameSize(),
-      jni_compiled_method.GetCoreSpillMask(),
-      jni_compiled_method.GetFpSpillMask(),
       ArrayRef<const uint8_t>(method_info),
       ArrayRef<const uint8_t>(stack_map),
       jni_compiled_method.GetCfi(),
@@ -1275,9 +1266,6 @@
         stack_map_data,
         method_info_data,
         roots_data,
-        jni_compiled_method.GetFrameSize(),
-        jni_compiled_method.GetCoreSpillMask(),
-        jni_compiled_method.GetFpSpillMask(),
         jni_compiled_method.GetCode().data(),
         jni_compiled_method.GetCode().size(),
         data_size,
@@ -1394,9 +1382,6 @@
       stack_map_data,
       method_info_data,
       roots_data,
-      codegen->HasEmptyFrame() ? 0 : codegen->GetFrameSize(),
-      codegen->GetCoreSpillMask(),
-      codegen->GetFpuSpillMask(),
       code_allocator.GetMemory().data(),
       code_allocator.GetMemory().size(),
       data_size,
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index 0a212bd..20ae19a 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -1329,15 +1329,7 @@
       method_info_offset += code_offset;
       DCHECK_LT(method_info_offset, code_offset);
     }
-    uint32_t frame_size_in_bytes = compiled_method->GetFrameSizeInBytes();
-    uint32_t core_spill_mask = compiled_method->GetCoreSpillMask();
-    uint32_t fp_spill_mask = compiled_method->GetFpSpillMask();
-    *method_header = OatQuickMethodHeader(vmap_table_offset,
-                                          method_info_offset,
-                                          frame_size_in_bytes,
-                                          core_spill_mask,
-                                          fp_spill_mask,
-                                          code_size);
+    *method_header = OatQuickMethodHeader(vmap_table_offset, method_info_offset, code_size);
 
     if (!deduped) {
       // Update offsets. (Checksum is updated when writing.)
@@ -1348,8 +1340,9 @@
     // Exclude quickened dex methods (code_size == 0) since they have no native code.
     if (generate_debug_info_ && code_size != 0) {
       DCHECK(has_debug_info);
+      const uint8_t* code_info = compiled_method->GetVmapTable().data();
+      DCHECK(code_info != nullptr);
 
-      bool has_code_info = method_header->IsOptimized();
       // Record debug information for this function if we are doing that.
       debug::MethodDebugInfo& info = writer_->method_info_[debug_info_idx];
       DCHECK(info.custom_name.empty());
@@ -1366,8 +1359,8 @@
       info.is_code_address_text_relative = true;
       info.code_address = code_offset - executable_offset_;
       info.code_size = code_size;
-      info.frame_size_in_bytes = compiled_method->GetFrameSizeInBytes();
-      info.code_info = has_code_info ? compiled_method->GetVmapTable().data() : nullptr;
+      info.frame_size_in_bytes = CodeInfo::DecodeFrameInfo(code_info).FrameSizeInBytes();
+      info.code_info = code_info;
       info.cfi = compiled_method->GetCFIInfo();
     } else {
       DCHECK(!has_debug_info);
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index f837051..37d0a3f 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -72,9 +72,6 @@
     } else {
       const void* quick_oat_code = oat_method.GetQuickCode();
       EXPECT_TRUE(quick_oat_code != nullptr) << method->PrettyMethod();
-      EXPECT_EQ(oat_method.GetFrameSizeInBytes(), compiled_method->GetFrameSizeInBytes());
-      EXPECT_EQ(oat_method.GetCoreSpillMask(), compiled_method->GetCoreSpillMask());
-      EXPECT_EQ(oat_method.GetFpSpillMask(), compiled_method->GetFpSpillMask());
       uintptr_t oat_code_aligned = RoundDown(reinterpret_cast<uintptr_t>(quick_oat_code), 2);
       quick_oat_code = reinterpret_cast<const void*>(oat_code_aligned);
       ArrayRef<const uint8_t> quick_code = compiled_method->GetQuickCode();
@@ -475,7 +472,7 @@
   // it is time to update OatHeader::kOatVersion
   EXPECT_EQ(76U, sizeof(OatHeader));
   EXPECT_EQ(4U, sizeof(OatMethodOffsets));
-  EXPECT_EQ(24U, sizeof(OatQuickMethodHeader));
+  EXPECT_EQ(12U, sizeof(OatQuickMethodHeader));
   EXPECT_EQ(166 * static_cast<size_t>(GetInstructionSetPointerSize(kRuntimeISA)),
             sizeof(QuickEntryPoints));
 }
diff --git a/dex2oat/linker/relative_patcher_test.h b/dex2oat/linker/relative_patcher_test.h
index ae58b54..075771d 100644
--- a/dex2oat/linker/relative_patcher_test.h
+++ b/dex2oat/linker/relative_patcher_test.h
@@ -87,9 +87,6 @@
         compiler_driver_.get(),
         instruction_set_,
         code,
-        /* frame_size_in_bytes */ 0u,
-        /* core_spill_mask */ 0u,
-        /* fp_spill_mask */ 0u,
         /* method_info */ ArrayRef<const uint8_t>(),
         /* vmap_table */ ArrayRef<const uint8_t>(),
         /* cfi_info */ ArrayRef<const uint8_t>(),
diff --git a/runtime/jit/jit_code_cache.cc b/runtime/jit/jit_code_cache.cc
index 17561d2..9aa05561 100644
--- a/runtime/jit/jit_code_cache.cc
+++ b/runtime/jit/jit_code_cache.cc
@@ -413,9 +413,6 @@
                                   uint8_t* stack_map,
                                   uint8_t* method_info,
                                   uint8_t* roots_data,
-                                  size_t frame_size_in_bytes,
-                                  size_t core_spill_mask,
-                                  size_t fp_spill_mask,
                                   const uint8_t* code,
                                   size_t code_size,
                                   size_t data_size,
@@ -428,9 +425,6 @@
                                        stack_map,
                                        method_info,
                                        roots_data,
-                                       frame_size_in_bytes,
-                                       core_spill_mask,
-                                       fp_spill_mask,
                                        code,
                                        code_size,
                                        data_size,
@@ -446,9 +440,6 @@
                                 stack_map,
                                 method_info,
                                 roots_data,
-                                frame_size_in_bytes,
-                                core_spill_mask,
-                                fp_spill_mask,
                                 code,
                                 code_size,
                                 data_size,
@@ -759,9 +750,6 @@
                                           uint8_t* stack_map,
                                           uint8_t* method_info,
                                           uint8_t* roots_data,
-                                          size_t frame_size_in_bytes,
-                                          size_t core_spill_mask,
-                                          size_t fp_spill_mask,
                                           const uint8_t* code,
                                           size_t code_size,
                                           size_t data_size,
@@ -796,9 +784,6 @@
       new (method_header) OatQuickMethodHeader(
           (stack_map != nullptr) ? code_ptr - stack_map : 0u,
           (method_info != nullptr) ? code_ptr - method_info : 0u,
-          frame_size_in_bytes,
-          core_spill_mask,
-          fp_spill_mask,
           code_size);
       // Flush caches before we remove write permission because some ARMv8 Qualcomm kernels may
       // trigger a segfault if a page fault occurs when requesting a cache maintenance operation.
diff --git a/runtime/jit/jit_code_cache.h b/runtime/jit/jit_code_cache.h
index 49a19a1..d17fb26 100644
--- a/runtime/jit/jit_code_cache.h
+++ b/runtime/jit/jit_code_cache.h
@@ -138,9 +138,6 @@
                       uint8_t* stack_map,
                       uint8_t* method_info,
                       uint8_t* roots_data,
-                      size_t frame_size_in_bytes,
-                      size_t core_spill_mask,
-                      size_t fp_spill_mask,
                       const uint8_t* code,
                       size_t code_size,
                       size_t data_size,
@@ -300,9 +297,6 @@
                               uint8_t* stack_map,
                               uint8_t* method_info,
                               uint8_t* roots_data,
-                              size_t frame_size_in_bytes,
-                              size_t core_spill_mask,
-                              size_t fp_spill_mask,
                               const uint8_t* code,
                               size_t code_size,
                               size_t data_size,
diff --git a/runtime/oat.h b/runtime/oat.h
index 3fa5a63..3939eec 100644
--- a/runtime/oat.h
+++ b/runtime/oat.h
@@ -32,8 +32,8 @@
 class PACKED(4) OatHeader {
  public:
   static constexpr uint8_t kOatMagic[] = { 'o', 'a', 't', '\n' };
-  // Last oat version changed reason: Move InlineInfo bit table.
-  static constexpr uint8_t kOatVersion[] = { '1', '5', '5', '\0' };
+  // Last oat version changed reason: Remove frame info from OatQuickMethodHeader.
+  static constexpr uint8_t kOatVersion[] = { '1', '5', '6', '\0' };
 
   static constexpr const char* kImageLocationKey = "image-location";
   static constexpr const char* kDex2OatCmdLineKey = "dex2oat-cmdline";
diff --git a/runtime/oat_quick_method_header.cc b/runtime/oat_quick_method_header.cc
index 79c3ad6..3ed2a91 100644
--- a/runtime/oat_quick_method_header.cc
+++ b/runtime/oat_quick_method_header.cc
@@ -24,17 +24,6 @@
 
 namespace art {
 
-OatQuickMethodHeader::OatQuickMethodHeader(uint32_t vmap_table_offset,
-                                           uint32_t method_info_offset,
-                                           uint32_t frame_size_in_bytes,
-                                           uint32_t core_spill_mask,
-                                           uint32_t fp_spill_mask,
-                                           uint32_t code_size)
-    : vmap_table_offset_(vmap_table_offset),
-      method_info_offset_(method_info_offset),
-      frame_info_(frame_size_in_bytes, core_spill_mask, fp_spill_mask),
-      code_size_(code_size) {}
-
 uint32_t OatQuickMethodHeader::ToDexPc(ArtMethod* method,
                                        const uintptr_t pc,
                                        bool abort_on_failure) const {
diff --git a/runtime/oat_quick_method_header.h b/runtime/oat_quick_method_header.h
index 1e4ca3e..3b9f466 100644
--- a/runtime/oat_quick_method_header.h
+++ b/runtime/oat_quick_method_header.h
@@ -32,12 +32,13 @@
 class PACKED(4) OatQuickMethodHeader {
  public:
   OatQuickMethodHeader() = default;
-  explicit OatQuickMethodHeader(uint32_t vmap_table_offset,
-                                uint32_t method_info_offset,
-                                uint32_t frame_size_in_bytes,
-                                uint32_t core_spill_mask,
-                                uint32_t fp_spill_mask,
-                                uint32_t code_size);
+  OatQuickMethodHeader(uint32_t vmap_table_offset,
+                       uint32_t method_info_offset,
+                       uint32_t code_size)
+      : vmap_table_offset_(vmap_table_offset),
+        method_info_offset_(method_info_offset),
+        code_size_(code_size) {
+  }
 
   static OatQuickMethodHeader* FromCodePointer(const void* code_ptr) {
     uintptr_t code = reinterpret_cast<uintptr_t>(code_ptr);
@@ -151,7 +152,7 @@
 
   template <bool kCheckFrameSize = true>
   uint32_t GetFrameSizeInBytes() const {
-    uint32_t result = frame_info_.FrameSizeInBytes();
+    uint32_t result = GetFrameInfo().FrameSizeInBytes();
     if (kCheckFrameSize) {
       DCHECK_ALIGNED(result, kStackAlignment);
     }
@@ -160,11 +161,7 @@
 
   QuickMethodFrameInfo GetFrameInfo() const {
     DCHECK(IsOptimized());
-    QuickMethodFrameInfo frame_info = CodeInfo::DecodeFrameInfo(GetOptimizedCodeInfoPtr());
-    DCHECK_EQ(frame_info.FrameSizeInBytes(), frame_info_.FrameSizeInBytes());
-    DCHECK_EQ(frame_info.CoreSpillMask(), frame_info_.CoreSpillMask());
-    DCHECK_EQ(frame_info.FpSpillMask(), frame_info_.FpSpillMask());
-    return frame_info;
+    return CodeInfo::DecodeFrameInfo(GetOptimizedCodeInfoPtr());
   }
 
   uintptr_t ToNativeQuickPc(ArtMethod* method,
@@ -194,8 +191,6 @@
   // would be lost from doing so. The method info memory region contains method indices since they
   // are hard to dedupe.
   uint32_t method_info_offset_ = 0u;
-  // The stack frame information.
-  QuickMethodFrameInfo frame_info_;
   // The code size in bytes. The highest bit is used to signify if the compiled
   // code with the method header has should_deoptimize flag.
   uint32_t code_size_ = 0u;