From e872656585952f993eb84633a66e0aedcbdf52ac Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Wed, 7 Feb 2024 11:53:09 +0000 Subject: Only compile optimized if it is useful. If profiling doesn't benefit the method, switch a baseline compilation into optimized. Reduces the number of JIT compilations on the Sheets benchmark from ~3100 (2250 baseline, 850 optimized) to ~2750 (2250 baseline, 500 optimized). Test: test.py Change-Id: I94760481d130d2dc168152daa94429baf201f66e --- compiler/optimizing/nodes.h | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index c862e31de7..367f45f3a4 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -425,6 +425,7 @@ class HGraph : public ArenaObject { cached_current_method_(nullptr), art_method_(nullptr), compilation_kind_(compilation_kind), + useful_optimizing_(false), cha_single_implementation_list_(allocator->Adapter(kArenaAllocCHA)) { blocks_.reserve(kDefaultNumberOfBlocks); } @@ -742,6 +743,9 @@ class HGraph : public ArenaObject { void SetNumberOfCHAGuards(uint32_t num) { number_of_cha_guards_ = num; } void IncrementNumberOfCHAGuards() { number_of_cha_guards_++; } + void SetUsefulOptimizing() { useful_optimizing_ = true; } + bool IsUsefulOptimizing() const { return useful_optimizing_; } + private: void RemoveDeadBlocksInstructionsAsUsersAndDisconnect(const ArenaBitVector& visited) const; void RemoveDeadBlocks(const ArenaBitVector& visited); @@ -897,6 +901,10 @@ class HGraph : public ArenaObject { // directly jump to. const CompilationKind compilation_kind_; + // Whether after compiling baseline it is still useful re-optimizing this + // method. + bool useful_optimizing_; + // List of methods that are assumed to have single implementation. ArenaSet cha_single_implementation_list_; -- cgit v1.2.3-59-g8ed1b