diff options
author | 2023-04-25 16:40:06 +0000 | |
---|---|---|
committer | 2023-04-27 10:53:55 +0000 | |
commit | cde6497d286337de2ed21c71c85157e2745b742b (patch) | |
tree | 087d790efb6987f5aab1da7cd91b89bedcdc5725 /compiler/optimizing/intrinsics_utils.h | |
parent | 79dc217688a774fc532584f6551a0aec8b45bc4a (diff) |
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
Diffstat (limited to 'compiler/optimizing/intrinsics_utils.h')
-rw-r--r-- | compiler/optimizing/intrinsics_utils.h | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/compiler/optimizing/intrinsics_utils.h b/compiler/optimizing/intrinsics_utils.h index 5422275ba7..13cabdafed 100644 --- a/compiler/optimizing/intrinsics_utils.h +++ b/compiler/optimizing/intrinsics_utils.h @@ -63,19 +63,16 @@ class IntrinsicSlowPath : public TSlowPathCode { Location method_loc = MoveArguments(codegen); if (invoke_->IsInvokeStaticOrDirect()) { - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* invoke_static_or_direct = invoke_->AsInvokeStaticOrDirectOrNull(); + HInvokeStaticOrDirect* invoke_static_or_direct = invoke_->AsInvokeStaticOrDirect(); DCHECK_NE(invoke_static_or_direct->GetMethodLoadKind(), MethodLoadKind::kRecursive); DCHECK_NE(invoke_static_or_direct->GetCodePtrLocation(), CodePtrLocation::kCallCriticalNative); codegen->GenerateStaticOrDirectCall(invoke_static_or_direct, method_loc, this); } else if (invoke_->IsInvokeVirtual()) { - // TODO: Remove "OrNull". - codegen->GenerateVirtualCall(invoke_->AsInvokeVirtualOrNull(), method_loc, this); + codegen->GenerateVirtualCall(invoke_->AsInvokeVirtual(), method_loc, this); } else { DCHECK(invoke_->IsInvokePolymorphic()); - // TODO: Remove "OrNull". - codegen->GenerateInvokePolymorphicCall(invoke_->AsInvokePolymorphicOrNull(), this); + codegen->GenerateInvokePolymorphicCall(invoke_->AsInvokePolymorphic(), this); } // Copy the result back to the expected output. @@ -116,8 +113,7 @@ static inline size_t GetExpectedVarHandleCoordinatesCount(HInvoke *invoke) { static inline DataType::Type GetDataTypeFromShorty(HInvoke* invoke, uint32_t index) { DCHECK(invoke->IsInvokePolymorphic()); const DexFile* dex_file = invoke->GetMethodReference().dex_file; - // TODO: Remove "OrNull". - const char* shorty = dex_file->GetShorty(invoke->AsInvokePolymorphicOrNull()->GetProtoIndex()); + const char* shorty = dex_file->GetShorty(invoke->AsInvokePolymorphic()->GetProtoIndex()); DCHECK_LT(index, strlen(shorty)); return DataType::FromShorty(shorty[index]); @@ -210,12 +206,10 @@ static inline ArtField* GetBootImageVarHandleField(HInvoke* invoke) var_handle_instruction = var_handle_instruction->InputAt(0); } DCHECK(var_handle_instruction->IsStaticFieldGet()); - // TODO: Remove "OrNull". - ArtField* field = var_handle_instruction->AsStaticFieldGetOrNull()->GetFieldInfo().GetField(); + ArtField* field = var_handle_instruction->AsStaticFieldGet()->GetFieldInfo().GetField(); DCHECK(field->IsStatic()); DCHECK(field->IsFinal()); - // TODO: Remove "OrNull". - DCHECK(var_handle_instruction->InputAt(0)->AsLoadClassOrNull()->IsInBootImage()); + DCHECK(var_handle_instruction->InputAt(0)->AsLoadClass()->IsInBootImage()); ObjPtr<mirror::Object> var_handle = field->GetObject(field->GetDeclaringClass()); DCHECK(var_handle->GetClass() == (GetExpectedVarHandleCoordinatesCount(invoke) == 0u |