From e19e9db1ddf799b148107568cadfa2fda07116a0 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 3 Dec 2024 12:47:44 +0000 Subject: verifier: Speed up `GetMethodIdxOfInvoke()`. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Bug: 181943478 Change-Id: I28689c4033f9322735b1d1ffe480d6daccb5d159 --- runtime/verifier/method_verifier.cc | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/runtime/verifier/method_verifier.cc b/runtime/verifier/method_verifier.cc index 934d73b4d1..2d9f986059 100644 --- a/runtime/verifier/method_verifier.cc +++ b/runtime/verifier/method_verifier.cc @@ -1021,9 +1021,30 @@ class MethodVerifier final : public ::art::verifier::MethodVerifier { } // Returns the method index of an invoke instruction. - uint16_t GetMethodIdxOfInvoke(const Instruction* inst) + static uint16_t GetMethodIdxOfInvoke(const Instruction* inst) REQUIRES_SHARED(Locks::mutator_lock_) { - return inst->VRegB(); + // Note: This is compiled to a single load in release mode. + Instruction::Code opcode = inst->Opcode(); + if (opcode == Instruction::INVOKE_VIRTUAL || + opcode == Instruction::INVOKE_SUPER || + opcode == Instruction::INVOKE_DIRECT || + opcode == Instruction::INVOKE_STATIC || + opcode == Instruction::INVOKE_INTERFACE || + opcode == Instruction::INVOKE_CUSTOM) { + return inst->VRegB_35c(); + } else if (opcode == Instruction::INVOKE_VIRTUAL_RANGE || + opcode == Instruction::INVOKE_SUPER_RANGE || + opcode == Instruction::INVOKE_DIRECT_RANGE || + opcode == Instruction::INVOKE_STATIC_RANGE || + opcode == Instruction::INVOKE_INTERFACE_RANGE || + opcode == Instruction::INVOKE_CUSTOM_RANGE) { + return inst->VRegB_3rc(); + } else if (opcode == Instruction::INVOKE_POLYMORPHIC) { + return inst->VRegB_45cc(); + } else { + DCHECK_EQ(opcode, Instruction::INVOKE_POLYMORPHIC_RANGE); + return inst->VRegB_4rcc(); + } } // Returns the field index of a field access instruction. uint16_t GetFieldIdxOfFieldAccess(const Instruction* inst, bool is_static) -- cgit v1.2.3-59-g8ed1b