From 0eca098c263e3f93d9996dbd6070a53d09d4a6c6 Mon Sep 17 00:00:00 2001 From: Santiago Aboy Solanes Date: Fri, 8 Apr 2022 18:00:48 +0100 Subject: Enable LoopOptimization for graphs with try catch blocks We can enable the optimization when the graph has try catch blocks, but we do not perform the optimizations if the loops themselves have try catch blocks. Bug: 227283906 Change-Id: I8889d2ed7a5a260d5c2dcbbc5184cb7eaf3a8f9f --- compiler/optimizing/loop_optimization.h | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'compiler/optimizing/loop_optimization.h') diff --git a/compiler/optimizing/loop_optimization.h b/compiler/optimizing/loop_optimization.h index 3acd5b191b..b17861648f 100644 --- a/compiler/optimizing/loop_optimization.h +++ b/compiler/optimizing/loop_optimization.h @@ -57,12 +57,23 @@ class HLoopOptimization : public HOptimization { outer(nullptr), inner(nullptr), previous(nullptr), - next(nullptr) {} + next(nullptr), + try_catch_kind(TryCatchKind::kUnknown) {} + + enum class TryCatchKind { + kUnknown, + // Either if we have a try catch in the loop, or if the loop is inside of an outer try catch, + // we set `kHasTryCatch`. + kHasTryCatch, + kNoTryCatch + }; + HLoopInformation* loop_info; LoopNode* outer; LoopNode* inner; LoopNode* previous; LoopNode* next; + TryCatchKind try_catch_kind; }; /* @@ -131,6 +142,11 @@ class HLoopOptimization : public HOptimization { // Returns true if loops nested inside current loop (node) have changed. bool TraverseLoopsInnerToOuter(LoopNode* node); + // Calculates `node`'s `try_catch_kind` and sets it to: + // 1) kHasTryCatch if it has try catches (or if it's inside of an outer try catch) + // 2) kNoTryCatch otherwise. + void CalculateAndSetTryCatchKind(LoopNode* node); + // // Optimization. // -- cgit v1.2.3-59-g8ed1b