From aa02410a2de17b638a1eb5c664b390c4b1c36aed Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 21 Feb 2024 12:13:01 +0100 Subject: Inliner: Always try code pattern recognition. Try code pattern recognition whenever we're allowed to inline. The pattern recognition is fast and when we find a match, we avoid costly processing, such as building the callee graph. The pattern replacement is always better than the invoke, so do it even when inlining is not "encouraged", for example in blocks that end with a `throw`. Reorder the code so that the pattern recognition respects the @NeverInline annotation. Enable run-test 569 for target and add a test for the @NeverInline annotation. Also remove some duplicated helper functions and reduce the number of arguments we pass around. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: testrunner.py --jvm Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I863fe1190eb38c7decf0c5e34a00c103e8e559f1 --- compiler/dex/inline_method_analyser.h | 41 +++++++---------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) (limited to 'compiler/dex/inline_method_analyser.h') diff --git a/compiler/dex/inline_method_analyser.h b/compiler/dex/inline_method_analyser.h index 99d07c6152..4cd5b824f1 100644 --- a/compiler/dex/inline_method_analyser.h +++ b/compiler/dex/inline_method_analyser.h @@ -21,7 +21,6 @@ #include "base/mutex.h" #include "dex/dex_file.h" #include "dex/dex_instruction.h" -#include "dex/method_reference.h" /* * NOTE: This code is part of the quick compiler. It lives in the runtime @@ -100,47 +99,23 @@ class InlineMethodAnalyser { * * @return true if the method is a candidate for inlining, false otherwise. */ - static bool AnalyseMethodCode(ArtMethod* method, InlineMethod* result) + static bool AnalyseMethodCode(ArtMethod* method, + const CodeItemDataAccessor* code_item, + InlineMethod* result) REQUIRES_SHARED(Locks::mutator_lock_); - static constexpr bool IsInstructionIGet(Instruction::Code opcode) { - return Instruction::IGET <= opcode && opcode <= Instruction::IGET_SHORT; - } - - static constexpr bool IsInstructionIPut(Instruction::Code opcode) { - return Instruction::IPUT <= opcode && opcode <= Instruction::IPUT_SHORT; - } - - static constexpr uint16_t IGetVariant(Instruction::Code opcode) { - return opcode - Instruction::IGET; - } - - static constexpr uint16_t IPutVariant(Instruction::Code opcode) { - return opcode - Instruction::IPUT; - } - // Determines whether the method is a synthetic accessor (method name starts with "access$"). - static bool IsSyntheticAccessor(MethodReference ref); + static bool IsSyntheticAccessor(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_); private: - static bool AnalyseMethodCode(const CodeItemDataAccessor* code_item, - const MethodReference& method_ref, - bool is_static, - ArtMethod* method, - InlineMethod* result) - REQUIRES_SHARED(Locks::mutator_lock_); static bool AnalyseReturnMethod(const CodeItemDataAccessor* code_item, InlineMethod* result); static bool AnalyseConstMethod(const CodeItemDataAccessor* code_item, InlineMethod* result); - static bool AnalyseIGetMethod(const CodeItemDataAccessor* code_item, - const MethodReference& method_ref, - bool is_static, - ArtMethod* method, + static bool AnalyseIGetMethod(ArtMethod* method, + const CodeItemDataAccessor* code_item, InlineMethod* result) REQUIRES_SHARED(Locks::mutator_lock_); - static bool AnalyseIPutMethod(const CodeItemDataAccessor* code_item, - const MethodReference& method_ref, - bool is_static, - ArtMethod* method, + static bool AnalyseIPutMethod(ArtMethod* method, + const CodeItemDataAccessor* code_item, InlineMethod* result) REQUIRES_SHARED(Locks::mutator_lock_); -- cgit v1.2.3-59-g8ed1b