Don't unquicken RETURN_VOID_NO_BARRIER with vdex.
The quickening of the RETURN_VOID instruction is based on
local information (no final fields) that doesn't get affected
by a boot image update.
Test: test-art-host, verifier_deps_test
bug:30937355
Change-Id: I12b22d7fcda6dc681a32ff752c3871f6e84f19a1
diff --git a/compiler/dex/dex_to_dex_decompiler.cc b/compiler/dex/dex_to_dex_decompiler.cc
index 051125e..bfd485d 100644
--- a/compiler/dex/dex_to_dex_decompiler.cc
+++ b/compiler/dex/dex_to_dex_decompiler.cc
@@ -27,10 +27,13 @@
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 @@
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 @@
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 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 5502ca2..b5d5b91 100644
--- a/compiler/dex/dex_to_dex_decompiler.h
+++ b/compiler/dex/dex_to_dex_decompiler.h
@@ -30,7 +30,8 @@
// 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 ea6c7a2..9a8d27c 100644
--- a/compiler/dex/dex_to_dex_decompiler_test.cc
+++ b/compiler/dex/dex_to_dex_decompiler_test.cc
@@ -102,7 +102,8 @@
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 @@
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 d1a5c4d..ec1642e 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -435,7 +435,8 @@
// 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 @@
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 @@
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 @@
// 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()));
}