diff options
author | 2016-12-19 12:58:45 +0000 | |
---|---|---|
committer | 2016-12-19 12:58:46 +0000 | |
commit | c0e74baddb0750723b69f54c2bc4fcdaa4be63f8 (patch) | |
tree | 68d0ba21ff9f1e2234923bbc92d6e10696851959 | |
parent | d96b96dd97e7fc757ff9ccc10d329869ff24503f (diff) | |
parent | b1677e2ff07d7cea3cf7ee91d7df202975c11836 (diff) |
Merge "Don't unquicken RETURN_VOID_NO_BARRIER with vdex."
-rw-r--r-- | compiler/dex/dex_to_dex_decompiler.cc | 20 | ||||
-rw-r--r-- | compiler/dex/dex_to_dex_decompiler.h | 3 | ||||
-rw-r--r-- | compiler/dex/dex_to_dex_decompiler_test.cc | 6 | ||||
-rw-r--r-- | compiler/driver/compiler_driver.cc | 19 |
4 files changed, 33 insertions, 15 deletions
diff --git a/compiler/dex/dex_to_dex_decompiler.cc b/compiler/dex/dex_to_dex_decompiler.cc index 051125eeaa..bfd485d126 100644 --- a/compiler/dex/dex_to_dex_decompiler.cc +++ b/compiler/dex/dex_to_dex_decompiler.cc @@ -27,10 +27,13 @@ namespace optimizer { class DexDecompiler { public: - DexDecompiler(const DexFile::CodeItem& code_item, const ArrayRef<const uint8_t>& quickened_info) + DexDecompiler(const DexFile::CodeItem& code_item, + const ArrayRef<const uint8_t>& quickened_info, + bool decompile_return_instruction) : code_item_(code_item), quickened_info_ptr_(quickened_info.data()), - quickened_info_end_(quickened_info.data() + quickened_info.size()) {} + quickened_info_end_(quickened_info.data() + quickened_info.size()), + decompile_return_instruction_(decompile_return_instruction) {} bool Decompile(); @@ -87,6 +90,7 @@ class DexDecompiler { const DexFile::CodeItem& code_item_; const uint8_t* quickened_info_ptr_; const uint8_t* const quickened_info_end_; + const bool decompile_return_instruction_; DISALLOW_COPY_AND_ASSIGN(DexDecompiler); }; @@ -102,7 +106,9 @@ bool DexDecompiler::Decompile() { switch (inst->Opcode()) { case Instruction::RETURN_VOID_NO_BARRIER: - inst->SetOpcode(Instruction::RETURN_VOID); + if (decompile_return_instruction_) { + inst->SetOpcode(Instruction::RETURN_VOID); + } break; case Instruction::NOP: @@ -189,8 +195,12 @@ bool DexDecompiler::Decompile() { } bool ArtDecompileDEX(const DexFile::CodeItem& code_item, - const ArrayRef<const uint8_t>& quickened_info) { - DexDecompiler decompiler(code_item, quickened_info); + const ArrayRef<const uint8_t>& quickened_info, + bool decompile_return_instruction) { + if (quickened_info.size() == 0 && !decompile_return_instruction) { + return true; + } + DexDecompiler decompiler(code_item, quickened_info, decompile_return_instruction); return decompiler.Decompile(); } diff --git a/compiler/dex/dex_to_dex_decompiler.h b/compiler/dex/dex_to_dex_decompiler.h index 5502ca2d92..b5d5b91915 100644 --- a/compiler/dex/dex_to_dex_decompiler.h +++ b/compiler/dex/dex_to_dex_decompiler.h @@ -30,7 +30,8 @@ namespace optimizer { // consistent with DexToDexCompiler, but we should really change it to // DexFile::CodeItem*. bool ArtDecompileDEX(const DexFile::CodeItem& code_item, - const ArrayRef<const uint8_t>& quickened_data); + const ArrayRef<const uint8_t>& quickened_data, + bool decompile_return_instruction); } // namespace optimizer } // namespace art diff --git a/compiler/dex/dex_to_dex_decompiler_test.cc b/compiler/dex/dex_to_dex_decompiler_test.cc index ea6c7a2e09..9a8d27cd03 100644 --- a/compiler/dex/dex_to_dex_decompiler_test.cc +++ b/compiler/dex/dex_to_dex_decompiler_test.cc @@ -102,7 +102,8 @@ class DexToDexDecompilerTest : public CommonCompilerTest { if (compiled_method != nullptr) { table = compiled_method->GetVmapTable(); } - optimizer::ArtDecompileDEX(*it.GetMethodCodeItem(), table); + optimizer::ArtDecompileDEX( + *it.GetMethodCodeItem(), table, /* decompile_return_instruction */ true); it.Next(); } while (it.HasNextVirtualMethod()) { @@ -113,7 +114,8 @@ class DexToDexDecompilerTest : public CommonCompilerTest { if (compiled_method != nullptr) { table = compiled_method->GetVmapTable(); } - optimizer::ArtDecompileDEX(*it.GetMethodCodeItem(), table); + optimizer::ArtDecompileDEX( + *it.GetMethodCodeItem(), table, /* decompile_return_instruction */ true); it.Next(); } DCHECK(!it.HasNext()); diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc index d1a5c4d9ab..ec1642e370 100644 --- a/compiler/driver/compiler_driver.cc +++ b/compiler/driver/compiler_driver.cc @@ -435,7 +435,8 @@ INTRINSICS_LIST(SETUP_INTRINSICS) // In-place unquicken the given `dex_files` based on `quickening_info`. static void Unquicken(const std::vector<const DexFile*>& dex_files, - const ArrayRef<const uint8_t>& quickening_info) { + const ArrayRef<const uint8_t>& quickening_info, + bool decompile_return_instruction) { const uint8_t* quickening_info_ptr = quickening_info.data(); const uint8_t* const quickening_info_end = quickening_info.data() + quickening_info.size(); for (const DexFile* dex_file : dex_files) { @@ -454,14 +455,14 @@ static void Unquicken(const std::vector<const DexFile*>& dex_files, it.Next(); } - // Unquicken each method. while (it.HasNextDirectMethod()) { const DexFile::CodeItem* code_item = it.GetMethodCodeItem(); if (code_item != nullptr) { uint32_t quickening_size = *reinterpret_cast<const uint32_t*>(quickening_info_ptr); quickening_info_ptr += sizeof(uint32_t); - optimizer::ArtDecompileDEX( - *code_item, ArrayRef<const uint8_t>(quickening_info_ptr, quickening_size)); + optimizer::ArtDecompileDEX(*code_item, + ArrayRef<const uint8_t>(quickening_info_ptr, quickening_size), + decompile_return_instruction); quickening_info_ptr += quickening_size; } it.Next(); @@ -472,8 +473,9 @@ static void Unquicken(const std::vector<const DexFile*>& dex_files, if (code_item != nullptr) { uint32_t quickening_size = *reinterpret_cast<const uint32_t*>(quickening_info_ptr); quickening_info_ptr += sizeof(uint32_t); - optimizer::ArtDecompileDEX( - *code_item, ArrayRef<const uint8_t>(quickening_info_ptr, quickening_size)); + optimizer::ArtDecompileDEX(*code_item, + ArrayRef<const uint8_t>(quickening_info_ptr, quickening_size), + decompile_return_instruction); quickening_info_ptr += quickening_size; } it.Next(); @@ -493,7 +495,10 @@ void CompilerDriver::CompileAll(jobject class_loader, // if the boot image has changed. How exactly we'll know is under // experimentation. TimingLogger::ScopedTiming t("Unquicken", timings); - Unquicken(dex_files, vdex_file->GetQuickeningInfo()); + // We do not decompile a RETURN_VOID_NO_BARRIER into a RETURN_VOID, as the quickening + // optimization does not depend on the boot image (the optimization relies on not + // having final fields in a class, which does not change for an app). + Unquicken(dex_files, vdex_file->GetQuickeningInfo(), /* decompile_return_instruction */ false); Runtime::Current()->GetCompilerCallbacks()->SetVerifierDeps( new verifier::VerifierDeps(dex_files, vdex_file->GetVerifierDepsData())); } |