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/bounds_check_elimination.cc | 78 ++--- compiler/optimizing/code_generator.cc | 33 +-- compiler/optimizing/code_generator.h | 24 +- compiler/optimizing/code_generator_arm64.cc | 98 ++----- compiler/optimizing/code_generator_arm_vixl.cc | 79 ++--- compiler/optimizing/code_generator_utils.cc | 7 +- .../optimizing/code_generator_vector_arm64_neon.cc | 49 +--- .../optimizing/code_generator_vector_arm64_sve.cc | 34 +-- .../optimizing/code_generator_vector_arm_vixl.cc | 15 +- compiler/optimizing/code_generator_vector_x86.cc | 9 +- .../optimizing/code_generator_vector_x86_64.cc | 9 +- compiler/optimizing/code_generator_x86.cc | 323 +++++++-------------- compiler/optimizing/code_generator_x86_64.cc | 228 +++++---------- compiler/optimizing/code_sinking.cc | 25 +- compiler/optimizing/common_arm.h | 15 +- compiler/optimizing/common_arm64.h | 10 +- compiler/optimizing/constant_folding.cc | 53 ++-- compiler/optimizing/constant_folding_test.cc | 42 +-- .../optimizing/critical_native_abi_fixup_arm.cc | 6 +- compiler/optimizing/dead_code_elimination.cc | 103 +++---- compiler/optimizing/escape.cc | 6 +- compiler/optimizing/graph_checker.cc | 28 +- compiler/optimizing/graph_test.cc | 66 ++--- compiler/optimizing/graph_visualizer.cc | 22 +- compiler/optimizing/gvn.cc | 6 +- compiler/optimizing/induction_var_analysis.cc | 40 +-- compiler/optimizing/induction_var_range.cc | 19 +- compiler/optimizing/induction_var_range.h | 3 +- compiler/optimizing/induction_var_range_test.cc | 3 +- compiler/optimizing/inliner.cc | 31 +- compiler/optimizing/instruction_builder.cc | 46 +-- compiler/optimizing/instruction_simplifier.cc | 260 ++++++----------- compiler/optimizing/instruction_simplifier_arm.cc | 3 +- .../optimizing/instruction_simplifier_arm64.cc | 6 +- .../optimizing/instruction_simplifier_shared.cc | 37 +-- .../optimizing/instruction_simplifier_shared.h | 13 +- .../instruction_simplifier_x86_shared.cc | 9 +- compiler/optimizing/intrinsics.cc | 15 +- compiler/optimizing/intrinsics.h | 3 +- compiler/optimizing/intrinsics_arm64.cc | 52 ++-- compiler/optimizing/intrinsics_arm_vixl.cc | 12 +- compiler/optimizing/intrinsics_utils.h | 18 +- compiler/optimizing/intrinsics_x86.cc | 106 +++---- compiler/optimizing/intrinsics_x86_64.cc | 69 ++--- compiler/optimizing/live_ranges_test.cc | 18 +- compiler/optimizing/load_store_analysis.cc | 56 ++-- compiler/optimizing/load_store_analysis.h | 6 +- compiler/optimizing/load_store_elimination.cc | 57 ++-- compiler/optimizing/load_store_elimination_test.cc | 22 +- compiler/optimizing/locations.cc | 3 +- compiler/optimizing/loop_optimization.cc | 72 ++--- compiler/optimizing/loop_optimization_test.cc | 3 +- compiler/optimizing/nodes.cc | 145 +++------ compiler/optimizing/nodes.h | 106 +++---- compiler/optimizing/nodes_shared.cc | 15 +- compiler/optimizing/nodes_shared.h | 6 +- compiler/optimizing/nodes_vector.h | 44 +-- compiler/optimizing/nodes_x86.h | 12 +- compiler/optimizing/optimizing_unit_test.h | 6 +- .../optimizing/prepare_for_register_allocation.cc | 27 +- compiler/optimizing/reference_type_propagation.cc | 86 ++---- .../optimizing/reference_type_propagation_test.cc | 12 +- .../optimizing/register_allocation_resolver.cc | 21 +- .../optimizing/register_allocator_graph_color.cc | 12 +- .../optimizing/register_allocator_linear_scan.cc | 16 +- compiler/optimizing/register_allocator_test.cc | 12 +- compiler/optimizing/scheduler.cc | 28 +- compiler/optimizing/scheduler_arm.cc | 12 +- compiler/optimizing/scheduler_arm64.cc | 6 +- compiler/optimizing/select_generator.cc | 25 +- compiler/optimizing/ssa_builder.cc | 82 ++---- compiler/optimizing/ssa_liveness_analysis.cc | 3 +- compiler/optimizing/ssa_phi_elimination.cc | 21 +- compiler/optimizing/superblock_cloner.cc | 42 +-- compiler/optimizing/superblock_cloner_test.cc | 3 +- compiler/optimizing/write_barrier_elimination.cc | 21 +- 76 files changed, 1032 insertions(+), 2081 deletions(-) diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc index 6b3d06e4fc..c0d4c37659 100644 --- a/compiler/optimizing/bounds_check_elimination.cc +++ b/compiler/optimizing/bounds_check_elimination.cc @@ -37,8 +37,7 @@ class ValueBound : public ValueObject { ValueBound(HInstruction* instruction, int32_t constant) { if (instruction != nullptr && instruction->IsIntConstant()) { // Normalize ValueBound with constant instruction. - // TODO: Remove "OrNull". - int32_t instr_const = instruction->AsIntConstantOrNull()->GetValue(); + int32_t instr_const = instruction->AsIntConstant()->GetValue(); if (!WouldAddOverflowOrUnderflow(instr_const, constant)) { instruction_ = nullptr; constant_ = instr_const + constant; @@ -72,13 +71,11 @@ class ValueBound : public ValueObject { HInstruction* left_so_far = nullptr; int32_t right_so_far = 0; while (instruction->IsAdd() || instruction->IsSub()) { - // TODO: Remove "OrNull". - HBinaryOperation* bin_op = instruction->AsBinaryOperationOrNull(); + HBinaryOperation* bin_op = instruction->AsBinaryOperation(); HInstruction* left = bin_op->GetLeft(); HInstruction* right = bin_op->GetRight(); if (right->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t v = right->AsIntConstantOrNull()->GetValue(); + int32_t v = right->AsIntConstant()->GetValue(); int32_t c = instruction->IsAdd() ? v : -v; if (!WouldAddOverflowOrUnderflow(right_so_far, c)) { instruction = left; @@ -98,8 +95,7 @@ class ValueBound : public ValueObject { // Expresses any instruction as a value bound. static ValueBound AsValueBound(HInstruction* instruction) { if (instruction->IsIntConstant()) { - // TODO: Remove "OrNull". - return ValueBound(nullptr, instruction->AsIntConstantOrNull()->GetValue()); + return ValueBound(nullptr, instruction->AsIntConstant()->GetValue()); } HInstruction *left; int32_t right; @@ -115,8 +111,7 @@ class ValueBound : public ValueObject { DCHECK(instruction != nullptr); if (instruction->IsIntConstant()) { *found = true; - // TODO: Remove "OrNull". - return ValueBound(nullptr, instruction->AsIntConstantOrNull()->GetValue()); + return ValueBound(nullptr, instruction->AsIntConstant()->GetValue()); } if (instruction->IsArrayLength()) { @@ -446,8 +441,7 @@ class MonotonicValueRange : public ValueRange { // Be conservative first, assume last number in the sequence hits upper. int32_t last_num_in_sequence = upper; if (initial_->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t initial_constant = initial_->AsIntConstantOrNull()->GetValue(); + int32_t initial_constant = initial_->AsIntConstant()->GetValue(); if (upper <= initial_constant) { last_num_in_sequence = upper; } else { @@ -883,14 +877,12 @@ class BCEVisitor final : public HGraphVisitor { } } else { // Constant index. - // TODO: Remove "OrNull". - int32_t constant = index->AsIntConstantOrNull()->GetValue(); + int32_t constant = index->AsIntConstant()->GetValue(); if (constant < 0) { // Will always throw exception. return; } else if (array_length->IsIntConstant()) { - // TODO: Remove "OrNull". - if (constant < array_length->AsIntConstantOrNull()->GetValue()) { + if (constant < array_length->AsIntConstant()->GetValue()) { ReplaceInstruction(bounds_check, index); } return; @@ -1017,8 +1009,7 @@ class BCEVisitor final : public HGraphVisitor { void VisitIf(HIf* instruction) override { if (instruction->InputAt(0)->IsCondition()) { - // TODO: Remove "OrNull". - HCondition* cond = instruction->InputAt(0)->AsConditionOrNull(); + HCondition* cond = instruction->InputAt(0)->AsCondition(); HandleIf(instruction, cond->GetLeft(), cond->GetRight(), cond->GetCondition()); } } @@ -1060,24 +1051,20 @@ class BCEVisitor final : public HGraphVisitor { if (!mul->GetLeft()->IsDiv() || !mul->GetRight()->IsConstant()) { return false; } - // TODO: Remove "OrNull". - div = mul->GetLeft()->AsDivOrNull(); - // TODO: Remove "OrNull". - const_divisor = Int64FromConstant(mul->GetRight()->AsConstantOrNull()); + div = mul->GetLeft()->AsDiv(); + const_divisor = Int64FromConstant(mul->GetRight()->AsConstant()); } else if (HAdd* add = instruction->GetRight()->AsAddOrNull()) { HShl* shl = add->GetRight()->AsShlOrNull(); if (!is_needed_shl(shl)) { return false; } - // TODO: Remove "OrNull". - div = shl->GetLeft()->AsDivOrNull(); + div = shl->GetLeft()->AsDiv(); if (add->GetLeft() != div) { return false; } - // TODO: Remove "OrNull". - int32_t n = shl->GetRight()->AsIntConstantOrNull()->GetValue(); + int32_t n = shl->GetRight()->AsIntConstant()->GetValue(); if (n == BitSizeOf() - 1) { // 2^n + 1 will be negative. return false; @@ -1089,14 +1076,12 @@ class BCEVisitor final : public HGraphVisitor { return false; } - // TODO: Remove "OrNull". - div = shl->GetLeft()->AsDivOrNull(); + div = shl->GetLeft()->AsDiv(); if (sub->GetRight() != div) { return false; } - // TODO: Remove "OrNull". - int32_t n = shl->GetRight()->AsIntConstantOrNull()->GetValue(); + int32_t n = shl->GetRight()->AsIntConstant()->GetValue(); const_divisor = (1LL << n) - 1; } @@ -1133,8 +1118,7 @@ class BCEVisitor final : public HGraphVisitor { if (left_range == nullptr) { return; } - // TODO: Remove "OrNull". - ValueRange* range = left_range->Add(right->AsIntConstantOrNull()->GetValue()); + ValueRange* range = left_range->Add(right->AsIntConstant()->GetValue()); if (range != nullptr) { AssignRange(add->GetBlock(), add, range); } @@ -1153,8 +1137,7 @@ class BCEVisitor final : public HGraphVisitor { if (left_range == nullptr) { return; } - // TODO: Remove "OrNull". - ValueRange* range = left_range->Add(-right->AsIntConstantOrNull()->GetValue()); + ValueRange* range = left_range->Add(-right->AsIntConstant()->GetValue()); if (range != nullptr) { AssignRange(sub->GetBlock(), sub, range); return; @@ -1174,8 +1157,7 @@ class BCEVisitor final : public HGraphVisitor { // The value of left input of the sub equals (left + right_const). if (left->IsArrayLength()) { - // TODO: Remove "OrNull". - HInstruction* array_length = left->AsArrayLengthOrNull(); + HInstruction* array_length = left->AsArrayLength(); ValueRange* right_range = LookupValueRange(right, sub->GetBlock()); if (right_range != nullptr) { ValueBound lower = right_range->GetLower(); @@ -1211,8 +1193,7 @@ class BCEVisitor final : public HGraphVisitor { HInstruction* right = instruction->GetRight(); int32_t right_const; if (right->IsIntConstant()) { - // TODO: Remove "OrNull". - right_const = right->AsIntConstantOrNull()->GetValue(); + right_const = right->AsIntConstant()->GetValue(); // Detect division by two or more. if ((instruction->IsDiv() && right_const <= 1) || (instruction->IsShr() && right_const < 1) || @@ -1264,8 +1245,7 @@ class BCEVisitor final : public HGraphVisitor { void VisitAnd(HAnd* instruction) override { if (instruction->GetRight()->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t constant = instruction->GetRight()->AsIntConstantOrNull()->GetValue(); + int32_t constant = instruction->GetRight()->AsIntConstant()->GetValue(); if (constant > 0) { // constant serves as a mask so any number masked with it // gets a [0, constant] value range. @@ -1285,8 +1265,7 @@ class BCEVisitor final : public HGraphVisitor { // Handle 'i % CONST' format expression in array index, e.g: // array[i % 20]; if (right->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t right_const = std::abs(right->AsIntConstantOrNull()->GetValue()); + int32_t right_const = std::abs(right->AsIntConstant()->GetValue()); if (right_const == 0) { return; } @@ -1318,8 +1297,7 @@ class BCEVisitor final : public HGraphVisitor { if (right->IsDivZeroCheck()) { // if array_length can pass div-by-zero check, // array_length must be > 0. - // TODO: Remove "OrNull". - right = right->AsDivZeroCheckOrNull()->InputAt(0); + right = right->AsDivZeroCheck()->InputAt(0); } // Handle 'i % array.length' format expression in array index, e.g: @@ -1456,8 +1434,7 @@ class BCEVisitor final : public HGraphVisitor { HInstruction* user = use.GetUser(); HBasicBlock* other_block = user->GetBlock(); if (user->IsBoundsCheck() && block->Dominates(other_block)) { - // TODO: Remove "OrNull". - HBoundsCheck* other_bounds_check = user->AsBoundsCheckOrNull(); + HBoundsCheck* other_bounds_check = user->AsBoundsCheck(); HInstruction* other_index = other_bounds_check->InputAt(0); HInstruction* other_array_length = other_bounds_check->InputAt(1); ValueBound other_value = ValueBound::AsValueBound(other_index); @@ -1575,8 +1552,7 @@ class BCEVisitor final : public HGraphVisitor { for (const HUseListNode& use : array_length->GetUses()) { HInstruction* user = use.GetUser(); if (user->IsBoundsCheck() && loop == user->GetBlock()->GetLoopInformation()) { - // TODO: Remove "OrNull". - HBoundsCheck* other_bounds_check = user->AsBoundsCheckOrNull(); + HBoundsCheck* other_bounds_check = user->AsBoundsCheck(); HInstruction* other_index = other_bounds_check->InputAt(0); HInstruction* other_array_length = other_bounds_check->InputAt(1); ValueBound other_value = ValueBound::AsValueBound(other_index); @@ -1811,11 +1787,9 @@ class BCEVisitor final : public HGraphVisitor { // ensure upper bound cannot cause an infinite loop. HInstruction* control = loop->GetHeader()->GetLastInstruction(); if (control->IsIf()) { - // TODO: Remove "OrNull". - HInstruction* if_expr = control->AsIfOrNull()->InputAt(0); + HInstruction* if_expr = control->AsIf()->InputAt(0); if (if_expr->IsCondition()) { - // TODO: Remove "OrNull". - HCondition* condition = if_expr->AsConditionOrNull(); + HCondition* condition = if_expr->AsCondition(); if (index == condition->InputAt(0) || index == condition->InputAt(1)) { finite_loop_.insert(loop_id); diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index 07f018b0a9..f90f17f8f5 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -514,8 +514,7 @@ void CodeGenerator::CreateCommonInvokeLocationSummary( locations->SetOut(visitor->GetReturnLocation(invoke->GetType())); if (invoke->IsInvokeStaticOrDirect()) { - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* call = invoke->AsInvokeStaticOrDirectOrNull(); + HInvokeStaticOrDirect* call = invoke->AsInvokeStaticOrDirect(); MethodLoadKind method_load_kind = call->GetMethodLoadKind(); CodePtrLocation code_ptr_location = call->GetCodePtrLocation(); if (code_ptr_location == CodePtrLocation::kCallCriticalNative) { @@ -999,8 +998,7 @@ void CodeGenerator::AllocateLocations(HInstruction* instruction) { } } else if (locations->Intrinsified() && instruction->IsInvokeStaticOrDirect() && - // TODO: Remove "OrNull". - !instruction->AsInvokeStaticOrDirectOrNull()->HasCurrentMethodInput()) { + !instruction->AsInvokeStaticOrDirect()->HasCurrentMethodInput()) { // A static method call that has been fully intrinsified, and cannot call on the slow // path or refer to the current method directly, no longer needs current method. return; @@ -1234,8 +1232,7 @@ void CodeGenerator::RecordPcInfo(HInstruction* instruction, return; } if (instruction->IsRem()) { - // TODO: Remove "OrNull". - DataType::Type type = instruction->AsRemOrNull()->GetResultType(); + DataType::Type type = instruction->AsRem()->GetResultType(); if ((type == DataType::Type::kFloat32) || (type == DataType::Type::kFloat64)) { return; } @@ -1358,8 +1355,7 @@ void CodeGenerator::RecordCatchBlockInfo() { dex_pc_list_for_verification.push_back(block->GetDexPc()); } DCHECK(block->GetFirstInstruction()->IsNop()); - // TODO: Remove "OrNull". - DCHECK(block->GetFirstInstruction()->AsNopOrNull()->NeedsEnvironment()); + DCHECK(block->GetFirstInstruction()->AsNop()->NeedsEnvironment()); HEnvironment* const environment = block->GetFirstInstruction()->GetEnvironment(); DCHECK(environment != nullptr); HEnvironment* outer_environment = environment; @@ -1418,29 +1414,25 @@ void CodeGenerator::EmitVRegInfo(HEnvironment* environment, case Location::kConstant: { DCHECK_EQ(current, location.GetConstant()); if (current->IsLongConstant()) { - // TODO: Remove "OrNull". - int64_t value = current->AsLongConstantOrNull()->GetValue(); + int64_t value = current->AsLongConstant()->GetValue(); stack_map_stream->AddDexRegisterEntry(Kind::kConstant, Low32Bits(value)); stack_map_stream->AddDexRegisterEntry(Kind::kConstant, High32Bits(value)); ++i; DCHECK_LT(i, environment_size); } else if (current->IsDoubleConstant()) { - // TODO: Remove "OrNull". - int64_t value = bit_cast(current->AsDoubleConstantOrNull()->GetValue()); + int64_t value = bit_cast(current->AsDoubleConstant()->GetValue()); stack_map_stream->AddDexRegisterEntry(Kind::kConstant, Low32Bits(value)); stack_map_stream->AddDexRegisterEntry(Kind::kConstant, High32Bits(value)); ++i; DCHECK_LT(i, environment_size); } else if (current->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t value = current->AsIntConstantOrNull()->GetValue(); + int32_t value = current->AsIntConstant()->GetValue(); stack_map_stream->AddDexRegisterEntry(Kind::kConstant, value); } else if (current->IsNullConstant()) { stack_map_stream->AddDexRegisterEntry(Kind::kConstant, 0); } else { DCHECK(current->IsFloatConstant()) << current->DebugName(); - // TODO: Remove "OrNull". - int32_t value = bit_cast(current->AsFloatConstantOrNull()->GetValue()); + int32_t value = bit_cast(current->AsFloatConstant()->GetValue()); stack_map_stream->AddDexRegisterEntry(Kind::kConstant, value); } break; @@ -1564,18 +1556,15 @@ void CodeGenerator::EmitVRegInfoOnlyCatchPhis(HEnvironment* environment) { DCHECK_EQ(environment->GetHolder()->GetBlock()->GetFirstInstruction(), environment->GetHolder()); HInstruction* current_phi = environment->GetHolder()->GetBlock()->GetFirstPhi(); for (size_t vreg = 0; vreg < environment->Size(); ++vreg) { - // TODO: Remove "OrNull". - while (current_phi != nullptr && current_phi->AsPhiOrNull()->GetRegNumber() < vreg) { + while (current_phi != nullptr && current_phi->AsPhi()->GetRegNumber() < vreg) { HInstruction* next_phi = current_phi->GetNext(); DCHECK(next_phi == nullptr || - // TODO: Remove "OrNull". - current_phi->AsPhiOrNull()->GetRegNumber() <= next_phi->AsPhiOrNull()->GetRegNumber()) + current_phi->AsPhi()->GetRegNumber() <= next_phi->AsPhi()->GetRegNumber()) << "Phis need to be sorted by vreg number to keep this a linear-time loop."; current_phi = next_phi; } - // TODO: Remove "OrNull". - if (current_phi == nullptr || current_phi->AsPhiOrNull()->GetRegNumber() != vreg) { + if (current_phi == nullptr || current_phi->AsPhi()->GetRegNumber() != vreg) { stack_map_stream->AddDexRegisterEntry(DexRegisterLocation::Kind::kNone, 0); } else { Location location = current_phi->GetLocations()->Out(); diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 59ae213960..9872efaa4a 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -552,45 +552,37 @@ class CodeGenerator : public DeletableArenaObject { static int8_t GetInt8ValueOf(HConstant* constant) { DCHECK(constant->IsIntConstant()); - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } static int16_t GetInt16ValueOf(HConstant* constant) { DCHECK(constant->IsIntConstant()); - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } static int32_t GetInt32ValueOf(HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } else if (constant->IsNullConstant()) { return 0; } else { DCHECK(constant->IsFloatConstant()); - // TODO: Remove "OrNull". - return bit_cast(constant->AsFloatConstantOrNull()->GetValue()); + return bit_cast(constant->AsFloatConstant()->GetValue()); } } static int64_t GetInt64ValueOf(HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } else if (constant->IsNullConstant()) { return 0; } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - return bit_cast(constant->AsFloatConstantOrNull()->GetValue()); + return bit_cast(constant->AsFloatConstant()->GetValue()); } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - return constant->AsLongConstantOrNull()->GetValue(); + return constant->AsLongConstant()->GetValue(); } else { DCHECK(constant->IsDoubleConstant()); - // TODO: Remove "OrNull". - return bit_cast(constant->AsDoubleConstantOrNull()->GetValue()); + return bit_cast(constant->AsDoubleConstant()->GetValue()); } } diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc index cfe33fc350..9b33712810 100644 --- a/compiler/optimizing/code_generator_arm64.cc +++ b/compiler/optimizing/code_generator_arm64.cc @@ -225,8 +225,7 @@ class BoundsCheckSlowPathARM64 : public SlowPathCodeARM64 { locations->InAt(1), LocationFrom(calling_convention.GetRegisterAt(1)), DataType::Type::kInt32); - // TODO: Remove "OrNull". - QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt() + QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt() ? kQuickThrowStringBounds : kQuickThrowArrayBounds; arm64_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this); @@ -341,8 +340,7 @@ class LoadStringSlowPathARM64 : public SlowPathCodeARM64 { SaveLiveRegisters(codegen, locations); InvokeRuntimeCallingConvention calling_convention; - // TODO: Remove "OrNull". - const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex(); + const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex(); __ Mov(calling_convention.GetRegisterAt(0).W(), string_index.index_); arm64_codegen->InvokeRuntime(kQuickResolveString, instruction_, instruction_->GetDexPc(), this); CheckEntrypointTypes(); @@ -494,8 +492,7 @@ class DeoptimizationSlowPathARM64 : public SlowPathCodeARM64 { SaveLiveRegisters(codegen, locations); InvokeRuntimeCallingConvention calling_convention; __ Mov(calling_convention.GetRegisterAt(0), - // TODO: Remove "OrNull". - static_cast(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind())); + static_cast(instruction_->AsDeoptimize()->GetDeoptimizationKind())); arm64_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this); CheckEntrypointTypes(); } @@ -618,8 +615,7 @@ class ReadBarrierForHeapReferenceSlowPathARM64 : public SlowPathCodeARM64 { // instructions does not support the HIntermediateAddress // instruction. DCHECK(!(instruction_->IsArrayGet() && - // TODO: Remove "OrNull". - instruction_->AsArrayGetOrNull()->GetArray()->IsIntermediateAddress())); + instruction_->AsArrayGet()->GetArray()->IsIntermediateAddress())); __ Bind(GetEntryLabel()); @@ -683,8 +679,7 @@ class ReadBarrierForHeapReferenceSlowPathARM64 : public SlowPathCodeARM64 { // object. DCHECK(instruction_->IsInvoke()) << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - HInvoke* invoke = instruction_->AsInvokeOrNull(); + HInvoke* invoke = instruction_->AsInvoke(); DCHECK(IsUnsafeGetObject(invoke) || IsVarHandleGet(invoke) || IsUnsafeCASObject(invoke) || @@ -1565,20 +1560,16 @@ const Arm64InstructionSetFeatures& CodeGeneratorARM64::GetInstructionSetFeatures void CodeGeneratorARM64::MoveConstant(CPURegister destination, HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - __ Mov(Register(destination), constant->AsIntConstantOrNull()->GetValue()); + __ Mov(Register(destination), constant->AsIntConstant()->GetValue()); } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - __ Mov(Register(destination), constant->AsLongConstantOrNull()->GetValue()); + __ Mov(Register(destination), constant->AsLongConstant()->GetValue()); } else if (constant->IsNullConstant()) { __ Mov(Register(destination), 0); } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - __ Fmov(VRegister(destination), constant->AsFloatConstantOrNull()->GetValue()); + __ Fmov(VRegister(destination), constant->AsFloatConstant()->GetValue()); } else { DCHECK(constant->IsDoubleConstant()); - // TODO: Remove "OrNull". - __ Fmov(VRegister(destination), constant->AsDoubleConstantOrNull()->GetValue()); + __ Fmov(VRegister(destination), constant->AsDoubleConstant()->GetValue()); } } @@ -2271,9 +2262,7 @@ void InstructionCodeGeneratorARM64::HandleFieldSet(HInstruction* instruction, WriteBarrierKind write_barrier_kind) { DCHECK(instruction->IsInstanceFieldSet() || instruction->IsStaticFieldSet()); bool is_predicated = - instruction->IsInstanceFieldSet() && - // TODO: Remove "OrNull". - instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet(); + instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet(); Register obj = InputRegisterAt(instruction, 0); CPURegister value = InputCPURegisterOrZeroRegAt(instruction, 1); @@ -2540,8 +2529,7 @@ void InstructionCodeGeneratorARM64::VisitDataProcWithShifterOp( __ And(out, left, right_operand); break; case HInstruction::kNeg: - // TODO: Remove "OrNull". - DCHECK(instruction->InputAt(0)->AsConstantOrNull()->IsArithmeticZero()); + DCHECK(instruction->InputAt(0)->AsConstant()->IsArithmeticZero()); __ Neg(out, right_operand); break; case HInstruction::kOr: @@ -2577,8 +2565,7 @@ void LocationsBuilderARM64::VisitIntermediateAddressIndex(HIntermediateAddressIn LocationSummary* locations = new (GetGraph()->GetAllocator()) LocationSummary(instruction, LocationSummary::kNoCall); - // TODO: Remove "OrNull". - HIntConstant* shift = instruction->GetShift()->AsIntConstantOrNull(); + HIntConstant* shift = instruction->GetShift()->AsIntConstant(); locations->SetInAt(0, Location::RequiresRegister()); // For byte case we don't need to shift the index variable so we can encode the data offset into @@ -2596,8 +2583,7 @@ void InstructionCodeGeneratorARM64::VisitIntermediateAddressIndex( HIntermediateAddressIndex* instruction) { Register index_reg = InputRegisterAt(instruction, 0); uint32_t shift = Int64FromLocation(instruction->GetLocations()->InAt(2)); - // TODO: Remove "OrNull". - uint32_t offset = instruction->GetOffset()->AsIntConstantOrNull()->GetValue(); + uint32_t offset = instruction->GetOffset()->AsIntConstant()->GetValue(); if (shift == 0) { __ Add(OutputRegister(instruction), index_reg, offset); @@ -2613,8 +2599,7 @@ void LocationsBuilderARM64::VisitMultiplyAccumulate(HMultiplyAccumulate* instr) HInstruction* accumulator = instr->InputAt(HMultiplyAccumulate::kInputAccumulatorIndex); if (instr->GetOpKind() == HInstruction::kSub && accumulator->IsConstant() && - // TODO: Remove "OrNull". - accumulator->AsConstantOrNull()->IsArithmeticZero()) { + accumulator->AsConstant()->IsArithmeticZero()) { // Don't allocate register for Mneg instruction. } else { locations->SetInAt(HMultiplyAccumulate::kInputAccumulatorIndex, @@ -2651,8 +2636,7 @@ void InstructionCodeGeneratorARM64::VisitMultiplyAccumulate(HMultiplyAccumulate* } else { DCHECK(instr->GetOpKind() == HInstruction::kSub); HInstruction* accum_instr = instr->InputAt(HMultiplyAccumulate::kInputAccumulatorIndex); - // TODO: Remove "OrNull". - if (accum_instr->IsConstant() && accum_instr->AsConstantOrNull()->IsArithmeticZero()) { + if (accum_instr->IsConstant() && accum_instr->AsConstant()->IsArithmeticZero()) { __ Mneg(res, mul_left, mul_right); } else { Register accumulator = InputRegisterAt(instr, HMultiplyAccumulate::kInputAccumulatorIndex); @@ -2677,8 +2661,7 @@ void LocationsBuilderARM64::VisitArrayGet(HArrayGet* instruction) { // CodeGeneratorARM64::GenerateFieldLoadWithBakerReadBarrier() // only if the offset is too big. uint32_t offset = CodeGenerator::GetArrayDataOffset(instruction); - // TODO: Remove "OrNull". - uint32_t index = instruction->GetIndex()->AsIntConstantOrNull()->GetValue(); + uint32_t index = instruction->GetIndex()->AsIntConstant()->GetValue(); offset += index << DataType::SizeShift(DataType::Type::kReference); if (offset >= kReferenceLoadMinFarOffset) { locations->AddTemp(FixedTempLocation()); @@ -2792,11 +2775,8 @@ void InstructionCodeGeneratorARM64::VisitArrayGet(HArrayGet* instruction) { // input instruction has done it already. See the comment in // `TryExtractArrayAccessAddress()`. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HIntermediateAddress* interm_addr = - instruction->GetArray()->AsIntermediateAddressOrNull(); - // TODO: Remove "OrNull". - DCHECK_EQ(interm_addr->GetOffset()->AsIntConstantOrNull()->GetValueAsUint64(), offset); + HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddress(); + DCHECK_EQ(interm_addr->GetOffset()->AsIntConstant()->GetValueAsUint64(), offset); } temp = obj; } else { @@ -2907,11 +2887,8 @@ void InstructionCodeGeneratorARM64::VisitArraySet(HArraySet* instruction) { // input instruction has done it already. See the comment in // `TryExtractArrayAccessAddress()`. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HIntermediateAddress* interm_addr = - instruction->GetArray()->AsIntermediateAddressOrNull(); - // TODO: Remove "OrNull". - DCHECK(interm_addr->GetOffset()->AsIntConstantOrNull()->GetValueAsUint64() == offset); + HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddress(); + DCHECK(interm_addr->GetOffset()->AsIntConstant()->GetValueAsUint64() == offset); } temp = array; } else { @@ -3122,9 +3099,8 @@ void InstructionCodeGeneratorARM64::VisitClinitCheck(HClinitCheck* check) { } static bool IsFloatingPointZeroConstant(HInstruction* inst) { - // TODO: Remove "OrNull". - return (inst->IsFloatConstant() && (inst->AsFloatConstantOrNull()->IsArithmeticZero())) - || (inst->IsDoubleConstant() && (inst->AsDoubleConstantOrNull()->IsArithmeticZero())); + return (inst->IsFloatConstant() && (inst->AsFloatConstant()->IsArithmeticZero())) + || (inst->IsDoubleConstant() && (inst->AsDoubleConstant()->IsArithmeticZero())); } void InstructionCodeGeneratorARM64::GenerateFcmp(HInstruction* instruction) { @@ -3708,8 +3684,7 @@ void InstructionCodeGeneratorARM64::HandleGoto(HInstruction* got, HBasicBlock* s return; // `GenerateSuspendCheck()` emitted the jump. } if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { - // TODO: Remove "OrNull". - GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr); + GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); codegen_->MaybeGenerateMarkingRegisterCheck(/* code= */ __LINE__); } if (!codegen_->GoesToNextBlock(block, successor)) { @@ -3747,14 +3722,12 @@ void InstructionCodeGeneratorARM64::GenerateTestAndBranch(HInstruction* instruct return; } else if (cond->IsIntConstant()) { // Constant condition, statically compared against "true" (integer value 1). - // TODO: Remove "OrNull". - if (cond->AsIntConstantOrNull()->IsTrue()) { + if (cond->AsIntConstant()->IsTrue()) { if (true_target != nullptr) { __ B(true_target); } } else { - // TODO: Remove "OrNull". - DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << cond->AsIntConstantOrNull()->GetValue(); + DCHECK(cond->AsIntConstant()->IsFalse()) << cond->AsIntConstant()->GetValue(); if (false_target != nullptr) { __ B(false_target); } @@ -3782,8 +3755,7 @@ void InstructionCodeGeneratorARM64::GenerateTestAndBranch(HInstruction* instruct } else { // The condition instruction has not been materialized, use its inputs as // the comparison and its condition as the branch condition. - // TODO: Remove "OrNull". - HCondition* condition = cond->AsConditionOrNull(); + HCondition* condition = cond->AsCondition(); DataType::Type type = condition->InputAt(0)->GetType(); if (DataType::IsFloatingPointType(type)) { @@ -3952,20 +3924,17 @@ void InstructionCodeGeneratorARM64::VisitSelect(HSelect* select) { if (IsBooleanValueOrMaterializedCondition(cond)) { if (cond->IsCondition() && cond->GetNext() == select) { // Use the condition flags set by the previous instruction. - // TODO: Remove "OrNull". - csel_cond = GetConditionForSelect(cond->AsConditionOrNull()); + csel_cond = GetConditionForSelect(cond->AsCondition()); } else { __ Cmp(InputRegisterAt(select, 2), 0); csel_cond = ne; } } else if (IsConditionOnFloatingPointValues(cond)) { GenerateFcmp(cond); - // TODO: Remove "OrNull". - csel_cond = GetConditionForSelect(cond->AsConditionOrNull()); + csel_cond = GetConditionForSelect(cond->AsCondition()); } else { __ Cmp(InputRegisterAt(cond, 0), InputOperandAt(cond, 1)); - // TODO: Remove "OrNull". - csel_cond = GetConditionForSelect(cond->AsConditionOrNull()); + csel_cond = GetConditionForSelect(cond->AsCondition()); } if (DataType::IsFloatingPointType(select->GetType())) { @@ -5968,8 +5937,7 @@ void LocationsBuilderARM64::VisitParallelMove(HParallelMove* instruction ATTRIBU void InstructionCodeGeneratorARM64::VisitParallelMove(HParallelMove* instruction) { if (instruction->GetNext()->IsSuspendCheck() && instruction->GetBlock()->GetLoopInformation() != nullptr) { - // TODO: Remove "OrNull". - HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull(); + HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck(); // The back edge will generate the suspend check. codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction); } @@ -6909,10 +6877,8 @@ void CodeGeneratorARM64::GenerateArrayLoadWithBakerReadBarrier(HArrayGet* instru // input instruction has done it already. See the comment in // `TryExtractArrayAccessAddress()`. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddressOrNull(); - // TODO: Remove "OrNull". - DCHECK_EQ(interm_addr->GetOffset()->AsIntConstantOrNull()->GetValueAsUint64(), data_offset); + HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddress(); + DCHECK_EQ(interm_addr->GetOffset()->AsIntConstant()->GetValueAsUint64(), data_offset); } temp = obj; } else { diff --git a/compiler/optimizing/code_generator_arm_vixl.cc b/compiler/optimizing/code_generator_arm_vixl.cc index c13708a7e4..1e1aee99aa 100644 --- a/compiler/optimizing/code_generator_arm_vixl.cc +++ b/compiler/optimizing/code_generator_arm_vixl.cc @@ -492,8 +492,7 @@ class BoundsCheckSlowPathARMVIXL : public SlowPathCodeARMVIXL { locations->InAt(1), LocationFrom(calling_convention.GetRegisterAt(1)), DataType::Type::kInt32); - // TODO: Remove "OrNull". - QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt() + QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt() ? kQuickThrowStringBounds : kQuickThrowArrayBounds; arm_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this); @@ -579,12 +578,10 @@ class LoadStringSlowPathARMVIXL : public SlowPathCodeARMVIXL { void EmitNativeCode(CodeGenerator* codegen) override { DCHECK(instruction_->IsLoadString()); - // TODO: Remove "OrNull". - DCHECK_EQ(instruction_->AsLoadStringOrNull()->GetLoadKind(), HLoadString::LoadKind::kBssEntry); + DCHECK_EQ(instruction_->AsLoadString()->GetLoadKind(), HLoadString::LoadKind::kBssEntry); LocationSummary* locations = instruction_->GetLocations(); DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg())); - // TODO: Remove "OrNull". - const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex(); + const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex(); CodeGeneratorARMVIXL* arm_codegen = down_cast(codegen); __ Bind(GetEntryLabel()); @@ -678,8 +675,7 @@ class DeoptimizationSlowPathARMVIXL : public SlowPathCodeARMVIXL { SaveLiveRegisters(codegen, locations); InvokeRuntimeCallingConventionARMVIXL calling_convention; __ Mov(calling_convention.GetRegisterAt(0), - // TODO: Remove "OrNull". - static_cast(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind())); + static_cast(instruction_->AsDeoptimize()->GetDeoptimizationKind())); arm_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this); CheckEntrypointTypes(); @@ -780,8 +776,7 @@ class ReadBarrierForHeapReferenceSlowPathARMVIXL : public SlowPathCodeARMVIXL { // instructions does not support the HIntermediateAddress // instruction. DCHECK(!(instruction_->IsArrayGet() && - // TODO: Remove "OrNull". - instruction_->AsArrayGetOrNull()->GetArray()->IsIntermediateAddress())); + instruction_->AsArrayGet()->GetArray()->IsIntermediateAddress())); __ Bind(GetEntryLabel()); SaveLiveRegisters(codegen, locations); @@ -844,8 +839,7 @@ class ReadBarrierForHeapReferenceSlowPathARMVIXL : public SlowPathCodeARMVIXL { // object. DCHECK(instruction_->IsInvoke()) << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - HInvoke* invoke = instruction_->AsInvokeOrNull(); + HInvoke* invoke = instruction_->AsInvoke(); DCHECK(IsUnsafeGetObject(invoke) || IsVarHandleGet(invoke) || IsVarHandleCASFamily(invoke)) << invoke->GetIntrinsic(); DCHECK_EQ(offset_, 0U); @@ -1853,8 +1847,7 @@ static bool CanEncodeConstantAs8BitImmediate(HConstant* constant) { static Location Arm8BitEncodableConstantOrRegister(HInstruction* constant) { DCHECK(!DataType::IsFloatingPointType(constant->GetType())); - // TODO: Remove "OrNull". - if (constant->IsConstant() && CanEncodeConstantAs8BitImmediate(constant->AsConstantOrNull())) { + if (constant->IsConstant() && CanEncodeConstantAs8BitImmediate(constant->AsConstant())) { return Location::ConstantLocation(constant); } @@ -1908,8 +1901,7 @@ vixl32::Label* CodeGeneratorARMVIXL::GetFinalLabel(HInstruction* instruction, if (next->IsGoto() && (info == nullptr || !info->IsBackEdge(*block) || !info->HasSuspendCheck())) { - // TODO: Remove "OrNull". - final_label = GetLabelOf(next->AsGotoOrNull()->GetSuccessor()); + final_label = GetLabelOf(next->AsGoto()->GetSuccessor()); } return final_label; @@ -2801,8 +2793,7 @@ void InstructionCodeGeneratorARMVIXL::HandleGoto(HInstruction* got, HBasicBlock* return; } if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { - // TODO: Remove "OrNull". - GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr); + GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); codegen_->MaybeGenerateMarkingRegisterCheck(/* code= */ 2); } if (!codegen_->GoesToNextBlock(block, successor)) { @@ -2886,14 +2877,12 @@ void InstructionCodeGeneratorARMVIXL::GenerateTestAndBranch(HInstruction* instru return; } else if (cond->IsIntConstant()) { // Constant condition, statically compared against "true" (integer value 1). - // TODO: Remove "OrNull". - if (cond->AsIntConstantOrNull()->IsTrue()) { + if (cond->AsIntConstant()->IsTrue()) { if (true_target != nullptr) { __ B(true_target); } } else { - // TODO: Remove "OrNull". - DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << Int32ConstantFrom(cond); + DCHECK(cond->AsIntConstant()->IsFalse()) << Int32ConstantFrom(cond); if (false_target != nullptr) { __ B(false_target); } @@ -2927,8 +2916,7 @@ void InstructionCodeGeneratorARMVIXL::GenerateTestAndBranch(HInstruction* instru } else { // Condition has not been materialized. Use its inputs as the comparison and // its condition as the branch condition. - // TODO: Remove "OrNull". - HCondition* condition = cond->AsConditionOrNull(); + HCondition* condition = cond->AsCondition(); // If this is a long or FP comparison that has been folded into // the HCondition, generate the comparison directly. @@ -3071,8 +3059,7 @@ void InstructionCodeGeneratorARMVIXL::VisitSelect(HSelect* select) { Location src; if (condition->IsIntConstant()) { - // TODO: Remove "OrNull". - if (condition->AsIntConstantOrNull()->IsFalse()) { + if (condition->AsIntConstant()->IsFalse()) { src = first; } else { src = second; @@ -3112,8 +3099,7 @@ void InstructionCodeGeneratorARMVIXL::VisitSelect(HSelect* select) { __ Cmp(InputRegisterAt(select, 2), 0); cond = invert ? std::make_pair(eq, ne) : std::make_pair(ne, eq); } else { - // TODO: Remove "OrNull". - cond = GenerateTest(condition->AsConditionOrNull(), invert, codegen_); + cond = GenerateTest(condition->AsCondition(), invert, codegen_); } const size_t instr_count = out.IsRegisterPair() ? 4 : 2; @@ -4068,8 +4054,7 @@ void InstructionCodeGeneratorARMVIXL::VisitTypeConversion(HTypeConversion* conve } else { DCHECK(in.IsConstant()); DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ Mov(OutputRegister(conversion), static_cast(value)); } break; @@ -5911,9 +5896,7 @@ void InstructionCodeGeneratorARMVIXL::HandleFieldSet(HInstruction* instruction, std::optional pred_is_null; bool is_predicated = - instruction->IsInstanceFieldSet() && - // TODO: Remove "OrNull". - instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet(); + instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet(); bool is_volatile = field_info.IsVolatile(); bool atomic_ldrd_strd = codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd(); DataType::Type field_type = field_info.GetFieldType(); @@ -6110,9 +6093,8 @@ void LocationsBuilderARMVIXL::HandleFieldGet(HInstruction* instruction, Location LocationsBuilderARMVIXL::ArithmeticZeroOrFpuRegister(HInstruction* input) { DCHECK(DataType::IsFloatingPointType(input->GetType())) << input->GetType(); - // TODO: Remove "OrNull". - if ((input->IsFloatConstant() && (input->AsFloatConstantOrNull()->IsArithmeticZero())) || - (input->IsDoubleConstant() && (input->AsDoubleConstantOrNull()->IsArithmeticZero()))) { + if ((input->IsFloatConstant() && (input->AsFloatConstant()->IsArithmeticZero())) || + (input->IsDoubleConstant() && (input->AsDoubleConstant()->IsArithmeticZero()))) { return Location::ConstantLocation(input); } else { return Location::RequiresFpuRegister(); @@ -6122,9 +6104,7 @@ Location LocationsBuilderARMVIXL::ArithmeticZeroOrFpuRegister(HInstruction* inpu Location LocationsBuilderARMVIXL::ArmEncodableConstantOrRegister(HInstruction* constant, Opcode opcode) { DCHECK(!DataType::IsFloatingPointType(constant->GetType())); - if (constant->IsConstant() && - // TODO: Remove "OrNull". - CanEncodeConstantAsImmediate(constant->AsConstantOrNull(), opcode)) { + if (constant->IsConstant() && CanEncodeConstantAsImmediate(constant->AsConstant(), opcode)) { return Location::ConstantLocation(constant); } return Location::RequiresRegister(); @@ -6559,8 +6539,7 @@ void LocationsBuilderARMVIXL::VisitArrayGet(HArrayGet* instruction) { // CodeGeneratorARMVIXL::GenerateFieldLoadWithBakerReadBarrier() // only if the offset is too big. uint32_t offset = CodeGenerator::GetArrayDataOffset(instruction); - // TODO: Remove "OrNull". - uint32_t index = instruction->GetIndex()->AsIntConstantOrNull()->GetValue(); + uint32_t index = instruction->GetIndex()->AsIntConstant()->GetValue(); offset += index << DataType::SizeShift(DataType::Type::kReference); if (offset >= kReferenceLoadMinFarOffset) { locations->AddTemp(Location::RequiresRegister()); @@ -6645,8 +6624,7 @@ void InstructionCodeGeneratorARMVIXL::VisitArrayGet(HArrayGet* instruction) { // input instruction has done it already. See the comment in // `TryExtractArrayAccessAddress()`. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HIntermediateAddress* tmp = array_instr->AsIntermediateAddressOrNull(); + HIntermediateAddress* tmp = array_instr->AsIntermediateAddress(); DCHECK_EQ(Uint64ConstantFrom(tmp->GetOffset()), data_offset); } temp = obj; @@ -6731,8 +6709,7 @@ void InstructionCodeGeneratorARMVIXL::VisitArrayGet(HArrayGet* instruction) { // input instruction has done it already. See the comment in // `TryExtractArrayAccessAddress()`. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HIntermediateAddress* tmp = array_instr->AsIntermediateAddressOrNull(); + HIntermediateAddress* tmp = array_instr->AsIntermediateAddress(); DCHECK_EQ(Uint64ConstantFrom(tmp->GetOffset()), data_offset); } temp = obj; @@ -6883,8 +6860,7 @@ void InstructionCodeGeneratorARMVIXL::VisitArraySet(HArraySet* instruction) { // input instruction has done it already. See the comment in // `TryExtractArrayAccessAddress()`. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HIntermediateAddress* tmp = array_instr->AsIntermediateAddressOrNull(); + HIntermediateAddress* tmp = array_instr->AsIntermediateAddress(); DCHECK_EQ(Uint64ConstantFrom(tmp->GetOffset()), data_offset); } temp = array; @@ -7264,8 +7240,7 @@ void LocationsBuilderARMVIXL::VisitParallelMove(HParallelMove* instruction ATTRI void InstructionCodeGeneratorARMVIXL::VisitParallelMove(HParallelMove* instruction) { if (instruction->GetNext()->IsSuspendCheck() && instruction->GetBlock()->GetLoopInformation() != nullptr) { - // TODO: Remove "OrNull". - HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull(); + HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck(); // The back edge will generate the suspend check. codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction); } @@ -7435,8 +7410,7 @@ void ParallelMoveResolverARMVIXL::EmitMove(size_t index) { destination.GetHighStackIndex(kArmWordSize)); } } else if (constant->IsDoubleConstant()) { - // TODO: Remove "OrNull". - double value = constant->AsDoubleConstantOrNull()->GetValue(); + double value = constant->AsDoubleConstant()->GetValue(); if (destination.IsFpuRegisterPair()) { __ Vmov(DRegisterFrom(destination), value); } else { @@ -7453,8 +7427,7 @@ void ParallelMoveResolverARMVIXL::EmitMove(size_t index) { } } else { DCHECK(constant->IsFloatConstant()) << constant->DebugName(); - // TODO: Remove "OrNull". - float value = constant->AsFloatConstantOrNull()->GetValue(); + float value = constant->AsFloatConstant()->GetValue(); if (destination.IsFpuRegister()) { __ Vmov(SRegisterFrom(destination), value); } else { diff --git a/compiler/optimizing/code_generator_utils.cc b/compiler/optimizing/code_generator_utils.cc index 2306f073be..99805928e4 100644 --- a/compiler/optimizing/code_generator_utils.cc +++ b/compiler/optimizing/code_generator_utils.cc @@ -140,8 +140,7 @@ bool UnsignedUseAnalyzer::IsComparedValueNonNegativeInBlock(HInstruction* value, // We need to find a successor basic block of HIf for the case when instr is non-negative. // If the successor dominates target_block, instructions in target_block see a non-negative value. - // TODO: Remove "OrNull". - HIf* if_instr = cond->GetBlock()->GetLastInstruction()->AsIfOrNull(); + HIf* if_instr = cond->GetBlock()->GetLastInstruction()->AsIf(); HBasicBlock* successor = nullptr; switch (cond->GetCondition()) { case kCondGT: @@ -228,9 +227,7 @@ bool UnsignedUseAnalyzer::IsNonNegativeUse(HInstruction* target_user, HInstructi // The condition must dominate target_user to guarantee that the value is always checked // before it is used by target_user. if (user->GetBlock()->Dominates(target_user->GetBlock()) && - // TODO: Remove "OrNull". - IsComparedValueNonNegativeInBlock( - value, user->AsConditionOrNull(), target_user->GetBlock())) { + IsComparedValueNonNegativeInBlock(value, user->AsCondition(), target_user->GetBlock())) { return true; } } diff --git a/compiler/optimizing/code_generator_vector_arm64_neon.cc b/compiler/optimizing/code_generator_vector_arm64_neon.cc index b73d0d3614..ce02bfa21a 100644 --- a/compiler/optimizing/code_generator_vector_arm64_neon.cc +++ b/compiler/optimizing/code_generator_vector_arm64_neon.cc @@ -47,11 +47,9 @@ inline bool NEONCanEncodeConstantAsImmediate(HConstant* constant, HInstruction* if (constant->IsLongConstant()) { return false; } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstantOrNull()->GetValue()); + return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstant()->GetValue()); } else if (constant->IsDoubleConstant()) { - // TODO: Remove "OrNull". - return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstantOrNull()->GetValue()); + return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstant()->GetValue()); } int64_t value = CodeGenerator::GetInt64ValueOf(constant); return IsUint<8>(value); @@ -64,9 +62,7 @@ inline bool NEONCanEncodeConstantAsImmediate(HConstant* constant, HInstruction* // encoded into the instruction. // - register location otherwise. inline Location NEONEncodableConstantOrRegister(HInstruction* constant, HInstruction* instr) { - if (constant->IsConstant() && - // TODO: Remove "OrNull". - NEONCanEncodeConstantAsImmediate(constant->AsConstantOrNull(), instr)) { + if (constant->IsConstant() && NEONCanEncodeConstantAsImmediate(constant->AsConstant(), instr)) { return Location::ConstantLocation(constant); } @@ -95,8 +91,7 @@ void LocationsBuilderARM64Neon::VisitVecReplicateScalar(HVecReplicateScalar* ins case DataType::Type::kFloat32: case DataType::Type::kFloat64: if (input->IsConstant() && - // TODO: Remove "OrNull". - NEONCanEncodeConstantAsImmediate(input->AsConstantOrNull(), instruction)) { + NEONCanEncodeConstantAsImmediate(input->AsConstant(), instruction)) { locations->SetInAt(0, Location::ConstantLocation(input)); locations->SetOut(Location::RequiresFpuRegister()); } else { @@ -153,8 +148,7 @@ void InstructionCodeGeneratorARM64Neon::VisitVecReplicateScalar(HVecReplicateSca case DataType::Type::kFloat32: DCHECK_EQ(4u, instruction->GetVectorLength()); if (src_loc.IsConstant()) { - // TODO: Remove "OrNull". - __ Fmov(dst.V4S(), src_loc.GetConstant()->AsFloatConstantOrNull()->GetValue()); + __ Fmov(dst.V4S(), src_loc.GetConstant()->AsFloatConstant()->GetValue()); } else { __ Dup(dst.V4S(), VRegisterFrom(src_loc).V4S(), 0); } @@ -162,8 +156,7 @@ void InstructionCodeGeneratorARM64Neon::VisitVecReplicateScalar(HVecReplicateSca case DataType::Type::kFloat64: DCHECK_EQ(2u, instruction->GetVectorLength()); if (src_loc.IsConstant()) { - // TODO: Remove "OrNull". - __ Fmov(dst.V2D(), src_loc.GetConstant()->AsDoubleConstantOrNull()->GetValue()); + __ Fmov(dst.V2D(), src_loc.GetConstant()->AsDoubleConstant()->GetValue()); } else { __ Dup(dst.V2D(), VRegisterFrom(src_loc).V2D(), 0); } @@ -903,8 +896,7 @@ void InstructionCodeGeneratorARM64Neon::VisitVecShl(HVecShl* instruction) { LocationSummary* locations = instruction->GetLocations(); VRegister lhs = VRegisterFrom(locations->InAt(0)); VRegister dst = VRegisterFrom(locations->Out()); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: case DataType::Type::kInt8: @@ -938,8 +930,7 @@ void InstructionCodeGeneratorARM64Neon::VisitVecShr(HVecShr* instruction) { LocationSummary* locations = instruction->GetLocations(); VRegister lhs = VRegisterFrom(locations->InAt(0)); VRegister dst = VRegisterFrom(locations->Out()); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: case DataType::Type::kInt8: @@ -973,8 +964,7 @@ void InstructionCodeGeneratorARM64Neon::VisitVecUShr(HVecUShr* instruction) { LocationSummary* locations = instruction->GetLocations(); VRegister lhs = VRegisterFrom(locations->InAt(0)); VRegister dst = VRegisterFrom(locations->Out()); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: case DataType::Type::kInt8: @@ -1146,10 +1136,8 @@ void LocationsBuilderARM64Neon::VisitVecSADAccumulate(HVecSADAccumulate* instruc CreateVecAccumLocations(GetGraph()->GetAllocator(), instruction); // Some conversions require temporary registers. LocationSummary* locations = instruction->GetLocations(); - // TODO: Remove "OrNull". - HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull(); - // TODO: Remove "OrNull". - HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull(); + HVecOperation* a = instruction->InputAt(1)->AsVecOperation(); + HVecOperation* b = instruction->InputAt(2)->AsVecOperation(); DCHECK_EQ(HVecOperation::ToSignedType(a->GetPackedType()), HVecOperation::ToSignedType(b->GetPackedType())); switch (a->GetPackedType()) { @@ -1195,10 +1183,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecSADAccumulate(HVecSADAccumulate* DCHECK(locations->InAt(0).Equals(locations->Out())); // Handle all feasible acc_T += sad(a_S, b_S) type combinations (T x S). - // TODO: Remove "OrNull". - HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull(); - // TODO: Remove "OrNull". - HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull(); + HVecOperation* a = instruction->InputAt(1)->AsVecOperation(); + HVecOperation* b = instruction->InputAt(2)->AsVecOperation(); DCHECK_EQ(HVecOperation::ToSignedType(a->GetPackedType()), HVecOperation::ToSignedType(b->GetPackedType())); switch (a->GetPackedType()) { @@ -1337,8 +1323,7 @@ void LocationsBuilderARM64Neon::VisitVecDotProd(HVecDotProd* instruction) { locations->SetOut(Location::SameAsFirstInput()); // For Int8 and Uint8 general case we need a temp register. - // TODO: Remove "OrNull". - if ((DataType::Size(instruction->InputAt(1)->AsVecOperationOrNull()->GetPackedType()) == 1) && + if ((DataType::Size(instruction->InputAt(1)->AsVecOperation()->GetPackedType()) == 1) && !ShouldEmitDotProductInstructions(codegen_)) { locations->AddTemp(Location::RequiresFpuRegister()); } @@ -1350,10 +1335,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecDotProd(HVecDotProd* instruction VRegister acc = VRegisterFrom(locations->InAt(0)); VRegister left = VRegisterFrom(locations->InAt(1)); VRegister right = VRegisterFrom(locations->InAt(2)); - // TODO: Remove "OrNull". - HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull(); - // TODO: Remove "OrNull". - HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull(); + HVecOperation* a = instruction->InputAt(1)->AsVecOperation(); + HVecOperation* b = instruction->InputAt(2)->AsVecOperation(); DCHECK_EQ(HVecOperation::ToSignedType(a->GetPackedType()), HVecOperation::ToSignedType(b->GetPackedType())); DCHECK_EQ(instruction->GetPackedType(), DataType::Type::kInt32); diff --git a/compiler/optimizing/code_generator_vector_arm64_sve.cc b/compiler/optimizing/code_generator_vector_arm64_sve.cc index aa4bbad0ce..4c16c3eb38 100644 --- a/compiler/optimizing/code_generator_vector_arm64_sve.cc +++ b/compiler/optimizing/code_generator_vector_arm64_sve.cc @@ -45,11 +45,9 @@ static bool SVECanEncodeConstantAsImmediate(HConstant* constant, HInstruction* i if (constant->IsLongConstant()) { return false; } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstantOrNull()->GetValue()); + return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstant()->GetValue()); } else if (constant->IsDoubleConstant()) { - // TODO: Remove "OrNull". - return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstantOrNull()->GetValue()); + return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstant()->GetValue()); } // TODO: Make use of shift part of DUP instruction. int64_t value = CodeGenerator::GetInt64ValueOf(constant); @@ -64,9 +62,7 @@ static bool SVECanEncodeConstantAsImmediate(HConstant* constant, HInstruction* i // encoded into the instruction. // - register location otherwise. inline Location SVEEncodableConstantOrRegister(HInstruction* constant, HInstruction* instr) { - if (constant->IsConstant() && - // TODO: Remove "OrNull". - SVECanEncodeConstantAsImmediate(constant->AsConstantOrNull(), instr)) { + if (constant->IsConstant() && SVECanEncodeConstantAsImmediate(constant->AsConstant(), instr)) { return Location::ConstantLocation(constant); } @@ -95,8 +91,7 @@ void LocationsBuilderARM64Sve::VisitVecReplicateScalar(HVecReplicateScalar* inst case DataType::Type::kFloat32: case DataType::Type::kFloat64: if (input->IsConstant() && - // TODO: Remove "OrNull". - SVECanEncodeConstantAsImmediate(input->AsConstantOrNull(), instruction)) { + SVECanEncodeConstantAsImmediate(input->AsConstant(), instruction)) { locations->SetInAt(0, Location::ConstantLocation(input)); locations->SetOut(Location::RequiresFpuRegister()); } else { @@ -150,16 +145,14 @@ void InstructionCodeGeneratorARM64Sve::VisitVecReplicateScalar(HVecReplicateScal break; case DataType::Type::kFloat32: if (src_loc.IsConstant()) { - // TODO: Remove "OrNull". - __ Fdup(dst.VnS(), src_loc.GetConstant()->AsFloatConstantOrNull()->GetValue()); + __ Fdup(dst.VnS(), src_loc.GetConstant()->AsFloatConstant()->GetValue()); } else { __ Dup(dst.VnS(), ZRegisterFrom(src_loc).VnS(), 0); } break; case DataType::Type::kFloat64: if (src_loc.IsConstant()) { - // TODO: Remove "OrNull". - __ Fdup(dst.VnD(), src_loc.GetConstant()->AsDoubleConstantOrNull()->GetValue()); + __ Fdup(dst.VnD(), src_loc.GetConstant()->AsDoubleConstant()->GetValue()); } else { __ Dup(dst.VnD(), ZRegisterFrom(src_loc).VnD(), 0); } @@ -776,8 +769,7 @@ void InstructionCodeGeneratorARM64Sve::VisitVecShl(HVecShl* instruction) { const ZRegister lhs = ZRegisterFrom(locations->InAt(0)); const ZRegister dst = ZRegisterFrom(locations->Out()); const PRegisterM p_reg = LoopPReg().Merging(); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); ValidateVectorLength(instruction); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: @@ -810,8 +802,7 @@ void InstructionCodeGeneratorARM64Sve::VisitVecShr(HVecShr* instruction) { const ZRegister lhs = ZRegisterFrom(locations->InAt(0)); const ZRegister dst = ZRegisterFrom(locations->Out()); const PRegisterM p_reg = LoopPReg().Merging(); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); ValidateVectorLength(instruction); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: @@ -844,8 +835,7 @@ void InstructionCodeGeneratorARM64Sve::VisitVecUShr(HVecUShr* instruction) { const ZRegister lhs = ZRegisterFrom(locations->InAt(0)); const ZRegister dst = ZRegisterFrom(locations->Out()); const PRegisterM p_reg = LoopPReg().Merging(); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); ValidateVectorLength(instruction); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: @@ -1039,10 +1029,8 @@ void InstructionCodeGeneratorARM64Sve::VisitVecDotProd(HVecDotProd* instruction) const ZRegister left = ZRegisterFrom(locations->InAt(1)); const ZRegister right = ZRegisterFrom(locations->InAt(2)); const PRegisterM p_reg = LoopPReg().Merging(); - // TODO: Remove "OrNull". - HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull(); - // TODO: Remove "OrNull". - HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull(); + HVecOperation* a = instruction->InputAt(1)->AsVecOperation(); + HVecOperation* b = instruction->InputAt(2)->AsVecOperation(); DCHECK_EQ(HVecOperation::ToSignedType(a->GetPackedType()), HVecOperation::ToSignedType(b->GetPackedType())); DCHECK_EQ(instruction->GetPackedType(), DataType::Type::kInt32); diff --git a/compiler/optimizing/code_generator_vector_arm_vixl.cc b/compiler/optimizing/code_generator_vector_arm_vixl.cc index 0ee6564dfc..e8ecf28386 100644 --- a/compiler/optimizing/code_generator_vector_arm_vixl.cc +++ b/compiler/optimizing/code_generator_vector_arm_vixl.cc @@ -657,8 +657,7 @@ void InstructionCodeGeneratorARMVIXL::VisitVecShl(HVecShl* instruction) { LocationSummary* locations = instruction->GetLocations(); vixl32::DRegister lhs = DRegisterFrom(locations->InAt(0)); vixl32::DRegister dst = DRegisterFrom(locations->Out()); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: case DataType::Type::kInt8: @@ -688,8 +687,7 @@ void InstructionCodeGeneratorARMVIXL::VisitVecShr(HVecShr* instruction) { LocationSummary* locations = instruction->GetLocations(); vixl32::DRegister lhs = DRegisterFrom(locations->InAt(0)); vixl32::DRegister dst = DRegisterFrom(locations->Out()); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: case DataType::Type::kInt8: @@ -719,8 +717,7 @@ void InstructionCodeGeneratorARMVIXL::VisitVecUShr(HVecUShr* instruction) { LocationSummary* locations = instruction->GetLocations(); vixl32::DRegister lhs = DRegisterFrom(locations->InAt(0)); vixl32::DRegister dst = DRegisterFrom(locations->Out()); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); switch (instruction->GetPackedType()) { case DataType::Type::kUint8: case DataType::Type::kInt8: @@ -830,10 +827,8 @@ void InstructionCodeGeneratorARMVIXL::VisitVecSADAccumulate(HVecSADAccumulate* i DCHECK(locations->InAt(0).Equals(locations->Out())); // Handle all feasible acc_T += sad(a_S, b_S) type combinations (T x S). - // TODO: Remove "OrNull". - HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull(); - // TODO: Remove "OrNull". - HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull(); + HVecOperation* a = instruction->InputAt(1)->AsVecOperation(); + HVecOperation* b = instruction->InputAt(2)->AsVecOperation(); DCHECK_EQ(a->GetPackedType(), b->GetPackedType()); switch (a->GetPackedType()) { case DataType::Type::kInt32: diff --git a/compiler/optimizing/code_generator_vector_x86.cc b/compiler/optimizing/code_generator_vector_x86.cc index 5fb63d3808..343a6e1af4 100644 --- a/compiler/optimizing/code_generator_vector_x86.cc +++ b/compiler/optimizing/code_generator_vector_x86.cc @@ -997,8 +997,7 @@ void LocationsBuilderX86::VisitVecShl(HVecShl* instruction) { void InstructionCodeGeneratorX86::VisitVecShl(HVecShl* instruction) { LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(0).Equals(locations->Out())); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); XmmRegister dst = locations->Out().AsFpuRegister(); switch (instruction->GetPackedType()) { case DataType::Type::kUint16: @@ -1027,8 +1026,7 @@ void LocationsBuilderX86::VisitVecShr(HVecShr* instruction) { void InstructionCodeGeneratorX86::VisitVecShr(HVecShr* instruction) { LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(0).Equals(locations->Out())); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); XmmRegister dst = locations->Out().AsFpuRegister(); switch (instruction->GetPackedType()) { case DataType::Type::kUint16: @@ -1053,8 +1051,7 @@ void LocationsBuilderX86::VisitVecUShr(HVecUShr* instruction) { void InstructionCodeGeneratorX86::VisitVecUShr(HVecUShr* instruction) { LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(0).Equals(locations->Out())); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); XmmRegister dst = locations->Out().AsFpuRegister(); switch (instruction->GetPackedType()) { case DataType::Type::kUint16: diff --git a/compiler/optimizing/code_generator_vector_x86_64.cc b/compiler/optimizing/code_generator_vector_x86_64.cc index 72c766fca0..fb6e4e753f 100644 --- a/compiler/optimizing/code_generator_vector_x86_64.cc +++ b/compiler/optimizing/code_generator_vector_x86_64.cc @@ -980,8 +980,7 @@ void LocationsBuilderX86_64::VisitVecShl(HVecShl* instruction) { void InstructionCodeGeneratorX86_64::VisitVecShl(HVecShl* instruction) { LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(0).Equals(locations->Out())); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); XmmRegister dst = locations->Out().AsFpuRegister(); switch (instruction->GetPackedType()) { case DataType::Type::kUint16: @@ -1010,8 +1009,7 @@ void LocationsBuilderX86_64::VisitVecShr(HVecShr* instruction) { void InstructionCodeGeneratorX86_64::VisitVecShr(HVecShr* instruction) { LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(0).Equals(locations->Out())); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); XmmRegister dst = locations->Out().AsFpuRegister(); switch (instruction->GetPackedType()) { case DataType::Type::kUint16: @@ -1036,8 +1034,7 @@ void LocationsBuilderX86_64::VisitVecUShr(HVecUShr* instruction) { void InstructionCodeGeneratorX86_64::VisitVecUShr(HVecUShr* instruction) { LocationSummary* locations = instruction->GetLocations(); DCHECK(locations->InAt(0).Equals(locations->Out())); - // TODO: Remove "OrNull". - int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); XmmRegister dst = locations->Out().AsFpuRegister(); switch (instruction->GetPackedType()) { case DataType::Type::kUint16: diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc index e19d49b6db..d85e0f6362 100644 --- a/compiler/optimizing/code_generator_x86.cc +++ b/compiler/optimizing/code_generator_x86.cc @@ -164,8 +164,7 @@ class BoundsCheckSlowPathX86 : public SlowPathCode { // Are we using an array length from memory? if (!length_loc.IsValid()) { DCHECK(instruction_->InputAt(1)->IsArrayLength()); - // TODO: Remove "OrNull". - HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLengthOrNull(); + HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLength(); DCHECK(array_length->IsEmittedAtUseSite()); uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length); Location array_loc = array_length->GetLocations()->InAt(0); @@ -207,8 +206,7 @@ class BoundsCheckSlowPathX86 : public SlowPathCode { DataType::Type::kInt32); } - // TODO: Remove "OrNull". - QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt() + QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt() ? kQuickThrowStringBounds : kQuickThrowArrayBounds; x86_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this); @@ -275,8 +273,7 @@ class LoadStringSlowPathX86 : public SlowPathCode { SaveLiveRegisters(codegen, locations); InvokeRuntimeCallingConvention calling_convention; - // TODO: Remove "OrNull". - const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex(); + const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex(); __ movl(calling_convention.GetRegisterAt(0), Immediate(string_index.index_)); x86_codegen->InvokeRuntime(kQuickResolveString, instruction_, instruction_->GetDexPc(), this); CheckEntrypointTypes(); @@ -370,8 +367,7 @@ class TypeCheckSlowPathX86 : public SlowPathCode { if (kPoisonHeapReferences && instruction_->IsCheckCast() && - // TODO: Remove "OrNull". - instruction_->AsCheckCastOrNull()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) { + instruction_->AsCheckCast()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) { // First, unpoison the `cls` reference that was poisoned for direct memory comparison. __ UnpoisonHeapReference(locations->InAt(1).AsRegister()); } @@ -436,8 +432,7 @@ class DeoptimizationSlowPathX86 : public SlowPathCode { InvokeRuntimeCallingConvention calling_convention; x86_codegen->Load32BitValue( calling_convention.GetRegisterAt(0), - // TODO: Remove "OrNull". - static_cast(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind())); + static_cast(instruction_->AsDeoptimize()->GetDeoptimizationKind())); x86_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this); CheckEntrypointTypes(); } @@ -608,8 +603,7 @@ class ReadBarrierMarkAndUpdateFieldSlowPathX86 : public SlowPathCode { DCHECK((instruction_->IsInvoke() && instruction_->GetLocations()->Intrinsified())) << "Unexpected instruction in read barrier marking and field updating slow path: " << instruction_->DebugName(); - // TODO: Remove "OrNull". - HInvoke* invoke = instruction_->AsInvokeOrNull(); + HInvoke* invoke = instruction_->AsInvoke(); DCHECK(IsUnsafeCASObject(invoke) || IsVarHandleCASFamily(invoke)) << invoke->GetIntrinsic(); __ Bind(GetEntryLabel()); @@ -842,17 +836,13 @@ class ReadBarrierForHeapReferenceSlowPathX86 : public SlowPathCode { // to an object field within an object. DCHECK(instruction_->IsInvoke()) << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - DCHECK((instruction_->AsInvokeOrNull()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == - Intrinsics::kUnsafeGetObjectVolatile) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == - Intrinsics::kJdkUnsafeGetObject) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == + DCHECK((instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) || + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObjectVolatile) || + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObject) || + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObjectVolatile) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == - Intrinsics::kJdkUnsafeGetObjectAcquire)) - << instruction_->AsInvokeOrNull()->GetIntrinsic(); + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObjectAcquire)) + << instruction_->AsInvoke()->GetIntrinsic(); DCHECK_EQ(offset_, 0U); DCHECK(index_.IsRegisterPair()); // UnsafeGet's offset location is a register pair, the low @@ -1846,8 +1836,7 @@ void InstructionCodeGeneratorX86::HandleGoto(HInstruction* got, HBasicBlock* suc } if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { - // TODO: Remove "OrNull". - GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr); + GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); } if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) { __ jmp(codegen_->GetLabelOf(successor)); @@ -1941,8 +1930,7 @@ void InstructionCodeGeneratorX86::GenerateLongComparesAndJumps(HCondition* cond, } if (right.IsConstant()) { - // TODO: Remove "OrNull". - int64_t value = right.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = right.GetConstant()->AsLongConstant()->GetValue(); int32_t val_high = High32Bits(value); int32_t val_low = Low32Bits(value); @@ -2002,8 +1990,7 @@ void InstructionCodeGeneratorX86::GenerateFPCompare(Location lhs, DCHECK(const_area->IsEmittedAtUseSite()); __ ucomisd(lhs.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(), + const_area->GetConstant()->AsDoubleConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -2017,8 +2004,7 @@ void InstructionCodeGeneratorX86::GenerateFPCompare(Location lhs, DCHECK(const_area->IsEmittedAtUseSite()); __ ucomiss(lhs.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(), + const_area->GetConstant()->AsFloatConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -2090,14 +2076,12 @@ void InstructionCodeGeneratorX86::GenerateTestAndBranch(HInstruction* instructio return; } else if (cond->IsIntConstant()) { // Constant condition, statically compared against "true" (integer value 1). - // TODO: Remove "OrNull". - if (cond->AsIntConstantOrNull()->IsTrue()) { + if (cond->AsIntConstant()->IsTrue()) { if (true_target != nullptr) { __ jmp(true_target); } } else { - // TODO: Remove "OrNull". - DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << cond->AsIntConstantOrNull()->GetValue(); + DCHECK(cond->AsIntConstant()->IsFalse()) << cond->AsIntConstant()->GetValue(); if (false_target != nullptr) { __ jmp(false_target); } @@ -2116,11 +2100,9 @@ void InstructionCodeGeneratorX86::GenerateTestAndBranch(HInstruction* instructio if (IsBooleanValueOrMaterializedCondition(cond)) { if (AreEflagsSetFrom(cond, instruction)) { if (true_target == nullptr) { - // TODO: Remove "OrNull". - __ j(X86Condition(cond->AsConditionOrNull()->GetOppositeCondition()), false_target); + __ j(X86Condition(cond->AsCondition()->GetOppositeCondition()), false_target); } else { - // TODO: Remove "OrNull". - __ j(X86Condition(cond->AsConditionOrNull()->GetCondition()), true_target); + __ j(X86Condition(cond->AsCondition()->GetCondition()), true_target); } } else { // Materialized condition, compare against 0. @@ -2139,8 +2121,7 @@ void InstructionCodeGeneratorX86::GenerateTestAndBranch(HInstruction* instructio } else { // Condition has not been materialized, use its inputs as the comparison and // its condition as the branch condition. - // TODO: Remove "OrNull". - HCondition* condition = cond->AsConditionOrNull(); + HCondition* condition = cond->AsCondition(); // If this is a long or FP comparison that has been folded into // the HCondition, generate the comparison directly. @@ -2273,8 +2254,7 @@ void InstructionCodeGeneratorX86::VisitSelect(HSelect* select) { // Figure out how to test the 'condition'. if (select_condition->IsCondition()) { - // TODO: Remove "OrNull". - HCondition* condition = select_condition->AsConditionOrNull(); + HCondition* condition = select_condition->AsCondition(); if (!condition->IsEmittedAtUseSite()) { // This was a previously materialized condition. // Can we use the existing condition code? @@ -3172,8 +3152,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movzxb(out.AsRegister(), in.AsRegister()); } else { DCHECK(in.GetConstant()->IsIntConstant()); - // TODO: Remove "OrNull". - int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = in.GetConstant()->AsIntConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3182,8 +3161,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movzxb(out.AsRegister(), in.AsRegisterPairLow()); } else { DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3204,8 +3182,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movsxb(out.AsRegister(), in.AsRegister()); } else { DCHECK(in.GetConstant()->IsIntConstant()); - // TODO: Remove "OrNull". - int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = in.GetConstant()->AsIntConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3214,8 +3191,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movsxb(out.AsRegister(), in.AsRegisterPairLow()); } else { DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3237,8 +3213,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movzxw(out.AsRegister(), Address(ESP, in.GetStackIndex())); } else { DCHECK(in.GetConstant()->IsIntConstant()); - // TODO: Remove "OrNull". - int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = in.GetConstant()->AsIntConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3249,8 +3224,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movzxw(out.AsRegister(), Address(ESP, in.GetStackIndex())); } else { DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3271,8 +3245,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movsxw(out.AsRegister(), Address(ESP, in.GetStackIndex())); } else { DCHECK(in.GetConstant()->IsIntConstant()); - // TODO: Remove "OrNull". - int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = in.GetConstant()->AsIntConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3283,8 +3256,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio __ movsxw(out.AsRegister(), Address(ESP, in.GetStackIndex())); } else { DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3305,8 +3277,7 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio } else { DCHECK(in.IsConstant()); DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3557,8 +3528,7 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) { first.AsRegister(), second.AsRegister(), TIMES_1, 0)); } } else if (second.IsConstant()) { - // TODO: Remove "OrNull". - int32_t value = second.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t value = second.GetConstant()->AsIntConstant()->GetValue(); if (out.AsRegister() == first.AsRegister()) { __ addl(out.AsRegister(), Immediate(value)); } else { @@ -3581,8 +3551,7 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) { Address(ESP, second.GetHighStackIndex(kX86WordSize))); } else { DCHECK(second.IsConstant()) << second; - // TODO: Remove "OrNull". - int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = second.GetConstant()->AsLongConstant()->GetValue(); __ addl(first.AsRegisterPairLow(), Immediate(Low32Bits(value))); __ adcl(first.AsRegisterPairHigh(), Immediate(High32Bits(value))); } @@ -3593,13 +3562,11 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) { if (second.IsFpuRegister()) { __ addss(first.AsFpuRegister(), second.AsFpuRegister()); } else if (add->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ addss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(), + const_area->GetConstant()->AsFloatConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -3613,13 +3580,11 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) { if (second.IsFpuRegister()) { __ addsd(first.AsFpuRegister(), second.AsFpuRegister()); } else if (add->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ addsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(), + const_area->GetConstant()->AsDoubleConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -3675,8 +3640,7 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) { __ subl(first.AsRegister(), second.AsRegister()); } else if (second.IsConstant()) { __ subl(first.AsRegister(), - // TODO: Remove "OrNull". - Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(second.GetConstant()->AsIntConstant()->GetValue())); } else { __ subl(first.AsRegister(), Address(ESP, second.GetStackIndex())); } @@ -3693,8 +3657,7 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) { Address(ESP, second.GetHighStackIndex(kX86WordSize))); } else { DCHECK(second.IsConstant()) << second; - // TODO: Remove "OrNull". - int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = second.GetConstant()->AsLongConstant()->GetValue(); __ subl(first.AsRegisterPairLow(), Immediate(Low32Bits(value))); __ sbbl(first.AsRegisterPairHigh(), Immediate(High32Bits(value))); } @@ -3705,13 +3668,11 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) { if (second.IsFpuRegister()) { __ subss(first.AsFpuRegister(), second.AsFpuRegister()); } else if (sub->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ subss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(), + const_area->GetConstant()->AsFloatConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -3725,13 +3686,11 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) { if (second.IsFpuRegister()) { __ subsd(first.AsFpuRegister(), second.AsFpuRegister()); } else if (sub->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ subsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(), + const_area->GetConstant()->AsDoubleConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -3799,8 +3758,7 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) { // The constant may have ended up in a register, so test explicitly to avoid // problems where the output may not be the same as the first operand. if (mul->InputAt(1)->IsIntConstant()) { - // TODO: Remove "OrNull". - Immediate imm(mul->InputAt(1)->AsIntConstantOrNull()->GetValue()); + Immediate imm(mul->InputAt(1)->AsIntConstant()->GetValue()); __ imull(out.AsRegister(), first.AsRegister(), imm); } else if (second.IsRegister()) { DCHECK(first.Equals(out)); @@ -3829,8 +3787,7 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) { if (second.IsConstant()) { DCHECK(second.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = second.GetConstant()->AsLongConstant()->GetValue(); int32_t low_value = Low32Bits(value); int32_t high_value = High32Bits(value); Immediate low(low_value); @@ -3900,13 +3857,11 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) { if (second.IsFpuRegister()) { __ mulss(first.AsFpuRegister(), second.AsFpuRegister()); } else if (mul->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ mulss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(), + const_area->GetConstant()->AsFloatConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -3921,13 +3876,11 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) { if (second.IsFpuRegister()) { __ mulsd(first.AsFpuRegister(), second.AsFpuRegister()); } else if (mul->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ mulsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(), + const_area->GetConstant()->AsDoubleConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -4047,8 +4000,7 @@ void InstructionCodeGeneratorX86::DivRemOneOrMinusOne(HBinaryOperation* instruct Register out_register = locations->Out().AsRegister(); Register input_register = locations->InAt(0).AsRegister(); - // TODO: Remove "OrNull". - int32_t imm = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); DCHECK(imm == 1 || imm == -1); @@ -4089,8 +4041,7 @@ void InstructionCodeGeneratorX86::DivByPowerOfTwo(HDiv* instruction) { Register out_register = locations->Out().AsRegister(); Register input_register = locations->InAt(0).AsRegister(); - // TODO: Remove "OrNull". - int32_t imm = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); DCHECK(IsPowerOfTwo(AbsOrMin(imm))); uint32_t abs_imm = static_cast(AbsOrMin(imm)); @@ -4113,8 +4064,7 @@ void InstructionCodeGeneratorX86::GenerateDivRemWithAnyConstant(HBinaryOperation DCHECK(instruction->IsDiv() || instruction->IsRem()); LocationSummary* locations = instruction->GetLocations(); - // TODO: Remove "OrNull". - int imm = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue(); + int imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue(); Register eax = locations->InAt(0).AsRegister(); Register out = locations->Out().AsRegister(); @@ -4192,8 +4142,7 @@ void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instr DCHECK_EQ(is_div ? EAX : EDX, out.AsRegister()); if (second.IsConstant()) { - // TODO: Remove "OrNull". - int32_t imm = second.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t imm = second.GetConstant()->AsIntConstant()->GetValue(); if (imm == 0) { // Do not generate anything for 0. DivZeroCheck would forbid any generated code. @@ -4201,11 +4150,9 @@ void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instr DivRemOneOrMinusOne(instruction); } else if (IsPowerOfTwo(AbsOrMin(imm))) { if (is_div) { - // TODO: Remove "OrNull". - DivByPowerOfTwo(instruction->AsDivOrNull()); + DivByPowerOfTwo(instruction->AsDiv()); } else { - // TODO: Remove "OrNull". - RemByPowerOfTwo(instruction->AsRemOrNull()); + RemByPowerOfTwo(instruction->AsRem()); } } else { DCHECK(imm <= -2 || imm >= 2); @@ -4323,13 +4270,11 @@ void InstructionCodeGeneratorX86::VisitDiv(HDiv* div) { if (second.IsFpuRegister()) { __ divss(first.AsFpuRegister(), second.AsFpuRegister()); } else if (div->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ divss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(), + const_area->GetConstant()->AsFloatConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -4343,13 +4288,11 @@ void InstructionCodeGeneratorX86::VisitDiv(HDiv* div) { if (second.IsFpuRegister()) { __ divsd(first.AsFpuRegister(), second.AsFpuRegister()); } else if (div->InputAt(1)->IsX86LoadFromConstantTable()) { - // TODO: Remove "OrNull". - HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTableOrNull(); + HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTable(); DCHECK(const_area->IsEmittedAtUseSite()); __ divsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(), + const_area->GetConstant()->AsDoubleConstant()->GetValue(), const_area->GetBaseMethodAddress(), const_area->GetLocations()->InAt(0).AsRegister())); } else { @@ -4769,8 +4712,7 @@ void InstructionCodeGeneratorX86::VisitDivZeroCheck(HDivZeroCheck* instruction) __ j(kEqual, slow_path->GetEntryLabel()); } else { DCHECK(value.IsConstant()) << value; - // TODO: Remove "OrNull". - if (value.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) { + if (value.GetConstant()->AsIntConstant()->GetValue() == 0) { __ jmp(slow_path->GetEntryLabel()); } } @@ -4784,8 +4726,7 @@ void InstructionCodeGeneratorX86::VisitDivZeroCheck(HDivZeroCheck* instruction) __ j(kEqual, slow_path->GetEntryLabel()); } else { DCHECK(value.IsConstant()) << value; - // TODO: Remove "OrNull". - if (value.GetConstant()->AsLongConstantOrNull()->GetValue() == 0) { + if (value.GetConstant()->AsLongConstant()->GetValue() == 0) { __ jmp(slow_path->GetEntryLabel()); } } @@ -4840,9 +4781,7 @@ void InstructionCodeGeneratorX86::HandleShift(HBinaryOperation* op) { __ shrl(first_reg, second_reg); } } else { - // TODO: Remove "OrNull". - int32_t shift = - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance; + int32_t shift = second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance; if (shift == 0) { return; } @@ -4870,9 +4809,7 @@ void InstructionCodeGeneratorX86::HandleShift(HBinaryOperation* op) { } } else { // Shift by a constant. - // TODO: Remove "OrNull". - int32_t shift = - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance; + int32_t shift = second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance; // Nothing to do if the shift is 0, as the input is already the output. if (shift != 0) { if (op->IsShl()) { @@ -5029,9 +4966,7 @@ void InstructionCodeGeneratorX86::VisitRor(HRor* ror) { Register second_reg = second.AsRegister(); __ rorl(first_reg, second_reg); } else { - // TODO: Remove "OrNull". - Immediate imm( - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance); __ rorl(first_reg, imm); } return; @@ -5052,9 +4987,7 @@ void InstructionCodeGeneratorX86::VisitRor(HRor* ror) { __ cmovl(kNotEqual, first_reg_hi, first_reg_lo); __ cmovl(kNotEqual, first_reg_lo, temp_reg); } else { - // TODO: Remove "OrNull". - int32_t shift_amt = - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance; + int32_t shift_amt = second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance; if (shift_amt == 0) { // Already fine. return; @@ -5297,8 +5230,7 @@ void InstructionCodeGeneratorX86::VisitCompare(HCompare* compare) { if (right.IsConstant()) { DCHECK(right.GetConstant()->IsLongConstant()); right_is_const = true; - // TODO: Remove "OrNull". - int64_t val = right.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t val = right.GetConstant()->AsLongConstant()->GetValue(); val_low = Low32Bits(val); val_high = High32Bits(val); } @@ -5399,13 +5331,11 @@ HInvokeStaticOrDirect::DispatchInfo CodeGeneratorX86::GetSupportedInvokeStaticOr Register CodeGeneratorX86::GetInvokeExtraParameter(HInvoke* invoke, Register temp) { if (invoke->IsInvokeStaticOrDirect()) { - // TODO: Remove "OrNull". - return GetInvokeStaticOrDirectExtraParameter(invoke->AsInvokeStaticOrDirectOrNull(), temp); + return GetInvokeStaticOrDirectExtraParameter(invoke->AsInvokeStaticOrDirect(), temp); } DCHECK(invoke->IsInvokeInterface()); - // TODO: Remove "OrNull". Location location = - invoke->GetLocations()->InAt(invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex()); + invoke->GetLocations()->InAt(invoke->AsInvokeInterface()->GetSpecialInputIndex()); return location.AsRegister(); } @@ -5445,15 +5375,13 @@ void CodeGeneratorX86::LoadMethod(MethodLoadKind load_kind, Location temp, HInvo break; } case MethodLoadKind::kBootImageRelRo: { - // TODO: Remove "OrNull". size_t index = invoke->IsInvokeInterface() - ? invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex() - : invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex(); + ? invoke->AsInvokeInterface()->GetSpecialInputIndex() + : invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex(); Register base_reg = GetInvokeExtraParameter(invoke, temp.AsRegister()); __ movl(temp.AsRegister(), Address(base_reg, kPlaceholder32BitOffset)); RecordBootImageRelRoPatch( - // TODO: Remove "OrNull". - invoke->InputAt(index)->AsX86ComputeBaseMethodAddressOrNull(), + invoke->InputAt(index)->AsX86ComputeBaseMethodAddress(), GetBootImageOffset(invoke)); break; } @@ -5634,13 +5562,11 @@ void CodeGeneratorX86::RecordBootImageRelRoPatch(HX86ComputeBaseMethodAddress* m } void CodeGeneratorX86::RecordBootImageMethodPatch(HInvoke* invoke) { - // TODO: Remove "OrNull". size_t index = invoke->IsInvokeInterface() - ? invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex() - : invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex(); - // TODO: Remove "OrNull". + ? invoke->AsInvokeInterface()->GetSpecialInputIndex() + : invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex(); HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(index)->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(index)->AsX86ComputeBaseMethodAddress(); boot_image_method_patches_.emplace_back( method_address, invoke->GetResolvedMethodReference().dex_file, @@ -5649,17 +5575,15 @@ void CodeGeneratorX86::RecordBootImageMethodPatch(HInvoke* invoke) { } void CodeGeneratorX86::RecordMethodBssEntryPatch(HInvoke* invoke) { - // TODO: Remove "OrNull". size_t index = invoke->IsInvokeInterface() - ? invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex() - : invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex(); + ? invoke->AsInvokeInterface()->GetSpecialInputIndex() + : invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex(); DCHECK(IsSameDexFile(GetGraph()->GetDexFile(), *invoke->GetMethodReference().dex_file) || GetCompilerOptions().WithinOatFile(invoke->GetMethodReference().dex_file) || ContainsElement(Runtime::Current()->GetClassLinker()->GetBootClassPath(), invoke->GetMethodReference().dex_file)); - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(index)->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(index)->AsX86ComputeBaseMethodAddress(); // Add the patch entry and bind its label at the end of the instruction. method_bss_entry_patches_.emplace_back( method_address, @@ -5669,18 +5593,16 @@ void CodeGeneratorX86::RecordMethodBssEntryPatch(HInvoke* invoke) { } void CodeGeneratorX86::RecordBootImageTypePatch(HLoadClass* load_class) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - load_class->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(); + load_class->InputAt(0)->AsX86ComputeBaseMethodAddress(); boot_image_type_patches_.emplace_back( method_address, &load_class->GetDexFile(), load_class->GetTypeIndex().index_); __ Bind(&boot_image_type_patches_.back().label); } Label* CodeGeneratorX86::NewTypeBssEntryPatch(HLoadClass* load_class) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - load_class->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(); + load_class->InputAt(0)->AsX86ComputeBaseMethodAddress(); ArenaDeque* patches = nullptr; switch (load_class->GetLoadKind()) { case HLoadClass::LoadKind::kBssEntry: @@ -5702,27 +5624,24 @@ Label* CodeGeneratorX86::NewTypeBssEntryPatch(HLoadClass* load_class) { } void CodeGeneratorX86::RecordBootImageStringPatch(HLoadString* load_string) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - load_string->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(); + load_string->InputAt(0)->AsX86ComputeBaseMethodAddress(); boot_image_string_patches_.emplace_back( method_address, &load_string->GetDexFile(), load_string->GetStringIndex().index_); __ Bind(&boot_image_string_patches_.back().label); } Label* CodeGeneratorX86::NewStringBssEntryPatch(HLoadString* load_string) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - load_string->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(); + load_string->InputAt(0)->AsX86ComputeBaseMethodAddress(); string_bss_entry_patches_.emplace_back( method_address, &load_string->GetDexFile(), load_string->GetStringIndex().index_); return &string_bss_entry_patches_.back().label; } void CodeGeneratorX86::RecordBootImageJniEntrypointPatch(HInvokeStaticOrDirect* invoke) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddress(); boot_image_jni_entrypoint_patches_.emplace_back( method_address, invoke->GetResolvedMethodReference().dex_file, @@ -5734,18 +5653,16 @@ void CodeGeneratorX86::LoadBootImageAddress(Register reg, uint32_t boot_image_reference, HInvokeStaticOrDirect* invoke) { if (GetCompilerOptions().IsBootImage()) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddress(); DCHECK(method_address != nullptr); Register method_address_reg = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()).AsRegister(); __ leal(reg, Address(method_address_reg, CodeGeneratorX86::kPlaceholder32BitOffset)); RecordBootImageIntrinsicPatch(method_address, boot_image_reference); } else if (GetCompilerOptions().GetCompilePic()) { - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddress(); DCHECK(method_address != nullptr); Register method_address_reg = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()).AsRegister(); @@ -5764,9 +5681,8 @@ void CodeGeneratorX86::LoadIntrinsicDeclaringClass(Register reg, HInvokeStaticOr DCHECK_NE(invoke->GetIntrinsic(), Intrinsics::kNone); if (GetCompilerOptions().IsBootImage()) { // Load the class the same way as for HLoadClass::LoadKind::kBootImageLinkTimePcRelative. - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddress(); DCHECK(method_address != nullptr); Register method_address_reg = invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()).AsRegister(); @@ -6185,9 +6101,7 @@ void InstructionCodeGeneratorX86::HandleFieldSet(HInstruction* instruction, DataType::Type field_type = field_info.GetFieldType(); uint32_t offset = field_info.GetFieldOffset().Uint32Value(); bool is_predicated = - instruction->IsInstanceFieldSet() && - // TODO: Remove "OrNull". - instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet(); + instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet(); Address field_addr(base, offset); @@ -6441,9 +6355,8 @@ void InstructionCodeGeneratorX86::VisitArrayGet(HArrayGet* instruction) { // Baker's using a slow path (and also unpoison the loaded // reference, if heap poisoning is enabled). if (index.IsConstant()) { - // TODO: Remove "OrNull". uint32_t offset = - (index.GetConstant()->AsIntConstantOrNull()->GetValue() << TIMES_4) + data_offset; + (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; codegen_->MaybeGenerateReadBarrierSlow(instruction, out_loc, out_loc, obj_loc, offset); } else { codegen_->MaybeGenerateReadBarrierSlow( @@ -6682,8 +6595,7 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) { value.AsRegisterPairHigh()); } else { DCHECK(value.IsConstant()); - // TODO: Remove "OrNull". - int64_t val = value.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t val = value.GetConstant()->AsLongConstant()->GetValue(); __ movl(CodeGeneratorX86::ArrayAddress(array, index, TIMES_8, data_offset), Immediate(Low32Bits(val))); codegen_->MaybeRecordImplicitNullCheck(instruction); @@ -6700,9 +6612,7 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) { __ movss(address, value.AsFpuRegister()); } else { DCHECK(value.IsConstant()); - // TODO: Remove "OrNull". - int32_t v = - bit_cast(value.GetConstant()->AsFloatConstantOrNull()->GetValue()); + int32_t v = bit_cast(value.GetConstant()->AsFloatConstant()->GetValue()); __ movl(address, Immediate(v)); } codegen_->MaybeRecordImplicitNullCheck(instruction); @@ -6718,9 +6628,7 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) { DCHECK(value.IsConstant()); Address address_hi = CodeGeneratorX86::ArrayAddress(array, index, TIMES_8, offset + kX86WordSize); - // TODO: Remove "OrNull". - int64_t v = - bit_cast(value.GetConstant()->AsDoubleConstantOrNull()->GetValue()); + int64_t v = bit_cast(value.GetConstant()->AsDoubleConstant()->GetValue()); __ movl(address, Immediate(Low32Bits(v))); codegen_->MaybeRecordImplicitNullCheck(instruction); __ movl(address_hi, Immediate(High32Bits(v))); @@ -6812,9 +6720,7 @@ void InstructionCodeGeneratorX86::VisitBoundsCheck(HBoundsCheck* instruction) { if (array_length->IsEmittedAtUseSite()) { // Address the length field in the array. DCHECK(array_length->IsArrayLength()); - // TODO: Remove "OrNull". - uint32_t len_offset = - CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLengthOrNull()); + uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLength()); Location array_loc = array_length->GetLocations()->InAt(0); Address array_len(array_loc.AsRegister(), len_offset); if (is_string_compressed_char_at) { @@ -6851,8 +6757,7 @@ void LocationsBuilderX86::VisitParallelMove(HParallelMove* instruction ATTRIBUTE void InstructionCodeGeneratorX86::VisitParallelMove(HParallelMove* instruction) { if (instruction->GetNext()->IsSuspendCheck() && instruction->GetBlock()->GetLoopInformation() != nullptr) { - // TODO: Remove "OrNull". - HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull(); + HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck(); // The back edge will generate the suspend check. codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction); } @@ -7031,8 +6936,7 @@ void ParallelMoveResolverX86::EmitMove(size_t index) { __ movl(Address(ESP, destination.GetStackIndex()), Immediate(value)); } } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - float fp_value = constant->AsFloatConstantOrNull()->GetValue(); + float fp_value = constant->AsFloatConstant()->GetValue(); int32_t value = bit_cast(fp_value); Immediate imm(value); if (destination.IsFpuRegister()) { @@ -7052,8 +6956,7 @@ void ParallelMoveResolverX86::EmitMove(size_t index) { __ movl(Address(ESP, destination.GetStackIndex()), imm); } } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - int64_t value = constant->AsLongConstantOrNull()->GetValue(); + int64_t value = constant->AsLongConstant()->GetValue(); int32_t low_value = Low32Bits(value); int32_t high_value = High32Bits(value); Immediate low(low_value); @@ -7067,8 +6970,7 @@ void ParallelMoveResolverX86::EmitMove(size_t index) { } } else { DCHECK(constant->IsDoubleConstant()); - // TODO: Remove "OrNull". - double dbl_value = constant->AsDoubleConstantOrNull()->GetValue(); + double dbl_value = constant->AsDoubleConstant()->GetValue(); int64_t value = bit_cast(dbl_value); int32_t low_value = Low32Bits(value); int32_t high_value = High32Bits(value); @@ -7342,8 +7244,7 @@ void InstructionCodeGeneratorX86::VisitLoadClass(HLoadClass* cls) NO_THREAD_SAFE DCHECK(!codegen_->GetCompilerOptions().IsBootImage()); Register method_address = locations->InAt(0).AsRegister(); __ movl(out, Address(method_address, CodeGeneratorX86::kPlaceholder32BitOffset)); - // TODO: Remove "OrNull". - codegen_->RecordBootImageRelRoPatch(cls->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(), + codegen_->RecordBootImageRelRoPatch(cls->InputAt(0)->AsX86ComputeBaseMethodAddress(), CodeGenerator::GetBootImageOffset(cls)); break; } @@ -7536,8 +7437,7 @@ void InstructionCodeGeneratorX86::VisitLoadString(HLoadString* load) NO_THREAD_S DCHECK(!codegen_->GetCompilerOptions().IsBootImage()); Register method_address = locations->InAt(0).AsRegister(); __ movl(out, Address(method_address, CodeGeneratorX86::kPlaceholder32BitOffset)); - // TODO: Remove "OrNull". - codegen_->RecordBootImageRelRoPatch(load->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(), + codegen_->RecordBootImageRelRoPatch(load->InputAt(0)->AsX86ComputeBaseMethodAddress(), CodeGenerator::GetBootImageOffset(load)); return; } @@ -8293,17 +8193,14 @@ void InstructionCodeGeneratorX86::HandleBitwiseOperation(HBinaryOperation* instr } else if (second.IsConstant()) { if (instruction->IsAnd()) { __ andl(first.AsRegister(), - // TODO: Remove "OrNull". - Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(second.GetConstant()->AsIntConstant()->GetValue())); } else if (instruction->IsOr()) { __ orl(first.AsRegister(), - // TODO: Remove "OrNull". - Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(second.GetConstant()->AsIntConstant()->GetValue())); } else { DCHECK(instruction->IsXor()); __ xorl(first.AsRegister(), - // TODO: Remove "OrNull". - Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(second.GetConstant()->AsIntConstant()->GetValue())); } } else { if (instruction->IsAnd()) { @@ -8346,8 +8243,7 @@ void InstructionCodeGeneratorX86::HandleBitwiseOperation(HBinaryOperation* instr } } else { DCHECK(second.IsConstant()) << second; - // TODO: Remove "OrNull". - int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = second.GetConstant()->AsLongConstant()->GetValue(); int32_t low_value = Low32Bits(value); int32_t high_value = High32Bits(value); Immediate low(low_value); @@ -8887,17 +8783,13 @@ void InstructionCodeGeneratorX86::VisitX86LoadFromConstantTable(HX86LoadFromCons case DataType::Type::kFloat32: __ movss(out.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - value->AsFloatConstantOrNull()->GetValue(), - insn->GetBaseMethodAddress(), - const_area)); + value->AsFloatConstant()->GetValue(), insn->GetBaseMethodAddress(), const_area)); break; case DataType::Type::kFloat64: __ movsd(out.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - value->AsDoubleConstantOrNull()->GetValue(), + value->AsDoubleConstant()->GetValue(), insn->GetBaseMethodAddress(), const_area)); break; @@ -8905,10 +8797,7 @@ void InstructionCodeGeneratorX86::VisitX86LoadFromConstantTable(HX86LoadFromCons case DataType::Type::kInt32: __ movl(out.AsRegister(), codegen_->LiteralInt32Address( - // TODO: Remove "OrNull". - value->AsIntConstantOrNull()->GetValue(), - insn->GetBaseMethodAddress(), - const_area)); + value->AsIntConstant()->GetValue(), insn->GetBaseMethodAddress(), const_area)); break; default: @@ -9083,9 +8972,7 @@ Address CodeGeneratorX86::ArrayAddress(Register obj, ScaleFactor scale, uint32_t data_offset) { return index.IsConstant() - ? Address(obj, - // TODO: Remove "OrNull". - (index.GetConstant()->AsIntConstantOrNull()->GetValue() << scale) + data_offset) + ? Address(obj, (index.GetConstant()->AsIntConstant()->GetValue() << scale) + data_offset) : Address(obj, index.AsRegister(), scale, data_offset); } diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc index 1170cd946f..df2bef747f 100644 --- a/compiler/optimizing/code_generator_x86_64.cc +++ b/compiler/optimizing/code_generator_x86_64.cc @@ -215,8 +215,7 @@ class BoundsCheckSlowPathX86_64 : public SlowPathCode { // Are we using an array length from memory? if (!length_loc.IsValid()) { DCHECK(instruction_->InputAt(1)->IsArrayLength()); - // TODO: Remove "OrNull". - HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLengthOrNull(); + HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLength(); DCHECK(array_length->IsEmittedAtUseSite()); uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length); Location array_loc = array_length->GetLocations()->InAt(0); @@ -252,8 +251,7 @@ class BoundsCheckSlowPathX86_64 : public SlowPathCode { DataType::Type::kInt32); } - // TODO: Remove "OrNull". - QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt() + QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt() ? kQuickThrowStringBounds : kQuickThrowArrayBounds; x86_64_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this); @@ -345,8 +343,7 @@ class LoadStringSlowPathX86_64 : public SlowPathCode { __ Bind(GetEntryLabel()); SaveLiveRegisters(codegen, locations); - // TODO: Remove "OrNull". - const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex(); + const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex(); // Custom calling convention: RAX serves as both input and output. __ movl(CpuRegister(RAX), Immediate(string_index.index_)); x86_64_codegen->InvokeRuntime(kQuickResolveString, @@ -382,8 +379,7 @@ class TypeCheckSlowPathX86_64 : public SlowPathCode { if (kPoisonHeapReferences && instruction_->IsCheckCast() && - // TODO: Remove "OrNull". - instruction_->AsCheckCastOrNull()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) { + instruction_->AsCheckCast()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) { // First, unpoison the `cls` reference that was poisoned for direct memory comparison. __ UnpoisonHeapReference(locations->InAt(1).AsRegister()); } @@ -443,8 +439,7 @@ class DeoptimizationSlowPathX86_64 : public SlowPathCode { InvokeRuntimeCallingConvention calling_convention; x86_64_codegen->Load32BitValue( CpuRegister(calling_convention.GetRegisterAt(0)), - // TODO: Remove "OrNull". - static_cast(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind())); + static_cast(instruction_->AsDeoptimize()->GetDeoptimizationKind())); x86_64_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this); CheckEntrypointTypes(); } @@ -622,8 +617,7 @@ class ReadBarrierMarkAndUpdateFieldSlowPathX86_64 : public SlowPathCode { DCHECK((instruction_->IsInvoke() && instruction_->GetLocations()->Intrinsified())) << "Unexpected instruction in read barrier marking and field updating slow path: " << instruction_->DebugName(); - // TODO: Remove "OrNull". - HInvoke* invoke = instruction_->AsInvokeOrNull(); + HInvoke* invoke = instruction_->AsInvoke(); DCHECK(IsUnsafeCASObject(invoke) || IsVarHandleCASFamily(invoke)) << invoke->GetIntrinsic(); __ Bind(GetEntryLabel()); @@ -859,17 +853,13 @@ class ReadBarrierForHeapReferenceSlowPathX86_64 : public SlowPathCode { // to an object field within an object. DCHECK(instruction_->IsInvoke()) << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - DCHECK((instruction_->AsInvokeOrNull()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == - Intrinsics::kUnsafeGetObjectVolatile) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == - Intrinsics::kJdkUnsafeGetObject) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == + DCHECK((instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) || + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObjectVolatile) || + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObject) || + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObjectVolatile) || - (instruction_->AsInvokeOrNull()->GetIntrinsic() == - Intrinsics::kJdkUnsafeGetObjectAcquire)) - << instruction_->AsInvokeOrNull()->GetIntrinsic(); + (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObjectAcquire)) + << instruction_->AsInvoke()->GetIntrinsic(); DCHECK_EQ(offset_, 0U); DCHECK(index_.IsRegister()); } @@ -1850,8 +1840,7 @@ void CodeGeneratorX86_64::Move(Location destination, Location source) { } else if (source.IsConstant()) { HConstant* constant = source.GetConstant(); if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - Load64BitValue(dest, constant->AsLongConstantOrNull()->GetValue()); + Load64BitValue(dest, constant->AsLongConstant()->GetValue()); } else if (constant->IsDoubleConstant()) { Load64BitValue(dest, GetInt64ValueOf(constant)); } else { @@ -1991,8 +1980,7 @@ void InstructionCodeGeneratorX86_64::HandleGoto(HInstruction* got, HBasicBlock* } if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) { - // TODO: Remove "OrNull". - GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr); + GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr); } if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) { __ jmp(codegen_->GetLabelOf(successor)); @@ -2064,8 +2052,7 @@ void InstructionCodeGeneratorX86_64::GenerateCompareTest(HCondition* condition) } else if (right.IsConstant()) { __ ucomiss(left.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - right.GetConstant()->AsFloatConstantOrNull()->GetValue())); + right.GetConstant()->AsFloatConstant()->GetValue())); } else { DCHECK(right.IsStackSlot()); __ ucomiss(left.AsFpuRegister(), @@ -2079,8 +2066,7 @@ void InstructionCodeGeneratorX86_64::GenerateCompareTest(HCondition* condition) } else if (right.IsConstant()) { __ ucomisd(left.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - right.GetConstant()->AsDoubleConstantOrNull()->GetValue())); + right.GetConstant()->AsDoubleConstant()->GetValue())); } else { DCHECK(right.IsDoubleStackSlot()); __ ucomisd(left.AsFpuRegister(), @@ -2155,14 +2141,12 @@ void InstructionCodeGeneratorX86_64::GenerateTestAndBranch(HInstruction* instruc return; } else if (cond->IsIntConstant()) { // Constant condition, statically compared against "true" (integer value 1). - // TODO: Remove "OrNull". - if (cond->AsIntConstantOrNull()->IsTrue()) { + if (cond->AsIntConstant()->IsTrue()) { if (true_target != nullptr) { __ jmp(true_target); } } else { - // TODO: Remove "OrNull". - DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << cond->AsIntConstantOrNull()->GetValue(); + DCHECK(cond->AsIntConstant()->IsFalse()) << cond->AsIntConstant()->GetValue(); if (false_target != nullptr) { __ jmp(false_target); } @@ -2181,12 +2165,9 @@ void InstructionCodeGeneratorX86_64::GenerateTestAndBranch(HInstruction* instruc if (IsBooleanValueOrMaterializedCondition(cond)) { if (AreEflagsSetFrom(cond, instruction)) { if (true_target == nullptr) { - // TODO: Remove "OrNull". - __ j(X86_64IntegerCondition(cond->AsConditionOrNull()->GetOppositeCondition()), - false_target); + __ j(X86_64IntegerCondition(cond->AsCondition()->GetOppositeCondition()), false_target); } else { - // TODO: Remove "OrNull". - __ j(X86_64IntegerCondition(cond->AsConditionOrNull()->GetCondition()), true_target); + __ j(X86_64IntegerCondition(cond->AsCondition()->GetCondition()), true_target); } } else { // Materialized condition, compare against 0. @@ -2205,8 +2186,7 @@ void InstructionCodeGeneratorX86_64::GenerateTestAndBranch(HInstruction* instruc } else { // Condition has not been materialized, use its inputs as the // comparison and its condition as the branch condition. - // TODO: Remove "OrNull". - HCondition* condition = cond->AsConditionOrNull(); + HCondition* condition = cond->AsCondition(); // If this is a long or FP comparison that has been folded into // the HCondition, generate the comparison directly. @@ -2335,8 +2315,7 @@ void InstructionCodeGeneratorX86_64::VisitSelect(HSelect* select) { // Figure out how to test the 'condition'. if (select_condition->IsCondition()) { - // TODO: Remove "OrNull". - HCondition* condition = select_condition->AsConditionOrNull(); + HCondition* condition = select_condition->AsCondition(); if (!condition->IsEmittedAtUseSite()) { // This was a previously materialized condition. // Can we use the existing condition code? @@ -2456,8 +2435,7 @@ void InstructionCodeGeneratorX86_64::HandleCondition(HCondition* cond) { case DataType::Type::kFloat32: { XmmRegister lhs_reg = lhs.AsFpuRegister(); if (rhs.IsConstant()) { - // TODO: Remove "OrNull". - float value = rhs.GetConstant()->AsFloatConstantOrNull()->GetValue(); + float value = rhs.GetConstant()->AsFloatConstant()->GetValue(); __ ucomiss(lhs_reg, codegen_->LiteralFloatAddress(value)); } else if (rhs.IsStackSlot()) { __ ucomiss(lhs_reg, Address(CpuRegister(RSP), rhs.GetStackIndex())); @@ -2470,8 +2448,7 @@ void InstructionCodeGeneratorX86_64::HandleCondition(HCondition* cond) { case DataType::Type::kFloat64: { XmmRegister lhs_reg = lhs.AsFpuRegister(); if (rhs.IsConstant()) { - // TODO: Remove "OrNull". - double value = rhs.GetConstant()->AsDoubleConstantOrNull()->GetValue(); + double value = rhs.GetConstant()->AsDoubleConstant()->GetValue(); __ ucomisd(lhs_reg, codegen_->LiteralDoubleAddress(value)); } else if (rhs.IsDoubleStackSlot()) { __ ucomisd(lhs_reg, Address(CpuRegister(RSP), rhs.GetStackIndex())); @@ -2632,8 +2609,7 @@ void InstructionCodeGeneratorX86_64::VisitCompare(HCompare* compare) { case DataType::Type::kFloat32: { XmmRegister left_reg = left.AsFpuRegister(); if (right.IsConstant()) { - // TODO: Remove "OrNull". - float value = right.GetConstant()->AsFloatConstantOrNull()->GetValue(); + float value = right.GetConstant()->AsFloatConstant()->GetValue(); __ ucomiss(left_reg, codegen_->LiteralFloatAddress(value)); } else if (right.IsStackSlot()) { __ ucomiss(left_reg, Address(CpuRegister(RSP), right.GetStackIndex())); @@ -2647,8 +2623,7 @@ void InstructionCodeGeneratorX86_64::VisitCompare(HCompare* compare) { case DataType::Type::kFloat64: { XmmRegister left_reg = left.AsFpuRegister(); if (right.IsConstant()) { - // TODO: Remove "OrNull". - double value = right.GetConstant()->AsDoubleConstantOrNull()->GetValue(); + double value = right.GetConstant()->AsDoubleConstant()->GetValue(); __ ucomisd(left_reg, codegen_->LiteralDoubleAddress(value)); } else if (right.IsDoubleStackSlot()) { __ ucomisd(left_reg, Address(CpuRegister(RSP), right.GetStackIndex())); @@ -3436,8 +3411,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver } else { DCHECK(in.IsConstant()); DCHECK(in.GetConstant()->IsLongConstant()); - // TODO: Remove "OrNull". - int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = in.GetConstant()->AsLongConstant()->GetValue(); __ movl(out.AsRegister(), Immediate(static_cast(value))); } break; @@ -3563,8 +3537,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver if (in.IsRegister()) { __ cvtsi2ss(out.AsFpuRegister(), in.AsRegister(), false); } else if (in.IsConstant()) { - // TODO: Remove "OrNull". - int32_t v = in.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t v = in.GetConstant()->AsIntConstant()->GetValue(); XmmRegister dest = out.AsFpuRegister(); codegen_->Load32BitValue(dest, static_cast(v)); } else { @@ -3577,8 +3550,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver if (in.IsRegister()) { __ cvtsi2ss(out.AsFpuRegister(), in.AsRegister(), true); } else if (in.IsConstant()) { - // TODO: Remove "OrNull". - int64_t v = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t v = in.GetConstant()->AsLongConstant()->GetValue(); XmmRegister dest = out.AsFpuRegister(); codegen_->Load32BitValue(dest, static_cast(v)); } else { @@ -3591,8 +3563,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver if (in.IsFpuRegister()) { __ cvtsd2ss(out.AsFpuRegister(), in.AsFpuRegister()); } else if (in.IsConstant()) { - // TODO: Remove "OrNull". - double v = in.GetConstant()->AsDoubleConstantOrNull()->GetValue(); + double v = in.GetConstant()->AsDoubleConstant()->GetValue(); XmmRegister dest = out.AsFpuRegister(); codegen_->Load32BitValue(dest, static_cast(v)); } else { @@ -3618,8 +3589,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver if (in.IsRegister()) { __ cvtsi2sd(out.AsFpuRegister(), in.AsRegister(), false); } else if (in.IsConstant()) { - // TODO: Remove "OrNull". - int32_t v = in.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t v = in.GetConstant()->AsIntConstant()->GetValue(); XmmRegister dest = out.AsFpuRegister(); codegen_->Load64BitValue(dest, static_cast(v)); } else { @@ -3632,8 +3602,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver if (in.IsRegister()) { __ cvtsi2sd(out.AsFpuRegister(), in.AsRegister(), true); } else if (in.IsConstant()) { - // TODO: Remove "OrNull". - int64_t v = in.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t v = in.GetConstant()->AsLongConstant()->GetValue(); XmmRegister dest = out.AsFpuRegister(); codegen_->Load64BitValue(dest, static_cast(v)); } else { @@ -3646,8 +3615,7 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver if (in.IsFpuRegister()) { __ cvtss2sd(out.AsFpuRegister(), in.AsFpuRegister()); } else if (in.IsConstant()) { - // TODO: Remove "OrNull". - float v = in.GetConstant()->AsFloatConstantOrNull()->GetValue(); + float v = in.GetConstant()->AsFloatConstant()->GetValue(); XmmRegister dest = out.AsFpuRegister(); codegen_->Load64BitValue(dest, static_cast(v)); } else { @@ -3720,13 +3688,10 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) { } else if (second.IsConstant()) { if (out.AsRegister() == first.AsRegister()) { __ addl(out.AsRegister(), - // TODO: Remove "OrNull". - Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(second.GetConstant()->AsIntConstant()->GetValue())); } else { __ leal(out.AsRegister(), Address( - first.AsRegister(), - // TODO: Remove "OrNull". - second.GetConstant()->AsIntConstantOrNull()->GetValue())); + first.AsRegister(), second.GetConstant()->AsIntConstant()->GetValue())); } } else { DCHECK(first.Equals(locations->Out())); @@ -3747,8 +3712,7 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) { } } else { DCHECK(second.IsConstant()); - // TODO: Remove "OrNull". - int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = second.GetConstant()->AsLongConstant()->GetValue(); int32_t int32_value = Low32Bits(value); DCHECK_EQ(int32_value, value); if (out.AsRegister() == first.AsRegister()) { @@ -3767,8 +3731,7 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) { } else if (second.IsConstant()) { __ addss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsFloatConstantOrNull()->GetValue())); + second.GetConstant()->AsFloatConstant()->GetValue())); } else { DCHECK(second.IsStackSlot()); __ addss(first.AsFpuRegister(), @@ -3783,8 +3746,7 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) { } else if (second.IsConstant()) { __ addsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsDoubleConstantOrNull()->GetValue())); + second.GetConstant()->AsDoubleConstant()->GetValue())); } else { DCHECK(second.IsDoubleStackSlot()); __ addsd(first.AsFpuRegister(), @@ -3836,8 +3798,7 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) { if (second.IsRegister()) { __ subl(first.AsRegister(), second.AsRegister()); } else if (second.IsConstant()) { - // TODO: Remove "OrNull". - Immediate imm(second.GetConstant()->AsIntConstantOrNull()->GetValue()); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue()); __ subl(first.AsRegister(), imm); } else { __ subl(first.AsRegister(), Address(CpuRegister(RSP), second.GetStackIndex())); @@ -3846,8 +3807,7 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) { } case DataType::Type::kInt64: { if (second.IsConstant()) { - // TODO: Remove "OrNull". - int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = second.GetConstant()->AsLongConstant()->GetValue(); DCHECK(IsInt<32>(value)); __ subq(first.AsRegister(), Immediate(static_cast(value))); } else { @@ -3862,8 +3822,7 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) { } else if (second.IsConstant()) { __ subss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsFloatConstantOrNull()->GetValue())); + second.GetConstant()->AsFloatConstant()->GetValue())); } else { DCHECK(second.IsStackSlot()); __ subss(first.AsFpuRegister(), @@ -3878,8 +3837,7 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) { } else if (second.IsConstant()) { __ subsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsDoubleConstantOrNull()->GetValue())); + second.GetConstant()->AsDoubleConstant()->GetValue())); } else { DCHECK(second.IsDoubleStackSlot()); __ subsd(first.AsFpuRegister(), @@ -3912,8 +3870,7 @@ void LocationsBuilderX86_64::VisitMul(HMul* mul) { locations->SetInAt(0, Location::RequiresRegister()); locations->SetInAt(1, Location::Any()); if (mul->InputAt(1)->IsLongConstant() && - // TODO: Remove "OrNull". - IsInt<32>(mul->InputAt(1)->AsLongConstantOrNull()->GetValue())) { + IsInt<32>(mul->InputAt(1)->AsLongConstant()->GetValue())) { // Can use 3 operand multiply. locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap); } else { @@ -3944,8 +3901,7 @@ void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) { // The constant may have ended up in a register, so test explicitly to avoid // problems where the output may not be the same as the first operand. if (mul->InputAt(1)->IsIntConstant()) { - // TODO: Remove "OrNull". - Immediate imm(mul->InputAt(1)->AsIntConstantOrNull()->GetValue()); + Immediate imm(mul->InputAt(1)->AsIntConstant()->GetValue()); __ imull(out.AsRegister(), first.AsRegister(), imm); } else if (second.IsRegister()) { DCHECK(first.Equals(out)); @@ -3961,8 +3917,7 @@ void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) { // The constant may have ended up in a register, so test explicitly to avoid // problems where the output may not be the same as the first operand. if (mul->InputAt(1)->IsLongConstant()) { - // TODO: Remove "OrNull". - int64_t value = mul->InputAt(1)->AsLongConstantOrNull()->GetValue(); + int64_t value = mul->InputAt(1)->AsLongConstant()->GetValue(); if (IsInt<32>(value)) { __ imulq(out.AsRegister(), first.AsRegister(), Immediate(static_cast(value))); @@ -3990,8 +3945,7 @@ void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) { } else if (second.IsConstant()) { __ mulss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsFloatConstantOrNull()->GetValue())); + second.GetConstant()->AsFloatConstant()->GetValue())); } else { DCHECK(second.IsStackSlot()); __ mulss(first.AsFpuRegister(), @@ -4007,8 +3961,7 @@ void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) { } else if (second.IsConstant()) { __ mulsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsDoubleConstantOrNull()->GetValue())); + second.GetConstant()->AsDoubleConstant()->GetValue())); } else { DCHECK(second.IsDoubleStackSlot()); __ mulsd(first.AsFpuRegister(), @@ -4256,8 +4209,7 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemWithAnyConstant(HBinaryOperat // TODO: can these branches be written as one? if (instruction->GetResultType() == DataType::Type::kInt32) { - // TODO: Remove "OrNull". - int imm = second.GetConstant()->AsIntConstantOrNull()->GetValue(); + int imm = second.GetConstant()->AsIntConstant()->GetValue(); CalculateMagicAndShiftForDivRem(imm, false /* is_long= */, &magic, &shift); @@ -4289,8 +4241,7 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemWithAnyConstant(HBinaryOperat __ movl(eax, edx); } } else { - // TODO: Remove "OrNull". - int64_t imm = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t imm = second.GetConstant()->AsLongConstant()->GetValue(); DCHECK_EQ(instruction->GetResultType(), DataType::Type::kInt64); @@ -4366,11 +4317,9 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemIntegral(HBinaryOperation* in DivRemOneOrMinusOne(instruction); } else if (IsPowerOfTwo(AbsOrMin(imm))) { if (is_div) { - // TODO: Remove "OrNull". - DivByPowerOfTwo(instruction->AsDivOrNull()); + DivByPowerOfTwo(instruction->AsDiv()); } else { - // TODO: Remove "OrNull". - RemByPowerOfTwo(instruction->AsRemOrNull()); + RemByPowerOfTwo(instruction->AsRem()); } } else { DCHECK(imm <= -2 || imm >= 2); @@ -4458,8 +4407,7 @@ void InstructionCodeGeneratorX86_64::VisitDiv(HDiv* div) { } else if (second.IsConstant()) { __ divss(first.AsFpuRegister(), codegen_->LiteralFloatAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsFloatConstantOrNull()->GetValue())); + second.GetConstant()->AsFloatConstant()->GetValue())); } else { DCHECK(second.IsStackSlot()); __ divss(first.AsFpuRegister(), @@ -4474,8 +4422,7 @@ void InstructionCodeGeneratorX86_64::VisitDiv(HDiv* div) { } else if (second.IsConstant()) { __ divsd(first.AsFpuRegister(), codegen_->LiteralDoubleAddress( - // TODO: Remove "OrNull". - second.GetConstant()->AsDoubleConstantOrNull()->GetValue())); + second.GetConstant()->AsDoubleConstant()->GetValue())); } else { DCHECK(second.IsDoubleStackSlot()); __ divsd(first.AsFpuRegister(), @@ -4805,8 +4752,7 @@ void InstructionCodeGeneratorX86_64::VisitDivZeroCheck(HDivZeroCheck* instructio __ j(kEqual, slow_path->GetEntryLabel()); } else { DCHECK(value.IsConstant()) << value; - // TODO: Remove "OrNull". - if (value.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) { + if (value.GetConstant()->AsIntConstant()->GetValue() == 0) { __ jmp(slow_path->GetEntryLabel()); } } @@ -4821,8 +4767,7 @@ void InstructionCodeGeneratorX86_64::VisitDivZeroCheck(HDivZeroCheck* instructio __ j(kEqual, slow_path->GetEntryLabel()); } else { DCHECK(value.IsConstant()) << value; - // TODO: Remove "OrNull". - if (value.GetConstant()->AsLongConstantOrNull()->GetValue() == 0) { + if (value.GetConstant()->AsLongConstant()->GetValue() == 0) { __ jmp(slow_path->GetEntryLabel()); } } @@ -4872,9 +4817,7 @@ void InstructionCodeGeneratorX86_64::HandleShift(HBinaryOperation* op) { __ shrl(first_reg, second_reg); } } else { - // TODO: Remove "OrNull". - Immediate imm( - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance); if (op->IsShl()) { __ shll(first_reg, imm); } else if (op->IsShr()) { @@ -4896,9 +4839,7 @@ void InstructionCodeGeneratorX86_64::HandleShift(HBinaryOperation* op) { __ shrq(first_reg, second_reg); } } else { - // TODO: Remove "OrNull". - Immediate imm( - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance); if (op->IsShl()) { __ shlq(first_reg, imm); } else if (op->IsShr()) { @@ -4945,9 +4886,7 @@ void InstructionCodeGeneratorX86_64::VisitRor(HRor* ror) { CpuRegister second_reg = second.AsRegister(); __ rorl(first_reg, second_reg); } else { - // TODO: Remove "OrNull". - Immediate imm( - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance); __ rorl(first_reg, imm); } break; @@ -4956,9 +4895,7 @@ void InstructionCodeGeneratorX86_64::VisitRor(HRor* ror) { CpuRegister second_reg = second.AsRegister(); __ rorq(first_reg, second_reg); } else { - // TODO: Remove "OrNull". - Immediate imm( - second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance); __ rorq(first_reg, imm); } break; @@ -5478,9 +5415,7 @@ void InstructionCodeGeneratorX86_64::HandleFieldSet(HInstruction* instruction, DataType::Type field_type = field_info.GetFieldType(); uint32_t offset = field_info.GetFieldOffset().Uint32Value(); bool is_predicated = - instruction->IsInstanceFieldSet() && - // TODO: Remove "OrNull". - instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet(); + instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet(); NearLabel pred_is_null; if (is_predicated) { @@ -5732,9 +5667,8 @@ void InstructionCodeGeneratorX86_64::VisitArrayGet(HArrayGet* instruction) { // Baker's using a slow path (and also unpoison the loaded // reference, if heap poisoning is enabled). if (index.IsConstant()) { - // TODO: Remove "OrNull". uint32_t offset = - (index.GetConstant()->AsIntConstantOrNull()->GetValue() << TIMES_4) + data_offset; + (index.GetConstant()->AsIntConstant()->GetValue() << TIMES_4) + data_offset; codegen_->MaybeGenerateReadBarrierSlow(instruction, out_loc, out_loc, obj_loc, offset); } else { codegen_->MaybeGenerateReadBarrierSlow( @@ -5968,8 +5902,7 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) { __ movq(address, value.AsRegister()); codegen_->MaybeRecordImplicitNullCheck(instruction); } else { - // TODO: Remove "OrNull". - int64_t v = value.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t v = value.GetConstant()->AsLongConstant()->GetValue(); Address address_high = CodeGeneratorX86_64::ArrayAddress(array, index, TIMES_8, offset + sizeof(int32_t)); codegen_->MoveInt64ToAddress(address, address_high, v, instruction); @@ -5984,9 +5917,7 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) { __ movss(address, value.AsFpuRegister()); } else { DCHECK(value.IsConstant()); - // TODO: Remove "OrNull". - int32_t v = - bit_cast(value.GetConstant()->AsFloatConstantOrNull()->GetValue()); + int32_t v = bit_cast(value.GetConstant()->AsFloatConstant()->GetValue()); __ movl(address, Immediate(v)); } codegen_->MaybeRecordImplicitNullCheck(instruction); @@ -6000,9 +5931,7 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) { __ movsd(address, value.AsFpuRegister()); codegen_->MaybeRecordImplicitNullCheck(instruction); } else { - // TODO: Remove "OrNull". - int64_t v = - bit_cast(value.GetConstant()->AsDoubleConstantOrNull()->GetValue()); + int64_t v = bit_cast(value.GetConstant()->AsDoubleConstant()->GetValue()); Address address_high = CodeGeneratorX86_64::ArrayAddress(array, index, TIMES_8, offset + sizeof(int32_t)); codegen_->MoveInt64ToAddress(address, address_high, v, instruction); @@ -6089,9 +6018,7 @@ void InstructionCodeGeneratorX86_64::VisitBoundsCheck(HBoundsCheck* instruction) if (array_length->IsEmittedAtUseSite()) { // Address the length field in the array. DCHECK(array_length->IsArrayLength()); - // TODO: Remove "OrNull". - uint32_t len_offset = - CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLengthOrNull()); + uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLength()); Location array_loc = array_length->GetLocations()->InAt(0); Address array_len(array_loc.AsRegister(), len_offset); if (mirror::kUseStringCompression && instruction->IsStringCharAt()) { @@ -6164,8 +6091,7 @@ void LocationsBuilderX86_64::VisitParallelMove(HParallelMove* instruction ATTRIB void InstructionCodeGeneratorX86_64::VisitParallelMove(HParallelMove* instruction) { if (instruction->GetNext()->IsSuspendCheck() && instruction->GetBlock()->GetLoopInformation() != nullptr) { - // TODO: Remove "OrNull". - HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull(); + HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck(); // The back edge will generate the suspend check. codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction); } @@ -6296,8 +6222,7 @@ void ParallelMoveResolverX86_64::EmitMove(size_t index) { __ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), Immediate(value)); } } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - int64_t value = constant->AsLongConstantOrNull()->GetValue(); + int64_t value = constant->AsLongConstant()->GetValue(); if (destination.IsRegister()) { codegen_->Load64BitValue(destination.AsRegister(), value); } else { @@ -6305,8 +6230,7 @@ void ParallelMoveResolverX86_64::EmitMove(size_t index) { codegen_->Store64BitValueToStack(destination, value); } } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - float fp_value = constant->AsFloatConstantOrNull()->GetValue(); + float fp_value = constant->AsFloatConstant()->GetValue(); if (destination.IsFpuRegister()) { XmmRegister dest = destination.AsFpuRegister(); codegen_->Load32BitValue(dest, fp_value); @@ -6317,8 +6241,7 @@ void ParallelMoveResolverX86_64::EmitMove(size_t index) { } } else { DCHECK(constant->IsDoubleConstant()) << constant->DebugName(); - // TODO: Remove "OrNull". - double fp_value = constant->AsDoubleConstantOrNull()->GetValue(); + double fp_value = constant->AsDoubleConstant()->GetValue(); int64_t value = bit_cast(fp_value); if (destination.IsFpuRegister()) { XmmRegister dest = destination.AsFpuRegister(); @@ -7529,8 +7452,7 @@ void InstructionCodeGeneratorX86_64::HandleBitwiseOperation(HBinaryOperation* in __ xorl(first.AsRegister(), second.AsRegister()); } } else if (second.IsConstant()) { - // TODO: Remove "OrNull". - Immediate imm(second.GetConstant()->AsIntConstantOrNull()->GetValue()); + Immediate imm(second.GetConstant()->AsIntConstant()->GetValue()); if (instruction->IsAnd()) { __ andl(first.AsRegister(), imm); } else if (instruction->IsOr()) { @@ -7557,8 +7479,7 @@ void InstructionCodeGeneratorX86_64::HandleBitwiseOperation(HBinaryOperation* in int64_t value = 0; if (second.IsConstant()) { second_is_constant = true; - // TODO: Remove "OrNull". - value = second.GetConstant()->AsLongConstantOrNull()->GetValue(); + value = second.GetConstant()->AsLongConstant()->GetValue(); } bool is_int32_value = IsInt<32>(value); @@ -8103,8 +8024,7 @@ void CodeGeneratorX86_64::GenerateIntCompare(CpuRegister lhs, Location rhs) { void CodeGeneratorX86_64::GenerateLongCompare(Location lhs, Location rhs) { CpuRegister lhs_reg = lhs.AsRegister(); if (rhs.IsConstant()) { - // TODO: Remove "OrNull". - int64_t value = rhs.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = rhs.GetConstant()->AsLongConstant()->GetValue(); Compare64BitValue(lhs_reg, value); } else if (rhs.IsDoubleStackSlot()) { __ cmpq(lhs_reg, Address(CpuRegister(RSP), rhs.GetStackIndex())); @@ -8118,9 +8038,7 @@ Address CodeGeneratorX86_64::ArrayAddress(CpuRegister obj, ScaleFactor scale, uint32_t data_offset) { return index.IsConstant() - ? Address(obj, - // TODO: Remove "OrNull". - (index.GetConstant()->AsIntConstantOrNull()->GetValue() << scale) + data_offset) + ? Address(obj, (index.GetConstant()->AsIntConstant()->GetValue() << scale) + data_offset) : Address(obj, index.AsRegister(), scale, data_offset); } diff --git a/compiler/optimizing/code_sinking.cc b/compiler/optimizing/code_sinking.cc index 8a3066521f..d759a16f48 100644 --- a/compiler/optimizing/code_sinking.cc +++ b/compiler/optimizing/code_sinking.cc @@ -53,8 +53,7 @@ void CodeSinking::UncommonBranchSinking() { // actual last instruction. if (last->IsTryBoundary()) { // We have an exit try boundary. Fetch the previous instruction. - // TODO: Remove "OrNull". - DCHECK(!last->AsTryBoundaryOrNull()->IsEntry()); + DCHECK(!last->AsTryBoundary()->IsEntry()); if (last->GetPrevious() == nullptr) { DCHECK(exit_predecessor->IsSingleTryBoundary()); exit_predecessor = exit_predecessor->GetSinglePredecessor(); @@ -81,8 +80,7 @@ static bool IsInterestingInstruction(HInstruction* instruction) { // Volatile stores cannot be moved. if (instruction->IsInstanceFieldSet()) { - // TODO: Remove "OrNull". - if (instruction->AsInstanceFieldSetOrNull()->IsVolatile()) { + if (instruction->AsInstanceFieldSet()->IsVolatile()) { return false; } } @@ -95,8 +93,7 @@ static bool IsInterestingInstruction(HInstruction* instruction) { // Check it is safe to move ConstructorFence. // (Safe to move ConstructorFence for only protecting the new-instance but not for finals.) if (instruction->IsConstructorFence()) { - // TODO: Remove "OrNull". - HConstructorFence* ctor_fence = instruction->AsConstructorFenceOrNull(); + HConstructorFence* ctor_fence = instruction->AsConstructorFence(); // A fence with "0" inputs is dead and should've been removed in a prior pass. DCHECK_NE(0u, ctor_fence->InputCount()); @@ -218,8 +215,7 @@ static HInstruction* FindIdealPosition(HInstruction* instruction, if (user->IsPhi()) { // Special case phis by taking the incoming block for regular ones, // or the dominator for catch phis. - // TODO: Remove "OrNull". - block = user->AsPhiOrNull()->IsCatchPhi() + block = user->AsPhi()->IsCatchPhi() ? block->GetDominator() : block->GetPredecessors()[use.GetIndex()]; } @@ -318,8 +314,7 @@ static HInstruction* FindIdealPosition(HInstruction* instruction, DCHECK(insert_pos->IsControlFlow()); // Avoid splitting HCondition from HIf to prevent unnecessary materialization. if (insert_pos->IsIf()) { - // TODO: Remove "OrNull". - HInstruction* if_input = insert_pos->AsIfOrNull()->InputAt(0); + HInstruction* if_input = insert_pos->AsIf()->InputAt(0); if (if_input == insert_pos->GetPrevious()) { insert_pos = if_input; } @@ -386,9 +381,7 @@ void CodeSinking::SinkCodeToUncommonBranch(HBasicBlock* end_block) { // If we sink to these basic blocks we would be sinking inside of the try so we would like // to check the catch block for post dominance. const bool ends_with_try_boundary_entry = - block->EndsWithTryBoundary() && - // TODO: Remove "OrNull". - block->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry(); + block->EndsWithTryBoundary() && block->GetLastInstruction()->AsTryBoundary()->IsEntry(); ArrayRef successors = ends_with_try_boundary_entry ? block->GetNormalSuccessors() : ArrayRef(block->GetSuccessors()); @@ -578,8 +571,7 @@ void CodeSinking::ReturnSinking() { continue; } - // TODO: Remove "OrNull". - HReturn* ret = pred->GetLastInstruction()->AsReturnOrNull(); + HReturn* ret = pred->GetLastInstruction()->AsReturn(); if (new_phi == nullptr) { // Create the new_phi, if we haven't done so yet. We do it here since we need to know the // type to assign to it. @@ -604,8 +596,7 @@ void CodeSinking::ReturnSinking() { continue; } - // TODO: Remove "OrNull". - HReturnVoid* ret = pred->GetLastInstruction()->AsReturnVoidOrNull(); + HReturnVoid* ret = pred->GetLastInstruction()->AsReturnVoid(); pred->ReplaceAndRemoveInstructionWith(ret, new (graph_->GetAllocator()) HGoto(ret->GetDexPc())); pred->ReplaceSuccessor(exit, new_block); diff --git a/compiler/optimizing/common_arm.h b/compiler/optimizing/common_arm.h index 53768efad6..5f71cb906c 100644 --- a/compiler/optimizing/common_arm.h +++ b/compiler/optimizing/common_arm.h @@ -155,14 +155,12 @@ inline vixl::aarch32::DRegister DRegisterFromS(vixl::aarch32::SRegister s) { inline int32_t Int32ConstantFrom(HInstruction* instr) { if (instr->IsIntConstant()) { - // TODO: Remove "OrNull". - return instr->AsIntConstantOrNull()->GetValue(); + return instr->AsIntConstant()->GetValue(); } else if (instr->IsNullConstant()) { return 0; } else { DCHECK(instr->IsLongConstant()) << instr->DebugName(); - // TODO: Remove "OrNull". - const int64_t ret = instr->AsLongConstantOrNull()->GetValue(); + const int64_t ret = instr->AsLongConstant()->GetValue(); DCHECK_GE(ret, std::numeric_limits::min()); DCHECK_LE(ret, std::numeric_limits::max()); return ret; @@ -176,21 +174,18 @@ inline int32_t Int32ConstantFrom(Location location) { inline int64_t Int64ConstantFrom(Location location) { HConstant* instr = location.GetConstant(); if (instr->IsIntConstant()) { - // TODO: Remove "OrNull". - return instr->AsIntConstantOrNull()->GetValue(); + return instr->AsIntConstant()->GetValue(); } else if (instr->IsNullConstant()) { return 0; } else { DCHECK(instr->IsLongConstant()) << instr->DebugName(); - // TODO: Remove "OrNull". - return instr->AsLongConstantOrNull()->GetValue(); + return instr->AsLongConstant()->GetValue(); } } inline uint64_t Uint64ConstantFrom(HInstruction* instr) { DCHECK(instr->IsConstant()) << instr->DebugName(); - // TODO: Remove "OrNull". - return instr->AsConstantOrNull()->GetValueAsUint64(); + return instr->AsConstant()->GetValueAsUint64(); } inline vixl::aarch32::Operand OperandFrom(Location location, DataType::Type type) { diff --git a/compiler/optimizing/common_arm64.h b/compiler/optimizing/common_arm64.h index 4c3f6d208c..e2ef8d52f2 100644 --- a/compiler/optimizing/common_arm64.h +++ b/compiler/optimizing/common_arm64.h @@ -260,11 +260,9 @@ inline bool Arm64CanEncodeConstantAsImmediate(HConstant* constant, HInstruction* if (constant->IsLongConstant()) { return false; } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstantOrNull()->GetValue()); + return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstant()->GetValue()); } else if (constant->IsDoubleConstant()) { - // TODO: Remove "OrNull". - return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstantOrNull()->GetValue()); + return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstant()->GetValue()); } return IsUint<8>(value); } @@ -314,9 +312,7 @@ inline bool Arm64CanEncodeConstantAsImmediate(HConstant* constant, HInstruction* } inline Location ARM64EncodableConstantOrRegister(HInstruction* constant, HInstruction* instr) { - if (constant->IsConstant() && - // TODO: Remove "OrNull". - Arm64CanEncodeConstantAsImmediate(constant->AsConstantOrNull(), instr)) { + if (constant->IsConstant() && Arm64CanEncodeConstantAsImmediate(constant->AsConstant(), instr)) { return Location::ConstantLocation(constant); } diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc index c27d22c8d6..2163c007e6 100644 --- a/compiler/optimizing/constant_folding.cc +++ b/compiler/optimizing/constant_folding.cc @@ -132,8 +132,7 @@ void HConstantFoldingVisitor::VisitBinaryOperation(HBinaryOperation* inst) { void HConstantFoldingVisitor::VisitDivZeroCheck(HDivZeroCheck* inst) { // We can safely remove the check if the input is a non-null constant. HInstruction* check_input = inst->InputAt(0); - // TODO: Remove "OrNull". - if (check_input->IsConstant() && !check_input->AsConstantOrNull()->IsArithmeticZero()) { + if (check_input->IsConstant() && !check_input->AsConstant()->IsArithmeticZero()) { inst->ReplaceWith(check_input); inst->GetBlock()->RemoveInstruction(inst); } @@ -195,8 +194,7 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) { if (!if_input->IsCondition()) { return; } - // TODO: Remove "OrNull". - HCondition* condition = if_input->AsConditionOrNull(); + HCondition* condition = if_input->AsCondition(); // We want either `==` or `!=`, since we cannot make assumptions for other conditions e.g. `>` if (!condition->IsEqual() && !condition->IsNotEqual()) { @@ -219,8 +217,7 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) { // } // Similarly with variable != constant, except that we can make guarantees in the else case. - // TODO: Remove "OrNull". - HConstant* constant = left->IsConstant() ? left->AsConstantOrNull() : right->AsConstantOrNull(); + HConstant* constant = left->IsConstant() ? left->AsConstant() : right->AsConstant(); HInstruction* variable = left->IsConstant() ? right : left; // Don't deal with floats/doubles since they bring a lot of edge cases e.g. @@ -241,18 +238,15 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) { } // Update left and right to be the ones from the HCompare. - // TODO: Remove "OrNull". - left = variable->AsCompareOrNull()->GetLeft(); - // TODO: Remove "OrNull". - right = variable->AsCompareOrNull()->GetRight(); + left = variable->AsCompare()->GetLeft(); + right = variable->AsCompare()->GetRight(); // Re-check that one of them to be a constant and not the other. if (left->IsConstant() == right->IsConstant()) { return; } - // TODO: Remove "OrNull". - constant = left->IsConstant() ? left->AsConstantOrNull() : right->AsConstantOrNull(); + constant = left->IsConstant() ? left->AsConstant() : right->AsConstant(); variable = left->IsConstant() ? right : left; // Re-check floating point values. @@ -274,14 +268,12 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) { // we cannot make an assumption for the `else` branch. if (variable->GetType() == DataType::Type::kBool && constant->IsIntConstant() && - // TODO: Remove "OrNull". - (constant->AsIntConstantOrNull()->IsTrue() || constant->AsIntConstantOrNull()->IsFalse())) { + (constant->AsIntConstant()->IsTrue() || constant->AsIntConstant()->IsFalse())) { HBasicBlock* other_starting_block = condition->IsEqual() ? inst->IfFalseSuccessor() : inst->IfTrueSuccessor(); DCHECK_NE(other_starting_block, starting_block); - // TODO: Remove "OrNull". - HConstant* other_constant = constant->AsIntConstantOrNull()->IsTrue() ? + HConstant* other_constant = constant->AsIntConstant()->IsTrue() ? GetGraph()->GetIntConstant(0) : GetGraph()->GetIntConstant(1); DCHECK_NE(other_constant, constant); @@ -293,8 +285,7 @@ void HConstantFoldingVisitor::VisitArrayLength(HArrayLength* inst) { HInstruction* input = inst->InputAt(0); if (input->IsLoadString()) { DCHECK(inst->IsStringLength()); - // TODO: Remove "OrNull". - HLoadString* load_string = input->AsLoadStringOrNull(); + HLoadString* load_string = input->AsLoadString(); const DexFile& dex_file = load_string->GetDexFile(); const dex::StringId& string_id = dex_file.GetStringId(load_string->GetStringIndex()); inst->ReplaceWith(GetGraph()->GetIntConstant(dex_file.GetStringLength(string_id))); @@ -314,8 +305,7 @@ void HConstantFoldingVisitor::VisitTypeConversion(HTypeConversion* inst) { void InstructionWithAbsorbingInputSimplifier::VisitShift(HBinaryOperation* instruction) { DCHECK(instruction->IsShl() || instruction->IsShr() || instruction->IsUShr()); HInstruction* left = instruction->GetLeft(); - // TODO: Remove "OrNull". - if (left->IsConstant() && left->AsConstantOrNull()->IsArithmeticZero()) { + if (left->IsConstant() && left->AsConstant()->IsArithmeticZero()) { // Replace code looking like // SHL dst, 0, shift_amount // with @@ -375,8 +365,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitAbove(HAbove* instruction) { instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 0)); instruction->GetBlock()->RemoveInstruction(instruction); } else if (instruction->GetLeft()->IsConstant() && - // TODO: Remove "OrNull". - instruction->GetLeft()->AsConstantOrNull()->IsArithmeticZero()) { + instruction->GetLeft()->AsConstant()->IsArithmeticZero()) { // Replace code looking like // ABOVE dst, 0, src // unsigned 0 > src is always false // with @@ -394,8 +383,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitAboveOrEqual(HAboveOrEqual* i instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 1)); instruction->GetBlock()->RemoveInstruction(instruction); } else if (instruction->GetRight()->IsConstant() && - // TODO: Remove "OrNull". - instruction->GetRight()->AsConstantOrNull()->IsArithmeticZero()) { + instruction->GetRight()->AsConstant()->IsArithmeticZero()) { // Replace code looking like // ABOVE_OR_EQUAL dst, src, 0 // unsigned src >= 0 is always true // with @@ -413,8 +401,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitBelow(HBelow* instruction) { instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 0)); instruction->GetBlock()->RemoveInstruction(instruction); } else if (instruction->GetRight()->IsConstant() && - // TODO: Remove "OrNull". - instruction->GetRight()->AsConstantOrNull()->IsArithmeticZero()) { + instruction->GetRight()->AsConstant()->IsArithmeticZero()) { // Replace code looking like // BELOW dst, src, 0 // unsigned src < 0 is always false // with @@ -432,8 +419,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitBelowOrEqual(HBelowOrEqual* i instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 1)); instruction->GetBlock()->RemoveInstruction(instruction); } else if (instruction->GetLeft()->IsConstant() && - // TODO: Remove "OrNull". - instruction->GetLeft()->AsConstantOrNull()->IsArithmeticZero()) { + instruction->GetLeft()->AsConstant()->IsArithmeticZero()) { // Replace code looking like // BELOW_OR_EQUAL dst, 0, src // unsigned 0 <= src is always true // with @@ -515,8 +501,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitAnd(HAnd* instruction) { // CONSTANT 0 HInstruction* hnot = (left->IsNot() ? left : right); HInstruction* hother = (left->IsNot() ? right : left); - // TODO: Remove "OrNull". - HInstruction* src = hnot->AsNotOrNull()->GetInput(); + HInstruction* src = hnot->AsNot()->GetInput(); if (src == hother) { instruction->ReplaceWith(GetGraph()->GetConstant(type, 0)); @@ -529,10 +514,9 @@ void InstructionWithAbsorbingInputSimplifier::VisitCompare(HCompare* instruction HConstant* input_cst = instruction->GetConstantRight(); if (input_cst != nullptr) { HInstruction* input_value = instruction->GetLeastConstantLeft(); - // TODO: Remove "OrNull". if (DataType::IsFloatingPointType(input_value->GetType()) && - ((input_cst->IsFloatConstant() && input_cst->AsFloatConstantOrNull()->IsNaN()) || - (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstantOrNull()->IsNaN()))) { + ((input_cst->IsFloatConstant() && input_cst->AsFloatConstant()->IsNaN()) || + (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstant()->IsNaN()))) { // Replace code looking like // CMP{G,L}-{FLOAT,DOUBLE} dst, src, NaN // with @@ -590,8 +574,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitRem(HRem* instruction) { HBasicBlock* block = instruction->GetBlock(); if (instruction->GetLeft()->IsConstant() && - // TODO: Remove "OrNull". - instruction->GetLeft()->AsConstantOrNull()->IsArithmeticZero()) { + instruction->GetLeft()->AsConstant()->IsArithmeticZero()) { // Replace code looking like // REM dst, 0, src // with diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc index 4573dce4aa..741fd3f822 100644 --- a/compiler/optimizing/constant_folding_test.cc +++ b/compiler/optimizing/constant_folding_test.cc @@ -128,8 +128,7 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingNegation) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), -1); + ASSERT_EQ(inst->AsIntConstant()->GetValue(), -1); }; // Expected difference after dead code elimination. @@ -190,8 +189,7 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingNegation) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsLongConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), INT64_C(-4294967296)); + ASSERT_EQ(inst->AsLongConstant()->GetValue(), INT64_C(-4294967296)); }; // Expected difference after dead code elimination. @@ -252,8 +250,7 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition1) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 3); + ASSERT_EQ(inst->AsIntConstant()->GetValue(), 3); }; // Expected difference after dead code elimination. @@ -332,16 +329,13 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition2) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst1 = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst1->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst1->AsIntConstantOrNull()->GetValue(), 12); + ASSERT_EQ(inst1->AsIntConstant()->GetValue(), 12); HInstruction* inst2 = inst1->GetPrevious(); ASSERT_TRUE(inst2->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst2->AsIntConstantOrNull()->GetValue(), 9); + ASSERT_EQ(inst2->AsIntConstant()->GetValue(), 9); HInstruction* inst3 = inst2->GetPrevious(); ASSERT_TRUE(inst3->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst3->AsIntConstantOrNull()->GetValue(), 3); + ASSERT_EQ(inst3->AsIntConstant()->GetValue(), 3); }; // Expected difference after dead code elimination. @@ -406,8 +400,7 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnSubtraction) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 1); + ASSERT_EQ(inst->AsIntConstant()->GetValue(), 1); }; // Expected difference after dead code elimination. @@ -470,8 +463,7 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingOnAddition) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsLongConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), 3); + ASSERT_EQ(inst->AsLongConstant()->GetValue(), 3); }; // Expected difference after dead code elimination. @@ -535,8 +527,7 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingOnSubtraction) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsLongConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), 1); + ASSERT_EQ(inst->AsLongConstant()->GetValue(), 1); }; // Expected difference after dead code elimination. @@ -636,20 +627,16 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingAndJumps) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst1 = graph->GetBlocks()[4]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst1->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst1->AsIntConstantOrNull()->GetValue(), 20); + ASSERT_EQ(inst1->AsIntConstant()->GetValue(), 20); HInstruction* inst2 = inst1->GetPrevious(); ASSERT_TRUE(inst2->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst2->AsIntConstantOrNull()->GetValue(), 12); + ASSERT_EQ(inst2->AsIntConstant()->GetValue(), 12); HInstruction* inst3 = inst2->GetPrevious(); ASSERT_TRUE(inst3->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst3->AsIntConstantOrNull()->GetValue(), 7); + ASSERT_EQ(inst3->AsIntConstant()->GetValue(), 7); HInstruction* inst4 = inst3->GetPrevious(); ASSERT_TRUE(inst4->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst4->AsIntConstantOrNull()->GetValue(), 3); + ASSERT_EQ(inst4->AsIntConstant()->GetValue(), 3); }; // Expected difference after dead code elimination. @@ -725,8 +712,7 @@ TEST_F(ConstantFoldingTest, ConstantCondition) { auto check_after_cf = [](HGraph* graph) { HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0); ASSERT_TRUE(inst->IsIntConstant()); - // TODO: Remove "OrNull". - ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 1); + ASSERT_EQ(inst->AsIntConstant()->GetValue(), 1); }; // Expected graph after dead code elimination. diff --git a/compiler/optimizing/critical_native_abi_fixup_arm.cc b/compiler/optimizing/critical_native_abi_fixup_arm.cc index 13c887ed1c..77e156608b 100644 --- a/compiler/optimizing/critical_native_abi_fixup_arm.cc +++ b/compiler/optimizing/critical_native_abi_fixup_arm.cc @@ -97,11 +97,9 @@ bool CriticalNativeAbiFixupArm::Run() { for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { HInstruction* instruction = it.Current(); if (instruction->IsInvokeStaticOrDirect() && - // TODO: Remove "OrNull". - instruction->AsInvokeStaticOrDirectOrNull()->GetCodePtrLocation() == + instruction->AsInvokeStaticOrDirect()->GetCodePtrLocation() == CodePtrLocation::kCallCriticalNative) { - // TODO: Remove "OrNull". - FixUpArguments(instruction->AsInvokeStaticOrDirectOrNull()); + FixUpArguments(instruction->AsInvokeStaticOrDirect()); } } } diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index 5840651467..cf49e39849 100644 --- a/compiler/optimizing/dead_code_elimination.cc +++ b/compiler/optimizing/dead_code_elimination.cc @@ -47,29 +47,23 @@ static void MarkReachableBlocks(HGraph* graph, ArenaBitVector* visited) { ArrayRef live_successors(block->GetSuccessors()); HInstruction* last_instruction = block->GetLastInstruction(); if (last_instruction->IsIf()) { - // TODO: Remove "OrNull". - HIf* if_instruction = last_instruction->AsIfOrNull(); + HIf* if_instruction = last_instruction->AsIf(); HInstruction* condition = if_instruction->InputAt(0); if (condition->IsIntConstant()) { - // TODO: Remove "OrNull". - if (condition->AsIntConstantOrNull()->IsTrue()) { + if (condition->AsIntConstant()->IsTrue()) { live_successors = live_successors.SubArray(0u, 1u); DCHECK_EQ(live_successors[0], if_instruction->IfTrueSuccessor()); } else { - // TODO: Remove "OrNull". - DCHECK(condition->AsIntConstantOrNull()->IsFalse()) - << condition->AsIntConstantOrNull()->GetValue(); + DCHECK(condition->AsIntConstant()->IsFalse()) << condition->AsIntConstant()->GetValue(); live_successors = live_successors.SubArray(1u, 1u); DCHECK_EQ(live_successors[0], if_instruction->IfFalseSuccessor()); } } } else if (last_instruction->IsPackedSwitch()) { - // TODO: Remove "OrNull". - HPackedSwitch* switch_instruction = last_instruction->AsPackedSwitchOrNull(); + HPackedSwitch* switch_instruction = last_instruction->AsPackedSwitch(); HInstruction* switch_input = switch_instruction->InputAt(0); if (switch_input->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t switch_value = switch_input->AsIntConstantOrNull()->GetValue(); + int32_t switch_value = switch_input->AsIntConstant()->GetValue(); int32_t start_value = switch_instruction->GetStartValue(); // Note: Though the spec forbids packed-switch values to wrap around, we leave // that task to the verifier and use unsigned arithmetic with it's "modulo 2^32" @@ -142,21 +136,16 @@ static HConstant* Evaluate(HCondition* condition, HInstruction* left, HInstructi } if (left->IsIntConstant()) { - // TODO: Remove "OrNull". - return condition->Evaluate(left->AsIntConstantOrNull(), right->AsIntConstantOrNull()); + return condition->Evaluate(left->AsIntConstant(), right->AsIntConstant()); } else if (left->IsNullConstant()) { - // TODO: Remove "OrNull". - return condition->Evaluate(left->AsNullConstantOrNull(), right->AsNullConstantOrNull()); + return condition->Evaluate(left->AsNullConstant(), right->AsNullConstant()); } else if (left->IsLongConstant()) { - // TODO: Remove "OrNull". - return condition->Evaluate(left->AsLongConstantOrNull(), right->AsLongConstantOrNull()); + return condition->Evaluate(left->AsLongConstant(), right->AsLongConstant()); } else if (left->IsFloatConstant()) { - // TODO: Remove "OrNull". - return condition->Evaluate(left->AsFloatConstantOrNull(), right->AsFloatConstantOrNull()); + return condition->Evaluate(left->AsFloatConstant(), right->AsFloatConstant()); } else { DCHECK(left->IsDoubleConstant()); - // TODO: Remove "OrNull". - return condition->Evaluate(left->AsDoubleConstantOrNull(), right->AsDoubleConstantOrNull()); + return condition->Evaluate(left->AsDoubleConstant(), right->AsDoubleConstant()); } } @@ -165,8 +154,7 @@ static bool RemoveNonNullControlDependences(HBasicBlock* block, HBasicBlock* thr if (!block->EndsWithIf()) { return false; } - // TODO: Remove "OrNull". - HIf* ifs = block->GetLastInstruction()->AsIfOrNull(); + HIf* ifs = block->GetLastInstruction()->AsIf(); // Find either: // if obj == null // throws @@ -279,8 +267,7 @@ bool HDeadCodeElimination::SimplifyAlwaysThrows() { // throw, the first one will throw and the second one will never be reached. HInstruction* throwing_invoke = nullptr; for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - if (it.Current()->IsInvoke() && it.Current()->AsInvokeOrNull()->AlwaysThrows()) { + if (it.Current()->IsInvoke() && it.Current()->AsInvoke()->AlwaysThrows()) { throwing_invoke = it.Current(); break; } @@ -375,15 +362,13 @@ bool HDeadCodeElimination::SimplifyIfs() { bool has_only_phi_condition_and_if = !has_only_phi_and_if && first->IsCondition() && - // TODO: Remove "OrNull". - HasInput(first->AsConditionOrNull(), block->GetFirstPhi()) && + HasInput(first->AsCondition(), block->GetFirstPhi()) && (first->GetNext() == last) && (last->InputAt(0) == first) && first->HasOnlyOneNonEnvironmentUse(); if (has_only_phi_and_if || has_only_phi_condition_and_if) { - // TODO: Remove "OrNull". - HPhi* phi = block->GetFirstPhi()->AsPhiOrNull(); + HPhi* phi = block->GetFirstPhi()->AsPhi(); bool phi_input_is_left = (first->InputAt(0) == phi); // Walk over all inputs of the phis and update the control flow of @@ -399,11 +384,9 @@ bool HDeadCodeElimination::SimplifyIfs() { } else { DCHECK(has_only_phi_condition_and_if); if (phi_input_is_left) { - // TODO: Remove "OrNull". - value_to_check = Evaluate(first->AsConditionOrNull(), input, first->InputAt(1)); + value_to_check = Evaluate(first->AsCondition(), input, first->InputAt(1)); } else { - // TODO: Remove "OrNull". - value_to_check = Evaluate(first->AsConditionOrNull(), first->InputAt(0), input); + value_to_check = Evaluate(first->AsCondition(), first->InputAt(0), input); } } if (value_to_check == nullptr) { @@ -412,16 +395,12 @@ bool HDeadCodeElimination::SimplifyIfs() { } else { HBasicBlock* predecessor_to_update = block->GetPredecessors()[i]; HBasicBlock* successor_to_update = nullptr; - // TODO: Remove "OrNull". - if (value_to_check->AsIntConstantOrNull()->IsTrue()) { - // TODO: Remove "OrNull". - successor_to_update = last->AsIfOrNull()->IfTrueSuccessor(); + if (value_to_check->AsIntConstant()->IsTrue()) { + successor_to_update = last->AsIf()->IfTrueSuccessor(); } else { - // TODO: Remove "OrNull". - DCHECK(value_to_check->AsIntConstantOrNull()->IsFalse()) - << value_to_check->AsIntConstantOrNull()->GetValue(); - // TODO: Remove "OrNull". - successor_to_update = last->AsIfOrNull()->IfFalseSuccessor(); + DCHECK(value_to_check->AsIntConstant()->IsFalse()) + << value_to_check->AsIntConstant()->GetValue(); + successor_to_update = last->AsIf()->IfFalseSuccessor(); } predecessor_to_update->ReplaceSuccessor(block, successor_to_update); phi->RemoveInputAt(i); @@ -442,8 +421,7 @@ bool HDeadCodeElimination::SimplifyIfs() { if (has_only_phi_condition_and_if) { // Evaluate here (and not wait for a constant folding pass) to open // more opportunities for DCE. - // TODO: Remove "OrNull". - HInstruction* result = first->AsConditionOrNull()->TryStaticEvaluation(); + HInstruction* result = first->AsCondition()->TryStaticEvaluation(); if (result != nullptr) { first->ReplaceWith(result); block->RemoveInstruction(first); @@ -476,8 +454,7 @@ bool HDeadCodeElimination::SimplifyIfs() { void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) { DCHECK(block->GetLastInstruction()->IsIf()); - // TODO: Remove "OrNull". - HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instruction = block->GetLastInstruction()->AsIf(); if (if_instruction->InputAt(0)->IsConstant()) { // Constant values are handled in RemoveDeadBlocks. return; @@ -500,8 +477,7 @@ void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) { } HInstruction* input = if_instruction->InputAt(0); - // TODO: Remove "OrNull". - HInstruction* dominator_input = dominator->GetLastInstruction()->AsIfOrNull()->InputAt(0); + HInstruction* dominator_input = dominator->GetLastInstruction()->AsIf()->InputAt(0); const bool same_input = dominator_input == input; if (!same_input) { // Try to see if the dominator has the opposite input (e.g. if(cond) and if(!cond)). If that's @@ -510,10 +486,8 @@ void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) { return; } - // TODO: Remove "OrNull". - HCondition* block_cond = input->AsConditionOrNull(); - // TODO: Remove "OrNull". - HCondition* dominator_cond = dominator_input->AsConditionOrNull(); + HCondition* block_cond = input->AsCondition(); + HCondition* dominator_cond = dominator_input->AsCondition(); if (block_cond->GetLeft() != dominator_cond->GetLeft() || block_cond->GetRight() != dominator_cond->GetRight() || @@ -536,12 +510,10 @@ void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) { for (size_t index = 0; index < pred_size; index++) { HBasicBlock* pred = block->GetPredecessors()[index]; - // TODO: Remove "OrNull". const bool dominated_by_true = - dominator->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor()->Dominates(pred); - // TODO: Remove "OrNull". + dominator->GetLastInstruction()->AsIf()->IfTrueSuccessor()->Dominates(pred); const bool dominated_by_false = - dominator->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor()->Dominates(pred); + dominator->GetLastInstruction()->AsIf()->IfFalseSuccessor()->Dominates(pred); if (dominated_by_true == dominated_by_false) { // In this case, we can't know if we are coming from the true branch, or the false branch. It // happens in cases like: @@ -672,14 +644,12 @@ void HDeadCodeElimination::RemoveTry(HBasicBlock* try_entry, /* out */ bool* any_block_in_loop) { // Update all try entries. DCHECK(try_entry->EndsWithTryBoundary()); - // TODO: Remove "OrNull". - DCHECK(try_entry->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry()); + DCHECK(try_entry->GetLastInstruction()->AsTryBoundary()->IsEntry()); DisconnectHandlersAndUpdateTryBoundary(try_entry, any_block_in_loop); for (HBasicBlock* other_try_entry : try_belonging_info.coalesced_try_entries) { DCHECK(other_try_entry->EndsWithTryBoundary()); - // TODO: Remove "OrNull". - DCHECK(other_try_entry->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry()); + DCHECK(other_try_entry->GetLastInstruction()->AsTryBoundary()->IsEntry()); DisconnectHandlersAndUpdateTryBoundary(other_try_entry, any_block_in_loop); } @@ -693,8 +663,7 @@ void HDeadCodeElimination::RemoveTry(HBasicBlock* try_entry, if (block->EndsWithTryBoundary()) { // Try exits. - // TODO: Remove "OrNull". - DCHECK(!block->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry()); + DCHECK(!block->GetLastInstruction()->AsTryBoundary()->IsEntry()); DisconnectHandlersAndUpdateTryBoundary(block, any_block_in_loop); if (block->GetSingleSuccessor()->IsExitBlock()) { @@ -743,13 +712,10 @@ bool HDeadCodeElimination::RemoveUnneededTries() { // Deduplicate the tries which have different try entries but they are really the same try. for (auto it = tries.begin(); it != tries.end(); it++) { DCHECK(it->first->EndsWithTryBoundary()); - // TODO: Remove "OrNull". - HTryBoundary* try_boundary = it->first->GetLastInstruction()->AsTryBoundaryOrNull(); + HTryBoundary* try_boundary = it->first->GetLastInstruction()->AsTryBoundary(); for (auto other_it = next(it); other_it != tries.end(); /*other_it++ in the loop*/) { DCHECK(other_it->first->EndsWithTryBoundary()); - // TODO: Remove "OrNull". - HTryBoundary* other_try_boundary = - other_it->first->GetLastInstruction()->AsTryBoundaryOrNull(); + HTryBoundary* other_try_boundary = other_it->first->GetLastInstruction()->AsTryBoundary(); if (try_boundary->HasSameExceptionHandlersAs(*other_try_boundary)) { // Merge the entries as they are really the same one. // Block merging. @@ -889,8 +855,7 @@ void HDeadCodeElimination::UpdateGraphFlags() { has_simd = true; } else if (instruction->IsBoundsCheck()) { has_bounds_checks = true; - // TODO: Remove "OrNull". - } else if (instruction->IsInvoke() && instruction->AsInvokeOrNull()->AlwaysThrows()) { + } else if (instruction->IsInvoke() && instruction->AsInvoke()->AlwaysThrows()) { has_always_throwing_invokes = true; } } diff --git a/compiler/optimizing/escape.cc b/compiler/optimizing/escape.cc index 6fffe22277..cebe94fd0d 100644 --- a/compiler/optimizing/escape.cc +++ b/compiler/optimizing/escape.cc @@ -24,8 +24,7 @@ void VisitEscapes(HInstruction* reference, EscapeVisitor& escape_visitor) { // References not allocated in the method are intrinsically escaped. // Finalizable references are always escaping since they end up in FinalizerQueues. if ((!reference->IsNewInstance() && !reference->IsNewArray()) || - // TODO: Remove "OrNull". - (reference->IsNewInstance() && reference->AsNewInstanceOrNull()->IsFinalizable())) { + (reference->IsNewInstance() && reference->AsNewInstance()->IsFinalizable())) { if (!escape_visitor(reference)) { return; } @@ -106,8 +105,7 @@ void CalculateEscape(HInstruction* reference, *is_singleton_and_not_returned = true; *is_singleton_and_not_deopt_visible = true; - // TODO: Remove "OrNull". - if (reference->IsNewInstance() && reference->AsNewInstanceOrNull()->IsFinalizable()) { + if (reference->IsNewInstance() && reference->AsNewInstance()->IsFinalizable()) { // Finalizable reference is treated as being returned in the end. *is_singleton_and_not_returned = false; } diff --git a/compiler/optimizing/graph_checker.cc b/compiler/optimizing/graph_checker.cc index e694273e0b..596049f369 100644 --- a/compiler/optimizing/graph_checker.cc +++ b/compiler/optimizing/graph_checker.cc @@ -53,8 +53,7 @@ static bool IsExitTryBoundaryIntoExitBlock(HBasicBlock* block) { return false; } - // TODO: Remove "OrNull". - HTryBoundary* boundary = block->GetLastInstruction()->AsTryBoundaryOrNull(); + HTryBoundary* boundary = block->GetLastInstruction()->AsTryBoundary(); return block->GetPredecessors().size() == 1u && boundary->GetNormalFlowSuccessor()->IsExitBlock() && !boundary->IsEntry(); @@ -248,8 +247,7 @@ void GraphChecker::VisitBasicBlock(HBasicBlock* block) { AddError(StringPrintf("Block %d doesn't have a Nop as its first instruction.", current_block_->GetBlockId())); } else { - // TODO: Remove "OrNull". - HNop* nop = block->GetFirstInstruction()->AsNopOrNull(); + HNop* nop = block->GetFirstInstruction()->AsNop(); if (!nop->NeedsEnvironment()) { AddError( StringPrintf("%s:%d is a Nop and the first instruction of block %d, but it doesn't " @@ -660,8 +658,7 @@ void GraphChecker::VisitInstruction(HInstruction* instruction) { for (HBasicBlock* catch_block : entry.GetExceptionHandlers()) { const HEnvironment* environment = catch_block->GetFirstInstruction()->GetEnvironment(); for (HInstructionIterator phi_it(catch_block->GetPhis()); !phi_it.Done(); phi_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* catch_phi = phi_it.Current()->AsPhiOrNull(); + HPhi* catch_phi = phi_it.Current()->AsPhi(); if (environment->GetInstructionAt(catch_phi->GetRegNumber()) == nullptr) { AddError(StringPrintf("Instruction %s:%d throws into catch block %d " "with catch phi %d for vreg %d but its " @@ -750,9 +747,8 @@ void GraphChecker::CheckTypeCheckBitstringInput(HTypeCheckInstruction* check, check->InputAt(2)->DebugName(), check->InputAt(2)->GetId())); } else if (check_value) { - // TODO: Remove "OrNull". uint32_t actual_value = - static_cast(check->InputAt(input_pos)->AsIntConstantOrNull()->GetValue()); + static_cast(check->InputAt(input_pos)->AsIntConstant()->GetValue()); if (actual_value != expected_value) { AddError(StringPrintf("%s:%d (bitstring) has %s 0x%x, not 0x%x as expected.", check->DebugName(), @@ -948,8 +944,7 @@ static bool IsSameSizeConstant(const HInstruction* insn1, const HInstruction* in static bool IsConstantEquivalent(const HInstruction* insn1, const HInstruction* insn2, BitVector* visited) { - // TODO: Remove "OrNull". - if (insn1->IsPhi() && insn1->AsPhiOrNull()->IsVRegEquivalentOf(insn2)) { + if (insn1->IsPhi() && insn1->AsPhi()->IsVRegEquivalentOf(insn2)) { HConstInputsRef insn1_inputs = insn1->GetInputs(); HConstInputsRef insn2_inputs = insn2->GetInputs(); if (insn1_inputs.size() != insn2_inputs.size()) { @@ -969,9 +964,7 @@ static bool IsConstantEquivalent(const HInstruction* insn1, } return true; } else if (IsSameSizeConstant(insn1, insn2)) { - // TODO: Remove "OrNull". - return insn1->AsConstantOrNull()->GetValueAsUint64() == - insn2->AsConstantOrNull()->GetValueAsUint64(); + return insn1->AsConstant()->GetValueAsUint64() == insn2->AsConstant()->GetValueAsUint64(); } else { return false; } @@ -1065,8 +1058,7 @@ void GraphChecker::VisitPhi(HPhi* phi) { // phis which can be constructed artifically. if (phi->IsCatchPhi()) { HInstruction* next_phi = phi->GetNext(); - // TODO: Remove "OrNull". - if (next_phi != nullptr && phi->GetRegNumber() > next_phi->AsPhiOrNull()->GetRegNumber()) { + if (next_phi != nullptr && phi->GetRegNumber() > next_phi->AsPhi()->GetRegNumber()) { AddError(StringPrintf("Catch phis %d and %d in block %d are not sorted by their " "vreg numbers.", phi->GetId(), @@ -1082,8 +1074,7 @@ void GraphChecker::VisitPhi(HPhi* phi) { for (HInstructionIterator phi_it(phi->GetBlock()->GetPhis()); !phi_it.Done(); phi_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* other_phi = phi_it.Current()->AsPhiOrNull(); + HPhi* other_phi = phi_it.Current()->AsPhi(); if (phi != other_phi && phi->GetRegNumber() == other_phi->GetRegNumber()) { if (phi->GetType() == other_phi->GetType()) { std::stringstream type_str; @@ -1126,8 +1117,7 @@ void GraphChecker::VisitPhi(HPhi* phi) { void GraphChecker::HandleBooleanInput(HInstruction* instruction, size_t input_index) { HInstruction* input = instruction->InputAt(input_index); if (input->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t value = input->AsIntConstantOrNull()->GetValue(); + int32_t value = input->AsIntConstant()->GetValue(); if (value != 0 && value != 1) { AddError(StringPrintf( "%s instruction %d has a non-Boolean constant input %d whose value is: %d.", diff --git a/compiler/optimizing/graph_test.cc b/compiler/optimizing/graph_test.cc index f391bcbcbe..b5d712736f 100644 --- a/compiler/optimizing/graph_test.cc +++ b/compiler/optimizing/graph_test.cc @@ -92,20 +92,16 @@ TEST_F(GraphTest, IfSuccessorSimpleJoinBlock1) { if_block->AddSuccessor(return_block); return_block->AddSuccessor(exit_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), if_true); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), if_true); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_block); graph->SimplifyCFG(); // Ensure we still have the same if true block. - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), if_true); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), if_true); // Ensure the critical edge has been removed. - // TODO: Remove "OrNull". - HBasicBlock* false_block = if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(); + HBasicBlock* false_block = if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(); ASSERT_NE(false_block, return_block); // Ensure the new block branches to the join block. @@ -128,20 +124,16 @@ TEST_F(GraphTest, IfSuccessorSimpleJoinBlock2) { if_block->AddSuccessor(if_false); return_block->AddSuccessor(exit_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), return_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), if_false); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), if_false); graph->SimplifyCFG(); // Ensure we still have the same if true block. - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), if_false); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), if_false); // Ensure the critical edge has been removed. - // TODO: Remove "OrNull". - HBasicBlock* true_block = if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(); + HBasicBlock* true_block = if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(); ASSERT_NE(true_block, return_block); // Ensure the new block branches to the join block. @@ -162,16 +154,13 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges1) { if_block->AddSuccessor(return_block); return_block->AddSuccessor(exit_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), if_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), if_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_block); graph->BuildDominatorTree(); // Ensure we still have the same if false block. - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_block); // Ensure there is only one back edge. ASSERT_EQ(if_block->GetPredecessors().size(), 2u); @@ -180,8 +169,7 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges1) { // Ensure the new block is the back edge. ASSERT_EQ(if_block->GetPredecessors()[1], - // TODO: Remove "OrNull". - if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor()); + if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor()); } // Test that the successors of an if block stay consistent after a SimplifyCFG. @@ -198,16 +186,13 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges2) { if_block->AddSuccessor(if_block); return_block->AddSuccessor(exit_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), return_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), if_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), if_block); graph->BuildDominatorTree(); // Ensure we still have the same if true block. - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block); // Ensure there is only one back edge. ASSERT_EQ(if_block->GetPredecessors().size(), 2u); @@ -216,8 +201,7 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges2) { // Ensure the new block is the back edge. ASSERT_EQ(if_block->GetPredecessors()[1], - // TODO: Remove "OrNull". - if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor()); + if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor()); } // Test that the successors of an if block stay consistent after a SimplifyCFG. @@ -238,15 +222,12 @@ TEST_F(GraphTest, IfSuccessorMultiplePreHeaders1) { if_block->AddSuccessor(return_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), loop_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), loop_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_block); graph->BuildDominatorTree(); - // TODO: Remove "OrNull". - HIf* if_instr = if_block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instr = if_block->GetLastInstruction()->AsIf(); // Ensure we still have the same if false block. ASSERT_EQ(if_instr->IfFalseSuccessor(), return_block); @@ -276,15 +257,12 @@ TEST_F(GraphTest, IfSuccessorMultiplePreHeaders2) { if_block->AddSuccessor(return_block); if_block->AddSuccessor(loop_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), return_block); - // TODO: Remove "OrNull". - ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), loop_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block); + ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), loop_block); graph->BuildDominatorTree(); - // TODO: Remove "OrNull". - HIf* if_instr = if_block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instr = if_block->GetLastInstruction()->AsIf(); // Ensure we still have the same if true block. ASSERT_EQ(if_instr->IfTrueSuccessor(), return_block); diff --git a/compiler/optimizing/graph_visualizer.cc b/compiler/optimizing/graph_visualizer.cc index a264968b10..73bdd1e223 100644 --- a/compiler/optimizing/graph_visualizer.cc +++ b/compiler/optimizing/graph_visualizer.cc @@ -323,17 +323,13 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { stream << "#"; HConstant* constant = location.GetConstant(); if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - stream << constant->AsIntConstantOrNull()->GetValue(); + stream << constant->AsIntConstant()->GetValue(); } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - stream << constant->AsLongConstantOrNull()->GetValue(); + stream << constant->AsLongConstant()->GetValue(); } else if (constant->IsFloatConstant()) { - // TODO: Remove "OrNull". - stream << constant->AsFloatConstantOrNull()->GetValue(); + stream << constant->AsFloatConstant()->GetValue(); } else if (constant->IsDoubleConstant()) { - // TODO: Remove "OrNull". - stream << constant->AsDoubleConstantOrNull()->GetValue(); + stream << constant->AsDoubleConstant()->GetValue(); } else if (constant->IsNullConstant()) { stream << "null"; } @@ -629,8 +625,7 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { void VisitVecDotProd(HVecDotProd* instruction) override { VisitVecOperation(instruction); - // TODO: Remove "OrNull". - DataType::Type arg_type = instruction->InputAt(1)->AsVecOperationOrNull()->GetPackedType(); + DataType::Type arg_type = instruction->InputAt(1)->AsVecOperation()->GetPackedType(); StartAttributeStream("type") << (instruction->IsZeroExtending() ? DataType::ToUnsigned(arg_type) : DataType::ToSigned(arg_type)); @@ -752,14 +747,13 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor { && (instruction->GetType() == DataType::Type::kReference || instruction->IsInstanceOf() || instruction->IsCheckCast())) { - // TODO: Remove "OrNull". ReferenceTypeInfo info = (instruction->GetType() == DataType::Type::kReference) ? instruction->IsLoadClass() - ? instruction->AsLoadClassOrNull()->GetLoadedClassRTI() + ? instruction->AsLoadClass()->GetLoadedClassRTI() : instruction->GetReferenceTypeInfo() : instruction->IsInstanceOf() - ? instruction->AsInstanceOfOrNull()->GetTargetClassRTI() - : instruction->AsCheckCastOrNull()->GetTargetClassRTI(); + ? instruction->AsInstanceOf()->GetTargetClassRTI() + : instruction->AsCheckCast()->GetTargetClassRTI(); ScopedObjectAccess soa(Thread::Current()); if (info.IsValid()) { StartAttributeStream("klass") diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc index cccb381bc6..a6ca057cfc 100644 --- a/compiler/optimizing/gvn.cc +++ b/compiler/optimizing/gvn.cc @@ -498,12 +498,10 @@ void GlobalValueNumberer::VisitBasicBlock(HBasicBlock* block) { // Deoptimize is a special case since even though we don't want to move it we can still remove // it for GVN. if (current->CanBeMoved() || current->IsBoundType() || current->IsDeoptimize()) { - // TODO: Remove "OrNull". - if (current->IsBinaryOperation() && current->AsBinaryOperationOrNull()->IsCommutative()) { + if (current->IsBinaryOperation() && current->AsBinaryOperation()->IsCommutative()) { // For commutative ops, (x op y) will be treated the same as (y op x) // after fixed ordering. - // TODO: Remove "OrNull". - current->AsBinaryOperationOrNull()->OrderInputs(); + current->AsBinaryOperation()->OrderInputs(); } HInstruction* existing = set->Lookup(current); if (existing != nullptr) { diff --git a/compiler/optimizing/induction_var_analysis.cc b/compiler/optimizing/induction_var_analysis.cc index e54d12b931..be6c268f5d 100644 --- a/compiler/optimizing/induction_var_analysis.cc +++ b/compiler/optimizing/induction_var_analysis.cc @@ -89,14 +89,12 @@ static bool IsGuardedBy(const HLoopInformation* loop, if (!control->IsIf()) { return false; } - // TODO: Remove "OrNull". - HIf* ifs = control->AsIfOrNull(); + HIf* ifs = control->AsIf(); HInstruction* if_expr = ifs->InputAt(0); if (if_expr->IsCondition()) { - // TODO: Remove "OrNull". IfCondition other_cmp = ifs->IfTrueSuccessor() == entry - ? if_expr->AsConditionOrNull()->GetCondition() - : if_expr->AsConditionOrNull()->GetOppositeCondition(); + ? if_expr->AsCondition()->GetCondition() + : if_expr->AsCondition()->GetOppositeCondition(); if (if_expr->InputAt(0) == a && if_expr->InputAt(1) == b) { return cmp == other_cmp; } else if (if_expr->InputAt(1) == a && if_expr->InputAt(0) == b) { @@ -437,10 +435,9 @@ void HInductionVarAnalysis::ClassifyTrivial(const HLoopInformation* loop, } else if (instruction->IsSelect()) { info = TransferPhi(loop, instruction, /*input_index*/ 0, /*adjust_input_size*/ 1); } else if (instruction->IsTypeConversion()) { - // TODO: Remove "OrNull". info = TransferConversion(LookupInfo(loop, instruction->InputAt(0)), - instruction->AsTypeConversionOrNull()->GetInputType(), - instruction->AsTypeConversionOrNull()->GetResultType()); + instruction->AsTypeConversion()->GetInputType(), + instruction->AsTypeConversion()->GetResultType()); } else if (instruction->IsBoundsCheck()) { info = LookupInfo(loop, instruction->InputAt(0)); // Pass-through. } @@ -476,8 +473,7 @@ void HInductionVarAnalysis::ClassifyNonTrivial(const HLoopInformation* loop, // Store interesting cycle in each loop phi. for (size_t i = 0; i < size; i++) { if (scc[i]->IsLoopHeaderPhi()) { - // TODO: Remove "OrNull". - AssignCycle(scc[i]->AsPhiOrNull(), ArrayRef(scc)); + AssignCycle(scc[i]->AsPhi(), ArrayRef(scc)); } } @@ -552,8 +548,7 @@ void HInductionVarAnalysis::ClassifyNonTrivial(const HLoopInformation* loop, // Select acts like Phi. update = SolvePhi(instruction, /*input_index=*/ 0, /*adjust_input_size=*/ 1, cycle); } else if (instruction->IsTypeConversion()) { - // TODO: Remove "OrNull". - update = SolveConversion(loop, phi, instruction->AsTypeConversionOrNull(), cycle, &type); + update = SolveConversion(loop, phi, instruction->AsTypeConversion(), cycle, &type); } if (update == nullptr) { return; @@ -1003,8 +998,7 @@ HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::SolveConversion( void HInductionVarAnalysis::VisitControl(const HLoopInformation* loop) { HInstruction* control = loop->GetHeader()->GetLastInstruction(); if (control->IsIf()) { - // TODO: Remove "OrNull". - HIf* ifs = control->AsIfOrNull(); + HIf* ifs = control->AsIf(); HBasicBlock* if_true = ifs->IfTrueSuccessor(); HBasicBlock* if_false = ifs->IfFalseSuccessor(); HInstruction* if_expr = ifs->InputAt(0); @@ -1012,8 +1006,7 @@ void HInductionVarAnalysis::VisitControl(const HLoopInformation* loop) { // loop-header: .... // if (condition) goto X if (if_expr->IsCondition()) { - // TODO: Remove "OrNull". - HCondition* condition = if_expr->AsConditionOrNull(); + HCondition* condition = if_expr->AsCondition(); const HBasicBlock* context = condition->GetBlock(); InductionInfo* a = LookupInfo(loop, condition->InputAt(0)); InductionInfo* b = LookupInfo(loop, condition->InputAt(1)); @@ -1259,8 +1252,7 @@ bool HInductionVarAnalysis::RewriteBreakLoop(const HBasicBlock* context, return false; } // Simple terminating i != U condition, used nowhere else. - // TODO: Remove "OrNull". - HIf* ifs = loop->GetHeader()->GetLastInstruction()->AsIfOrNull(); + HIf* ifs = loop->GetHeader()->GetLastInstruction()->AsIf(); HInstruction* cond = ifs->InputAt(0); if (ifs->GetPrevious() != cond || !cond->HasOnlyOneNonEnvironmentUse()) { return false; @@ -1523,11 +1515,9 @@ bool HInductionVarAnalysis::InductionEqual(InductionInfo* info1, std::string HInductionVarAnalysis::FetchToString(HInstruction* fetch) { DCHECK(fetch != nullptr); if (fetch->IsIntConstant()) { - // TODO: Remove "OrNull". - return std::to_string(fetch->AsIntConstantOrNull()->GetValue()); + return std::to_string(fetch->AsIntConstant()->GetValue()); } else if (fetch->IsLongConstant()) { - // TODO: Remove "OrNull". - return std::to_string(fetch->AsLongConstantOrNull()->GetValue()); + return std::to_string(fetch->AsLongConstant()->GetValue()); } return std::to_string(fetch->GetId()) + ":" + fetch->DebugName(); } @@ -1619,8 +1609,7 @@ void HInductionVarAnalysis::CalculateLoopHeaderPhisInARow( // If the input is not a loop header phi, we only have 1 (current_phi). int current_value = 1; if (current_phi->InputAt(index)->IsLoopHeaderPhi()) { - // TODO: Remove "OrNull". - HPhi* loop_header_phi = current_phi->InputAt(index)->AsPhiOrNull(); + HPhi* loop_header_phi = current_phi->InputAt(index)->AsPhi(); auto it = cached_values.find(loop_header_phi); if (it != cached_values.end()) { current_value += it->second; @@ -1661,8 +1650,7 @@ bool HInductionVarAnalysis::IsPathologicalCase() { for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { DCHECK(it.Current()->IsLoopHeaderPhi()); - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); CalculateLoopHeaderPhisInARow(phi, cached_values, local_allocator); DCHECK(cached_values.find(phi) != cached_values.end()) << " we should have a value for Phi " << phi->GetId() diff --git a/compiler/optimizing/induction_var_range.cc b/compiler/optimizing/induction_var_range.cc index 107a2c38da..9b78699ead 100644 --- a/compiler/optimizing/induction_var_range.cc +++ b/compiler/optimizing/induction_var_range.cc @@ -171,9 +171,8 @@ bool UseFullTripCount(const HBasicBlock* context, const HLoopInformation* loop, // one edge leaving the loop. The loop header is the only block that's both inside // the loop and not in the loop body. DCHECK(GetLoopControl(loop)->IsIf()); - // TODO: Remove "OrNull". - DCHECK_NE(loop->Contains(*GetLoopControl(loop)->AsIfOrNull()->IfTrueSuccessor()), - loop->Contains(*GetLoopControl(loop)->AsIfOrNull()->IfFalseSuccessor())); + DCHECK_NE(loop->Contains(*GetLoopControl(loop)->AsIf()->IfTrueSuccessor()), + loop->Contains(*GetLoopControl(loop)->AsIf()->IfFalseSuccessor())); if (loop->Contains(*context)) { // Use the full trip count if determining the maximum and context is not in the loop body. DCHECK_NE(context == loop->GetHeader(), IsContextInBody(context, loop)); @@ -183,10 +182,8 @@ bool UseFullTripCount(const HBasicBlock* context, const HLoopInformation* loop, // as long as the `context` is dominated by the loop control exit block. // If there are additional exit edges, the value is unknown on those paths. HInstruction* loop_control = GetLoopControl(loop); - // TODO: Remove "OrNull". - HBasicBlock* then_block = loop_control->AsIfOrNull()->IfTrueSuccessor(); - // TODO: Remove "OrNull". - HBasicBlock* else_block = loop_control->AsIfOrNull()->IfFalseSuccessor(); + HBasicBlock* then_block = loop_control->AsIf()->IfTrueSuccessor(); + HBasicBlock* else_block = loop_control->AsIf()->IfFalseSuccessor(); HBasicBlock* loop_exit_block = loop->Contains(*then_block) ? else_block : then_block; return loop_exit_block->Dominates(context); } @@ -738,15 +735,13 @@ InductionVarRange::Value InductionVarRange::GetFetch(const HBasicBlock* context, return is_min ? Value(0) : Value(std::numeric_limits::max()); } else if (instruction->InputAt(0)->IsNewArray()) { return GetFetch( - // TODO: Remove "OrNull". - context, loop, instruction->InputAt(0)->AsNewArrayOrNull()->GetLength(), trip, is_min); + context, loop, instruction->InputAt(0)->AsNewArray()->GetLength(), trip, is_min); } } else if (instruction->IsTypeConversion()) { // Since analysis is 32-bit (or narrower), chase beyond widening along the path. // For example, this discovers the length in: for (long i = 0; i < a.length; i++); - // TODO: Remove "OrNull". - if (instruction->AsTypeConversionOrNull()->GetInputType() == DataType::Type::kInt32 && - instruction->AsTypeConversionOrNull()->GetResultType() == DataType::Type::kInt64) { + if (instruction->AsTypeConversion()->GetInputType() == DataType::Type::kInt32 && + instruction->AsTypeConversion()->GetResultType() == DataType::Type::kInt64) { return GetFetch(context, loop, instruction->InputAt(0), trip, is_min); } } diff --git a/compiler/optimizing/induction_var_range.h b/compiler/optimizing/induction_var_range.h index 356a04ab19..3e1212bec8 100644 --- a/compiler/optimizing/induction_var_range.h +++ b/compiler/optimizing/induction_var_range.h @@ -139,8 +139,7 @@ class InductionVarRange { void ReVisit(const HLoopInformation* loop) { induction_analysis_->induction_.erase(loop); for (HInstructionIterator it(loop->GetHeader()->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - induction_analysis_->cycles_.erase(it.Current()->AsPhiOrNull()); + induction_analysis_->cycles_.erase(it.Current()->AsPhi()); } induction_analysis_->VisitLoop(loop); } diff --git a/compiler/optimizing/induction_var_range_test.cc b/compiler/optimizing/induction_var_range_test.cc index 9c84a75f06..d879897959 100644 --- a/compiler/optimizing/induction_var_range_test.cc +++ b/compiler/optimizing/induction_var_range_test.cc @@ -50,8 +50,7 @@ class InductionVarRangeTest : public OptimizingUnitTest { void ExpectInt(int32_t value, HInstruction* i) { ASSERT_TRUE(i->IsIntConstant()); - // TODO: Remove "OrNull". - EXPECT_EQ(value, i->AsIntConstantOrNull()->GetValue()); + EXPECT_EQ(value, i->AsIntConstant()->GetValue()); } // diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 2185fc0c4e..443392ba28 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -467,8 +467,7 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) { ArtMethod* resolved_method = invoke_instruction->GetResolvedMethod(); if (resolved_method == nullptr) { DCHECK(invoke_instruction->IsInvokeStaticOrDirect()); - // TODO: Remove "OrNull". - DCHECK(invoke_instruction->AsInvokeStaticOrDirectOrNull()->IsStringInit()); + DCHECK(invoke_instruction->AsInvokeStaticOrDirect()->IsStringInit()); LOG_FAIL_NO_STAT() << "Not inlining a String. method"; return false; } @@ -1147,10 +1146,9 @@ bool HInliner::TryInlinePolymorphicCallToSameTarget( PointerSize pointer_size = class_linker->GetImagePointerSize(); ArtMethod* actual_method = nullptr; - // TODO: Remove "OrNull". size_t method_index = invoke_instruction->IsInvokeVirtual() - ? invoke_instruction->AsInvokeVirtualOrNull()->GetVTableIndex() - : invoke_instruction->AsInvokeInterfaceOrNull()->GetImtIndex(); + ? invoke_instruction->AsInvokeVirtual()->GetVTableIndex() + : invoke_instruction->AsInvokeInterface()->GetImtIndex(); // Check whether we are actually calling the same method among // the different types seen. @@ -1466,8 +1464,7 @@ bool HInliner::IsInliningSupported(const HInvoke* invoke_instruction, } if (invoke_instruction->IsInvokeStaticOrDirect() && - // TODO: Remove "OrNull". - invoke_instruction->AsInvokeStaticOrDirectOrNull()->IsStaticWithImplicitClinitCheck()) { + invoke_instruction->AsInvokeStaticOrDirect()->IsStaticWithImplicitClinitCheck()) { // Case of a static method that cannot be inlined because it implicitly // requires an initialization check of its declaring class. LOG_FAIL(stats_, MethodCompilationStat::kNotInlinedDexCacheClinitCheck) @@ -1853,21 +1850,15 @@ void HInliner::SubstituteArguments(HGraph* callee_graph, if (argument->IsNullConstant()) { current->ReplaceWith(callee_graph->GetNullConstant()); } else if (argument->IsIntConstant()) { - // TODO: Remove "OrNull". - current->ReplaceWith( - callee_graph->GetIntConstant(argument->AsIntConstantOrNull()->GetValue())); + current->ReplaceWith(callee_graph->GetIntConstant(argument->AsIntConstant()->GetValue())); } else if (argument->IsLongConstant()) { - // TODO: Remove "OrNull". - current->ReplaceWith( - callee_graph->GetLongConstant(argument->AsLongConstantOrNull()->GetValue())); + current->ReplaceWith(callee_graph->GetLongConstant(argument->AsLongConstant()->GetValue())); } else if (argument->IsFloatConstant()) { - // TODO: Remove "OrNull". current->ReplaceWith( - callee_graph->GetFloatConstant(argument->AsFloatConstantOrNull()->GetValue())); + callee_graph->GetFloatConstant(argument->AsFloatConstant()->GetValue())); } else if (argument->IsDoubleConstant()) { - // TODO: Remove "OrNull". current->ReplaceWith( - callee_graph->GetDoubleConstant(argument->AsDoubleConstantOrNull()->GetValue())); + callee_graph->GetDoubleConstant(argument->AsDoubleConstant()->GetValue())); } else if (argument->GetType() == DataType::Type::kReference) { if (!resolved_method->IsStatic() && parameter_index == 0 && receiver_type.IsValid()) { run_rtp = true; @@ -1875,8 +1866,7 @@ void HInliner::SubstituteArguments(HGraph* callee_graph, } else { current->SetReferenceTypeInfoIfValid(argument->GetReferenceTypeInfo()); } - // TODO: Remove "OrNull". - current->AsParameterValueOrNull()->SetCanBeNull(argument->CanBeNull()); + current->AsParameterValue()->SetCanBeNull(argument->CanBeNull()); } ++parameter_index; } @@ -2337,8 +2327,7 @@ bool HInliner::ReturnTypeMoreSpecific(HInstruction* return_replacement, return_replacement)) { return true; } else if (return_replacement->IsInstanceFieldGet()) { - // TODO: Remove "OrNull". - HInstanceFieldGet* field_get = return_replacement->AsInstanceFieldGetOrNull(); + HInstanceFieldGet* field_get = return_replacement->AsInstanceFieldGet(); if (field_get->GetFieldInfo().GetField() == GetClassRoot()->GetInstanceField(0)) { return true; diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc index f461be9df1..2576b02c9f 100644 --- a/compiler/optimizing/instruction_builder.cc +++ b/compiler/optimizing/instruction_builder.cc @@ -268,14 +268,12 @@ void HInstructionBuilder::PropagateLocalsToCatchBlocks() { if (local_value == nullptr) { // This is the first instruction throwing into `catch_block` where // `vreg` is undefined. Delete the catch phi. - // TODO: Remove "OrNull". - catch_block->RemovePhi(handler_value->AsPhiOrNull()); + catch_block->RemovePhi(handler_value->AsPhi()); (*handler_locals)[vreg] = nullptr; } else { // Vreg has been defined at all instructions throwing into `catch_block` // encountered so far. Record the local value in the catch phi. - // TODO: Remove "OrNull". - handler_value->AsPhiOrNull()->AddInput(local_value); + handler_value->AsPhi()->AddInput(local_value); } } } @@ -323,8 +321,7 @@ void HInstructionBuilder::SetLoopHeaderPhiInputs() { for (size_t i = loop_headers_.size(); i > 0; --i) { HBasicBlock* block = loop_headers_[i - 1]; for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); size_t vreg = phi->GetRegNumber(); for (HBasicBlock* predecessor : block->GetPredecessors()) { HInstruction* value = ValueOfLocalAt(predecessor, vreg); @@ -1470,8 +1467,7 @@ void HInstructionBuilder::BuildConstructorFenceForAllocation(HInstruction* alloc // // Do not emit an HConstructorFence here since it can inhibit some String new-instance // optimizations (to pass checker tests that rely on those optimizations). - // TODO: Remove "OrNull". - HNewInstance* new_inst = allocation->AsNewInstanceOrNull(); + HNewInstance* new_inst = allocation->AsNewInstance(); HLoadClass* load_class = new_inst->GetLoadClass(); Thread* self = Thread::Current(); @@ -1840,20 +1836,15 @@ bool HInstructionBuilder::SetupInvokeArguments(HInstruction* invoke, if (invoke->IsInvokeStaticOrDirect() && HInvokeStaticOrDirect::NeedsCurrentMethodInput( - // TODO: Remove "OrNull". - invoke->AsInvokeStaticOrDirectOrNull()->GetDispatchInfo())) { - // TODO: Remove "OrNull". - DCHECK_EQ(argument_index, invoke->AsInvokeStaticOrDirectOrNull()->GetCurrentMethodIndex()); + invoke->AsInvokeStaticOrDirect()->GetDispatchInfo())) { + DCHECK_EQ(argument_index, invoke->AsInvokeStaticOrDirect()->GetCurrentMethodIndex()); DCHECK(invoke->InputAt(argument_index) == nullptr); invoke->SetRawInputAt(argument_index, graph_->GetCurrentMethod()); } if (invoke->IsInvokeInterface() && - // TODO: Remove "OrNull". - (invoke->AsInvokeInterfaceOrNull()->GetHiddenArgumentLoadKind() == - MethodLoadKind::kRecursive)) { - // TODO: Remove "OrNull". - invoke->SetRawInputAt(invoke->AsInvokeInterfaceOrNull()->GetNumberOfArguments() - 1, + (invoke->AsInvokeInterface()->GetHiddenArgumentLoadKind() == MethodLoadKind::kRecursive)) { + invoke->SetRawInputAt(invoke->AsInvokeInterface()->GetNumberOfArguments() - 1, graph_->GetCurrentMethod()); } @@ -1865,8 +1856,7 @@ bool HInstructionBuilder::HandleInvoke(HInvoke* invoke, const char* shorty, bool is_unresolved) { DCHECK_IMPLIES(invoke->IsInvokeStaticOrDirect(), - // TODO: Remove "OrNull". - !invoke->AsInvokeStaticOrDirectOrNull()->IsStringInit()); + !invoke->AsInvokeStaticOrDirect()->IsStringInit()); ReceiverArg receiver_arg = (invoke->GetInvokeType() == InvokeType::kStatic) ? ReceiverArg::kNone @@ -1924,8 +1914,7 @@ bool HInstructionBuilder::BuildSimpleIntrinsic(ArtMethod* method, case Intrinsics::kDoubleIsNaN: { // IsNaN(x) is the same as x != x. instruction = new (allocator_) HNotEqual(/*first=*/ nullptr, /*second=*/ nullptr, dex_pc); - // TODO: Remove "OrNull". - instruction->AsConditionOrNull()->SetBias(ComparisonBias::kLtBias); + instruction->AsCondition()->SetBias(ComparisonBias::kLtBias); break; } case Intrinsics::kStringCharAt: @@ -2072,8 +2061,7 @@ bool HInstructionBuilder::HandleStringInit(HInvoke* invoke, const InstructionOperands& operands, const char* shorty) { DCHECK(invoke->IsInvokeStaticOrDirect()); - // TODO: Remove "OrNull". - DCHECK(invoke->AsInvokeStaticOrDirectOrNull()->IsStringInit()); + DCHECK(invoke->AsInvokeStaticOrDirect()->IsStringInit()); if (!SetupInvokeArguments(invoke, operands, shorty, ReceiverArg::kIgnored)) { return false; @@ -2089,8 +2077,7 @@ bool HInstructionBuilder::HandleStringInit(HInvoke* invoke, // Replacing the NewInstance might render it redundant. Keep a list of these // to be visited once it is clear whether it has remaining uses. if (arg_this->IsNewInstance()) { - // TODO: Remove "OrNull". - ssa_builder_->AddUninitializedString(arg_this->AsNewInstanceOrNull()); + ssa_builder_->AddUninitializedString(arg_this->AsNewInstance()); } else { DCHECK(arg_this->IsPhi()); // We can get a phi as input of a String. if there is a loop between the @@ -2379,10 +2366,8 @@ void HInstructionBuilder::BuildCheckedDivRem(uint16_t out_vreg, } if (!second_is_constant || - // TODO: Remove "OrNull". - (type == DataType::Type::kInt32 && second->AsIntConstantOrNull()->GetValue() == 0) || - // TODO: Remove "OrNull". - (type == DataType::Type::kInt64 && second->AsLongConstantOrNull()->GetValue() == 0)) { + (type == DataType::Type::kInt32 && second->AsIntConstant()->GetValue() == 0) || + (type == DataType::Type::kInt64 && second->AsLongConstant()->GetValue() == 0)) { second = new (allocator_) HDivZeroCheck(second, dex_pc); AppendInstruction(second); } @@ -2878,8 +2863,7 @@ bool HInstructionBuilder::ProcessDexInstruction(const Instruction& instruction, uint32_t reg_number = instruction.VRegB(); HInstruction* value = (*current_locals_)[reg_number]; if (value->IsIntConstant()) { - // TODO: Remove "OrNull". - DCHECK_EQ(value->AsIntConstantOrNull()->GetValue(), 0); + DCHECK_EQ(value->AsIntConstant()->GetValue(), 0); } else if (value->IsPhi()) { DCHECK(value->GetType() == DataType::Type::kInt32 || value->GetType() == DataType::Type::kReference); diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc index 43129d1704..0d2c252184 100644 --- a/compiler/optimizing/instruction_simplifier.cc +++ b/compiler/optimizing/instruction_simplifier.cc @@ -192,10 +192,8 @@ bool AreAllBitsSet(HConstant* constant) { bool InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop(HBinaryOperation* binop) { DCHECK(binop->IsAdd() || binop->IsSub()); DCHECK(binop->GetLeft()->IsNeg() && binop->GetRight()->IsNeg()); - // TODO: Remove "OrNull". - HNeg* left_neg = binop->GetLeft()->AsNegOrNull(); - // TODO: Remove "OrNull". - HNeg* right_neg = binop->GetRight()->AsNegOrNull(); + HNeg* left_neg = binop->GetLeft()->AsNeg(); + HNeg* right_neg = binop->GetRight()->AsNeg(); if (!left_neg->HasOnlyOneNonEnvironmentUse() || !right_neg->HasOnlyOneNonEnvironmentUse()) { return false; @@ -315,8 +313,7 @@ bool InstructionSimplifierVisitor::TryCombineVecMultiplyAccumulate(HVecMul* mul) // whether all uses are on different control-flow paths (using dominance and // reverse-dominance information) and only perform the merge when they are. HInstruction* accumulator = nullptr; - // TODO: Remove "OrNull". - HVecBinaryOperation* vec_binop = binop->AsVecBinaryOperationOrNull(); + HVecBinaryOperation* vec_binop = binop->AsVecBinaryOperation(); HInstruction* binop_left = vec_binop->GetLeft(); HInstruction* binop_right = vec_binop->GetRight(); // This is always true since the `HVecMul` has only one use (which is checked above). @@ -374,8 +371,7 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) { : kMaxIntShiftDistance; if (shift_amount->IsConstant()) { - // TODO: Remove "OrNull". - int64_t cst = Int64FromConstant(shift_amount->AsConstantOrNull()); + int64_t cst = Int64FromConstant(shift_amount->AsConstant()); int64_t masked_cst = cst & implicit_mask; if (masked_cst == 0) { // Replace code looking like @@ -416,8 +412,7 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) { shift_amount->IsAdd() || shift_amount->IsSub()) { int64_t required_result = shift_amount->IsAnd() ? implicit_mask : 0; - // TODO: Remove "OrNull". - HBinaryOperation* bin_op = shift_amount->AsBinaryOperationOrNull(); + HBinaryOperation* bin_op = shift_amount->AsBinaryOperation(); HConstant* mask = bin_op->GetConstantRight(); if (mask != nullptr && (Int64FromConstant(mask) & implicit_mask) == required_result) { instruction->ReplaceInput(bin_op->GetLeastConstantLeft(), 1); @@ -429,8 +424,7 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) { DataType::Type source_type = shift_amount->InputAt(0)->GetType(); // Non-integral and 64-bit source types require an explicit type conversion. if (DataType::IsIntegralType(source_type) && !DataType::Is64BitType(source_type)) { - // TODO: Remove "OrNull". - instruction->ReplaceInput(shift_amount->AsTypeConversionOrNull()->GetInput(), 1); + instruction->ReplaceInput(shift_amount->AsTypeConversion()->GetInput(), 1); RecordSimplification(); return; } @@ -440,8 +434,7 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) { static bool IsSubRegBitsMinusOther(HSub* sub, size_t reg_bits, HInstruction* other) { return (sub->GetRight() == other && sub->GetLeft()->IsConstant() && - // TODO: Remove "OrNull". - (Int64FromConstant(sub->GetLeft()->AsConstantOrNull()) & (reg_bits - 1)) == 0); + (Int64FromConstant(sub->GetLeft()->AsConstant()) & (reg_bits - 1)) == 0); } bool InstructionSimplifierVisitor::ReplaceRotateWithRor(HBinaryOperation* op, @@ -474,10 +467,8 @@ bool InstructionSimplifierVisitor::TryReplaceWithRotate(HBinaryOperation* op) { HInstruction* right = op->GetRight(); // If we have an UShr and a Shl (in either order). if ((left->IsUShr() && right->IsShl()) || (left->IsShl() && right->IsUShr())) { - // TODO: Remove "OrNull". - HUShr* ushr = left->IsUShr() ? left->AsUShrOrNull() : right->AsUShrOrNull(); - // TODO: Remove "OrNull". - HShl* shl = left->IsShl() ? left->AsShlOrNull() : right->AsShlOrNull(); + HUShr* ushr = left->IsUShr() ? left->AsUShr() : right->AsUShr(); + HShl* shl = left->IsShl() ? left->AsShl() : right->AsShl(); DCHECK(DataType::IsIntOrLongType(ushr->GetType())); if (ushr->GetType() == shl->GetType() && ushr->GetLeft() == shl->GetLeft()) { @@ -512,10 +503,8 @@ bool InstructionSimplifierVisitor::TryReplaceWithRotateConstantPattern(HBinaryOp HShl* shl) { DCHECK(op->IsAdd() || op->IsXor() || op->IsOr()); size_t reg_bits = DataType::Size(ushr->GetType()) * kBitsPerByte; - // TODO: Remove "OrNull". - size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstantOrNull()); - // TODO: Remove "OrNull". - size_t ldist = Int64FromConstant(shl->GetRight()->AsConstantOrNull()); + size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstant()); + size_t ldist = Int64FromConstant(shl->GetRight()->AsConstant()); if (((ldist + rdist) & (reg_bits - 1)) == 0) { ReplaceRotateWithRor(op, ushr, shl); return true; @@ -545,8 +534,7 @@ bool InstructionSimplifierVisitor::TryReplaceWithRotateRegisterNegPattern(HBinar DCHECK(op->IsAdd() || op->IsXor() || op->IsOr()); DCHECK(ushr->GetRight()->IsNeg() || shl->GetRight()->IsNeg()); bool neg_is_left = shl->GetRight()->IsNeg(); - // TODO: Remove "OrNull". - HNeg* neg = neg_is_left ? shl->GetRight()->AsNegOrNull() : ushr->GetRight()->AsNegOrNull(); + HNeg* neg = neg_is_left ? shl->GetRight()->AsNeg() : ushr->GetRight()->AsNeg(); // And the shift distance being negated is the distance being shifted the other way. if (neg->InputAt(0) == (neg_is_left ? ushr->GetRight() : shl->GetRight())) { ReplaceRotateWithRor(op, ushr, shl); @@ -578,12 +566,8 @@ bool InstructionSimplifierVisitor::TryReplaceWithRotateRegisterSubPattern(HBinar size_t reg_bits = DataType::Size(ushr->GetType()) * kBitsPerByte; HInstruction* shl_shift = shl->GetRight(); HInstruction* ushr_shift = ushr->GetRight(); - if ((shl_shift->IsSub() && - // TODO: Remove "OrNull". - IsSubRegBitsMinusOther(shl_shift->AsSubOrNull(), reg_bits, ushr_shift)) || - (ushr_shift->IsSub() && - // TODO: Remove "OrNull". - IsSubRegBitsMinusOther(ushr_shift->AsSubOrNull(), reg_bits, shl_shift))) { + if ((shl_shift->IsSub() && IsSubRegBitsMinusOther(shl_shift->AsSub(), reg_bits, ushr_shift)) || + (ushr_shift->IsSub() && IsSubRegBitsMinusOther(ushr_shift->AsSub(), reg_bits, shl_shift))) { return ReplaceRotateWithRor(op, ushr, shl); } return false; @@ -805,14 +789,12 @@ void InstructionSimplifierVisitor::VisitEqual(HEqual* equal) { HBasicBlock* block = equal->GetBlock(); // We are comparing the boolean to a constant which is of type int and can // be any constant. - // TODO: Remove "OrNull". - if (input_const->AsIntConstantOrNull()->IsTrue()) { + if (input_const->AsIntConstant()->IsTrue()) { // Replace (bool_value == true) with bool_value equal->ReplaceWith(input_value); block->RemoveInstruction(equal); RecordSimplification(); - // TODO: Remove "OrNull". - } else if (input_const->AsIntConstantOrNull()->IsFalse()) { + } else if (input_const->AsIntConstant()->IsFalse()) { // Replace (bool_value == false) with !bool_value equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, equal)); block->RemoveInstruction(equal); @@ -839,14 +821,12 @@ void InstructionSimplifierVisitor::VisitNotEqual(HNotEqual* not_equal) { HBasicBlock* block = not_equal->GetBlock(); // We are comparing the boolean to a constant which is of type int and can // be any constant. - // TODO: Remove "OrNull". - if (input_const->AsIntConstantOrNull()->IsTrue()) { + if (input_const->AsIntConstant()->IsTrue()) { // Replace (bool_value != true) with !bool_value not_equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, not_equal)); block->RemoveInstruction(not_equal); RecordSimplification(); - // TODO: Remove "OrNull". - } else if (input_const->AsIntConstantOrNull()->IsFalse()) { + } else if (input_const->AsIntConstant()->IsFalse()) { // Replace (bool_value != false) with bool_value not_equal->ReplaceWith(input_value); block->RemoveInstruction(not_equal); @@ -871,12 +851,10 @@ void InstructionSimplifierVisitor::VisitBooleanNot(HBooleanNot* bool_not) { if (input->IsIntConstant()) { // Replace !(true/false) with false/true. - // TODO: Remove "OrNull". - if (input->AsIntConstantOrNull()->IsTrue()) { + if (input->AsIntConstant()->IsTrue()) { replace_with = GetGraph()->GetIntConstant(0); } else { - // TODO: Remove "OrNull". - DCHECK(input->AsIntConstantOrNull()->IsFalse()) << input->AsIntConstantOrNull()->GetValue(); + DCHECK(input->AsIntConstant()->IsFalse()) << input->AsIntConstant()->GetValue(); replace_with = GetGraph()->GetIntConstant(1); } } else if (input->IsBooleanNot()) { @@ -887,8 +865,7 @@ void InstructionSimplifierVisitor::VisitBooleanNot(HBooleanNot* bool_not) { // NaNs forces the compares to be done as written by the user. !DataType::IsFloatingPointType(input->InputAt(0)->GetType())) { // Replace condition with its opposite. - // TODO: Remove "OrNull". - replace_with = GetGraph()->InsertOppositeCondition(input->AsConditionOrNull(), bool_not); + replace_with = GetGraph()->InsertOppositeCondition(input->AsCondition(), bool_not); } if (replace_with != nullptr) { @@ -956,10 +933,8 @@ static HInstruction* AllowInMinMax(IfCondition cmp, if (IsInt64AndGet(b, /*out*/ &value) && (((cmp == kCondLT || cmp == kCondLE) && c->IsMax()) || ((cmp == kCondGT || cmp == kCondGE) && c->IsMin()))) { - // TODO: Remove "OrNull". - HConstant* other = c->AsBinaryOperationOrNull()->GetConstantRight(); - // TODO: Remove "OrNull". - if (other != nullptr && a == c->AsBinaryOperationOrNull()->GetLeastConstantLeft()) { + HConstant* other = c->AsBinaryOperation()->GetConstantRight(); + if (other != nullptr && a == c->AsBinaryOperation()->GetLeastConstantLeft()) { int64_t other_value = Int64FromConstant(other); bool is_max = (cmp == kCondLT || cmp == kCondLE); // Allow the max for a < 100 ? max(a, -100) : .. @@ -1053,32 +1028,24 @@ void InstructionSimplifierVisitor::VisitSelect(HSelect* select) { // Replace (cond ? x : x) with (x). replace_with = true_value; } else if (condition->IsIntConstant()) { - // TODO: Remove "OrNull". - if (condition->AsIntConstantOrNull()->IsTrue()) { + if (condition->AsIntConstant()->IsTrue()) { // Replace (true ? x : y) with (x). replace_with = true_value; } else { // Replace (false ? x : y) with (y). - // TODO: Remove "OrNull". - DCHECK(condition->AsIntConstantOrNull()->IsFalse()) - << condition->AsIntConstantOrNull()->GetValue(); + DCHECK(condition->AsIntConstant()->IsFalse()) << condition->AsIntConstant()->GetValue(); replace_with = false_value; } } else if (true_value->IsIntConstant() && false_value->IsIntConstant()) { - // TODO: Remove "OrNull". - if (true_value->AsIntConstantOrNull()->IsTrue() && - false_value->AsIntConstantOrNull()->IsFalse()) { + if (true_value->AsIntConstant()->IsTrue() && false_value->AsIntConstant()->IsFalse()) { // Replace (cond ? true : false) with (cond). replace_with = condition; - // TODO: Remove "OrNull". - } else if (true_value->AsIntConstantOrNull()->IsFalse() && - false_value->AsIntConstantOrNull()->IsTrue()) { + } else if (true_value->AsIntConstant()->IsFalse() && false_value->AsIntConstant()->IsTrue()) { // Replace (cond ? false : true) with (!cond). replace_with = GetGraph()->InsertOppositeCondition(condition, select); } } else if (condition->IsCondition()) { - // TODO: Remove "OrNull". - IfCondition cmp = condition->AsConditionOrNull()->GetCondition(); + IfCondition cmp = condition->AsCondition()->GetCondition(); HInstruction* a = condition->InputAt(0); HInstruction* b = condition->InputAt(1); DataType::Type t_type = true_value->GetType(); @@ -1159,8 +1126,7 @@ void InstructionSimplifierVisitor::VisitArrayLength(HArrayLength* instruction) { // If the array is a NewArray with constant size, replace the array length // with the constant instruction. This helps the bounds check elimination phase. if (input->IsNewArray()) { - // TODO: Remove "OrNull". - input = input->AsNewArrayOrNull()->GetLength(); + input = input->AsNewArray()->GetLength(); if (input->IsIntConstant()) { instruction->ReplaceWith(input); } @@ -1178,8 +1144,7 @@ void InstructionSimplifierVisitor::VisitArraySet(HArraySet* instruction) { } if (value->IsArrayGet()) { - // TODO: Remove "OrNull". - if (value->AsArrayGetOrNull()->GetArray() == instruction->GetArray()) { + if (value->AsArrayGet()->GetArray() == instruction->GetArray()) { // If the code is just swapping elements in the array, no need for a type check. instruction->ClearTypeCheck(); return; @@ -1255,21 +1220,16 @@ static bool CanRemoveRedundantAnd(HConstant* and_right, static inline bool TryReplaceFieldOrArrayGetType(HInstruction* maybe_get, DataType::Type new_type) { if (maybe_get->IsInstanceFieldGet()) { - // TODO: Remove "OrNull". - maybe_get->AsInstanceFieldGetOrNull()->SetType(new_type); + maybe_get->AsInstanceFieldGet()->SetType(new_type); return true; } else if (maybe_get->IsPredicatedInstanceFieldGet()) { - // TODO: Remove "OrNull". - maybe_get->AsPredicatedInstanceFieldGetOrNull()->SetType(new_type); + maybe_get->AsPredicatedInstanceFieldGet()->SetType(new_type); return true; } else if (maybe_get->IsStaticFieldGet()) { - // TODO: Remove "OrNull". - maybe_get->AsStaticFieldGetOrNull()->SetType(new_type); + maybe_get->AsStaticFieldGet()->SetType(new_type); return true; - // TODO: Remove "OrNull". - } else if (maybe_get->IsArrayGet() && !maybe_get->AsArrayGetOrNull()->IsStringCharAt()) { - // TODO: Remove "OrNull". - maybe_get->AsArrayGetOrNull()->SetType(new_type); + } else if (maybe_get->IsArrayGet() && !maybe_get->AsArrayGet()->IsStringCharAt()) { + maybe_get->AsArrayGet()->SetType(new_type); return true; } else { return false; @@ -1304,27 +1264,20 @@ static bool IsTypeConversionForStoringIntoNoWiderFieldOnly(HTypeConversion* type for (const HUseListNode& use : type_conversion->GetUses()) { HInstruction* instruction = use.GetUser(); if (instruction->IsInstanceFieldSet() && - // TODO: Remove "OrNull". - instruction->AsInstanceFieldSetOrNull()->GetFieldType() == result_type) { - // TODO: Remove "OrNull". - DCHECK_EQ(instruction->AsInstanceFieldSetOrNull()->GetValue(), type_conversion); + instruction->AsInstanceFieldSet()->GetFieldType() == result_type) { + DCHECK_EQ(instruction->AsInstanceFieldSet()->GetValue(), type_conversion); continue; } if (instruction->IsStaticFieldSet() && - // TODO: Remove "OrNull". - instruction->AsStaticFieldSetOrNull()->GetFieldType() == result_type) { - // TODO: Remove "OrNull". - DCHECK_EQ(instruction->AsStaticFieldSetOrNull()->GetValue(), type_conversion); + instruction->AsStaticFieldSet()->GetFieldType() == result_type) { + DCHECK_EQ(instruction->AsStaticFieldSet()->GetValue(), type_conversion); continue; } if (instruction->IsArraySet() && - // TODO: Remove "OrNull". - instruction->AsArraySetOrNull()->GetComponentType() == result_type && + instruction->AsArraySet()->GetComponentType() == result_type && // not index use. - // TODO: Remove "OrNull". - instruction->AsArraySetOrNull()->GetIndex() != type_conversion) { - // TODO: Remove "OrNull". - DCHECK_EQ(instruction->AsArraySetOrNull()->GetValue(), type_conversion); + instruction->AsArraySet()->GetIndex() != type_conversion) { + DCHECK_EQ(instruction->AsArraySet()->GetValue(), type_conversion); continue; } // The use is not as a store value, or the field/element type is not the @@ -1347,8 +1300,7 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct } if (input->IsTypeConversion()) { - // TODO: Remove "OrNull". - HTypeConversion* input_conversion = input->AsTypeConversionOrNull(); + HTypeConversion* input_conversion = input->AsTypeConversion(); HInstruction* original_input = input_conversion->GetInput(); DataType::Type original_type = original_input->GetType(); @@ -1390,14 +1342,12 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct // Optimization only applies to lossy Type Conversions. !IsTypeConversionLossless(input_type, result_type)) { DCHECK(DataType::IsIntegralType(input_type)); - // TODO: Remove "OrNull". - HShr* shr_op = input->AsShrOrNull(); + HShr* shr_op = input->AsShr(); HConstant* shr_right = shr_op->GetConstantRight(); HInstruction* shr_left = shr_op->GetLeastConstantLeft(); if (shr_right != nullptr && shr_left->IsAnd()) { // Optimization needs AND -> SHR -> TypeConversion pattern. - // TODO: Remove "OrNull". - HAnd* and_op = shr_left->AsAndOrNull(); + HAnd* and_op = shr_left->AsAnd(); HConstant* and_right = and_op->GetConstantRight(); HInstruction* and_left = and_op->GetLeastConstantLeft(); if (and_right != nullptr && @@ -1420,8 +1370,7 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct } } else if (input->IsAnd() && DataType::IsIntegralType(result_type)) { DCHECK(DataType::IsIntegralType(input_type)); - // TODO: Remove "OrNull". - HAnd* input_and = input->AsAndOrNull(); + HAnd* input_and = input->AsAnd(); HConstant* constant = input_and->GetConstantRight(); if (constant != nullptr) { int64_t value = Int64FromConstant(constant); @@ -1507,8 +1456,7 @@ void InstructionSimplifierVisitor::VisitAdd(HAdd* instruction) { } } - // TODO: Remove first "OrNull", keep the second. - HNeg* neg = left_is_neg ? left->AsNegOrNull() : right->AsNegOrNull(); + HNeg* neg = left_is_neg ? left->AsNeg() : right->AsNegOrNull(); if (left_is_neg != right_is_neg && neg->HasOnlyOneNonEnvironmentUse()) { // Replace code looking like // NEG tmp, b @@ -1619,9 +1567,7 @@ void InstructionSimplifierVisitor::VisitAnd(HAnd* instruction) { // precisely clears the shifted-in sign bits. if ((input_other->IsUShr() || input_other->IsShr()) && input_other->InputAt(1)->IsConstant()) { size_t reg_bits = (instruction->GetResultType() == DataType::Type::kInt64) ? 64 : 32; - // TODO: Remove "OrNull". - size_t shift = - Int64FromConstant(input_other->InputAt(1)->AsConstantOrNull()) & (reg_bits - 1); + size_t shift = Int64FromConstant(input_other->InputAt(1)->AsConstant()) & (reg_bits - 1); size_t num_tail_bits_set = CTZ(value + 1); if ((num_tail_bits_set >= reg_bits - shift) && input_other->IsUShr()) { // This AND clears only bits known to be clear, for example "(x >>> 24) & 0xff". @@ -1729,8 +1675,7 @@ static bool RecognizeAndSimplifyClassCheck(HCondition* condition) { HInstruction* input_one = condition->InputAt(0); HInstruction* input_two = condition->InputAt(1); HLoadClass* load_class = input_one->IsLoadClass() - // TODO: Remove "OrNull". - ? input_one->AsLoadClassOrNull() + ? input_one->AsLoadClass() : input_two->AsLoadClassOrNull(); if (load_class == nullptr) { return false; @@ -1810,8 +1755,7 @@ void InstructionSimplifierVisitor::VisitCondition(HCondition* condition) { // We can only replace an HCondition which compares a Compare to 0. // Both 'dx' and 'jack' generate a compare to 0 when compiling a // condition with a long, float or double comparison as input. - // TODO: Remove "OrNull". - if (!left->IsCompare() || !right->IsConstant() || right->AsIntConstantOrNull()->GetValue() != 0) { + if (!left->IsCompare() || !right->IsConstant() || right->AsIntConstant()->GetValue() != 0) { // Conversion is not possible. return; } @@ -1838,8 +1782,7 @@ void InstructionSimplifierVisitor::VisitCondition(HCondition* condition) { left->RemoveEnvironmentUsers(); // We have decided to fold the HCompare into the HCondition. Transfer the information. - // TODO: Remove "OrNull". - condition->SetBias(left->AsCompareOrNull()->GetBias()); + condition->SetBias(left->AsCompare()->GetBias()); // Replace the operands of the HCondition. condition->ReplaceInput(left->InputAt(0), 0); @@ -1897,15 +1840,13 @@ void InstructionSimplifierVisitor::VisitDiv(HDiv* instruction) { // MUL dst, src, 1 / constant HConstant* reciprocal = nullptr; if (type == DataType::Type::kFloat64) { - // TODO: Remove "OrNull". - double value = input_cst->AsDoubleConstantOrNull()->GetValue(); + double value = input_cst->AsDoubleConstant()->GetValue(); if (CanDivideByReciprocalMultiplyDouble(bit_cast(value))) { reciprocal = GetGraph()->GetDoubleConstant(1.0 / value); } } else { DCHECK_EQ(type, DataType::Type::kFloat32); - // TODO: Remove "OrNull". - float value = input_cst->AsFloatConstantOrNull()->GetValue(); + float value = input_cst->AsFloatConstant()->GetValue(); if (CanDivideByReciprocalMultiplyFloat(bit_cast(value))) { reciprocal = GetGraph()->GetFloatConstant(1.0f / value); } @@ -1932,8 +1873,7 @@ static HDiv* FindDivWithInputsInBasicBlock(HInstruction* dividend, user->IsDiv() && user->InputAt(0) == dividend && user->InputAt(1) == divisor) { - // TODO: Remove "OrNull". - return user->AsDivOrNull(); + return user->AsDiv(); } } return nullptr; @@ -2023,10 +1963,9 @@ void InstructionSimplifierVisitor::VisitMul(HMul* instruction) { return; } - // TODO: Remove "OrNull". if (DataType::IsFloatingPointType(type) && - ((input_cst->IsFloatConstant() && input_cst->AsFloatConstantOrNull()->GetValue() == 2.0f) || - (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstantOrNull()->GetValue() == 2.0))) { + ((input_cst->IsFloatConstant() && input_cst->AsFloatConstant()->GetValue() == 2.0f) || + (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstant()->GetValue() == 2.0))) { // Replace code looking like // FP_MUL dst, src, 2.0 // with @@ -2107,8 +2046,7 @@ void InstructionSimplifierVisitor::VisitNeg(HNeg* instruction) { // NEG dst, tmp // with // src - // TODO: Remove "OrNull". - HNeg* previous_neg = input->AsNegOrNull(); + HNeg* previous_neg = input->AsNeg(); instruction->ReplaceWith(previous_neg->GetInput()); instruction->GetBlock()->RemoveInstruction(instruction); // We perform the optimization even if the input negation has environment @@ -2134,8 +2072,7 @@ void InstructionSimplifierVisitor::VisitNeg(HNeg* instruction) { // to be extended if we are not sure the initial 'SUB' instruction can be // removed. // We do not perform optimization for fp because we could lose the sign of zero. - // TODO: Remove "OrNull". - HSub* sub = input->AsSubOrNull(); + HSub* sub = input->AsSub(); HSub* new_sub = new (GetGraph()->GetAllocator()) HSub( instruction->GetType(), sub->GetRight(), sub->GetLeft()); instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, new_sub); @@ -2157,8 +2094,7 @@ void InstructionSimplifierVisitor::VisitNot(HNot* instruction) { // We perform the optimization even if the input negation has environment // uses since it allows removing the current instruction. But we only delete // the input negation only if it is does not have any uses left. - // TODO: Remove "OrNull". - HNot* previous_not = input->AsNotOrNull(); + HNot* previous_not = input->AsNot(); instruction->ReplaceWith(previous_not->GetInput()); instruction->GetBlock()->RemoveInstruction(instruction); if (!previous_not->HasUses()) { @@ -2245,8 +2181,7 @@ void InstructionSimplifierVisitor::VisitSub(HSub* instruction) { HInstruction* left = instruction->GetLeft(); HInstruction* right = instruction->GetRight(); if (left->IsConstant()) { - // TODO: Remove "OrNull". - if (Int64FromConstant(left->AsConstantOrNull()) == 0) { + if (Int64FromConstant(left->AsConstant()) == 0) { // Replace code looking like // SUB dst, 0, src // with @@ -2273,8 +2208,7 @@ void InstructionSimplifierVisitor::VisitSub(HSub* instruction) { // SUB dst, a, tmp // with // ADD dst, a, b - // TODO: Remove "OrNull". - HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left, right->AsNegOrNull()->GetInput()); + HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left, right->AsNeg()->GetInput()); instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, add); RecordSimplification(); right->GetBlock()->RemoveInstruction(right); @@ -2290,8 +2224,7 @@ void InstructionSimplifierVisitor::VisitSub(HSub* instruction) { // NEG dst, tmp // The second version is not intrinsically better, but enables more // transformations. - // TODO: Remove "OrNull". - HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left->AsNegOrNull()->GetInput(), right); + HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left->AsNeg()->GetInput(), right); instruction->GetBlock()->InsertInstructionBefore(add, instruction); HNeg* neg = new (GetGraph()->GetAllocator()) HNeg(instruction->GetType(), add); instruction->GetBlock()->InsertInstructionBefore(neg, instruction); @@ -2431,8 +2364,7 @@ static bool IsArrayLengthOf(HInstruction* potential_length, HInstruction* potent } if (potential_array->IsNewArray()) { - // TODO: Remove "OrNull". - return potential_array->AsNewArrayOrNull()->GetLength() == potential_length; + return potential_array->AsNewArray()->GetLength() == potential_length; } return false; @@ -2499,8 +2431,7 @@ void InstructionSimplifierVisitor::SimplifySystemArrayCopy(HInvoke* instruction) (source_component_type == destination_component_type)) { ClassLinker* class_linker = Runtime::Current()->GetClassLinker(); PointerSize image_size = class_linker->GetImagePointerSize(); - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirectOrNull(); + HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirect(); ObjPtr system = invoke->GetResolvedMethod()->GetDeclaringClass(); ArtMethod* method = nullptr; switch (source_component_type) { @@ -2616,8 +2547,7 @@ void InstructionSimplifierVisitor::SimplifyStringIndexOf(HInvoke* invoke) { DCHECK(invoke->GetIntrinsic() == Intrinsics::kStringIndexOf || invoke->GetIntrinsic() == Intrinsics::kStringIndexOfAfter); if (invoke->InputAt(0)->IsLoadString()) { - // TODO: Remove "OrNull". - HLoadString* load_string = invoke->InputAt(0)->AsLoadStringOrNull(); + HLoadString* load_string = invoke->InputAt(0)->AsLoadString(); const DexFile& dex_file = load_string->GetDexFile(); uint32_t utf16_length; const char* data = @@ -2673,13 +2603,11 @@ void InstructionSimplifierVisitor::SimplifyReturnThis(HInvoke* invoke) { static bool NoEscapeForStringBufferReference(HInstruction* reference, HInstruction* user) { if (user->IsInvokeStaticOrDirect()) { // Any constructor on StringBuffer is okay. - // TODO: Remove "OrNull". - return user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod() != nullptr && - user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod()->IsConstructor() && + return user->AsInvokeStaticOrDirect()->GetResolvedMethod() != nullptr && + user->AsInvokeStaticOrDirect()->GetResolvedMethod()->IsConstructor() && user->InputAt(0) == reference; } else if (user->IsInvokeVirtual()) { - // TODO: Remove "OrNull". - switch (user->AsInvokeVirtualOrNull()->GetIntrinsic()) { + switch (user->AsInvokeVirtual()->GetIntrinsic()) { case Intrinsics::kStringBufferLength: case Intrinsics::kStringBufferToString: DCHECK_EQ(user->InputAt(0), reference); @@ -2750,8 +2678,7 @@ static bool TryReplaceStringBuilderAppend(HInvoke* invoke) { } // Then we should see the arguments. if (user->IsInvokeVirtual()) { - // TODO: Remove "OrNull". - HInvokeVirtual* as_invoke_virtual = user->AsInvokeVirtualOrNull(); + HInvokeVirtual* as_invoke_virtual = user->AsInvokeVirtual(); DCHECK(!seen_constructor); DCHECK(!seen_constructor_fence); StringBuilderAppend::Argument arg; @@ -2787,8 +2714,7 @@ static bool TryReplaceStringBuilderAppend(HInvoke* invoke) { has_fp_args = true; break; case Intrinsics::kStringBuilderAppendCharSequence: { - // TODO: Remove "OrNull". - ReferenceTypeInfo rti = user->AsInvokeVirtualOrNull()->InputAt(1)->GetReferenceTypeInfo(); + ReferenceTypeInfo rti = user->AsInvokeVirtual()->InputAt(1)->GetReferenceTypeInfo(); if (!rti.IsValid()) { return false; } @@ -2820,12 +2746,9 @@ static bool TryReplaceStringBuilderAppend(HInvoke* invoke) { args[num_args] = as_invoke_virtual->InputAt(1u); ++num_args; } else if (user->IsInvokeStaticOrDirect() && - // TODO: Remove "OrNull". - user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod() != nullptr && - // TODO: Remove "OrNull". - user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod()->IsConstructor() && - // TODO: Remove "OrNull". - user->AsInvokeStaticOrDirectOrNull()->GetNumberOfArguments() == 1u) { + user->AsInvokeStaticOrDirect()->GetResolvedMethod() != nullptr && + user->AsInvokeStaticOrDirect()->GetResolvedMethod()->IsConstructor() && + user->AsInvokeStaticOrDirect()->GetNumberOfArguments() == 1u) { // After arguments, we should see the constructor. // We accept only the constructor with no extra arguments. DCHECK(!seen_constructor); @@ -2964,8 +2887,7 @@ bool InstructionSimplifierVisitor::CanUseKnownBootImageVarHandle(HInvoke* invoke if (!var_handle_instruction->IsStaticFieldGet()) { return false; } - // TODO: Remove "OrNull". - ArtField* field = var_handle_instruction->AsStaticFieldGetOrNull()->GetFieldInfo().GetField(); + ArtField* field = var_handle_instruction->AsStaticFieldGet()->GetFieldInfo().GetField(); DCHECK(field->IsStatic()); if (!field->IsFinal()) { return false; @@ -2988,11 +2910,9 @@ bool InstructionSimplifierVisitor::CanUseKnownBootImageVarHandle(HInvoke* invoke is_in_boot_image = compiler_options.IsImageClass(descriptor); } CHECK_EQ(is_in_boot_image, - // TODO: Remove "OrNull". - load_class->IsLoadClass() && load_class->AsLoadClassOrNull()->IsInBootImage()); + load_class->IsLoadClass() && load_class->AsLoadClass()->IsInBootImage()); } - // TODO: Remove "OrNull". - if (!load_class->IsLoadClass() || !load_class->AsLoadClassOrNull()->IsInBootImage()) { + if (!load_class->IsLoadClass() || !load_class->AsLoadClass()->IsInBootImage()) { return false; } @@ -3188,8 +3108,7 @@ void InstructionSimplifierVisitor::VisitInvoke(HInvoke* instruction) { void InstructionSimplifierVisitor::VisitDeoptimize(HDeoptimize* deoptimize) { HInstruction* cond = deoptimize->InputAt(0); if (cond->IsConstant()) { - // TODO: Remove "OrNull". - if (cond->AsIntConstantOrNull()->IsFalse()) { + if (cond->AsIntConstant()->IsFalse()) { // Never deopt: instruction can be removed. if (deoptimize->GuardsAnInput()) { deoptimize->ReplaceWith(deoptimize->GuardedInput()); @@ -3222,15 +3141,11 @@ bool InstructionSimplifierVisitor::TryHandleAssociativeAndCommutativeOperation( HBinaryOperation* y; if (instruction->GetKind() == left->GetKind() && right->IsConstant()) { - // TODO: Remove "OrNull". - const2 = right->AsConstantOrNull(); - // TODO: Remove "OrNull". - y = left->AsBinaryOperationOrNull(); + const2 = right->AsConstant(); + y = left->AsBinaryOperation(); } else if (left->IsConstant() && instruction->GetKind() == right->GetKind()) { - // TODO: Remove "OrNull". - const2 = left->AsConstantOrNull(); - // TODO: Remove "OrNull". - y = right->AsBinaryOperationOrNull(); + const2 = left->AsConstant(); + y = right->AsBinaryOperation(); } else { // The node does not match the pattern. return false; @@ -3261,8 +3176,7 @@ bool InstructionSimplifierVisitor::TryHandleAssociativeAndCommutativeOperation( } static HBinaryOperation* AsAddOrSub(HInstruction* binop) { - // TODO: Remove "OrNull". - return (binop->IsAdd() || binop->IsSub()) ? binop->AsBinaryOperationOrNull() : nullptr; + return (binop->IsAdd() || binop->IsSub()) ? binop->AsBinaryOperation() : nullptr; } // Helper function that performs addition statically, considering the result type. @@ -3301,15 +3215,13 @@ bool InstructionSimplifierVisitor::TrySubtractionChainSimplification( HInstruction* left = instruction->GetLeft(); HInstruction* right = instruction->GetRight(); // Variable names as described above. - // TODO: Remove first "OrNull", keep the second. - HConstant* const2 = right->IsConstant() ? right->AsConstantOrNull() : left->AsConstantOrNull(); + HConstant* const2 = right->IsConstant() ? right->AsConstant() : left->AsConstantOrNull(); if (const2 == nullptr) { return false; } HBinaryOperation* y = (AsAddOrSub(left) != nullptr) - // TODO: Remove "OrNull". - ? left->AsBinaryOperationOrNull() + ? left->AsBinaryOperation() : AsAddOrSub(right); // If y has more than one use, we do not perform the optimization because // it might increase code size (e.g. if the new constant is no longer @@ -3319,9 +3231,7 @@ bool InstructionSimplifierVisitor::TrySubtractionChainSimplification( } left = y->GetLeft(); - // TODO: Remove first "OrNull", keep the second. - HConstant* const1 = - left->IsConstant() ? left->AsConstantOrNull() : y->GetRight()->AsConstantOrNull(); + HConstant* const1 = left->IsConstant() ? left->AsConstant() : y->GetRight()->AsConstantOrNull(); if (const1 == nullptr) { return false; } diff --git a/compiler/optimizing/instruction_simplifier_arm.cc b/compiler/optimizing/instruction_simplifier_arm.cc index 1aeb63867a..05a518d544 100644 --- a/compiler/optimizing/instruction_simplifier_arm.cc +++ b/compiler/optimizing/instruction_simplifier_arm.cc @@ -105,8 +105,7 @@ bool InstructionSimplifierArmVisitor::TryMergeIntoShifterOperand(HInstruction* u return false; } - // TODO: Remove "OrNull". - bool is_commutative = use->AsBinaryOperationOrNull()->IsCommutative(); + bool is_commutative = use->AsBinaryOperation()->IsCommutative(); HInstruction* other_input; if (bitfield_op == right) { other_input = left; diff --git a/compiler/optimizing/instruction_simplifier_arm64.cc b/compiler/optimizing/instruction_simplifier_arm64.cc index a4e558b42d..671900bd9d 100644 --- a/compiler/optimizing/instruction_simplifier_arm64.cc +++ b/compiler/optimizing/instruction_simplifier_arm64.cc @@ -107,8 +107,7 @@ bool InstructionSimplifierArm64Visitor::TryMergeIntoShifterOperand(HInstruction* right = use->InputAt(1); } else { DCHECK(use->IsNeg()); - // TODO: Remove "OrNull". - right = use->AsNegOrNull()->InputAt(0); + right = use->AsNeg()->InputAt(0); left = GetGraph()->GetConstant(right->GetType(), 0); } DCHECK(left == bitfield_op || right == bitfield_op); @@ -120,8 +119,7 @@ bool InstructionSimplifierArm64Visitor::TryMergeIntoShifterOperand(HInstruction* return false; } - // TODO: Remove "OrNull". - bool is_commutative = use->IsBinaryOperation() && use->AsBinaryOperationOrNull()->IsCommutative(); + bool is_commutative = use->IsBinaryOperation() && use->AsBinaryOperation()->IsCommutative(); HInstruction* other_input; if (bitfield_op == right) { other_input = left; diff --git a/compiler/optimizing/instruction_simplifier_shared.cc b/compiler/optimizing/instruction_simplifier_shared.cc index 3357e53737..34daae21ee 100644 --- a/compiler/optimizing/instruction_simplifier_shared.cc +++ b/compiler/optimizing/instruction_simplifier_shared.cc @@ -52,8 +52,7 @@ bool TrySimpleMultiplyAccumulatePatterns(HMul* mul, } else { DCHECK(input_binop->IsSub()); if (input_binop->GetRight()->IsConstant() && - // TODO: Remove "OrNull". - input_binop->GetRight()->AsConstantOrNull()->IsMinusOne()) { + input_binop->GetRight()->AsConstant()->IsMinusOne()) { // Interpret // a * (b - (-1)) // as @@ -61,8 +60,7 @@ bool TrySimpleMultiplyAccumulatePatterns(HMul* mul, input_b = input_binop->GetLeft(); op_kind = HInstruction::kAdd; } else if (input_binop->GetLeft()->IsConstant() && - // TODO: Remove "OrNull". - input_binop->GetLeft()->AsConstantOrNull()->IsOne()) { + input_binop->GetLeft()->AsConstant()->IsOne()) { // Interpret // a * (1 - b) // as @@ -124,8 +122,7 @@ bool TryCombineMultiplyAccumulate(HMul* mul, InstructionSet isa) { // whether all uses are on different control-flow paths (using dominance and // reverse-dominance information) and only perform the merge when they are. HInstruction* accumulator = nullptr; - // TODO: Remove "OrNull". - HBinaryOperation* binop = use->AsBinaryOperationOrNull(); + HBinaryOperation* binop = use->AsBinaryOperation(); HInstruction* binop_left = binop->GetLeft(); HInstruction* binop_right = binop->GetRight(); // Be careful after GVN. This should not happen since the `HMul` has only @@ -178,13 +175,11 @@ bool TryCombineMultiplyAccumulate(HMul* mul, InstructionSet isa) { HInstruction* left = mul->GetLeft(); HInstruction* right = mul->GetRight(); if ((right->IsAdd() || right->IsSub()) && - // TODO: Remove "OrNull". - TrySimpleMultiplyAccumulatePatterns(mul, right->AsBinaryOperationOrNull(), left)) { + TrySimpleMultiplyAccumulatePatterns(mul, right->AsBinaryOperation(), left)) { return true; } if ((left->IsAdd() || left->IsSub()) && - // TODO: Remove "OrNull". - TrySimpleMultiplyAccumulatePatterns(mul, left->AsBinaryOperationOrNull(), right)) { + TrySimpleMultiplyAccumulatePatterns(mul, left->AsBinaryOperation(), right)) { return true; } return false; @@ -219,8 +214,7 @@ bool TryMergeNegatedInput(HBinaryOperation* op) { // AND dst, src, tmp (respectively ORR, EOR) // with // BIC dst, src, mask (respectively ORN, EON) - // TODO: Remove "OrNull". - HInstruction* src = hnot->AsNotOrNull()->GetInput(); + HInstruction* src = hnot->AsNot()->GetInput(); HBitwiseNegatedRight* neg_op = new (hnot->GetBlock()->GetGraph()->GetAllocator()) HBitwiseNegatedRight(op->GetType(), op->GetKind(), hother, src, op->GetDexPc()); @@ -240,15 +234,13 @@ bool TryExtractArrayAccessAddress(HInstruction* access, HInstruction* index, size_t data_offset) { if (index->IsConstant() || - // TODO: Remove "OrNull". - (index->IsBoundsCheck() && index->AsBoundsCheckOrNull()->GetIndex()->IsConstant())) { + (index->IsBoundsCheck() && index->AsBoundsCheck()->GetIndex()->IsConstant())) { // When the index is a constant all the addressing can be fitted in the // memory access instruction, so do not split the access. return false; } if (access->IsArraySet() && - // TODO: Remove "OrNull". - access->AsArraySetOrNull()->GetValue()->GetType() == DataType::Type::kReference) { + access->AsArraySet()->GetValue()->GetType() == DataType::Type::kReference) { // The access may require a runtime call or the original array pointer. return false; } @@ -308,8 +300,7 @@ bool TryExtractVecArrayAccessAddress(HVecMemoryOperation* access, HInstruction* for (const HUseListNode& use : index->GetUses()) { HInstruction* user = use.GetUser(); if (user->IsVecMemoryOperation() && user != access) { - // TODO: Remove "OrNull". - HVecMemoryOperation* another_access = user->AsVecMemoryOperationOrNull(); + HVecMemoryOperation* another_access = user->AsVecMemoryOperation(); DataType::Type another_packed_type = another_access->GetPackedType(); uint32_t another_data_offset = mirror::Array::DataOffset( DataType::Size(another_packed_type)).Uint32Value(); @@ -319,13 +310,9 @@ bool TryExtractVecArrayAccessAddress(HVecMemoryOperation* access, HInstruction* break; } } else if (user->IsIntermediateAddressIndex()) { - // TODO: Remove "OrNull". - HIntermediateAddressIndex* another_access = user->AsIntermediateAddressIndexOrNull(); - // TODO: Remove "OrNull". - uint32_t another_data_offset = another_access->GetOffset()->AsIntConstantOrNull()->GetValue(); - // TODO: Remove "OrNull". - size_t another_component_shift = - another_access->GetShift()->AsIntConstantOrNull()->GetValue(); + HIntermediateAddressIndex* another_access = user->AsIntermediateAddressIndex(); + uint32_t another_data_offset = another_access->GetOffset()->AsIntConstant()->GetValue(); + size_t another_component_shift = another_access->GetShift()->AsIntConstant()->GetValue(); if (another_data_offset == data_offset && another_component_shift == component_shift) { is_extracting_beneficial = true; break; diff --git a/compiler/optimizing/instruction_simplifier_shared.h b/compiler/optimizing/instruction_simplifier_shared.h index fe9d429984..01489f8bcb 100644 --- a/compiler/optimizing/instruction_simplifier_shared.h +++ b/compiler/optimizing/instruction_simplifier_shared.h @@ -26,18 +26,16 @@ namespace helpers { inline bool CanFitInShifterOperand(HInstruction* instruction) { if (instruction->IsTypeConversion()) { - // TODO: Remove "OrNull". - HTypeConversion* conversion = instruction->AsTypeConversionOrNull(); + HTypeConversion* conversion = instruction->AsTypeConversion(); DataType::Type result_type = conversion->GetResultType(); DataType::Type input_type = conversion->GetInputType(); // We don't expect to see the same type as input and result. return DataType::IsIntegralType(result_type) && DataType::IsIntegralType(input_type) && (result_type != input_type); } else { - // TODO: Remove "OrNull". - return (instruction->IsShl() && instruction->AsShlOrNull()->InputAt(1)->IsIntConstant()) || - (instruction->IsShr() && instruction->AsShrOrNull()->InputAt(1)->IsIntConstant()) || - (instruction->IsUShr() && instruction->AsUShrOrNull()->InputAt(1)->IsIntConstant()); + return (instruction->IsShl() && instruction->AsShl()->InputAt(1)->IsIntConstant()) || + (instruction->IsShr() && instruction->AsShr()->InputAt(1)->IsIntConstant()) || + (instruction->IsUShr() && instruction->AsUShr()->InputAt(1)->IsIntConstant()); } } @@ -56,8 +54,7 @@ inline bool HasShifterOperand(HInstruction* instr, InstructionSet isa) { // t3 = Sub(*, t2) inline bool IsSubRightSubLeftShl(HSub *sub) { HInstruction* right = sub->GetRight(); - // TODO: Remove "OrNull". - return right->IsSub() && right->AsSubOrNull()->GetLeft()->IsShl(); + return right->IsSub() && right->AsSub()->GetLeft()->IsShl(); } } // namespace helpers diff --git a/compiler/optimizing/instruction_simplifier_x86_shared.cc b/compiler/optimizing/instruction_simplifier_x86_shared.cc index 39ae39e27e..74c5ca2466 100644 --- a/compiler/optimizing/instruction_simplifier_x86_shared.cc +++ b/compiler/optimizing/instruction_simplifier_x86_shared.cc @@ -37,8 +37,7 @@ bool TryCombineAndNot(HAnd* instruction) { if (left->IsNot() ^ right->IsNot()) { bool left_is_not = left->IsNot(); HInstruction* other_ins = (left_is_not ? right : left); - // TODO: Remove "OrNull". - HNot* not_ins = (left_is_not ? left : right)->AsNotOrNull(); + HNot* not_ins = (left_is_not ? left : right)->AsNot(); // Only do the simplification if instruction has only one use // and thus can be safely removed. if (not_ins->HasOnlyOneNonEnvironmentUse()) { @@ -124,14 +123,12 @@ bool TryGenerateMaskUptoLeastSetBit(HXor* instruction) { bool AreLeastSetBitInputs(HInstruction* to_test, HInstruction* other) { if (to_test->IsAdd()) { - // TODO: Remove "OrNull". - HAdd* add = to_test->AsAddOrNull(); + HAdd* add = to_test->AsAdd(); HConstant* cst = add->GetConstantRight(); return cst != nullptr && cst->IsMinusOne() && other == add->GetLeastConstantLeft(); } if (to_test->IsSub()) { - // TODO: Remove "OrNull". - HSub* sub = to_test->AsSubOrNull(); + HSub* sub = to_test->AsSub(); HConstant* cst = sub->GetConstantRight(); return cst != nullptr && cst->IsOne() && other == sub->GetLeastConstantLeft(); } diff --git a/compiler/optimizing/intrinsics.cc b/compiler/optimizing/intrinsics.cc index f832d9c8bf..774deec438 100644 --- a/compiler/optimizing/intrinsics.cc +++ b/compiler/optimizing/intrinsics.cc @@ -151,8 +151,7 @@ static bool CanReferenceBootImageObjects(HInvoke* invoke, const CompilerOptions& // for AOT. This should cover both the testing config (non-PIC boot image) and codegens that // reject PC-relative load kinds and fall back to the runtime call. if (compiler_options.IsAotCompiler() && - // TODO: Remove "OrNull". - !invoke->AsInvokeStaticOrDirectOrNull()->HasPcRelativeMethodLoadKind()) { + !invoke->AsInvokeStaticOrDirect()->HasPcRelativeMethodLoadKind()) { return false; } if (!compiler_options.IsBootImage() && @@ -210,8 +209,7 @@ void IntrinsicVisitor::ComputeIntegerValueOfLocations(HInvoke* invoke, } } if (input->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t value = input->AsIntConstantOrNull()->GetValue(); + int32_t value = input->AsIntConstant()->GetValue(); if (static_cast(value) - static_cast(low) < static_cast(high - low + 1)) { // No call, we shall use direct pointer to the Integer object. @@ -236,8 +234,7 @@ void IntrinsicVisitor::ComputeIntegerValueOfLocations(HInvoke* invoke, DCHECK(compiler_options.IsAotCompiler()); DCHECK(CheckIntegerCache(self, runtime->GetClassLinker(), boot_image_live_objects, cache)); if (input->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t value = input->AsIntConstantOrNull()->GetValue(); + int32_t value = input->AsIntConstant()->GetValue(); // Retrieve the `value` from the lowest cached Integer. ObjPtr low_integer = IntrinsicObjects::GetIntegerValueOfObject(boot_image_live_objects, 0u); @@ -311,8 +308,7 @@ IntrinsicVisitor::IntegerValueOfInfo IntrinsicVisitor::ComputeIntegerValueOfInfo info.length = dchecked_integral_cast(high - info.low + 1); if (invoke->InputAt(0)->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t input_value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue(); + int32_t input_value = invoke->InputAt(0)->AsIntConstant()->GetValue(); uint32_t index = static_cast(input_value) - static_cast(info.low); if (index < static_cast(info.length)) { info.value_boot_image_reference = IntrinsicObjects::EncodePatch( @@ -347,8 +343,7 @@ IntrinsicVisitor::IntegerValueOfInfo IntrinsicVisitor::ComputeIntegerValueOfInfo IntrinsicObjects::GetIntegerValueOfCache(boot_image_live_objects)->GetLength()); if (invoke->InputAt(0)->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t input_value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue(); + int32_t input_value = invoke->InputAt(0)->AsIntConstant()->GetValue(); uint32_t index = static_cast(input_value) - static_cast(info.low); if (index < static_cast(info.length)) { ObjPtr integer = diff --git a/compiler/optimizing/intrinsics.h b/compiler/optimizing/intrinsics.h index 017c3d123b..893cd04411 100644 --- a/compiler/optimizing/intrinsics.h +++ b/compiler/optimizing/intrinsics.h @@ -71,8 +71,7 @@ class IntrinsicVisitor : public ValueObject { CodeGenerator* codegen, InvokeDexCallingConventionVisitor* calling_convention_visitor) { if (kIsDebugBuild && invoke->IsInvokeStaticOrDirect()) { - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirectOrNull(); + HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirect(); // Explicit clinit checks triggered by static invokes must have been // pruned by art::PrepareForRegisterAllocation. DCHECK(!invoke_static_or_direct->IsStaticWithExplicitClinitCheck()); diff --git a/compiler/optimizing/intrinsics_arm64.cc b/compiler/optimizing/intrinsics_arm64.cc index 01138ff9d9..c6df9e2e4d 100644 --- a/compiler/optimizing/intrinsics_arm64.cc +++ b/compiler/optimizing/intrinsics_arm64.cc @@ -103,8 +103,7 @@ class ReadBarrierSystemArrayCopySlowPathARM64 : public SlowPathCodeARM64 { << "Unexpected instruction in read barrier arraycopy slow path: " << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); + DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); const int32_t element_size = DataType::Size(DataType::Type::kReference); @@ -1898,8 +1897,7 @@ constexpr size_t kShortConstStringEqualsCutoffInBytes = 32; static const char* GetConstString(HInstruction* candidate, uint32_t* utf16_length) { if (candidate->IsLoadString()) { - // TODO: Remove "OrNull". - HLoadString* load_string = candidate->AsLoadStringOrNull(); + HLoadString* load_string = candidate->AsLoadString(); const DexFile& dex_file = load_string->GetDexFile(); return dex_file.StringDataAndUtf16LengthByIdx(load_string->GetStringIndex(), utf16_length); } @@ -2109,8 +2107,7 @@ static void GenerateVisitStringIndexOf(HInvoke* invoke, SlowPathCodeARM64* slow_path = nullptr; HInstruction* code_point = invoke->InputAt(1); if (code_point->IsIntConstant()) { - // TODO: Remove "OrNull". - if (static_cast(code_point->AsIntConstantOrNull()->GetValue()) > 0xFFFFU) { + if (static_cast(code_point->AsIntConstant()->GetValue()) > 0xFFFFU) { // Always needs the slow-path. We could directly dispatch to it, but this case should be // rare, so for simplicity just put the full slow-path down and branch unconditionally. slow_path = new (codegen->GetScopedAllocator()) IntrinsicSlowPathARM64(invoke); @@ -2641,8 +2638,7 @@ static void CheckSystemArrayCopyPosition(MacroAssembler* masm, bool length_is_input_length = false) { const int32_t length_offset = mirror::Array::LengthOffset().Int32Value(); if (pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue(); if (pos_const == 0) { if (!length_is_input_length) { // Check that length(input) >= length. @@ -2698,8 +2694,7 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm, const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value(); if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue(); __ Add(src_base, src, element_size * constant + data_offset); } else { __ Add(src_base, src, data_offset); @@ -2707,8 +2702,7 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm, } if (dst_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = dst_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = dst_pos.GetConstant()->AsIntConstant()->GetValue(); __ Add(dst_base, dst, element_size * constant + data_offset); } else { __ Add(dst_base, dst, data_offset); @@ -2717,8 +2711,7 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm, if (src_end.IsValid()) { if (copy_length.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue(); __ Add(src_end, src_base, element_size * constant); } else { __ Add(src_end, src_base, Operand(XRegisterFrom(copy_length), LSL, element_size_shift)); @@ -2759,11 +2752,8 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopyChar(HInvoke* invoke) { __ B(slow_path->GetEntryLabel(), hi); } else { // We have already checked in the LocationsBuilder for the constant case. - // TODO: Remove "OrNull". - DCHECK_GE(length.GetConstant()->AsIntConstantOrNull()->GetValue(), 0); - // TODO: Remove "OrNull". - DCHECK_LE(length.GetConstant()->AsIntConstantOrNull()->GetValue(), - kSystemArrayCopyCharThreshold); + DCHECK_GE(length.GetConstant()->AsIntConstant()->GetValue(), 0); + DCHECK_LE(length.GetConstant()->AsIntConstant()->GetValue(), kSystemArrayCopyCharThreshold); } Register src_curr_addr = WRegisterFrom(locations->GetTemp(0)); @@ -2867,8 +2857,7 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopyChar(HInvoke* invoke) { }; if (length.IsConstant()) { - // TODO: Remove "OrNull". - const int32_t constant_length = length.GetConstant()->AsIntConstantOrNull()->GetValue(); + const int32_t constant_length = length.GetConstant()->AsIntConstant()->GetValue(); if (constant_length >= unroll_threshold) { __ Mov(length_tmp, constant_length - chars_per_block); emitHeadLoop(); @@ -3009,11 +2998,9 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) { // If source and destination are the same, we go to slow path if we need to do // forward copying. if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue(); if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue(); if (optimizations.GetDestinationIsSource()) { // Checked when building locations. DCHECK_GE(src_pos_constant, dest_pos_constant); @@ -3023,8 +3010,7 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) { } // Checked when building locations. DCHECK(!optimizations.GetDestinationIsSource() || - // TODO: Remove "OrNull". - (src_pos_constant >= dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue())); + (src_pos_constant >= dest_pos.GetConstant()->AsIntConstant()->GetValue())); } else { if (!optimizations.GetDestinationIsSource()) { __ Cmp(src, dest); @@ -3297,8 +3283,7 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) { __ Cbnz(temp2, intrinsic_slow_path->GetEntryLabel()); } - // TODO: Remove "OrNull". - if (length.IsConstant() && length.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) { + if (length.IsConstant() && length.GetConstant()->AsIntConstant()->GetValue() == 0) { // Null constant length: not need to emit the loop code at all. } else { Register src_curr_addr = temp1.X(); @@ -3505,8 +3490,7 @@ void IntrinsicCodeGeneratorARM64::VisitIntegerValueOf(HInvoke* invoke) { CheckEntrypointTypes(); }; if (invoke->InputAt(0)->IsConstant()) { - // TODO: Remove "OrNull". - int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue(); + int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue(); if (static_cast(value - info.low) < info.length) { // Just embed the j.l.Integer in the code. DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference); @@ -3881,8 +3865,7 @@ void IntrinsicCodeGeneratorARM64::VisitCRC32UpdateBytes(HInvoke* invoke) { Register array = XRegisterFrom(locations->InAt(1)); Location offset = locations->InAt(2); if (offset.IsConstant()) { - // TODO: Remove "OrNull". - int32_t offset_value = offset.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t offset_value = offset.GetConstant()->AsIntConstant()->GetValue(); __ Add(ptr, array, array_data_offset + offset_value); } else { __ Add(ptr, array, array_data_offset); @@ -4379,8 +4362,7 @@ class VarHandleSlowPathARM64 : public IntrinsicSlowPathARM64 { private: HInvoke* GetInvoke() const { - // TODO: Remove "OrNull". - return GetInstruction()->AsInvokeOrNull(); + return GetInstruction()->AsInvoke(); } mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const { diff --git a/compiler/optimizing/intrinsics_arm_vixl.cc b/compiler/optimizing/intrinsics_arm_vixl.cc index c99e9122ce..ab742bb10b 100644 --- a/compiler/optimizing/intrinsics_arm_vixl.cc +++ b/compiler/optimizing/intrinsics_arm_vixl.cc @@ -133,8 +133,7 @@ class ReadBarrierSystemArrayCopySlowPathARMVIXL : public SlowPathCodeARMVIXL { << "Unexpected instruction in read barrier arraycopy slow path: " << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); + DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); DataType::Type type = DataType::Type::kReference; const int32_t element_size = DataType::Size(type); @@ -883,8 +882,7 @@ constexpr size_t kShortConstStringEqualsCutoffInBytes = 16; static const char* GetConstString(HInstruction* candidate, uint32_t* utf16_length) { if (candidate->IsLoadString()) { - // TODO: Remove "OrNull". - HLoadString* load_string = candidate->AsLoadStringOrNull(); + HLoadString* load_string = candidate->AsLoadString(); const DexFile& dex_file = load_string->GetDexFile(); return dex_file.StringDataAndUtf16LengthByIdx(load_string->GetStringIndex(), utf16_length); } @@ -2460,8 +2458,7 @@ void IntrinsicCodeGeneratorARMVIXL::VisitIntegerValueOf(HInvoke* invoke) { CheckEntrypointTypes(); }; if (invoke->InputAt(0)->IsConstant()) { - // TODO: Remove "OrNull". - int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue(); + int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue(); if (static_cast(value - info.low) < info.length) { // Just embed the j.l.Integer in the code. DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference); @@ -3996,8 +3993,7 @@ class VarHandleSlowPathARMVIXL : public IntrinsicSlowPathARMVIXL { private: HInvoke* GetInvoke() const { - // TODO: Remove "OrNull". - return GetInstruction()->AsInvokeOrNull(); + return GetInstruction()->AsInvoke(); } mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const { 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 var_handle = field->GetObject(field->GetDeclaringClass()); DCHECK(var_handle->GetClass() == (GetExpectedVarHandleCoordinatesCount(invoke) == 0u diff --git a/compiler/optimizing/intrinsics_x86.cc b/compiler/optimizing/intrinsics_x86.cc index 8baa2a24e4..c16337985a 100644 --- a/compiler/optimizing/intrinsics_x86.cc +++ b/compiler/optimizing/intrinsics_x86.cc @@ -87,8 +87,7 @@ class ReadBarrierSystemArrayCopySlowPathX86 : public SlowPathCode { << "Unexpected instruction in read barrier arraycopy slow path: " << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); + DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); int32_t element_size = DataType::Size(DataType::Type::kReference); uint32_t offset = mirror::Array::DataOffset(element_size).Uint32Value(); @@ -120,8 +119,7 @@ class ReadBarrierSystemArrayCopySlowPathX86 : public SlowPathCode { __ Bind(&loop); // value = src_array[i + src_pos] if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue(); int32_t adjusted_offset = offset + constant * element_size; __ movl(temp2, Address(src, temp1, ScaleFactor::TIMES_4, adjusted_offset)); } else { @@ -144,8 +142,7 @@ class ReadBarrierSystemArrayCopySlowPathX86 : public SlowPathCode { __ MaybePoisonHeapReference(temp2); // dest_array[i + dest_pos] = value if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = dest_pos.GetConstant()->AsIntConstant()->GetValue(); int32_t adjusted_offset = offset + constant * element_size; __ movl(Address(dest, temp1, ScaleFactor::TIMES_4, adjusted_offset), temp2); } else { @@ -396,9 +393,7 @@ void IntrinsicLocationsBuilderX86::VisitMathRoundFloat(HInvoke* invoke) { return; } - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* static_or_direct = invoke->AsInvokeStaticOrDirectOrNull(); - DCHECK(static_or_direct != nullptr); + HInvokeStaticOrDirect* static_or_direct = invoke->AsInvokeStaticOrDirect(); LocationSummary* locations = new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified); locations->SetInAt(0, Location::RequiresFpuRegister()); @@ -433,9 +428,8 @@ void IntrinsicCodeGeneratorX86::VisitMathRoundFloat(HInvoke* invoke) { __ subss(t2, t1); if (locations->GetInputCount() == 2 && locations->InAt(1).IsValid()) { // Direct constant area available. - // TODO: Remove "OrNull". HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(1)->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(1)->AsX86ComputeBaseMethodAddress(); Register constant_area = locations->InAt(1).AsRegister(); __ comiss(t2, codegen_->LiteralInt32Address(bit_cast(0.5f), method_address, @@ -528,8 +522,7 @@ static void GenLowestOneBit(X86Assembler* assembler, if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); if (value == 0) { if (is_long) { __ xorl(out_loc.AsRegisterPairLow(), out_loc.AsRegisterPairLow()); @@ -839,15 +832,13 @@ static void CheckPosition(X86Assembler* assembler, const uint32_t length_offset = mirror::Array::LengthOffset().Uint32Value(); if (pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue(); if (pos_const == 0) { if (!length_is_input_length) { // Check that length(input) >= length. if (length.IsConstant()) { __ cmpl(Address(input, length_offset), - // TODO: Remove "OrNull". - Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ cmpl(Address(input, length_offset), length.AsRegister()); } @@ -861,8 +852,7 @@ static void CheckPosition(X86Assembler* assembler, // Check that (length(input) - pos) >= length. if (length.IsConstant()) { - // TODO: Remove "OrNull". - __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ cmpl(temp, length.AsRegister()); } @@ -887,8 +877,7 @@ static void CheckPosition(X86Assembler* assembler, __ movl(temp, Address(input, length_offset)); __ subl(temp, pos_reg); if (length.IsConstant()) { - // TODO: Remove "OrNull". - __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ cmpl(temp, length.AsRegister()); } @@ -939,8 +928,7 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke, // We need the count in ECX. if (length.IsConstant()) { - // TODO: Remove "OrNull". - __ movl(count, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + __ movl(count, Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ movl(count, length.AsRegister()); } @@ -958,15 +946,13 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke, const uint32_t data_offset = mirror::Array::DataOffset(data_size).Uint32Value(); if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t src_pos_const = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t src_pos_const = src_pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(src_base, Address(src, data_size * src_pos_const + data_offset)); } else { __ leal(src_base, Address(src, src_pos.AsRegister(), scale_factor, data_offset)); } if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(dest_base, Address(dest, data_size * dest_pos_const + data_offset)); } else { __ leal(dest_base, Address(dest, dest_pos.AsRegister(), scale_factor, data_offset)); @@ -1217,8 +1203,7 @@ static void GenerateStringIndexOf(HInvoke* invoke, SlowPathCode* slow_path = nullptr; HInstruction* code_point = invoke->InputAt(1); if (code_point->IsIntConstant()) { - // TODO: Remove "OrNull". - if (static_cast(code_point->AsIntConstantOrNull()->GetValue()) > + if (static_cast(code_point->AsIntConstant()->GetValue()) > std::numeric_limits::max()) { // Always needs the slow-path. We could directly dispatch to it, but this case should be // rare, so for simplicity just put the full slow-path down and branch unconditionally. @@ -1458,9 +1443,8 @@ void IntrinsicCodeGeneratorX86::VisitStringGetCharsNoCheck(HInvoke* invoke) { // public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin); Register obj = locations->InAt(0).AsRegister(); Location srcBegin = locations->InAt(1); - // TODO: Remove "OrNull". int srcBegin_value = - srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstantOrNull()->GetValue() : 0; + srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstant()->GetValue() : 0; Register srcEnd = locations->InAt(2).AsRegister(); Register dst = locations->InAt(3).AsRegister(); Register dstBegin = locations->InAt(4).AsRegister(); @@ -1613,8 +1597,7 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86Assemble case DataType::Type::kInt8: if (value_loc.IsConstant()) { __ movb(Address(address, 0), - // TODO: Remove "OrNull". - Immediate(value_loc.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(value_loc.GetConstant()->AsIntConstant()->GetValue())); } else { __ movb(Address(address, 0), value_loc.AsRegister()); } @@ -1622,8 +1605,7 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86Assemble case DataType::Type::kInt16: if (value_loc.IsConstant()) { __ movw(Address(address, 0), - // TODO: Remove "OrNull". - Immediate(value_loc.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(value_loc.GetConstant()->AsIntConstant()->GetValue())); } else { __ movw(Address(address, 0), value_loc.AsRegister()); } @@ -1631,16 +1613,14 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86Assemble case DataType::Type::kInt32: if (value_loc.IsConstant()) { __ movl(Address(address, 0), - // TODO: Remove "OrNull". - Immediate(value_loc.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(value_loc.GetConstant()->AsIntConstant()->GetValue())); } else { __ movl(Address(address, 0), value_loc.AsRegister()); } break; case DataType::Type::kInt64: if (value_loc.IsConstant()) { - // TODO: Remove "OrNull". - int64_t value = value_loc.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t value = value_loc.GetConstant()->AsLongConstant()->GetValue(); __ movl(Address(address, 0), Immediate(Low32Bits(value))); __ movl(Address(address, 4), Immediate(High32Bits(value))); } else { @@ -2570,8 +2550,7 @@ static void GenBitCount(X86Assembler* assembler, if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); int32_t result = is_long ? POPCOUNT(static_cast(value)) : POPCOUNT(static_cast(value)); @@ -2638,8 +2617,7 @@ static void GenLeadingZeros(X86Assembler* assembler, if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); if (value == 0) { value = is_long ? 64 : 32; } else { @@ -2743,8 +2721,7 @@ static void GenTrailingZeros(X86Assembler* assembler, if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); if (value == 0) { value = is_long ? 64 : 32; } else { @@ -2834,8 +2811,7 @@ static void GenSystemArrayCopyBaseAddress(X86Assembler* assembler, const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value(); if (pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(base, Address(array, element_size * constant + data_offset)); } else { __ leal(base, Address(array, pos.AsRegister(), scale_factor, data_offset)); @@ -2856,8 +2832,7 @@ static void GenSystemArrayCopyEndAddress(X86Assembler* assembler, const ScaleFactor scale_factor = static_cast(DataType::SizeShift(type)); if (copy_length.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue(); __ leal(end, Address(base, element_size * constant)); } else { __ leal(end, Address(base, copy_length.AsRegister(), scale_factor, 0)); @@ -2931,11 +2906,9 @@ void IntrinsicCodeGeneratorX86::VisitSystemArrayCopy(HInvoke* invoke) { // If source and destination are the same, we go to slow path if we need to do // forward copying. if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue(); if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue(); if (optimizations.GetDestinationIsSource()) { // Checked when building locations. DCHECK_GE(src_pos_constant, dest_pos_constant); @@ -2957,8 +2930,7 @@ void IntrinsicCodeGeneratorX86::VisitSystemArrayCopy(HInvoke* invoke) { __ j(kNotEqual, &conditions_on_positions_validated); } if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue(); __ cmpl(src_pos.AsRegister(), Immediate(dest_pos_constant)); __ j(kLess, intrinsic_slow_path->GetEntryLabel()); } else { @@ -3294,8 +3266,7 @@ void IntrinsicCodeGeneratorX86::VisitSystemArrayCopy(HInvoke* invoke) { static void RequestBaseMethodAddressInRegister(HInvoke* invoke) { LocationSummary* locations = invoke->GetLocations(); if (locations != nullptr) { - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirectOrNull(); + HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirect(); // Note: The base method address is not present yet when this is called from the // PCRelativeHandlerVisitor via IsCallFreeIntrinsic() to determine whether to insert it. if (invoke_static_or_direct->HasSpecialInput()) { @@ -3328,20 +3299,17 @@ void IntrinsicCodeGeneratorX86::VisitIntegerValueOf(HInvoke* invoke) { Register out = locations->Out().AsRegister(); auto allocate_instance = [&]() { DCHECK_EQ(out, InvokeRuntimeCallingConvention().GetRegisterAt(0)); - // TODO: Remove "OrNull". - codegen_->LoadIntrinsicDeclaringClass(out, invoke->AsInvokeStaticOrDirectOrNull()); + codegen_->LoadIntrinsicDeclaringClass(out, invoke->AsInvokeStaticOrDirect()); codegen_->InvokeRuntime(kQuickAllocObjectInitialized, invoke, invoke->GetDexPc()); CheckEntrypointTypes(); }; if (invoke->InputAt(0)->IsConstant()) { - // TODO: Remove "OrNull". - int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue(); + int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue(); if (static_cast(value - info.low) < info.length) { // Just embed the j.l.Integer in the code. DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference); codegen_->LoadBootImageAddress( - // TODO: Remove "OrNull". - out, info.value_boot_image_reference, invoke->AsInvokeStaticOrDirectOrNull()); + out, info.value_boot_image_reference, invoke->AsInvokeStaticOrDirect()); } else { DCHECK(locations->CanCall()); // Allocate and initialize a new j.l.Integer. @@ -3364,11 +3332,9 @@ void IntrinsicCodeGeneratorX86::VisitIntegerValueOf(HInvoke* invoke) { "Check heap reference size."); if (codegen_->GetCompilerOptions().IsBootImage()) { DCHECK_EQ(invoke->InputCount(), invoke->GetNumberOfArguments() + 1u); - // TODO: Remove "OrNull". - size_t method_address_index = invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex(); - // TODO: Remove "OrNull". + size_t method_address_index = invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex(); HX86ComputeBaseMethodAddress* method_address = - invoke->InputAt(method_address_index)->AsX86ComputeBaseMethodAddressOrNull(); + invoke->InputAt(method_address_index)->AsX86ComputeBaseMethodAddress(); DCHECK(method_address != nullptr); Register method_address_reg = invoke->GetLocations()->InAt(method_address_index).AsRegister(); @@ -3380,9 +3346,8 @@ void IntrinsicCodeGeneratorX86::VisitIntegerValueOf(HInvoke* invoke) { // adjust the offset accordingly. uint32_t mid_array_boot_image_offset = info.array_data_boot_image_reference - info.low * kElementSize; - // TODO: Remove "OrNull". codegen_->LoadBootImageAddress( - out, mid_array_boot_image_offset, invoke->AsInvokeStaticOrDirectOrNull()); + out, mid_array_boot_image_offset, invoke->AsInvokeStaticOrDirect()); DCHECK_NE(out, in); __ movl(out, Address(out, in, TIMES_4, 0)); } @@ -3421,8 +3386,7 @@ void IntrinsicCodeGeneratorX86::VisitReferenceGetReferent(HInvoke* invoke) { // Load the java.lang.ref.Reference class, use the output register as a temporary. codegen_->LoadIntrinsicDeclaringClass(out.AsRegister(), - // TODO: Remove "OrNull". - invoke->AsInvokeStaticOrDirectOrNull()); + invoke->AsInvokeStaticOrDirect()); // Check static fields java.lang.ref.Reference.{disableIntrinsic,slowPathEnabled} together. MemberOffset disable_intrinsic_offset = IntrinsicVisitor::GetReferenceDisableIntrinsicOffset(); diff --git a/compiler/optimizing/intrinsics_x86_64.cc b/compiler/optimizing/intrinsics_x86_64.cc index 3a441f3c3b..e18ef8ebfe 100644 --- a/compiler/optimizing/intrinsics_x86_64.cc +++ b/compiler/optimizing/intrinsics_x86_64.cc @@ -83,8 +83,7 @@ class ReadBarrierSystemArrayCopySlowPathX86_64 : public SlowPathCode { << "Unexpected instruction in read barrier arraycopy slow path: " << instruction_->DebugName(); DCHECK(instruction_->GetLocations()->Intrinsified()); - // TODO: Remove "OrNull". - DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); + DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy); int32_t element_size = DataType::Size(DataType::Type::kReference); @@ -664,15 +663,13 @@ static void CheckPosition(X86_64Assembler* assembler, const uint32_t length_offset = mirror::Array::LengthOffset().Uint32Value(); if (pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue(); if (pos_const == 0) { if (!length_is_input_length) { // Check that length(input) >= length. if (length.IsConstant()) { __ cmpl(Address(input, length_offset), - // TODO: Remove "OrNull". - Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ cmpl(Address(input, length_offset), length.AsRegister()); } @@ -686,8 +683,7 @@ static void CheckPosition(X86_64Assembler* assembler, // Check that (length(input) - pos) >= length. if (length.IsConstant()) { - // TODO: Remove "OrNull". - __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ cmpl(temp, length.AsRegister()); } @@ -712,8 +708,7 @@ static void CheckPosition(X86_64Assembler* assembler, __ movl(temp, Address(input, length_offset)); __ subl(temp, pos_reg); if (length.IsConstant()) { - // TODO: Remove "OrNull". - __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ cmpl(temp, length.AsRegister()); } @@ -770,8 +765,7 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke, // We need the count in RCX. if (length.IsConstant()) { - // TODO: Remove "OrNull". - __ movl(count, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue())); + __ movl(count, Immediate(length.GetConstant()->AsIntConstant()->GetValue())); } else { __ movl(count, length.AsRegister()); } @@ -783,15 +777,13 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke, const uint32_t data_offset = mirror::Array::DataOffset(data_size).Uint32Value(); if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t src_pos_const = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t src_pos_const = src_pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(src_base, Address(src, data_size * src_pos_const + data_offset)); } else { __ leal(src_base, Address(src, src_pos.AsRegister(), scale_factor, data_offset)); } if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(dest_base, Address(dest, data_size * dest_pos_const + data_offset)); } else { __ leal(dest_base, @@ -871,24 +863,21 @@ static void GenSystemArrayCopyAddresses(X86_64Assembler* assembler, const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value(); if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(src_base, Address(src, element_size * constant + data_offset)); } else { __ leal(src_base, Address(src, src_pos.AsRegister(), scale_factor, data_offset)); } if (dst_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = dst_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = dst_pos.GetConstant()->AsIntConstant()->GetValue(); __ leal(dst_base, Address(dst, element_size * constant + data_offset)); } else { __ leal(dst_base, Address(dst, dst_pos.AsRegister(), scale_factor, data_offset)); } if (copy_length.IsConstant()) { - // TODO: Remove "OrNull". - int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue(); __ leal(src_end, Address(src_base, element_size * constant)); } else { __ leal(src_end, Address(src_base, copy_length.AsRegister(), scale_factor, 0)); @@ -932,11 +921,9 @@ void IntrinsicCodeGeneratorX86_64::VisitSystemArrayCopy(HInvoke* invoke) { // If source and destination are the same, we go to slow path if we need to do // forward copying. if (src_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue(); if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue(); if (optimizations.GetDestinationIsSource()) { // Checked when building locations. DCHECK_GE(src_pos_constant, dest_pos_constant); @@ -958,8 +945,7 @@ void IntrinsicCodeGeneratorX86_64::VisitSystemArrayCopy(HInvoke* invoke) { __ j(kNotEqual, &conditions_on_positions_validated); } if (dest_pos.IsConstant()) { - // TODO: Remove "OrNull". - int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue(); + int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue(); __ cmpl(src_pos.AsRegister(), Immediate(dest_pos_constant)); __ j(kLess, intrinsic_slow_path->GetEntryLabel()); } else { @@ -1437,8 +1423,7 @@ static void GenerateStringIndexOf(HInvoke* invoke, SlowPathCode* slow_path = nullptr; HInstruction* code_point = invoke->InputAt(1); if (code_point->IsIntConstant()) { - // TODO: Remove "OrNull". - if (static_cast(code_point->AsIntConstantOrNull()->GetValue()) > + if (static_cast(code_point->AsIntConstant()->GetValue()) > std::numeric_limits::max()) { // Always needs the slow-path. We could directly dispatch to it, but this case should be // rare, so for simplicity just put the full slow-path down and branch unconditionally. @@ -1669,9 +1654,8 @@ void IntrinsicCodeGeneratorX86_64::VisitStringGetCharsNoCheck(HInvoke* invoke) { // public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin); CpuRegister obj = locations->InAt(0).AsRegister(); Location srcBegin = locations->InAt(1); - // TODO: Remove "OrNull". int srcBegin_value = - srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstantOrNull()->GetValue() : 0; + srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstant()->GetValue() : 0; CpuRegister srcEnd = locations->InAt(2).AsRegister(); CpuRegister dst = locations->InAt(3).AsRegister(); CpuRegister dstBegin = locations->InAt(4).AsRegister(); @@ -1827,8 +1811,7 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86_64Assem break; case DataType::Type::kInt64: if (value.IsConstant()) { - // TODO: Remove "OrNull". - int64_t v = value.GetConstant()->AsLongConstantOrNull()->GetValue(); + int64_t v = value.GetConstant()->AsLongConstant()->GetValue(); DCHECK(IsInt<32>(v)); int32_t v_32 = v; __ movq(Address(address, 0), Immediate(v_32)); @@ -2755,8 +2738,7 @@ static void GenBitCount(X86_64Assembler* assembler, if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); int32_t result = is_long ? POPCOUNT(static_cast(value)) : POPCOUNT(static_cast(value)); @@ -2814,8 +2796,7 @@ static void GenOneBit(X86_64Assembler* assembler, if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); if (value == 0) { __ xorl(out, out); // Clears upper bits too. return; @@ -2948,8 +2929,7 @@ static void GenLeadingZeros(X86_64Assembler* assembler, int zero_value_result = is_long ? 64 : 32; if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); if (value == 0) { value = zero_value_result; } else { @@ -3022,8 +3002,7 @@ static void GenTrailingZeros(X86_64Assembler* assembler, int zero_value_result = is_long ? 64 : 32; if (invoke->InputAt(0)->IsConstant()) { // Evaluate this at compile time. - // TODO: Remove "OrNull". - int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull()); + int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant()); if (value == 0) { value = zero_value_result; } else { @@ -3098,8 +3077,7 @@ void IntrinsicCodeGeneratorX86_64::VisitIntegerValueOf(HInvoke* invoke) { CheckEntrypointTypes(); }; if (invoke->InputAt(0)->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue(); + int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue(); if (static_cast(value - info.low) < info.length) { // Just embed the j.l.Integer in the code. DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference); @@ -3405,8 +3383,7 @@ class VarHandleSlowPathX86_64 : public IntrinsicSlowPathX86_64 { private: HInvoke* GetInvoke() const { - // TODO: Remove "OrNull". - return GetInstruction()->AsInvokeOrNull(); + return GetInstruction()->AsInvoke(); } mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const { diff --git a/compiler/optimizing/live_ranges_test.cc b/compiler/optimizing/live_ranges_test.cc index 4e1a49b41b..fb1a23eef4 100644 --- a/compiler/optimizing/live_ranges_test.cc +++ b/compiler/optimizing/live_ranges_test.cc @@ -311,8 +311,7 @@ TEST_F(LiveRangesTest, Loop2) { liveness.Analyze(); // Test for the 0 constant. - // TODO: Remove "OrNull". - HIntConstant* constant = liveness.GetInstructionFromSsaIndex(0)->AsIntConstantOrNull(); + HIntConstant* constant = liveness.GetInstructionFromSsaIndex(0)->AsIntConstant(); LiveInterval* interval = constant->GetLiveInterval(); LiveRange* range = interval->GetFirstRange(); ASSERT_EQ(2u, range->GetStart()); @@ -322,8 +321,7 @@ TEST_F(LiveRangesTest, Loop2) { ASSERT_TRUE(range->GetNext() == nullptr); // Test for the loop phi. - // TODO: Remove "OrNull". - HPhi* phi = liveness.GetInstructionFromSsaIndex(1)->AsPhiOrNull(); + HPhi* phi = liveness.GetInstructionFromSsaIndex(1)->AsPhi(); interval = phi->GetLiveInterval(); range = interval->GetFirstRange(); ASSERT_EQ(10u, range->GetStart()); @@ -334,8 +332,7 @@ TEST_F(LiveRangesTest, Loop2) { ASSERT_EQ(24u, range->GetEnd()); // Test for the add instruction. - // TODO: Remove "OrNull". - HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAddOrNull(); + HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAdd(); interval = add->GetLiveInterval(); range = interval->GetFirstRange(); ASSERT_EQ(18u, range->GetStart()); @@ -409,8 +406,7 @@ TEST_F(LiveRangesTest, CFG4) { ASSERT_TRUE(range->GetNext() == nullptr); // Test for the first add. - // TODO: Remove "OrNull". - HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAddOrNull(); + HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAdd(); interval = add->GetLiveInterval(); range = interval->GetFirstRange(); ASSERT_EQ(16u, range->GetStart()); @@ -418,16 +414,14 @@ TEST_F(LiveRangesTest, CFG4) { ASSERT_TRUE(range->GetNext() == nullptr); // Test for the second add. - // TODO: Remove "OrNull". - add = liveness.GetInstructionFromSsaIndex(3)->AsAddOrNull(); + add = liveness.GetInstructionFromSsaIndex(3)->AsAdd(); interval = add->GetLiveInterval(); range = interval->GetFirstRange(); ASSERT_EQ(22u, range->GetStart()); ASSERT_EQ(26u, range->GetEnd()); ASSERT_TRUE(range->GetNext() == nullptr); - // TODO: Remove "OrNull". - HPhi* phi = liveness.GetInstructionFromSsaIndex(4)->AsPhiOrNull(); + HPhi* phi = liveness.GetInstructionFromSsaIndex(4)->AsPhi(); ASSERT_TRUE(phi->GetUses().HasExactlyOneElement()); interval = phi->GetLiveInterval(); range = interval->GetFirstRange(); diff --git a/compiler/optimizing/load_store_analysis.cc b/compiler/optimizing/load_store_analysis.cc index 9a63da4c05..b46e3e18d9 100644 --- a/compiler/optimizing/load_store_analysis.cc +++ b/compiler/optimizing/load_store_analysis.cc @@ -51,10 +51,9 @@ static bool CanBinaryOpAndIndexAlias(const HBinaryOperation* idx1, // Since 'i' are the same in [i+CONST] and [i], // further compare [CONST] and [0]. - // TODO: Remove "OrNull". int64_t l1 = idx1->IsAdd() - ? idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue() - : -idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue(); + ? idx1->GetConstantRight()->AsIntConstant()->GetValue() + : -idx1->GetConstantRight()->AsIntConstant()->GetValue(); int64_t l2 = 0; int64_t h1 = l1 + (vector_length1 - 1); int64_t h2 = l2 + (vector_length2 - 1); @@ -80,14 +79,12 @@ static bool CanBinaryOpsAlias(const HBinaryOperation* idx1, // Since 'i' are the same in [i+CONST1] and [i+CONST2], // further compare [CONST1] and [CONST2]. - // TODO: Remove "OrNull". int64_t l1 = idx1->IsAdd() - ? idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue() - : -idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue(); - // TODO: Remove "OrNull". + ? idx1->GetConstantRight()->AsIntConstant()->GetValue() + : -idx1->GetConstantRight()->AsIntConstant()->GetValue(); int64_t l2 = idx2->IsAdd() - ? idx2->GetConstantRight()->AsIntConstantOrNull()->GetValue() - : -idx2->GetConstantRight()->AsIntConstantOrNull()->GetValue(); + ? idx2->GetConstantRight()->AsIntConstant()->GetValue() + : -idx2->GetConstantRight()->AsIntConstant()->GetValue(); int64_t h1 = l1 + (vector_length1 - 1); int64_t h2 = l2 + (vector_length2 - 1); return CanIntegerRangesOverlap(l1, h1, l2, h2); @@ -132,14 +129,11 @@ void ReferenceInfo::PrunePartialEscapeWrites() { bool HeapLocationCollector::InstructionEligibleForLSERemoval(HInstruction* inst) const { if (inst->IsNewInstance()) { - // TODO: Remove "OrNull". - return !inst->AsNewInstanceOrNull()->NeedsChecks(); + return !inst->AsNewInstance()->NeedsChecks(); } else if (inst->IsNewArray()) { - // TODO: Remove "OrNull". - HInstruction* array_length = inst->AsNewArrayOrNull()->GetLength(); - // TODO: Remove "OrNull". + HInstruction* array_length = inst->AsNewArray()->GetLength(); bool known_array_length = - array_length->IsIntConstant() && array_length->AsIntConstantOrNull()->GetValue() >= 0; + array_length->IsIntConstant() && array_length->AsIntConstant()->GetValue() >= 0; return known_array_length && std::all_of(inst->GetUses().cbegin(), inst->GetUses().cend(), @@ -229,10 +223,8 @@ bool HeapLocationCollector::CanArrayElementsAlias(const HInstruction* idx1, // [CONST1] and [CONST2]. if (idx1->IsIntConstant() && idx2->IsIntConstant()) { - // TODO: Remove "OrNull". - int64_t l1 = idx1->AsIntConstantOrNull()->GetValue(); - // TODO: Remove "OrNull". - int64_t l2 = idx2->AsIntConstantOrNull()->GetValue(); + int64_t l1 = idx1->AsIntConstant()->GetValue(); + int64_t l2 = idx2->AsIntConstant()->GetValue(); // To avoid any overflow in following CONST+vector_length calculation, // use int64_t instead of int32_t. int64_t h1 = l1 + (vector_length1 - 1); @@ -241,39 +233,33 @@ bool HeapLocationCollector::CanArrayElementsAlias(const HInstruction* idx1, } // [i+CONST] and [i]. - // TODO: Remove "OrNull". if (idx1->IsBinaryOperation() && - idx1->AsBinaryOperationOrNull()->GetConstantRight() != nullptr && - idx1->AsBinaryOperationOrNull()->GetLeastConstantLeft() == idx2) { - // TODO: Remove "OrNull". - return CanBinaryOpAndIndexAlias(idx1->AsBinaryOperationOrNull(), + idx1->AsBinaryOperation()->GetConstantRight() != nullptr && + idx1->AsBinaryOperation()->GetLeastConstantLeft() == idx2) { + return CanBinaryOpAndIndexAlias(idx1->AsBinaryOperation(), vector_length1, idx2, vector_length2); } // [i] and [i+CONST]. - // TODO: Remove "OrNull". if (idx2->IsBinaryOperation() && - idx2->AsBinaryOperationOrNull()->GetConstantRight() != nullptr && - idx2->AsBinaryOperationOrNull()->GetLeastConstantLeft() == idx1) { - // TODO: Remove "OrNull". - return CanBinaryOpAndIndexAlias(idx2->AsBinaryOperationOrNull(), + idx2->AsBinaryOperation()->GetConstantRight() != nullptr && + idx2->AsBinaryOperation()->GetLeastConstantLeft() == idx1) { + return CanBinaryOpAndIndexAlias(idx2->AsBinaryOperation(), vector_length2, idx1, vector_length1); } // [i+CONST1] and [i+CONST2]. - // TODO: Remove "OrNull". if (idx1->IsBinaryOperation() && - idx1->AsBinaryOperationOrNull()->GetConstantRight() != nullptr && + idx1->AsBinaryOperation()->GetConstantRight() != nullptr && idx2->IsBinaryOperation() && - idx2->AsBinaryOperationOrNull()->GetConstantRight() != nullptr) { - // TODO: Remove "OrNull". - return CanBinaryOpsAlias(idx1->AsBinaryOperationOrNull(), + idx2->AsBinaryOperation()->GetConstantRight() != nullptr) { + return CanBinaryOpsAlias(idx1->AsBinaryOperation(), vector_length1, - idx2->AsBinaryOperationOrNull(), + idx2->AsBinaryOperation(), vector_length2); } diff --git a/compiler/optimizing/load_store_analysis.h b/compiler/optimizing/load_store_analysis.h index 97a7cf6e78..c46a5b9cc1 100644 --- a/compiler/optimizing/load_store_analysis.h +++ b/compiler/optimizing/load_store_analysis.h @@ -334,11 +334,9 @@ class HeapLocationCollector : public HGraphVisitor { size_t vector_length = HeapLocation::kScalar; const bool is_vec_op = instruction->IsVecStore() || instruction->IsVecLoad(); if (instruction->IsArraySet()) { - // TODO: Remove "OrNull". - type = instruction->AsArraySetOrNull()->GetComponentType(); + type = instruction->AsArraySet()->GetComponentType(); } else if (is_vec_op) { - // TODO: Remove "OrNull". - HVecOperation* vec_op = instruction->AsVecOperationOrNull(); + HVecOperation* vec_op = instruction->AsVecOperation(); type = vec_op->GetPackedType(); vector_length = vec_op->GetVectorLength(); } else { diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc index b44db65dc2..9cabb12a9f 100644 --- a/compiler/optimizing/load_store_elimination.cc +++ b/compiler/optimizing/load_store_elimination.cc @@ -736,8 +736,7 @@ class LSEVisitor final : private HGraphDelegateVisitor { use.GetUser()->MoveBefore(instruction); } DCHECK(use.GetUser()->StrictlyDominates(instruction)); - // TODO: Remove "OrNull". - return use.GetUser()->AsTypeConversionOrNull(); + return use.GetUser()->AsTypeConversion(); } } @@ -976,13 +975,9 @@ class LSEVisitor final : private HGraphDelegateVisitor { } void HandleAcquireLoad(HInstruction* instruction) { - // TODO: Remove "OrNull". - DCHECK((instruction->IsInstanceFieldGet() && - instruction->AsInstanceFieldGetOrNull()->IsVolatile()) || - (instruction->IsStaticFieldGet() && - instruction->AsStaticFieldGetOrNull()->IsVolatile()) || - (instruction->IsMonitorOperation() && - instruction->AsMonitorOperationOrNull()->IsEnter())) + DCHECK((instruction->IsInstanceFieldGet() && instruction->AsInstanceFieldGet()->IsVolatile()) || + (instruction->IsStaticFieldGet() && instruction->AsStaticFieldGet()->IsVolatile()) || + (instruction->IsMonitorOperation() && instruction->AsMonitorOperation()->IsEnter())) << "Unexpected instruction " << instruction->GetId() << ": " << instruction->DebugName(); // Acquire operations e.g. MONITOR_ENTER change the thread's view of the memory, so we must @@ -1000,13 +995,9 @@ class LSEVisitor final : private HGraphDelegateVisitor { } void HandleReleaseStore(HInstruction* instruction) { - // TODO: Remove "OrNull". - DCHECK((instruction->IsInstanceFieldSet() && - instruction->AsInstanceFieldSetOrNull()->IsVolatile()) || - (instruction->IsStaticFieldSet() && - instruction->AsStaticFieldSetOrNull()->IsVolatile()) || - (instruction->IsMonitorOperation() && - !instruction->AsMonitorOperationOrNull()->IsEnter())) + DCHECK((instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->IsVolatile()) || + (instruction->IsStaticFieldSet() && instruction->AsStaticFieldSet()->IsVolatile()) || + (instruction->IsMonitorOperation() && !instruction->AsMonitorOperation()->IsEnter())) << "Unexpected instruction " << instruction->GetId() << ": " << instruction->DebugName(); // Release operations e.g. MONITOR_EXIT do not affect this thread's view of the memory, but @@ -1114,9 +1105,8 @@ class LSEVisitor final : private HGraphDelegateVisitor { if (!inside_a_try && info->IsSingleton()) { HInstruction* reference = info->GetReference(); // Finalizable objects always escape. - // TODO: Remove "OrNull". const bool finalizable_object = - reference->IsNewInstance() && reference->AsNewInstanceOrNull()->IsFinalizable(); + reference->IsNewInstance() && reference->AsNewInstance()->IsFinalizable(); if (!finalizable_object && !IsEscapingObject(info, block, i)) { // Check whether the reference for a store is used by an environment local of // the HDeoptimize. If not, the singleton is not observed after deoptimization. @@ -1341,8 +1331,7 @@ class LSEVisitor final : private HGraphDelegateVisitor { } if (ref_info->IsSingletonAndRemovable()) { if (new_array->GetLength()->IsIntConstant() && - // TODO: Remove "OrNull". - new_array->GetLength()->AsIntConstantOrNull()->GetValue() >= 0) { + new_array->GetLength()->AsIntConstant()->GetValue() >= 0) { // new_array can potentially be eliminated. singleton_new_instances_.push_back(new_array); } else { @@ -1676,9 +1665,8 @@ LSEVisitor::Value LSEVisitor::PrepareLoopStoredBy(HBasicBlock* block, size_t idx const ReferenceInfo* ref_info = heap_location_collector_.GetHeapLocation(idx)->GetReferenceInfo(); const HInstruction* reference = ref_info->GetReference(); // Finalizable objects always escape. - // TODO: Remove "OrNull". const bool is_finalizable = - reference->IsNewInstance() && reference->AsNewInstanceOrNull()->IsFinalizable(); + reference->IsNewInstance() && reference->AsNewInstance()->IsFinalizable(); if (ref_info->IsSingleton() && block->GetLoopInformation()->Contains(*reference->GetBlock()) && !is_finalizable) { @@ -2411,9 +2399,7 @@ bool LSEVisitor::MaterializeLoopPhis(ArrayRef phi_placeholder_inde for (size_t phi_placeholder_index : phi_placeholder_indexes) { PhiPlaceholder phi_placeholder = GetPhiPlaceholderAt(phi_placeholder_index); HBasicBlock* block = blocks[phi_placeholder.GetBlockId()]; - // TODO: Remove "OrNull". - block->AddPhi( - phi_placeholder_replacements_[phi_placeholder_index].GetInstruction()->AsPhiOrNull()); + block->AddPhi(phi_placeholder_replacements_[phi_placeholder_index].GetInstruction()->AsPhi()); } if (type == DataType::Type::kReference) { ScopedArenaAllocator local_allocator(allocator_.GetArenaStack()); @@ -3393,8 +3379,7 @@ class PartialLoadStoreEliminationHelper { } else if (ins->IsInstanceFieldGet()) { // IFieldGet[obj] => PredicatedIFieldGet[PartialValue, obj] HInstruction* new_fget = new (GetGraph()->GetAllocator()) HPredicatedInstanceFieldGet( - // TODO: Remove "OrNull". - ins->AsInstanceFieldGetOrNull(), + ins->AsInstanceFieldGet(), GetMaterialization(ins->GetBlock()), helper_->lse_->GetPartialValueAt(OriginalNewInstance(), ins)); MaybeRecordStat(helper_->lse_->stats_, MethodCompilationStat::kPredicatedLoadAdded); @@ -3420,8 +3405,7 @@ class PartialLoadStoreEliminationHelper { ins->GetBlock()->RemoveInstruction(ins); } else if (ins->IsInstanceFieldSet()) { // Any predicated sets shouldn't require movement. - // TODO: Remove "OrNull". - ins->AsInstanceFieldSetOrNull()->SetIsPredicatedSet(); + ins->AsInstanceFieldSet()->SetIsPredicatedSet(); MaybeRecordStat(helper_->lse_->stats_, MethodCompilationStat::kPredicatedStoreAdded); HInstruction* merged_inst = GetMaterialization(ins->GetBlock()); ins->ReplaceInput(merged_inst, idx); @@ -3490,8 +3474,7 @@ class PartialLoadStoreEliminationHelper { } } else if (use.GetUser()->IsConstructorFence()) { LSE_VLOG << "User " << *use.GetUser() << " being moved to materialization!"; - // TODO: Remove "OrNull". - constructor_fences.push_back({use.GetUser()->AsConstructorFenceOrNull(), use.GetIndex()}); + constructor_fences.push_back({use.GetUser()->AsConstructorFence(), use.GetIndex()}); } else { LSE_VLOG << "User " << *use.GetUser() << " not contained in cohort!"; to_remove.push_back(use.GetUser()); @@ -3662,8 +3645,7 @@ class PartialLoadStoreEliminationHelper { for (HInstruction* ins : MakeSTLInstructionIteratorRange(HInstructionIterator(blk->GetInstructions()))) { if (ins->IsNewInstance()) { - // TODO: Remove "OrNull". - materializations.push_back(ins->AsNewInstanceOrNull()); + materializations.push_back(ins->AsNewInstance()); still_unsorted.SetBit(ins->GetId()); } } @@ -3717,8 +3699,7 @@ class PartialLoadStoreEliminationHelper { if (ri->IsPartialSingleton() && ri->GetReference()->GetBlock() != nullptr && ri->GetNoEscapeSubgraph()->ContainsBlock(ri->GetReference()->GetBlock())) { - // TODO: Remove "OrNull". - RecordHeapRefField(ri->GetReference()->AsNewInstanceOrNull(), i); + RecordHeapRefField(ri->GetReference()->AsNewInstance(), i); } } } @@ -3744,8 +3725,7 @@ class PartialLoadStoreEliminationHelper { void NotifyNewMaterialization(HInstruction* ins) { if (ins->IsPhi()) { - // TODO: Remove "OrNull". - new_ref_phis_.push_back(ins->AsPhiOrNull()); + new_ref_phis_.push_back(ins->AsPhi()); } } @@ -3793,8 +3773,7 @@ HInstruction* LSEVisitor::SetupPartialMaterialization(PartialLoadStoreEliminatio } HBasicBlock* bb = helper.GetOrCreateMaterializationBlock(entry, pred_idx); CHECK(bb != nullptr) << "entry " << entry->GetBlockId() << " -> " << old_pred->GetBlockId(); - // TODO: Remove "OrNull". - HNewInstance* repl_create = new_inst->Clone(GetGraph()->GetAllocator())->AsNewInstanceOrNull(); + HNewInstance* repl_create = new_inst->Clone(GetGraph()->GetAllocator())->AsNewInstance(); repl_create->SetPartialMaterialization(); bb->InsertInstructionBefore(repl_create, bb->GetLastInstruction()); repl_create->CopyEnvironmentFrom(new_inst->GetEnvironment()); diff --git a/compiler/optimizing/load_store_elimination_test.cc b/compiler/optimizing/load_store_elimination_test.cc index 2126f9ec87..9fcc8ddef6 100644 --- a/compiler/optimizing/load_store_elimination_test.cc +++ b/compiler/optimizing/load_store_elimination_test.cc @@ -392,21 +392,17 @@ class PartialComparisonTestGroup PartialComparisonKind kind = GetParam(); if (ins->IsIntConstant()) { if (kind.IsDefinitelyTrue()) { - // TODO: Remove "OrNull". - EXPECT_TRUE(ins->AsIntConstantOrNull()->IsTrue()) << kind << " " << *ins; + EXPECT_TRUE(ins->AsIntConstant()->IsTrue()) << kind << " " << *ins; } else if (kind.IsDefinitelyFalse()) { - // TODO: Remove "OrNull". - EXPECT_TRUE(ins->AsIntConstantOrNull()->IsFalse()) << kind << " " << *ins; + EXPECT_TRUE(ins->AsIntConstant()->IsFalse()) << kind << " " << *ins; } else { EXPECT_EQ(placement, ComparisonPlacement::kBeforeEscape); EXPECT_EQ(kind.target_, Target::kValue); // We are before escape so value is not the object if (kind.type_ == Type::kEquals) { - // TODO: Remove "OrNull". - EXPECT_TRUE(ins->AsIntConstantOrNull()->IsFalse()) << kind << " " << *ins; + EXPECT_TRUE(ins->AsIntConstant()->IsFalse()) << kind << " " << *ins; } else { - // TODO: Remove "OrNull". - EXPECT_TRUE(ins->AsIntConstantOrNull()->IsTrue()) << kind << " " << *ins; + EXPECT_TRUE(ins->AsIntConstant()->IsTrue()) << kind << " " << *ins; } } return; @@ -417,14 +413,10 @@ class PartialComparisonTestGroup if (placement == ComparisonPlacement::kInEscape) { // Should be the same type. ASSERT_TRUE(ins->IsEqual() || ins->IsNotEqual()) << *ins; - // TODO: Remove "OrNull". - HInstruction* other = kind.position_ == Position::kLeft - ? ins->AsBinaryOperationOrNull()->GetRight() - : ins->AsBinaryOperationOrNull()->GetLeft(); + HInstruction* other = kind.position_ == Position::kLeft ? ins->AsBinaryOperation()->GetRight() + : ins->AsBinaryOperation()->GetLeft(); if (kind.target_ == Target::kSelf) { - // TODO: Remove "OrNull". - EXPECT_INS_EQ(ins->AsBinaryOperationOrNull()->GetLeft(), - ins->AsBinaryOperationOrNull()->GetRight()) + EXPECT_INS_EQ(ins->AsBinaryOperation()->GetLeft(), ins->AsBinaryOperation()->GetRight()) << " ins is: " << *ins; } else if (kind.target_ == Target::kNull) { EXPECT_INS_EQ(other, graph_->GetNullConstant()) << " ins is: " << *ins; diff --git a/compiler/optimizing/locations.cc b/compiler/optimizing/locations.cc index a1506ceea9..4189bc4053 100644 --- a/compiler/optimizing/locations.cc +++ b/compiler/optimizing/locations.cc @@ -99,8 +99,7 @@ void Location::DCheckInstructionIsConstant(HInstruction* instruction) { DCHECK(instruction != nullptr); DCHECK(instruction->IsConstant()); DCHECK_EQ(reinterpret_cast(instruction), - // TODO: Remove "OrNull". - reinterpret_cast(instruction->AsConstantOrNull())); + reinterpret_cast(instruction->AsConstant())); } std::ostream& operator<<(std::ostream& os, const Location& location) { diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc index 4c517482c8..d5e34634c8 100644 --- a/compiler/optimizing/loop_optimization.cc +++ b/compiler/optimizing/loop_optimization.cc @@ -732,8 +732,7 @@ void HLoopOptimization::SimplifyInduction(LoopNode* node) { // Examples: for (int i = 0; x != null; i++) { .... no i .... } // for (int i = 0; i < 10; i++, k++) { .... no k .... } return k; for (HInstructionIterator it(header->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); if (TrySetPhiInduction(phi, /*restrict_uses*/ true) && TryAssignLastValue(node->loop_info, phi, preheader, /*collect_loop_uses*/ false)) { // Note that it's ok to have replaced uses after the loop with the last value, without @@ -892,9 +891,8 @@ bool HLoopOptimization::TryUnrollingForBranchPenaltyReduction(LoopAnalysisInfo* helper.DoUnrolling(); // Remove the redundant loop check after unrolling. - // TODO: Remove "OrNull". HIf* copy_hif = - helper.GetBasicBlockMap()->Get(loop_info->GetHeader())->GetLastInstruction()->AsIfOrNull(); + helper.GetBasicBlockMap()->Get(loop_info->GetHeader())->GetLastInstruction()->AsIf(); int32_t constant = loop_info->Contains(*copy_hif->IfTrueSuccessor()) ? 1 : 0; copy_hif->ReplaceInput(graph_->GetIntConstant(constant), 0u); } @@ -922,8 +920,7 @@ bool HLoopOptimization::TryPeelingForLoopInvariantExitsElimination(LoopAnalysisI for (auto entry : *hir_map) { HInstruction* copy = entry.second; if (copy->IsIf()) { - // TODO: Remove "OrNull". - TryToEvaluateIfCondition(copy->AsIfOrNull(), graph_); + TryToEvaluateIfCondition(copy->AsIf(), graph_); } } } @@ -962,8 +959,7 @@ bool HLoopOptimization::TryFullUnrolling(LoopAnalysisInfo* analysis_info, bool g // HLoopInformation* loop_info = analysis_info->GetLoopInfo(); PeelByCount(loop_info, trip_count, &induction_range_); - // TODO: Remove "OrNull". - HIf* loop_hif = loop_info->GetHeader()->GetLastInstruction()->AsIfOrNull(); + HIf* loop_hif = loop_info->GetHeader()->GetLastInstruction()->AsIf(); int32_t constant = loop_info->Contains(*loop_hif->IfTrueSuccessor()) ? 0 : 1; loop_hif->ReplaceInput(graph_->GetIntConstant(constant), 0u); } @@ -1371,8 +1367,7 @@ void HLoopOptimization::GenerateNewLoop(LoopNode* node, if (i != vector_map_->end() && !i->second->IsInBlock()) { Insert(vector_body_, i->second); if (IsInPredicatedVectorizationMode() && i->second->IsVecOperation()) { - // TODO: Remove "OrNull". - HVecOperation* op = i->second->AsVecOperationOrNull(); + HVecOperation* op = i->second->AsVecOperation(); op->SetMergingGoverningPredicate(set_pred); } // Deal with instructions that need an environment, such as the scalar intrinsics. @@ -1389,8 +1384,7 @@ void HLoopOptimization::GenerateNewLoop(LoopNode* node, for (auto i = reductions_->begin(); i != reductions_->end(); ++i) { if (!i->first->IsPhi()) { DCHECK(i->second->IsPhi()); - // TODO: Remove "OrNull". - GenerateVecReductionPhiInputs(i->second->AsPhiOrNull(), i->first); + GenerateVecReductionPhiInputs(i->second->AsPhi(), i->first); } } // Finalize phi inputs for the loop index. @@ -1413,8 +1407,7 @@ bool HLoopOptimization::VectorizeDef(LoopNode* node, return false; } if (instruction->IsArraySet()) { - // TODO: Remove "OrNull". - DataType::Type type = instruction->AsArraySetOrNull()->GetComponentType(); + DataType::Type type = instruction->AsArraySet()->GetComponentType(); HInstruction* base = instruction->InputAt(0); HInstruction* index = instruction->InputAt(1); HInstruction* value = instruction->InputAt(2); @@ -1490,8 +1483,7 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node, return true; } else if (instruction->IsArrayGet()) { // Deal with vector restrictions. - // TODO: Remove "OrNull". - bool is_string_char_at = instruction->AsArrayGetOrNull()->IsStringCharAt(); + bool is_string_char_at = instruction->AsArrayGet()->IsStringCharAt(); if (is_string_char_at && (HasVectorRestrictions(restrictions, kNoStringCharAt) || IsInPredicatedVectorizationMode())) { @@ -1526,8 +1518,7 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node, } // Accept a reduction. if (generate_code) { - // TODO: Remove "OrNull". - GenerateVecReductionPhi(instruction->AsPhiOrNull()); + GenerateVecReductionPhi(instruction->AsPhi()); } return true; } @@ -1535,8 +1526,7 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node, return false; } else if (instruction->IsTypeConversion()) { // Accept particular type conversions. - // TODO: Remove "OrNull". - HTypeConversion* conversion = instruction->AsTypeConversionOrNull(); + HTypeConversion* conversion = instruction->AsTypeConversion(); HInstruction* opa = conversion->InputAt(0); DataType::Type from = conversion->GetInputType(); DataType::Type to = conversion->GetResultType(); @@ -1872,8 +1862,7 @@ void HLoopOptimization::GenerateVecInv(HInstruction* org, DataType::Type type) { vector_length_, 0u); vector_preheader_->InsertInstructionBefore(set_pred, vector); - // TODO: Remove "OrNull". - vector->AsVecOperationOrNull()->SetMergingGoverningPredicate(set_pred); + vector->AsVecOperation()->SetMergingGoverningPredicate(set_pred); } } vector_map_->Put(org, vector); @@ -1909,8 +1898,7 @@ void HLoopOptimization::GenerateVecMem(HInstruction* org, vector = new (global_allocator_) HVecStore( global_allocator_, base, opa, opb, type, org->GetSideEffects(), vector_length_, dex_pc); } else { - // TODO: Remove "OrNull". - is_string_char_at = org->AsArrayGetOrNull()->IsStringCharAt(); + is_string_char_at = org->AsArrayGet()->IsStringCharAt(); vector = new (global_allocator_) HVecLoad(global_allocator_, base, opa, @@ -1925,26 +1913,22 @@ void HLoopOptimization::GenerateVecMem(HInstruction* org, if (vector_dynamic_peeling_candidate_->offset == offset && // TODO: diffs too? DataType::Size(vector_dynamic_peeling_candidate_->type) == DataType::Size(type) && vector_dynamic_peeling_candidate_->is_string_char_at == is_string_char_at) { - // TODO: Remove "OrNull". - vector->AsVecMemoryOperationOrNull()->SetAlignment( // forced + vector->AsVecMemoryOperation()->SetAlignment( // forced Alignment(GetVectorSizeInBytes(), 0)); } } else { - // TODO: Remove "OrNull". - vector->AsVecMemoryOperationOrNull()->SetAlignment( // adjusted/original + vector->AsVecMemoryOperation()->SetAlignment( // adjusted/original ComputeAlignment(offset, type, is_string_char_at, vector_static_peeling_factor_)); } } else { // Scalar store or load. DCHECK(vector_mode_ == kSequential); if (opb != nullptr) { - // TODO: Remove "OrNull". - DataType::Type component_type = org->AsArraySetOrNull()->GetComponentType(); + DataType::Type component_type = org->AsArraySet()->GetComponentType(); vector = new (global_allocator_) HArraySet( org->InputAt(0), opa, opb, component_type, org->GetSideEffects(), dex_pc); } else { - // TODO: Remove "OrNull". - bool is_string_char_at = org->AsArrayGetOrNull()->IsStringCharAt(); + bool is_string_char_at = org->AsArrayGet()->IsStringCharAt(); vector = new (global_allocator_) HArrayGet( org->InputAt(0), opa, org->GetType(), org->GetSideEffects(), dex_pc, is_string_char_at); } @@ -1988,8 +1972,7 @@ void HLoopOptimization::GenerateVecReductionPhiInputs(HPhi* phi, HInstruction* r if (vector_mode_ == kVector) { // Generate a [initial, 0, .., 0] vector for add or // a [initial, initial, .., initial] vector for min/max. - // TODO: Remove "OrNull". - HVecOperation* red_vector = new_red->AsVecOperationOrNull(); + HVecOperation* red_vector = new_red->AsVecOperation(); HVecReduce::ReductionKind kind = GetReductionKind(red_vector); uint32_t vector_length = red_vector->GetVectorLength(); DataType::Type type = red_vector->GetPackedType(); @@ -2016,18 +1999,15 @@ void HLoopOptimization::GenerateVecReductionPhiInputs(HPhi* phi, HInstruction* r vector_length, 0u); vector_preheader_->InsertInstructionBefore(set_pred, new_init); - // TODO: Remove "OrNull". - new_init->AsVecOperationOrNull()->SetMergingGoverningPredicate(set_pred); + new_init->AsVecOperation()->SetMergingGoverningPredicate(set_pred); } } else { new_init = ReduceAndExtractIfNeeded(new_init); } // Set the phi inputs. DCHECK(new_phi->IsPhi()); - // TODO: Remove "OrNull". - new_phi->AsPhiOrNull()->AddInput(new_init); - // TODO: Remove "OrNull". - new_phi->AsPhiOrNull()->AddInput(new_red); + new_phi->AsPhi()->AddInput(new_init); + new_phi->AsPhi()->AddInput(new_red); // New feed value for next phi (safe mutation in iteration). reductions_->find(phi)->second = new_phi; } @@ -2037,8 +2017,7 @@ HInstruction* HLoopOptimization::ReduceAndExtractIfNeeded(HInstruction* instruct HInstruction* input = instruction->InputAt(1); if (HVecOperation::ReturnsSIMDValue(input)) { DCHECK(!input->IsPhi()); - // TODO: Remove "OrNull". - HVecOperation* input_vector = input->AsVecOperationOrNull(); + HVecOperation* input_vector = input->AsVecOperation(); uint32_t vector_length = input_vector->GetVectorLength(); DataType::Type type = input_vector->GetPackedType(); HVecReduce::ReductionKind kind = GetReductionKind(input_vector); @@ -2062,8 +2041,7 @@ HInstruction* HLoopOptimization::ReduceAndExtractIfNeeded(HInstruction* instruct 0u); exit->InsertInstructionBefore(set_pred, reduce); reduce->SetMergingGoverningPredicate(set_pred); - // TODO: Remove "OrNull". - instruction->AsVecOperationOrNull()->SetMergingGoverningPredicate(set_pred); + instruction->AsVecOperation()->SetMergingGoverningPredicate(set_pred); } } } @@ -2543,13 +2521,11 @@ bool HLoopOptimization::TrySetSimpleLoopHeader(HBasicBlock* block, /*out*/ HPhi* // (2) the main induction, used in loop control. HPhi* phi = nullptr; for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - if (TrySetPhiReduction(it.Current()->AsPhiOrNull())) { + if (TrySetPhiReduction(it.Current()->AsPhi())) { continue; } else if (phi == nullptr) { // Found the first candidate for main induction. - // TODO: Remove "OrNull". - phi = it.Current()->AsPhiOrNull(); + phi = it.Current()->AsPhi(); } else { return false; } diff --git a/compiler/optimizing/loop_optimization_test.cc b/compiler/optimizing/loop_optimization_test.cc index 36976519c0..7f694fb655 100644 --- a/compiler/optimizing/loop_optimization_test.cc +++ b/compiler/optimizing/loop_optimization_test.cc @@ -324,8 +324,7 @@ TEST_F(LoopOptimizationTest, SimplifyLoopSinglePreheader) { EXPECT_EQ(preheader1->GetSingleSuccessor(), new_preheader); EXPECT_EQ(new_preheader->GetPhis().CountSize(), 1u); - // TODO: Remove "OrNull". - HPhi* new_preheader_phi = new_preheader->GetFirstPhi()->AsPhiOrNull(); + HPhi* new_preheader_phi = new_preheader->GetFirstPhi()->AsPhi(); EXPECT_EQ(new_preheader_phi->InputCount(), 2u); EXPECT_EQ(new_preheader_phi->InputAt(0), preheader0_add); EXPECT_EQ(new_preheader_phi->InputAt(1), preheader1_add); diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index b0c7b8a711..83b58763a4 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -183,8 +183,7 @@ static void RemoveCatchPhiUsesOfDeadInstruction(HInstruction* insn) { DCHECK(use.GetUser()->IsPhi()); DCHECK(user_block->IsCatchBlock()); for (HInstructionIterator phi_it(user_block->GetPhis()); !phi_it.Done(); phi_it.Advance()) { - // TODO: Remove "OrNull". - phi_it.Current()->AsPhiOrNull()->RemoveInputAt(use_index); + phi_it.Current()->AsPhi()->RemoveInputAt(use_index); } } } @@ -583,8 +582,7 @@ HBasicBlock* HGraph::SplitEdgeAndUpdateRPO(HBasicBlock* block, HBasicBlock* succ // Reorder phi inputs to match reordering of the block's predecessors. static void FixPhisAfterPredecessorsReodering(HBasicBlock* block, size_t first, size_t second) { for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); HInstruction* first_instr = phi->InputAt(first); HInstruction* second_instr = phi->InputAt(second); phi->ReplaceInput(first_instr, second); @@ -683,8 +681,7 @@ void HGraph::TransformLoopToSinglePreheaderFormat(HBasicBlock* header) { // Fix the data-flow. for (HInstructionIterator it(header->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* header_phi = it.Current()->AsPhiOrNull(); + HPhi* header_phi = it.Current()->AsPhi(); HPhi* preheader_phi = new (GetAllocator()) HPhi(GetAllocator(), header_phi->GetRegNumber(), @@ -739,8 +736,7 @@ void HGraph::SimplifyLoop(HBasicBlock* header) { HInstruction* first_instruction = header->GetFirstInstruction(); if (first_instruction != nullptr && first_instruction->IsSuspendCheck()) { // Called from DeadBlockElimination. Update SuspendCheck pointer. - // TODO: Remove "OrNull". - info->SetSuspendCheck(first_instruction->AsSuspendCheckOrNull()); + info->SetSuspendCheck(first_instruction->AsSuspendCheck()); } } @@ -1287,8 +1283,7 @@ void HBasicBlock::RemovePhi(HPhi* phi, bool ensure_safety) { void HBasicBlock::RemoveInstructionOrPhi(HInstruction* instruction, bool ensure_safety) { if (instruction->IsPhi()) { - // TODO: Remove "OrNull". - RemovePhi(instruction->AsPhiOrNull(), ensure_safety); + RemovePhi(instruction->AsPhi(), ensure_safety); } else { RemoveInstruction(instruction, ensure_safety); } @@ -1326,8 +1321,7 @@ void HEnvironment::CopyFromWithLoopPhiAdjustment(HEnvironment* env, if (instruction->IsLoopHeaderPhi() && (instruction->GetBlock() == loop_header)) { // At the end of the loop pre-header, the corresponding value for instruction // is the first input of the phi. - // TODO: Remove "OrNull". - HInstruction* initial = instruction->AsPhiOrNull()->InputAt(0); + HInstruction* initial = instruction->AsPhi()->InputAt(0); SetRawEnvAt(i, initial); initial->AddEnvUseAt(this, i); } else { @@ -1582,8 +1576,7 @@ void HInstruction::ReplaceUsesDominatedBy(HInstruction* dominator, if (dominated) { user->ReplaceInput(replacement, index); - // TODO: Remove "OrNull". - } else if (user->IsPhi() && !user->AsPhiOrNull()->IsCatchPhi()) { + } else if (user->IsPhi() && !user->AsPhi()->IsCatchPhi()) { // If the input flows from a block dominated by `dominator`, we can replace it. // We do not perform this for catch phis as we don't have control flow support // for their inputs. @@ -1689,8 +1682,7 @@ size_t HConstructorFence::RemoveConstructorFences(HInstruction* instruction) { ++it; if (use_instruction->IsConstructorFence()) { - // TODO: Remove "OrNull". - HConstructorFence* ctor_fence = use_instruction->AsConstructorFenceOrNull(); + HConstructorFence* ctor_fence = use_instruction->AsConstructorFence(); size_t input_index = use_node.GetIndex(); // Process the candidate instruction for removal @@ -1826,8 +1818,7 @@ void HGraphVisitor::VisitBasicBlock(HBasicBlock* block) { HConstant* HTypeConversion::TryStaticEvaluation() const { HGraph* graph = GetBlock()->GetGraph(); if (GetInput()->IsIntConstant()) { - // TODO: Remove "OrNull". - int32_t value = GetInput()->AsIntConstantOrNull()->GetValue(); + int32_t value = GetInput()->AsIntConstant()->GetValue(); switch (GetResultType()) { case DataType::Type::kInt8: return graph->GetIntConstant(static_cast(value), GetDexPc()); @@ -1847,8 +1838,7 @@ HConstant* HTypeConversion::TryStaticEvaluation() const { return nullptr; } } else if (GetInput()->IsLongConstant()) { - // TODO: Remove "OrNull". - int64_t value = GetInput()->AsLongConstantOrNull()->GetValue(); + int64_t value = GetInput()->AsLongConstant()->GetValue(); switch (GetResultType()) { case DataType::Type::kInt8: return graph->GetIntConstant(static_cast(value), GetDexPc()); @@ -1868,8 +1858,7 @@ HConstant* HTypeConversion::TryStaticEvaluation() const { return nullptr; } } else if (GetInput()->IsFloatConstant()) { - // TODO: Remove "OrNull". - float value = GetInput()->AsFloatConstantOrNull()->GetValue(); + float value = GetInput()->AsFloatConstant()->GetValue(); switch (GetResultType()) { case DataType::Type::kInt32: if (std::isnan(value)) @@ -1893,8 +1882,7 @@ HConstant* HTypeConversion::TryStaticEvaluation() const { return nullptr; } } else if (GetInput()->IsDoubleConstant()) { - // TODO: Remove "OrNull". - double value = GetInput()->AsDoubleConstantOrNull()->GetValue(); + double value = GetInput()->AsDoubleConstant()->GetValue(); switch (GetResultType()) { case DataType::Type::kInt32: if (std::isnan(value)) @@ -1923,18 +1911,14 @@ HConstant* HTypeConversion::TryStaticEvaluation() const { HConstant* HUnaryOperation::TryStaticEvaluation() const { if (GetInput()->IsIntConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetInput()->AsIntConstantOrNull()); + return Evaluate(GetInput()->AsIntConstant()); } else if (GetInput()->IsLongConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetInput()->AsLongConstantOrNull()); + return Evaluate(GetInput()->AsLongConstant()); } else if (kEnableFloatingPointStaticEvaluation) { if (GetInput()->IsFloatConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetInput()->AsFloatConstantOrNull()); + return Evaluate(GetInput()->AsFloatConstant()); } else if (GetInput()->IsDoubleConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetInput()->AsDoubleConstantOrNull()); + return Evaluate(GetInput()->AsDoubleConstant()); } } return nullptr; @@ -1942,30 +1926,24 @@ HConstant* HUnaryOperation::TryStaticEvaluation() const { HConstant* HBinaryOperation::TryStaticEvaluation() const { if (GetLeft()->IsIntConstant() && GetRight()->IsIntConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetLeft()->AsIntConstantOrNull(), GetRight()->AsIntConstantOrNull()); + return Evaluate(GetLeft()->AsIntConstant(), GetRight()->AsIntConstant()); } else if (GetLeft()->IsLongConstant()) { if (GetRight()->IsIntConstant()) { // The binop(long, int) case is only valid for shifts and rotations. DCHECK(IsShl() || IsShr() || IsUShr() || IsRor()) << DebugName(); - // TODO: Remove "OrNull". - return Evaluate(GetLeft()->AsLongConstantOrNull(), GetRight()->AsIntConstantOrNull()); + return Evaluate(GetLeft()->AsLongConstant(), GetRight()->AsIntConstant()); } else if (GetRight()->IsLongConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetLeft()->AsLongConstantOrNull(), GetRight()->AsLongConstantOrNull()); + return Evaluate(GetLeft()->AsLongConstant(), GetRight()->AsLongConstant()); } } else if (GetLeft()->IsNullConstant() && GetRight()->IsNullConstant()) { // The binop(null, null) case is only valid for equal and not-equal conditions. DCHECK(IsEqual() || IsNotEqual()) << DebugName(); - // TODO: Remove "OrNull". - return Evaluate(GetLeft()->AsNullConstantOrNull(), GetRight()->AsNullConstantOrNull()); + return Evaluate(GetLeft()->AsNullConstant(), GetRight()->AsNullConstant()); } else if (kEnableFloatingPointStaticEvaluation) { if (GetLeft()->IsFloatConstant() && GetRight()->IsFloatConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetLeft()->AsFloatConstantOrNull(), GetRight()->AsFloatConstantOrNull()); + return Evaluate(GetLeft()->AsFloatConstant(), GetRight()->AsFloatConstant()); } else if (GetLeft()->IsDoubleConstant() && GetRight()->IsDoubleConstant()) { - // TODO: Remove "OrNull". - return Evaluate(GetLeft()->AsDoubleConstantOrNull(), GetRight()->AsDoubleConstantOrNull()); + return Evaluate(GetLeft()->AsDoubleConstant(), GetRight()->AsDoubleConstant()); } } return nullptr; @@ -1973,11 +1951,9 @@ HConstant* HBinaryOperation::TryStaticEvaluation() const { HConstant* HBinaryOperation::GetConstantRight() const { if (GetRight()->IsConstant()) { - // TODO: Remove "OrNull". - return GetRight()->AsConstantOrNull(); + return GetRight()->AsConstant(); } else if (IsCommutative() && GetLeft()->IsConstant()) { - // TODO: Remove "OrNull". - return GetLeft()->AsConstantOrNull(); + return GetLeft()->AsConstant(); } else { return nullptr; } @@ -2172,8 +2148,7 @@ void HInstruction::MoveBeforeFirstUserAndOutOfLoops() { DCHECK(insert_pos->IsControlFlow()); // Avoid splitting HCondition from HIf to prevent unnecessary materialization. if (insert_pos->IsIf()) { - // TODO: Remove "OrNull". - HInstruction* if_input = insert_pos->AsIfOrNull()->InputAt(0); + HInstruction* if_input = insert_pos->AsIf()->InputAt(0); if (if_input == insert_pos->GetPrevious()) { insert_pos = if_input; } @@ -2290,8 +2265,7 @@ HBasicBlock* HBasicBlock::SplitAfterForInlining(HInstruction* cursor) { const HTryBoundary* HBasicBlock::ComputeTryEntryOfSuccessors() const { if (EndsWithTryBoundary()) { - // TODO: Remove "OrNull". - HTryBoundary* try_boundary = GetLastInstruction()->AsTryBoundaryOrNull(); + HTryBoundary* try_boundary = GetLastInstruction()->AsTryBoundary(); if (try_boundary->IsEntry()) { DCHECK(!IsTryBlock()); return try_boundary; @@ -2363,9 +2337,7 @@ bool HBasicBlock::HasSinglePhi() const { ArrayRef HBasicBlock::GetNormalSuccessors() const { if (EndsWithTryBoundary()) { // The normal-flow successor of HTryBoundary is always stored at index zero. - // TODO: Remove "OrNull". - DCHECK_EQ(successors_[0], - GetLastInstruction()->AsTryBoundaryOrNull()->GetNormalFlowSuccessor()); + DCHECK_EQ(successors_[0], GetLastInstruction()->AsTryBoundary()->GetNormalFlowSuccessor()); return ArrayRef(successors_).SubArray(0u, 1u); } else { // All successors of blocks not ending with TryBoundary are normal. @@ -2375,8 +2347,7 @@ ArrayRef HBasicBlock::GetNormalSuccessors() const { ArrayRef HBasicBlock::GetExceptionalSuccessors() const { if (EndsWithTryBoundary()) { - // TODO: Remove "OrNull". - return GetLastInstruction()->AsTryBoundaryOrNull()->GetExceptionHandlers(); + return GetLastInstruction()->AsTryBoundary()->GetExceptionHandlers(); } else { // Blocks not ending with TryBoundary do not have exceptional successors. return ArrayRef(); @@ -2501,8 +2472,7 @@ void HBasicBlock::DisconnectAndDelete() { // exception handlers of this TryBoundary were already visited and any // remaining handlers therefore must be live. We remove `predecessor` from // their list of predecessors. - // TODO: Remove "OrNull". - DCHECK_EQ(last_instruction->AsTryBoundaryOrNull()->GetNormalFlowSuccessor(), this); + DCHECK_EQ(last_instruction->AsTryBoundary()->GetNormalFlowSuccessor(), this); while (predecessor->GetSuccessors().size() > 1) { HBasicBlock* handler = predecessor->GetSuccessors()[1]; DCHECK(handler->IsCatchBlock()); @@ -2582,15 +2552,13 @@ void HBasicBlock::DisconnectFromSuccessors(const ArenaBitVector* visited) { // The successor has just one predecessor left. Replace phis with the only // remaining input. for (HInstructionIterator phi_it(successor->GetPhis()); !phi_it.Done(); phi_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = phi_it.Current()->AsPhiOrNull(); + HPhi* phi = phi_it.Current()->AsPhi(); phi->ReplaceWith(phi->InputAt(1 - this_index)); successor->RemovePhi(phi); } } else { for (HInstructionIterator phi_it(successor->GetPhis()); !phi_it.Done(); phi_it.Advance()) { - // TODO: Remove "OrNull". - phi_it.Current()->AsPhiOrNull()->RemoveInputAt(this_index); + phi_it.Current()->AsPhi()->RemoveInputAt(this_index); } } } @@ -2613,8 +2581,7 @@ void HBasicBlock::RemoveCatchPhiUsesAndInstruction(bool building_dominator_tree) RemoveInstruction(insn, /* ensure_safety= */ !building_dominator_tree); } for (HInstructionIterator it(GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* insn = it.Current()->AsPhiOrNull(); + HPhi* insn = it.Current()->AsPhi(); RemoveCatchPhiUsesOfDeadInstruction(insn); // If we are building the dominator tree, we removed all input records previously. @@ -2941,8 +2908,7 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { const bool saw_try_boundary = last->IsTryBoundary(); if (saw_try_boundary) { DCHECK(predecessor->IsSingleTryBoundary()); - // TODO: Remove "OrNull". - DCHECK(!last->AsTryBoundaryOrNull()->IsEntry()); + DCHECK(!last->AsTryBoundary()->IsEntry()); predecessor = predecessor->GetSinglePredecessor(); last = predecessor->GetLastInstruction(); } @@ -2964,9 +2930,8 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { try_catch_info->GetTryEntry().GetBlock()->GetExceptionalSuccessors()) { new_block->AddSuccessor(xhandler); } - // TODO: Remove "OrNull". DCHECK(try_catch_info->GetTryEntry().HasSameExceptionHandlersAs( - *new_block->GetLastInstruction()->AsTryBoundaryOrNull())); + *new_block->GetLastInstruction()->AsTryBoundary())); } else { // We either have `Throw->TryBoundary` or `Throw`. We want to point the whole chain to the // exit, so we recompute `predecessor` @@ -3049,26 +3014,21 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) { if (current->IsNullConstant()) { replacement = outer_graph->GetNullConstant(current->GetDexPc()); } else if (current->IsIntConstant()) { - // TODO: Remove "OrNull". replacement = outer_graph->GetIntConstant( - current->AsIntConstantOrNull()->GetValue(), current->GetDexPc()); + current->AsIntConstant()->GetValue(), current->GetDexPc()); } else if (current->IsLongConstant()) { - // TODO: Remove "OrNull". replacement = outer_graph->GetLongConstant( - current->AsLongConstantOrNull()->GetValue(), current->GetDexPc()); + current->AsLongConstant()->GetValue(), current->GetDexPc()); } else if (current->IsFloatConstant()) { - // TODO: Remove "OrNull". replacement = outer_graph->GetFloatConstant( - current->AsFloatConstantOrNull()->GetValue(), current->GetDexPc()); + current->AsFloatConstant()->GetValue(), current->GetDexPc()); } else if (current->IsDoubleConstant()) { - // TODO: Remove "OrNull". replacement = outer_graph->GetDoubleConstant( - current->AsDoubleConstantOrNull()->GetValue(), current->GetDexPc()); + current->AsDoubleConstant()->GetValue(), current->GetDexPc()); } else if (current->IsParameterValue()) { if (kIsDebugBuild && invoke->IsInvokeStaticOrDirect() && - // TODO: Remove "OrNull". - invoke->AsInvokeStaticOrDirectOrNull()->IsStaticWithExplicitClinitCheck()) { + invoke->AsInvokeStaticOrDirect()->IsStaticWithExplicitClinitCheck()) { // Ensure we do not use the last input of `invoke`, as it // contains a clinit check which is not an actual argument. size_t last_input_index = invoke->InputCount() - 1; @@ -3248,8 +3208,7 @@ void HInstruction::SetReferenceTypeInfo(ReferenceTypeInfo rti) { if (IsBoundType()) { // Having the test here spares us from making the method virtual just for // the sake of a DCHECK. - // TODO: Remove "OrNull". - CheckAgainstUpperBound(rti, AsBoundTypeOrNull()->GetUpperBound()); + CheckAgainstUpperBound(rti, AsBoundType()->GetUpperBound()); } } reference_type_handle_ = rti.GetTypeHandle(); @@ -3263,8 +3222,7 @@ void HInstruction::SetReferenceTypeInfoIfValid(ReferenceTypeInfo rti) { } bool HBoundType::InstructionDataEquals(const HInstruction* other) const { - // TODO: Remove "OrNull". - const HBoundType* other_bt = other->AsBoundTypeOrNull(); + const HBoundType* other_bt = other->AsBoundType(); ScopedObjectAccess soa(Thread::Current()); return GetUpperBound().IsEqual(other_bt->GetUpperBound()) && GetUpperCanBeNull() == other_bt->GetUpperCanBeNull() && @@ -3404,8 +3362,7 @@ bool HInvokeVirtual::CanDoImplicitNullCheckOn(HInstruction* obj) const { } bool HLoadClass::InstructionDataEquals(const HInstruction* other) const { - // TODO: Remove "OrNull". - const HLoadClass* other_load_class = other->AsLoadClassOrNull(); + const HLoadClass* other_load_class = other->AsLoadClass(); // TODO: To allow GVN for HLoadClass from different dex files, we should compare the type // names rather than type indexes. However, we shall also have to re-think the hash code. if (type_index_ != other_load_class->type_index_ || @@ -3426,8 +3383,7 @@ bool HLoadClass::InstructionDataEquals(const HInstruction* other) const { } bool HLoadString::InstructionDataEquals(const HInstruction* other) const { - // TODO: Remove "OrNull". - const HLoadString* other_load_string = other->AsLoadStringOrNull(); + const HLoadString* other_load_string = other->AsLoadString(); // TODO: To allow GVN for HLoadString from different dex files, we should compare the strings // rather than their indexes. However, we shall also have to re-think the hash code. if (string_index_ != other_load_string->string_index_ || @@ -3459,11 +3415,9 @@ HInstruction* ReplaceInstrOrPhiByClone(HInstruction* instr) { HBasicBlock* block = instr->GetBlock(); if (instr->IsPhi()) { - // TODO: Remove "OrNull". - HPhi* phi = instr->AsPhiOrNull(); + HPhi* phi = instr->AsPhi(); DCHECK(!phi->HasEnvironment()); - // TODO: Remove "OrNull". - HPhi* phi_clone = clone->AsPhiOrNull(); + HPhi* phi_clone = clone->AsPhi(); block->ReplaceAndRemovePhiWith(phi, phi_clone); } else { block->ReplaceAndRemoveInstructionWith(instr, clone); @@ -3471,8 +3425,7 @@ HInstruction* ReplaceInstrOrPhiByClone(HInstruction* instr) { clone->CopyEnvironmentFrom(instr->GetEnvironment()); HLoopInformation* loop_info = block->GetLoopInformation(); if (instr->IsSuspendCheck() && loop_info != nullptr) { - // TODO: Remove "OrNull". - loop_info->SetSuspendCheck(clone->AsSuspendCheckOrNull()); + loop_info->SetSuspendCheck(clone->AsSuspendCheck()); } } } @@ -3489,8 +3442,7 @@ HInstruction* HGraph::InsertOppositeCondition(HInstruction* cond, HInstruction* HInstruction* lhs = cond->InputAt(0); HInstruction* rhs = cond->InputAt(1); HInstruction* replacement = nullptr; - // TODO: Remove "OrNull". - switch (cond->AsConditionOrNull()->GetOppositeCondition()) { // get *opposite* + switch (cond->AsCondition()->GetOppositeCondition()) { // get *opposite* case kCondEQ: replacement = new (allocator) HEqual(lhs, rhs); break; case kCondNE: replacement = new (allocator) HNotEqual(lhs, rhs); break; case kCondLT: replacement = new (allocator) HLessThan(lhs, rhs); break; @@ -3508,8 +3460,7 @@ HInstruction* HGraph::InsertOppositeCondition(HInstruction* cond, HInstruction* cursor->GetBlock()->InsertInstructionBefore(replacement, cursor); return replacement; } else if (cond->IsIntConstant()) { - // TODO: Remove "OrNull". - HIntConstant* int_const = cond->AsIntConstantOrNull(); + HIntConstant* int_const = cond->AsIntConstant(); if (int_const->IsFalse()) { return GetIntConstant(1); } else { diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h index 53396dbb72..4a0be10b77 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -2366,8 +2366,7 @@ class HInstruction : public ArenaObject { HInstruction* prev_not_move = GetPreviousDisregardingMoves(); while (prev_not_move != nullptr && prev_not_move->IsEmittedAtUseSite()) { if (prev_not_move->IsNullCheck()) { - // TODO: Remove "OrNull". - return prev_not_move->AsNullCheckOrNull(); + return prev_not_move->AsNullCheck(); } prev_not_move = prev_not_move->GetPreviousDisregardingMoves(); } @@ -2553,6 +2552,8 @@ class HInstruction : public ArenaObject { #undef INSTRUCTION_TYPE_CHECK #define INSTRUCTION_TYPE_CAST(type, super) \ + const H##type* As##type() const; \ + H##type* As##type(); \ const H##type* As##type##OrNull() const; \ H##type* As##type##OrNull(); @@ -3166,18 +3167,14 @@ class HPhi final : public HVariableInputSizeInstruction { return other != nullptr && other->IsPhi() && other->GetBlock() == GetBlock() - // TODO: Remove "OrNull". - && other->AsPhiOrNull()->GetRegNumber() == GetRegNumber(); + && other->AsPhi()->GetRegNumber() == GetRegNumber(); } bool HasEquivalentPhi() const { - // TODO: Remove "OrNull". - if (GetPrevious() != nullptr && - GetPrevious()->AsPhiOrNull()->GetRegNumber() == GetRegNumber()) { + if (GetPrevious() != nullptr && GetPrevious()->AsPhi()->GetRegNumber() == GetRegNumber()) { return true; } - // TODO: Remove "OrNull". - if (GetNext() != nullptr && GetNext()->AsPhiOrNull()->GetRegNumber() == GetRegNumber()) { + if (GetNext() != nullptr && GetNext()->AsPhi()->GetRegNumber() == GetRegNumber()) { return true; } return false; @@ -3188,11 +3185,9 @@ class HPhi final : public HVariableInputSizeInstruction { // It assumes that phis with the same dex register are adjacent. HPhi* GetNextEquivalentPhiWithSameType() { HInstruction* next = GetNext(); - // TODO: Remove "OrNull". - while (next != nullptr && next->AsPhiOrNull()->GetRegNumber() == reg_number_) { + while (next != nullptr && next->AsPhi()->GetRegNumber() == reg_number_) { if (next->GetType() == GetType()) { - // TODO: Remove "OrNull". - return next->AsPhiOrNull(); + return next->AsPhi(); } next = next->GetNext(); } @@ -3313,8 +3308,7 @@ class HIntConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsIntConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsIntConstantOrNull()->value_ == value_; + return other->AsIntConstant()->value_ == value_; } size_t ComputeHashCode() const override { return GetValue(); } @@ -3358,8 +3352,7 @@ class HLongConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsLongConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsLongConstantOrNull()->value_ == value_; + return other->AsLongConstant()->value_ == value_; } size_t ComputeHashCode() const override { return static_cast(GetValue()); } @@ -3395,8 +3388,7 @@ class HFloatConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsFloatConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsFloatConstantOrNull()->GetValueAsUint64() == GetValueAsUint64(); + return other->AsFloatConstant()->GetValueAsUint64() == GetValueAsUint64(); } size_t ComputeHashCode() const override { return static_cast(GetValue()); } @@ -3453,8 +3445,7 @@ class HDoubleConstant final : public HConstant { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsDoubleConstant()) << other->DebugName(); - // TODO: Remove "OrNull". - return other->AsDoubleConstantOrNull()->GetValueAsUint64() == GetValueAsUint64(); + return other->AsDoubleConstant()->GetValueAsUint64() == GetValueAsUint64(); } size_t ComputeHashCode() const override { return static_cast(GetValue()); } @@ -3651,8 +3642,7 @@ class HDeoptimize final : public HVariableInputSizeInstruction { bool InstructionDataEquals(const HInstruction* other) const override { return (other->CanBeMoved() == CanBeMoved()) && - // TODO: Remove "OrNull". - (other->AsDeoptimizeOrNull()->GetDeoptimizationKind() == GetDeoptimizationKind()); + (other->AsDeoptimize()->GetDeoptimizationKind() == GetDeoptimizationKind()); } bool NeedsEnvironment() const override { return true; } @@ -3761,9 +3751,8 @@ class HClassTableGet final : public HExpression<1> { bool IsClonable() const override { return true; } bool CanBeMoved() const override { return true; } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return other->AsClassTableGetOrNull()->GetIndex() == index_ && - other->AsClassTableGetOrNull()->GetPackedFields() == GetPackedFields(); + return other->AsClassTableGet()->GetIndex() == index_ && + other->AsClassTableGet()->GetPackedFields() == GetPackedFields(); } TableKind GetTableKind() const { return GetPackedField(); } @@ -3999,8 +3988,7 @@ class HCondition : public HBinaryOperation { void SetBias(ComparisonBias bias) { SetPackedField(bias); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return GetPackedFields() == other->AsConditionOrNull()->GetPackedFields(); + return GetPackedFields() == other->AsCondition()->GetPackedFields(); } bool IsFPConditionTrueIfNaN() const { @@ -4525,8 +4513,7 @@ class HCompare final : public HBinaryOperation { } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return GetPackedFields() == other->AsCompareOrNull()->GetPackedFields(); + return GetPackedFields() == other->AsCompare()->GetPackedFields(); } ComparisonBias GetBias() const { return GetPackedField(); } @@ -4626,8 +4613,7 @@ class HNewInstance final : public HExpression<1> { input = input->InputAt(0); } DCHECK(input->IsLoadClass()); - // TODO: Remove "OrNull". - return input->AsLoadClassOrNull(); + return input->AsLoadClass(); } bool IsStringAlloc() const; @@ -4759,8 +4745,7 @@ class HInvoke : public HVariableInputSizeInstruction { bool CanBeMoved() const override { return IsIntrinsic() && !DoesAnyWrite(); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return intrinsic_ != Intrinsics::kNone && intrinsic_ == other->AsInvokeOrNull()->intrinsic_; + return intrinsic_ != Intrinsics::kNone && intrinsic_ == other->AsInvoke()->intrinsic_; } uint32_t* GetIntrinsicOptimizations() { @@ -5365,8 +5350,7 @@ class HNewArray final : public HExpression<2> { HLoadClass* GetLoadClass() const { DCHECK(InputAt(0)->IsLoadClass()); - // TODO: Remove "OrNull". - return InputAt(0)->AsLoadClassOrNull(); + return InputAt(0)->AsLoadClass(); } HInstruction* GetLength() const { @@ -6306,8 +6290,7 @@ class HInstanceFieldGet final : public HExpression<1> { bool CanBeMoved() const override { return !IsVolatile(); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - const HInstanceFieldGet* other_get = other->AsInstanceFieldGetOrNull(); + const HInstanceFieldGet* other_get = other->AsInstanceFieldGet(); return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue(); } @@ -6396,8 +6379,7 @@ class HPredicatedInstanceFieldGet final : public HExpression<2> { } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - const HPredicatedInstanceFieldGet* other_get = other->AsPredicatedInstanceFieldGetOrNull(); + const HPredicatedInstanceFieldGet* other_get = other->AsPredicatedInstanceFieldGet(); return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue() && GetDefaultValue() == other_get->GetDefaultValue(); } @@ -7457,8 +7439,7 @@ class HClinitCheck final : public HExpression<1> { HLoadClass* GetLoadClass() const { DCHECK(InputAt(0)->IsLoadClass()); - // TODO: Remove "OrNull". - return InputAt(0)->AsLoadClassOrNull(); + return InputAt(0)->AsLoadClass(); } DECLARE_INSTRUCTION(ClinitCheck); @@ -7498,8 +7479,7 @@ class HStaticFieldGet final : public HExpression<1> { bool CanBeMoved() const override { return !IsVolatile(); } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - const HStaticFieldGet* other_get = other->AsStaticFieldGetOrNull(); + const HStaticFieldGet* other_get = other->AsStaticFieldGet(); return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue(); } @@ -7634,8 +7614,7 @@ class HStringBuilderAppend final : public HVariableInputSizeInstruction { } HIntConstant* GetFormat() { - // TODO: Remove "OrNull". - return InputAt(FormatIndex())->AsIntConstantOrNull(); + return InputAt(FormatIndex())->AsIntConstant(); } bool NeedsEnvironment() const override { return true; } @@ -7898,24 +7877,21 @@ class HTypeCheckInstruction : public HVariableInputSizeInstruction { DCHECK_NE(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck); HInstruction* load_class = InputAt(1); DCHECK(load_class->IsLoadClass()); - // TODO: Remove "OrNull". - return load_class->AsLoadClassOrNull(); + return load_class->AsLoadClass(); } uint32_t GetBitstringPathToRoot() const { DCHECK_EQ(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck); HInstruction* path_to_root = InputAt(2); DCHECK(path_to_root->IsIntConstant()); - // TODO: Remove "OrNull". - return static_cast(path_to_root->AsIntConstantOrNull()->GetValue()); + return static_cast(path_to_root->AsIntConstant()->GetValue()); } uint32_t GetBitstringMask() const { DCHECK_EQ(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck); HInstruction* mask = InputAt(3); DCHECK(mask->IsIntConstant()); - // TODO: Remove "OrNull". - return static_cast(mask->AsIntConstantOrNull()->GetValue()); + return static_cast(mask->AsIntConstant()->GetValue()); } bool IsClonable() const override { return true; } @@ -8719,11 +8695,9 @@ class HBlocksInLoopReversePostOrderIterator : public ValueObject { // Returns int64_t value of a properly typed constant. inline int64_t Int64FromConstant(HConstant* constant) { if (constant->IsIntConstant()) { - // TODO: Remove "OrNull". - return constant->AsIntConstantOrNull()->GetValue(); + return constant->AsIntConstant()->GetValue(); } else if (constant->IsLongConstant()) { - // TODO: Remove "OrNull". - return constant->AsLongConstantOrNull()->GetValue(); + return constant->AsLongConstant()->GetValue(); } else { DCHECK(constant->IsNullConstant()) << constant->DebugName(); return 0; @@ -8733,12 +8707,10 @@ inline int64_t Int64FromConstant(HConstant* constant) { // Returns true iff instruction is an integral constant (and sets value on success). inline bool IsInt64AndGet(HInstruction* instruction, /*out*/ int64_t* value) { if (instruction->IsIntConstant()) { - // TODO: Remove "OrNull". - *value = instruction->AsIntConstantOrNull()->GetValue(); + *value = instruction->AsIntConstant()->GetValue(); return true; } else if (instruction->IsLongConstant()) { - // TODO: Remove "OrNull". - *value = instruction->AsLongConstantOrNull()->GetValue(); + *value = instruction->AsLongConstant()->GetValue(); return true; } else if (instruction->IsNullConstant()) { *value = 0; @@ -8755,8 +8727,7 @@ inline bool IsInt64Value(HInstruction* instruction, int64_t value) { // Returns true iff instruction is a zero bit pattern. inline bool IsZeroBitPattern(HInstruction* instruction) { - // TODO: Remove "OrNull". - return instruction->IsConstant() && instruction->AsConstantOrNull()->IsZeroBitPattern(); + return instruction->IsConstant() && instruction->AsConstant()->IsZeroBitPattern(); } // Implement HInstruction::Is##type() for concrete instructions. @@ -8783,6 +8754,14 @@ inline bool IsZeroBitPattern(HInstruction* instruction) { #undef INSTRUCTION_TYPE_CHECK_RESULT #define INSTRUCTION_TYPE_CAST(type, super) \ + inline const H##type* HInstruction::As##type() const { \ + DCHECK(Is##type()); \ + return down_cast(this); \ + } \ + inline H##type* HInstruction::As##type() { \ + DCHECK(Is##type()); \ + return down_cast(this); \ + } \ inline const H##type* HInstruction::As##type##OrNull() const { \ return Is##type() ? down_cast(this) : nullptr; \ } \ @@ -8817,8 +8796,7 @@ inline HInstruction* HuntForDeclaration(HInstruction* instruction) { instruction->IsNullCheck() || instruction->IsNewArray()) { instruction = instruction->IsNewArray() - // TODO: Remove "OrNull". - ? instruction->AsNewArrayOrNull()->GetLength() + ? instruction->AsNewArray()->GetLength() : instruction->InputAt(0); } return instruction; diff --git a/compiler/optimizing/nodes_shared.cc b/compiler/optimizing/nodes_shared.cc index 6216da8234..b3a7ad9a05 100644 --- a/compiler/optimizing/nodes_shared.cc +++ b/compiler/optimizing/nodes_shared.cc @@ -33,22 +33,17 @@ void HDataProcWithShifterOp::GetOpInfoFromInstruction(HInstruction* instruction, DCHECK(CanFitInShifterOperand(instruction)); if (instruction->IsShl()) { *op_kind = kLSL; - // TODO: Remove "OrNull". - *shift_amount = instruction->AsShlOrNull()->GetRight()->AsIntConstantOrNull()->GetValue(); + *shift_amount = instruction->AsShl()->GetRight()->AsIntConstant()->GetValue(); } else if (instruction->IsShr()) { *op_kind = kASR; - // TODO: Remove "OrNull". - *shift_amount = instruction->AsShrOrNull()->GetRight()->AsIntConstantOrNull()->GetValue(); + *shift_amount = instruction->AsShr()->GetRight()->AsIntConstant()->GetValue(); } else if (instruction->IsUShr()) { *op_kind = kLSR; - // TODO: Remove "OrNull". - *shift_amount = instruction->AsUShrOrNull()->GetRight()->AsIntConstantOrNull()->GetValue(); + *shift_amount = instruction->AsUShr()->GetRight()->AsIntConstant()->GetValue(); } else { DCHECK(instruction->IsTypeConversion()); - // TODO: Remove "OrNull". - DataType::Type result_type = instruction->AsTypeConversionOrNull()->GetResultType(); - // TODO: Remove "OrNull". - DataType::Type input_type = instruction->AsTypeConversionOrNull()->GetInputType(); + DataType::Type result_type = instruction->AsTypeConversion()->GetResultType(); + DataType::Type input_type = instruction->AsTypeConversion()->GetInputType(); int result_size = DataType::Size(result_type); int input_size = DataType::Size(input_type); int min_size = std::min(result_size, input_size); diff --git a/compiler/optimizing/nodes_shared.h b/compiler/optimizing/nodes_shared.h index b91cc3e5fd..27e610328f 100644 --- a/compiler/optimizing/nodes_shared.h +++ b/compiler/optimizing/nodes_shared.h @@ -47,8 +47,7 @@ class HMultiplyAccumulate final : public HExpression<3> { bool CanBeMoved() const override { return true; } bool InstructionDataEquals(const HInstruction* other) const override { - // TODO: Remove "OrNull". - return op_kind_ == other->AsMultiplyAccumulateOrNull()->op_kind_; + return op_kind_ == other->AsMultiplyAccumulate()->op_kind_; } InstructionKind GetOpKind() const { return op_kind_; } @@ -216,8 +215,7 @@ class HDataProcWithShifterOp final : public HExpression<2> { bool IsClonable() const override { return true; } bool CanBeMoved() const override { return true; } bool InstructionDataEquals(const HInstruction* other_instr) const override { - // TODO: Remove "OrNull". - const HDataProcWithShifterOp* other = other_instr->AsDataProcWithShifterOpOrNull(); + const HDataProcWithShifterOp* other = other_instr->AsDataProcWithShifterOp(); return instr_kind_ == other->instr_kind_ && op_kind_ == other->op_kind_ && shift_amount_ == other->shift_amount_; diff --git a/compiler/optimizing/nodes_vector.h b/compiler/optimizing/nodes_vector.h index 223c06e1dc..73f6c40a0d 100644 --- a/compiler/optimizing/nodes_vector.h +++ b/compiler/optimizing/nodes_vector.h @@ -142,8 +142,7 @@ class HVecOperation : public HVariableInputSizeInstruction { DCHECK(IsPredicated()); HInstruction* pred_input = InputAt(InputCount() - 1); DCHECK(pred_input->IsVecPredSetOperation()); - // TODO: Remove "OrNull". - return pred_input->AsVecPredSetOperationOrNull(); + return pred_input->AsVecPredSetOperation(); } // Returns whether two vector operations are predicated by the same vector predicate @@ -189,8 +188,7 @@ class HVecOperation : public HVariableInputSizeInstruction { // those fields in its own method *and* call all super methods. bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsVecOperation()); - // TODO: Remove "OrNull". - const HVecOperation* o = other->AsVecOperationOrNull(); + const HVecOperation* o = other->AsVecOperation(); return GetVectorLength() == o->GetVectorLength() && GetPackedType() == o->GetPackedType(); } @@ -352,8 +350,7 @@ class HVecMemoryOperation : public HVecOperation { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsVecMemoryOperation()); - // TODO: Remove "OrNull". - const HVecMemoryOperation* o = other->AsVecMemoryOperationOrNull(); + const HVecMemoryOperation* o = other->AsVecMemoryOperation(); return HVecOperation::InstructionDataEquals(o) && GetAlignment() == o->GetAlignment(); } @@ -374,8 +371,7 @@ inline static bool HasConsistentPackedTypes(HInstruction* input, DataType::Type return input->GetType() == HVecOperation::kSIMDType; // carries SIMD } DCHECK(input->IsVecOperation()); - // TODO: Remove "OrNull". - DataType::Type input_type = input->AsVecOperationOrNull()->GetPackedType(); + DataType::Type input_type = input->AsVecOperation()->GetPackedType(); DCHECK_EQ(HVecOperation::ToUnsignedType(input_type) == HVecOperation::ToUnsignedType(type), HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type)); return HVecOperation::ToSignedType(input_type) == HVecOperation::ToSignedType(type); @@ -469,8 +465,7 @@ class HVecReduce final : public HVecUnaryOperation { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsVecReduce()); - // TODO: Remove "OrNull". - const HVecReduce* o = other->AsVecReduceOrNull(); + const HVecReduce* o = other->AsVecReduce(); return HVecOperation::InstructionDataEquals(o) && GetReductionKind() == o->GetReductionKind(); } @@ -497,10 +492,7 @@ class HVecCnv final : public HVecUnaryOperation { DCHECK_NE(GetInputType(), GetResultType()); // actual convert } - DataType::Type GetInputType() const { - // TODO: Remove "OrNull". - return InputAt(0)->AsVecOperationOrNull()->GetPackedType(); - } + DataType::Type GetInputType() const { return InputAt(0)->AsVecOperation()->GetPackedType(); } DataType::Type GetResultType() const { return GetPackedType(); } bool CanBeMoved() const override { return true; } @@ -654,8 +646,7 @@ class HVecHalvingAdd final : public HVecBinaryOperation { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsVecHalvingAdd()); - // TODO: Remove "OrNull". - const HVecHalvingAdd* o = other->AsVecHalvingAddOrNull(); + const HVecHalvingAdd* o = other->AsVecHalvingAdd(); return HVecOperation::InstructionDataEquals(o) && IsRounded() == o->IsRounded(); } @@ -1045,8 +1036,7 @@ class HVecMultiplyAccumulate final : public HVecOperation { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsVecMultiplyAccumulate()); - // TODO: Remove "OrNull". - const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulateOrNull(); + const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulate(); return HVecOperation::InstructionDataEquals(o) && GetOpKind() == o->GetOpKind(); } @@ -1086,9 +1076,8 @@ class HVecSADAccumulate final : public HVecOperation { DCHECK(HasConsistentPackedTypes(accumulator, packed_type)); DCHECK(sad_left->IsVecOperation()); DCHECK(sad_right->IsVecOperation()); - // TODO: Remove "OrNull". - DCHECK_EQ(ToSignedType(sad_left->AsVecOperationOrNull()->GetPackedType()), - ToSignedType(sad_right->AsVecOperationOrNull()->GetPackedType())); + DCHECK_EQ(ToSignedType(sad_left->AsVecOperation()->GetPackedType()), + ToSignedType(sad_right->AsVecOperation()->GetPackedType())); SetRawInputAt(0, accumulator); SetRawInputAt(1, sad_left); SetRawInputAt(2, sad_right); @@ -1135,9 +1124,8 @@ class HVecDotProd final : public HVecOperation { DCHECK(DataType::IsIntegralType(packed_type)); DCHECK(left->IsVecOperation()); DCHECK(right->IsVecOperation()); - // TODO: Remove "OrNull". - DCHECK_EQ(ToSignedType(left->AsVecOperationOrNull()->GetPackedType()), - ToSignedType(right->AsVecOperationOrNull()->GetPackedType())); + DCHECK_EQ(ToSignedType(left->AsVecOperation()->GetPackedType()), + ToSignedType(right->AsVecOperation()->GetPackedType())); SetRawInputAt(0, accumulator); SetRawInputAt(1, left); SetRawInputAt(2, right); @@ -1191,8 +1179,7 @@ class HVecLoad final : public HVecMemoryOperation { bool InstructionDataEquals(const HInstruction* other) const override { DCHECK(other->IsVecLoad()); - // TODO: Remove "OrNull". - const HVecLoad* o = other->AsVecLoadOrNull(); + const HVecLoad* o = other->AsVecLoad(); return HVecMemoryOperation::InstructionDataEquals(o) && IsStringCharAt() == o->IsStringCharAt(); } @@ -1323,10 +1310,7 @@ class HVecPredSetAll final : public HVecPredSetOperation { // Having governing predicate doesn't make sense for set all TRUE/FALSE instruction. bool MustBePredicatedInPredicatedSIMDMode() override { return false; } - bool IsSetTrue() const { - // TODO: Remove "OrNull". - return InputAt(0)->AsIntConstantOrNull()->IsTrue(); - } + bool IsSetTrue() const { return InputAt(0)->AsIntConstant()->IsTrue(); } // Vector predicates are not kept alive across vector loop boundaries. bool CanBeMoved() const override { return false; } diff --git a/compiler/optimizing/nodes_x86.h b/compiler/optimizing/nodes_x86.h index 04f9763060..e246390aa5 100644 --- a/compiler/optimizing/nodes_x86.h +++ b/compiler/optimizing/nodes_x86.h @@ -52,13 +52,11 @@ class HX86LoadFromConstantTable final : public HExpression<2> { } HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const { - // TODO: Remove "OrNull". - return InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(); + return InputAt(0)->AsX86ComputeBaseMethodAddress(); } HConstant* GetConstant() const { - // TODO: Remove "OrNull". - return InputAt(1)->AsConstantOrNull(); + return InputAt(1)->AsConstant(); } DECLARE_INSTRUCTION(X86LoadFromConstantTable); @@ -81,8 +79,7 @@ class HX86FPNeg final : public HExpression<2> { } HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const { - // TODO: Remove "OrNull". - return InputAt(1)->AsX86ComputeBaseMethodAddressOrNull(); + return InputAt(1)->AsX86ComputeBaseMethodAddress(); } DECLARE_INSTRUCTION(X86FPNeg); @@ -113,8 +110,7 @@ class HX86PackedSwitch final : public HExpression<2> { int32_t GetNumEntries() const { return num_entries_; } HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const { - // TODO: Remove "OrNull". - return InputAt(1)->AsX86ComputeBaseMethodAddressOrNull(); + return InputAt(1)->AsX86ComputeBaseMethodAddress(); } HBasicBlock* GetDefaultBlock() const { 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; \ } \ diff --git a/compiler/optimizing/prepare_for_register_allocation.cc b/compiler/optimizing/prepare_for_register_allocation.cc index 741bef7627..398b10abf3 100644 --- a/compiler/optimizing/prepare_for_register_allocation.cc +++ b/compiler/optimizing/prepare_for_register_allocation.cc @@ -58,8 +58,7 @@ void PrepareForRegisterAllocation::VisitNullCheck(HNullCheck* check) { // so do it ourselves now to not prevent optimizations. while (next->IsBoundType()) { next = next->GetNext(); - // TODO: Remove "OrNull". - VisitBoundType(next->GetPrevious()->AsBoundTypeOrNull()); + VisitBoundType(next->GetPrevious()->AsBoundType()); } if (next->CanDoImplicitNullCheckOn(check->InputAt(0))) { check->MarkEmittedAtUseSite(); @@ -124,18 +123,14 @@ void PrepareForRegisterAllocation::VisitClinitCheck(HClinitCheck* check) { CanMoveClinitCheck(check, user)) { implicit_clinit = user; if (user->IsInvokeStaticOrDirect()) { - // TODO: Remove "OrNull". - DCHECK(user->AsInvokeStaticOrDirectOrNull()->IsStaticWithExplicitClinitCheck()); - // TODO: Remove "OrNull". - user->AsInvokeStaticOrDirectOrNull()->RemoveExplicitClinitCheck( + DCHECK(user->AsInvokeStaticOrDirect()->IsStaticWithExplicitClinitCheck()); + user->AsInvokeStaticOrDirect()->RemoveExplicitClinitCheck( HInvokeStaticOrDirect::ClinitCheckRequirement::kImplicit); } else { DCHECK(user->IsNewInstance()); // We delegate the initialization duty to the allocation. - // TODO: Remove "OrNull". - if (user->AsNewInstanceOrNull()->GetEntrypoint() == kQuickAllocObjectInitialized) { - // TODO: Remove "OrNull". - user->AsNewInstanceOrNull()->SetEntrypoint(kQuickAllocObjectResolved); + if (user->AsNewInstance()->GetEntrypoint() == kQuickAllocObjectInitialized) { + user->AsNewInstance()->SetEntrypoint(kQuickAllocObjectResolved); } } break; @@ -151,8 +146,7 @@ void PrepareForRegisterAllocation::VisitClinitCheck(HClinitCheck* check) { DCHECK(implicit_clinit->StrictlyDominates(user) || (implicit_clinit == user)); ++it; // Advance before we remove the node, reference to the next node is preserved. if (user->IsInvokeStaticOrDirect()) { - // TODO: Remove "OrNull". - user->AsInvokeStaticOrDirectOrNull()->RemoveExplicitClinitCheck( + user->AsInvokeStaticOrDirect()->RemoveExplicitClinitCheck( HInvokeStaticOrDirect::ClinitCheckRequirement::kNone); } } @@ -190,8 +184,7 @@ bool PrepareForRegisterAllocation::CanEmitConditionAt(HCondition* condition, return true; } - // TODO: Remove "OrNull". - if (user->IsSelect() && user->AsSelectOrNull()->GetCondition() == condition) { + if (user->IsSelect() && user->AsSelect()->GetCondition() == condition) { return true; } @@ -219,8 +212,7 @@ void PrepareForRegisterAllocation::VisitConstructorFence(HConstructorFence* cons // TODO: Move this to a separate pass. HInstruction* allocation_inst = constructor_fence->GetAssociatedAllocation(); if (allocation_inst != nullptr && allocation_inst->IsNewInstance()) { - // TODO: Remove "OrNull". - HNewInstance* new_inst = allocation_inst->AsNewInstanceOrNull(); + HNewInstance* new_inst = allocation_inst->AsNewInstance(); // This relies on the entrypoint already being set to the more optimized version; // as that happens in this pass, this redundancy removal also cannot happen any earlier. if (new_inst != nullptr && new_inst->GetEntrypoint() == kQuickAllocObjectResolved) { @@ -276,8 +268,7 @@ bool PrepareForRegisterAllocation::CanMoveClinitCheck(HInstruction* input, return false; } - // TODO: Remove "OrNull". - if (user->IsNewInstance() && user->AsNewInstanceOrNull()->IsPartialMaterialization()) { + if (user->IsNewInstance() && user->AsNewInstance()->IsPartialMaterialization()) { return false; } diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc index 4fddee1874..6d4fdf3a55 100644 --- a/compiler/optimizing/reference_type_propagation.cc +++ b/compiler/optimizing/reference_type_propagation.cc @@ -132,8 +132,7 @@ void ReferenceTypePropagation::Visit(ArrayRef instructions) for (HInstruction* instruction : instructions) { if (instruction->IsPhi()) { // Need to force phis to recalculate null-ness. - // TODO: Remove "OrNull". - instruction->AsPhiOrNull()->SetCanBeNull(false); + instruction->AsPhi()->SetCanBeNull(false); } } for (HInstruction* instruction : instructions) { @@ -164,8 +163,7 @@ static bool ShouldCreateBoundType(HInstruction* position, return true; } - // TODO: Remove "OrNull". - HBoundType* existing_bound_type = position->AsBoundTypeOrNull(); + HBoundType* existing_bound_type = position->AsBoundType(); if (existing_bound_type->GetUpperBound().IsSupertypeOf(upper_bound)) { if (kIsDebugBuild) { // Check that the existing HBoundType dominates all the uses. @@ -255,8 +253,7 @@ static void BoundTypeForClassCheck(HInstruction* check) { HInstruction* input_one = compare->InputAt(0); HInstruction* input_two = compare->InputAt(1); HLoadClass* load_class = input_one->IsLoadClass() - // TODO: Remove "OrNull". - ? input_one->AsLoadClassOrNull() + ? input_one->AsLoadClass() : input_two->AsLoadClassOrNull(); if (load_class == nullptr) { return; @@ -289,15 +286,13 @@ static void BoundTypeForClassCheck(HInstruction* check) { } if (check->IsIf()) { - // TODO: Remove "OrNull". HBasicBlock* trueBlock = compare->IsEqual() - ? check->AsIfOrNull()->IfTrueSuccessor() - : check->AsIfOrNull()->IfFalseSuccessor(); + ? check->AsIf()->IfTrueSuccessor() + : check->AsIf()->IfFalseSuccessor(); BoundTypeIn(receiver, trueBlock, /* start_instruction= */ nullptr, class_rti); } else { DCHECK(check->IsDeoptimize()); - // TODO: Remove "OrNull". - if (compare->IsEqual() && check->AsDeoptimizeOrNull()->GuardsAnInput()) { + if (compare->IsEqual() && check->AsDeoptimize()->GuardsAnInput()) { check->SetReferenceTypeInfo(class_rti); } } @@ -323,8 +318,7 @@ bool ReferenceTypePropagation::Run() { void ReferenceTypePropagation::RTPVisitor::VisitBasicBlock(HBasicBlock* block) { // Handle Phis first as there might be instructions in the same block who depend on them. for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - VisitPhi(it.Current()->AsPhiOrNull()); + VisitPhi(it.Current()->AsPhi()); } // Handle instructions. Since RTP may add HBoundType instructions just after the @@ -397,18 +391,14 @@ static bool MatchIfInstanceOf(HIf* ifInstruction, HInstruction* input = ifInstruction->InputAt(0); if (input->IsEqual()) { - // TODO: Remove "OrNull". - HInstruction* rhs = input->AsEqualOrNull()->GetConstantRight(); + HInstruction* rhs = input->AsEqual()->GetConstantRight(); if (rhs != nullptr) { - // TODO: Remove "OrNull". - HInstruction* lhs = input->AsEqualOrNull()->GetLeastConstantLeft(); + HInstruction* lhs = input->AsEqual()->GetLeastConstantLeft(); if (lhs->IsInstanceOf() && rhs->IsIntConstant()) { - // TODO: Remove "OrNull". - if (rhs->AsIntConstantOrNull()->IsTrue()) { + if (rhs->AsIntConstant()->IsTrue()) { // Case (1a) *trueBranch = ifInstruction->IfTrueSuccessor(); - // TODO: Remove "OrNull". - } else if (rhs->AsIntConstantOrNull()->IsFalse()) { + } else if (rhs->AsIntConstant()->IsFalse()) { // Case (2a) *trueBranch = ifInstruction->IfFalseSuccessor(); } else { @@ -416,24 +406,19 @@ static bool MatchIfInstanceOf(HIf* ifInstruction, // In those cases, we cannot do the match if+instance-of. return false; } - // TODO: Remove "OrNull". - *instanceOf = lhs->AsInstanceOfOrNull(); + *instanceOf = lhs->AsInstanceOf(); return true; } } } else if (input->IsNotEqual()) { - // TODO: Remove "OrNull". - HInstruction* rhs = input->AsNotEqualOrNull()->GetConstantRight(); + HInstruction* rhs = input->AsNotEqual()->GetConstantRight(); if (rhs != nullptr) { - // TODO: Remove "OrNull". - HInstruction* lhs = input->AsNotEqualOrNull()->GetLeastConstantLeft(); + HInstruction* lhs = input->AsNotEqual()->GetLeastConstantLeft(); if (lhs->IsInstanceOf() && rhs->IsIntConstant()) { - // TODO: Remove "OrNull". - if (rhs->AsIntConstantOrNull()->IsFalse()) { + if (rhs->AsIntConstant()->IsFalse()) { // Case (1b) *trueBranch = ifInstruction->IfTrueSuccessor(); - // TODO: Remove "OrNull". - } else if (rhs->AsIntConstantOrNull()->IsTrue()) { + } else if (rhs->AsIntConstant()->IsTrue()) { // Case (2b) *trueBranch = ifInstruction->IfFalseSuccessor(); } else { @@ -441,23 +426,20 @@ static bool MatchIfInstanceOf(HIf* ifInstruction, // In those cases, we cannot do the match if+instance-of. return false; } - // TODO: Remove "OrNull". - *instanceOf = lhs->AsInstanceOfOrNull(); + *instanceOf = lhs->AsInstanceOf(); return true; } } } else if (input->IsInstanceOf()) { // Case (1c) - // TODO: Remove "OrNull". - *instanceOf = input->AsInstanceOfOrNull(); + *instanceOf = input->AsInstanceOf(); *trueBranch = ifInstruction->IfTrueSuccessor(); return true; } else if (input->IsBooleanNot()) { HInstruction* not_input = input->InputAt(0); if (not_input->IsInstanceOf()) { // Case (2c) - // TODO: Remove "OrNull". - *instanceOf = not_input->AsInstanceOfOrNull(); + *instanceOf = not_input->AsInstanceOf(); *trueBranch = ifInstruction->IfFalseSuccessor(); return true; } @@ -512,12 +494,10 @@ void ReferenceTypePropagation::RTPVisitor::BoundTypeForIfInstanceOf(HBasicBlock* void ReferenceTypePropagation::RTPVisitor::SetClassAsTypeInfo(HInstruction* instr, ObjPtr klass, bool is_exact) { - // TODO: Remove "OrNull". - if (instr->IsInvokeStaticOrDirect() && instr->AsInvokeStaticOrDirectOrNull()->IsStringInit()) { + if (instr->IsInvokeStaticOrDirect() && instr->AsInvokeStaticOrDirect()->IsStringInit()) { // Calls to String. are replaced with a StringFactory. if (kIsDebugBuild) { - // TODO: Remove "OrNull". - HInvokeStaticOrDirect* invoke = instr->AsInvokeStaticOrDirectOrNull(); + HInvokeStaticOrDirect* invoke = instr->AsInvokeStaticOrDirect(); ClassLinker* cl = Runtime::Current()->GetClassLinker(); Thread* self = Thread::Current(); StackHandleScope<2> hs(self); @@ -779,8 +759,7 @@ void ReferenceTypePropagation::FixUpInstructionType(HInstruction* instruction, HandleCache* handle_cache) { if (instruction->IsSelect()) { ScopedObjectAccess soa(Thread::Current()); - // TODO: Remove "OrNull". - HSelect* select = instruction->AsSelectOrNull(); + HSelect* select = instruction->AsSelect(); ReferenceTypeInfo false_rti = select->GetFalseValue()->GetReferenceTypeInfo(); ReferenceTypeInfo true_rti = select->GetTrueValue()->GetReferenceTypeInfo(); select->SetReferenceTypeInfo(MergeTypes(false_rti, true_rti, handle_cache)); @@ -858,11 +837,9 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateReferenceTypeInfo(HInstruction* ReferenceTypeInfo previous_rti = instr->GetReferenceTypeInfo(); if (instr->IsBoundType()) { - // TODO: Remove "OrNull". - UpdateBoundType(instr->AsBoundTypeOrNull()); + UpdateBoundType(instr->AsBoundType()); } else if (instr->IsPhi()) { - // TODO: Remove "OrNull". - UpdatePhi(instr->AsPhiOrNull()); + UpdatePhi(instr->AsPhi()); } else if (instr->IsNullCheck()) { ReferenceTypeInfo parent_rti = instr->InputAt(0)->GetReferenceTypeInfo(); if (parent_rti.IsValid()) { @@ -871,8 +848,7 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateReferenceTypeInfo(HInstruction* } else if (instr->IsArrayGet()) { // TODO: consider if it's worth "looking back" and binding the input object // to an array type. - // TODO: Remove "OrNull". - UpdateArrayGet(instr->AsArrayGetOrNull()); + UpdateArrayGet(instr->AsArrayGet()); } else { LOG(FATAL) << "Invalid instruction (should not get here)"; } @@ -973,8 +949,7 @@ void ReferenceTypePropagation::RTPVisitor::UpdatePhi(HPhi* instr) { } constexpr bool ReferenceTypePropagation::RTPVisitor::IsUpdateable(const HInstruction* instr) { - // TODO: Remove "OrNull". - return (instr->IsPhi() && instr->AsPhiOrNull()->IsLive()) || + return (instr->IsPhi() && instr->AsPhi()->IsLive()) || instr->IsBoundType() || instr->IsNullCheck() || instr->IsArrayGet(); @@ -991,8 +966,7 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateNullability(HInstruction* instr bool existing_can_be_null = instr->CanBeNull(); if (instr->IsPhi()) { - // TODO: Remove "OrNull". - HPhi* phi = instr->AsPhiOrNull(); + HPhi* phi = instr->AsPhi(); bool new_can_be_null = false; for (HInstruction* input : phi->GetInputs()) { if (input->CanBeNull()) { @@ -1002,8 +976,7 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateNullability(HInstruction* instr } phi->SetCanBeNull(new_can_be_null); } else if (instr->IsBoundType()) { - // TODO: Remove "OrNull". - HBoundType* bound_type = instr->AsBoundTypeOrNull(); + HBoundType* bound_type = instr->AsBoundType(); bound_type->SetCanBeNull(instr->InputAt(0)->CanBeNull() && bound_type->GetUpperCanBeNull()); } return existing_can_be_null != instr->CanBeNull(); @@ -1031,8 +1004,7 @@ void ReferenceTypePropagation::RTPVisitor::AddDependentInstructionsToWorklist( HInstruction* instruction) { for (const HUseListNode& use : instruction->GetUses()) { HInstruction* user = use.GetUser(); - // TODO: Remove "OrNull". - if ((user->IsPhi() && user->AsPhiOrNull()->IsLive()) + if ((user->IsPhi() && user->AsPhi()->IsLive()) || user->IsBoundType() || user->IsNullCheck() || (user->IsArrayGet() && (user->GetType() == DataType::Type::kReference))) { diff --git a/compiler/optimizing/reference_type_propagation_test.cc b/compiler/optimizing/reference_type_propagation_test.cc index 5211e09a38..2b012fcd67 100644 --- a/compiler/optimizing/reference_type_propagation_test.cc +++ b/compiler/optimizing/reference_type_propagation_test.cc @@ -333,8 +333,7 @@ void LoopReferenceTypePropagationTestGroup::RunVisitListTest(Func mutator) { } for (HBasicBlock* blk : succ_blocks) { CHECK(single_value[blk]->IsPhi()) << blk->GetBlockId(); - // TODO: Remove "OrNull". - blk->AddPhi(single_value[blk]->AsPhiOrNull()); + blk->AddPhi(single_value[blk]->AsPhi()); } auto vals = MakeTransformRange(succ_blocks, [&](HBasicBlock* blk) { DCHECK(single_value[blk]->IsPhi()); @@ -422,8 +421,7 @@ void NonLoopReferenceTypePropagationTestGroup::RunVisitListTest(Func mutator) { for (const auto& [pred, index] : ZipCount(MakeIterationRange(blk->GetPredecessors()))) { my_val->SetRawInputAt(index, single_value[pred]); } - // TODO: Remove "OrNull". - blk->AddPhi(my_val->AsPhiOrNull()); + blk->AddPhi(my_val->AsPhi()); } auto vals = MakeTransformRange(succ_blocks, [&](HBasicBlock* blk) { return single_value[blk]; }); std::vector ins(vals.begin(), vals.end()); @@ -487,15 +485,13 @@ TEST_P(LoopReferenceTypePropagationTestGroup, RunVisitTest) { return uid(g); } }; - // TODO: Remove "OrNull". - HPhi* nulled_phi = lo.null_insertion_ >= 0 ? lst[lo.null_insertion_]->AsPhiOrNull() : nullptr; + HPhi* nulled_phi = lo.null_insertion_ >= 0 ? lst[lo.null_insertion_]->AsPhi() : nullptr; if (nulled_phi != nullptr) { nulled_phi->ReplaceInput(null_input, lo.null_phi_arg_); } MutateList(lst, lo.shuffle_); std::for_each(lst.begin(), lst.end(), [&](HInstruction* ins) { - // TODO: Remove "OrNull". - ins->AsPhiOrNull()->SetCanBeNull(next_null()); + ins->AsPhi()->SetCanBeNull(next_null()); }); }); } diff --git a/compiler/optimizing/register_allocation_resolver.cc b/compiler/optimizing/register_allocation_resolver.cc index 969a2733b1..a4b1698b8d 100644 --- a/compiler/optimizing/register_allocation_resolver.cc +++ b/compiler/optimizing/register_allocation_resolver.cc @@ -76,8 +76,7 @@ void RegisterAllocationResolver::Resolve(ArrayRef safepoint } else if (instruction->IsCurrentMethod()) { // The current method is always at offset 0. DCHECK_IMPLIES(current->HasSpillSlot(), (current->GetSpillSlot() == 0)); - // TODO: Remove "OrNull". - } else if (instruction->IsPhi() && instruction->AsPhiOrNull()->IsCatchPhi()) { + } else if (instruction->IsPhi() && instruction->AsPhi()->IsCatchPhi()) { DCHECK(current->HasSpillSlot()); size_t slot = current->GetSpillSlot() + spill_slots @@ -352,8 +351,7 @@ void RegisterAllocationResolver::ConnectSiblings(LiveInterval* interval) { } } else { DCHECK(use.GetUser()->IsInvoke()); - // TODO: Remove "OrNull". - DCHECK(use.GetUser()->AsInvokeOrNull()->GetIntrinsic() != Intrinsics::kNone); + DCHECK(use.GetUser()->AsInvoke()->GetIntrinsic() != Intrinsics::kNone); } } } @@ -540,8 +538,7 @@ void RegisterAllocationResolver::AddInputMoveFor(HInstruction* input, move->SetLifetimePosition(user->GetLifetimePosition()); user->GetBlock()->InsertInstructionBefore(move, user); } else { - // TODO: Remove "OrNull". - move = previous->AsParallelMoveOrNull(); + move = previous->AsParallelMove(); } DCHECK_EQ(move->GetLifetimePosition(), user->GetLifetimePosition()); AddMove(move, source, destination, nullptr, input->GetType()); @@ -590,8 +587,7 @@ void RegisterAllocationResolver::InsertParallelMoveAt(size_t position, at->GetBlock()->InsertInstructionBefore(move, at); } else { DCHECK(at->IsParallelMove()); - // TODO: Remove "OrNull". - move = at->AsParallelMoveOrNull(); + move = at->AsParallelMove(); } } } else if (IsInstructionEnd(position)) { @@ -621,8 +617,7 @@ void RegisterAllocationResolver::InsertParallelMoveAt(size_t position, move->SetLifetimePosition(position); at->GetBlock()->InsertInstructionBefore(move, at); } else { - // TODO: Remove "OrNull". - move = previous->AsParallelMoveOrNull(); + move = previous->AsParallelMove(); } } DCHECK_EQ(move->GetLifetimePosition(), position); @@ -650,14 +645,12 @@ void RegisterAllocationResolver::InsertParallelMoveAtExitOf(HBasicBlock* block, size_t position = last->GetLifetimePosition(); if (previous == nullptr || !previous->IsParallelMove() || - // TODO: Remove "OrNull". - previous->AsParallelMoveOrNull()->GetLifetimePosition() != position) { + previous->AsParallelMove()->GetLifetimePosition() != position) { move = new (allocator_) HParallelMove(allocator_); move->SetLifetimePosition(position); block->InsertInstructionBefore(move, last); } else { - // TODO: Remove "OrNull". - move = previous->AsParallelMoveOrNull(); + move = previous->AsParallelMove(); } AddMove(move, source, destination, instruction, instruction->GetType()); } diff --git a/compiler/optimizing/register_allocator_graph_color.cc b/compiler/optimizing/register_allocator_graph_color.cc index 8b96f32ef7..a7c891d4e7 100644 --- a/compiler/optimizing/register_allocator_graph_color.cc +++ b/compiler/optimizing/register_allocator_graph_color.cc @@ -1044,16 +1044,13 @@ void RegisterAllocatorGraphColor::SplitAtRegisterUses(LiveInterval* interval) { } void RegisterAllocatorGraphColor::AllocateSpillSlotForCatchPhi(HInstruction* instruction) { - // TODO: Remove "OrNull". - if (instruction->IsPhi() && instruction->AsPhiOrNull()->IsCatchPhi()) { - // TODO: Remove "OrNull". - HPhi* phi = instruction->AsPhiOrNull(); + if (instruction->IsPhi() && instruction->AsPhi()->IsCatchPhi()) { + HPhi* phi = instruction->AsPhi(); LiveInterval* interval = phi->GetLiveInterval(); HInstruction* previous_phi = phi->GetPrevious(); DCHECK(previous_phi == nullptr || - // TODO: Remove "OrNull". - previous_phi->AsPhiOrNull()->GetRegNumber() <= phi->GetRegNumber()) + previous_phi->AsPhi()->GetRegNumber() <= phi->GetRegNumber()) << "Phis expected to be sorted by vreg number, " << "so that equivalent phis are adjacent."; @@ -1956,8 +1953,7 @@ void RegisterAllocatorGraphColor::AllocateSpillSlots(ArrayRefIsParameterValue()) { // Parameters already have a stack slot. - // TODO: Remove "OrNull". - parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValueOrNull())); + parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValue())); } else if (defined_by->IsCurrentMethod()) { // The current method is always at stack slot 0. parent->SetSpillSlot(0); diff --git a/compiler/optimizing/register_allocator_linear_scan.cc b/compiler/optimizing/register_allocator_linear_scan.cc index cbb9002c46..ffa9937cc5 100644 --- a/compiler/optimizing/register_allocator_linear_scan.cc +++ b/compiler/optimizing/register_allocator_linear_scan.cc @@ -259,10 +259,8 @@ void RegisterAllocatorLinearScan::ProcessInstruction(HInstruction* instruction) current->ResetSearchCache(); CheckForFixedOutput(instruction); - // TODO: Remove "OrNull". - if (instruction->IsPhi() && instruction->AsPhiOrNull()->IsCatchPhi()) { - // TODO: Remove "OrNull". - AllocateSpillSlotForCatchPhi(instruction->AsPhiOrNull()); + if (instruction->IsPhi() && instruction->AsPhi()->IsCatchPhi()) { + AllocateSpillSlotForCatchPhi(instruction->AsPhi()); } // If needed, add interval to the list of unhandled intervals. @@ -1130,13 +1128,11 @@ void RegisterAllocatorLinearScan::AllocateSpillSlotFor(LiveInterval* interval) { } HInstruction* defined_by = parent->GetDefinedBy(); - // TODO: Remove "OrNull". - DCHECK_IMPLIES(defined_by->IsPhi(), !defined_by->AsPhiOrNull()->IsCatchPhi()); + DCHECK_IMPLIES(defined_by->IsPhi(), !defined_by->AsPhi()->IsCatchPhi()); if (defined_by->IsParameterValue()) { // Parameters have their own stack slot. - // TODO: Remove "OrNull". - parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValueOrNull())); + parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValue())); return; } @@ -1212,9 +1208,7 @@ void RegisterAllocatorLinearScan::AllocateSpillSlotForCatchPhi(HPhi* phi) { LiveInterval* interval = phi->GetLiveInterval(); HInstruction* previous_phi = phi->GetPrevious(); - DCHECK(previous_phi == nullptr || - // TODO: Remove "OrNull". - previous_phi->AsPhiOrNull()->GetRegNumber() <= phi->GetRegNumber()) + DCHECK(previous_phi == nullptr || previous_phi->AsPhi()->GetRegNumber() <= phi->GetRegNumber()) << "Phis expected to be sorted by vreg number, so that equivalent phis are adjacent."; if (phi->IsVRegEquivalentOf(previous_phi)) { diff --git a/compiler/optimizing/register_allocator_test.cc b/compiler/optimizing/register_allocator_test.cc index a123bf858e..d316aa5dc2 100644 --- a/compiler/optimizing/register_allocator_test.cc +++ b/compiler/optimizing/register_allocator_test.cc @@ -338,8 +338,7 @@ void RegisterAllocatorTest::Loop3(Strategy strategy) { ASSERT_TRUE(register_allocator->Validate(false)); HBasicBlock* loop_header = graph->GetBlocks()[2]; - // TODO: Remove "OrNull". - HPhi* phi = loop_header->GetFirstPhi()->AsPhiOrNull(); + HPhi* phi = loop_header->GetFirstPhi()->AsPhi(); LiveInterval* phi_interval = phi->GetLiveInterval(); LiveInterval* loop_update = phi->InputAt(1)->GetLiveInterval(); @@ -348,8 +347,7 @@ void RegisterAllocatorTest::Loop3(Strategy strategy) { ASSERT_NE(phi_interval->GetRegister(), loop_update->GetRegister()); HBasicBlock* return_block = graph->GetBlocks()[3]; - // TODO: Remove "OrNull". - HReturn* ret = return_block->GetLastInstruction()->AsReturnOrNull(); + HReturn* ret = return_block->GetLastInstruction()->AsReturn(); ASSERT_EQ(phi_interval->GetRegister(), ret->InputAt(0)->GetLiveInterval()->GetRegister()); } @@ -368,10 +366,8 @@ TEST_F(RegisterAllocatorTest, FirstRegisterUse) { SsaLivenessAnalysis liveness(graph, &codegen, GetScopedAllocator()); liveness.Analyze(); - // TODO: Remove "OrNull". - HXor* first_xor = graph->GetBlocks()[1]->GetFirstInstruction()->AsXorOrNull(); - // TODO: Remove "OrNull". - HXor* last_xor = graph->GetBlocks()[1]->GetLastInstruction()->GetPrevious()->AsXorOrNull(); + HXor* first_xor = graph->GetBlocks()[1]->GetFirstInstruction()->AsXor(); + HXor* last_xor = graph->GetBlocks()[1]->GetLastInstruction()->GetPrevious()->AsXor(); ASSERT_EQ(last_xor->InputAt(0), first_xor); LiveInterval* interval = first_xor->GetLiveInterval(); ASSERT_EQ(interval->GetEnd(), last_xor->GetLifetimePosition()); diff --git a/compiler/optimizing/scheduler.cc b/compiler/optimizing/scheduler.cc index 299418adfe..1cdc98a8be 100644 --- a/compiler/optimizing/scheduler.cc +++ b/compiler/optimizing/scheduler.cc @@ -150,8 +150,7 @@ size_t SideEffectDependencyAnalysis::MemoryDependencyAnalysis::FieldAccessHeapLo DCHECK(heap_location_collector_ != nullptr); HInstruction* ref = instr->IsPredicatedInstanceFieldGet() - // TODO: Remove "OrNull". - ? instr->AsPredicatedInstanceFieldGetOrNull()->GetTarget() + ? instr->AsPredicatedInstanceFieldGet()->GetTarget() : instr->InputAt(0); size_t heap_loc = heap_location_collector_->GetFieldHeapLocation(ref, GetFieldInfo(instr)); // This field access should be analyzed and added to HeapLocationCollector before. @@ -491,11 +490,9 @@ SchedulingNode* CriticalPathSchedulingNodeSelector::SelectMaterializedCondition( DCHECK(instruction != nullptr); if (instruction->IsIf()) { - // TODO: Remove first "OrNull", keep the second. - condition = instruction->AsIfOrNull()->InputAt(0)->AsConditionOrNull(); + condition = instruction->AsIf()->InputAt(0)->AsConditionOrNull(); } else if (instruction->IsSelect()) { - // TODO: Remove first "OrNull", keep the second. - condition = instruction->AsSelectOrNull()->GetCondition()->AsConditionOrNull(); + condition = instruction->AsSelect()->GetCondition()->AsConditionOrNull(); } SchedulingNode* condition_node = (condition != nullptr) ? graph.GetNode(condition) : nullptr; @@ -736,15 +733,10 @@ bool HScheduler::IsSchedulable(const HInstruction* instruction) const { instruction->IsClassTableGet() || instruction->IsCurrentMethod() || instruction->IsDivZeroCheck() || - (instruction->IsInstanceFieldGet() && - // TODO: Remove "OrNull". - !instruction->AsInstanceFieldGetOrNull()->IsVolatile()) || + (instruction->IsInstanceFieldGet() && !instruction->AsInstanceFieldGet()->IsVolatile()) || (instruction->IsPredicatedInstanceFieldGet() && - // TODO: Remove "OrNull". - !instruction->AsPredicatedInstanceFieldGetOrNull()->IsVolatile()) || - (instruction->IsInstanceFieldSet() && - // TODO: Remove "OrNull". - !instruction->AsInstanceFieldSetOrNull()->IsVolatile()) || + !instruction->AsPredicatedInstanceFieldGet()->IsVolatile()) || + (instruction->IsInstanceFieldSet() && !instruction->AsInstanceFieldSet()->IsVolatile()) || instruction->IsInstanceOf() || instruction->IsInvokeInterface() || instruction->IsInvokeStaticOrDirect() || @@ -760,12 +752,8 @@ bool HScheduler::IsSchedulable(const HInstruction* instruction) const { instruction->IsReturn() || instruction->IsReturnVoid() || instruction->IsSelect() || - (instruction->IsStaticFieldGet() && - // TODO: Remove "OrNull". - !instruction->AsStaticFieldGetOrNull()->IsVolatile()) || - (instruction->IsStaticFieldSet() && - // TODO: Remove "OrNull". - !instruction->AsStaticFieldSetOrNull()->IsVolatile()) || + (instruction->IsStaticFieldGet() && !instruction->AsStaticFieldGet()->IsVolatile()) || + (instruction->IsStaticFieldSet() && !instruction->AsStaticFieldSet()->IsVolatile()) || instruction->IsSuspendCheck() || instruction->IsTypeConversion(); } diff --git a/compiler/optimizing/scheduler_arm.cc b/compiler/optimizing/scheduler_arm.cc index cded09ac67..3f931c4c49 100644 --- a/compiler/optimizing/scheduler_arm.cc +++ b/compiler/optimizing/scheduler_arm.cc @@ -109,8 +109,7 @@ void SchedulingLatencyVisitorARM::VisitRor(HRor* instr) { // HandleLongRotate HInstruction* rhs = instr->GetRight(); if (rhs->IsConstant()) { - // TODO: Remove "OrNull". - uint64_t rot = Uint64ConstantFrom(rhs->AsConstantOrNull()) & kMaxLongShiftDistance; + uint64_t rot = Uint64ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance; if (rot != 0u) { last_visited_internal_latency_ = 3 * kArmIntegerOpLatency; last_visited_latency_ = kArmIntegerOpLatency; @@ -144,8 +143,7 @@ void SchedulingLatencyVisitorARM::HandleShiftLatencies(HBinaryOperation* instr) if (!rhs->IsConstant()) { last_visited_internal_latency_ = 8 * kArmIntegerOpLatency; } else { - // TODO: Remove "OrNull". - uint32_t shift_value = Int32ConstantFrom(rhs->AsConstantOrNull()) & kMaxLongShiftDistance; + uint32_t shift_value = Int32ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance; if (shift_value == 1 || shift_value >= 32) { last_visited_internal_latency_ = kArmIntegerOpLatency; } else { @@ -835,8 +833,7 @@ void SchedulingLatencyVisitorARM::VisitDiv(HDiv* instruction) { case DataType::Type::kInt32: { HInstruction* rhs = instruction->GetRight(); if (rhs->IsConstant()) { - // TODO: Remove "OrNull". - int32_t imm = Int32ConstantFrom(rhs->AsConstantOrNull()); + int32_t imm = Int32ConstantFrom(rhs->AsConstant()); HandleDivRemConstantIntegralLatencies(imm); } else { last_visited_latency_ = kArmDivIntegerLatency; @@ -904,8 +901,7 @@ void SchedulingLatencyVisitorARM::VisitRem(HRem* instruction) { case DataType::Type::kInt32: { HInstruction* rhs = instruction->GetRight(); if (rhs->IsConstant()) { - // TODO: Remove "OrNull". - int32_t imm = Int32ConstantFrom(rhs->AsConstantOrNull()); + int32_t imm = Int32ConstantFrom(rhs->AsConstant()); HandleDivRemConstantIntegralLatencies(imm); } else { last_visited_internal_latency_ = kArmDivIntegerLatency; diff --git a/compiler/optimizing/scheduler_arm64.cc b/compiler/optimizing/scheduler_arm64.cc index 0c178f6d6e..3071afd951 100644 --- a/compiler/optimizing/scheduler_arm64.cc +++ b/compiler/optimizing/scheduler_arm64.cc @@ -91,8 +91,7 @@ void SchedulingLatencyVisitorARM64::VisitDiv(HDiv* instr) { default: // Follow the code path used by code generation. if (instr->GetRight()->IsConstant()) { - // TODO: Remove "OrNull". - int64_t imm = Int64FromConstant(instr->GetRight()->AsConstantOrNull()); + int64_t imm = Int64FromConstant(instr->GetRight()->AsConstant()); if (imm == 0) { last_visited_internal_latency_ = 0; last_visited_latency_ = 0; @@ -160,8 +159,7 @@ void SchedulingLatencyVisitorARM64::VisitRem(HRem* instruction) { } else { // Follow the code path used by code generation. if (instruction->GetRight()->IsConstant()) { - // TODO: Remove "OrNull". - int64_t imm = Int64FromConstant(instruction->GetRight()->AsConstantOrNull()); + int64_t imm = Int64FromConstant(instruction->GetRight()->AsConstant()); if (imm == 0) { last_visited_internal_latency_ = 0; last_visited_latency_ = 0; diff --git a/compiler/optimizing/select_generator.cc b/compiler/optimizing/select_generator.cc index 54eac54c01..07065efbb7 100644 --- a/compiler/optimizing/select_generator.cc +++ b/compiler/optimizing/select_generator.cc @@ -46,9 +46,7 @@ static bool IsSimpleBlock(HBasicBlock* block) { } else if (instruction->CanBeMoved() && !instruction->HasSideEffects() && !instruction->CanThrow()) { - if (instruction->IsSelect() && - // TODO: Remove "OrNull". - instruction->AsSelectOrNull()->GetCondition()->GetBlock() == block) { + if (instruction->IsSelect() && instruction->AsSelect()->GetCondition()->GetBlock() == block) { // Count one HCondition and HSelect in the same block as a single instruction. // This enables finding nested selects. continue; @@ -77,8 +75,7 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) { HPhi* select_phi = nullptr; for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); if (select_phi == nullptr) { // First phi found. select_phi = phi; @@ -93,8 +90,7 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) { bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( HBasicBlock* block, ScopedArenaSafeMap* cache) { DCHECK(block->GetLastInstruction()->IsIf()); - // TODO: Remove "OrNull". - HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instruction = block->GetLastInstruction()->AsIf(); HBasicBlock* true_block = if_instruction->IfTrueSuccessor(); HBasicBlock* false_block = if_instruction->IfFalseSuccessor(); DCHECK_NE(true_block, false_block); @@ -220,8 +216,7 @@ bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern( HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) { DCHECK(block->GetLastInstruction()->IsIf()); - // TODO: Remove "OrNull". - HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull(); + HIf* if_instruction = block->GetLastInstruction()->AsIf(); HBasicBlock* true_block = if_instruction->IfTrueSuccessor(); HBasicBlock* false_block = if_instruction->IfFalseSuccessor(); DCHECK_NE(true_block, false_block); @@ -236,8 +231,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) // The innner if branch has to be a block with just a comparison and an if. if (!inner_if_block->EndsWithIf() || - // TODO: Remove "OrNull". - inner_if_block->GetLastInstruction()->AsIfOrNull()->InputAt(0) != + inner_if_block->GetLastInstruction()->AsIf()->InputAt(0) != inner_if_block->GetFirstInstruction() || inner_if_block->GetLastInstruction()->GetPrevious() != inner_if_block->GetFirstInstruction() || @@ -245,8 +239,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) return nullptr; } - // TODO: Remove "OrNull". - HIf* inner_if_instruction = inner_if_block->GetLastInstruction()->AsIfOrNull(); + HIf* inner_if_instruction = inner_if_block->GetLastInstruction()->AsIf(); HBasicBlock* inner_if_true_block = inner_if_instruction->IfTrueSuccessor(); HBasicBlock* inner_if_false_block = inner_if_instruction->IfFalseSuccessor(); if (!inner_if_true_block->IsSingleGoto() || !inner_if_false_block->IsSingleGoto()) { @@ -269,8 +262,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) return nullptr; } - // TODO: Remove "OrNull". - HPhi* first_phi = first_merge->GetFirstPhi()->AsPhiOrNull(); + HPhi* first_phi = first_merge->GetFirstPhi()->AsPhi(); // Second merge is first_merge and the remainder branch merging. It must be phi + goto, or phi + // return. Depending on the first merge, we define the second merge. @@ -292,8 +284,7 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) } size_t index = second_merge->GetPredecessorIndexOf(merges_into_second_merge); - // TODO: Remove "OrNull". - HPhi* second_phi = second_merge->GetFirstPhi()->AsPhiOrNull(); + HPhi* second_phi = second_merge->GetFirstPhi()->AsPhi(); // Merge the phis. first_phi->AddInput(second_phi->InputAt(index)); diff --git a/compiler/optimizing/ssa_builder.cc b/compiler/optimizing/ssa_builder.cc index 09ca850eee..2179bf50b5 100644 --- a/compiler/optimizing/ssa_builder.cc +++ b/compiler/optimizing/ssa_builder.cc @@ -56,8 +56,7 @@ void SsaBuilder::FixNullConstantType() { // Both type propagation and redundant phi elimination ensure `int_operand` // can only be the 0 constant. DCHECK(int_operand->IsIntConstant()) << int_operand->DebugName(); - // TODO: Remove "OrNull". - DCHECK_EQ(0, int_operand->AsIntConstantOrNull()->GetValue()); + DCHECK_EQ(0, int_operand->AsIntConstant()->GetValue()); equality_instr->ReplaceInput(graph_->GetNullConstant(), int_operand == right ? 1 : 0); } } @@ -67,8 +66,7 @@ void SsaBuilder::EquivalentPhisCleanup() { // The order doesn't matter here. for (HBasicBlock* block : graph_->GetReversePostOrder()) { for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it.Current()->AsPhiOrNull(); + HPhi* phi = it.Current()->AsPhi(); HPhi* next = phi->GetNextEquivalentPhiWithSameType(); if (next != nullptr) { // Make sure we do not replace a live phi with a dead phi. A live phi @@ -90,21 +88,18 @@ void SsaBuilder::EquivalentPhisCleanup() { void SsaBuilder::FixEnvironmentPhis() { for (HBasicBlock* block : graph_->GetReversePostOrder()) { for (HInstructionIterator it_phis(block->GetPhis()); !it_phis.Done(); it_phis.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = it_phis.Current()->AsPhiOrNull(); + HPhi* phi = it_phis.Current()->AsPhi(); // If the phi is not dead, or has no environment uses, there is nothing to do. if (!phi->IsDead() || !phi->HasEnvironmentUses()) continue; HInstruction* next = phi->GetNext(); if (!phi->IsVRegEquivalentOf(next)) continue; - // TODO: Remove "OrNull". - if (next->AsPhiOrNull()->IsDead()) { + if (next->AsPhi()->IsDead()) { // If the phi equivalent is dead, check if there is another one. next = next->GetNext(); if (!phi->IsVRegEquivalentOf(next)) continue; // There can be at most two phi equivalents. DCHECK(!phi->IsVRegEquivalentOf(next->GetNext())); - // TODO: Remove "OrNull". - if (next->AsPhiOrNull()->IsDead()) continue; + if (next->AsPhi()->IsDead()) continue; } // We found a live phi equivalent. Update the environment uses of `phi` with it. phi->ReplaceWith(next); @@ -118,15 +113,12 @@ static void AddDependentInstructionsToWorklist(HInstruction* instruction, // live phi users, and transitively users of those users, therefore need to be // marked dead/conflicting too, so we add them to the worklist. Otherwise we // add users whose type does not match and needs to be updated. - // TODO: Remove "OrNull". - bool add_all_live_phis = instruction->IsPhi() && instruction->AsPhiOrNull()->IsDead(); + bool add_all_live_phis = instruction->IsPhi() && instruction->AsPhi()->IsDead(); for (const HUseListNode& use : instruction->GetUses()) { HInstruction* user = use.GetUser(); - // TODO: Remove "OrNull". - if (user->IsPhi() && user->AsPhiOrNull()->IsLive()) { + if (user->IsPhi() && user->AsPhi()->IsLive()) { if (add_all_live_phis || user->GetType() != instruction->GetType()) { - // TODO: Remove "OrNull". - worklist->push_back(user->AsPhiOrNull()); + worklist->push_back(user->AsPhi()); } } } @@ -138,8 +130,7 @@ static bool TypePhiFromInputs(HPhi* phi) { DataType::Type common_type = phi->GetType(); for (HInstruction* input : phi->GetInputs()) { - // TODO: Remove "OrNull". - if (input->IsPhi() && input->AsPhiOrNull()->IsDead()) { + if (input->IsPhi() && input->AsPhi()->IsDead()) { // Phis are constructed live so if an input is a dead phi, it must have // been made dead due to type conflict. Mark this phi conflicting too. return false; @@ -213,8 +204,7 @@ bool SsaBuilder::TypeInputsOfPhi(HPhi* phi, ScopedArenaVector* worklist) phi->ReplaceInput(equivalent, i); if (equivalent->IsPhi()) { - // TODO: Remove "OrNull". - worklist->push_back(equivalent->AsPhiOrNull()); + worklist->push_back(equivalent->AsPhi()); } } } @@ -251,8 +241,7 @@ void SsaBuilder::RunPrimitiveTypePropagation() { for (HBasicBlock* block : graph_->GetReversePostOrder()) { if (block->IsLoopHeader()) { for (HInstructionIterator phi_it(block->GetPhis()); !phi_it.Done(); phi_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = phi_it.Current()->AsPhiOrNull(); + HPhi* phi = phi_it.Current()->AsPhi(); if (phi->IsLive()) { worklist.push_back(phi); } @@ -264,8 +253,7 @@ void SsaBuilder::RunPrimitiveTypePropagation() { // doing a reverse post-order visit, therefore either the phi users are // non-loop phi and will be visited later in the visit, or are loop-phis, // and they are already in the work list. - // TODO: Remove "OrNull". - HPhi* phi = phi_it.Current()->AsPhiOrNull(); + HPhi* phi = phi_it.Current()->AsPhi(); if (phi->IsLive()) { UpdatePrimitiveType(phi, &worklist); } @@ -295,8 +283,7 @@ static HArrayGet* FindFloatOrDoubleEquivalentOfArrayGet(HArrayGet* aget) { DCHECK(DataType::IsIntOrLongType(type)); HInstruction* next = aget->GetNext(); if (next != nullptr && next->IsArrayGet()) { - // TODO: Remove "OrNull". - HArrayGet* next_aget = next->AsArrayGetOrNull(); + HArrayGet* next_aget = next->AsArrayGet(); if (next_aget->IsEquivalentOf(aget)) { return next_aget; } @@ -408,8 +395,7 @@ bool SsaBuilder::FixAmbiguousArrayOps() { if (equivalent->IsPhi()) { // Returned equivalent is a phi which may not have had its inputs // replaced yet. We need to run primitive type propagation on it. - // TODO: Remove "OrNull". - worklist.push_back(equivalent->AsPhiOrNull()); + worklist.push_back(equivalent->AsPhi()); } } // Refine the side effects of this floating point aset. Note that we do this even if @@ -456,8 +442,7 @@ bool SsaBuilder::ReplaceUninitializedStringPhis() { return false; } DCHECK(str->IsNewInstance()); - // TODO: Remove "OrNull". - AddUninitializedString(str->AsNewInstanceOrNull()); + AddUninitializedString(str->AsNewInstance()); str->ReplaceUsesDominatedBy(invoke, invoke); str->ReplaceEnvUsesDominatedBy(invoke, invoke); invoke->RemoveInputAt(invoke->InputCount() - 1); @@ -493,13 +478,11 @@ void SsaBuilder::RemoveRedundantUninitializedStrings() { // class is always initialized at the point of running Java code, we can remove // that check. if (input->IsClinitCheck()) { - // TODO: Remove "OrNull". - load_class = input->InputAt(0)->AsLoadClassOrNull(); + load_class = input->InputAt(0)->AsLoadClass(); input->ReplaceWith(load_class); input->GetBlock()->RemoveInstruction(input); } else { - // TODO: Remove "OrNull". - load_class = input->AsLoadClassOrNull(); + load_class = input->AsLoadClass(); DCHECK(new_instance->IsStringAlloc()); DCHECK(!load_class->NeedsAccessCheck()) << "String class is always accessible"; } @@ -520,8 +503,7 @@ static bool HasPhiEquivalentAtLoopEntry(HGraph* graph) { for (HBasicBlock* block : graph->GetReversePostOrder()) { if (block->IsLoopHeader()) { for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - if (it.Current()->AsPhiOrNull()->HasEquivalentPhi()) { + if (it.Current()->AsPhi()->HasEquivalentPhi()) { return true; } } @@ -671,16 +653,14 @@ HPhi* SsaBuilder::GetFloatDoubleOrReferenceEquivalentOfPhi(HPhi* phi, DataType:: // We place the floating point /reference phi next to this phi. HInstruction* next = phi->GetNext(); if (next != nullptr && - // TODO: Remove "OrNull". - next->AsPhiOrNull()->GetRegNumber() == phi->GetRegNumber() && + next->AsPhi()->GetRegNumber() == phi->GetRegNumber() && next->GetType() != type) { // Move to the next phi to see if it is the one we are looking for. next = next->GetNext(); } if (next == nullptr || - // TODO: Remove "OrNull". - (next->AsPhiOrNull()->GetRegNumber() != phi->GetRegNumber()) || + (next->AsPhi()->GetRegNumber() != phi->GetRegNumber()) || (next->GetType() != type)) { ArenaAllocator* allocator = graph_->GetAllocator(); HInputsRef inputs = phi->GetInputs(); @@ -697,8 +677,7 @@ HPhi* SsaBuilder::GetFloatDoubleOrReferenceEquivalentOfPhi(HPhi* phi, DataType:: } else { // An existing equivalent was found. If it is dead, conflict was previously // identified and we return nullptr instead. - // TODO: Remove "OrNull". - HPhi* next_phi = next->AsPhiOrNull(); + HPhi* next_phi = next->AsPhi(); DCHECK_EQ(next_phi->GetType(), type); return next_phi->IsLive() ? next_phi : nullptr; } @@ -731,30 +710,23 @@ HArrayGet* SsaBuilder::GetFloatOrDoubleEquivalentOfArrayGet(HArrayGet* aget) { HInstruction* SsaBuilder::GetFloatOrDoubleEquivalent(HInstruction* value, DataType::Type type) { if (value->IsArrayGet()) { - // TODO: Remove "OrNull". - return GetFloatOrDoubleEquivalentOfArrayGet(value->AsArrayGetOrNull()); + return GetFloatOrDoubleEquivalentOfArrayGet(value->AsArrayGet()); } else if (value->IsLongConstant()) { - // TODO: Remove "OrNull". - return GetDoubleEquivalent(value->AsLongConstantOrNull()); + return GetDoubleEquivalent(value->AsLongConstant()); } else if (value->IsIntConstant()) { - // TODO: Remove "OrNull". - return GetFloatEquivalent(value->AsIntConstantOrNull()); + return GetFloatEquivalent(value->AsIntConstant()); } else if (value->IsPhi()) { - // TODO: Remove "OrNull". - return GetFloatDoubleOrReferenceEquivalentOfPhi(value->AsPhiOrNull(), type); + return GetFloatDoubleOrReferenceEquivalentOfPhi(value->AsPhi(), type); } else { return nullptr; } } HInstruction* SsaBuilder::GetReferenceTypeEquivalent(HInstruction* value) { - // TODO: Remove "OrNull". - if (value->IsIntConstant() && value->AsIntConstantOrNull()->GetValue() == 0) { + if (value->IsIntConstant() && value->AsIntConstant()->GetValue() == 0) { return graph_->GetNullConstant(); } else if (value->IsPhi()) { - // TODO: Remove "OrNull". - return GetFloatDoubleOrReferenceEquivalentOfPhi( - value->AsPhiOrNull(), DataType::Type::kReference); + return GetFloatDoubleOrReferenceEquivalentOfPhi(value->AsPhi(), DataType::Type::kReference); } else { return nullptr; } diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc index b36ccbe02b..317e0999d7 100644 --- a/compiler/optimizing/ssa_liveness_analysis.cc +++ b/compiler/optimizing/ssa_liveness_analysis.cc @@ -496,8 +496,7 @@ size_t LiveInterval::NumberOfSpillSlotsNeeded() const { if (definition->IsPhi()) { definition = definition->InputAt(1); // SIMD always appears on back-edge } - // TODO: Remove "OrNull". - return definition->AsVecOperationOrNull()->GetVectorNumberOfBytes() / kVRegSize; + return definition->AsVecOperation()->GetVectorNumberOfBytes() / kVRegSize; } // Return number of needed spill slots based on type. return (type_ == DataType::Type::kInt64 || type_ == DataType::Type::kFloat64) ? 2 : 1; diff --git a/compiler/optimizing/ssa_phi_elimination.cc b/compiler/optimizing/ssa_phi_elimination.cc index 2a1697d7a2..1d9be3956a 100644 --- a/compiler/optimizing/ssa_phi_elimination.cc +++ b/compiler/optimizing/ssa_phi_elimination.cc @@ -45,8 +45,7 @@ void SsaDeadPhiElimination::MarkDeadPhis() { // Add to the worklist phis referenced by non-phi instructions. for (HBasicBlock* block : graph_->GetReversePostOrder()) { for (HInstructionIterator inst_it(block->GetPhis()); !inst_it.Done(); inst_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = inst_it.Current()->AsPhiOrNull(); + HPhi* phi = inst_it.Current()->AsPhi(); if (phi->IsDead()) { continue; } @@ -98,8 +97,7 @@ void SsaDeadPhiElimination::EliminateDeadPhis() { HInstruction* next = nullptr; HPhi* phi; while (current != nullptr) { - // TODO: Remove "OrNull". - phi = current->AsPhiOrNull(); + phi = current->AsPhi(); next = current->GetNext(); if (phi->IsDead()) { // Make sure the phi is only used by other dead phis. @@ -107,8 +105,7 @@ void SsaDeadPhiElimination::EliminateDeadPhis() { for (const HUseListNode& use : phi->GetUses()) { HInstruction* user = use.GetUser(); DCHECK(user->IsLoopHeaderPhi()); - // TODO: Remove "OrNull". - DCHECK(user->AsPhiOrNull()->IsDead()); + DCHECK(user->AsPhi()->IsDead()); } } // Remove the phi from use lists of its inputs. @@ -138,8 +135,7 @@ bool SsaRedundantPhiElimination::Run() { // neither will necessarily converge faster. for (HBasicBlock* block : graph_->GetReversePostOrder()) { for (HInstructionIterator inst_it(block->GetPhis()); !inst_it.Done(); inst_it.Advance()) { - // TODO: Remove "OrNull". - worklist.push_back(inst_it.Current()->AsPhiOrNull()); + worklist.push_back(inst_it.Current()->AsPhi()); } } @@ -201,11 +197,9 @@ bool SsaRedundantPhiElimination::Run() { continue; } else if (input->IsPhi()) { if (!visited_phis_in_cycle.IsBitSet(input->GetId())) { - // TODO: Remove "OrNull". - cycle_worklist.push_back(input->AsPhiOrNull()); + cycle_worklist.push_back(input->AsPhi()); visited_phis_in_cycle.SetBit(input->GetId()); - // TODO: Remove "OrNull". - catch_phi_in_cycle |= input->AsPhiOrNull()->IsCatchPhi(); + catch_phi_in_cycle |= input->AsPhi()->IsCatchPhi(); irreducible_loop_phi_in_cycle |= input->IsIrreducibleLoopHeaderPhi(); } else { // Already visited, nothing to do. @@ -254,8 +248,7 @@ bool SsaRedundantPhiElimination::Run() { for (const HUseListNode& use : current->GetUses()) { HInstruction* user = use.GetUser(); if (user->IsPhi() && !visited_phis_in_cycle.IsBitSet(user->GetId())) { - // TODO: Remove "OrNull". - worklist.push_back(user->AsPhiOrNull()); + worklist.push_back(user->AsPhi()); } } DCHECK(candidate->StrictlyDominates(current)); diff --git a/compiler/optimizing/superblock_cloner.cc b/compiler/optimizing/superblock_cloner.cc index f323c8af2d..7c0097c6f6 100644 --- a/compiler/optimizing/superblock_cloner.cc +++ b/compiler/optimizing/superblock_cloner.cc @@ -175,10 +175,8 @@ void SuperblockCloner::RemapOrigInternalOrIncomingEdge(HBasicBlock* orig_block, // of copy successor's predecessors. bool first_phi_met = false; for (HInstructionIterator it(orig_succ->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* orig_phi = it.Current()->AsPhiOrNull(); - // TODO: Remove "OrNull". - HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull(); + HPhi* orig_phi = it.Current()->AsPhi(); + HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi(); HInstruction* orig_phi_input = orig_phi->InputAt(this_index); // Remove corresponding input for original phi. orig_phi->RemoveInputAt(this_index); @@ -207,10 +205,8 @@ void SuperblockCloner::AddCopyInternalEdge(HBasicBlock* orig_block, size_t orig_index = orig_succ->GetPredecessorIndexOf(orig_block); for (HInstructionIterator it(orig_succ->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* orig_phi = it.Current()->AsPhiOrNull(); - // TODO: Remove "OrNull". - HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull(); + HPhi* orig_phi = it.Current()->AsPhi(); + HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi(); HInstruction* orig_phi_input = orig_phi->InputAt(orig_index); copy_phi->AddInput(orig_phi_input); } @@ -225,8 +221,7 @@ void SuperblockCloner::RemapCopyInternalEdge(HBasicBlock* orig_block, size_t orig_index = orig_succ->GetPredecessorIndexOf(orig_block); for (HInstructionIterator it(orig_succ->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* orig_phi = it.Current()->AsPhiOrNull(); + HPhi* orig_phi = it.Current()->AsPhi(); HInstruction* orig_phi_input = orig_phi->InputAt(orig_index); orig_phi->AddInput(orig_phi_input); } @@ -254,10 +249,8 @@ void SuperblockCloner::CopyIncomingEdgesForVersioning() { // TODO: remove this requirement. DCHECK_EQ(orig_block->GetPredecessorIndexOf(orig_pred), incoming_edge_count); for (HInstructionIterator it(orig_block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* orig_phi = it.Current()->AsPhiOrNull(); - // TODO: Remove "OrNull". - HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull(); + HPhi* orig_phi = it.Current()->AsPhi(); + HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi(); HInstruction* orig_phi_input = orig_phi->InputAt(incoming_edge_count); // Add the corresponding input of the original phi to the copy one. copy_phi->AddInput(orig_phi_input); @@ -554,10 +547,8 @@ void SuperblockCloner::ResolveDataFlow() { HBasicBlock* orig_block = entry.first; for (HInstructionIterator it(orig_block->GetPhis()); !it.Done(); it.Advance()) { - // TODO: Remove "OrNull". - HPhi* orig_phi = it.Current()->AsPhiOrNull(); - // TODO: Remove "OrNull". - HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull(); + HPhi* orig_phi = it.Current()->AsPhi(); + HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi(); ResolvePhi(orig_phi); ResolvePhi(copy_phi); } @@ -678,8 +669,7 @@ void SuperblockCloner::FixSubgraphClosedSSAAfterCloning() { for (auto it : live_outs_) { DCHECK(it.first != it.second); HInstruction* orig_value = it.first; - // TODO: Remove "OrNull". - HPhi* phi = it.second->AsPhiOrNull(); + HPhi* phi = it.second->AsPhi(); HInstruction* copy_value = GetInstrCopy(orig_value); // Copy edges are inserted after the original so we can just add new input to the phi. phi->AddInput(copy_value); @@ -1011,8 +1001,7 @@ void SuperblockCloner::CleanUp() { for (auto entry : *bb_map_) { HBasicBlock* orig_block = entry.first; for (HInstructionIterator inst_it(orig_block->GetPhis()); !inst_it.Done(); inst_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = inst_it.Current()->AsPhiOrNull(); + HPhi* phi = inst_it.Current()->AsPhi(); if (ArePhiInputsTheSame(phi)) { phi->ReplaceWith(phi->InputAt(0)); orig_block->RemovePhi(phi); @@ -1021,8 +1010,7 @@ void SuperblockCloner::CleanUp() { HBasicBlock* copy_block = GetBlockCopy(orig_block); for (HInstructionIterator inst_it(copy_block->GetPhis()); !inst_it.Done(); inst_it.Advance()) { - // TODO: Remove "OrNull". - HPhi* phi = inst_it.Current()->AsPhiOrNull(); + HPhi* phi = inst_it.Current()->AsPhi(); if (ArePhiInputsTheSame(phi)) { phi->ReplaceWith(phi->InputAt(0)); copy_block->RemovePhi(phi); @@ -1044,10 +1032,8 @@ HBasicBlock* SuperblockCloner::CloneBasicBlock(const HBasicBlock* orig_block) { for (HInstructionIterator it(orig_block->GetPhis()); !it.Done(); it.Advance()) { HInstruction* orig_instr = it.Current(); HInstruction* copy_instr = orig_instr->Clone(arena_); - // TODO: Remove "OrNull". - copy_block->AddPhi(copy_instr->AsPhiOrNull()); - // TODO: Remove "OrNull". - copy_instr->AsPhiOrNull()->RemoveAllInputs(); + copy_block->AddPhi(copy_instr->AsPhi()); + copy_instr->AsPhi()->RemoveAllInputs(); DCHECK(!orig_instr->HasEnvironment()); hir_map_->Put(orig_instr, copy_instr); } diff --git a/compiler/optimizing/superblock_cloner_test.cc b/compiler/optimizing/superblock_cloner_test.cc index 7c90562909..ea2563ea7d 100644 --- a/compiler/optimizing/superblock_cloner_test.cc +++ b/compiler/optimizing/superblock_cloner_test.cc @@ -432,8 +432,7 @@ TEST_F(SuperblockClonerTest, LoopPeelingMultipleBackEdges) { HInstructionIterator it(header->GetPhis()); DCHECK(!it.Done()); - // TODO: Remove "OrNull". - HPhi* loop_phi = it.Current()->AsPhiOrNull(); + HPhi* loop_phi = it.Current()->AsPhi(); HInstruction* temp_add = new (GetAllocator()) HAdd(DataType::Type::kInt32, loop_phi, graph_->GetIntConstant(2)); diff --git a/compiler/optimizing/write_barrier_elimination.cc b/compiler/optimizing/write_barrier_elimination.cc index 390c6e9f8f..eb70b670fe 100644 --- a/compiler/optimizing/write_barrier_elimination.cc +++ b/compiler/optimizing/write_barrier_elimination.cc @@ -52,13 +52,10 @@ class WBEVisitor final : public HGraphVisitor { auto it = current_write_barriers_.find(obj); if (it != current_write_barriers_.end()) { DCHECK(it->second->IsInstanceFieldSet()); - // TODO: Remove "OrNull". - DCHECK(it->second->AsInstanceFieldSetOrNull()->GetWriteBarrierKind() != + DCHECK(it->second->AsInstanceFieldSet()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit); DCHECK_EQ(it->second->GetBlock(), instruction->GetBlock()); - // TODO: Remove "OrNull". - it->second->AsInstanceFieldSetOrNull()->SetWriteBarrierKind( - WriteBarrierKind::kEmitNoNullCheck); + it->second->AsInstanceFieldSet()->SetWriteBarrierKind(WriteBarrierKind::kEmitNoNullCheck); instruction->SetWriteBarrierKind(WriteBarrierKind::kDontEmit); MaybeRecordStat(stats_, MethodCompilationStat::kRemovedWriteBarrier); } else { @@ -82,12 +79,9 @@ class WBEVisitor final : public HGraphVisitor { auto it = current_write_barriers_.find(cls); if (it != current_write_barriers_.end()) { DCHECK(it->second->IsStaticFieldSet()); - // TODO: Remove "OrNull". - DCHECK(it->second->AsStaticFieldSetOrNull()->GetWriteBarrierKind() != - WriteBarrierKind::kDontEmit); + DCHECK(it->second->AsStaticFieldSet()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit); DCHECK_EQ(it->second->GetBlock(), instruction->GetBlock()); - // TODO: Remove "OrNull". - it->second->AsStaticFieldSetOrNull()->SetWriteBarrierKind(WriteBarrierKind::kEmitNoNullCheck); + it->second->AsStaticFieldSet()->SetWriteBarrierKind(WriteBarrierKind::kEmitNoNullCheck); instruction->SetWriteBarrierKind(WriteBarrierKind::kDontEmit); MaybeRecordStat(stats_, MethodCompilationStat::kRemovedWriteBarrier); } else { @@ -113,13 +107,10 @@ class WBEVisitor final : public HGraphVisitor { auto it = current_write_barriers_.find(arr); if (it != current_write_barriers_.end()) { DCHECK(it->second->IsArraySet()); - // TODO: Remove "OrNull". - DCHECK(it->second->AsArraySetOrNull()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit); + DCHECK(it->second->AsArraySet()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit); DCHECK_EQ(it->second->GetBlock(), instruction->GetBlock()); // We never skip the null check in ArraySets so that value is already set. - // TODO: Remove "OrNull". - DCHECK(it->second->AsArraySetOrNull()->GetWriteBarrierKind() == - WriteBarrierKind::kEmitNoNullCheck); + DCHECK(it->second->AsArraySet()->GetWriteBarrierKind() == WriteBarrierKind::kEmitNoNullCheck); instruction->SetWriteBarrierKind(WriteBarrierKind::kDontEmit); MaybeRecordStat(stats_, MethodCompilationStat::kRemovedWriteBarrier); } else { -- cgit v1.2.3-59-g8ed1b