diff options
author | 2024-12-04 11:43:38 +0000 | |
---|---|---|
committer | 2024-12-04 15:18:00 +0000 | |
commit | 701e215aa52ac710d3d4b1bf3dac5abb3f57750e (patch) | |
tree | 48480ac2c0970974d4c256966b1387e37da44737 | |
parent | a0bdc8d7d84a470aabdb6a3bc5a0fa06a7d9dc84 (diff) |
Remove remnants of quickened opcode verification.
Test: m test-art-host-gtest
Test: testrunner.py --host --optimizing
Bug: 170086509
Change-Id: I1865f016934158e2691116b59a5b6d462c99eccb
-rw-r--r-- | dexdump/dexdump.cc | 7 | ||||
-rw-r--r-- | libdexfile/dex/dex_instruction.h | 23 | ||||
-rw-r--r-- | runtime/verifier/method_verifier.cc | 15 | ||||
-rw-r--r-- | test/983-source-transform-verify/source_transform_art.cc | 2 |
4 files changed, 8 insertions, 39 deletions
diff --git a/dexdump/dexdump.cc b/dexdump/dexdump.cc index ce0eb130fb..43ed224b01 100644 --- a/dexdump/dexdump.cc +++ b/dexdump/dexdump.cc @@ -968,13 +968,6 @@ static std::unique_ptr<char[]> indexString(const DexFile* pDexFile, outSize = snprintf(buf.get(), bufSize, "<field?> // field@%0*x", width, index); } break; - case Instruction::kIndexVtableOffset: - outSize = snprintf(buf.get(), bufSize, "[%0*x] // vtable #%0*x", - width, index, width, index); - break; - case Instruction::kIndexFieldOffset: - outSize = snprintf(buf.get(), bufSize, "[obj+%0*x]", width, index); - break; case Instruction::kIndexMethodAndProtoRef: { std::string method("<method?>"); std::string proto("<proto?>"); diff --git a/libdexfile/dex/dex_instruction.h b/libdexfile/dex/dex_instruction.h index f6950af9a0..3b7fe4668e 100644 --- a/libdexfile/dex/dex_instruction.h +++ b/libdexfile/dex/dex_instruction.h @@ -132,8 +132,6 @@ class Instruction { kIndexStringRef, // string reference index kIndexMethodRef, // method reference index kIndexFieldRef, // field reference index - kIndexFieldOffset, // field offset (for static linked fields) - kIndexVtableOffset, // vtable offset (for static linked methods) kIndexMethodAndProtoRef, // method and a proto reference index (for invoke-polymorphic) kIndexCallSiteRef, // call site reference index kIndexMethodHandleRef, // constant method handle reference index @@ -195,12 +193,11 @@ class Instruction { kVerifyVarArgNonZero = 0x0040000, kVerifyVarArgRange = 0x0080000, kVerifyVarArgRangeNonZero = 0x0100000, - kVerifyRuntimeOnly = 0x0200000, - kVerifyError = 0x0400000, - kVerifyRegHPrototype = 0x0800000, - kVerifyRegBCallSite = 0x1000000, - kVerifyRegBMethodHandle = 0x2000000, - kVerifyRegBPrototype = 0x4000000, + kVerifyError = 0x0200000, + kVerifyRegHPrototype = 0x0400000, + kVerifyRegBCallSite = 0x0800000, + kVerifyRegBMethodHandle = 0x1000000, + kVerifyRegBPrototype = 0x2000000, }; // Collect the enums in a struct for better locality. @@ -563,12 +560,6 @@ class Instruction { // Returns true if the instruction allows control flow to go to the following instruction. bool CanFlowThrough() const; - // Returns true if the instruction is a quickened instruction. - bool IsQuickened() const { - return (kInstructionDescriptors[Opcode()].index_type == kIndexFieldOffset) || - (kInstructionDescriptors[Opcode()].index_type == kIndexVtableOffset); - } - // Returns true if this instruction is a switch. bool IsSwitch() const { return (kInstructionDescriptors[Opcode()].flags & kSwitch) != 0; @@ -624,10 +615,6 @@ class Instruction { kVerifyVarArgRange | kVerifyVarArgRangeNonZero | kVerifyError)); } - bool GetVerifyIsRuntimeOnly() const { - return (kInstructionDescriptors[Opcode()].verify_flags & kVerifyRuntimeOnly) != 0; - } - // Get the dex PC of this instruction as a offset in code units from the beginning of insns. uint32_t GetDexPc(const uint16_t* insns) const { return (reinterpret_cast<const uint16_t*>(this) - insns); diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 2d9f986059..e8a6de8991 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -249,7 +249,6 @@ class MethodVerifier final : public ::art::verifier::MethodVerifier { * * Walks through instructions in a method calling VerifyInstruction on each. */ - template <bool kAllowRuntimeOnlyInstructions> bool VerifyInstructions(); /* @@ -285,7 +284,6 @@ class MethodVerifier final : public ::art::verifier::MethodVerifier { * - (earlier) for each exception handler, the handler must start at a valid * instruction */ - template <bool kAllowRuntimeOnlyInstructions> bool VerifyInstruction(const Instruction* inst, uint32_t code_offset); /* Ensure that the register index is valid for this code item. */ @@ -1373,13 +1371,10 @@ bool MethodVerifier<kVerifierDebug>::Verify() { InstructionFlags()); // Run through the instructions and see if the width checks out. bool result = ComputeWidthsAndCountOps(); - bool allow_runtime_only_instructions = !IsAotMode() || verify_to_dump_; // Flag instructions guarded by a "try" block and check exception handlers. result = result && ScanTryCatchBlocks(); // Perform static instruction verification. - result = result && (allow_runtime_only_instructions - ? VerifyInstructions<true>() - : VerifyInstructions<false>()); + result = result && VerifyInstructions(); // Perform code-flow analysis and return. result = result && VerifyCodeFlow(); @@ -1477,13 +1472,12 @@ bool MethodVerifier<kVerifierDebug>::ScanTryCatchBlocks() { } template <bool kVerifierDebug> -template <bool kAllowRuntimeOnlyInstructions> bool MethodVerifier<kVerifierDebug>::VerifyInstructions() { // Flag the start of the method as a branch target. GetModifiableInstructionFlags(0).SetBranchTarget(); for (const DexInstructionPcPair& inst : code_item_accessor_) { const uint32_t dex_pc = inst.DexPc(); - if (!VerifyInstruction<kAllowRuntimeOnlyInstructions>(&inst.Inst(), dex_pc)) { + if (!VerifyInstruction(&inst.Inst(), dex_pc)) { DCHECK_NE(failures_.size(), 0U); return false; } @@ -1499,7 +1493,6 @@ bool MethodVerifier<kVerifierDebug>::VerifyInstructions() { } template <bool kVerifierDebug> -template <bool kAllowRuntimeOnlyInstructions> bool MethodVerifier<kVerifierDebug>::VerifyInstruction(const Instruction* inst, uint32_t code_offset) { bool result = true; @@ -1608,10 +1601,6 @@ bool MethodVerifier<kVerifierDebug>::VerifyInstruction(const Instruction* inst, result = false; break; } - if (!kAllowRuntimeOnlyInstructions && inst->GetVerifyIsRuntimeOnly()) { - Fail(VERIFY_ERROR_BAD_CLASS_HARD) << "opcode only expected at runtime " << inst->Name(); - result = false; - } return result; } diff --git a/test/983-source-transform-verify/source_transform_art.cc b/test/983-source-transform-verify/source_transform_art.cc index 289874b95b..852810474d 100644 --- a/test/983-source-transform-verify/source_transform_art.cc +++ b/test/983-source-transform-verify/source_transform_art.cc @@ -54,7 +54,7 @@ void VerifyClassData(jint class_data_len, const unsigned char* class_data) { for (const ClassAccessor::Method& method : accessor.GetMethods()) { for (const DexInstructionPcPair& pair : method.GetInstructions()) { const Instruction& inst = pair.Inst(); - int forbidden_flags = (Instruction::kVerifyError | Instruction::kVerifyRuntimeOnly); + int forbidden_flags = Instruction::kVerifyError; if ((inst.GetVerifyExtraFlags() & forbidden_flags) != 0) { LOG(FATAL) << "Unexpected instruction found in " << dex->PrettyMethod(method.GetIndex()) << " [Dex PC: 0x" << std::hex << pair.DexPc() << std::dec << "] : " |