From f7bd87edf3b80ce3bbd6e571fd119c878cb79992 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Thu, 23 Dec 2021 18:07:38 +0000 Subject: Add branch profiling in baseline compiler. Currently unused. Follow-up CLs will make use of the data. Test: test.py Bug: 304969871 Change-Id: I486faba3de030061715d06ab9fdb33970d319d9b --- compiler/optimizing/nodes.h | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'compiler/optimizing/nodes.h') diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 3613b9519b..04d51328f2 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2663,7 +2663,12 @@ class HInstruction : public ArenaObject { void RemoveEnvironmentUsers(); bool IsEmittedAtUseSite() const { return GetPackedFlag(); } - void MarkEmittedAtUseSite() { SetPackedFlag(true); } + void MarkEmittedAtUseSite() { + // When compiling baseline, in order to do branch profiling, we don't want to + // emit conditions at use site. + DCHECK(!IsCondition() || !GetBlock()->GetGraph()->IsCompilingBaseline()); + SetPackedFlag(true); + } protected: // If set, the machine code for this instruction is assumed to be generated by @@ -3519,7 +3524,9 @@ class HDoubleConstant final : public HConstant { class HIf final : public HExpression<1> { public: explicit HIf(HInstruction* input, uint32_t dex_pc = kNoDexPc) - : HExpression(kIf, SideEffects::None(), dex_pc) { + : HExpression(kIf, SideEffects::None(), dex_pc), + true_count_(std::numeric_limits::max()), + false_count_(std::numeric_limits::max()) { SetRawInputAt(0, input); } @@ -3534,10 +3541,20 @@ class HIf final : public HExpression<1> { return GetBlock()->GetSuccessors()[1]; } + void SetTrueCount(uint16_t count) { true_count_ = count; } + uint16_t GetTrueCount() const { return true_count_; } + + void SetFalseCount(uint16_t count) { false_count_ = count; } + uint16_t GetFalseCount() const { return false_count_; } + DECLARE_INSTRUCTION(If); protected: DEFAULT_COPY_CONSTRUCTOR(If); + + private: + uint16_t true_count_; + uint16_t false_count_; }; -- cgit v1.2.3-59-g8ed1b