diff options
author | 2018-06-23 22:05:56 +0100 | |
---|---|---|
committer | 2018-07-27 15:03:06 +0100 | |
commit | 8808756b8fba036a9c73a45c800a56be09872364 (patch) | |
tree | 9b28f314ff516d1d9b85d07f71bdc77fad465e48 | |
parent | dda4e8b5f2ffed24a2dcdb99d2301d9fc0eb91e2 (diff) |
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
-rw-r--r-- | compiler/common_compiler_test.cc | 7 | ||||
-rw-r--r-- | compiler/compiled_method.cc | 12 | ||||
-rw-r--r-- | compiler/compiled_method.h | 24 | ||||
-rw-r--r-- | compiler/dex/dex_to_dex_compiler.cc | 3 | ||||
-rw-r--r-- | compiler/driver/compiled_method_storage_test.cc | 2 | ||||
-rw-r--r-- | compiler/exception_test.cc | 2 | ||||
-rw-r--r-- | compiler/optimizing/optimizing_compiler.cc | 15 | ||||
-rw-r--r-- | dex2oat/linker/oat_writer.cc | 17 | ||||
-rw-r--r-- | dex2oat/linker/oat_writer_test.cc | 5 | ||||
-rw-r--r-- | dex2oat/linker/relative_patcher_test.h | 3 | ||||
-rw-r--r-- | runtime/jit/jit_code_cache.cc | 15 | ||||
-rw-r--r-- | runtime/jit/jit_code_cache.h | 6 | ||||
-rw-r--r-- | runtime/oat.h | 4 | ||||
-rw-r--r-- | runtime/oat_quick_method_header.cc | 11 | ||||
-rw-r--r-- | runtime/oat_quick_method_header.h | 23 |
15 files changed, 20 insertions, 129 deletions
diff --git a/compiler/common_compiler_test.cc b/compiler/common_compiler_test.cc index e8e1d408ef..4824763288 100644 --- a/compiler/common_compiler_test.cc +++ b/compiler/common_compiler_test.cc @@ -70,12 +70,7 @@ void CommonCompilerTest::MakeExecutable(ArtMethod* method) { 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 e41371855d..5b93316b87 100644 --- a/compiler/compiled_method.cc +++ b/compiler/compiled_method.cc @@ -102,17 +102,11 @@ const void* CompiledCode::CodePointer(const void* code_pointer, InstructionSet i 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 @@ CompiledMethod* CompiledMethod::SwapAllocCompiledMethod( 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 @@ CompiledMethod* CompiledMethod::SwapAllocCompiledMethod( 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 acdce260e5..aa6fd3e655 100644 --- a/compiler/compiled_method.h +++ b/compiler/compiled_method.h @@ -112,9 +112,6 @@ class CompiledMethod FINAL : public CompiledCode { 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 @@ class CompiledMethod FINAL : public CompiledCode { 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 @@ class CompiledMethod FINAL : public CompiledCode { 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 @@ class CompiledMethod FINAL : public CompiledCode { 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 fcaa0cdd07..0800ab3d41 100644 --- a/compiler/dex/dex_to_dex_compiler.cc +++ b/compiler/dex/dex_to_dex_compiler.cc @@ -619,9 +619,6 @@ CompiledMethod* DexToDexCompiler::CompileMethod( 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 f25ee9b5a6..14d1e191ca 100644 --- a/compiler/driver/compiled_method_storage_test.cc +++ b/compiler/driver/compiled_method_storage_test.cc @@ -84,7 +84,7 @@ TEST(CompiledMethodStorage, Deduplicate) { 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 b56a991e74..90c9e52e84 100644 --- a/compiler/exception_test.cc +++ b/compiler/exception_test.cc @@ -89,7 +89,7 @@ class ExceptionTest : public CommonRuntimeTest { 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 2f530a911a..939802626c 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -726,12 +726,6 @@ CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* allocator, 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 @@ CompiledMethod* OptimizingCompiler::JniCompile(uint32_t access_flags, 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 @@ bool OptimizingCompiler::JitCompile(Thread* self, 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 @@ bool OptimizingCompiler::JitCompile(Thread* self, 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 0a212bde53..20ae19afd8 100644 --- a/dex2oat/linker/oat_writer.cc +++ b/dex2oat/linker/oat_writer.cc @@ -1329,15 +1329,7 @@ class OatWriter::LayoutReserveOffsetCodeMethodVisitor : public OrderedMethodVisi 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 @@ class OatWriter::LayoutReserveOffsetCodeMethodVisitor : public OrderedMethodVisi // 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 @@ class OatWriter::LayoutReserveOffsetCodeMethodVisitor : public OrderedMethodVisi 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 f8370515b5..37d0a3f5ce 100644 --- a/dex2oat/linker/oat_writer_test.cc +++ b/dex2oat/linker/oat_writer_test.cc @@ -72,9 +72,6 @@ class OatTest : public CommonCompilerTest { } 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 @@ TEST_F(OatTest, OatHeaderSizeCheck) { // 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 ae58b54863..075771d152 100644 --- a/dex2oat/linker/relative_patcher_test.h +++ b/dex2oat/linker/relative_patcher_test.h @@ -87,9 +87,6 @@ class RelativePatcherTest : public CommonCompilerTest { 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 17561d2864..9aa05561f0 100644 --- a/runtime/jit/jit_code_cache.cc +++ b/runtime/jit/jit_code_cache.cc @@ -413,9 +413,6 @@ uint8_t* JitCodeCache::CommitCode(Thread* self, 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 @@ uint8_t* JitCodeCache::CommitCode(Thread* self, 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 @@ uint8_t* JitCodeCache::CommitCode(Thread* self, 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* JitCodeCache::CommitCodeInternal(Thread* self, 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 @@ uint8_t* JitCodeCache::CommitCodeInternal(Thread* self, 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 49a19a18f1..d17fb261b6 100644 --- a/runtime/jit/jit_code_cache.h +++ b/runtime/jit/jit_code_cache.h @@ -138,9 +138,6 @@ class JitCodeCache { 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 @@ class JitCodeCache { 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 3fa5a632b1..3939eec1ac 100644 --- a/runtime/oat.h +++ b/runtime/oat.h @@ -32,8 +32,8 @@ class InstructionSetFeatures; 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 79c3ad6b45..3ed2a91be6 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 1e4ca3e450..3b9f466220 100644 --- a/runtime/oat_quick_method_header.h +++ b/runtime/oat_quick_method_header.h @@ -32,12 +32,13 @@ class ArtMethod; 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 @@ class PACKED(4) OatQuickMethodHeader { 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 @@ class PACKED(4) OatQuickMethodHeader { 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 @@ class PACKED(4) OatQuickMethodHeader { // 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; |