diff options
author | 2025-01-07 12:22:49 +0000 | |
---|---|---|
committer | 2025-01-07 06:31:12 -0800 | |
commit | fe90069d7f7d26e0117d3b1d51fd707b434ca776 (patch) | |
tree | 2db06749d5248f36e5d18821b9839f39bf5e6425 | |
parent | 364066f0a04c197ce95c8103a222835911990595 (diff) |
Clean up `Instruction::SizeInCodeUnitsComplexOpcode()`.
And remove code that's dead since
https://android-review.googlesource.com/3436080 .
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 181943478
Change-Id: Icadd18246bc812fe3c7589172223e632604e146a
-rw-r--r-- | libdexfile/dex/dex_instruction.cc | 40 | ||||
-rw-r--r-- | libdexfile/dex/dex_instruction.h | 9 |
2 files changed, 8 insertions, 41 deletions
diff --git a/libdexfile/dex/dex_instruction.cc b/libdexfile/dex/dex_instruction.cc index c4db658ae1..27feb08d77 100644 --- a/libdexfile/dex/dex_instruction.cc +++ b/libdexfile/dex/dex_instruction.cc @@ -63,16 +63,17 @@ bool Instruction::CanFlowThrough() const { } size_t Instruction::SizeInCodeUnitsComplexOpcode() const { - const uint16_t* insns = reinterpret_cast<const uint16_t*>(this); // Handle special NOP encoded variable length sequences. - switch (*insns) { + uint16_t inst_data = Fetch16(0); + DCHECK_EQ(inst_data & 0xFF, 0) << DumpString(nullptr); + switch (inst_data) { case kPackedSwitchSignature: - return (4 + insns[1] * 2); + return (4 + Fetch16(1) * 2); case kSparseSwitchSignature: - return (2 + insns[1] * 4); + return (2 + Fetch16(1) * 4); case kArrayDataSignature: { - uint16_t element_size = insns[1]; - uint32_t length = insns[2] | (((uint32_t)insns[3]) << 16); + uint16_t element_size = Fetch16(1); + uint32_t length = Fetch16(2) | ((static_cast<uint32_t>(Fetch16(3))) << 16); // The plus 1 is to round up for odd size and width. uint32_t result = (4 + (element_size * length + 1) / 2); // This function is used only after the `MethodVerifier` checked that the 32-bit calculation @@ -82,32 +83,7 @@ size_t Instruction::SizeInCodeUnitsComplexOpcode() const { return result; } default: - if ((*insns & 0xFF) == 0) { - return 1; // NOP. - } else { - LOG(FATAL) << "Unreachable: " << DumpString(nullptr); - UNREACHABLE(); - } - } -} - -size_t Instruction::CodeUnitsRequiredForSizeOfComplexOpcode() const { - const uint16_t* insns = reinterpret_cast<const uint16_t*>(this); - // Handle special NOP encoded variable length sequences. - switch (*insns) { - case kPackedSwitchSignature: - FALLTHROUGH_INTENDED; - case kSparseSwitchSignature: - return 2; - case kArrayDataSignature: - return 4; - default: - if ((*insns & 0xFF) == 0) { - return 1; // NOP. - } else { - LOG(FATAL) << "Unreachable: " << DumpString(nullptr); - UNREACHABLE(); - } + return 1; // NOP. } } diff --git a/libdexfile/dex/dex_instruction.h b/libdexfile/dex/dex_instruction.h index 0f12f45acd..cf676681e0 100644 --- a/libdexfile/dex/dex_instruction.h +++ b/libdexfile/dex/dex_instruction.h @@ -225,12 +225,6 @@ class Instruction { // Returns the size (in 2 byte code units) of the given instruction format. ALWAYS_INLINE static constexpr size_t SizeInCodeUnits(Format format); - // Code units required to calculate the size of the instruction. - size_t CodeUnitsRequiredForSizeComputation() const { - const int8_t result = InstructionDescriptorOf(Opcode()).size_in_code_units; - return UNLIKELY(result < 0) ? CodeUnitsRequiredForSizeOfComplexOpcode() : 1; - } - // Reads an instruction out of the stream at the specified address. static const Instruction* At(const uint16_t* code) { DCHECK(code != nullptr); @@ -681,9 +675,6 @@ class Instruction { return kInstructionDescriptors[opcode]; } - // Return how many code unit words are required to compute the size of the opcode. - size_t CodeUnitsRequiredForSizeOfComplexOpcode() const; - uint32_t Fetch32(size_t offset) const { return (Fetch16(offset) | ((uint32_t) Fetch16(offset + 1) << 16)); } |