Merge "Build fuzzing sources against release 8 when eventually running with ART."
diff --git a/compiler/debug/debug_info.h b/compiler/debug/debug_info.h
new file mode 100644
index 0000000..04c6991
--- /dev/null
+++ b/compiler/debug/debug_info.h
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_COMPILER_DEBUG_DEBUG_INFO_H_
+#define ART_COMPILER_DEBUG_DEBUG_INFO_H_
+
+#include <map>
+
+#include "base/array_ref.h"
+#include "method_debug_info.h"
+
+namespace art {
+class DexFile;
+
+namespace debug {
+
+// References inputs for all debug information which can be written into the ELF file.
+struct DebugInfo {
+ // Describes compiled code in the .text section.
+ ArrayRef<const MethodDebugInfo> compiled_methods;
+
+ // Describes dex-files in the .dex section.
+ std::map<uint32_t, const DexFile*> dex_files; // Offset in section -> dex file content.
+
+ bool Empty() const {
+ return compiled_methods.empty() && dex_files.empty();
+ }
+};
+
+} // namespace debug
+} // namespace art
+
+#endif // ART_COMPILER_DEBUG_DEBUG_INFO_H_
diff --git a/compiler/debug/elf_debug_info_writer.h b/compiler/debug/elf_debug_info_writer.h
index 713f8eb..893cad2 100644
--- a/compiler/debug/elf_debug_info_writer.h
+++ b/compiler/debug/elf_debug_info_writer.h
@@ -49,7 +49,7 @@
static std::vector<const char*> GetParamNames(const MethodDebugInfo* mi) {
std::vector<const char*> names;
- CodeItemDebugInfoAccessor accessor(*mi->dex_file, mi->code_item);
+ CodeItemDebugInfoAccessor accessor(*mi->dex_file, mi->code_item, mi->dex_method_index);
if (accessor.HasCodeItem()) {
DCHECK(mi->dex_file != nullptr);
const uint8_t* stream = mi->dex_file->GetDebugInfoStream(accessor.DebugInfoOffset());
@@ -163,7 +163,7 @@
for (auto mi : compilation_unit.methods) {
DCHECK(mi->dex_file != nullptr);
const DexFile* dex = mi->dex_file;
- CodeItemDebugInfoAccessor accessor(*dex, mi->code_item);
+ CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index);
const DexFile::MethodId& dex_method = dex->GetMethodId(mi->dex_method_index);
const DexFile::ProtoId& dex_proto = dex->GetMethodPrototype(dex_method);
const DexFile::TypeList* dex_params = dex->GetProtoParameters(dex_proto);
diff --git a/compiler/debug/elf_debug_line_writer.h b/compiler/debug/elf_debug_line_writer.h
index 4e37f4e..44504c1 100644
--- a/compiler/debug/elf_debug_line_writer.h
+++ b/compiler/debug/elf_debug_line_writer.h
@@ -159,7 +159,7 @@
PositionInfos dex2line_map;
DCHECK(mi->dex_file != nullptr);
const DexFile* dex = mi->dex_file;
- CodeItemDebugInfoAccessor accessor(*dex, mi->code_item);
+ CodeItemDebugInfoAccessor accessor(*dex, mi->code_item, mi->dex_method_index);
const uint32_t debug_info_offset = accessor.DebugInfoOffset();
if (!dex->DecodeDebugPositionInfo(debug_info_offset, PositionInfoCallback, &dex2line_map)) {
continue;
diff --git a/compiler/debug/elf_debug_writer.cc b/compiler/debug/elf_debug_writer.cc
index a626729..bb2a214 100644
--- a/compiler/debug/elf_debug_writer.cc
+++ b/compiler/debug/elf_debug_writer.cc
@@ -38,18 +38,18 @@
template <typename ElfTypes>
void WriteDebugInfo(linker::ElfBuilder<ElfTypes>* builder,
- const ArrayRef<const MethodDebugInfo>& method_infos,
+ const DebugInfo& debug_info,
dwarf::CFIFormat cfi_format,
bool write_oat_patches) {
// Write .strtab and .symtab.
- WriteDebugSymbols(builder, method_infos, true /* with_signature */);
+ WriteDebugSymbols(builder, false /* mini-debug-info */, debug_info);
// Write .debug_frame.
- WriteCFISection(builder, method_infos, cfi_format, write_oat_patches);
+ WriteCFISection(builder, debug_info.compiled_methods, cfi_format, write_oat_patches);
// Group the methods into compilation units based on class.
std::unordered_map<const DexFile::ClassDef*, ElfCompilationUnit> class_to_compilation_unit;
- for (const MethodDebugInfo& mi : method_infos) {
+ for (const MethodDebugInfo& mi : debug_info.compiled_methods) {
if (mi.dex_file != nullptr) {
auto& dex_class_def = mi.dex_file->GetClassDef(mi.class_def_index);
ElfCompilationUnit& cu = class_to_compilation_unit[&dex_class_def];
@@ -108,21 +108,27 @@
std::vector<uint8_t> MakeMiniDebugInfo(
InstructionSet isa,
const InstructionSetFeatures* features,
- uint64_t text_address,
- size_t text_size,
- const ArrayRef<const MethodDebugInfo>& method_infos) {
+ uint64_t text_section_address,
+ size_t text_section_size,
+ uint64_t dex_section_address,
+ size_t dex_section_size,
+ const DebugInfo& debug_info) {
if (Is64BitInstructionSet(isa)) {
return MakeMiniDebugInfoInternal<ElfTypes64>(isa,
features,
- text_address,
- text_size,
- method_infos);
+ text_section_address,
+ text_section_size,
+ dex_section_address,
+ dex_section_size,
+ debug_info);
} else {
return MakeMiniDebugInfoInternal<ElfTypes32>(isa,
features,
- text_address,
- text_size,
- method_infos);
+ text_section_address,
+ text_section_size,
+ dex_section_address,
+ dex_section_size,
+ debug_info);
}
}
@@ -133,7 +139,8 @@
bool mini_debug_info,
const MethodDebugInfo& mi) {
CHECK_EQ(mi.is_code_address_text_relative, false);
- ArrayRef<const MethodDebugInfo> method_infos(&mi, 1);
+ DebugInfo debug_info{};
+ debug_info.compiled_methods = ArrayRef<const debug::MethodDebugInfo>(&mi, 1);
std::vector<uint8_t> buffer;
buffer.reserve(KB);
linker::VectorOutputStream out("Debug ELF file", &buffer);
@@ -146,12 +153,14 @@
features,
mi.code_address,
mi.code_size,
- method_infos);
+ /* dex_section_address */ 0,
+ /* dex_section_size */ 0,
+ debug_info);
builder->WriteSection(".gnu_debugdata", &mdi);
} else {
builder->GetText()->AllocateVirtualMemory(mi.code_address, mi.code_size);
WriteDebugInfo(builder.get(),
- method_infos,
+ debug_info,
dwarf::DW_DEBUG_FRAME_FORMAT,
false /* write_oat_patches */);
}
@@ -209,12 +218,12 @@
// Explicit instantiations
template void WriteDebugInfo<ElfTypes32>(
linker::ElfBuilder<ElfTypes32>* builder,
- const ArrayRef<const MethodDebugInfo>& method_infos,
+ const DebugInfo& debug_info,
dwarf::CFIFormat cfi_format,
bool write_oat_patches);
template void WriteDebugInfo<ElfTypes64>(
linker::ElfBuilder<ElfTypes64>* builder,
- const ArrayRef<const MethodDebugInfo>& method_infos,
+ const DebugInfo& debug_info,
dwarf::CFIFormat cfi_format,
bool write_oat_patches);
diff --git a/compiler/debug/elf_debug_writer.h b/compiler/debug/elf_debug_writer.h
index a47bf07..8ad0c42 100644
--- a/compiler/debug/elf_debug_writer.h
+++ b/compiler/debug/elf_debug_writer.h
@@ -23,6 +23,7 @@
#include "base/macros.h"
#include "base/mutex.h"
#include "debug/dwarf/dwarf_constants.h"
+#include "debug/debug_info.h"
#include "linker/elf_builder.h"
namespace art {
@@ -36,7 +37,7 @@
template <typename ElfTypes>
void WriteDebugInfo(
linker::ElfBuilder<ElfTypes>* builder,
- const ArrayRef<const MethodDebugInfo>& method_infos,
+ const DebugInfo& debug_info,
dwarf::CFIFormat cfi_format,
bool write_oat_patches);
@@ -45,7 +46,9 @@
const InstructionSetFeatures* features,
uint64_t text_section_address,
size_t text_section_size,
- const ArrayRef<const MethodDebugInfo>& method_infos);
+ uint64_t dex_section_address,
+ size_t dex_section_size,
+ const DebugInfo& debug_info);
std::vector<uint8_t> MakeElfFileForJIT(
InstructionSet isa,
diff --git a/compiler/debug/elf_gnu_debugdata_writer.h b/compiler/debug/elf_gnu_debugdata_writer.h
index 78b8e27..a88c5cb 100644
--- a/compiler/debug/elf_gnu_debugdata_writer.h
+++ b/compiler/debug/elf_gnu_debugdata_writer.h
@@ -82,18 +82,23 @@
const InstructionSetFeatures* features,
typename ElfTypes::Addr text_section_address,
size_t text_section_size,
- const ArrayRef<const MethodDebugInfo>& method_infos) {
+ typename ElfTypes::Addr dex_section_address,
+ size_t dex_section_size,
+ const DebugInfo& debug_info) {
std::vector<uint8_t> buffer;
buffer.reserve(KB);
linker::VectorOutputStream out("Mini-debug-info ELF file", &buffer);
std::unique_ptr<linker::ElfBuilder<ElfTypes>> builder(
new linker::ElfBuilder<ElfTypes>(isa, features, &out));
builder->Start(false /* write_program_headers */);
- // Mirror .text as NOBITS section since the added symbols will reference it.
+ // Mirror ELF sections as NOBITS since the added symbols will reference them.
builder->GetText()->AllocateVirtualMemory(text_section_address, text_section_size);
- WriteDebugSymbols(builder.get(), method_infos, false /* with_signature */);
+ if (dex_section_size != 0) {
+ builder->GetDex()->AllocateVirtualMemory(dex_section_address, dex_section_size);
+ }
+ WriteDebugSymbols(builder.get(), true /* mini-debug-info */, debug_info);
WriteCFISection(builder.get(),
- method_infos,
+ debug_info.compiled_methods,
dwarf::DW_DEBUG_FRAME_FORMAT,
false /* write_oat_paches */);
builder->End();
diff --git a/compiler/debug/elf_symtab_writer.h b/compiler/debug/elf_symtab_writer.h
index 57e010f..95a0b4f 100644
--- a/compiler/debug/elf_symtab_writer.h
+++ b/compiler/debug/elf_symtab_writer.h
@@ -17,9 +17,13 @@
#ifndef ART_COMPILER_DEBUG_ELF_SYMTAB_WRITER_H_
#define ART_COMPILER_DEBUG_ELF_SYMTAB_WRITER_H_
+#include <map>
#include <unordered_set>
+#include "debug/debug_info.h"
#include "debug/method_debug_info.h"
+#include "dex/dex_file-inl.h"
+#include "dex/code_item_accessors.h"
#include "linker/elf_builder.h"
#include "utils.h"
@@ -35,22 +39,26 @@
// one symbol which marks the whole .text section as code.
constexpr bool kGenerateSingleArmMappingSymbol = true;
+// Magic name for .symtab symbols which enumerate dex files used
+// by this ELF file (currently mmapped inside the .dex section).
+constexpr const char* kDexFileSymbolName = "$dexfile";
+
template <typename ElfTypes>
static void WriteDebugSymbols(linker::ElfBuilder<ElfTypes>* builder,
- const ArrayRef<const MethodDebugInfo>& method_infos,
- bool with_signature) {
+ bool mini_debug_info,
+ const DebugInfo& debug_info) {
uint64_t mapping_symbol_address = std::numeric_limits<uint64_t>::max();
auto* strtab = builder->GetStrTab();
auto* symtab = builder->GetSymTab();
- if (method_infos.empty()) {
+ if (debug_info.Empty()) {
return;
}
// Find all addresses which contain deduped methods.
// The first instance of method is not marked deduped_, but the rest is.
std::unordered_set<uint64_t> deduped_addresses;
- for (const MethodDebugInfo& info : method_infos) {
+ for (const MethodDebugInfo& info : debug_info.compiled_methods) {
if (info.deduped) {
deduped_addresses.insert(info.code_address);
}
@@ -58,9 +66,8 @@
strtab->Start();
strtab->Write(""); // strtab should start with empty string.
- std::string last_name;
- size_t last_name_offset = 0;
- for (const MethodDebugInfo& info : method_infos) {
+ // Add symbols for compiled methods.
+ for (const MethodDebugInfo& info : debug_info.compiled_methods) {
if (info.deduped) {
continue; // Add symbol only for the first instance.
}
@@ -69,14 +76,11 @@
name_offset = strtab->Write(info.trampoline_name);
} else {
DCHECK(info.dex_file != nullptr);
- std::string name = info.dex_file->PrettyMethod(info.dex_method_index, with_signature);
+ std::string name = info.dex_file->PrettyMethod(info.dex_method_index, !mini_debug_info);
if (deduped_addresses.find(info.code_address) != deduped_addresses.end()) {
name += " [DEDUPED]";
}
- // If we write method names without signature, we might see the same name multiple times.
- name_offset = (name == last_name ? last_name_offset : strtab->Write(name));
- last_name = std::move(name);
- last_name_offset = name_offset;
+ name_offset = strtab->Write(name);
}
const auto* text = builder->GetText();
@@ -97,13 +101,46 @@
}
}
}
+ // Add symbols for interpreted methods (with address range of the method's bytecode).
+ if (!debug_info.dex_files.empty() && builder->GetDex()->Exists()) {
+ auto dex = builder->GetDex();
+ for (auto it : debug_info.dex_files) {
+ uint64_t dex_address = dex->GetAddress() + it.first /* offset within the section */;
+ const DexFile* dex_file = it.second;
+ symtab->Add(strtab->Write(kDexFileSymbolName), dex, dex_address, 0, STB_LOCAL, STT_NOTYPE);
+ if (mini_debug_info) {
+ continue; // Don't add interpreter method names to mini-debug-info for now.
+ }
+ for (uint32_t i = 0; i < dex_file->NumClassDefs(); ++i) {
+ const DexFile::ClassDef& class_def = dex_file->GetClassDef(i);
+ const uint8_t* class_data = dex_file->GetClassData(class_def);
+ if (class_data == nullptr) {
+ continue;
+ }
+ for (ClassDataItemIterator item(*dex_file, class_data); item.HasNext(); item.Next()) {
+ if (!item.IsAtMethod()) {
+ continue;
+ }
+ const DexFile::CodeItem* code_item = item.GetMethodCodeItem();
+ if (code_item == nullptr) {
+ continue;
+ }
+ CodeItemInstructionAccessor code(*dex_file, code_item);
+ DCHECK(code.HasCodeItem());
+ std::string name = dex_file->PrettyMethod(item.GetMemberIndex(), !mini_debug_info);
+ size_t name_offset = strtab->Write(name);
+ uint64_t offset = reinterpret_cast<const uint8_t*>(code.Insns()) - dex_file->Begin();
+ uint64_t address = dex_address + offset;
+ size_t size = code.InsnsSizeInCodeUnits() * sizeof(uint16_t);
+ symtab->Add(name_offset, dex, address, size, STB_GLOBAL, STT_FUNC);
+ }
+ }
+ }
+ }
strtab->End();
// Symbols are buffered and written after names (because they are smaller).
- // We could also do two passes in this function to avoid the buffering.
- symtab->Start();
- symtab->Write();
- symtab->End();
+ symtab->WriteCachedSection();
}
} // namespace debug
diff --git a/compiler/dex/dex_to_dex_compiler.cc b/compiler/dex/dex_to_dex_compiler.cc
index 52cb217..308e75d 100644
--- a/compiler/dex/dex_to_dex_compiler.cc
+++ b/compiler/dex/dex_to_dex_compiler.cc
@@ -373,15 +373,15 @@
CHECK_EQ(quicken_count, dex_compiler.GetQuickenedInfo().size());
}
std::vector<uint8_t> quicken_data;
+ QuickenInfoTable::Builder builder(&quicken_data, dex_compiler.GetQuickenedInfo().size());
+ // Length is encoded by the constructor.
for (QuickenedInfo info : dex_compiler.GetQuickenedInfo()) {
// Dex pc is not serialized, only used for checking the instructions. Since we access the
// array based on the index of the quickened instruction, the indexes must line up perfectly.
// The reader side uses the NeedsIndexForInstruction function too.
const Instruction& inst = unit.GetCodeItemAccessor().InstructionAt(info.dex_pc);
CHECK(QuickenInfoTable::NeedsIndexForInstruction(&inst)) << inst.Opcode();
- // Add the index.
- quicken_data.push_back(static_cast<uint8_t>(info.dex_member_index >> 0));
- quicken_data.push_back(static_cast<uint8_t>(info.dex_member_index >> 8));
+ builder.AddIndex(info.dex_member_index);
}
InstructionSet instruction_set = driver->GetInstructionSet();
if (instruction_set == InstructionSet::kThumb2) {
diff --git a/compiler/driver/compiler_driver.cc b/compiler/driver/compiler_driver.cc
index c0886d0..8698659 100644
--- a/compiler/driver/compiler_driver.cc
+++ b/compiler/driver/compiler_driver.cc
@@ -424,10 +424,6 @@
// optimizations that could break that.
max_level = optimizer::DexToDexCompilationLevel::kDontDexToDexCompile;
}
- if (!VdexFile::CanEncodeQuickenedData(dex_file)) {
- // Don't do any dex level optimizations if we cannot encode the quickening.
- return optimizer::DexToDexCompilationLevel::kDontDexToDexCompile;
- }
if (klass->IsVerified()) {
// Class is verified so we can enable DEX-to-DEX compilation for performance.
return max_level;
diff --git a/compiler/linker/elf_builder.h b/compiler/linker/elf_builder.h
index 5262ab6..1c87518 100644
--- a/compiler/linker/elf_builder.h
+++ b/compiler/linker/elf_builder.h
@@ -18,6 +18,7 @@
#define ART_COMPILER_LINKER_ELF_BUILDER_H_
#include <vector>
+#include <unordered_map>
#include "arch/instruction_set.h"
#include "arch/mips/instruction_set_features_mips.h"
@@ -196,6 +197,11 @@
return section_index_;
}
+ // Returns true if this section has been added.
+ bool Exists() const {
+ return section_index_ != 0;
+ }
+
private:
// Add this section to the list of generated ELF sections (if not there already).
// It also ensures the alignment is sufficient to generate valid program headers,
@@ -311,35 +317,36 @@
if (current_offset_ == 0) {
DCHECK(name.empty());
}
- Elf_Word offset = current_offset_;
- this->WriteFully(name.c_str(), name.length() + 1);
- current_offset_ += name.length() + 1;
- return offset;
+ auto res = written_names_.emplace(name, current_offset_);
+ if (res.second) { // Inserted.
+ this->WriteFully(name.c_str(), name.length() + 1);
+ current_offset_ += name.length() + 1;
+ }
+ return res.first->second; // Offset.
}
private:
Elf_Word current_offset_;
+ std::unordered_map<std::string, Elf_Word> written_names_; // Dedup strings.
};
// Writer of .dynsym and .symtab sections.
- class SymbolSection FINAL : public CachedSection {
+ class SymbolSection FINAL : public Section {
public:
SymbolSection(ElfBuilder<ElfTypes>* owner,
const std::string& name,
Elf_Word type,
Elf_Word flags,
Section* strtab)
- : CachedSection(owner,
- name,
- type,
- flags,
- strtab,
- /* info */ 0,
- sizeof(Elf_Off),
- sizeof(Elf_Sym)) {
- // The symbol table always has to start with NULL symbol.
- Elf_Sym null_symbol = Elf_Sym();
- CachedSection::Add(&null_symbol, sizeof(null_symbol));
+ : Section(owner,
+ name,
+ type,
+ flags,
+ strtab,
+ /* info */ 0,
+ sizeof(Elf_Off),
+ sizeof(Elf_Sym)) {
+ syms_.push_back(Elf_Sym()); // The symbol table always has to start with NULL symbol.
}
// Buffer symbol for this section. It will be written later.
@@ -362,6 +369,7 @@
Add(name, section_index, addr, size, binding, type);
}
+ // Buffer symbol for this section. It will be written later.
void Add(Elf_Word name,
Elf_Word section_index,
Elf_Addr addr,
@@ -375,8 +383,19 @@
sym.st_other = 0;
sym.st_shndx = section_index;
sym.st_info = (binding << 4) + (type & 0xf);
- CachedSection::Add(&sym, sizeof(sym));
+ syms_.push_back(sym);
}
+
+ Elf_Word GetCacheSize() { return syms_.size() * sizeof(Elf_Sym); }
+
+ void WriteCachedSection() {
+ this->Start();
+ this->WriteFully(syms_.data(), syms_.size() * sizeof(Elf_Sym));
+ this->End();
+ }
+
+ private:
+ std::vector<Elf_Sym> syms_; // Buffered/cached content of the whole section.
};
class AbiflagsSection FINAL : public Section {
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index af537dd..a1a5692 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -43,7 +43,7 @@
CompilerDriver* driver,
CodeGenerator* code_generator,
OptimizingCompilerStats* compiler_stats,
- const uint8_t* interpreter_metadata,
+ ArrayRef<const uint8_t> interpreter_metadata,
VariableSizedHandleScope* handles)
: graph_(graph),
dex_file_(&graph->GetDexFile()),
@@ -70,7 +70,6 @@
compiler_driver_(nullptr),
code_generator_(nullptr),
compilation_stats_(nullptr),
- interpreter_metadata_(nullptr),
handles_(handles),
return_type_(return_type) {}
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index c16a3a9..5a1914c 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -18,6 +18,7 @@
#define ART_COMPILER_OPTIMIZING_BUILDER_H_
#include "base/arena_object.h"
+#include "base/array_ref.h"
#include "dex/code_item_accessors.h"
#include "dex/dex_file-inl.h"
#include "dex/dex_file.h"
@@ -40,7 +41,7 @@
CompilerDriver* driver,
CodeGenerator* code_generator,
OptimizingCompilerStats* compiler_stats,
- const uint8_t* interpreter_metadata,
+ ArrayRef<const uint8_t> interpreter_metadata,
VariableSizedHandleScope* handles);
// Only for unit testing.
@@ -73,7 +74,7 @@
CodeGenerator* const code_generator_;
OptimizingCompilerStats* const compilation_stats_;
- const uint8_t* const interpreter_metadata_;
+ const ArrayRef<const uint8_t> interpreter_metadata_;
VariableSizedHandleScope* const handles_;
const DataType::Type return_type_;
diff --git a/compiler/optimizing/codegen_test.cc b/compiler/optimizing/codegen_test.cc
index 6eda289..ba4040a 100644
--- a/compiler/optimizing/codegen_test.cc
+++ b/compiler/optimizing/codegen_test.cc
@@ -74,8 +74,8 @@
class CodegenTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data, bool has_result = false, int32_t expected = 0);
- void TestCodeLong(const uint16_t* data, bool has_result, int64_t expected);
+ void TestCode(const std::vector<uint16_t>& data, bool has_result = false, int32_t expected = 0);
+ void TestCodeLong(const std::vector<uint16_t>& data, bool has_result, int64_t expected);
void TestComparison(IfCondition condition,
int64_t i,
int64_t j,
@@ -83,7 +83,7 @@
const CodegenTargetConfig target_config);
};
-void CodegenTest::TestCode(const uint16_t* data, bool has_result, int32_t expected) {
+void CodegenTest::TestCode(const std::vector<uint16_t>& data, bool has_result, int32_t expected) {
for (const CodegenTargetConfig& target_config : GetTargetConfigs()) {
ResetPoolAndAllocator();
HGraph* graph = CreateCFG(data);
@@ -93,7 +93,8 @@
}
}
-void CodegenTest::TestCodeLong(const uint16_t* data, bool has_result, int64_t expected) {
+void CodegenTest::TestCodeLong(const std::vector<uint16_t>& data,
+ bool has_result, int64_t expected) {
for (const CodegenTargetConfig& target_config : GetTargetConfigs()) {
ResetPoolAndAllocator();
HGraph* graph = CreateCFG(data, DataType::Type::kInt64);
@@ -104,12 +105,12 @@
}
TEST_F(CodegenTest, ReturnVoid) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(Instruction::RETURN_VOID);
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(Instruction::RETURN_VOID);
TestCode(data);
}
TEST_F(CodegenTest, CFG1) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100,
Instruction::RETURN_VOID);
@@ -117,7 +118,7 @@
}
TEST_F(CodegenTest, CFG2) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100,
Instruction::GOTO | 0x100,
Instruction::RETURN_VOID);
@@ -126,21 +127,21 @@
}
TEST_F(CodegenTest, CFG3) {
- const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x200,
Instruction::RETURN_VOID,
Instruction::GOTO | 0xFF00);
TestCode(data1);
- const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_16, 3,
Instruction::RETURN_VOID,
Instruction::GOTO_16, 0xFFFF);
TestCode(data2);
- const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_32, 4, 0,
Instruction::RETURN_VOID,
Instruction::GOTO_32, 0xFFFF, 0xFFFF);
@@ -149,7 +150,7 @@
}
TEST_F(CodegenTest, CFG4) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID,
Instruction::GOTO | 0x100,
Instruction::GOTO | 0xFE00);
@@ -158,7 +159,7 @@
}
TEST_F(CodegenTest, CFG5) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -168,7 +169,7 @@
}
TEST_F(CodegenTest, IntConstant) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN_VOID);
@@ -176,7 +177,7 @@
}
TEST_F(CodegenTest, Return1) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN | 0);
@@ -184,7 +185,7 @@
}
TEST_F(CodegenTest, Return2) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 0 | 1 << 8,
Instruction::RETURN | 1 << 8);
@@ -193,7 +194,7 @@
}
TEST_F(CodegenTest, Return3) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 1 << 8 | 1 << 12,
Instruction::RETURN | 1 << 8);
@@ -202,7 +203,7 @@
}
TEST_F(CodegenTest, ReturnIf1) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 1 << 8 | 1 << 12,
Instruction::IF_EQ, 3,
@@ -213,7 +214,7 @@
}
TEST_F(CodegenTest, ReturnIf2) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 1 << 8 | 1 << 12,
Instruction::IF_EQ | 0 << 4 | 1 << 8, 3,
@@ -224,17 +225,17 @@
}
// Exercise bit-wise (one's complement) not-int instruction.
-#define NOT_INT_TEST(TEST_NAME, INPUT, EXPECTED_OUTPUT) \
-TEST_F(CodegenTest, TEST_NAME) { \
- const int32_t input = INPUT; \
- const uint16_t input_lo = Low16Bits(input); \
- const uint16_t input_hi = High16Bits(input); \
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM( \
- Instruction::CONST | 0 << 8, input_lo, input_hi, \
- Instruction::NOT_INT | 1 << 8 | 0 << 12 , \
- Instruction::RETURN | 1 << 8); \
- \
- TestCode(data, true, EXPECTED_OUTPUT); \
+#define NOT_INT_TEST(TEST_NAME, INPUT, EXPECTED_OUTPUT) \
+TEST_F(CodegenTest, TEST_NAME) { \
+ const int32_t input = INPUT; \
+ const uint16_t input_lo = Low16Bits(input); \
+ const uint16_t input_hi = High16Bits(input); \
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM( \
+ Instruction::CONST | 0 << 8, input_lo, input_hi, \
+ Instruction::NOT_INT | 1 << 8 | 0 << 12 , \
+ Instruction::RETURN | 1 << 8); \
+ \
+ TestCode(data, true, EXPECTED_OUTPUT); \
}
NOT_INT_TEST(ReturnNotIntMinus2, -2, 1)
@@ -256,7 +257,7 @@
const uint16_t word1 = High16Bits(Low32Bits(input)); \
const uint16_t word2 = Low16Bits(High32Bits(input)); \
const uint16_t word3 = High16Bits(High32Bits(input)); /* MSW. */ \
- const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM( \
+ const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM( \
Instruction::CONST_WIDE | 0 << 8, word0, word1, word2, word3, \
Instruction::NOT_LONG | 2 << 8 | 0 << 12, \
Instruction::RETURN_WIDE | 2 << 8); \
@@ -306,7 +307,7 @@
const uint16_t word1 = High16Bits(Low32Bits(input));
const uint16_t word2 = Low16Bits(High32Bits(input));
const uint16_t word3 = High16Bits(High32Bits(input)); // MSW.
- const uint16_t data[] = FIVE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = FIVE_REGISTERS_CODE_ITEM(
Instruction::CONST_WIDE | 0 << 8, word0, word1, word2, word3,
Instruction::CONST_WIDE | 2 << 8, 1, 0, 0, 0,
Instruction::ADD_LONG | 0, 0 << 8 | 2, // v0 <- 2^32 + 1
@@ -318,7 +319,7 @@
}
TEST_F(CodegenTest, ReturnAdd1) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 3 << 12 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::ADD_INT, 1 << 8 | 0,
@@ -328,7 +329,7 @@
}
TEST_F(CodegenTest, ReturnAdd2) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 3 << 12 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::ADD_INT_2ADDR | 1 << 12,
@@ -338,7 +339,7 @@
}
TEST_F(CodegenTest, ReturnAdd3) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 4 << 12 | 0 << 8,
Instruction::ADD_INT_LIT8, 3 << 8 | 0,
Instruction::RETURN);
@@ -347,7 +348,7 @@
}
TEST_F(CodegenTest, ReturnAdd4) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 4 << 12 | 0 << 8,
Instruction::ADD_INT_LIT16, 3,
Instruction::RETURN);
@@ -356,7 +357,7 @@
}
TEST_F(CodegenTest, ReturnMulInt) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 3 << 12 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::MUL_INT, 1 << 8 | 0,
@@ -366,7 +367,7 @@
}
TEST_F(CodegenTest, ReturnMulInt2addr) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 3 << 12 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::MUL_INT_2ADDR | 1 << 12,
@@ -376,7 +377,7 @@
}
TEST_F(CodegenTest, ReturnMulLong) {
- const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(
Instruction::CONST_WIDE | 0 << 8, 3, 0, 0, 0,
Instruction::CONST_WIDE | 2 << 8, 4, 0, 0, 0,
Instruction::MUL_LONG, 2 << 8 | 0,
@@ -386,7 +387,7 @@
}
TEST_F(CodegenTest, ReturnMulLong2addr) {
- const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(
Instruction::CONST_WIDE | 0 << 8, 3, 0, 0, 0,
Instruction::CONST_WIDE | 2 << 8, 4, 0, 0, 0,
Instruction::MUL_LONG_2ADDR | 2 << 12,
@@ -396,7 +397,7 @@
}
TEST_F(CodegenTest, ReturnMulIntLit8) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 4 << 12 | 0 << 8,
Instruction::MUL_INT_LIT8, 3 << 8 | 0,
Instruction::RETURN);
@@ -405,7 +406,7 @@
}
TEST_F(CodegenTest, ReturnMulIntLit16) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 4 << 12 | 0 << 8,
Instruction::MUL_INT_LIT16, 3,
Instruction::RETURN);
@@ -578,7 +579,7 @@
}
TEST_F(CodegenTest, ReturnDivIntLit8) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 4 << 12 | 0 << 8,
Instruction::DIV_INT_LIT8, 3 << 8 | 0,
Instruction::RETURN);
@@ -587,7 +588,7 @@
}
TEST_F(CodegenTest, ReturnDivInt2Addr) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 4 << 12 | 0,
Instruction::CONST_4 | 2 << 12 | 1 << 8,
Instruction::DIV_INT_2ADDR | 1 << 12,
diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc
index e1980e0..d271047 100644
--- a/compiler/optimizing/constant_folding_test.cc
+++ b/compiler/optimizing/constant_folding_test.cc
@@ -36,7 +36,7 @@
public:
ConstantFoldingTest() : graph_(nullptr) { }
- void TestCode(const uint16_t* data,
+ void TestCode(const std::vector<uint16_t>& data,
const std::string& expected_before,
const std::string& expected_after_cf,
const std::string& expected_after_dce,
@@ -100,7 +100,7 @@
* return v1 2. return v1
*/
TEST_F(ConstantFoldingTest, IntConstantFoldingNegation) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 8 | 1 << 12,
Instruction::NEG_INT | 1 << 8 | 0 << 12,
Instruction::RETURN | 1 << 8);
@@ -161,7 +161,7 @@
const uint16_t word1 = High16Bits(Low32Bits(input));
const uint16_t word2 = Low16Bits(High32Bits(input));
const uint16_t word3 = High16Bits(High32Bits(input)); // MSW.
- const uint16_t data[] = FOUR_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = FOUR_REGISTERS_CODE_ITEM(
Instruction::CONST_WIDE | 0 << 8, word0, word1, word2, word3,
Instruction::NEG_LONG | 2 << 8 | 0 << 12,
Instruction::RETURN_WIDE | 2 << 8);
@@ -219,7 +219,7 @@
* return v2 4. return v2
*/
TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition1) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 8 | 1 << 12,
Instruction::CONST_4 | 1 << 8 | 2 << 12,
Instruction::ADD_INT | 2 << 8, 0 | 1 << 8,
@@ -284,7 +284,7 @@
* return v2 8. return v2
*/
TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition2) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 8 | 1 << 12,
Instruction::CONST_4 | 1 << 8 | 2 << 12,
Instruction::ADD_INT_2ADDR | 0 << 8 | 1 << 12,
@@ -369,7 +369,7 @@
* return v2 4. return v2
*/
TEST_F(ConstantFoldingTest, IntConstantFoldingOnSubtraction) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 8 | 3 << 12,
Instruction::CONST_4 | 1 << 8 | 2 << 12,
Instruction::SUB_INT | 2 << 8, 0 | 1 << 8,
@@ -432,7 +432,7 @@
* return (v4, v5) 6. return-wide v4
*/
TEST_F(ConstantFoldingTest, LongConstantFoldingOnAddition) {
- const uint16_t data[] = SIX_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
Instruction::CONST_WIDE_16 | 0 << 8, 1,
Instruction::CONST_WIDE_16 | 2 << 8, 2,
Instruction::ADD_LONG | 4 << 8, 0 | 2 << 8,
@@ -496,7 +496,7 @@
* return (v4, v5) 6. return-wide v4
*/
TEST_F(ConstantFoldingTest, LongConstantFoldingOnSubtraction) {
- const uint16_t data[] = SIX_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
Instruction::CONST_WIDE_16 | 0 << 8, 3,
Instruction::CONST_WIDE_16 | 2 << 8, 2,
Instruction::SUB_LONG | 4 << 8, 0 | 2 << 8,
@@ -569,7 +569,7 @@
* return v2 13. return v2
*/
TEST_F(ConstantFoldingTest, IntConstantFoldingAndJumps) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 8 | 1 << 12,
Instruction::CONST_4 | 1 << 8 | 2 << 12,
Instruction::ADD_INT | 2 << 8, 0 | 1 << 8,
@@ -672,7 +672,7 @@
* return-void 7. return
*/
TEST_F(ConstantFoldingTest, ConstantCondition) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 1 << 8 | 1 << 12,
Instruction::CONST_4 | 0 << 8 | 0 << 12,
Instruction::IF_GEZ | 1 << 8, 3,
diff --git a/compiler/optimizing/dead_code_elimination_test.cc b/compiler/optimizing/dead_code_elimination_test.cc
index 929572e..adb6ce1 100644
--- a/compiler/optimizing/dead_code_elimination_test.cc
+++ b/compiler/optimizing/dead_code_elimination_test.cc
@@ -29,12 +29,12 @@
class DeadCodeEliminationTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data,
+ void TestCode(const std::vector<uint16_t>& data,
const std::string& expected_before,
const std::string& expected_after);
};
-void DeadCodeEliminationTest::TestCode(const uint16_t* data,
+void DeadCodeEliminationTest::TestCode(const std::vector<uint16_t>& data,
const std::string& expected_before,
const std::string& expected_after) {
HGraph* graph = CreateCFG(data);
@@ -73,7 +73,7 @@
* return-void 7. return
*/
TEST_F(DeadCodeEliminationTest, AdditionAndConditionalJump) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 1 << 8 | 1 << 12,
Instruction::CONST_4 | 0 << 8 | 0 << 12,
Instruction::IF_GEZ | 1 << 8, 3,
@@ -135,7 +135,7 @@
* return 13. return-void
*/
TEST_F(DeadCodeEliminationTest, AdditionsAndInconditionalJumps) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 8 | 0 << 12,
Instruction::CONST_4 | 1 << 8 | 1 << 12,
Instruction::ADD_INT | 2 << 8, 0 | 1 << 8,
diff --git a/compiler/optimizing/dominator_test.cc b/compiler/optimizing/dominator_test.cc
index 572466e..1d72ba1 100644
--- a/compiler/optimizing/dominator_test.cc
+++ b/compiler/optimizing/dominator_test.cc
@@ -26,10 +26,12 @@
class OptimizerTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data, const uint32_t* blocks, size_t blocks_length);
+ void TestCode(const std::vector<uint16_t>& data, const uint32_t* blocks, size_t blocks_length);
};
-void OptimizerTest::TestCode(const uint16_t* data, const uint32_t* blocks, size_t blocks_length) {
+void OptimizerTest::TestCode(const std::vector<uint16_t>& data,
+ const uint32_t* blocks,
+ size_t blocks_length) {
HGraph* graph = CreateCFG(data);
ASSERT_EQ(graph->GetBlocks().size(), blocks_length);
for (size_t i = 0, e = blocks_length; i < e; ++i) {
@@ -49,7 +51,7 @@
}
TEST_F(OptimizerTest, ReturnVoid) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID); // Block number 1
const uint32_t dominators[] = {
@@ -62,7 +64,7 @@
}
TEST_F(OptimizerTest, CFG1) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100, // Block number 1
Instruction::RETURN_VOID); // Block number 2
@@ -77,7 +79,7 @@
}
TEST_F(OptimizerTest, CFG2) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100, // Block number 1
Instruction::GOTO | 0x100, // Block number 2
Instruction::RETURN_VOID); // Block number 3
@@ -94,7 +96,7 @@
}
TEST_F(OptimizerTest, CFG3) {
- const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x200, // Block number 1
Instruction::RETURN_VOID, // Block number 2
Instruction::GOTO | 0xFF00); // Block number 3
@@ -109,14 +111,14 @@
TestCode(data1, dominators, sizeof(dominators) / sizeof(int));
- const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_16, 3,
Instruction::RETURN_VOID,
Instruction::GOTO_16, 0xFFFF);
TestCode(data2, dominators, sizeof(dominators) / sizeof(int));
- const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_32, 4, 0,
Instruction::RETURN_VOID,
Instruction::GOTO_32, 0xFFFF, 0xFFFF);
@@ -125,7 +127,7 @@
}
TEST_F(OptimizerTest, CFG4) {
- const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
Instruction::NOP,
Instruction::GOTO | 0xFF00);
@@ -138,14 +140,14 @@
TestCode(data1, dominators, sizeof(dominators) / sizeof(int));
- const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_32, 0, 0);
TestCode(data2, dominators, sizeof(dominators) / sizeof(int));
}
TEST_F(OptimizerTest, CFG5) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID, // Block number 1
Instruction::GOTO | 0x100, // Dead block
Instruction::GOTO | 0xFE00); // Block number 2
@@ -162,7 +164,7 @@
}
TEST_F(OptimizerTest, CFG6) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -181,7 +183,7 @@
}
TEST_F(OptimizerTest, CFG7) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3, // Block number 1
Instruction::GOTO | 0x100, // Block number 2
@@ -201,7 +203,7 @@
}
TEST_F(OptimizerTest, CFG8) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3, // Block number 1
Instruction::GOTO | 0x200, // Block number 2
@@ -222,7 +224,7 @@
}
TEST_F(OptimizerTest, CFG9) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3, // Block number 1
Instruction::GOTO | 0x200, // Block number 2
@@ -243,7 +245,7 @@
}
TEST_F(OptimizerTest, CFG10) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 6, // Block number 1
Instruction::IF_EQ, 3, // Block number 2
diff --git a/compiler/optimizing/find_loops_test.cc b/compiler/optimizing/find_loops_test.cc
index b799fb4..75b8e96 100644
--- a/compiler/optimizing/find_loops_test.cc
+++ b/compiler/optimizing/find_loops_test.cc
@@ -31,7 +31,7 @@
TEST_F(FindLoopsTest, CFG1) {
// Constant is not used.
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN_VOID);
@@ -42,7 +42,7 @@
}
TEST_F(FindLoopsTest, CFG2) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN);
@@ -53,7 +53,7 @@
}
TEST_F(FindLoopsTest, CFG3) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 3 << 12 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::ADD_INT_2ADDR | 1 << 12,
@@ -67,7 +67,7 @@
}
TEST_F(FindLoopsTest, CFG4) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -82,7 +82,7 @@
}
TEST_F(FindLoopsTest, CFG5) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -126,7 +126,7 @@
// while (a == a) {
// }
// return;
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0xFE00,
@@ -150,7 +150,7 @@
// while (a == a) {
// }
// return a;
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::GOTO | 0x400,
Instruction::IF_EQ, 4,
@@ -173,7 +173,7 @@
TEST_F(FindLoopsTest, Loop3) {
// Make sure we create a preheader of a loop when a header originally has two
// incoming blocks and one back edge.
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -197,7 +197,7 @@
TEST_F(FindLoopsTest, Loop4) {
// Test loop with originally two back edges.
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 6,
Instruction::IF_EQ, 3,
@@ -221,7 +221,7 @@
TEST_F(FindLoopsTest, Loop5) {
// Test loop with two exit edges.
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 6,
Instruction::IF_EQ, 3,
@@ -244,7 +244,7 @@
}
TEST_F(FindLoopsTest, InnerLoop) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 6,
Instruction::IF_EQ, 3,
@@ -273,7 +273,7 @@
}
TEST_F(FindLoopsTest, TwoLoops) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0xFE00, // first loop
@@ -301,7 +301,7 @@
}
TEST_F(FindLoopsTest, NonNaturalLoop) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x0100,
@@ -317,7 +317,7 @@
}
TEST_F(FindLoopsTest, DoWhileLoop) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::GOTO | 0x0100,
Instruction::IF_EQ, 0xFFFF,
diff --git a/compiler/optimizing/graph_checker_test.cc b/compiler/optimizing/graph_checker_test.cc
index 9ca3e49..08bfa5d 100644
--- a/compiler/optimizing/graph_checker_test.cc
+++ b/compiler/optimizing/graph_checker_test.cc
@@ -22,7 +22,7 @@
class GraphCheckerTest : public OptimizingUnitTest {
protected:
HGraph* CreateSimpleCFG();
- void TestCode(const uint16_t* data);
+ void TestCode(const std::vector<uint16_t>& data);
};
/**
@@ -48,7 +48,7 @@
return graph;
}
-void GraphCheckerTest::TestCode(const uint16_t* data) {
+void GraphCheckerTest::TestCode(const std::vector<uint16_t>& data) {
HGraph* graph = CreateCFG(data);
ASSERT_NE(graph, nullptr);
@@ -58,14 +58,14 @@
}
TEST_F(GraphCheckerTest, ReturnVoid) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID);
TestCode(data);
}
TEST_F(GraphCheckerTest, CFG1) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100,
Instruction::RETURN_VOID);
@@ -73,7 +73,7 @@
}
TEST_F(GraphCheckerTest, CFG2) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -83,7 +83,7 @@
}
TEST_F(GraphCheckerTest, CFG3) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -128,7 +128,7 @@
TEST_F(GraphCheckerTest, SSAPhi) {
// This code creates one Phi function during the conversion to SSA form.
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::CONST_4 | 4 << 12 | 0,
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index b2ad8ec..81a7558 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -1660,7 +1660,7 @@
const DexFile::CodeItem* code_item = resolved_method->GetCodeItem();
const DexFile& callee_dex_file = *resolved_method->GetDexFile();
uint32_t method_index = resolved_method->GetDexMethodIndex();
- CodeItemDebugInfoAccessor code_item_accessor(callee_dex_file, code_item);
+ CodeItemDebugInfoAccessor code_item_accessor(resolved_method);
ClassLinker* class_linker = caller_compilation_unit_.GetClassLinker();
Handle<mirror::DexCache> dex_cache = NewHandleIfDifferent(resolved_method->GetDexCache(),
caller_compilation_unit_.GetDexCache(),
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 72a93c1..64a1ecc 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -49,7 +49,7 @@
const DexCompilationUnit* outer_compilation_unit,
CompilerDriver* compiler_driver,
CodeGenerator* code_generator,
- const uint8_t* interpreter_metadata,
+ ArrayRef<const uint8_t> interpreter_metadata,
OptimizingCompilerStats* compiler_stats,
VariableSizedHandleScope* handles,
ScopedArenaAllocator* local_allocator)
diff --git a/compiler/optimizing/instruction_builder.h b/compiler/optimizing/instruction_builder.h
index 708a097..4428c53 100644
--- a/compiler/optimizing/instruction_builder.h
+++ b/compiler/optimizing/instruction_builder.h
@@ -17,6 +17,7 @@
#ifndef ART_COMPILER_OPTIMIZING_INSTRUCTION_BUILDER_H_
#define ART_COMPILER_OPTIMIZING_INSTRUCTION_BUILDER_H_
+#include "base/array_ref.h"
#include "base/scoped_arena_allocator.h"
#include "base/scoped_arena_containers.h"
#include "data_type.h"
@@ -57,7 +58,7 @@
const DexCompilationUnit* outer_compilation_unit,
CompilerDriver* compiler_driver,
CodeGenerator* code_generator,
- const uint8_t* interpreter_metadata,
+ ArrayRef<const uint8_t> interpreter_metadata,
OptimizingCompilerStats* compiler_stats,
VariableSizedHandleScope* handles,
ScopedArenaAllocator* local_allocator);
diff --git a/compiler/optimizing/linearize_test.cc b/compiler/optimizing/linearize_test.cc
index 43b63a7..9fa5b74 100644
--- a/compiler/optimizing/linearize_test.cc
+++ b/compiler/optimizing/linearize_test.cc
@@ -35,11 +35,12 @@
class LinearizeTest : public OptimizingUnitTest {
protected:
template <size_t number_of_blocks>
- void TestCode(const uint16_t* data, const uint32_t (&expected_order)[number_of_blocks]);
+ void TestCode(const std::vector<uint16_t>& data,
+ const uint32_t (&expected_order)[number_of_blocks]);
};
template <size_t number_of_blocks>
-void LinearizeTest::TestCode(const uint16_t* data,
+void LinearizeTest::TestCode(const std::vector<uint16_t>& data,
const uint32_t (&expected_order)[number_of_blocks]) {
HGraph* graph = CreateCFG(data);
std::unique_ptr<const X86InstructionSetFeatures> features_x86(
@@ -68,7 +69,7 @@
// + / \ +
// Block4 Block8
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 5,
Instruction::IF_EQ, 0xFFFE,
@@ -93,7 +94,7 @@
// + / \ +
// Block5 Block8
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::RETURN_VOID,
@@ -119,7 +120,7 @@
// Block6 + Block9
// | +
// Block4 ++
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::RETURN_VOID,
@@ -149,7 +150,7 @@
// + / \ +
// Block5 Block11
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 7,
Instruction::IF_EQ, 0xFFFE,
@@ -179,7 +180,7 @@
// +/ \ +
// Block6 Block11
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::RETURN_VOID,
@@ -205,7 +206,7 @@
// Block5 <- Block9 Block6 +
// |
// Block7
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::GOTO | 0x0100,
Instruction::IF_EQ, 0x0004,
@@ -233,7 +234,7 @@
// |
// Block7
//
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::GOTO | 0x0100,
Instruction::IF_EQ, 0x0005,
diff --git a/compiler/optimizing/live_ranges_test.cc b/compiler/optimizing/live_ranges_test.cc
index e45d7c8..6666066 100644
--- a/compiler/optimizing/live_ranges_test.cc
+++ b/compiler/optimizing/live_ranges_test.cc
@@ -31,10 +31,10 @@
class LiveRangesTest : public OptimizingUnitTest {
public:
- HGraph* BuildGraph(const uint16_t* data);
+ HGraph* BuildGraph(const std::vector<uint16_t>& data);
};
-HGraph* LiveRangesTest::BuildGraph(const uint16_t* data) {
+HGraph* LiveRangesTest::BuildGraph(const std::vector<uint16_t>& data) {
HGraph* graph = CreateCFG(data);
// Suspend checks implementation may change in the future, and this test relies
// on how instructions are ordered.
@@ -57,7 +57,7 @@
* |
* 12: exit
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN);
@@ -102,7 +102,7 @@
* |
* 26: exit
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -151,7 +151,7 @@
* |
* 28: exit
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -225,7 +225,7 @@
* 30: exit
*/
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -304,7 +304,7 @@
* We want to make sure the phi at 10 has a lifetime hole after the add at 20.
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 6,
Instruction::ADD_INT, 0, 0,
@@ -378,7 +378,7 @@
*
* We want to make sure the constant0 has a lifetime hole after the 16: add.
*/
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::IF_EQ, 5,
diff --git a/compiler/optimizing/liveness_test.cc b/compiler/optimizing/liveness_test.cc
index 35bc4ff..6621a03 100644
--- a/compiler/optimizing/liveness_test.cc
+++ b/compiler/optimizing/liveness_test.cc
@@ -31,7 +31,7 @@
class LivenessTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data, const char* expected);
+ void TestCode(const std::vector<uint16_t>& data, const char* expected);
};
static void DumpBitVector(BitVector* vector,
@@ -46,7 +46,7 @@
buffer << ")\n";
}
-void LivenessTest::TestCode(const uint16_t* data, const char* expected) {
+void LivenessTest::TestCode(const std::vector<uint16_t>& data, const char* expected) {
HGraph* graph = CreateCFG(data);
// `Inline` conditions into ifs.
PrepareForRegisterAllocation(graph).Run();
@@ -86,7 +86,7 @@
" kill: (0)\n";
// Constant is not used.
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN_VOID);
@@ -108,7 +108,7 @@
" live out: (0)\n"
" kill: (0)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN);
@@ -134,7 +134,7 @@
" live out: (000)\n"
" kill: (000)\n";
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 3 << 12 | 0,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
Instruction::ADD_INT_2ADDR | 1 << 12,
@@ -181,7 +181,7 @@
" live out: (0000)\n"
" kill: (0000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -228,7 +228,7 @@
" live out: (000)\n"
" kill: (000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -273,7 +273,7 @@
" kill: (000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -318,7 +318,7 @@
" live out: (0000)\n"
" kill: (0000)\n";
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -370,7 +370,7 @@
" live out: (000)\n"
" kill: (000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::GOTO | 0x500,
Instruction::IF_EQ, 5,
@@ -425,7 +425,7 @@
" live out: (0001)\n"
" kill: (0001)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -475,7 +475,7 @@
" live out: (0000)\n"
" kill: (0000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 8,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -530,7 +530,7 @@
" live out: (00000)\n"
" kill: (00000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 8,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -580,7 +580,7 @@
" live out: (000)\n"
" kill: (000)\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 6,
Instruction::ADD_INT, 0, 0,
diff --git a/compiler/optimizing/optimizing_cfi_test.cc b/compiler/optimizing/optimizing_cfi_test.cc
index e2b2106..d20b681 100644
--- a/compiler/optimizing/optimizing_cfi_test.cc
+++ b/compiler/optimizing/optimizing_cfi_test.cc
@@ -41,7 +41,7 @@
// Run the tests only on host.
#ifndef ART_TARGET_ANDROID
-class OptimizingCFITest : public CFITest {
+class OptimizingCFITest : public CFITest, public OptimizingUnitTestHelper {
public:
// Enable this flag to generate the expected outputs.
static constexpr bool kGenerateExpected = false;
@@ -63,7 +63,7 @@
// Setup simple context.
std::string error;
isa_features_ = InstructionSetFeatures::FromVariant(isa, "default", &error);
- graph_ = CreateGraph(&pool_and_allocator_);
+ graph_ = CreateGraph();
// Generate simple frame with some spills.
code_gen_ = CodeGenerator::Create(graph_, isa, *isa_features_, opts_);
code_gen_->GetAssembler()->cfi().SetEnabled(true);
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index f4115f7..a3b1f0c 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -772,7 +772,7 @@
return nullptr;
}
- CodeItemDebugInfoAccessor code_item_accessor(dex_file, code_item);
+ CodeItemDebugInfoAccessor code_item_accessor(dex_file, code_item, method_idx);
HGraph* graph = new (allocator) HGraph(
allocator,
arena_stack,
@@ -783,7 +783,7 @@
compiler_driver->GetCompilerOptions().GetDebuggable(),
osr);
- const uint8_t* interpreter_metadata = nullptr;
+ ArrayRef<const uint8_t> interpreter_metadata;
// For AOT compilation, we may not get a method, for example if its class is erroneous.
// JIT should always have a method.
DCHECK(Runtime::Current()->IsAotCompiler() || method != nullptr);
@@ -940,7 +940,7 @@
compiler_driver,
codegen.get(),
compilation_stats_.get(),
- /* interpreter_metadata */ nullptr,
+ /* interpreter_metadata */ ArrayRef<const uint8_t>(),
handles);
builder.BuildIntrinsicGraph(method);
}
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 8c97d57..6dcbadb 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -17,12 +17,16 @@
#ifndef ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_
#define ART_COMPILER_OPTIMIZING_OPTIMIZING_UNIT_TEST_H_
+#include <memory>
+#include <vector>
+
#include "base/scoped_arena_allocator.h"
#include "builder.h"
#include "common_compiler_test.h"
#include "dex/code_item_accessors-inl.h"
#include "dex/dex_file.h"
#include "dex/dex_instruction.h"
+#include "dex/standard_dex_file.h"
#include "driver/dex_compilation_unit.h"
#include "handle_scope-inl.h"
#include "mirror/class_loader.h"
@@ -99,18 +103,11 @@
ScopedArenaAllocator scoped_allocator_;
};
-inline HGraph* CreateGraph(ArenaPoolAndAllocator* pool_and_allocator) {
- return new (pool_and_allocator->GetAllocator()) HGraph(
- pool_and_allocator->GetAllocator(),
- pool_and_allocator->GetArenaStack(),
- *reinterpret_cast<DexFile*>(pool_and_allocator->GetAllocator()->Alloc(sizeof(DexFile))),
- /*method_idx*/-1,
- kRuntimeISA);
-}
-
-class OptimizingUnitTest : public CommonCompilerTest {
- protected:
- OptimizingUnitTest() : pool_and_allocator_(new ArenaPoolAndAllocator()) { }
+// Have a separate helper so the OptimizingCFITest can inherit it without causing
+// multiple inheritance errors from having two gtest as a parent twice.
+class OptimizingUnitTestHelper {
+ public:
+ OptimizingUnitTestHelper() : pool_and_allocator_(new ArenaPoolAndAllocator()) { }
ArenaAllocator* GetAllocator() { return pool_and_allocator_->GetAllocator(); }
ArenaStack* GetArenaStack() { return pool_and_allocator_->GetArenaStack(); }
@@ -122,14 +119,42 @@
}
HGraph* CreateGraph() {
- return art::CreateGraph(pool_and_allocator_.get());
+ ArenaAllocator* const allocator = pool_and_allocator_->GetAllocator();
+
+ // Reserve a big array of 0s so the dex file constructor can offsets from the header.
+ static constexpr size_t kDexDataSize = 4 * KB;
+ const uint8_t* dex_data = reinterpret_cast<uint8_t*>(allocator->Alloc(kDexDataSize));
+
+ // Create the dex file based on the fake data. Call the constructor so that we can use virtual
+ // functions. Don't use the arena for the StandardDexFile otherwise the dex location leaks.
+ dex_files_.emplace_back(new StandardDexFile(
+ dex_data,
+ sizeof(StandardDexFile::Header),
+ "no_location",
+ /*location_checksum*/ 0,
+ /*oat_dex_file*/ nullptr,
+ /*container*/ nullptr));
+
+ return new (allocator) HGraph(
+ allocator,
+ pool_and_allocator_->GetArenaStack(),
+ *dex_files_.back(),
+ /*method_idx*/-1,
+ kRuntimeISA);
}
// Create a control-flow graph from Dex instructions.
- HGraph* CreateCFG(const uint16_t* data, DataType::Type return_type = DataType::Type::kInt32) {
- const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(data);
+ HGraph* CreateCFG(const std::vector<uint16_t>& data,
+ DataType::Type return_type = DataType::Type::kInt32) {
HGraph* graph = CreateGraph();
+ // The code item data might not aligned to 4 bytes, copy it to ensure that.
+ const size_t code_item_size = data.size() * sizeof(data.front());
+ void* aligned_data = GetAllocator()->Alloc(code_item_size);
+ memcpy(aligned_data, &data[0], code_item_size);
+ CHECK_ALIGNED(aligned_data, StandardDexFile::CodeItem::kAlignment);
+ const DexFile::CodeItem* code_item = reinterpret_cast<const DexFile::CodeItem*>(aligned_data);
+
{
ScopedObjectAccess soa(Thread::Current());
if (handles_ == nullptr) {
@@ -146,7 +171,7 @@
/* access_flags */ 0u,
/* verified_method */ nullptr,
handles_->NewHandle<mirror::DexCache>(nullptr));
- CodeItemDebugInfoAccessor accessor(graph->GetDexFile(), code_item);
+ CodeItemDebugInfoAccessor accessor(graph->GetDexFile(), code_item, /*dex_method_idx*/ 0u);
HGraphBuilder builder(graph, dex_compilation_unit, accessor, handles_.get(), return_type);
bool graph_built = (builder.BuildGraph() == kAnalysisSuccess);
return graph_built ? graph : nullptr;
@@ -154,10 +179,13 @@
}
private:
+ std::vector<std::unique_ptr<const StandardDexFile>> dex_files_;
std::unique_ptr<ArenaPoolAndAllocator> pool_and_allocator_;
std::unique_ptr<VariableSizedHandleScope> handles_;
};
+class OptimizingUnitTest : public CommonCompilerTest, public OptimizingUnitTestHelper {};
+
// Naive string diff data type.
typedef std::list<std::pair<std::string, std::string>> diff_t;
diff --git a/compiler/optimizing/pretty_printer_test.cc b/compiler/optimizing/pretty_printer_test.cc
index 4fc7fe9..6ef386b 100644
--- a/compiler/optimizing/pretty_printer_test.cc
+++ b/compiler/optimizing/pretty_printer_test.cc
@@ -29,10 +29,10 @@
class PrettyPrinterTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data, const char* expected);
+ void TestCode(const std::vector<uint16_t>& data, const char* expected);
};
-void PrettyPrinterTest::TestCode(const uint16_t* data, const char* expected) {
+void PrettyPrinterTest::TestCode(const std::vector<uint16_t>& data, const char* expected) {
HGraph* graph = CreateCFG(data);
StringPrettyPrinter printer(graph);
printer.VisitInsertionOrder();
@@ -40,7 +40,7 @@
}
TEST_F(PrettyPrinterTest, ReturnVoid) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID);
const char* expected =
@@ -67,7 +67,7 @@
"BasicBlock 3, pred: 2\n"
" 4: Exit\n";
- const uint16_t data[] =
+ const std::vector<uint16_t> data =
ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100,
Instruction::RETURN_VOID);
@@ -89,7 +89,7 @@
"BasicBlock 4, pred: 3\n"
" 5: Exit\n";
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x100,
Instruction::GOTO | 0x100,
Instruction::RETURN_VOID);
@@ -111,21 +111,21 @@
"BasicBlock 4, pred: 2\n"
" 5: Exit\n";
- const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO | 0x200,
Instruction::RETURN_VOID,
Instruction::GOTO | 0xFF00);
TestCode(data1, expected);
- const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_16, 3,
Instruction::RETURN_VOID,
Instruction::GOTO_16, 0xFFFF);
TestCode(data2, expected);
- const uint16_t data3[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data3 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_32, 4, 0,
Instruction::RETURN_VOID,
Instruction::GOTO_32, 0xFFFF, 0xFFFF);
@@ -144,13 +144,13 @@
"BasicBlock 3, pred: 0, succ: 1\n"
" 0: Goto 1\n";
- const uint16_t data1[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data1 = ZERO_REGISTER_CODE_ITEM(
Instruction::NOP,
Instruction::GOTO | 0xFF00);
TestCode(data1, expected);
- const uint16_t data2[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data2 = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_32, 0, 0);
TestCode(data2, expected);
@@ -166,7 +166,7 @@
"BasicBlock 3, pred: 1\n"
" 3: Exit\n";
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::RETURN_VOID,
Instruction::GOTO | 0x100,
Instruction::GOTO | 0xFE00);
@@ -192,7 +192,7 @@
"BasicBlock 5, pred: 1, succ: 3\n"
" 0: Goto 3\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -220,7 +220,7 @@
"BasicBlock 6, pred: 1, succ: 2\n"
" 1: Goto 2\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -240,7 +240,7 @@
"BasicBlock 2, pred: 1\n"
" 4: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN_VOID);
diff --git a/compiler/optimizing/register_allocator_test.cc b/compiler/optimizing/register_allocator_test.cc
index 3748d59..a70b066 100644
--- a/compiler/optimizing/register_allocator_test.cc
+++ b/compiler/optimizing/register_allocator_test.cc
@@ -46,7 +46,7 @@
void ExpectedInRegisterHint(Strategy strategy);
// Helper functions that make use of the OptimizingUnitTest's members.
- bool Check(const uint16_t* data, Strategy strategy);
+ bool Check(const std::vector<uint16_t>& data, Strategy strategy);
void CFG1(Strategy strategy);
void Loop1(Strategy strategy);
void Loop2(Strategy strategy);
@@ -79,7 +79,7 @@
test_name(Strategy::kRegisterAllocatorGraphColor);\
}
-bool RegisterAllocatorTest::Check(const uint16_t* data, Strategy strategy) {
+bool RegisterAllocatorTest::Check(const std::vector<uint16_t>& data, Strategy strategy) {
HGraph* graph = CreateCFG(data);
std::unique_ptr<const X86InstructionSetFeatures> features_x86(
X86InstructionSetFeatures::FromCppDefines());
@@ -185,7 +185,7 @@
* |
* exit
*/
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN);
@@ -222,7 +222,7 @@
* exit
*/
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -268,7 +268,7 @@
* exit
*/
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 8 << 12 | 1 << 8,
Instruction::IF_EQ | 1 << 8, 7,
@@ -314,7 +314,7 @@
* exit
*/
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::ADD_INT_LIT8 | 1 << 8, 1 << 8,
Instruction::CONST_4 | 5 << 12 | 2 << 8,
@@ -351,7 +351,7 @@
TEST_ALL_STRATEGIES(Loop3);
TEST_F(RegisterAllocatorTest, FirstRegisterUse) {
- const uint16_t data[] = THREE_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = THREE_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::XOR_INT_LIT8 | 1 << 8, 1 << 8,
Instruction::XOR_INT_LIT8 | 0 << 8, 1 << 8,
@@ -402,7 +402,7 @@
* } while (true);
*/
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::CONST_4 | 1 << 8 | 0,
Instruction::IF_NE | 1 << 8 | 1 << 12, 3,
@@ -432,7 +432,7 @@
* This test only applies to the linear scan allocator.
*/
TEST_F(RegisterAllocatorTest, FreeUntil) {
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN);
diff --git a/compiler/optimizing/scheduler_test.cc b/compiler/optimizing/scheduler_test.cc
index 104ebc7..fb15fc8 100644
--- a/compiler/optimizing/scheduler_test.cc
+++ b/compiler/optimizing/scheduler_test.cc
@@ -182,7 +182,9 @@
scheduler->Schedule(graph_);
}
- void CompileWithRandomSchedulerAndRun(const uint16_t* data, bool has_result, int expected) {
+ void CompileWithRandomSchedulerAndRun(const std::vector<uint16_t>& data,
+ bool has_result,
+ int expected) {
for (CodegenTargetConfig target_config : GetTargetConfigs()) {
HGraph* graph = CreateCFG(data);
@@ -393,7 +395,7 @@
// }
// return result;
//
- const uint16_t data[] = SIX_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = SIX_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 << 12 | 2 << 8, // const/4 v2, #int 0
Instruction::CONST_HIGH16 | 0 << 8, 0x4120, // const/high16 v0, #float 10.0 // #41200000
Instruction::CONST_4 | 1 << 12 | 1 << 8, // const/4 v1, #int 1
diff --git a/compiler/optimizing/ssa_test.cc b/compiler/optimizing/ssa_test.cc
index 77e70d7..85ed06e 100644
--- a/compiler/optimizing/ssa_test.cc
+++ b/compiler/optimizing/ssa_test.cc
@@ -31,7 +31,7 @@
class SsaTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data, const char* expected);
+ void TestCode(const std::vector<uint16_t>& data, const char* expected);
};
class SsaPrettyPrinter : public HPrettyPrinter {
@@ -80,7 +80,7 @@
}
}
-void SsaTest::TestCode(const uint16_t* data, const char* expected) {
+void SsaTest::TestCode(const std::vector<uint16_t>& data, const char* expected) {
HGraph* graph = CreateCFG(data);
// Suspend checks implementation may change in the future, and this test relies
// on how instructions are ordered.
@@ -119,7 +119,7 @@
"BasicBlock 5, pred: 1, succ: 3\n"
" 7: Goto\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::GOTO | 0x100,
@@ -150,7 +150,7 @@
"BasicBlock 5, pred: 1, succ: 3\n"
" 9: Goto\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -181,7 +181,7 @@
"BasicBlock 5, pred: 4\n"
" 10: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -214,7 +214,7 @@
"BasicBlock 6, pred: 5\n"
" 10: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -245,7 +245,7 @@
"BasicBlock 5, pred: 4\n"
" 9: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -276,7 +276,7 @@
"BasicBlock 5, pred: 4\n"
" 10: Exit\n";
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -310,7 +310,7 @@
"BasicBlock 6, pred: 5\n"
" 10: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::GOTO | 0x500,
Instruction::IF_EQ, 5,
@@ -351,7 +351,7 @@
" 13: Phi(2, 1) [11, 8, 8]\n"
" 14: Goto\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 4,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -390,7 +390,7 @@
"BasicBlock 7, pred: 6\n"
" 13: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 8,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -432,7 +432,7 @@
"BasicBlock 8, pred: 2, succ: 6\n"
" 15: Goto\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 8,
Instruction::CONST_4 | 4 << 12 | 0,
@@ -456,7 +456,7 @@
"BasicBlock 2, pred: 1\n"
" 3: Exit\n";
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::RETURN_VOID);
@@ -484,7 +484,7 @@
"BasicBlock 5, pred: 1, succ: 3\n"
" 8: Goto\n";
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 3,
Instruction::CONST_4 | 4 << 12 | 1 << 8,
@@ -520,7 +520,7 @@
"BasicBlock 7, pred: 3, succ: 5\n"
" 12: Goto\n";
- const uint16_t data[] = TWO_REGISTERS_CODE_ITEM(
+ const std::vector<uint16_t> data = TWO_REGISTERS_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 5,
Instruction::ADD_INT_LIT8 | 1 << 8, 0 << 8,
diff --git a/compiler/optimizing/suspend_check_test.cc b/compiler/optimizing/suspend_check_test.cc
index 7e83f8c..33823e2 100644
--- a/compiler/optimizing/suspend_check_test.cc
+++ b/compiler/optimizing/suspend_check_test.cc
@@ -30,10 +30,10 @@
class SuspendCheckTest : public OptimizingUnitTest {
protected:
- void TestCode(const uint16_t* data);
+ void TestCode(const std::vector<uint16_t>& data);
};
-void SuspendCheckTest::TestCode(const uint16_t* data) {
+void SuspendCheckTest::TestCode(const std::vector<uint16_t>& data) {
HGraph* graph = CreateCFG(data);
HBasicBlock* first_block = graph->GetEntryBlock()->GetSingleSuccessor();
HBasicBlock* loop_header = first_block->GetSingleSuccessor();
@@ -43,7 +43,7 @@
}
TEST_F(SuspendCheckTest, CFG1) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::NOP,
Instruction::GOTO | 0xFF00);
@@ -51,14 +51,14 @@
}
TEST_F(SuspendCheckTest, CFG2) {
- const uint16_t data[] = ZERO_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ZERO_REGISTER_CODE_ITEM(
Instruction::GOTO_32, 0, 0);
TestCode(data);
}
TEST_F(SuspendCheckTest, CFG3) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQ, 0xFFFF,
Instruction::RETURN_VOID);
@@ -67,7 +67,7 @@
}
TEST_F(SuspendCheckTest, CFG4) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_NE, 0xFFFF,
Instruction::RETURN_VOID);
@@ -76,7 +76,7 @@
}
TEST_F(SuspendCheckTest, CFG5) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_EQZ, 0xFFFF,
Instruction::RETURN_VOID);
@@ -85,7 +85,7 @@
}
TEST_F(SuspendCheckTest, CFG6) {
- const uint16_t data[] = ONE_REGISTER_CODE_ITEM(
+ const std::vector<uint16_t> data = ONE_REGISTER_CODE_ITEM(
Instruction::CONST_4 | 0 | 0,
Instruction::IF_NEZ, 0xFFFF,
Instruction::RETURN_VOID);
diff --git a/dex2oat/dex2oat.cc b/dex2oat/dex2oat.cc
index 23af2ab..7796b3a 100644
--- a/dex2oat/dex2oat.cc
+++ b/dex2oat/dex2oat.cc
@@ -1807,9 +1807,7 @@
// 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).
- VdexFile::Unquicken(dex_files_,
- input_vdex_file_->GetQuickeningInfo(),
- /* decompile_return_instruction */ false);
+ input_vdex_file_->Unquicken(dex_files_, /* decompile_return_instruction */ false);
} else {
// Create the main VerifierDeps, here instead of in the compiler since we want to aggregate
// the results for all the dex files, not just the results for the current dex file.
@@ -2043,7 +2041,8 @@
// We need to mirror the layout of the ELF file in the compressed debug-info.
// Therefore PrepareDebugInfo() relies on the SetLoadedSectionSizes() call further above.
- elf_writer->PrepareDebugInfo(oat_writer->GetMethodDebugInfo());
+ debug::DebugInfo debug_info = oat_writer->GetDebugInfo(); // Keep the variable alive.
+ elf_writer->PrepareDebugInfo(debug_info); // Processes the data on background thread.
linker::OutputStream*& rodata = rodata_[i];
DCHECK(rodata != nullptr);
@@ -2077,7 +2076,7 @@
}
elf_writer->WriteDynamicSection();
- elf_writer->WriteDebugInfo(oat_writer->GetMethodDebugInfo());
+ elf_writer->WriteDebugInfo(oat_writer->GetDebugInfo());
if (!elf_writer->End()) {
LOG(ERROR) << "Failed to write ELF file " << oat_file->GetPath();
diff --git a/dex2oat/linker/elf_writer.h b/dex2oat/linker/elf_writer.h
index a49112b..7c47740 100644
--- a/dex2oat/linker/elf_writer.h
+++ b/dex2oat/linker/elf_writer.h
@@ -25,6 +25,7 @@
#include "base/array_ref.h"
#include "base/macros.h"
#include "base/mutex.h"
+#include "debug/debug_info.h"
#include "os.h"
namespace art {
@@ -66,13 +67,13 @@
size_t bss_methods_offset,
size_t bss_roots_offset,
size_t dex_section_size) = 0;
- virtual void PrepareDebugInfo(const ArrayRef<const debug::MethodDebugInfo>& method_infos) = 0;
+ virtual void PrepareDebugInfo(const debug::DebugInfo& debug_info) = 0;
virtual OutputStream* StartRoData() = 0;
virtual void EndRoData(OutputStream* rodata) = 0;
virtual OutputStream* StartText() = 0;
virtual void EndText(OutputStream* text) = 0;
virtual void WriteDynamicSection() = 0;
- virtual void WriteDebugInfo(const ArrayRef<const debug::MethodDebugInfo>& method_infos) = 0;
+ virtual void WriteDebugInfo(const debug::DebugInfo& debug_info) = 0;
virtual bool End() = 0;
// Get the ELF writer's stream. This stream can be used for writing data directly
diff --git a/dex2oat/linker/elf_writer_quick.cc b/dex2oat/linker/elf_writer_quick.cc
index af11d58..707e877 100644
--- a/dex2oat/linker/elf_writer_quick.cc
+++ b/dex2oat/linker/elf_writer_quick.cc
@@ -54,22 +54,28 @@
public:
DebugInfoTask(InstructionSet isa,
const InstructionSetFeatures* features,
- size_t rodata_section_size,
+ uint64_t text_section_address,
size_t text_section_size,
- const ArrayRef<const debug::MethodDebugInfo>& method_infos)
+ uint64_t dex_section_address,
+ size_t dex_section_size,
+ const debug::DebugInfo& debug_info)
: isa_(isa),
instruction_set_features_(features),
- rodata_section_size_(rodata_section_size),
+ text_section_address_(text_section_address),
text_section_size_(text_section_size),
- method_infos_(method_infos) {
+ dex_section_address_(dex_section_address),
+ dex_section_size_(dex_section_size),
+ debug_info_(debug_info) {
}
void Run(Thread*) {
result_ = debug::MakeMiniDebugInfo(isa_,
instruction_set_features_,
- kPageSize + rodata_section_size_, // .text address.
+ text_section_address_,
text_section_size_,
- method_infos_);
+ dex_section_address_,
+ dex_section_size_,
+ debug_info_);
}
std::vector<uint8_t>* GetResult() {
@@ -79,9 +85,11 @@
private:
InstructionSet isa_;
const InstructionSetFeatures* instruction_set_features_;
- size_t rodata_section_size_;
+ uint64_t text_section_address_;
size_t text_section_size_;
- const ArrayRef<const debug::MethodDebugInfo> method_infos_;
+ uint64_t dex_section_address_;
+ size_t dex_section_size_;
+ const debug::DebugInfo& debug_info_;
std::vector<uint8_t> result_;
};
@@ -101,13 +109,13 @@
size_t bss_methods_offset,
size_t bss_roots_offset,
size_t dex_section_size) OVERRIDE;
- void PrepareDebugInfo(const ArrayRef<const debug::MethodDebugInfo>& method_infos) OVERRIDE;
+ void PrepareDebugInfo(const debug::DebugInfo& debug_info) OVERRIDE;
OutputStream* StartRoData() OVERRIDE;
void EndRoData(OutputStream* rodata) OVERRIDE;
OutputStream* StartText() OVERRIDE;
void EndText(OutputStream* text) OVERRIDE;
void WriteDynamicSection() OVERRIDE;
- void WriteDebugInfo(const ArrayRef<const debug::MethodDebugInfo>& method_infos) OVERRIDE;
+ void WriteDebugInfo(const debug::DebugInfo& debug_info) OVERRIDE;
bool End() OVERRIDE;
virtual OutputStream* GetStream() OVERRIDE;
@@ -124,6 +132,7 @@
size_t rodata_size_;
size_t text_size_;
size_t bss_size_;
+ size_t dex_section_size_;
std::unique_ptr<BufferedOutputStream> output_stream_;
std::unique_ptr<ElfBuilder<ElfTypes>> builder_;
std::unique_ptr<DebugInfoTask> debug_info_task_;
@@ -163,6 +172,7 @@
rodata_size_(0u),
text_size_(0u),
bss_size_(0u),
+ dex_section_size_(0u),
output_stream_(
std::make_unique<BufferedOutputStream>(std::make_unique<FileOutputStream>(elf_file))),
builder_(new ElfBuilder<ElfTypes>(instruction_set, features, output_stream_.get())) {}
@@ -192,6 +202,8 @@
text_size_ = text_size;
DCHECK_EQ(bss_size_, 0u);
bss_size_ = bss_size;
+ DCHECK_EQ(dex_section_size_, 0u);
+ dex_section_size_ = dex_section_size;
builder_->PrepareDynamicSection(elf_file_->GetPath(),
rodata_size_,
text_size_,
@@ -237,17 +249,18 @@
}
template <typename ElfTypes>
-void ElfWriterQuick<ElfTypes>::PrepareDebugInfo(
- const ArrayRef<const debug::MethodDebugInfo>& method_infos) {
- if (!method_infos.empty() && compiler_options_->GetGenerateMiniDebugInfo()) {
+void ElfWriterQuick<ElfTypes>::PrepareDebugInfo(const debug::DebugInfo& debug_info) {
+ if (!debug_info.Empty() && compiler_options_->GetGenerateMiniDebugInfo()) {
// Prepare the mini-debug-info in background while we do other I/O.
Thread* self = Thread::Current();
debug_info_task_ = std::unique_ptr<DebugInfoTask>(
new DebugInfoTask(builder_->GetIsa(),
instruction_set_features_,
- rodata_size_,
+ builder_->GetText()->GetAddress(),
text_size_,
- method_infos));
+ builder_->GetDex()->Exists() ? builder_->GetDex()->GetAddress() : 0,
+ dex_section_size_,
+ debug_info));
debug_info_thread_pool_ = std::unique_ptr<ThreadPool>(
new ThreadPool("Mini-debug-info writer", 1));
debug_info_thread_pool_->AddTask(self, debug_info_task_.get());
@@ -256,12 +269,11 @@
}
template <typename ElfTypes>
-void ElfWriterQuick<ElfTypes>::WriteDebugInfo(
- const ArrayRef<const debug::MethodDebugInfo>& method_infos) {
- if (!method_infos.empty()) {
+void ElfWriterQuick<ElfTypes>::WriteDebugInfo(const debug::DebugInfo& debug_info) {
+ if (!debug_info.Empty()) {
if (compiler_options_->GetGenerateDebugInfo()) {
// Generate all the debug information we can.
- debug::WriteDebugInfo(builder_.get(), method_infos, kCFIFormat, true /* write_oat_patches */);
+ debug::WriteDebugInfo(builder_.get(), debug_info, kCFIFormat, true /* write_oat_patches */);
}
if (compiler_options_->GetGenerateMiniDebugInfo()) {
// Wait for the mini-debug-info generation to finish and write it to disk.
diff --git a/dex2oat/linker/image_test.h b/dex2oat/linker/image_test.h
index 0671118..637578e 100644
--- a/dex2oat/linker/image_test.h
+++ b/dex2oat/linker/image_test.h
@@ -339,7 +339,7 @@
writer->UpdateOatFileHeader(i, oat_writer->GetOatHeader());
elf_writer->WriteDynamicSection();
- elf_writer->WriteDebugInfo(oat_writer->GetMethodDebugInfo());
+ elf_writer->WriteDebugInfo(oat_writer->GetDebugInfo());
bool success = elf_writer->End();
ASSERT_TRUE(success);
diff --git a/dex2oat/linker/oat_writer.cc b/dex2oat/linker/oat_writer.cc
index cecd376..31b6ac3 100644
--- a/dex2oat/linker/oat_writer.cc
+++ b/dex2oat/linker/oat_writer.cc
@@ -58,6 +58,7 @@
#include "mirror/object-inl.h"
#include "oat_quick_method_header.h"
#include "os.h"
+#include "quicken_info.h"
#include "safe_map.h"
#include "scoped_thread_state_change-inl.h"
#include "type_lookup_table.h"
@@ -2618,42 +2619,54 @@
return true;
}
-class OatWriter::WriteQuickeningInfoMethodVisitor : public DexMethodVisitor {
+class OatWriter::WriteQuickeningInfoMethodVisitor {
public:
- WriteQuickeningInfoMethodVisitor(OatWriter* writer,
- OutputStream* out,
- uint32_t offset,
- SafeMap<const uint8_t*, uint32_t>* offset_map)
- : DexMethodVisitor(writer, offset),
- out_(out),
- written_bytes_(0u),
- offset_map_(offset_map) {}
+ WriteQuickeningInfoMethodVisitor(OatWriter* writer, OutputStream* out)
+ : writer_(writer),
+ out_(out) {}
- bool VisitMethod(size_t class_def_method_index ATTRIBUTE_UNUSED, const ClassDataItemIterator& it)
- OVERRIDE {
- uint32_t method_idx = it.GetMemberIndex();
- CompiledMethod* compiled_method =
- writer_->compiler_driver_->GetCompiledMethod(MethodReference(dex_file_, method_idx));
+ bool VisitDexMethods(const std::vector<const DexFile*>& dex_files) {
+ std::vector<uint8_t> empty_quicken_info;
+ {
+ // Since we need to be able to access by dex method index, put a one byte empty quicken info
+ // for any method that isn't quickened.
+ QuickenInfoTable::Builder empty_info(&empty_quicken_info, /*num_elements*/ 0u);
+ CHECK(!empty_quicken_info.empty());
+ }
+ for (const DexFile* dex_file : dex_files) {
+ std::vector<uint32_t>* const offsets =
+ &quicken_info_offset_indices_.Put(dex_file, std::vector<uint32_t>())->second;
- if (HasQuickeningInfo(compiled_method)) {
- ArrayRef<const uint8_t> map = compiled_method->GetVmapTable();
- // Deduplication is already done on a pointer basis by the compiler driver,
- // so we can simply compare the pointers to find out if things are duplicated.
- if (offset_map_->find(map.data()) == offset_map_->end()) {
- uint32_t length = map.size() * sizeof(map.front());
- offset_map_->Put(map.data(), written_bytes_);
- if (!out_->WriteFully(&length, sizeof(length)) ||
- !out_->WriteFully(map.data(), length)) {
- PLOG(ERROR) << "Failed to write quickening info for "
- << dex_file_->PrettyMethod(it.GetMemberIndex()) << " to "
- << out_->GetLocation();
+ // Every method needs an index in the table.
+ for (uint32_t method_idx = 0; method_idx < dex_file->NumMethodIds(); ++method_idx) {
+ ArrayRef<const uint8_t> map(empty_quicken_info);
+
+ // Use the existing quicken info if it exists.
+ MethodReference method_ref(dex_file, method_idx);
+ CompiledMethod* compiled_method = writer_->compiler_driver_->GetCompiledMethod(method_ref);
+ if (compiled_method != nullptr && HasQuickeningInfo(compiled_method)) {
+ map = compiled_method->GetVmapTable();
+ }
+
+ // The current approach prevents deduplication of quicken infos since each method index
+ // has one unique quicken info. Deduplication does not provide much savings for dex indices
+ // since they are rarely duplicated.
+ const uint32_t length = map.size() * sizeof(map.front());
+
+ // Record each index if required. written_bytes_ is the offset from the start of the
+ // quicken info data.
+ if (QuickenInfoOffsetTableAccessor::IsCoveredIndex(method_idx)) {
+ offsets->push_back(written_bytes_);
+ }
+
+ if (!out_->WriteFully(map.data(), length)) {
+ PLOG(ERROR) << "Failed to write quickening info for " << method_ref.PrettyMethod()
+ << " to " << out_->GetLocation();
return false;
}
- written_bytes_ += sizeof(length) + length;
- offset_ += sizeof(length) + length;
+ written_bytes_ += length;
}
}
-
return true;
}
@@ -2661,71 +2674,59 @@
return written_bytes_;
}
+ SafeMap<const DexFile*, std::vector<uint32_t>>& GetQuickenInfoOffsetIndicies() {
+ return quicken_info_offset_indices_;
+ }
+
+
private:
+ OatWriter* const writer_;
OutputStream* const out_;
- size_t written_bytes_;
- // Maps quickening map to its offset in the file.
- SafeMap<const uint8_t*, uint32_t>* offset_map_;
+ size_t written_bytes_ = 0u;
+ // Map of offsets for quicken info related to method indices.
+ SafeMap<const DexFile*, std::vector<uint32_t>> quicken_info_offset_indices_;
};
-class OatWriter::WriteQuickeningIndicesMethodVisitor {
+class OatWriter::WriteQuickeningInfoOffsetsMethodVisitor {
public:
- WriteQuickeningIndicesMethodVisitor(OutputStream* out,
- uint32_t quickening_info_bytes,
- const SafeMap<const uint8_t*, uint32_t>& offset_map)
+ WriteQuickeningInfoOffsetsMethodVisitor(
+ OutputStream* out,
+ uint32_t start_offset,
+ SafeMap<const DexFile*, std::vector<uint32_t>>* quicken_info_offset_indices,
+ std::vector<uint32_t>* out_table_offsets)
: out_(out),
- quickening_info_bytes_(quickening_info_bytes),
- written_bytes_(0u),
- offset_map_(offset_map) {}
+ start_offset_(start_offset),
+ quicken_info_offset_indices_(quicken_info_offset_indices),
+ out_table_offsets_(out_table_offsets) {}
- bool VisitDexMethods(const std::vector<const DexFile*>& dex_files, const CompilerDriver& driver) {
+ bool VisitDexMethods(const std::vector<const DexFile*>& dex_files) {
for (const DexFile* dex_file : dex_files) {
- const size_t class_def_count = dex_file->NumClassDefs();
- for (size_t class_def_index = 0; class_def_index != class_def_count; ++class_def_index) {
- const DexFile::ClassDef& class_def = dex_file->GetClassDef(class_def_index);
- const uint8_t* class_data = dex_file->GetClassData(class_def);
- if (class_data == nullptr) {
- continue;
- }
- for (ClassDataItemIterator class_it(*dex_file, class_data);
- class_it.HasNext();
- class_it.Next()) {
- if (!class_it.IsAtMethod() || class_it.GetMethodCodeItem() == nullptr) {
- continue;
- }
- uint32_t method_idx = class_it.GetMemberIndex();
- CompiledMethod* compiled_method =
- driver.GetCompiledMethod(MethodReference(dex_file, method_idx));
- const DexFile::CodeItem* code_item = class_it.GetMethodCodeItem();
- CodeItemDebugInfoAccessor accessor(*dex_file, code_item);
- const uint32_t existing_debug_info_offset = accessor.DebugInfoOffset();
- // If the existing offset is already out of bounds (and not magic marker 0xFFFFFFFF)
- // we will pretend the method has been quickened.
- bool existing_offset_out_of_bounds =
- (existing_debug_info_offset >= dex_file->Size() &&
- existing_debug_info_offset != 0xFFFFFFFF);
- bool has_quickening_info = HasQuickeningInfo(compiled_method);
- if (has_quickening_info || existing_offset_out_of_bounds) {
- uint32_t new_debug_info_offset =
- dex_file->Size() + quickening_info_bytes_ + written_bytes_;
- // Abort if overflow.
- CHECK_GE(new_debug_info_offset, dex_file->Size());
- const_cast<DexFile::CodeItem*>(code_item)->SetDebugInfoOffset(new_debug_info_offset);
- uint32_t quickening_offset = has_quickening_info
- ? offset_map_.Get(compiled_method->GetVmapTable().data())
- : VdexFile::kNoQuickeningInfoOffset;
- if (!out_->WriteFully(&existing_debug_info_offset,
- sizeof(existing_debug_info_offset)) ||
- !out_->WriteFully(&quickening_offset, sizeof(quickening_offset))) {
- PLOG(ERROR) << "Failed to write quickening info for "
- << dex_file->PrettyMethod(method_idx) << " to "
- << out_->GetLocation();
- return false;
- }
- written_bytes_ += sizeof(existing_debug_info_offset) + sizeof(quickening_offset);
- }
- }
+ auto it = quicken_info_offset_indices_->find(dex_file);
+ DCHECK(it != quicken_info_offset_indices_->end()) << "Failed to find dex file "
+ << dex_file->GetLocation();
+ const std::vector<uint32_t>* const offsets = &it->second;
+
+ const uint32_t current_offset = start_offset_ + written_bytes_;
+ CHECK_ALIGNED_PARAM(current_offset, QuickenInfoOffsetTableAccessor::Alignment());
+
+ // Generate and write the data.
+ std::vector<uint8_t> table_data;
+ QuickenInfoOffsetTableAccessor::Builder builder(&table_data);
+ for (uint32_t offset : *offsets) {
+ builder.AddOffset(offset);
}
+
+ // Store the offset since we need to put those after the dex file. Table offsets are relative
+ // to the start of the quicken info section.
+ out_table_offsets_->push_back(current_offset);
+
+ const uint32_t length = table_data.size() * sizeof(table_data.front());
+ if (!out_->WriteFully(table_data.data(), length)) {
+ PLOG(ERROR) << "Failed to write quickening offset table for " << dex_file->GetLocation()
+ << " to " << out_->GetLocation();
+ return false;
+ }
+ written_bytes_ += length;
}
return true;
}
@@ -2736,14 +2737,16 @@
private:
OutputStream* const out_;
- const uint32_t quickening_info_bytes_;
- size_t written_bytes_;
- // Maps quickening map to its offset in the file.
- const SafeMap<const uint8_t*, uint32_t>& offset_map_;
+ const uint32_t start_offset_;
+ size_t written_bytes_ = 0u;
+ // Maps containing the offsets for the tables.
+ SafeMap<const DexFile*, std::vector<uint32_t>>* const quicken_info_offset_indices_;
+ std::vector<uint32_t>* const out_table_offsets_;
};
bool OatWriter::WriteQuickeningInfo(OutputStream* vdex_out) {
size_t initial_offset = vdex_size_;
+ // Make sure the table is properly aligned.
size_t start_offset = RoundUp(initial_offset, 4u);
off_t actual_offset = vdex_out->Seek(start_offset, kSeekSet);
@@ -2754,36 +2757,71 @@
return false;
}
- if (compiler_driver_->GetCompilerOptions().IsAnyCompilationEnabled()) {
+ size_t current_offset = start_offset;
+ if (compiler_driver_->GetCompilerOptions().IsQuickeningCompilationEnabled()) {
std::vector<uint32_t> dex_files_indices;
- SafeMap<const uint8_t*, uint32_t> offset_map;
- WriteQuickeningInfoMethodVisitor visitor1(this, vdex_out, start_offset, &offset_map);
- if (!VisitDexMethods(&visitor1)) {
+ WriteQuickeningInfoMethodVisitor write_quicken_info_visitor(this, vdex_out);
+ if (!write_quicken_info_visitor.VisitDexMethods(*dex_files_)) {
PLOG(ERROR) << "Failed to write the vdex quickening info. File: " << vdex_out->GetLocation();
return false;
}
- if (visitor1.GetNumberOfWrittenBytes() > 0) {
- WriteQuickeningIndicesMethodVisitor visitor2(vdex_out,
- visitor1.GetNumberOfWrittenBytes(),
- offset_map);
- if (!visitor2.VisitDexMethods(*dex_files_, *compiler_driver_)) {
- PLOG(ERROR) << "Failed to write the vdex quickening info. File: "
- << vdex_out->GetLocation();
+ uint32_t quicken_info_offset = write_quicken_info_visitor.GetNumberOfWrittenBytes();
+ current_offset = current_offset + quicken_info_offset;
+ uint32_t before_offset = current_offset;
+ current_offset = RoundUp(current_offset, QuickenInfoOffsetTableAccessor::Alignment());
+ const size_t extra_bytes = current_offset - before_offset;
+ quicken_info_offset += extra_bytes;
+ actual_offset = vdex_out->Seek(current_offset, kSeekSet);
+ if (actual_offset != static_cast<off_t>(current_offset)) {
+ PLOG(ERROR) << "Failed to seek to quickening offset table section. Actual: " << actual_offset
+ << " Expected: " << current_offset
+ << " Output: " << vdex_out->GetLocation();
+ return false;
+ }
+
+ std::vector<uint32_t> table_offsets;
+ WriteQuickeningInfoOffsetsMethodVisitor table_visitor(
+ vdex_out,
+ quicken_info_offset,
+ &write_quicken_info_visitor.GetQuickenInfoOffsetIndicies(),
+ /*out*/ &table_offsets);
+ if (!table_visitor.VisitDexMethods(*dex_files_)) {
+ PLOG(ERROR) << "Failed to write the vdex quickening info. File: "
+ << vdex_out->GetLocation();
+ return false;
+ }
+
+ CHECK_EQ(table_offsets.size(), dex_files_->size());
+
+ current_offset += table_visitor.GetNumberOfWrittenBytes();
+
+ // Store the offset table offset as a preheader for each dex.
+ size_t index = 0;
+ for (const OatDexFile& oat_dex_file : oat_dex_files_) {
+ const off_t desired_offset = oat_dex_file.dex_file_offset_ -
+ sizeof(VdexFile::QuickeningTableOffsetType);
+ actual_offset = vdex_out->Seek(desired_offset, kSeekSet);
+ if (actual_offset != desired_offset) {
+ PLOG(ERROR) << "Failed to seek to before dex file for writing offset table offset: "
+ << actual_offset << " Expected: " << desired_offset
+ << " Output: " << vdex_out->GetLocation();
return false;
}
-
- if (!vdex_out->Flush()) {
- PLOG(ERROR) << "Failed to flush stream after writing quickening info."
+ uint32_t offset = table_offsets[index];
+ if (!vdex_out->WriteFully(reinterpret_cast<const uint8_t*>(&offset), sizeof(offset))) {
+ PLOG(ERROR) << "Failed to write verifier deps."
<< " File: " << vdex_out->GetLocation();
return false;
}
- size_quickening_info_ = visitor1.GetNumberOfWrittenBytes() +
- visitor2.GetNumberOfWrittenBytes();
- } else {
- // We know we did not quicken.
- size_quickening_info_ = 0;
+ ++index;
}
+ if (!vdex_out->Flush()) {
+ PLOG(ERROR) << "Failed to flush stream after writing quickening info."
+ << " File: " << vdex_out->GetLocation();
+ return false;
+ }
+ size_quickening_info_ = current_offset - start_offset;
} else {
// We know we did not quicken.
size_quickening_info_ = 0;
@@ -3358,9 +3396,15 @@
// Dex files are required to be 4 byte aligned.
size_t initial_offset = vdex_size_;
size_t start_offset = RoundUp(initial_offset, 4);
- size_t file_offset = start_offset;
size_dex_file_alignment_ += start_offset - initial_offset;
+ // Leave extra room for the quicken offset table offset.
+ start_offset += sizeof(VdexFile::QuickeningTableOffsetType);
+ // TODO: Not count the offset as part of alignment.
+ size_dex_file_alignment_ += sizeof(VdexFile::QuickeningTableOffsetType);
+
+ size_t file_offset = start_offset;
+
// Seek to the start of the dex file and flush any pending operations in the stream.
// Verify that, after flushing the stream, the file is at the same offset as the stream.
off_t actual_offset = out->Seek(file_offset, kSeekSet);
@@ -4163,5 +4207,17 @@
UNREACHABLE();
}
+debug::DebugInfo OatWriter::GetDebugInfo() const {
+ debug::DebugInfo debug_info{};
+ debug_info.compiled_methods = ArrayRef<const debug::MethodDebugInfo>(method_info_);
+ if (dex_files_ != nullptr) {
+ for (auto dex_file : *dex_files_) {
+ uint32_t offset = vdex_dex_files_offset_ + (dex_file->Begin() - (*dex_files_)[0]->Begin());
+ debug_info.dex_files.emplace(offset, dex_file);
+ }
+ }
+ return debug_info;
+}
+
} // namespace linker
} // namespace art
diff --git a/dex2oat/linker/oat_writer.h b/dex2oat/linker/oat_writer.h
index c9deea9..ac96bb8 100644
--- a/dex2oat/linker/oat_writer.h
+++ b/dex2oat/linker/oat_writer.h
@@ -25,6 +25,7 @@
#include "base/array_ref.h"
#include "base/dchecked_vector.h"
#include "dex/compact_dex_level.h"
+#include "debug/debug_info.h"
#include "linker/relative_patcher.h" // For RelativePatcherTargetProvider.
#include "mem_map.h"
#include "method_reference.h"
@@ -240,9 +241,7 @@
~OatWriter();
- ArrayRef<const debug::MethodDebugInfo> GetMethodDebugInfo() const {
- return ArrayRef<const debug::MethodDebugInfo>(method_info_);
- }
+ debug::DebugInfo GetDebugInfo() const;
const CompilerDriver* GetCompilerDriver() const {
return compiler_driver_;
@@ -275,7 +274,7 @@
class WriteMapMethodVisitor;
class WriteMethodInfoVisitor;
class WriteQuickeningInfoMethodVisitor;
- class WriteQuickeningIndicesMethodVisitor;
+ class WriteQuickeningInfoOffsetsMethodVisitor;
// Visit all the methods in all the compiled dex files in their definition order
// with a given DexMethodVisitor.
diff --git a/dex2oat/linker/oat_writer_test.cc b/dex2oat/linker/oat_writer_test.cc
index 99bc1ad..c45166b 100644
--- a/dex2oat/linker/oat_writer_test.cc
+++ b/dex2oat/linker/oat_writer_test.cc
@@ -250,7 +250,7 @@
}
elf_writer->WriteDynamicSection();
- elf_writer->WriteDebugInfo(oat_writer.GetMethodDebugInfo());
+ elf_writer->WriteDebugInfo(oat_writer.GetDebugInfo());
if (!elf_writer->End()) {
return false;
@@ -659,7 +659,11 @@
ASSERT_EQ(dex_file2_data->GetLocation(), opened_dex_file2->GetLocation());
const VdexFile::Header &vdex_header = opened_oat_file->GetVdexFile()->GetHeader();
- ASSERT_EQ(vdex_header.GetQuickeningInfoSize(), 0u);
+ if (!compiler_driver_->GetCompilerOptions().IsQuickeningCompilationEnabled()) {
+ // If quickening is enabled we will always write the table since there is no special logic that
+ // checks for all methods not being quickened (not worth the complexity).
+ ASSERT_EQ(vdex_header.GetQuickeningInfoSize(), 0u);
+ }
int64_t actual_vdex_size = vdex_file.GetFile()->GetLength();
ASSERT_GE(actual_vdex_size, 0);
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc
index 8132323..1518e1d 100644
--- a/dexdump/dexdump.cc
+++ b/dexdump/dexdump.cc
@@ -1187,7 +1187,7 @@
*/
static void dumpCode(const DexFile* pDexFile, u4 idx, u4 flags,
const DexFile::CodeItem* pCode, u4 codeOffset) {
- CodeItemDebugInfoAccessor accessor(*pDexFile, pCode, pDexFile->GetDebugInfoOffset(pCode));
+ CodeItemDebugInfoAccessor accessor(*pDexFile, pCode, idx);
fprintf(gOutFile, " registers : %d\n", accessor.RegistersSize());
fprintf(gOutFile, " ins : %d\n", accessor.InsSize());
diff --git a/dexlayout/compact_dex_writer.cc b/dexlayout/compact_dex_writer.cc
index 1c5b16d..d1dc658 100644
--- a/dexlayout/compact_dex_writer.cc
+++ b/dexlayout/compact_dex_writer.cc
@@ -16,10 +16,144 @@
#include "compact_dex_writer.h"
+#include "base/logging.h"
+#include "base/time_utils.h"
+#include "dex/compact_dex_debug_info.h"
#include "dex/compact_dex_file.h"
+#include "dexlayout.h"
namespace art {
+uint32_t CompactDexWriter::WriteDebugInfoOffsetTable(uint32_t offset) {
+ const uint32_t start_offset = offset;
+ const dex_ir::Collections& collections = header_->GetCollections();
+ // Debug offsets for method indexes. 0 means no debug info.
+ std::vector<uint32_t> debug_info_offsets(collections.MethodIdsSize(), 0u);
+
+ static constexpr InvokeType invoke_types[] = {
+ kDirect,
+ kVirtual
+ };
+
+ for (InvokeType invoke_type : invoke_types) {
+ for (const std::unique_ptr<dex_ir::ClassDef>& class_def : collections.ClassDefs()) {
+ // Skip classes that are not defined in this dex file.
+ dex_ir::ClassData* class_data = class_def->GetClassData();
+ if (class_data == nullptr) {
+ continue;
+ }
+ for (auto& method : *(invoke_type == InvokeType::kDirect
+ ? class_data->DirectMethods()
+ : class_data->VirtualMethods())) {
+ const dex_ir::MethodId* method_id = method->GetMethodId();
+ dex_ir::CodeItem* code_item = method->GetCodeItem();
+ if (code_item != nullptr && code_item->DebugInfo() != nullptr) {
+ const uint32_t debug_info_offset = code_item->DebugInfo()->GetOffset();
+ const uint32_t method_idx = method_id->GetIndex();
+ if (debug_info_offsets[method_idx] != 0u) {
+ CHECK_EQ(debug_info_offset, debug_info_offsets[method_idx]);
+ }
+ debug_info_offsets[method_idx] = debug_info_offset;
+ }
+ }
+ }
+ }
+
+ std::vector<uint8_t> data;
+ debug_info_base_ = 0u;
+ debug_info_offsets_table_offset_ = 0u;
+ CompactDexDebugInfoOffsetTable::Build(debug_info_offsets,
+ &data,
+ &debug_info_base_,
+ &debug_info_offsets_table_offset_);
+ // Align the table and write it out.
+ offset = RoundUp(offset, CompactDexDebugInfoOffsetTable::kAlignment);
+ debug_info_offsets_pos_ = offset;
+ offset += Write(data.data(), data.size(), offset);
+
+ // Verify that the whole table decodes as expected and measure average performance.
+ const bool kMeasureAndTestOutput = dex_layout_->GetOptions().verify_output_;
+ if (kMeasureAndTestOutput && !debug_info_offsets.empty()) {
+ uint64_t start_time = NanoTime();
+ CompactDexDebugInfoOffsetTable::Accessor accessor(mem_map_->Begin() + debug_info_offsets_pos_,
+ debug_info_base_,
+ debug_info_offsets_table_offset_);
+
+ for (size_t i = 0; i < debug_info_offsets.size(); ++i) {
+ CHECK_EQ(accessor.GetDebugInfoOffset(i), debug_info_offsets[i]);
+ }
+ uint64_t end_time = NanoTime();
+ VLOG(dex) << "Average lookup time (ns) for debug info offsets: "
+ << (end_time - start_time) / debug_info_offsets.size();
+ }
+
+ return offset - start_offset;
+}
+
+uint32_t CompactDexWriter::WriteCodeItem(dex_ir::CodeItem* code_item,
+ uint32_t offset,
+ bool reserve_only) {
+ DCHECK(code_item != nullptr);
+ const uint32_t start_offset = offset;
+ offset = RoundUp(offset, CompactDexFile::CodeItem::kAlignment);
+ ProcessOffset(&offset, code_item);
+
+ CompactDexFile::CodeItem disk_code_item;
+ disk_code_item.registers_size_ = code_item->RegistersSize();
+ disk_code_item.ins_size_ = code_item->InsSize();
+ disk_code_item.outs_size_ = code_item->OutsSize();
+ disk_code_item.tries_size_ = code_item->TriesSize();
+ disk_code_item.insns_size_in_code_units_ = code_item->InsnsSize();
+ // Avoid using sizeof so that we don't write the fake instruction array at the end of the code
+ // item.
+ offset += Write(&disk_code_item,
+ OFFSETOF_MEMBER(CompactDexFile::CodeItem, insns_),
+ offset);
+ // Write the instructions.
+ offset += Write(code_item->Insns(), code_item->InsnsSize() * sizeof(uint16_t), offset);
+ // Write the post instruction data.
+ offset += WriteCodeItemPostInstructionData(code_item, offset, reserve_only);
+ return offset - start_offset;
+}
+
+void CompactDexWriter::SortDebugInfosByMethodIndex() {
+ dex_ir::Collections& collections = header_->GetCollections();
+ static constexpr InvokeType invoke_types[] = {
+ kDirect,
+ kVirtual
+ };
+ std::map<const dex_ir::DebugInfoItem*, uint32_t> method_idx_map;
+ for (InvokeType invoke_type : invoke_types) {
+ for (std::unique_ptr<dex_ir::ClassDef>& class_def : collections.ClassDefs()) {
+ // Skip classes that are not defined in this dex file.
+ dex_ir::ClassData* class_data = class_def->GetClassData();
+ if (class_data == nullptr) {
+ continue;
+ }
+ for (auto& method : *(invoke_type == InvokeType::kDirect
+ ? class_data->DirectMethods()
+ : class_data->VirtualMethods())) {
+ const dex_ir::MethodId* method_id = method->GetMethodId();
+ dex_ir::CodeItem* code_item = method->GetCodeItem();
+ if (code_item != nullptr && code_item->DebugInfo() != nullptr) {
+ const dex_ir::DebugInfoItem* debug_item = code_item->DebugInfo();
+ method_idx_map.insert(std::make_pair(debug_item, method_id->GetIndex()));
+ }
+ }
+ }
+ }
+ std::sort(collections.DebugInfoItems().begin(),
+ collections.DebugInfoItems().end(),
+ [&](const std::unique_ptr<dex_ir::DebugInfoItem>& a,
+ const std::unique_ptr<dex_ir::DebugInfoItem>& b) {
+ auto it_a = method_idx_map.find(a.get());
+ auto it_b = method_idx_map.find(b.get());
+ uint32_t idx_a = it_a != method_idx_map.end() ? it_a->second : 0u;
+ uint32_t idx_b = it_b != method_idx_map.end() ? it_b->second : 0u;
+ return idx_a < idx_b;
+ });
+}
+
void CompactDexWriter::WriteHeader() {
CompactDexFile::Header header;
CompactDexFile::WriteMagic(&header.magic_[0]);
@@ -49,6 +183,11 @@
header.class_defs_off_ = collections.ClassDefsOffset();
header.data_size_ = header_->DataSize();
header.data_off_ = header_->DataOffset();
+
+ // Compact dex specific flags.
+ header.debug_info_offsets_pos_ = debug_info_offsets_pos_;
+ header.debug_info_offsets_table_offset_ = debug_info_offsets_table_offset_;
+ header.debug_info_base_ = debug_info_base_;
header.feature_flags_ = 0u;
// In cases where apps are converted to cdex during install, maintain feature flags so that
// the verifier correctly verifies apps that aren't targetting default methods.
@@ -62,4 +201,103 @@
return sizeof(CompactDexFile::Header);
}
+void CompactDexWriter::WriteMemMap() {
+ // Starting offset is right after the header.
+ uint32_t offset = GetHeaderSize();
+
+ dex_ir::Collections& collection = header_->GetCollections();
+
+ // Based on: https://source.android.com/devices/tech/dalvik/dex-format
+ // Since the offsets may not be calculated already, the writing must be done in the correct order.
+ const uint32_t string_ids_offset = offset;
+ offset += WriteStringIds(offset, /*reserve_only*/ true);
+ offset += WriteTypeIds(offset);
+ const uint32_t proto_ids_offset = offset;
+ offset += WriteProtoIds(offset, /*reserve_only*/ true);
+ offset += WriteFieldIds(offset);
+ offset += WriteMethodIds(offset);
+ const uint32_t class_defs_offset = offset;
+ offset += WriteClassDefs(offset, /*reserve_only*/ true);
+ const uint32_t call_site_ids_offset = offset;
+ offset += WriteCallSiteIds(offset, /*reserve_only*/ true);
+ offset += WriteMethodHandles(offset);
+
+ uint32_t data_offset_ = 0u;
+ if (compute_offsets_) {
+ // Data section.
+ offset = RoundUp(offset, kDataSectionAlignment);
+ data_offset_ = offset;
+ }
+
+ // Write code item first to minimize the space required for encoded methods.
+ // For cdex, the code items don't depend on the debug info.
+ offset += WriteCodeItems(offset, /*reserve_only*/ false);
+
+ // Sort the debug infos by method index order, this reduces size by ~0.1% by reducing the size of
+ // the debug info offset table.
+ SortDebugInfosByMethodIndex();
+ offset += WriteDebugInfoItems(offset);
+
+ offset += WriteEncodedArrays(offset);
+ offset += WriteAnnotations(offset);
+ offset += WriteAnnotationSets(offset);
+ offset += WriteAnnotationSetRefs(offset);
+ offset += WriteAnnotationsDirectories(offset);
+ offset += WriteTypeLists(offset);
+ offset += WriteClassDatas(offset);
+ offset += WriteStringDatas(offset);
+
+ // Write delayed id sections that depend on data sections.
+ WriteStringIds(string_ids_offset, /*reserve_only*/ false);
+ WriteProtoIds(proto_ids_offset, /*reserve_only*/ false);
+ WriteClassDefs(class_defs_offset, /*reserve_only*/ false);
+ WriteCallSiteIds(call_site_ids_offset, /*reserve_only*/ false);
+
+ // Write the map list.
+ if (compute_offsets_) {
+ offset = RoundUp(offset, SectionAlignment(DexFile::kDexTypeMapList));
+ collection.SetMapListOffset(offset);
+ } else {
+ offset = collection.MapListOffset();
+ }
+ offset += GenerateAndWriteMapItems(offset);
+ offset = RoundUp(offset, kDataSectionAlignment);
+
+ // Map items are included in the data section.
+ if (compute_offsets_) {
+ header_->SetDataSize(offset - data_offset_);
+ if (header_->DataSize() != 0) {
+ // Offset must be zero when the size is zero.
+ header_->SetDataOffset(data_offset_);
+ } else {
+ header_->SetDataOffset(0u);
+ }
+ }
+
+ // Write link data if it exists.
+ const std::vector<uint8_t>& link_data = collection.LinkData();
+ if (link_data.size() > 0) {
+ CHECK_EQ(header_->LinkSize(), static_cast<uint32_t>(link_data.size()));
+ if (compute_offsets_) {
+ header_->SetLinkOffset(offset);
+ }
+ offset += Write(&link_data[0], link_data.size(), header_->LinkOffset());
+ }
+
+ // Write debug info offset table last to make dex file verifier happy.
+ offset += WriteDebugInfoOffsetTable(offset);
+
+ // Write header last.
+ if (compute_offsets_) {
+ header_->SetFileSize(offset);
+ }
+ WriteHeader();
+
+ if (dex_layout_->GetOptions().update_checksum_) {
+ header_->SetChecksum(DexFile::CalculateChecksum(mem_map_->Begin(), offset));
+ // Rewrite the header with the calculated checksum.
+ WriteHeader();
+ }
+}
+
} // namespace art
diff --git a/dexlayout/compact_dex_writer.h b/dexlayout/compact_dex_writer.h
index d13333b..37f6ff1 100644
--- a/dexlayout/compact_dex_writer.h
+++ b/dexlayout/compact_dex_writer.h
@@ -33,13 +33,30 @@
compact_dex_level_(compact_dex_level) {}
protected:
+ void WriteMemMap() OVERRIDE;
+
void WriteHeader() OVERRIDE;
size_t GetHeaderSize() const OVERRIDE;
+ uint32_t WriteDebugInfoOffsetTable(uint32_t offset);
+
const CompactDexLevel compact_dex_level_;
+ uint32_t WriteCodeItem(dex_ir::CodeItem* code_item, uint32_t offset, bool reserve_only) OVERRIDE;
+
+ void SortDebugInfosByMethodIndex();
+
private:
+ // Position in the compact dex file for the debug info table data starts.
+ uint32_t debug_info_offsets_pos_ = 0u;
+
+ // Offset into the debug info table data where the lookup table is.
+ uint32_t debug_info_offsets_table_offset_ = 0u;
+
+ // Base offset of where debug info starts in the dex file.
+ uint32_t debug_info_base_ = 0u;
+
DISALLOW_COPY_AND_ASSIGN(CompactDexWriter);
};
diff --git a/dexlayout/dex_ir.cc b/dexlayout/dex_ir.cc
index 2191ea6..0a59cc9 100644
--- a/dexlayout/dex_ir.cc
+++ b/dexlayout/dex_ir.cc
@@ -566,8 +566,10 @@
}
CodeItem* Collections::CreateCodeItem(const DexFile& dex_file,
- const DexFile::CodeItem& disk_code_item, uint32_t offset) {
- CodeItemDebugInfoAccessor accessor(dex_file, &disk_code_item);
+ const DexFile::CodeItem& disk_code_item,
+ uint32_t offset,
+ uint32_t dex_method_index) {
+ CodeItemDebugInfoAccessor accessor(dex_file, &disk_code_item, dex_method_index);
const uint16_t registers_size = accessor.RegistersSize();
const uint16_t ins_size = accessor.InsSize();
const uint16_t outs_size = accessor.OutsSize();
@@ -705,7 +707,10 @@
DebugInfoItem* debug_info = nullptr;
if (disk_code_item != nullptr) {
if (code_item == nullptr) {
- code_item = CreateCodeItem(dex_file, *disk_code_item, cdii.GetMethodCodeItemOffset());
+ code_item = CreateCodeItem(dex_file,
+ *disk_code_item,
+ cdii.GetMethodCodeItemOffset(),
+ cdii.GetMemberIndex());
}
debug_info = code_item->DebugInfo();
}
diff --git a/dexlayout/dex_ir.h b/dexlayout/dex_ir.h
index 6797fa5..ca47b34 100644
--- a/dexlayout/dex_ir.h
+++ b/dexlayout/dex_ir.h
@@ -133,6 +133,7 @@
uint32_t Size() const { return collection_.size(); }
Vector& Collection() { return collection_; }
+ const Vector& Collection() const { return collection_; }
protected:
Vector collection_;
@@ -230,6 +231,8 @@
CollectionVector<CodeItem>::Vector& CodeItems() { return code_items_.Collection(); }
CollectionVector<ClassData>::Vector& ClassDatas() { return class_datas_.Collection(); }
+ const CollectionVector<ClassDef>::Vector& ClassDefs() const { return class_defs_.Collection(); }
+
void CreateStringId(const DexFile& dex_file, uint32_t i);
void CreateTypeId(const DexFile& dex_file, uint32_t i);
void CreateProtoId(const DexFile& dex_file, uint32_t i);
@@ -251,8 +254,10 @@
const DexFile::AnnotationSetItem* disk_annotations_item, uint32_t offset);
AnnotationsDirectoryItem* CreateAnnotationsDirectoryItem(const DexFile& dex_file,
const DexFile::AnnotationsDirectoryItem* disk_annotations_item, uint32_t offset);
- CodeItem* CreateCodeItem(
- const DexFile& dex_file, const DexFile::CodeItem& disk_code_item, uint32_t offset);
+ CodeItem* CreateCodeItem(const DexFile& dex_file,
+ const DexFile::CodeItem& disk_code_item,
+ uint32_t offset,
+ uint32_t dex_method_index);
ClassData* CreateClassData(const DexFile& dex_file, const uint8_t* encoded_data, uint32_t offset);
void AddAnnotationsFromMapListSection(const DexFile& dex_file,
uint32_t start_offset,
diff --git a/dexlayout/dex_writer.cc b/dexlayout/dex_writer.cc
index 489a6b1..6e1cb62 100644
--- a/dexlayout/dex_writer.cc
+++ b/dexlayout/dex_writer.cc
@@ -30,25 +30,6 @@
namespace art {
-static constexpr uint32_t kDataSectionAlignment = sizeof(uint32_t) * 2;
-static constexpr uint32_t kDexSectionWordAlignment = 4;
-
-static constexpr uint32_t SectionAlignment(DexFile::MapItemType type) {
- switch (type) {
- case DexFile::kDexTypeClassDataItem:
- case DexFile::kDexTypeStringDataItem:
- case DexFile::kDexTypeDebugInfoItem:
- case DexFile::kDexTypeAnnotationItem:
- case DexFile::kDexTypeEncodedArrayItem:
- return alignof(uint8_t);
-
- default:
- // All other sections are kDexAlignedSection.
- return kDexSectionWordAlignment;
- }
-}
-
-
size_t EncodeIntValue(int32_t value, uint8_t* buffer) {
size_t length = 0;
if (value >= 0) {
@@ -526,69 +507,96 @@
return offset - start;
}
+uint32_t DexWriter::WriteCodeItemPostInstructionData(dex_ir::CodeItem* code_item,
+ uint32_t offset,
+ bool reserve_only) {
+ const uint32_t start_offset = offset;
+ if (code_item->TriesSize() != 0) {
+ // Make sure the try items are properly aligned.
+ offset = RoundUp(offset, kDexTryItemAlignment);
+ // Write try items.
+ for (std::unique_ptr<const dex_ir::TryItem>& try_item : *code_item->Tries()) {
+ DexFile::TryItem disk_try_item;
+ if (!reserve_only) {
+ disk_try_item.start_addr_ = try_item->StartAddr();
+ disk_try_item.insn_count_ = try_item->InsnCount();
+ disk_try_item.handler_off_ = try_item->GetHandlers()->GetListOffset();
+ }
+ offset += Write(&disk_try_item, sizeof(disk_try_item), offset);
+ }
+ size_t max_offset = offset;
+ // Leave offset pointing to the end of the try items.
+ UNUSED(WriteUleb128(code_item->Handlers()->size(), offset));
+ for (std::unique_ptr<const dex_ir::CatchHandler>& handlers : *code_item->Handlers()) {
+ size_t list_offset = offset + handlers->GetListOffset();
+ uint32_t size = handlers->HasCatchAll() ? (handlers->GetHandlers()->size() - 1) * -1 :
+ handlers->GetHandlers()->size();
+ list_offset += WriteSleb128(size, list_offset);
+ for (std::unique_ptr<const dex_ir::TypeAddrPair>& handler : *handlers->GetHandlers()) {
+ if (handler->GetTypeId() != nullptr) {
+ list_offset += WriteUleb128(handler->GetTypeId()->GetIndex(), list_offset);
+ }
+ list_offset += WriteUleb128(handler->GetAddress(), list_offset);
+ }
+ // TODO: Clean this up to write the handlers in address order.
+ max_offset = std::max(max_offset, list_offset);
+ }
+ offset = max_offset;
+ }
+
+ return offset - start_offset;
+}
+
+uint32_t DexWriter::WriteCodeItem(dex_ir::CodeItem* code_item,
+ uint32_t offset,
+ bool reserve_only) {
+ DCHECK(code_item != nullptr);
+ const uint32_t start_offset = offset;
+ offset = RoundUp(offset, SectionAlignment(DexFile::kDexTypeCodeItem));
+ ProcessOffset(&offset, code_item);
+
+ StandardDexFile::CodeItem disk_code_item;
+ if (!reserve_only) {
+ disk_code_item.registers_size_ = code_item->RegistersSize();
+ disk_code_item.ins_size_ = code_item->InsSize();
+ disk_code_item.outs_size_ = code_item->OutsSize();
+ disk_code_item.tries_size_ = code_item->TriesSize();
+ disk_code_item.debug_info_off_ = code_item->DebugInfo() == nullptr
+ ? 0
+ : code_item->DebugInfo()->GetOffset();
+ disk_code_item.insns_size_in_code_units_ = code_item->InsnsSize();
+ }
+ // Avoid using sizeof so that we don't write the fake instruction array at the end of the code
+ // item.
+ offset += Write(&disk_code_item,
+ OFFSETOF_MEMBER(StandardDexFile::CodeItem, insns_),
+ offset);
+ // Write the instructions.
+ offset += Write(code_item->Insns(), code_item->InsnsSize() * sizeof(uint16_t), offset);
+ // Write the post instruction data.
+ offset += WriteCodeItemPostInstructionData(code_item, offset, reserve_only);
+ return offset - start_offset;
+}
+
uint32_t DexWriter::WriteCodeItems(uint32_t offset, bool reserve_only) {
DexLayoutSection* code_section = nullptr;
if (!reserve_only && dex_layout_ != nullptr) {
code_section = &dex_layout_->GetSections().sections_[static_cast<size_t>(
DexLayoutSections::SectionType::kSectionTypeCode)];
}
- uint16_t uint16_buffer[4] = {};
- uint32_t uint32_buffer[2] = {};
uint32_t start = offset;
for (auto& code_item : header_->GetCollections().CodeItems()) {
- offset = RoundUp(offset, SectionAlignment(DexFile::kDexTypeCodeItem));
- ProcessOffset(&offset, code_item.get());
- if (!reserve_only) {
- uint16_buffer[0] = code_item->RegistersSize();
- uint16_buffer[1] = code_item->InsSize();
- uint16_buffer[2] = code_item->OutsSize();
- uint16_buffer[3] = code_item->TriesSize();
- uint32_buffer[0] = code_item->DebugInfo() == nullptr ? 0 :
- code_item->DebugInfo()->GetOffset();
- uint32_buffer[1] = code_item->InsnsSize();
- // Only add the section hotness info once.
- if (code_section != nullptr) {
- auto it = dex_layout_->LayoutHotnessInfo().code_item_layout_.find(code_item.get());
- if (it != dex_layout_->LayoutHotnessInfo().code_item_layout_.end()) {
- code_section->parts_[static_cast<size_t>(it->second)].CombineSection(
- code_item->GetOffset(), code_item->GetOffset() + code_item->GetSize());
- }
+ const size_t code_item_size = WriteCodeItem(code_item.get(), offset, reserve_only);
+ // Only add the section hotness info once.
+ if (!reserve_only && code_section != nullptr) {
+ auto it = dex_layout_->LayoutHotnessInfo().code_item_layout_.find(code_item.get());
+ if (it != dex_layout_->LayoutHotnessInfo().code_item_layout_.end()) {
+ code_section->parts_[static_cast<size_t>(it->second)].CombineSection(
+ offset,
+ offset + code_item_size);
}
}
- offset += Write(uint16_buffer, 4 * sizeof(uint16_t), offset);
- offset += Write(uint32_buffer, 2 * sizeof(uint32_t), offset);
- offset += Write(code_item->Insns(), code_item->InsnsSize() * sizeof(uint16_t), offset);
- if (code_item->TriesSize() != 0) {
- if (code_item->InsnsSize() % 2 != 0) {
- uint16_t padding[1] = { 0 };
- offset += Write(padding, sizeof(uint16_t), offset);
- }
- uint32_t start_addr[1];
- uint16_t insn_count_and_handler_off[2];
- for (std::unique_ptr<const dex_ir::TryItem>& try_item : *code_item->Tries()) {
- start_addr[0] = try_item->StartAddr();
- insn_count_and_handler_off[0] = try_item->InsnCount();
- insn_count_and_handler_off[1] = try_item->GetHandlers()->GetListOffset();
- offset += Write(start_addr, sizeof(uint32_t), offset);
- offset += Write(insn_count_and_handler_off, 2 * sizeof(uint16_t), offset);
- }
- // Leave offset pointing to the end of the try items.
- UNUSED(WriteUleb128(code_item->Handlers()->size(), offset));
- for (std::unique_ptr<const dex_ir::CatchHandler>& handlers : *code_item->Handlers()) {
- size_t list_offset = offset + handlers->GetListOffset();
- uint32_t size = handlers->HasCatchAll() ? (handlers->GetHandlers()->size() - 1) * -1 :
- handlers->GetHandlers()->size();
- list_offset += WriteSleb128(size, list_offset);
- for (std::unique_ptr<const dex_ir::TypeAddrPair>& handler : *handlers->GetHandlers()) {
- if (handler->GetTypeId() != nullptr) {
- list_offset += WriteUleb128(handler->GetTypeId()->GetIndex(), list_offset);
- }
- list_offset += WriteUleb128(handler->GetAddress(), list_offset);
- }
- }
- }
- // TODO: Clean this up to properly calculate the size instead of assuming it doesn't change.
- offset = code_item->GetOffset() + code_item->GetSize();
+ offset += code_item_size;
}
if (compute_offsets_ && start != offset) {
diff --git a/dexlayout/dex_writer.h b/dexlayout/dex_writer.h
index 92a002e..fdeb299 100644
--- a/dexlayout/dex_writer.h
+++ b/dexlayout/dex_writer.h
@@ -23,6 +23,7 @@
#include "base/unix_file/fd_file.h"
#include "dex/compact_dex_level.h"
+#include "dex/dex_file.h"
#include "dex_ir.h"
#include "mem_map.h"
#include "os.h"
@@ -59,6 +60,25 @@
class DexWriter {
public:
+ static constexpr uint32_t kDataSectionAlignment = sizeof(uint32_t) * 2;
+ static constexpr uint32_t kDexSectionWordAlignment = 4;
+ static constexpr uint32_t kDexTryItemAlignment = sizeof(uint32_t);
+
+ static inline constexpr uint32_t SectionAlignment(DexFile::MapItemType type) {
+ switch (type) {
+ case DexFile::kDexTypeClassDataItem:
+ case DexFile::kDexTypeStringDataItem:
+ case DexFile::kDexTypeDebugInfoItem:
+ case DexFile::kDexTypeAnnotationItem:
+ case DexFile::kDexTypeEncodedArrayItem:
+ return alignof(uint8_t);
+
+ default:
+ // All other sections are kDexAlignedSection.
+ return DexWriter::kDexSectionWordAlignment;
+ }
+ }
+
DexWriter(dex_ir::Header* header,
MemMap* mem_map,
DexLayout* dex_layout,
@@ -77,7 +97,7 @@
virtual ~DexWriter() {}
protected:
- void WriteMemMap();
+ virtual void WriteMemMap();
size_t Write(const void* buffer, size_t length, size_t offset) WARN_UNUSED;
size_t WriteSleb128(uint32_t value, size_t offset) WARN_UNUSED;
@@ -118,6 +138,11 @@
uint32_t WriteMapItems(uint32_t offset, MapItemQueue* queue);
uint32_t GenerateAndWriteMapItems(uint32_t offset);
+ virtual uint32_t WriteCodeItemPostInstructionData(dex_ir::CodeItem* item,
+ uint32_t offset,
+ bool reserve_only);
+ virtual uint32_t WriteCodeItem(dex_ir::CodeItem* item, uint32_t offset, bool reserve_only);
+
// Process an offset, if compute_offset is set, write into the dex ir item, otherwise read the
// existing offset and use that for writing.
void ProcessOffset(uint32_t* const offset, dex_ir::Item* item) {
diff --git a/dexlist/dexlist.cc b/dexlist/dexlist.cc
index e452e98..1ced8ca 100644
--- a/dexlist/dexlist.cc
+++ b/dexlist/dexlist.cc
@@ -101,7 +101,7 @@
if (pCode == nullptr || codeOffset == 0) {
return;
}
- CodeItemDebugInfoAccessor accessor(*pDexFile, pCode, pDexFile->GetDebugInfoOffset(pCode));
+ CodeItemDebugInfoAccessor accessor(*pDexFile, pCode, idx);
// Method information.
const DexFile::MethodId& pMethodId = pDexFile->GetMethodId(idx);
diff --git a/oatdump/oatdump.cc b/oatdump/oatdump.cc
index 6668dac..2b90614 100644
--- a/oatdump/oatdump.cc
+++ b/oatdump/oatdump.cc
@@ -38,6 +38,7 @@
#include "class_linker-inl.h"
#include "class_linker.h"
#include "compiled_method.h"
+#include "debug/debug_info.h"
#include "debug/elf_debug_writer.h"
#include "debug/method_debug_info.h"
#include "dex/code_item_accessors-inl.h"
@@ -202,8 +203,13 @@
// TODO: Try to symbolize link-time thunks?
// This would require disassembling all methods to find branches outside the method code.
+ // TODO: Add symbols for dex bytecode in the .dex section.
+
+ debug::DebugInfo debug_info{};
+ debug_info.compiled_methods = ArrayRef<const debug::MethodDebugInfo>(method_debug_infos_);
+
debug::WriteDebugInfo(builder_.get(),
- ArrayRef<const debug::MethodDebugInfo>(method_debug_infos_),
+ debug_info,
dwarf::DW_DEBUG_FRAME_FORMAT,
true /* write_oat_patches */);
@@ -718,7 +724,6 @@
}
vdex_file->Unquicken(MakeNonOwningPointerVector(tmp_dex_files),
- vdex_file->GetQuickeningInfo(),
/* decompile_return_instruction */ true);
*dex_files = std::move(tmp_dex_files);
diff --git a/openjdkjvmti/fixed_up_dex_file.cc b/openjdkjvmti/fixed_up_dex_file.cc
index 963c6f8..dcc834a 100644
--- a/openjdkjvmti/fixed_up_dex_file.cc
+++ b/openjdkjvmti/fixed_up_dex_file.cc
@@ -63,8 +63,7 @@
if (vdex == nullptr) {
return;
}
- art::VdexFile::UnquickenDexFile(
- new_dex_file, vdex->GetQuickeningInfo(), /* decompile_return_instruction */true);
+ vdex->UnquickenDexFile(new_dex_file, original_dex_file, /* decompile_return_instruction */true);
}
std::unique_ptr<FixedUpDexFile> FixedUpDexFile::Create(const art::DexFile& original) {
diff --git a/runtime/Android.bp b/runtime/Android.bp
index 78cb3b6..2e34baf 100644
--- a/runtime/Android.bp
+++ b/runtime/Android.bp
@@ -25,6 +25,7 @@
defaults: ["art_defaults"],
host_supported: true,
srcs: [
+ "dex/compact_dex_debug_info.cc",
"dex/compact_dex_file.cc",
"dex/dex_file.cc",
"dex/dex_file_exception_helpers.cc",
@@ -120,6 +121,7 @@
"common_throws.cc",
"compiler_filter.cc",
"debugger.cc",
+ "dex/compact_dex_debug_info.cc",
"dex/compact_dex_file.cc",
"dex/dex_file.cc",
"dex/dex_file_annotations.cc",
@@ -637,6 +639,7 @@
"class_table_test.cc",
"compiler_filter_test.cc",
"dex/code_item_accessors_test.cc",
+ "dex/compact_dex_debug_info_test.cc",
"dex/compact_dex_file_test.cc",
"dex/dex_file_test.cc",
"dex/dex_file_verifier_test.cc",
diff --git a/runtime/art_method.cc b/runtime/art_method.cc
index f9eedae..96468bb 100644
--- a/runtime/art_method.cc
+++ b/runtime/art_method.cc
@@ -319,21 +319,6 @@
self->AssertThreadSuspensionIsAllowable();
CHECK_EQ(kRunnable, self->GetState());
CHECK_STREQ(GetInterfaceMethodIfProxy(kRuntimePointerSize)->GetShorty(), shorty);
-
- if (!IsNative() &&
- !IsObsolete() &&
- !IsProxyMethod() &&
- IsInvokable() &&
- ClassLinker::ShouldUseInterpreterEntrypoint(this, GetEntryPointFromQuickCompiledCode())) {
- ClassLinker* cl = Runtime::Current()->GetClassLinker();
- const void* entry_point = GetEntryPointFromQuickCompiledCode();
- DCHECK(cl->IsQuickToInterpreterBridge(entry_point) ||
- cl->IsQuickResolutionStub(entry_point) ||
- entry_point == GetQuickInstrumentationEntryPoint())
- << PrettyMethod() << " is expected to be interpreted but has an unexpected entrypoint."
- << " The entrypoint is " << entry_point << " (incorrect) oat entrypoint would be "
- << GetOatMethodQuickCode(cl->GetImagePointerSize());
- }
}
// Push a transition back into managed code onto the linked list in thread.
@@ -577,14 +562,14 @@
return true;
}
-const uint8_t* ArtMethod::GetQuickenedInfo() {
+ArrayRef<const uint8_t> ArtMethod::GetQuickenedInfo() {
const DexFile& dex_file = GetDeclaringClass()->GetDexFile();
const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
if (oat_dex_file == nullptr || (oat_dex_file->GetOatFile() == nullptr)) {
- return nullptr;
+ return ArrayRef<const uint8_t>();
}
- return oat_dex_file->GetOatFile()->GetVdexFile()->GetQuickenedInfoOf(
- dex_file, GetCodeItemOffset());
+ return oat_dex_file->GetOatFile()->GetVdexFile()->GetQuickenedInfoOf(dex_file,
+ GetDexMethodIndex());
}
const OatQuickMethodHeader* ArtMethod::GetOatQuickMethodHeader(uintptr_t pc) {
diff --git a/runtime/art_method.h b/runtime/art_method.h
index c4a586e..cd06354 100644
--- a/runtime/art_method.h
+++ b/runtime/art_method.h
@@ -21,6 +21,7 @@
#include <android-base/logging.h>
+#include "base/array_ref.h"
#include "base/bit_utils.h"
#include "base/casts.h"
#include "base/enums.h"
@@ -662,7 +663,7 @@
return hotness_count_;
}
- const uint8_t* GetQuickenedInfo() REQUIRES_SHARED(Locks::mutator_lock_);
+ ArrayRef<const uint8_t> GetQuickenedInfo() REQUIRES_SHARED(Locks::mutator_lock_);
// Returns the method header for the compiled code containing 'pc'. Note that runtime
// methods will return null for this method, as they are not oat based.
diff --git a/runtime/class_linker.cc b/runtime/class_linker.cc
index c487808..8776542 100644
--- a/runtime/class_linker.cc
+++ b/runtime/class_linker.cc
@@ -1296,32 +1296,22 @@
}
for (ArtMethod& m : klass->GetDirectMethods(kRuntimePointerSize)) {
const void* code = m.GetEntryPointFromQuickCompiledCode();
- if (!m.IsProxyMethod() &&
- !m.IsNative() &&
- !class_linker->IsQuickResolutionStub(code) &&
+ const void* oat_code = m.IsInvokable() ? class_linker->GetQuickOatCodeFor(&m) : code;
+ if (!class_linker->IsQuickResolutionStub(code) &&
+ !class_linker->IsQuickGenericJniStub(code) &&
!class_linker->IsQuickToInterpreterBridge(code) &&
- m.IsInvokable()) {
- // Since this is just a sanity check it's okay to get the oat code here regardless
- // of whether it's usable.
- const void* oat_code = m.GetOatMethodQuickCode(class_linker->GetImagePointerSize());
- if (oat_code != nullptr) {
- DCHECK_EQ(code, oat_code) << m.PrettyMethod();
- }
+ !m.IsNative()) {
+ DCHECK_EQ(code, oat_code) << m.PrettyMethod();
}
}
for (ArtMethod& m : klass->GetVirtualMethods(kRuntimePointerSize)) {
const void* code = m.GetEntryPointFromQuickCompiledCode();
- if (!m.IsProxyMethod() &&
- !m.IsNative() &&
- !class_linker->IsQuickResolutionStub(code) &&
+ const void* oat_code = m.IsInvokable() ? class_linker->GetQuickOatCodeFor(&m) : code;
+ if (!class_linker->IsQuickResolutionStub(code) &&
+ !class_linker->IsQuickGenericJniStub(code) &&
!class_linker->IsQuickToInterpreterBridge(code) &&
- m.IsInvokable()) {
- // Since this is just a sanity check it's okay to get the oat code here regardless
- // of whether it's usable.
- const void* oat_code = m.GetOatMethodQuickCode(class_linker->GetImagePointerSize());
- if (oat_code != nullptr) {
- DCHECK_EQ(code, oat_code) << m.PrettyMethod();
- }
+ !m.IsNative()) {
+ DCHECK_EQ(code, oat_code) << m.PrettyMethod();
}
}
}
@@ -2909,25 +2899,21 @@
image_pointer_size_);
}
-const void* ClassLinker::GetQuickEntrypointFor(ArtMethod* method) {
+// Special case to get oat code without overwriting a trampoline.
+const void* ClassLinker::GetQuickOatCodeFor(ArtMethod* method) {
CHECK(method->IsInvokable()) << method->PrettyMethod();
if (method->IsProxyMethod()) {
return GetQuickProxyInvokeHandler();
}
- const void* oat_code = method->GetOatMethodQuickCode(GetImagePointerSize());
- if (oat_code == nullptr) {
- // We need either the generic jni or interpreter bridge.
- if (method->IsNative()) {
- return GetQuickGenericJniStub();
- } else {
- return GetQuickToInterpreterBridge();
- }
- } else if (ClassLinker::ShouldUseInterpreterEntrypoint(method, oat_code)) {
- // We have oat code but we cannot use it for some reason.
- return GetQuickToInterpreterBridge();
- } else {
- return oat_code;
+ auto* code = method->GetOatMethodQuickCode(GetImagePointerSize());
+ if (code != nullptr) {
+ return code;
}
+ if (method->IsNative()) {
+ // No code and native? Use generic trampoline.
+ return GetQuickGenericJniStub();
+ }
+ return GetQuickToInterpreterBridge();
}
bool ClassLinker::ShouldUseInterpreterEntrypoint(ArtMethod* method, const void* quick_code) {
diff --git a/runtime/class_linker.h b/runtime/class_linker.h
index 62804e7..3e3425f 100644
--- a/runtime/class_linker.h
+++ b/runtime/class_linker.h
@@ -498,8 +498,9 @@
std::string GetDescriptorForProxy(ObjPtr<mirror::Class> proxy_class)
REQUIRES_SHARED(Locks::mutator_lock_);
- // Get the correct entrypoint for a method as far as the class-linker is concerned.
- const void* GetQuickEntrypointFor(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
+ // Get the oat code for a method when its class isn't yet initialized.
+ const void* GetQuickOatCodeFor(ArtMethod* method)
+ REQUIRES_SHARED(Locks::mutator_lock_);
pid_t GetClassesLockOwner(); // For SignalCatcher.
pid_t GetDexLockOwner(); // For SignalCatcher.
diff --git a/runtime/dex/code_item_accessors-inl.h b/runtime/dex/code_item_accessors-inl.h
index 2792dc0..63fd120 100644
--- a/runtime/dex/code_item_accessors-inl.h
+++ b/runtime/dex/code_item_accessors-inl.h
@@ -34,15 +34,9 @@
: CodeItemDataAccessor(*method->GetDexFile(), method->GetCodeItem()) {}
inline CodeItemDebugInfoAccessor::CodeItemDebugInfoAccessor(ArtMethod* method)
- : CodeItemDebugInfoAccessor(*method->GetDexFile(), method->GetCodeItem()) {}
-
-inline CodeItemDebugInfoAccessor::CodeItemDebugInfoAccessor(const DexFile& dex_file,
- const DexFile::CodeItem* code_item) {
- if (code_item == nullptr) {
- return;
- }
- Init(dex_file, code_item, OatFile::GetDebugInfoOffset(dex_file, code_item->debug_info_off_));
-}
+ : CodeItemDebugInfoAccessor(*method->GetDexFile(),
+ method->GetCodeItem(),
+ method->GetDexMethodIndex()) {}
} // namespace art
diff --git a/runtime/dex/code_item_accessors-no_art-inl.h b/runtime/dex/code_item_accessors-no_art-inl.h
index baea856..aaa86d4 100644
--- a/runtime/dex/code_item_accessors-no_art-inl.h
+++ b/runtime/dex/code_item_accessors-no_art-inl.h
@@ -146,22 +146,28 @@
inline void CodeItemDebugInfoAccessor::Init(const DexFile& dex_file,
const DexFile::CodeItem* code_item,
- uint32_t debug_info_offset) {
+ uint32_t dex_method_index) {
+ if (code_item == nullptr) {
+ return;
+ }
dex_file_ = &dex_file;
- debug_info_offset_ = debug_info_offset;
if (dex_file.IsCompactDexFile()) {
- Init(down_cast<const CompactDexFile::CodeItem&>(*code_item));
+ Init(down_cast<const CompactDexFile::CodeItem&>(*code_item), dex_method_index);
} else {
DCHECK(dex_file.IsStandardDexFile());
Init(down_cast<const StandardDexFile::CodeItem&>(*code_item));
}
}
-inline void CodeItemDebugInfoAccessor::Init(const CompactDexFile::CodeItem& code_item) {
+inline void CodeItemDebugInfoAccessor::Init(const CompactDexFile::CodeItem& code_item,
+ uint32_t dex_method_index) {
+ debug_info_offset_ = down_cast<const CompactDexFile*>(dex_file_)->GetDebugInfoOffset(
+ dex_method_index);
CodeItemDataAccessor::Init(code_item);
}
inline void CodeItemDebugInfoAccessor::Init(const StandardDexFile::CodeItem& code_item) {
+ debug_info_offset_ = code_item.debug_info_off_;
CodeItemDataAccessor::Init(code_item);
}
diff --git a/runtime/dex/code_item_accessors.h b/runtime/dex/code_item_accessors.h
index b5a6957..66531f9 100644
--- a/runtime/dex/code_item_accessors.h
+++ b/runtime/dex/code_item_accessors.h
@@ -131,20 +131,16 @@
public:
CodeItemDebugInfoAccessor() = default;
- // Handles null code items, but not null dex files.
- ALWAYS_INLINE CodeItemDebugInfoAccessor(const DexFile& dex_file,
- const DexFile::CodeItem* code_item);
-
// Initialize with an existing offset.
ALWAYS_INLINE CodeItemDebugInfoAccessor(const DexFile& dex_file,
const DexFile::CodeItem* code_item,
- uint32_t debug_info_offset) {
- Init(dex_file, code_item, debug_info_offset);
+ uint32_t dex_method_index) {
+ Init(dex_file, code_item, dex_method_index);
}
ALWAYS_INLINE void Init(const DexFile& dex_file,
const DexFile::CodeItem* code_item,
- uint32_t debug_info_offset);
+ uint32_t dex_method_index);
ALWAYS_INLINE explicit CodeItemDebugInfoAccessor(ArtMethod* method);
@@ -159,7 +155,7 @@
void* context) const;
protected:
- ALWAYS_INLINE void Init(const CompactDexFile::CodeItem& code_item);
+ ALWAYS_INLINE void Init(const CompactDexFile::CodeItem& code_item, uint32_t dex_method_index);
ALWAYS_INLINE void Init(const StandardDexFile::CodeItem& code_item);
private:
diff --git a/runtime/dex/compact_dex_debug_info.cc b/runtime/dex/compact_dex_debug_info.cc
new file mode 100644
index 0000000..19495ca
--- /dev/null
+++ b/runtime/dex/compact_dex_debug_info.cc
@@ -0,0 +1,117 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include "compact_dex_debug_info.h"
+
+#include "compact_dex_utils.h"
+#include "leb128.h"
+
+namespace art {
+
+constexpr size_t CompactDexDebugInfoOffsetTable::kElementsPerIndex;
+
+CompactDexDebugInfoOffsetTable::Accessor::Accessor(const uint8_t* data_begin,
+ uint32_t debug_info_base,
+ uint32_t debug_info_table_offset)
+ : table_(reinterpret_cast<const uint32_t*>(data_begin + debug_info_table_offset)),
+ debug_info_base_(debug_info_base),
+ data_begin_(data_begin) {}
+
+uint32_t CompactDexDebugInfoOffsetTable::Accessor::GetDebugInfoOffset(uint32_t method_idx) const {
+ const uint32_t offset = table_[method_idx / kElementsPerIndex];
+ const size_t bit_index = method_idx % kElementsPerIndex;
+
+ const uint8_t* block = data_begin_ + offset;
+ uint16_t bit_mask = *block;
+ ++block;
+ bit_mask = (bit_mask << kBitsPerByte) | *block;
+ ++block;
+ if ((bit_mask & (1 << bit_index)) == 0) {
+ // Bit is not set means the offset is 0 for the debug info.
+ return 0u;
+ }
+ // Trim off the bits above the index we want and count how many bits are set. This is how many
+ // lebs we need to decode.
+ size_t count = POPCOUNT(static_cast<uintptr_t>(bit_mask) << (kBitsPerIntPtrT - 1 - bit_index));
+ DCHECK_GT(count, 0u);
+ uint32_t current_offset = debug_info_base_;
+ do {
+ current_offset += DecodeUnsignedLeb128(&block);
+ --count;
+ } while (count > 0);
+ return current_offset;
+}
+
+void CompactDexDebugInfoOffsetTable::Build(const std::vector<uint32_t>& debug_info_offsets,
+ std::vector<uint8_t>* out_data,
+ uint32_t* out_min_offset,
+ uint32_t* out_table_offset) {
+ DCHECK(out_data != nullptr);
+ DCHECK(out_data->empty());
+ // Calculate the base offset and return it.
+ *out_min_offset = std::numeric_limits<uint32_t>::max();
+ for (const uint32_t offset : debug_info_offsets) {
+ if (offset != 0u) {
+ *out_min_offset = std::min(*out_min_offset, offset);
+ }
+ }
+ // Write the leb blocks and store the important offsets (each kElementsPerIndex elements).
+ size_t block_start = 0;
+
+ std::vector<uint32_t> offset_table;
+
+ // Write data first then the table.
+ while (block_start < debug_info_offsets.size()) {
+ // Write the offset of the block for each block.
+ offset_table.push_back(out_data->size());
+
+ // Block size of up to kElementsPerIndex
+ const size_t block_size = std::min(debug_info_offsets.size() - block_start, kElementsPerIndex);
+
+ // Calculate bit mask since need to write that first.
+ uint16_t bit_mask = 0u;
+ for (size_t i = 0; i < block_size; ++i) {
+ if (debug_info_offsets[block_start + i] != 0u) {
+ bit_mask |= 1 << i;
+ }
+ }
+ // Write bit mask.
+ out_data->push_back(static_cast<uint8_t>(bit_mask >> kBitsPerByte));
+ out_data->push_back(static_cast<uint8_t>(bit_mask));
+
+ // Write debug info offsets relative to the current offset.
+ uint32_t current_offset = *out_min_offset;
+ for (size_t i = 0; i < block_size; ++i) {
+ const uint32_t debug_info_offset = debug_info_offsets[block_start + i];
+ if (debug_info_offset != 0u) {
+ uint32_t delta = debug_info_offset - current_offset;
+ EncodeUnsignedLeb128(out_data, delta);
+ current_offset = debug_info_offset;
+ }
+ }
+
+ block_start += block_size;
+ }
+
+ // Write the offset table.
+ AlignmentPadVector(out_data, alignof(uint32_t));
+ *out_table_offset = out_data->size();
+ out_data->insert(out_data->end(),
+ reinterpret_cast<const uint8_t*>(&offset_table[0]),
+ reinterpret_cast<const uint8_t*>(&offset_table[0] + offset_table.size()));
+}
+
+} // namespace art
diff --git a/runtime/dex/compact_dex_debug_info.h b/runtime/dex/compact_dex_debug_info.h
new file mode 100644
index 0000000..1aff758
--- /dev/null
+++ b/runtime/dex/compact_dex_debug_info.h
@@ -0,0 +1,65 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_DEX_COMPACT_DEX_DEBUG_INFO_H_
+#define ART_RUNTIME_DEX_COMPACT_DEX_DEBUG_INFO_H_
+
+#include <cstdint>
+#include <vector>
+
+namespace art {
+
+// Debug offset table for compact dex, aims to minimize size while still providing reasonable
+// speed (10-20ns average time per lookup on host).
+class CompactDexDebugInfoOffsetTable {
+ public:
+ // This value is coupled with the leb chunk bitmask. That logic must also be adjusted when the
+ // integer is modified.
+ static constexpr size_t kElementsPerIndex = 16;
+
+ // Leb block format:
+ // [uint16_t] 16 bit mask for what method ids actually have a debug info offset for the chunk.
+ // [lebs] Up to 16 lebs encoded using leb128, one leb bit. The leb specifies how the offset
+ // changes compared to the previous index.
+
+ class Accessor {
+ public:
+ Accessor(const uint8_t* data_begin,
+ uint32_t debug_info_base,
+ uint32_t debug_info_table_offset);
+
+ // Return the debug info for a method index (or 0 if it doesn't have one).
+ uint32_t GetDebugInfoOffset(uint32_t method_idx) const;
+
+ private:
+ const uint32_t* const table_;
+ const uint32_t debug_info_base_;
+ const uint8_t* const data_begin_;
+ };
+
+ // Returned offsets are all relative to debug_info_offsets.
+ static void Build(const std::vector<uint32_t>& debug_info_offsets,
+ std::vector<uint8_t>* out_data,
+ uint32_t* out_min_offset,
+ uint32_t* out_table_offset);
+
+ // 32 bit aligned for the offset table.
+ static constexpr size_t kAlignment = sizeof(uint32_t);
+};
+
+} // namespace art
+
+#endif // ART_RUNTIME_DEX_COMPACT_DEX_DEBUG_INFO_H_
diff --git a/runtime/dex/compact_dex_debug_info_test.cc b/runtime/dex/compact_dex_debug_info_test.cc
new file mode 100644
index 0000000..02b95e6
--- /dev/null
+++ b/runtime/dex/compact_dex_debug_info_test.cc
@@ -0,0 +1,95 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <vector>
+#include <sys/mman.h>
+
+#include "base/logging.h"
+#include "dex/compact_dex_debug_info.h"
+#include "gtest/gtest.h"
+#include "mem_map.h"
+
+namespace art {
+
+TEST(CompactDexDebugInfoTest, TestBuildAndAccess) {
+ MemMap::Init();
+
+ const size_t kDebugInfoMinOffset = 1234567;
+ std::vector<uint32_t> offsets = {
+ 0, 17, 2, 3, 11, 0, 0, 0, 0, 1, 0, 1552, 100, 122, 44, 1234567, 0, 0,
+ std::numeric_limits<uint32_t>::max() - kDebugInfoMinOffset, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 12,
+ };
+ // Add some large offset since the debug info section will never be that close to the beginning
+ // of the file.
+ for (uint32_t& offset : offsets) {
+ if (offset != 0u) {
+ offset += kDebugInfoMinOffset;
+ }
+ }
+
+ std::vector<uint8_t> data;
+ uint32_t base_offset = 0;
+ uint32_t table_offset = 0;
+ CompactDexDebugInfoOffsetTable::Build(offsets,
+ /*out*/ &data,
+ /*out*/ &base_offset,
+ /*out*/ &table_offset);
+ EXPECT_GE(base_offset, kDebugInfoMinOffset);
+ EXPECT_LT(table_offset, data.size());
+ ASSERT_GT(data.size(), 0u);
+ const size_t before_size = offsets.size() * sizeof(offsets.front());
+ EXPECT_LT(data.size(), before_size);
+
+ // Note that the accessor requires the data to be aligned. Use memmap to accomplish this.
+ std::string error_msg;
+ // Leave some extra room since we don't copy the table at the start (for testing).
+ constexpr size_t kExtraOffset = 4 * 128;
+ std::unique_ptr<MemMap> fake_dex(MemMap::MapAnonymous("fake dex",
+ nullptr,
+ data.size() + kExtraOffset,
+ PROT_READ | PROT_WRITE,
+ /*low_4gb*/ false,
+ /*reuse*/ false,
+ &error_msg));
+ ASSERT_TRUE(fake_dex != nullptr) << error_msg;
+ std::copy(data.begin(), data.end(), fake_dex->Begin() + kExtraOffset);
+
+ CompactDexDebugInfoOffsetTable::Accessor accessor(fake_dex->Begin() + kExtraOffset,
+ base_offset,
+ table_offset);
+ for (size_t i = 0; i < offsets.size(); ++i) {
+ EXPECT_EQ(offsets[i], accessor.GetDebugInfoOffset(i));
+ }
+
+ // Sort to produce a try and produce a smaller table. This happens because the leb diff is smaller
+ // for sorted increasing order.
+ std::sort(offsets.begin(), offsets.end());
+ std::vector<uint8_t> sorted_data;
+ CompactDexDebugInfoOffsetTable::Build(offsets,
+ /*out*/ &sorted_data,
+ /*out*/ &base_offset,
+ /*out*/ &table_offset);
+ EXPECT_LT(sorted_data.size(), data.size());
+ {
+ ScopedLogSeverity sls(LogSeverity::INFO);
+ LOG(INFO) << "raw size " << before_size
+ << " table size " << data.size()
+ << " sorted table size " << sorted_data.size();
+ }
+}
+
+} // namespace art
diff --git a/runtime/dex/compact_dex_file.cc b/runtime/dex/compact_dex_file.cc
index 2d1ee04..ff193ff 100644
--- a/runtime/dex/compact_dex_file.cc
+++ b/runtime/dex/compact_dex_file.cc
@@ -63,4 +63,21 @@
reinterpret_cast<uintptr_t>(&item);
}
+CompactDexFile::CompactDexFile(const uint8_t* base,
+ size_t size,
+ const std::string& location,
+ uint32_t location_checksum,
+ const OatDexFile* oat_dex_file,
+ DexFileContainer* container)
+ : DexFile(base,
+ size,
+ location,
+ location_checksum,
+ oat_dex_file,
+ container,
+ /*is_compact_dex*/ true),
+ debug_info_offsets_(Begin() + GetHeader().debug_info_offsets_pos_,
+ GetHeader().debug_info_base_,
+ GetHeader().debug_info_offsets_table_offset_) {}
+
} // namespace art
diff --git a/runtime/dex/compact_dex_file.h b/runtime/dex/compact_dex_file.h
index 280c6f7..af782a9 100644
--- a/runtime/dex/compact_dex_file.h
+++ b/runtime/dex/compact_dex_file.h
@@ -19,6 +19,7 @@
#include "base/casts.h"
#include "dex_file.h"
+#include "dex/compact_dex_debug_info.h"
namespace art {
@@ -41,13 +42,45 @@
private:
uint32_t feature_flags_ = 0u;
+ // Position in the compact dex file for the debug info table data starts.
+ uint32_t debug_info_offsets_pos_ = 0u;
+
+ // Offset into the debug info table data where the lookup table is.
+ uint32_t debug_info_offsets_table_offset_ = 0u;
+
+ // Base offset of where debug info starts in the dex file.
+ uint32_t debug_info_base_ = 0u;
+
+ friend class CompactDexFile;
friend class CompactDexWriter;
};
+ // Like the standard code item except without a debug info offset.
struct CodeItem : public DexFile::CodeItem {
+ static constexpr size_t kAlignment = sizeof(uint32_t);
+
private:
- // TODO: Insert compact dex specific fields here.
+ CodeItem() = default;
+
+ uint16_t registers_size_; // the number of registers used by this code
+ // (locals + parameters)
+ uint16_t ins_size_; // the number of words of incoming arguments to the method
+ // that this code is for
+ uint16_t outs_size_; // the number of words of outgoing argument space required
+ // by this code for method invocation
+ uint16_t tries_size_; // the number of try_items for this instance. If non-zero,
+ // then these appear as the tries array just after the
+ // insns in this instance.
+
+ uint32_t insns_size_in_code_units_; // size of the insns array, in 2 byte code units
+ uint16_t insns_[1]; // actual array of bytecode.
+
+ ART_FRIEND_TEST(CodeItemAccessorsTest, TestDexInstructionsAccessor);
+ friend class CodeItemDataAccessor;
+ friend class CodeItemDebugInfoAccessor;
+ friend class CodeItemInstructionAccessor;
friend class CompactDexFile;
+ friend class CompactDexWriter;
DISALLOW_COPY_AND_ASSIGN(CodeItem);
};
@@ -73,25 +106,22 @@
uint32_t GetCodeItemSize(const DexFile::CodeItem& item) const OVERRIDE;
+ uint32_t GetDebugInfoOffset(uint32_t dex_method_index) const {
+ return debug_info_offsets_.GetDebugInfoOffset(dex_method_index);
+ }
+
private:
- // Not supported yet.
CompactDexFile(const uint8_t* base,
size_t size,
const std::string& location,
uint32_t location_checksum,
const OatDexFile* oat_dex_file,
- DexFileContainer* container)
- : DexFile(base,
- size,
- location,
- location_checksum,
- oat_dex_file,
- container,
- /*is_compact_dex*/ true) {}
+ DexFileContainer* container);
+
+ CompactDexDebugInfoOffsetTable::Accessor debug_info_offsets_;
friend class DexFile;
friend class DexFileLoader;
-
DISALLOW_COPY_AND_ASSIGN(CompactDexFile);
};
diff --git a/runtime/dex/compact_dex_utils.h b/runtime/dex/compact_dex_utils.h
new file mode 100644
index 0000000..1c7e951
--- /dev/null
+++ b/runtime/dex/compact_dex_utils.h
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2018 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#ifndef ART_RUNTIME_DEX_COMPACT_DEX_UTILS_H_
+#define ART_RUNTIME_DEX_COMPACT_DEX_UTILS_H_
+
+#include <vector>
+
+#include "base/bit_utils.h"
+
+namespace art {
+
+// Add padding to the end of the array until the size is aligned.
+template <typename T, template<typename> class Allocator>
+static inline void AlignmentPadVector(std::vector<T, Allocator<T>>* dest,
+ size_t alignment) {
+ while (!IsAlignedParam(dest->size(), alignment)) {
+ dest->push_back(T());
+ }
+}
+
+} // namespace art
+
+#endif // ART_RUNTIME_DEX_COMPACT_DEX_UTILS_H_
diff --git a/runtime/dex/dex_file.h b/runtime/dex/dex_file.h
index c2a36ce..183d84e 100644
--- a/runtime/dex/dex_file.h
+++ b/runtime/dex/dex_file.h
@@ -301,43 +301,12 @@
DISALLOW_COPY_AND_ASSIGN(CallSiteIdItem);
};
- // Raw code_item.
+ // Base code_item, compact dex and standard dex have different code item layouts.
struct CodeItem {
- // Used when quickening / unquickening.
- void SetDebugInfoOffset(uint32_t new_offset) {
- debug_info_off_ = new_offset;
- }
-
- uint32_t GetDebugInfoOffset() const {
- return debug_info_off_;
- }
-
protected:
- uint16_t registers_size_; // the number of registers used by this code
- // (locals + parameters)
- uint16_t ins_size_; // the number of words of incoming arguments to the method
- // that this code is for
- uint16_t outs_size_; // the number of words of outgoing argument space required
- // by this code for method invocation
- uint16_t tries_size_; // the number of try_items for this instance. If non-zero,
- // then these appear as the tries array just after the
- // insns in this instance.
- // Normally holds file offset to debug info stream. In case the method has been quickened
- // holds an offset in the Vdex file containing both the actual debug_info_off and the
- // quickening info offset.
- // Don't use this field directly, use OatFile::GetDebugInfoOffset in general ART code,
- // or DexFile::GetDebugInfoOffset in code that are not using a Runtime.
- uint32_t debug_info_off_;
-
- uint32_t insns_size_in_code_units_; // size of the insns array, in 2 byte code units
- uint16_t insns_[1]; // actual array of bytecode.
+ CodeItem() = default;
private:
- ART_FRIEND_TEST(CodeItemAccessorsTest, TestDexInstructionsAccessor);
- friend class CodeItemDataAccessor;
- friend class CodeItemDebugInfoAccessor;
- friend class CodeItemInstructionAccessor;
- friend class VdexFile; // TODO: Remove this one when it's cleaned up.
DISALLOW_COPY_AND_ASSIGN(CodeItem);
};
@@ -348,6 +317,8 @@
uint16_t handler_off_;
private:
+ TryItem() = default;
+ friend class DexWriter;
DISALLOW_COPY_AND_ASSIGN(TryItem);
};
@@ -712,15 +683,6 @@
return reinterpret_cast<const CodeItem*>(addr);
}
- uint32_t GetDebugInfoOffset(const CodeItem* code_item) const {
- if (code_item == nullptr) {
- return 0;
- }
- CHECK(oat_dex_file_ == nullptr)
- << "Should only use GetDebugInfoOffset in a non runtime setup";
- return code_item->GetDebugInfoOffset();
- }
-
const char* GetReturnTypeDescriptor(const ProtoId& proto_id) const;
// Returns the number of prototype identifiers in the .dex file.
diff --git a/runtime/dex/dex_file_test.cc b/runtime/dex/dex_file_test.cc
index 1c8b3e4..cb721af 100644
--- a/runtime/dex/dex_file_test.cc
+++ b/runtime/dex/dex_file_test.cc
@@ -738,8 +738,10 @@
std::unique_ptr<const DexFile> raw = OpenDexFileInMemoryBase64(
kRawDexDebugInfoLocalNullType, tmp.GetFilename().c_str(), 0xf25f2b38U, true);
const DexFile::ClassDef& class_def = raw->GetClassDef(0);
- const DexFile::CodeItem* code_item = raw->GetCodeItem(raw->FindCodeItemOffset(class_def, 1));
- CodeItemDebugInfoAccessor accessor(*raw, code_item);
+ constexpr uint32_t kMethodIdx = 1;
+ const DexFile::CodeItem* code_item = raw->GetCodeItem(raw->FindCodeItemOffset(class_def,
+ kMethodIdx));
+ CodeItemDebugInfoAccessor accessor(*raw, code_item, kMethodIdx);
ASSERT_TRUE(accessor.DecodeDebugLocalInfo(true, 1, Callback, nullptr));
}
diff --git a/runtime/dex/standard_dex_file.h b/runtime/dex/standard_dex_file.h
index fb2f720..6437def 100644
--- a/runtime/dex/standard_dex_file.h
+++ b/runtime/dex/standard_dex_file.h
@@ -33,8 +33,30 @@
};
struct CodeItem : public DexFile::CodeItem {
+ static constexpr size_t kAlignment = 4;
+
private:
- // TODO: Insert standard dex specific fields here.
+ CodeItem() = default;
+
+ uint16_t registers_size_; // the number of registers used by this code
+ // (locals + parameters)
+ uint16_t ins_size_; // the number of words of incoming arguments to the method
+ // that this code is for
+ uint16_t outs_size_; // the number of words of outgoing argument space required
+ // by this code for method invocation
+ uint16_t tries_size_; // the number of try_items for this instance. If non-zero,
+ // then these appear as the tries array just after the
+ // insns in this instance.
+ uint32_t debug_info_off_; // Holds file offset to debug info stream.
+
+ uint32_t insns_size_in_code_units_; // size of the insns array, in 2 byte code units
+ uint16_t insns_[1]; // actual array of bytecode.
+
+ ART_FRIEND_TEST(CodeItemAccessorsTest, TestDexInstructionsAccessor);
+ friend class CodeItemDataAccessor;
+ friend class CodeItemDebugInfoAccessor;
+ friend class CodeItemInstructionAccessor;
+ friend class DexWriter;
friend class StandardDexFile;
DISALLOW_COPY_AND_ASSIGN(CodeItem);
};
@@ -80,6 +102,7 @@
friend class DexFileVerifierTest;
ART_FRIEND_TEST(ClassLinkerTest, RegisterDexFileName); // for constructor
+ friend class OptimizingUnitTestHelper; // for constructor
DISALLOW_COPY_AND_ASSIGN(StandardDexFile);
};
diff --git a/runtime/dex_to_dex_decompiler.cc b/runtime/dex_to_dex_decompiler.cc
index e1c07ba..7887191 100644
--- a/runtime/dex_to_dex_decompiler.cc
+++ b/runtime/dex_to_dex_decompiler.cc
@@ -36,8 +36,7 @@
const ArrayRef<const uint8_t>& quickened_info,
bool decompile_return_instruction)
: code_item_accessor_(dex_file, &code_item),
- quicken_info_(quickened_info.data()),
- quicken_info_number_of_indices_(QuickenInfoTable::NumberOfIndices(quickened_info.size())),
+ quicken_info_(quickened_info),
decompile_return_instruction_(decompile_return_instruction) {}
bool Decompile();
@@ -72,7 +71,7 @@
}
uint16_t NextIndex() {
- DCHECK_LT(quicken_index_, quicken_info_number_of_indices_);
+ DCHECK_LT(quicken_index_, quicken_info_.NumIndices());
const uint16_t ret = quicken_info_.GetData(quicken_index_);
quicken_index_++;
return ret;
@@ -80,7 +79,6 @@
const CodeItemInstructionAccessor code_item_accessor_;
const QuickenInfoTable quicken_info_;
- const size_t quicken_info_number_of_indices_;
const bool decompile_return_instruction_;
size_t quicken_index_ = 0u;
@@ -104,7 +102,7 @@
break;
case Instruction::NOP:
- if (quicken_info_number_of_indices_ > 0) {
+ if (quicken_info_.NumIndices() > 0) {
// Only try to decompile NOP if there are more than 0 indices. Not having
// any index happens when we unquicken a code item that only has
// RETURN_VOID_NO_BARRIER as quickened instruction.
@@ -181,14 +179,14 @@
}
}
- if (quicken_index_ != quicken_info_number_of_indices_) {
+ if (quicken_index_ != quicken_info_.NumIndices()) {
if (quicken_index_ == 0) {
LOG(WARNING) << "Failed to use any value in quickening info,"
<< " potentially due to duplicate methods.";
} else {
LOG(FATAL) << "Failed to use all values in quickening info."
<< " Actual: " << std::hex << quicken_index_
- << " Expected: " << quicken_info_number_of_indices_;
+ << " Expected: " << quicken_info_.NumIndices();
return false;
}
}
diff --git a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
index a32c717..f727690 100644
--- a/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
+++ b/runtime/entrypoints/quick/quick_trampoline_entrypoints.cc
@@ -1294,9 +1294,9 @@
// with the interpreter.
code = GetQuickToInterpreterBridge();
} else if (invoke_type == kStatic) {
- // Class is still initializing. The entrypoint contains the trampoline, so we cannot return
- // it. Instead, ask the class linker what is the actual code that needs to be invoked.
- code = linker->GetQuickEntrypointFor(called);
+ // Class is still initializing, go to oat and grab code (trampoline must be left in place
+ // until class is initialized to stop races between threads).
+ code = linker->GetQuickOatCodeFor(called);
} else {
// No trampoline for non-static methods.
code = called->GetEntryPointFromQuickCompiledCode();
diff --git a/runtime/instrumentation.cc b/runtime/instrumentation.cc
index 2a1f219..4524448 100644
--- a/runtime/instrumentation.cc
+++ b/runtime/instrumentation.cc
@@ -167,7 +167,7 @@
if (NeedDebugVersionFor(method)) {
new_quick_code = GetQuickToInterpreterBridge();
} else {
- new_quick_code = class_linker->GetQuickEntrypointFor(method);
+ new_quick_code = class_linker->GetQuickOatCodeFor(method);
}
} else {
new_quick_code = GetQuickResolutionStub();
@@ -188,7 +188,7 @@
} else if (entry_exit_stubs_installed_) {
new_quick_code = GetQuickInstrumentationEntryPoint();
} else {
- new_quick_code = class_linker->GetQuickEntrypointFor(method);
+ new_quick_code = class_linker->GetQuickOatCodeFor(method);
}
} else {
new_quick_code = GetQuickResolutionStub();
@@ -877,7 +877,7 @@
} else {
const void* quick_code = NeedDebugVersionFor(method)
? GetQuickToInterpreterBridge()
- : class_linker->GetQuickEntrypointFor(method);
+ : class_linker->GetQuickOatCodeFor(method);
UpdateEntrypoints(method, quick_code);
}
@@ -971,7 +971,7 @@
return code;
}
}
- return class_linker->GetQuickEntrypointFor(method);
+ return class_linker->GetQuickOatCodeFor(method);
}
void Instrumentation::MethodEnterEventImpl(Thread* thread,
diff --git a/runtime/native/dalvik_system_VMStack.cc b/runtime/native/dalvik_system_VMStack.cc
index 3e8040b..ed0eb97 100644
--- a/runtime/native/dalvik_system_VMStack.cc
+++ b/runtime/native/dalvik_system_VMStack.cc
@@ -160,12 +160,22 @@
return Thread::InternalStackTraceToStackTraceElementArray(soa, trace);
}
+static jobjectArray VMStack_getAnnotatedThreadStackTrace(JNIEnv* env, jclass, jobject javaThread) {
+ ScopedFastNativeObjectAccess soa(env);
+ auto fn = [](Thread* thread, const ScopedFastNativeObjectAccess& soaa)
+ REQUIRES_SHARED(Locks::mutator_lock_) -> jobjectArray {
+ return thread->CreateAnnotatedStackTrace(soaa);
+ };
+ return GetThreadStack(soa, javaThread, fn);
+}
+
static JNINativeMethod gMethods[] = {
FAST_NATIVE_METHOD(VMStack, fillStackTraceElements, "(Ljava/lang/Thread;[Ljava/lang/StackTraceElement;)I"),
FAST_NATIVE_METHOD(VMStack, getCallingClassLoader, "()Ljava/lang/ClassLoader;"),
FAST_NATIVE_METHOD(VMStack, getClosestUserClassLoader, "()Ljava/lang/ClassLoader;"),
FAST_NATIVE_METHOD(VMStack, getStackClass2, "()Ljava/lang/Class;"),
FAST_NATIVE_METHOD(VMStack, getThreadStackTrace, "(Ljava/lang/Thread;)[Ljava/lang/StackTraceElement;"),
+ FAST_NATIVE_METHOD(VMStack, getAnnotatedThreadStackTrace, "(Ljava/lang/Thread;)[Ldalvik/system/AnnotatedStackTraceElement;"),
};
void register_dalvik_system_VMStack(JNIEnv* env) {
diff --git a/runtime/oat_file.cc b/runtime/oat_file.cc
index 446a004..c03dbcc 100644
--- a/runtime/oat_file.cc
+++ b/runtime/oat_file.cc
@@ -1535,21 +1535,6 @@
}
}
-uint32_t OatFile::GetDebugInfoOffset(const DexFile& dex_file, uint32_t debug_info_off) {
- // Note that although the specification says that 0 should be used if there
- // is no debug information, some applications incorrectly use 0xFFFFFFFF.
- // The following check also handles debug_info_off == 0.
- if (debug_info_off < dex_file.Size() || debug_info_off == 0xFFFFFFFF) {
- return debug_info_off;
- }
- const OatFile::OatDexFile* oat_dex_file = dex_file.GetOatDexFile();
- if (oat_dex_file == nullptr || (oat_dex_file->GetOatFile() == nullptr)) {
- return debug_info_off;
- }
- return oat_dex_file->GetOatFile()->GetVdexFile()->GetDebugInfoOffset(
- dex_file, debug_info_off);
-}
-
const OatFile::OatDexFile* OatFile::GetOatDexFile(const char* dex_location,
const uint32_t* dex_location_checksum,
std::string* error_msg) const {
diff --git a/runtime/oat_file.h b/runtime/oat_file.h
index e9f7edc..bf22e0b 100644
--- a/runtime/oat_file.h
+++ b/runtime/oat_file.h
@@ -115,10 +115,6 @@
const char* abs_dex_location,
std::string* error_msg);
- // Return the actual debug info offset for an offset that might be actually pointing to
- // dequickening info. The returned debug info offset is the one originally in the the dex file.
- static uint32_t GetDebugInfoOffset(const DexFile& dex_file, uint32_t debug_info_off);
-
virtual ~OatFile();
bool IsExecutable() const {
diff --git a/runtime/quicken_info.h b/runtime/quicken_info.h
index ce11f3c..52eca61 100644
--- a/runtime/quicken_info.h
+++ b/runtime/quicken_info.h
@@ -17,15 +17,93 @@
#ifndef ART_RUNTIME_QUICKEN_INFO_H_
#define ART_RUNTIME_QUICKEN_INFO_H_
+#include "base/array_ref.h"
#include "dex/dex_instruction.h"
+#include "leb128.h"
namespace art {
-// QuickenInfoTable is a table of 16 bit dex indices. There is one slot fo every instruction that is
-// possibly dequickenable.
+// Table for getting the offset of quicken info. Doesn't have one slot for each index, so a
+// combination of iteration and indexing is required to get the quicken info for a given dex method
+// index.
+class QuickenInfoOffsetTableAccessor {
+ public:
+ using TableType = uint32_t;
+ static constexpr uint32_t kElementsPerIndex = 16;
+
+ class Builder {
+ public:
+ explicit Builder(std::vector<uint8_t>* out_data) : out_data_(out_data) {}
+
+ void AddOffset(uint32_t index) {
+ out_data_->insert(out_data_->end(),
+ reinterpret_cast<const uint8_t*>(&index),
+ reinterpret_cast<const uint8_t*>(&index + 1));
+ }
+
+ private:
+ std::vector<uint8_t>* const out_data_;
+ };
+
+ // The table only covers every kElementsPerIndex indices.
+ static bool IsCoveredIndex(uint32_t index) {
+ return index % kElementsPerIndex == 0;
+ }
+
+ explicit QuickenInfoOffsetTableAccessor(const uint8_t* data, uint32_t max_index)
+ : table_(reinterpret_cast<const uint32_t*>(data)),
+ num_indices_(RoundUp(max_index, kElementsPerIndex) / kElementsPerIndex) {}
+
+ size_t SizeInBytes() const {
+ return NumIndices() * sizeof(table_[0]);
+ }
+
+ uint32_t NumIndices() const {
+ return num_indices_;
+ }
+
+ // Returns the offset for the index at or before the desired index. If the offset is for an index
+ // before the desired one, remainder is how many elements to traverse to reach the desired index.
+ TableType ElementOffset(uint32_t index, uint32_t* remainder) const {
+ *remainder = index % kElementsPerIndex;
+ return table_[index / kElementsPerIndex];
+ }
+
+ const uint8_t* DataEnd() const {
+ return reinterpret_cast<const uint8_t*>(table_ + NumIndices());
+ }
+
+ static uint32_t Alignment() {
+ return alignof(TableType);
+ }
+
+ private:
+ const TableType* table_;
+ uint32_t num_indices_;
+};
+
+// QuickenInfoTable is a table of 16 bit dex indices. There is one slot for every instruction that
+// is possibly dequickenable.
class QuickenInfoTable {
public:
- explicit QuickenInfoTable(const uint8_t* data) : data_(data) {}
+ class Builder {
+ public:
+ Builder(std::vector<uint8_t>* out_data, size_t num_elements) : out_data_(out_data) {
+ EncodeUnsignedLeb128(out_data_, num_elements);
+ }
+
+ void AddIndex(uint16_t index) {
+ out_data_->push_back(static_cast<uint8_t>(index));
+ out_data_->push_back(static_cast<uint8_t>(index >> 8));
+ }
+
+ private:
+ std::vector<uint8_t>* const out_data_;
+ };
+
+ explicit QuickenInfoTable(ArrayRef<const uint8_t> data)
+ : data_(data.data()),
+ num_elements_(!data.empty() ? DecodeUnsignedLeb128(&data_) : 0u) {}
bool IsNull() const {
return data_ == nullptr;
@@ -44,8 +122,18 @@
return bytes / sizeof(uint16_t);
}
+ static size_t SizeInBytes(ArrayRef<const uint8_t> data) {
+ QuickenInfoTable table(data);
+ return table.data_ + table.NumIndices() * 2 - data.data();
+ }
+
+ uint32_t NumIndices() const {
+ return num_elements_;
+ }
+
private:
- const uint8_t* const data_;
+ const uint8_t* data_;
+ const uint32_t num_elements_;
DISALLOW_COPY_AND_ASSIGN(QuickenInfoTable);
};
diff --git a/runtime/thread.cc b/runtime/thread.cc
index 9f4e544..46cb751 100644
--- a/runtime/thread.cc
+++ b/runtime/thread.cc
@@ -2743,6 +2743,199 @@
return result;
}
+jobjectArray Thread::CreateAnnotatedStackTrace(const ScopedObjectAccessAlreadyRunnable& soa) const {
+ // This code allocates. Do not allow it to operate with a pending exception.
+ if (IsExceptionPending()) {
+ return nullptr;
+ }
+
+ // If flip_function is not null, it means we have run a checkpoint
+ // before the thread wakes up to execute the flip function and the
+ // thread roots haven't been forwarded. So the following access to
+ // the roots (locks or methods in the frames) would be bad. Run it
+ // here. TODO: clean up.
+ // Note: copied from DumpJavaStack.
+ {
+ Thread* this_thread = const_cast<Thread*>(this);
+ Closure* flip_func = this_thread->GetFlipFunction();
+ if (flip_func != nullptr) {
+ flip_func->Run(this_thread);
+ }
+ }
+
+ class CollectFramesAndLocksStackVisitor : public MonitorObjectsStackVisitor {
+ public:
+ CollectFramesAndLocksStackVisitor(const ScopedObjectAccessAlreadyRunnable& soaa_in,
+ Thread* self,
+ Context* context)
+ : MonitorObjectsStackVisitor(self, context),
+ wait_jobject_(soaa_in.Env(), nullptr),
+ block_jobject_(soaa_in.Env(), nullptr),
+ soaa_(soaa_in) {}
+
+ protected:
+ VisitMethodResult StartMethod(ArtMethod* m, size_t frame_nr ATTRIBUTE_UNUSED)
+ OVERRIDE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ ObjPtr<mirror::StackTraceElement> obj = CreateStackTraceElement(
+ soaa_, m, GetDexPc(/* abort on error */ false));
+ if (obj == nullptr) {
+ return VisitMethodResult::kEndStackWalk;
+ }
+ stack_trace_elements_.emplace_back(soaa_.Env(), soaa_.AddLocalReference<jobject>(obj.Ptr()));
+ return VisitMethodResult::kContinueMethod;
+ }
+
+ VisitMethodResult EndMethod(ArtMethod* m ATTRIBUTE_UNUSED) OVERRIDE {
+ lock_objects_.push_back({});
+ lock_objects_[lock_objects_.size() - 1].swap(frame_lock_objects_);
+
+ DCHECK_EQ(lock_objects_.size(), stack_trace_elements_.size());
+
+ return VisitMethodResult::kContinueMethod;
+ }
+
+ void VisitWaitingObject(mirror::Object* obj, ThreadState state ATTRIBUTE_UNUSED)
+ OVERRIDE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ wait_jobject_.reset(soaa_.AddLocalReference<jobject>(obj));
+ }
+ void VisitSleepingObject(mirror::Object* obj)
+ OVERRIDE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ wait_jobject_.reset(soaa_.AddLocalReference<jobject>(obj));
+ }
+ void VisitBlockedOnObject(mirror::Object* obj,
+ ThreadState state ATTRIBUTE_UNUSED,
+ uint32_t owner_tid ATTRIBUTE_UNUSED)
+ OVERRIDE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ block_jobject_.reset(soaa_.AddLocalReference<jobject>(obj));
+ }
+ void VisitLockedObject(mirror::Object* obj)
+ OVERRIDE
+ REQUIRES_SHARED(Locks::mutator_lock_) {
+ frame_lock_objects_.emplace_back(soaa_.Env(), soaa_.AddLocalReference<jobject>(obj));
+ }
+
+ public:
+ std::vector<ScopedLocalRef<jobject>> stack_trace_elements_;
+ ScopedLocalRef<jobject> wait_jobject_;
+ ScopedLocalRef<jobject> block_jobject_;
+ std::vector<std::vector<ScopedLocalRef<jobject>>> lock_objects_;
+
+ private:
+ const ScopedObjectAccessAlreadyRunnable& soaa_;
+
+ std::vector<ScopedLocalRef<jobject>> frame_lock_objects_;
+ };
+
+ std::unique_ptr<Context> context(Context::Create());
+ CollectFramesAndLocksStackVisitor dumper(soa, const_cast<Thread*>(this), context.get());
+ dumper.WalkStack();
+
+ // There should not be a pending exception. Otherwise, return with it pending.
+ if (IsExceptionPending()) {
+ return nullptr;
+ }
+
+ // Now go and create Java arrays.
+
+ ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
+
+ StackHandleScope<6> hs(soa.Self());
+ mirror::Class* aste_array_class = class_linker->FindClass(
+ soa.Self(),
+ "[Ldalvik/system/AnnotatedStackTraceElement;",
+ ScopedNullHandle<mirror::ClassLoader>());
+ if (aste_array_class == nullptr) {
+ return nullptr;
+ }
+ Handle<mirror::Class> h_aste_array_class(hs.NewHandle<mirror::Class>(aste_array_class));
+
+ mirror::Class* o_array_class = class_linker->FindClass(soa.Self(),
+ "[Ljava/lang/Object;",
+ ScopedNullHandle<mirror::ClassLoader>());
+ if (o_array_class == nullptr) {
+ // This should not fail in a healthy runtime.
+ soa.Self()->AssertPendingException();
+ return nullptr;
+ }
+ Handle<mirror::Class> h_o_array_class(hs.NewHandle<mirror::Class>(o_array_class));
+
+ Handle<mirror::Class> h_aste_class(hs.NewHandle<mirror::Class>(
+ h_aste_array_class->GetComponentType()));
+ ArtField* stack_trace_element_field = h_aste_class->FindField(
+ soa.Self(), h_aste_class.Get(), "stackTraceElement", "Ljava/lang/StackTraceElement;");
+ DCHECK(stack_trace_element_field != nullptr);
+ ArtField* held_locks_field = h_aste_class->FindField(
+ soa.Self(), h_aste_class.Get(), "heldLocks", "[Ljava/lang/Object;");
+ DCHECK(held_locks_field != nullptr);
+ ArtField* blocked_on_field = h_aste_class->FindField(
+ soa.Self(), h_aste_class.Get(), "blockedOn", "Ljava/lang/Object;");
+ DCHECK(blocked_on_field != nullptr);
+
+ size_t length = dumper.stack_trace_elements_.size();
+ ObjPtr<mirror::ObjectArray<mirror::Object>> array =
+ mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(), aste_array_class, length);
+ if (array == nullptr) {
+ soa.Self()->AssertPendingOOMException();
+ return nullptr;
+ }
+
+ ScopedLocalRef<jobjectArray> result(soa.Env(), soa.Env()->AddLocalReference<jobjectArray>(array));
+
+ MutableHandle<mirror::Object> handle(hs.NewHandle<mirror::Object>(nullptr));
+ MutableHandle<mirror::ObjectArray<mirror::Object>> handle2(
+ hs.NewHandle<mirror::ObjectArray<mirror::Object>>(nullptr));
+ for (size_t i = 0; i != length; ++i) {
+ handle.Assign(h_aste_class->AllocObject(soa.Self()));
+ if (handle == nullptr) {
+ soa.Self()->AssertPendingOOMException();
+ return nullptr;
+ }
+
+ // Set stack trace element.
+ stack_trace_element_field->SetObject<false>(
+ handle.Get(), soa.Decode<mirror::Object>(dumper.stack_trace_elements_[i].get()));
+
+ // Create locked-on array.
+ if (!dumper.lock_objects_[i].empty()) {
+ handle2.Assign(mirror::ObjectArray<mirror::Object>::Alloc(soa.Self(),
+ h_o_array_class.Get(),
+ dumper.lock_objects_[i].size()));
+ if (handle2 == nullptr) {
+ soa.Self()->AssertPendingOOMException();
+ return nullptr;
+ }
+ int32_t j = 0;
+ for (auto& scoped_local : dumper.lock_objects_[i]) {
+ if (scoped_local == nullptr) {
+ continue;
+ }
+ handle2->Set(j, soa.Decode<mirror::Object>(scoped_local.get()));
+ DCHECK(!soa.Self()->IsExceptionPending());
+ j++;
+ }
+ held_locks_field->SetObject<false>(handle.Get(), handle2.Get());
+ }
+
+ // Set blocked-on object.
+ if (i == 0) {
+ if (dumper.block_jobject_ != nullptr) {
+ blocked_on_field->SetObject<false>(
+ handle.Get(), soa.Decode<mirror::Object>(dumper.block_jobject_.get()));
+ }
+ }
+
+ ScopedLocalRef<jobject> elem(soa.Env(), soa.AddLocalReference<jobject>(handle.Get()));
+ soa.Env()->SetObjectArrayElement(result.get(), i, elem.get());
+ DCHECK(!soa.Self()->IsExceptionPending());
+ }
+
+ return result.release();
+}
+
void Thread::ThrowNewExceptionF(const char* exception_class_descriptor, const char* fmt, ...) {
va_list args;
va_start(args, fmt);
diff --git a/runtime/thread.h b/runtime/thread.h
index 1e89887..426d27d 100644
--- a/runtime/thread.h
+++ b/runtime/thread.h
@@ -599,6 +599,9 @@
jobjectArray output_array = nullptr, int* stack_depth = nullptr)
REQUIRES_SHARED(Locks::mutator_lock_);
+ jobjectArray CreateAnnotatedStackTrace(const ScopedObjectAccessAlreadyRunnable& soa) const
+ REQUIRES_SHARED(Locks::mutator_lock_);
+
bool HasDebuggerShadowFrames() const {
return tlsPtr_.frame_id_to_shadow_frame != nullptr;
}
diff --git a/runtime/vdex_file.cc b/runtime/vdex_file.cc
index c16cfb6..118cffe 100644
--- a/runtime/vdex_file.cc
+++ b/runtime/vdex_file.cc
@@ -29,6 +29,7 @@
#include "dex/dex_file.h"
#include "dex/dex_file_loader.h"
#include "dex_to_dex_decompiler.h"
+#include "quicken_info.h"
namespace art {
@@ -144,9 +145,8 @@
if (!vdex->OpenAllDexFiles(&unique_ptr_dex_files, error_msg)) {
return nullptr;
}
- Unquicken(MakeNonOwningPointerVector(unique_ptr_dex_files),
- vdex->GetQuickeningInfo(),
- /* decompile_return_instruction */ false);
+ vdex->Unquicken(MakeNonOwningPointerVector(unique_ptr_dex_files),
+ /* decompile_return_instruction */ false);
// Update the quickening info size to pretend there isn't any.
reinterpret_cast<Header*>(vdex->mmap_->Begin())->quickening_info_size_ = 0;
}
@@ -159,14 +159,15 @@
DCHECK(cursor == nullptr || (cursor > Begin() && cursor <= End()));
if (cursor == nullptr) {
// Beginning of the iteration, return the first dex file if there is one.
- return HasDexSection() ? DexBegin() : nullptr;
+ return HasDexSection() ? DexBegin() + sizeof(QuickeningTableOffsetType) : nullptr;
} else {
// Fetch the next dex file. Return null if there is none.
const uint8_t* data = cursor + reinterpret_cast<const DexFile::Header*>(cursor)->file_size_;
// Dex files are required to be 4 byte aligned. the OatWriter makes sure they are, see
// OatWriter::SeekToDexFiles.
data = AlignUp(data, 4);
- return (data == DexEnd()) ? nullptr : data;
+
+ return (data == DexEnd()) ? nullptr : data + sizeof(QuickeningTableOffsetType);
}
}
@@ -197,64 +198,68 @@
return true;
}
-void VdexFile::Unquicken(const std::vector<const DexFile*>& dex_files,
- ArrayRef<const uint8_t> quickening_info,
- bool decompile_return_instruction) {
- if (quickening_info.size() == 0 && !decompile_return_instruction) {
- // Bail early if there is no quickening info and no need to decompile
- // RETURN_VOID_NO_BARRIER instructions to RETURN_VOID instructions.
- return;
+void VdexFile::Unquicken(const std::vector<const DexFile*>& target_dex_files,
+ bool decompile_return_instruction) const {
+ const uint8_t* source_dex = GetNextDexFileData(nullptr);
+ for (const DexFile* target_dex : target_dex_files) {
+ UnquickenDexFile(*target_dex, source_dex, decompile_return_instruction);
+ source_dex = GetNextDexFileData(source_dex);
}
-
- for (uint32_t i = 0; i < dex_files.size(); ++i) {
- UnquickenDexFile(*dex_files[i], quickening_info, decompile_return_instruction);
- }
+ DCHECK(source_dex == nullptr);
}
-typedef __attribute__((__aligned__(1))) uint32_t unaligned_uint32_t;
-
-static uint32_t GetDebugInfoOffsetInternal(const DexFile& dex_file,
- uint32_t offset_in_code_item,
- const ArrayRef<const uint8_t>& quickening_info) {
- if (quickening_info.size() == 0) {
- // No quickening info: offset is the right one, return it.
- return offset_in_code_item;
- }
- uint32_t quickening_offset = offset_in_code_item - dex_file.Size();
- return *reinterpret_cast<const unaligned_uint32_t*>(quickening_info.data() + quickening_offset);
+uint32_t VdexFile::GetQuickeningInfoTableOffset(const uint8_t* source_dex_begin) const {
+ DCHECK_GE(source_dex_begin, DexBegin());
+ DCHECK_LT(source_dex_begin, DexEnd());
+ return reinterpret_cast<const QuickeningTableOffsetType*>(source_dex_begin)[-1];
}
-static uint32_t GetQuickeningInfoOffsetFrom(const DexFile& dex_file,
- uint32_t offset_in_code_item,
- const ArrayRef<const uint8_t>& quickening_info) {
- if (offset_in_code_item < dex_file.Size()) {
- return VdexFile::kNoQuickeningInfoOffset;
- }
- if (quickening_info.size() == 0) {
- // No quickening info.
- return VdexFile::kNoQuickeningInfoOffset;
- }
- uint32_t quickening_offset = offset_in_code_item - dex_file.Size();
+QuickenInfoOffsetTableAccessor VdexFile::GetQuickenInfoOffsetTable(
+ const uint8_t* source_dex_begin,
+ uint32_t num_method_ids,
+ const ArrayRef<const uint8_t>& quickening_info) const {
+ // The offset a is in preheader right before the dex file.
+ const uint32_t offset = GetQuickeningInfoTableOffset(source_dex_begin);
+ const uint8_t* data_ptr = quickening_info.data() + offset;
+ return QuickenInfoOffsetTableAccessor(data_ptr, num_method_ids);
+}
- // Add 2 * sizeof(uint32_t) for the debug info offset and the data offset.
- CHECK_LE(quickening_offset + 2 * sizeof(uint32_t), quickening_info.size());
- return *reinterpret_cast<const unaligned_uint32_t*>(
- quickening_info.data() + quickening_offset + sizeof(uint32_t));
+QuickenInfoOffsetTableAccessor VdexFile::GetQuickenInfoOffsetTable(
+ const DexFile& dex_file,
+ const ArrayRef<const uint8_t>& quickening_info) const {
+ return GetQuickenInfoOffsetTable(dex_file.Begin(), dex_file.NumMethodIds(), quickening_info);
}
static ArrayRef<const uint8_t> GetQuickeningInfoAt(const ArrayRef<const uint8_t>& quickening_info,
uint32_t quickening_offset) {
- return (quickening_offset == VdexFile::kNoQuickeningInfoOffset)
- ? ArrayRef<const uint8_t>(nullptr, 0)
- : quickening_info.SubArray(
- quickening_offset + sizeof(uint32_t),
- *reinterpret_cast<const unaligned_uint32_t*>(
- quickening_info.data() + quickening_offset));
+ ArrayRef<const uint8_t> remaining = quickening_info.SubArray(quickening_offset);
+ return remaining.SubArray(0u, QuickenInfoTable::SizeInBytes(remaining));
+}
+
+static uint32_t GetQuickeningInfoOffset(const QuickenInfoOffsetTableAccessor& table,
+ uint32_t dex_method_index,
+ const ArrayRef<const uint8_t>& quickening_info) {
+ DCHECK(!quickening_info.empty());
+ uint32_t remainder;
+ uint32_t offset = table.ElementOffset(dex_method_index, &remainder);
+ // Decode the sizes for the remainder offsets (not covered by the table).
+ while (remainder != 0) {
+ offset += GetQuickeningInfoAt(quickening_info, offset).size();
+ --remainder;
+ }
+ return offset;
}
void VdexFile::UnquickenDexFile(const DexFile& target_dex_file,
- ArrayRef<const uint8_t> quickening_info,
- bool decompile_return_instruction) {
+ const DexFile& source_dex_file,
+ bool decompile_return_instruction) const {
+ UnquickenDexFile(target_dex_file, source_dex_file.Begin(), decompile_return_instruction);
+}
+
+void VdexFile::UnquickenDexFile(const DexFile& target_dex_file,
+ const uint8_t* source_dex_begin,
+ bool decompile_return_instruction) const {
+ ArrayRef<const uint8_t> quickening_info = GetQuickeningInfo();
if (quickening_info.size() == 0 && !decompile_return_instruction) {
// Bail early if there is no quickening info and no need to decompile
// RETURN_VOID_NO_BARRIER instructions to RETURN_VOID instructions.
@@ -269,19 +274,20 @@
class_it.Next()) {
if (class_it.IsAtMethod() && class_it.GetMethodCodeItem() != nullptr) {
const DexFile::CodeItem* code_item = class_it.GetMethodCodeItem();
- uint32_t quickening_offset = GetQuickeningInfoOffsetFrom(
- target_dex_file, code_item->debug_info_off_, quickening_info);
- if (quickening_offset != VdexFile::kNoQuickeningInfoOffset) {
- // If we have quickening data, put back the original debug_info_off.
- const_cast<DexFile::CodeItem*>(code_item)->SetDebugInfoOffset(
- GetDebugInfoOffsetInternal(target_dex_file,
- code_item->debug_info_off_,
- quickening_info));
+ ArrayRef<const uint8_t> quicken_data;
+ if (!quickening_info.empty()) {
+ const uint32_t quickening_offset = GetQuickeningInfoOffset(
+ GetQuickenInfoOffsetTable(source_dex_begin,
+ target_dex_file.NumMethodIds(),
+ quickening_info),
+ class_it.GetMemberIndex(),
+ quickening_info);
+ quicken_data = GetQuickeningInfoAt(quickening_info, quickening_offset);
}
optimizer::ArtDecompileDEX(
target_dex_file,
*code_item,
- GetQuickeningInfoAt(quickening_info, quickening_offset),
+ quicken_data,
decompile_return_instruction);
}
}
@@ -289,25 +295,17 @@
}
}
-uint32_t VdexFile::GetDebugInfoOffset(const DexFile& dex_file, uint32_t offset_in_code_item) const {
- return GetDebugInfoOffsetInternal(dex_file, offset_in_code_item, GetQuickeningInfo());
-}
-
-const uint8_t* VdexFile::GetQuickenedInfoOf(const DexFile& dex_file,
- uint32_t code_item_offset) const {
+ArrayRef<const uint8_t> VdexFile::GetQuickenedInfoOf(const DexFile& dex_file,
+ uint32_t dex_method_idx) const {
ArrayRef<const uint8_t> quickening_info = GetQuickeningInfo();
- uint32_t quickening_offset = GetQuickeningInfoOffsetFrom(
- dex_file, dex_file.GetCodeItem(code_item_offset)->debug_info_off_, quickening_info);
-
- return GetQuickeningInfoAt(quickening_info, quickening_offset).data();
-}
-
-bool VdexFile::CanEncodeQuickenedData(const DexFile& dex_file) {
- // We are going to use the debug_info_off_ to signal there is
- // quickened data, by putting a value greater than dex_file.Size(). So
- // make sure we have some room in the offset by checking that we have at least
- // half of the range of a uint32_t.
- return dex_file.Size() <= (std::numeric_limits<uint32_t>::max() >> 1);
+ if (quickening_info.empty()) {
+ return ArrayRef<const uint8_t>();
+ }
+ const uint32_t quickening_offset = GetQuickeningInfoOffset(
+ GetQuickenInfoOffsetTable(dex_file, quickening_info),
+ dex_method_idx,
+ quickening_info);
+ return GetQuickeningInfoAt(quickening_info, quickening_offset);
}
} // namespace art
diff --git a/runtime/vdex_file.h b/runtime/vdex_file.h
index f78335d..4687a39 100644
--- a/runtime/vdex_file.h
+++ b/runtime/vdex_file.h
@@ -24,6 +24,7 @@
#include "base/macros.h"
#include "mem_map.h"
#include "os.h"
+#include "quicken_info.h"
namespace art {
@@ -35,18 +36,17 @@
// File format:
// VdexFile::Header fixed-length header
//
-// DEX[0] array of the input DEX files
-// DEX[1] the bytecode may have been quickened
+// quicken_table_off[0] offset into QuickeningInfo section for offset table for DEX[0].
+// DEX[0] array of the input DEX files, the bytecode may have been quickened.
+// quicken_table_off[1]
+// DEX[1]
// ...
// DEX[D]
// VerifierDeps
// uint8[D][] verification dependencies
// QuickeningInfo
// uint8[D][] quickening data
-// unaligned_uint32_t[D][2][] table of offsets pair:
-// uint32_t[0] contains original CodeItem::debug_info_off_
-// uint32_t[1] contains quickening data offset from the start
-// of QuickeningInfo
+// uint32[D][] quickening data offset tables
class VdexFile {
public:
@@ -84,8 +84,8 @@
private:
static constexpr uint8_t kVdexMagic[] = { 'v', 'd', 'e', 'x' };
- // Last update: Lookup-friendly encoding for quickening info.
- static constexpr uint8_t kVdexVersion[] = { '0', '1', '1', '\0' };
+ // Last update: Side table for debug info offsets in compact dex.
+ static constexpr uint8_t kVdexVersion[] = { '0', '1', '4', '\0' };
uint8_t magic_[4];
uint8_t version_[4];
@@ -98,6 +98,7 @@
};
typedef uint32_t VdexChecksum;
+ using QuickeningTableOffsetType = uint32_t;
explicit VdexFile(MemMap* mmap) : mmap_(mmap) {}
@@ -204,29 +205,42 @@
// `decompile_return_instruction` controls if RETURN_VOID_BARRIER instructions are
// decompiled to RETURN_VOID instructions using the slower ClassDataItemIterator
// instead of the faster QuickeningInfoIterator.
- static void Unquicken(const std::vector<const DexFile*>& dex_files,
- ArrayRef<const uint8_t> quickening_info,
- bool decompile_return_instruction);
+ // Always unquickens using the vdex dex files as the source for quicken tables.
+ void Unquicken(const std::vector<const DexFile*>& target_dex_files,
+ bool decompile_return_instruction) const;
// Fully unquicken `target_dex_file` based on `quickening_info`.
- static void UnquickenDexFile(const DexFile& target_dex_file,
- ArrayRef<const uint8_t> quickening_info,
- bool decompile_return_instruction);
+ void UnquickenDexFile(const DexFile& target_dex_file,
+ const DexFile& source_dex_file,
+ bool decompile_return_instruction) const;
- // Return the quickening info of the given code item.
- const uint8_t* GetQuickenedInfoOf(const DexFile& dex_file, uint32_t code_item_offset) const;
-
- uint32_t GetDebugInfoOffset(const DexFile& dex_file, uint32_t offset_in_code_item) const;
-
- static bool CanEncodeQuickenedData(const DexFile& dex_file);
-
- static constexpr uint32_t kNoQuickeningInfoOffset = -1;
+ // Return the quickening info of a given method index (or null if it's empty).
+ ArrayRef<const uint8_t> GetQuickenedInfoOf(const DexFile& dex_file,
+ uint32_t dex_method_idx) const;
private:
+ uint32_t GetQuickeningInfoTableOffset(const uint8_t* source_dex_begin) const;
+
+ // Source dex must be the in the vdex file.
+ void UnquickenDexFile(const DexFile& target_dex_file,
+ const uint8_t* source_dex_begin,
+ bool decompile_return_instruction) const;
+
+ QuickenInfoOffsetTableAccessor GetQuickenInfoOffsetTable(
+ const DexFile& dex_file,
+ const ArrayRef<const uint8_t>& quickening_info) const;
+
+ QuickenInfoOffsetTableAccessor GetQuickenInfoOffsetTable(
+ const uint8_t* source_dex_begin,
+ uint32_t num_method_ids,
+ const ArrayRef<const uint8_t>& quickening_info) const;
+
bool HasDexSection() const {
return GetHeader().GetDexSize() != 0;
}
+ bool ContainsDexFile(const DexFile& dex_file) const;
+
const uint8_t* DexBegin() const {
return Begin() + sizeof(Header) + GetHeader().GetSizeOfChecksumsSection();
}
@@ -235,8 +249,6 @@
return DexBegin() + GetHeader().GetDexSize();
}
- uint32_t GetDexFileIndex(const DexFile& dex_file) const;
-
std::unique_ptr<MemMap> mmap_;
DISALLOW_COPY_AND_ASSIGN(VdexFile);
diff --git a/test/168-vmstack-annotated/expected.txt b/test/168-vmstack-annotated/expected.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/test/168-vmstack-annotated/expected.txt
diff --git a/test/168-vmstack-annotated/info.txt b/test/168-vmstack-annotated/info.txt
new file mode 100644
index 0000000..d849bc3
--- /dev/null
+++ b/test/168-vmstack-annotated/info.txt
@@ -0,0 +1 @@
+Regression test for b/68703210
diff --git a/test/168-vmstack-annotated/run b/test/168-vmstack-annotated/run
new file mode 100644
index 0000000..9365411
--- /dev/null
+++ b/test/168-vmstack-annotated/run
@@ -0,0 +1,18 @@
+#!/bin/bash
+#
+# Copyright (C) 2017 The Android Open Source Project
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+
+# Use a smaller heap so it's easier to potentially fill up.
+exec ${RUN} $@ --runtime-option -Xmx2m
diff --git a/test/168-vmstack-annotated/src/Main.java b/test/168-vmstack-annotated/src/Main.java
new file mode 100644
index 0000000..8234f94
--- /dev/null
+++ b/test/168-vmstack-annotated/src/Main.java
@@ -0,0 +1,225 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.lang.Thread.State;
+import java.lang.reflect.Method;
+import java.util.Arrays;
+import java.util.LinkedList;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.BrokenBarrierException;
+import java.util.concurrent.CyclicBarrier;
+
+public class Main {
+
+ static class Runner implements Runnable {
+ List<Object> locks;
+ List<CyclicBarrier> barriers;
+
+ public Runner(List<Object> locks, List<CyclicBarrier> barriers) {
+ this.locks = locks;
+ this.barriers = barriers;
+ }
+
+ @Override
+ public void run() {
+ step(locks, barriers);
+ }
+
+ private void step(List<Object> l, List<CyclicBarrier> b) {
+ if (l.isEmpty()) {
+ // Nothing to do, sleep indefinitely.
+ try {
+ Thread.sleep(100000000);
+ } catch (InterruptedException e) {
+ throw new RuntimeException(e);
+ }
+ } else {
+ Object lockObject = l.remove(0);
+ CyclicBarrier barrierObject = b.remove(0);
+
+ if (lockObject == null) {
+ // No lock object: only take barrier, recurse.
+ try {
+ barrierObject.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException(e);
+ }
+ step(l, b);
+ } else if (barrierObject != null) {
+ // Have barrier: sync, wait and recurse.
+ synchronized(lockObject) {
+ try {
+ barrierObject.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException(e);
+ }
+ step(l, b);
+ }
+ } else {
+ // Sync, and get next step (which is assumed to have object and barrier).
+ synchronized (lockObject) {
+ Object lockObject2 = l.remove(0);
+ CyclicBarrier barrierObject2 = b.remove(0);
+ synchronized(lockObject2) {
+ try {
+ barrierObject2.await();
+ } catch (InterruptedException | BrokenBarrierException e) {
+ throw new RuntimeException(e);
+ }
+ step(l, b);
+ }
+ }
+ }
+ }
+ }
+ }
+
+ public static void main(String[] args) throws Exception {
+ try {
+ testCluster1();
+ } catch (Exception e) {
+ Map<Thread,StackTraceElement[]> stacks = Thread.getAllStackTraces();
+ for (Map.Entry<Thread,StackTraceElement[]> entry : stacks.entrySet()) {
+ System.out.println(entry.getKey());
+ System.out.println(Arrays.toString(entry.getValue()));
+ }
+ throw e;
+ }
+ }
+
+ private static void testCluster1() throws Exception {
+ // Test setup (at deadlock):
+ //
+ // Thread 1:
+ // #0 step: synchornized(o3) { synchronized(o2) }
+ // #1 step: synchronized(o1)
+ //
+ // Thread 2:
+ // #0 step: synchronized(o1)
+ // #1 step: synchronized(o4) { synchronized(o2) }
+ //
+ LinkedList<Object> l1 = new LinkedList<>();
+ LinkedList<CyclicBarrier> b1 = new LinkedList<>();
+ LinkedList<Object> l2 = new LinkedList<>();
+ LinkedList<CyclicBarrier> b2 = new LinkedList<>();
+
+ Object o1 = new Object();
+ Object o2 = new Object();
+ Object o3 = new Object();
+ Object o4 = new Object();
+
+ l1.add(o1);
+ l1.add(o3);
+ l1.add(o2);
+ l2.add(o4);
+ l2.add(o2);
+ l2.add(o1);
+
+ CyclicBarrier c1 = new CyclicBarrier(3);
+ CyclicBarrier c2 = new CyclicBarrier(2);
+ b1.add(c1);
+ b1.add(null);
+ b1.add(c2);
+ b2.add(null);
+ b2.add(c1);
+ b2.add(c2);
+
+ Thread t1 = new Thread(new Runner(l1, b1));
+ t1.setDaemon(true);
+ t1.start();
+ Thread t2 = new Thread(new Runner(l2, b2));
+ t2.setDaemon(true);
+ t2.start();
+
+ c1.await();
+
+ waitNotRunnable(t1);
+ waitNotRunnable(t2);
+ Thread.sleep(250); // Unfortunately this seems necessary. :-(
+
+ // Thread 1.
+ {
+ Object[] stack1 = getAnnotatedStack(t1);
+ assertBlockedOn(stack1[0], o2); // Blocked on o2.
+ assertLocks(stack1[0], o3); // Locked o3.
+ assertStackTraceElementStep(stack1[0]);
+
+ assertBlockedOn(stack1[1], null); // Frame can't be blocked.
+ assertLocks(stack1[1], o1); // Locked o1.
+ assertStackTraceElementStep(stack1[1]);
+ }
+
+ // Thread 2.
+ {
+ Object[] stack2 = getAnnotatedStack(t2);
+ assertBlockedOn(stack2[0], o1); // Blocked on o1.
+ assertLocks(stack2[0]); // Nothing locked.
+ assertStackTraceElementStep(stack2[0]);
+
+ assertBlockedOn(stack2[1], null); // Frame can't be blocked.
+ assertLocks(stack2[1], o4, o2); // Locked o4, o2.
+ assertStackTraceElementStep(stack2[1]);
+ }
+ }
+
+ private static void waitNotRunnable(Thread t) throws InterruptedException {
+ while (t.getState() == State.RUNNABLE) {
+ Thread.sleep(100);
+ }
+ }
+
+ private static Object[] getAnnotatedStack(Thread t) throws Exception {
+ Class<?> vmStack = Class.forName("dalvik.system.VMStack");
+ Method m = vmStack.getDeclaredMethod("getAnnotatedThreadStackTrace", Thread.class);
+ return (Object[]) m.invoke(null, t);
+ }
+
+ private static void assertEquals(Object o1, Object o2) {
+ if (o1 != o2) {
+ throw new RuntimeException("Expected " + o1 + " == " + o2);
+ }
+ }
+ private static void assertLocks(Object fromTrace, Object... locks) throws Exception {
+ Object fieldValue = fromTrace.getClass().getDeclaredMethod("getHeldLocks").
+ invoke(fromTrace);
+ assertEquals((Object[]) fieldValue,
+ (locks == null) ? null : (locks.length == 0 ? null : locks));
+ }
+ private static void assertBlockedOn(Object fromTrace, Object block) throws Exception {
+ Object fieldValue = fromTrace.getClass().getDeclaredMethod("getBlockedOn").
+ invoke(fromTrace);
+ assertEquals(fieldValue, block);
+ }
+ private static void assertEquals(Object[] o1, Object[] o2) {
+ if (!Arrays.equals(o1, o2)) {
+ throw new RuntimeException(
+ "Expected " + Arrays.toString(o1) + " == " + Arrays.toString(o2));
+ }
+ }
+ private static void assertStackTraceElementStep(Object o) throws Exception {
+ Object fieldValue = o.getClass().getDeclaredMethod("getStackTraceElement").invoke(o);
+ if (fieldValue instanceof StackTraceElement) {
+ StackTraceElement elem = (StackTraceElement) fieldValue;
+ if (!elem.getMethodName().equals("step")) {
+ throw new RuntimeException("Expected step method");
+ }
+ return;
+ }
+ throw new RuntimeException("Expected StackTraceElement " + fieldValue + " / " + o);
+ }
+}
+
diff --git a/test/626-checker-arm64-scratch-register/smali/Smali.smali b/test/626-checker-arm64-scratch-register/smali/Smali.smali
deleted file mode 100644
index e6943cf..0000000
--- a/test/626-checker-arm64-scratch-register/smali/Smali.smali
+++ /dev/null
@@ -1,2119 +0,0 @@
-# Copyright (C) 2017 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-
-.class public LSmali;
-.super Ljava/lang/Object;
-.field b00:Z
-.field b01:Z
-.field b02:Z
-.field b03:Z
-.field b04:Z
-.field b05:Z
-.field b06:Z
-.field b07:Z
-.field b08:Z
-.field b09:Z
-.field b10:Z
-.field b11:Z
-.field b12:Z
-.field b13:Z
-.field b14:Z
-.field b15:Z
-.field b16:Z
-.field b17:Z
-.field b18:Z
-.field b19:Z
-.field b20:Z
-.field b21:Z
-.field b22:Z
-.field b23:Z
-.field b24:Z
-.field b25:Z
-.field b26:Z
-.field b27:Z
-.field b28:Z
-.field b29:Z
-.field b30:Z
-.field b31:Z
-.field b32:Z
-.field b33:Z
-.field b34:Z
-.field b35:Z
-.field b36:Z
-
-.field conditionA:Z
-.field conditionB:Z
-.field conditionC:Z
-
-.method public constructor <init>()V
- .registers 1
- invoke-direct {p0}, Ljava/lang/Object;-><init>()V
- return-void
-.end method
-
-## CHECK-START-ARM64: void Smali.test() register (after)
-## CHECK: begin_block
-## CHECK: name "B0"
-## CHECK: <<This:l\d+>> ParameterValue
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: successors "<<ThenBlock:B\d+>>" "<<ElseBlock:B\d+>>"
-## CHECK: <<CondB:z\d+>> InstanceFieldGet [<<This>>] field_name:Smali.conditionB
-## CHECK: If [<<CondB>>]
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: name "<<ElseBlock>>"
-## CHECK: ParallelMove moves:[40(sp)->d0,24(sp)->32(sp),28(sp)->36(sp),d0->d3,d3->d4,d2->d5,d4->d6,d5->d7,d6->d18,d7->d19,d18->d20,d19->d21,d20->d22,d21->d23,d22->d10,d23->d11,16(sp)->24(sp),20(sp)->28(sp),d10->d14,d11->d12,d12->d13,d13->d1,d14->d2,32(sp)->16(sp),36(sp)->20(sp)]
-## CHECK: end_block
-
-## CHECK-START-ARM64: void Smali.test() disassembly (after)
-## CHECK: begin_block
-## CHECK: name "B0"
-## CHECK: <<This:l\d+>> ParameterValue
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: successors "<<ThenBlock:B\d+>>" "<<ElseBlock:B\d+>>"
-## CHECK: <<CondB:z\d+>> InstanceFieldGet [<<This>>] field_name:Smali.conditionB
-## CHECK: If [<<CondB>>]
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: name "<<ElseBlock>>"
-## CHECK: ParallelMove moves:[invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid]
-## CHECK: fmov d31, d2
-## CHECK: ldr s2, [sp, #36]
-## CHECK: ldr w16, [sp, #16]
-## CHECK: str w16, [sp, #36]
-## CHECK: str s14, [sp, #16]
-## CHECK: ldr s14, [sp, #28]
-## CHECK: str s1, [sp, #28]
-## CHECK: ldr s1, [sp, #32]
-## CHECK: str s31, [sp, #32]
-## CHECK: ldr s31, [sp, #20]
-## CHECK: str s31, [sp, #40]
-## CHECK: str s12, [sp, #20]
-## CHECK: fmov d12, d11
-## CHECK: fmov d11, d10
-## CHECK: fmov d10, d23
-## CHECK: fmov d23, d22
-## CHECK: fmov d22, d21
-## CHECK: fmov d21, d20
-## CHECK: fmov d20, d19
-## CHECK: fmov d19, d18
-## CHECK: fmov d18, d7
-## CHECK: fmov d7, d6
-## CHECK: fmov d6, d5
-## CHECK: fmov d5, d4
-## CHECK: fmov d4, d3
-## CHECK: fmov d3, d13
-## CHECK: ldr s13, [sp, #24]
-## CHECK: str s3, [sp, #24]
-## CHECK: ldr s3, pc+{{\d+}} (addr {{0x[0-9a-f]+}}) (100)
-## CHECK: end_block
-.method public test()V
- .registers 45
-
- const-string v39, ""
-
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b17:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_367
-
- const/16 v19, 0x0
-
- :goto_c
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b16:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_36b
-
- const/16 v18, 0x0
-
- :goto_16
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b18:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_36f
-
- const/16 v20, 0x0
-
- :goto_20
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b19:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_373
-
- const/16 v21, 0x0
-
- :goto_2a
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b20:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_377
-
- const/16 v22, 0x0
-
- :goto_34
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b21:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_37b
-
- const/16 v23, 0x0
-
- :goto_3e
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b15:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_37f
-
- const/16 v17, 0x0
-
- :goto_48
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b00:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_383
-
- const/4 v2, 0x0
-
- :goto_51
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b22:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_387
-
- const/16 v24, 0x0
-
- :goto_5b
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b23:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_38b
-
- const/16 v25, 0x0
-
- :goto_65
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b24:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_38f
-
- const/16 v26, 0x0
-
- :goto_6f
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b25:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_393
-
- const/16 v27, 0x0
-
- :goto_79
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b26:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_397
-
- const/16 v28, 0x0
-
- :goto_83
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b27:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_39b
-
- const/16 v29, 0x0
-
- :goto_8d
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b29:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_39f
-
- const/16 v31, 0x0
-
- :goto_97
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b28:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3a3
-
- const/16 v30, 0x0
-
- :goto_a1
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b01:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3a7
-
- const/4 v3, 0x0
-
- :goto_aa
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b02:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3ab
-
- const/4 v4, 0x0
-
- :goto_b3
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b03:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3af
-
- const/4 v5, 0x0
-
- :goto_bc
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b04:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3b3
-
- const/4 v6, 0x0
-
- :goto_c5
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b05:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3b7
-
- const/4 v7, 0x0
-
- :goto_ce
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b07:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3bb
-
- const/4 v9, 0x0
-
- :goto_d7
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b06:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3bf
-
- const/4 v8, 0x0
-
- :goto_e0
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b30:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3c3
-
- const/16 v32, 0x0
-
- :goto_ea
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b31:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3c7
-
- const/16 v33, 0x0
-
- :goto_f4
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b32:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3cb
-
- const/16 v34, 0x0
-
- :goto_fe
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b33:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3cf
-
- const/16 v35, 0x0
-
- :goto_108
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b34:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3d3
-
- const/16 v36, 0x0
-
- :goto_112
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b36:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3d7
-
- const/16 v38, 0x0
-
- :goto_11c
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b35:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3db
-
- const/16 v37, 0x0
-
- :goto_126
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b08:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3df
-
- const/4 v10, 0x0
-
- :goto_12f
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b09:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3e3
-
- const/4 v11, 0x0
-
- :goto_138
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b10:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3e7
-
- const/4 v12, 0x0
-
- :goto_141
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b11:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3eb
-
- const/4 v13, 0x0
-
- :goto_14a
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b12:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3ef
-
- const/4 v14, 0x0
-
- :goto_153
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b14:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3f3
-
- const/16 v16, 0x0
-
- :goto_15d
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->b13:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_3f7
-
- const/4 v15, 0x0
-
- :goto_166
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->conditionA:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_202
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v18, v18, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v19, v19, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v20, v20, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v21, v21, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v22, v22, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v23, v23, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v17, v17, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v10, v10, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v11, v11, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v12, v12, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v13, v13, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v14, v14, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v32, v32, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v33, v33, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v34, v34, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v35, v35, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v36, v36, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v3, v3, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v4, v4, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v5, v5, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v6, v6, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v7, v7, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v25, v25, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v26, v26, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v27, v27, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v28, v28, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v29, v29, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v24, v24, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v2, v2, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v16, v16, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v15, v15, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v38, v38, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v37, v37, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v9, v9, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v8, v8, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v31, v31, v42
-
- const/high16 v42, 0x447a0000 # 1000.0f
-
- div-float v30, v30, v42
-
- :cond_202
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->conditionB:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_29e
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v18, v18, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v19, v19, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v20, v20, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v21, v21, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v22, v22, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v23, v23, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v17, v17, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v10, v10, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v11, v11, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v12, v12, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v13, v13, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v14, v14, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v32, v32, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v33, v33, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v34, v34, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v35, v35, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v36, v36, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v3, v3, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v4, v4, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v5, v5, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v6, v6, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v7, v7, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v25, v25, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v26, v26, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v27, v27, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v28, v28, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v29, v29, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v24, v24, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v2, v2, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v16, v16, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v15, v15, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v38, v38, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v37, v37, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v9, v9, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v8, v8, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v31, v31, v42
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- div-float v30, v30, v42
-
- :cond_29e
- move-object/from16 v0, p0
-
- iget-boolean v0, v0, LSmali;->conditionC:Z
-
- move/from16 v42, v0
-
- if-eqz v42, :cond_33a
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v18, v18, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v19, v19, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v20, v20, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v21, v21, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v22, v22, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v23, v23, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v17, v17, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v10, v10, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v11, v11, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v12, v12, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v13, v13, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v14, v14, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v32, v32, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v33, v33, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v34, v34, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v35, v35, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v36, v36, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v3, v3, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v4, v4, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v5, v5, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v6, v6, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v7, v7, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v25, v25, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v26, v26, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v27, v27, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v28, v28, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v29, v29, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v24, v24, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v2, v2, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v16, v16, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v15, v15, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v38, v38, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v37, v37, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v9, v9, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v8, v8, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v31, v31, v42
-
- const/high16 v42, 0x41400000 # 12.0f
-
- div-float v30, v30, v42
-
- :cond_33a
- const/16 v41, 0x0
-
- const/high16 v42, 0x42c80000 # 100.0f
-
- mul-float v42, v42, v41
-
- invoke-static/range {v42 .. v42}, Ljava/lang/Math;->round(F)I
-
- move-result v42
-
- move/from16 v0, v42
-
- int-to-float v0, v0
-
- move/from16 v42, v0
-
- const/high16 v43, 0x42c80000 # 100.0f
-
- div-float v41, v42, v43
-
- new-instance v42, Ljava/lang/StringBuilder;
-
- invoke-direct/range {v42 .. v42}, Ljava/lang/StringBuilder;-><init>()V
-
- move-object/from16 v0, v42
-
- move/from16 v1, v41
-
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(F)Ljava/lang/StringBuilder;
-
- move-result-object v42
-
- move-object/from16 v0, v42
-
- move-object/from16 v1, v39
-
- invoke-virtual {v0, v1}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
-
- move-result-object v42
-
- invoke-virtual/range {v42 .. v42}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
-
- move-result-object v40
-
- return-void
-
- :cond_367
- const/high16 v19, 0x3f800000 # 1.0f
-
- goto/16 :goto_c
-
- :cond_36b
- const/high16 v18, 0x3f800000 # 1.0f
-
- goto/16 :goto_16
-
- :cond_36f
- const/high16 v20, 0x3f800000 # 1.0f
-
- goto/16 :goto_20
-
- :cond_373
- const/high16 v21, 0x3f800000 # 1.0f
-
- goto/16 :goto_2a
-
- :cond_377
- const/high16 v22, 0x3f800000 # 1.0f
-
- goto/16 :goto_34
-
- :cond_37b
- const/high16 v23, 0x3f800000 # 1.0f
-
- goto/16 :goto_3e
-
- :cond_37f
- const/high16 v17, 0x3f800000 # 1.0f
-
- goto/16 :goto_48
-
- :cond_383
- const/high16 v2, 0x3f800000 # 1.0f
-
- goto/16 :goto_51
-
- :cond_387
- const/high16 v24, 0x3f800000 # 1.0f
-
- goto/16 :goto_5b
-
- :cond_38b
- const/high16 v25, 0x3f800000 # 1.0f
-
- goto/16 :goto_65
-
- :cond_38f
- const/high16 v26, 0x3f800000 # 1.0f
-
- goto/16 :goto_6f
-
- :cond_393
- const/high16 v27, 0x3f800000 # 1.0f
-
- goto/16 :goto_79
-
- :cond_397
- const/high16 v28, 0x3f800000 # 1.0f
-
- goto/16 :goto_83
-
- :cond_39b
- const/high16 v29, 0x3f800000 # 1.0f
-
- goto/16 :goto_8d
-
- :cond_39f
- const/high16 v31, 0x3f800000 # 1.0f
-
- goto/16 :goto_97
-
- :cond_3a3
- const/high16 v30, 0x3f800000 # 1.0f
-
- goto/16 :goto_a1
-
- :cond_3a7
- const/high16 v3, 0x3f800000 # 1.0f
-
- goto/16 :goto_aa
-
- :cond_3ab
- const/high16 v4, 0x3f800000 # 1.0f
-
- goto/16 :goto_b3
-
- :cond_3af
- const/high16 v5, 0x3f800000 # 1.0f
-
- goto/16 :goto_bc
-
- :cond_3b3
- const/high16 v6, 0x3f800000 # 1.0f
-
- goto/16 :goto_c5
-
- :cond_3b7
- const/high16 v7, 0x3f800000 # 1.0f
-
- goto/16 :goto_ce
-
- :cond_3bb
- const/high16 v9, 0x3f800000 # 1.0f
-
- goto/16 :goto_d7
-
- :cond_3bf
- const/high16 v8, 0x3f800000 # 1.0f
-
- goto/16 :goto_e0
-
- :cond_3c3
- const/high16 v32, 0x3f800000 # 1.0f
-
- goto/16 :goto_ea
-
- :cond_3c7
- const/high16 v33, 0x3f800000 # 1.0f
-
- goto/16 :goto_f4
-
- :cond_3cb
- const/high16 v34, 0x3f800000 # 1.0f
-
- goto/16 :goto_fe
-
- :cond_3cf
- const/high16 v35, 0x3f800000 # 1.0f
-
- goto/16 :goto_108
-
- :cond_3d3
- const/high16 v36, 0x3f800000 # 1.0f
-
- goto/16 :goto_112
-
- :cond_3d7
- const/high16 v38, 0x3f800000 # 1.0f
-
- goto/16 :goto_11c
-
- :cond_3db
- const/high16 v37, 0x3f800000 # 1.0f
-
- goto/16 :goto_126
-
- :cond_3df
- const/high16 v10, 0x3f800000 # 1.0f
-
- goto/16 :goto_12f
-
- :cond_3e3
- const/high16 v11, 0x3f800000 # 1.0f
-
- goto/16 :goto_138
-
- :cond_3e7
- const/high16 v12, 0x3f800000 # 1.0f
-
- goto/16 :goto_141
-
- :cond_3eb
- const/high16 v13, 0x3f800000 # 1.0f
-
- goto/16 :goto_14a
-
- :cond_3ef
- const/high16 v14, 0x3f800000 # 1.0f
-
- goto/16 :goto_153
-
- :cond_3f3
- const/high16 v16, 0x3f800000 # 1.0f
-
- goto/16 :goto_15d
-
- :cond_3f7
- const/high16 v15, 0x3f800000 # 1.0f
-
- goto/16 :goto_166
-.end method
-
-## CHECK-START-ARM64: void Smali.testD8() register (after)
-## CHECK: begin_block
-## CHECK: name "B0"
-## CHECK: <<This:l\d+>> ParameterValue
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: successors "<<ThenBlockA:B\d+>>" "<<ElseBlockA:B\d+>>"
-## CHECK: <<CondA:z\d+>> InstanceFieldGet [<<This>>] field_name:Smali.conditionA
-## CHECK: If [<<CondA>>]
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: name "<<ThenBlockA>>"
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: name "<<ElseBlockA>>"
-## CHECK: ParallelMove moves:[d2->d0,40(sp)->d17,d20->d26,d19->d27,d27->d1,d26->d2,d14->d20,d13->d19,d17->d14,d0->d13]
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: successors "<<ThenBlockB:B\d+>>" "<<ElseBlockB:B\d+>>"
-## CHECK: <<CondB:z\d+>> InstanceFieldGet [<<This>>] field_name:Smali.conditionB
-## CHECK: If [<<CondB>>]
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: name "<<ThenBlockB>>"
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: name "<<ElseBlockB>>"
-## CHECK: ParallelMove moves:[#100->d13,16(sp)->d1,20(sp)->d2,28(sp)->d19,24(sp)->d20,36(sp)->d14,32(sp)->16(sp),d1->20(sp),d2->24(sp),d20->28(sp),d19->32(sp),d14->36(sp),d13->40(sp)]
-## CHECK: end_block
-
-## CHECK-START-ARM64: void Smali.testD8() disassembly (after)
-## CHECK: begin_block
-## CHECK: name "B0"
-## CHECK: <<This:l\d+>> ParameterValue
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: successors "<<ThenBlockA:B\d+>>" "<<ElseBlockA:B\d+>>"
-## CHECK: <<CondA:z\d+>> InstanceFieldGet [<<This>>] field_name:Smali.conditionA
-## CHECK: If [<<CondA>>]
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: name "<<ThenBlockA>>"
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: name "<<ElseBlockA>>"
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: successors "<<ThenBlockB:B\d+>>" "<<ElseBlockB:B\d+>>"
-## CHECK: <<CondB:z\d+>> InstanceFieldGet [<<This>>] field_name:Smali.conditionB
-## CHECK: If [<<CondB>>]
-## CHECK: end_block
-
-## CHECK: begin_block
-## CHECK: name "<<ThenBlockB>>"
-## CHECK: end_block
-## CHECK: begin_block
-## CHECK: name "<<ElseBlockB>>"
-## CHECK: ParallelMove moves:[invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid]
-## CHECK: ldr w16, [sp, #32]
-## CHECK: str s19, [sp, #32]
-## CHECK: ldr s19, [sp, #28]
-## CHECK: str s20, [sp, #28]
-## CHECK: ldr s20, [sp, #24]
-## CHECK: str s2, [sp, #24]
-## CHECK: ldr s2, [sp, #20]
-## CHECK: str s1, [sp, #20]
-## CHECK: ldr s1, [sp, #16]
-## CHECK: str w16, [sp, #16]
-## CHECK: fmov d31, d14
-## CHECK: ldr s14, [sp, #36]
-## CHECK: str s31, [sp, #36]
-## CHECK: str s13, [sp, #40]
-## CHECK: ldr s13, pc+580 (addr 0x61c) (100)
-## CHECK: end_block
-.method public testD8()V
- .registers 47
-
- move-object/from16 v0, p0
-
- const-string v1, ""
-
- iget-boolean v2, v0, LSmali;->b17:Z
-
- if-eqz v2, :cond_a
-
- const/4 v2, 0x0
-
- goto :goto_c
-
- :cond_a
- const/high16 v2, 0x3f800000 # 1.0f
-
- :goto_c
- iget-boolean v5, v0, LSmali;->b16:Z
-
- if-eqz v5, :cond_12
-
- const/4 v5, 0x0
-
- goto :goto_14
-
- :cond_12
- const/high16 v5, 0x3f800000 # 1.0f
-
- :goto_14
- iget-boolean v6, v0, LSmali;->b18:Z
-
- if-eqz v6, :cond_1a
-
- const/4 v6, 0x0
-
- goto :goto_1c
-
- :cond_1a
- const/high16 v6, 0x3f800000 # 1.0f
-
- :goto_1c
- iget-boolean v7, v0, LSmali;->b19:Z
-
- if-eqz v7, :cond_22
-
- const/4 v7, 0x0
-
- goto :goto_24
-
- :cond_22
- const/high16 v7, 0x3f800000 # 1.0f
-
- :goto_24
- iget-boolean v8, v0, LSmali;->b20:Z
-
- if-eqz v8, :cond_2a
-
- const/4 v8, 0x0
-
- goto :goto_2c
-
- :cond_2a
- const/high16 v8, 0x3f800000 # 1.0f
-
- :goto_2c
- iget-boolean v9, v0, LSmali;->b21:Z
-
- if-eqz v9, :cond_32
-
- const/4 v9, 0x0
-
- goto :goto_34
-
- :cond_32
- const/high16 v9, 0x3f800000 # 1.0f
-
- :goto_34
- iget-boolean v10, v0, LSmali;->b15:Z
-
- if-eqz v10, :cond_3a
-
- const/4 v10, 0x0
-
- goto :goto_3c
-
- :cond_3a
- const/high16 v10, 0x3f800000 # 1.0f
-
- :goto_3c
- iget-boolean v11, v0, LSmali;->b00:Z
-
- if-eqz v11, :cond_42
-
- const/4 v11, 0x0
-
- goto :goto_44
-
- :cond_42
- const/high16 v11, 0x3f800000 # 1.0f
-
- :goto_44
- iget-boolean v12, v0, LSmali;->b22:Z
-
- if-eqz v12, :cond_4a
-
- const/4 v12, 0x0
-
- goto :goto_4c
-
- :cond_4a
- const/high16 v12, 0x3f800000 # 1.0f
-
- :goto_4c
- iget-boolean v13, v0, LSmali;->b23:Z
-
- if-eqz v13, :cond_52
-
- const/4 v13, 0x0
-
- goto :goto_54
-
- :cond_52
- const/high16 v13, 0x3f800000 # 1.0f
-
- :goto_54
- iget-boolean v14, v0, LSmali;->b24:Z
-
- if-eqz v14, :cond_5a
-
- const/4 v14, 0x0
-
- goto :goto_5c
-
- :cond_5a
- const/high16 v14, 0x3f800000 # 1.0f
-
- :goto_5c
- iget-boolean v15, v0, LSmali;->b25:Z
-
- if-eqz v15, :cond_62
-
- const/4 v15, 0x0
-
- goto :goto_64
-
- :cond_62
- const/high16 v15, 0x3f800000 # 1.0f
-
- :goto_64
- iget-boolean v3, v0, LSmali;->b26:Z
-
- if-eqz v3, :cond_6a
-
- const/4 v3, 0x0
-
- goto :goto_6c
-
- :cond_6a
- const/high16 v3, 0x3f800000 # 1.0f
-
- :goto_6c
- iget-boolean v4, v0, LSmali;->b27:Z
-
- if-eqz v4, :cond_72
-
- const/4 v4, 0x0
-
- goto :goto_74
-
- :cond_72
- const/high16 v4, 0x3f800000 # 1.0f
-
- :goto_74
- move-object/from16 v18, v1
-
- iget-boolean v1, v0, LSmali;->b29:Z
-
- if-eqz v1, :cond_7c
-
- const/4 v1, 0x0
-
- goto :goto_7e
-
- :cond_7c
- const/high16 v1, 0x3f800000 # 1.0f
-
- :goto_7e
- move/from16 v19, v1
-
- iget-boolean v1, v0, LSmali;->b28:Z
-
- if-eqz v1, :cond_86
-
- const/4 v1, 0x0
-
- goto :goto_88
-
- :cond_86
- const/high16 v1, 0x3f800000 # 1.0f
-
- :goto_88
- move/from16 v20, v1
-
- iget-boolean v1, v0, LSmali;->b01:Z
-
- if-eqz v1, :cond_90
-
- const/4 v1, 0x0
-
- goto :goto_92
-
- :cond_90
- const/high16 v1, 0x3f800000 # 1.0f
-
- :goto_92
- move/from16 v21, v11
-
- iget-boolean v11, v0, LSmali;->b02:Z
-
- if-eqz v11, :cond_9a
-
- const/4 v11, 0x0
-
- goto :goto_9c
-
- :cond_9a
- const/high16 v11, 0x3f800000 # 1.0f
-
- :goto_9c
- move/from16 v22, v12
-
- iget-boolean v12, v0, LSmali;->b03:Z
-
- if-eqz v12, :cond_a4
-
- const/4 v12, 0x0
-
- goto :goto_a6
-
- :cond_a4
- const/high16 v12, 0x3f800000 # 1.0f
-
- :goto_a6
- move/from16 v23, v4
-
- iget-boolean v4, v0, LSmali;->b04:Z
-
- if-eqz v4, :cond_ae
-
- const/4 v4, 0x0
-
- goto :goto_b0
-
- :cond_ae
- const/high16 v4, 0x3f800000 # 1.0f
-
- :goto_b0
- move/from16 v24, v3
-
- iget-boolean v3, v0, LSmali;->b05:Z
-
- if-eqz v3, :cond_b8
-
- const/4 v3, 0x0
-
- goto :goto_ba
-
- :cond_b8
- const/high16 v3, 0x3f800000 # 1.0f
-
- :goto_ba
- move/from16 v25, v15
-
- iget-boolean v15, v0, LSmali;->b07:Z
-
- if-eqz v15, :cond_c2
-
- const/4 v15, 0x0
-
- goto :goto_c4
-
- :cond_c2
- const/high16 v15, 0x3f800000 # 1.0f
-
- :goto_c4
- move/from16 v26, v15
-
- iget-boolean v15, v0, LSmali;->b06:Z
-
- if-eqz v15, :cond_cc
-
- const/4 v15, 0x0
-
- goto :goto_ce
-
- :cond_cc
- const/high16 v15, 0x3f800000 # 1.0f
-
- :goto_ce
- move/from16 v27, v15
-
- iget-boolean v15, v0, LSmali;->b30:Z
-
- if-eqz v15, :cond_d6
-
- const/4 v15, 0x0
-
- goto :goto_d8
-
- :cond_d6
- const/high16 v15, 0x3f800000 # 1.0f
-
- :goto_d8
- move/from16 v28, v14
-
- iget-boolean v14, v0, LSmali;->b31:Z
-
- if-eqz v14, :cond_e0
-
- const/4 v14, 0x0
-
- goto :goto_e2
-
- :cond_e0
- const/high16 v14, 0x3f800000 # 1.0f
-
- :goto_e2
- move/from16 v29, v13
-
- iget-boolean v13, v0, LSmali;->b32:Z
-
- if-eqz v13, :cond_ea
-
- const/4 v13, 0x0
-
- goto :goto_ec
-
- :cond_ea
- const/high16 v13, 0x3f800000 # 1.0f
-
- :goto_ec
- move/from16 v30, v3
-
- iget-boolean v3, v0, LSmali;->b33:Z
-
- if-eqz v3, :cond_f4
-
- const/4 v3, 0x0
-
- goto :goto_f6
-
- :cond_f4
- const/high16 v3, 0x3f800000 # 1.0f
-
- :goto_f6
- move/from16 v31, v4
-
- iget-boolean v4, v0, LSmali;->b34:Z
-
- if-eqz v4, :cond_fe
-
- const/4 v4, 0x0
-
- goto :goto_100
-
- :cond_fe
- const/high16 v4, 0x3f800000 # 1.0f
-
- :goto_100
- move/from16 v32, v12
-
- iget-boolean v12, v0, LSmali;->b36:Z
-
- if-eqz v12, :cond_108
-
- const/4 v12, 0x0
-
- goto :goto_10a
-
- :cond_108
- const/high16 v12, 0x3f800000 # 1.0f
-
- :goto_10a
- move/from16 v33, v12
-
- iget-boolean v12, v0, LSmali;->b35:Z
-
- if-eqz v12, :cond_112
-
- const/4 v12, 0x0
-
- goto :goto_114
-
- :cond_112
- const/high16 v12, 0x3f800000 # 1.0f
-
- :goto_114
- move/from16 v34, v12
-
- iget-boolean v12, v0, LSmali;->b08:Z
-
- if-eqz v12, :cond_11c
-
- const/4 v12, 0x0
-
- goto :goto_11e
-
- :cond_11c
- const/high16 v12, 0x3f800000 # 1.0f
-
- :goto_11e
- move/from16 v35, v11
-
- iget-boolean v11, v0, LSmali;->b09:Z
-
- if-eqz v11, :cond_126
-
- const/4 v11, 0x0
-
- goto :goto_128
-
- :cond_126
- const/high16 v11, 0x3f800000 # 1.0f
-
- :goto_128
- move/from16 v36, v1
-
- iget-boolean v1, v0, LSmali;->b10:Z
-
- if-eqz v1, :cond_130
-
- const/4 v1, 0x0
-
- goto :goto_132
-
- :cond_130
- const/high16 v1, 0x3f800000 # 1.0f
-
- :goto_132
- move/from16 v37, v4
-
- iget-boolean v4, v0, LSmali;->b11:Z
-
- if-eqz v4, :cond_13a
-
- const/4 v4, 0x0
-
- goto :goto_13c
-
- :cond_13a
- const/high16 v4, 0x3f800000 # 1.0f
-
- :goto_13c
- move/from16 v38, v3
-
- iget-boolean v3, v0, LSmali;->b12:Z
-
- if-eqz v3, :cond_144
-
- const/4 v3, 0x0
-
- goto :goto_146
-
- :cond_144
- const/high16 v3, 0x3f800000 # 1.0f
-
- :goto_146
- move/from16 v39, v13
-
- iget-boolean v13, v0, LSmali;->b14:Z
-
- if-eqz v13, :cond_14e
-
- const/4 v13, 0x0
-
- goto :goto_150
-
- :cond_14e
- const/high16 v13, 0x3f800000 # 1.0f
-
- :goto_150
- move/from16 v40, v13
-
- iget-boolean v13, v0, LSmali;->b13:Z
-
- if-eqz v13, :cond_159
-
- const/16 v16, 0x0
-
- goto :goto_15b
-
- :cond_159
- const/high16 v16, 0x3f800000 # 1.0f
-
- :goto_15b
- move/from16 v13, v16
-
- move/from16 v41, v13
-
- iget-boolean v13, v0, LSmali;->conditionA:Z
-
- if-eqz v13, :cond_1a2
-
- const/high16 v13, 0x447a0000 # 1000.0f
-
- div-float/2addr v5, v13
-
- div-float/2addr v2, v13
-
- div-float/2addr v6, v13
-
- div-float/2addr v7, v13
-
- div-float/2addr v8, v13
-
- div-float/2addr v9, v13
-
- div-float/2addr v10, v13
-
- div-float/2addr v12, v13
-
- div-float/2addr v11, v13
-
- div-float/2addr v1, v13
-
- div-float/2addr v4, v13
-
- div-float/2addr v3, v13
-
- div-float/2addr v15, v13
-
- div-float/2addr v14, v13
-
- div-float v16, v39, v13
-
- div-float v38, v38, v13
-
- div-float v37, v37, v13
-
- div-float v36, v36, v13
-
- div-float v35, v35, v13
-
- div-float v32, v32, v13
-
- div-float v31, v31, v13
-
- div-float v30, v30, v13
-
- div-float v29, v29, v13
-
- div-float v28, v28, v13
-
- div-float v25, v25, v13
-
- div-float v24, v24, v13
-
- div-float v23, v23, v13
-
- div-float v22, v22, v13
-
- div-float v21, v21, v13
-
- div-float v39, v40, v13
-
- div-float v40, v41, v13
-
- div-float v33, v33, v13
-
- div-float v34, v34, v13
-
- div-float v26, v26, v13
-
- div-float v27, v27, v13
-
- div-float v19, v19, v13
-
- div-float v13, v20, v13
-
- goto :goto_1aa
-
- :cond_1a2
- move/from16 v13, v20
-
- move/from16 v16, v39
-
- move/from16 v39, v40
-
- move/from16 v40, v41
-
- :goto_1aa
- move/from16 v42, v13
-
- iget-boolean v13, v0, LSmali;->conditionB:Z
-
- const/high16 v20, 0x42c80000 # 100.0f
-
- if-eqz v13, :cond_1fd
-
- div-float v5, v5, v20
-
- div-float v2, v2, v20
-
- div-float v6, v6, v20
-
- div-float v7, v7, v20
-
- div-float v8, v8, v20
-
- div-float v9, v9, v20
-
- div-float v10, v10, v20
-
- div-float v12, v12, v20
-
- div-float v11, v11, v20
-
- div-float v1, v1, v20
-
- div-float v4, v4, v20
-
- div-float v3, v3, v20
-
- div-float v15, v15, v20
-
- div-float v14, v14, v20
-
- div-float v16, v16, v20
-
- div-float v38, v38, v20
-
- div-float v37, v37, v20
-
- div-float v36, v36, v20
-
- div-float v35, v35, v20
-
- div-float v32, v32, v20
-
- div-float v31, v31, v20
-
- div-float v30, v30, v20
-
- div-float v29, v29, v20
-
- div-float v28, v28, v20
-
- div-float v25, v25, v20
-
- div-float v24, v24, v20
-
- div-float v23, v23, v20
-
- div-float v22, v22, v20
-
- div-float v21, v21, v20
-
- div-float v39, v39, v20
-
- div-float v40, v40, v20
-
- div-float v33, v33, v20
-
- div-float v34, v34, v20
-
- div-float v26, v26, v20
-
- div-float v27, v27, v20
-
- div-float v19, v19, v20
-
- div-float v13, v42, v20
-
- goto :goto_1ff
-
- :cond_1fd
- move/from16 v13, v42
-
- :goto_1ff
- move/from16 v43, v13
-
- iget-boolean v13, v0, LSmali;->conditionC:Z
-
- if-eqz v13, :cond_244
-
- const/high16 v13, 0x41400000 # 12.0f
-
- div-float/2addr v5, v13
-
- div-float/2addr v2, v13
-
- div-float/2addr v6, v13
-
- div-float/2addr v7, v13
-
- div-float/2addr v8, v13
-
- div-float/2addr v9, v13
-
- div-float/2addr v10, v13
-
- div-float/2addr v12, v13
-
- div-float/2addr v11, v13
-
- div-float/2addr v1, v13
-
- div-float/2addr v4, v13
-
- div-float/2addr v3, v13
-
- div-float/2addr v15, v13
-
- div-float/2addr v14, v13
-
- div-float v16, v16, v13
-
- div-float v38, v38, v13
-
- div-float v37, v37, v13
-
- div-float v36, v36, v13
-
- div-float v35, v35, v13
-
- div-float v32, v32, v13
-
- div-float v31, v31, v13
-
- div-float v30, v30, v13
-
- div-float v29, v29, v13
-
- div-float v28, v28, v13
-
- div-float v25, v25, v13
-
- div-float v24, v24, v13
-
- div-float v23, v23, v13
-
- div-float v22, v22, v13
-
- div-float v21, v21, v13
-
- div-float v39, v39, v13
-
- div-float v40, v40, v13
-
- div-float v33, v33, v13
-
- div-float v34, v34, v13
-
- div-float v26, v26, v13
-
- div-float v27, v27, v13
-
- div-float v19, v19, v13
-
- div-float v13, v43, v13
-
- goto :goto_246
-
- :cond_244
- move/from16 v13, v43
-
- :goto_246
- const/16 v17, 0x0
-
- mul-float v0, v20, v17
-
- invoke-static {v0}, Ljava/lang/Math;->round(F)I
-
- move-result v0
-
- int-to-float v0, v0
-
- div-float v0, v0, v20
-
- move/from16 v44, v1
-
- new-instance v1, Ljava/lang/StringBuilder;
-
- invoke-direct {v1}, Ljava/lang/StringBuilder;-><init>()V
-
- invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(F)Ljava/lang/StringBuilder;
-
- move/from16 v45, v0
-
- move-object/from16 v0, v18
-
- invoke-virtual {v1, v0}, Ljava/lang/StringBuilder;->append(Ljava/lang/String;)Ljava/lang/StringBuilder;
-
- invoke-virtual {v1}, Ljava/lang/StringBuilder;->toString()Ljava/lang/String;
-
- move-result-object v1
-
- return-void
-.end method
diff --git a/test/626-checker-arm64-scratch-register/src/Main.java b/test/626-checker-arm64-scratch-register/src/Main.java
index cf94b87..1394917 100644
--- a/test/626-checker-arm64-scratch-register/src/Main.java
+++ b/test/626-checker-arm64-scratch-register/src/Main.java
@@ -13,8 +13,6 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-import java.lang.reflect.Constructor;
-import java.lang.reflect.Method;
public class Main {
@@ -65,17 +63,14 @@
/// CHECK: name "B0"
/// CHECK: <<This:l\d+>> ParameterValue
/// CHECK: end_block
-
/// CHECK: begin_block
- /// CHECK: successors "<<ThenBlockA:B\d+>>" "<<ElseBlockA:B\d+>>"
- /// CHECK: <<CondA:z\d+>> InstanceFieldGet [<<This>>] field_name:Main.conditionA
- /// CHECK: If [<<CondA>>]
- /// CHECK: end_block
-
- /// CHECK: begin_block
- /// CHECK: successors "<<ThenBlockB:B\d+>>" "<<ElseBlockB:B\d+>>"
+ /// CHECK: successors "<<ThenBlock:B\d+>>" "<<ElseBlock:B\d+>>"
/// CHECK: <<CondB:z\d+>> InstanceFieldGet [<<This>>] field_name:Main.conditionB
/// CHECK: If [<<CondB>>]
+ /// CHECK: end_block
+ /// CHECK: begin_block
+ /// CHECK: name "<<ElseBlock>>"
+ /// CHECK: ParallelMove moves:[40(sp)->d0,24(sp)->32(sp),28(sp)->36(sp),d0->d3,d3->d4,d2->d5,d4->d6,d5->d7,d6->d18,d7->d19,d18->d20,d19->d21,d20->d22,d21->d23,d22->d10,d23->d11,16(sp)->24(sp),20(sp)->28(sp),d10->d14,d11->d12,d12->d13,d13->d1,d14->d2,32(sp)->16(sp),36(sp)->20(sp)]
/// CHECK: end_block
/// CHECK-START-ARM64: void Main.test() disassembly (after)
@@ -87,6 +82,39 @@
/// CHECK: successors "<<ThenBlock:B\d+>>" "<<ElseBlock:B\d+>>"
/// CHECK: <<CondB:z\d+>> InstanceFieldGet [<<This>>] field_name:Main.conditionB
/// CHECK: If [<<CondB>>]
+ /// CHECK: end_block
+ /// CHECK: begin_block
+ /// CHECK: name "<<ElseBlock>>"
+ /// CHECK: ParallelMove moves:[invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid,invalid->invalid]
+ /// CHECK: fmov d31, d2
+ /// CHECK: ldr s2, [sp, #36]
+ /// CHECK: ldr w16, [sp, #16]
+ /// CHECK: str w16, [sp, #36]
+ /// CHECK: str s14, [sp, #16]
+ /// CHECK: ldr s14, [sp, #28]
+ /// CHECK: str s1, [sp, #28]
+ /// CHECK: ldr s1, [sp, #32]
+ /// CHECK: str s31, [sp, #32]
+ /// CHECK: ldr s31, [sp, #20]
+ /// CHECK: str s31, [sp, #40]
+ /// CHECK: str s12, [sp, #20]
+ /// CHECK: fmov d12, d11
+ /// CHECK: fmov d11, d10
+ /// CHECK: fmov d10, d23
+ /// CHECK: fmov d23, d22
+ /// CHECK: fmov d22, d21
+ /// CHECK: fmov d21, d20
+ /// CHECK: fmov d20, d19
+ /// CHECK: fmov d19, d18
+ /// CHECK: fmov d18, d7
+ /// CHECK: fmov d7, d6
+ /// CHECK: fmov d6, d5
+ /// CHECK: fmov d5, d4
+ /// CHECK: fmov d4, d3
+ /// CHECK: fmov d3, d13
+ /// CHECK: ldr s13, [sp, #24]
+ /// CHECK: str s3, [sp, #24]
+ /// CHECK: ldr s3, pc+{{\d+}} (addr {{0x[0-9a-f]+}}) (100)
/// CHECK: end_block
public void test() {
@@ -261,20 +289,9 @@
String res = s + r;
}
- public static void main(String[] args) throws Exception {
+ public static void main(String[] args) {
Main main = new Main();
main.test();
-
- Class<?> cl = Class.forName("Smali");
- Constructor<?> cons = cl.getConstructor();
- Object o = cons.newInstance();
-
- Method test = cl.getMethod("test");
- test.invoke(o);
-
- Method testD8 = cl.getMethod("testD8");
- testD8.invoke(o);
-
System.out.println("passed");
}
}