From cde6497d286337de2ed21c71c85157e2745b742b Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Tue, 25 Apr 2023 16:40:06 +0000 Subject: Optimizing: Add `HInstruction::As##type()`. After the old implementation was renamed in https://android-review.googlesource.com/2526708 , we introduce a new function with the old name but new behavior, just `DCHECK()`-ing the instruction kind before casting down the pointer. We change appropriate calls from `As##type##OrNull()` to `As##type()` to avoid unncessary run-time checks and reduce the size of libart-compiler.so. Test: m test-art-host-gtest Test: testrunner.py --host --optimizing Test: run-gtests.sh Test: testrunner.py --target --optimizing Bug: 181943478 Change-Id: I025681612a77ca2157fed4886ca47f2053975d4e --- compiler/optimizing/optimizing_unit_test.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'compiler/optimizing/optimizing_unit_test.h') diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h index ceffce9333..2e05c41f01 100644 --- a/compiler/optimizing/optimizing_unit_test.h +++ b/compiler/optimizing/optimizing_unit_test.h @@ -407,9 +407,8 @@ class OptimizingUnitTestHelper { HNewInstance* MakeNewInstance(HInstruction* cls, uint32_t dex_pc = 0u) { EXPECT_TRUE(cls->IsLoadClass() || cls->IsClinitCheck()) << *cls; - // TODO: Remove "OrNull". HLoadClass* load = - cls->IsLoadClass() ? cls->AsLoadClassOrNull() : cls->AsClinitCheckOrNull()->GetLoadClass(); + cls->IsLoadClass() ? cls->AsLoadClass() : cls->AsClinitCheck()->GetLoadClass(); return new (GetAllocator()) HNewInstance(cls, dex_pc, load->GetTypeIndex(), @@ -593,8 +592,7 @@ class PatternMatchGraphVisitor final : public HGraphVisitor { explicit KindWrapper(F f) : f_(f) {} \ void operator()(HInstruction* h) override { \ if constexpr (std::is_invocable_v) { \ - /* TODO: Remove "OrNull". */ \ - f_(h->As##nm##OrNull()); \ + f_(h->As##nm()); \ } else { \ LOG(FATAL) << "Incorrect call with " << #nm; \ } \ -- cgit v1.2.3-59-g8ed1b