summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--compiler/optimizing/bounds_check_elimination.cc88
-rw-r--r--compiler/optimizing/code_generator.cc39
-rw-r--r--compiler/optimizing/code_generator.h24
-rw-r--r--compiler/optimizing/code_generator_arm64.cc102
-rw-r--r--compiler/optimizing/code_generator_arm_vixl.cc79
-rw-r--r--compiler/optimizing/code_generator_utils.cc7
-rw-r--r--compiler/optimizing/code_generator_vector_arm64_neon.cc49
-rw-r--r--compiler/optimizing/code_generator_vector_arm64_sve.cc34
-rw-r--r--compiler/optimizing/code_generator_vector_arm_vixl.cc15
-rw-r--r--compiler/optimizing/code_generator_vector_x86.cc9
-rw-r--r--compiler/optimizing/code_generator_vector_x86_64.cc9
-rw-r--r--compiler/optimizing/code_generator_x86.cc325
-rw-r--r--compiler/optimizing/code_generator_x86_64.cc228
-rw-r--r--compiler/optimizing/code_sinking.cc25
-rw-r--r--compiler/optimizing/common_arm.h15
-rw-r--r--compiler/optimizing/common_arm64.h10
-rw-r--r--compiler/optimizing/constant_folding.cc55
-rw-r--r--compiler/optimizing/constant_folding_test.cc42
-rw-r--r--compiler/optimizing/critical_native_abi_fixup_arm.cc6
-rw-r--r--compiler/optimizing/dead_code_elimination.cc103
-rw-r--r--compiler/optimizing/escape.cc6
-rw-r--r--compiler/optimizing/graph_checker.cc28
-rw-r--r--compiler/optimizing/graph_test.cc66
-rw-r--r--compiler/optimizing/graph_visualizer.cc22
-rw-r--r--compiler/optimizing/gvn.cc6
-rw-r--r--compiler/optimizing/induction_var_analysis.cc40
-rw-r--r--compiler/optimizing/induction_var_range.cc19
-rw-r--r--compiler/optimizing/induction_var_range.h3
-rw-r--r--compiler/optimizing/induction_var_range_test.cc3
-rw-r--r--compiler/optimizing/inliner.cc33
-rw-r--r--compiler/optimizing/instruction_builder.cc46
-rw-r--r--compiler/optimizing/instruction_simplifier.cc266
-rw-r--r--compiler/optimizing/instruction_simplifier_arm.cc3
-rw-r--r--compiler/optimizing/instruction_simplifier_arm64.cc6
-rw-r--r--compiler/optimizing/instruction_simplifier_shared.cc37
-rw-r--r--compiler/optimizing/instruction_simplifier_shared.h13
-rw-r--r--compiler/optimizing/instruction_simplifier_x86_shared.cc9
-rw-r--r--compiler/optimizing/intrinsics.cc15
-rw-r--r--compiler/optimizing/intrinsics.h3
-rw-r--r--compiler/optimizing/intrinsics_arm64.cc66
-rw-r--r--compiler/optimizing/intrinsics_arm_vixl.cc18
-rw-r--r--compiler/optimizing/intrinsics_utils.h18
-rw-r--r--compiler/optimizing/intrinsics_x86.cc111
-rw-r--r--compiler/optimizing/intrinsics_x86_64.cc75
-rw-r--r--compiler/optimizing/live_ranges_test.cc18
-rw-r--r--compiler/optimizing/load_store_analysis.cc56
-rw-r--r--compiler/optimizing/load_store_analysis.h6
-rw-r--r--compiler/optimizing/load_store_elimination.cc57
-rw-r--r--compiler/optimizing/load_store_elimination_test.cc44
-rw-r--r--compiler/optimizing/locations.cc7
-rw-r--r--compiler/optimizing/loop_analysis.cc2
-rw-r--r--compiler/optimizing/loop_optimization.cc72
-rw-r--r--compiler/optimizing/loop_optimization_test.cc3
-rw-r--r--compiler/optimizing/nodes.cc145
-rw-r--r--compiler/optimizing/nodes.h104
-rw-r--r--compiler/optimizing/nodes_shared.cc15
-rw-r--r--compiler/optimizing/nodes_shared.h6
-rw-r--r--compiler/optimizing/nodes_vector.h44
-rw-r--r--compiler/optimizing/nodes_x86.h12
-rw-r--r--compiler/optimizing/optimizing_unit_test.h6
-rw-r--r--compiler/optimizing/pc_relative_fixups_x86.cc10
-rw-r--r--compiler/optimizing/prepare_for_register_allocation.cc27
-rw-r--r--compiler/optimizing/reference_type_propagation.cc94
-rw-r--r--compiler/optimizing/reference_type_propagation_test.cc12
-rw-r--r--compiler/optimizing/register_allocation_resolver.cc27
-rw-r--r--compiler/optimizing/register_allocator_graph_color.cc12
-rw-r--r--compiler/optimizing/register_allocator_linear_scan.cc16
-rw-r--r--compiler/optimizing/register_allocator_test.cc12
-rw-r--r--compiler/optimizing/scheduler.cc28
-rw-r--r--compiler/optimizing/scheduler_arm.cc12
-rw-r--r--compiler/optimizing/scheduler_arm64.cc6
-rw-r--r--compiler/optimizing/select_generator.cc25
-rw-r--r--compiler/optimizing/ssa_builder.cc86
-rw-r--r--compiler/optimizing/ssa_liveness_analysis.cc3
-rw-r--r--compiler/optimizing/ssa_phi_elimination.cc23
-rw-r--r--compiler/optimizing/superblock_cloner.cc42
-rw-r--r--compiler/optimizing/superblock_cloner_test.cc3
-rw-r--r--compiler/optimizing/write_barrier_elimination.cc21
-rw-r--r--compiler/optimizing/x86_memory_gen.cc2
79 files changed, 2146 insertions, 1088 deletions
diff --git a/compiler/optimizing/bounds_check_elimination.cc b/compiler/optimizing/bounds_check_elimination.cc
index 89caf32f25..6b3d06e4fc 100644
--- a/compiler/optimizing/bounds_check_elimination.cc
+++ b/compiler/optimizing/bounds_check_elimination.cc
@@ -37,7 +37,8 @@ class ValueBound : public ValueObject {
ValueBound(HInstruction* instruction, int32_t constant) {
if (instruction != nullptr && instruction->IsIntConstant()) {
// Normalize ValueBound with constant instruction.
- int32_t instr_const = instruction->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t instr_const = instruction->AsIntConstantOrNull()->GetValue();
if (!WouldAddOverflowOrUnderflow(instr_const, constant)) {
instruction_ = nullptr;
constant_ = instr_const + constant;
@@ -71,11 +72,13 @@ class ValueBound : public ValueObject {
HInstruction* left_so_far = nullptr;
int32_t right_so_far = 0;
while (instruction->IsAdd() || instruction->IsSub()) {
- HBinaryOperation* bin_op = instruction->AsBinaryOperation();
+ // TODO: Remove "OrNull".
+ HBinaryOperation* bin_op = instruction->AsBinaryOperationOrNull();
HInstruction* left = bin_op->GetLeft();
HInstruction* right = bin_op->GetRight();
if (right->IsIntConstant()) {
- int32_t v = right->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t v = right->AsIntConstantOrNull()->GetValue();
int32_t c = instruction->IsAdd() ? v : -v;
if (!WouldAddOverflowOrUnderflow(right_so_far, c)) {
instruction = left;
@@ -95,7 +98,8 @@ class ValueBound : public ValueObject {
// Expresses any instruction as a value bound.
static ValueBound AsValueBound(HInstruction* instruction) {
if (instruction->IsIntConstant()) {
- return ValueBound(nullptr, instruction->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return ValueBound(nullptr, instruction->AsIntConstantOrNull()->GetValue());
}
HInstruction *left;
int32_t right;
@@ -111,7 +115,8 @@ class ValueBound : public ValueObject {
DCHECK(instruction != nullptr);
if (instruction->IsIntConstant()) {
*found = true;
- return ValueBound(nullptr, instruction->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return ValueBound(nullptr, instruction->AsIntConstantOrNull()->GetValue());
}
if (instruction->IsArrayLength()) {
@@ -441,7 +446,8 @@ 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()) {
- int32_t initial_constant = initial_->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t initial_constant = initial_->AsIntConstantOrNull()->GetValue();
if (upper <= initial_constant) {
last_num_in_sequence = upper;
} else {
@@ -877,12 +883,14 @@ class BCEVisitor final : public HGraphVisitor {
}
} else {
// Constant index.
- int32_t constant = index->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = index->AsIntConstantOrNull()->GetValue();
if (constant < 0) {
// Will always throw exception.
return;
} else if (array_length->IsIntConstant()) {
- if (constant < array_length->AsIntConstant()->GetValue()) {
+ // TODO: Remove "OrNull".
+ if (constant < array_length->AsIntConstantOrNull()->GetValue()) {
ReplaceInstruction(bounds_check, index);
}
return;
@@ -1009,7 +1017,8 @@ class BCEVisitor final : public HGraphVisitor {
void VisitIf(HIf* instruction) override {
if (instruction->InputAt(0)->IsCondition()) {
- HCondition* cond = instruction->InputAt(0)->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* cond = instruction->InputAt(0)->AsConditionOrNull();
HandleIf(instruction, cond->GetLeft(), cond->GetRight(), cond->GetCondition());
}
}
@@ -1047,41 +1056,47 @@ class BCEVisitor final : public HGraphVisitor {
HDiv* div = nullptr;
int64_t const_divisor = 0;
- if (HMul* mul = instruction->GetRight()->AsMul()) {
+ if (HMul* mul = instruction->GetRight()->AsMulOrNull()) {
if (!mul->GetLeft()->IsDiv() || !mul->GetRight()->IsConstant()) {
return false;
}
- div = mul->GetLeft()->AsDiv();
- const_divisor = Int64FromConstant(mul->GetRight()->AsConstant());
- } else if (HAdd* add = instruction->GetRight()->AsAdd()) {
- HShl* shl = add->GetRight()->AsShl();
+ // TODO: Remove "OrNull".
+ div = mul->GetLeft()->AsDivOrNull();
+ // TODO: Remove "OrNull".
+ const_divisor = Int64FromConstant(mul->GetRight()->AsConstantOrNull());
+ } else if (HAdd* add = instruction->GetRight()->AsAddOrNull()) {
+ HShl* shl = add->GetRight()->AsShlOrNull();
if (!is_needed_shl(shl)) {
return false;
}
- div = shl->GetLeft()->AsDiv();
+ // TODO: Remove "OrNull".
+ div = shl->GetLeft()->AsDivOrNull();
if (add->GetLeft() != div) {
return false;
}
- int32_t n = shl->GetRight()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t n = shl->GetRight()->AsIntConstantOrNull()->GetValue();
if (n == BitSizeOf<int32_t>() - 1) {
// 2^n + 1 will be negative.
return false;
}
const_divisor = (1LL << n) + 1;
- } else if (HSub* sub = instruction->GetRight()->AsSub()) {
- HShl* shl = sub->GetLeft()->AsShl();
+ } else if (HSub* sub = instruction->GetRight()->AsSubOrNull()) {
+ HShl* shl = sub->GetLeft()->AsShlOrNull();
if (!is_needed_shl(shl)) {
return false;
}
- div = shl->GetLeft()->AsDiv();
+ // TODO: Remove "OrNull".
+ div = shl->GetLeft()->AsDivOrNull();
if (sub->GetRight() != div) {
return false;
}
- int32_t n = shl->GetRight()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t n = shl->GetRight()->AsIntConstantOrNull()->GetValue();
const_divisor = (1LL << n) - 1;
}
@@ -1118,7 +1133,8 @@ class BCEVisitor final : public HGraphVisitor {
if (left_range == nullptr) {
return;
}
- ValueRange* range = left_range->Add(right->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ ValueRange* range = left_range->Add(right->AsIntConstantOrNull()->GetValue());
if (range != nullptr) {
AssignRange(add->GetBlock(), add, range);
}
@@ -1137,7 +1153,8 @@ class BCEVisitor final : public HGraphVisitor {
if (left_range == nullptr) {
return;
}
- ValueRange* range = left_range->Add(-right->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ ValueRange* range = left_range->Add(-right->AsIntConstantOrNull()->GetValue());
if (range != nullptr) {
AssignRange(sub->GetBlock(), sub, range);
return;
@@ -1157,7 +1174,8 @@ class BCEVisitor final : public HGraphVisitor {
// The value of left input of the sub equals (left + right_const).
if (left->IsArrayLength()) {
- HInstruction* array_length = left->AsArrayLength();
+ // TODO: Remove "OrNull".
+ HInstruction* array_length = left->AsArrayLengthOrNull();
ValueRange* right_range = LookupValueRange(right, sub->GetBlock());
if (right_range != nullptr) {
ValueBound lower = right_range->GetLower();
@@ -1193,7 +1211,8 @@ class BCEVisitor final : public HGraphVisitor {
HInstruction* right = instruction->GetRight();
int32_t right_const;
if (right->IsIntConstant()) {
- right_const = right->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ right_const = right->AsIntConstantOrNull()->GetValue();
// Detect division by two or more.
if ((instruction->IsDiv() && right_const <= 1) ||
(instruction->IsShr() && right_const < 1) ||
@@ -1245,7 +1264,8 @@ class BCEVisitor final : public HGraphVisitor {
void VisitAnd(HAnd* instruction) override {
if (instruction->GetRight()->IsIntConstant()) {
- int32_t constant = instruction->GetRight()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = instruction->GetRight()->AsIntConstantOrNull()->GetValue();
if (constant > 0) {
// constant serves as a mask so any number masked with it
// gets a [0, constant] value range.
@@ -1265,7 +1285,8 @@ class BCEVisitor final : public HGraphVisitor {
// Handle 'i % CONST' format expression in array index, e.g:
// array[i % 20];
if (right->IsIntConstant()) {
- int32_t right_const = std::abs(right->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int32_t right_const = std::abs(right->AsIntConstantOrNull()->GetValue());
if (right_const == 0) {
return;
}
@@ -1297,7 +1318,8 @@ class BCEVisitor final : public HGraphVisitor {
if (right->IsDivZeroCheck()) {
// if array_length can pass div-by-zero check,
// array_length must be > 0.
- right = right->AsDivZeroCheck()->InputAt(0);
+ // TODO: Remove "OrNull".
+ right = right->AsDivZeroCheckOrNull()->InputAt(0);
}
// Handle 'i % array.length' format expression in array index, e.g:
@@ -1434,7 +1456,8 @@ class BCEVisitor final : public HGraphVisitor {
HInstruction* user = use.GetUser();
HBasicBlock* other_block = user->GetBlock();
if (user->IsBoundsCheck() && block->Dominates(other_block)) {
- HBoundsCheck* other_bounds_check = user->AsBoundsCheck();
+ // TODO: Remove "OrNull".
+ HBoundsCheck* other_bounds_check = user->AsBoundsCheckOrNull();
HInstruction* other_index = other_bounds_check->InputAt(0);
HInstruction* other_array_length = other_bounds_check->InputAt(1);
ValueBound other_value = ValueBound::AsValueBound(other_index);
@@ -1552,7 +1575,8 @@ class BCEVisitor final : public HGraphVisitor {
for (const HUseListNode<HInstruction*>& use : array_length->GetUses()) {
HInstruction* user = use.GetUser();
if (user->IsBoundsCheck() && loop == user->GetBlock()->GetLoopInformation()) {
- HBoundsCheck* other_bounds_check = user->AsBoundsCheck();
+ // TODO: Remove "OrNull".
+ HBoundsCheck* other_bounds_check = user->AsBoundsCheckOrNull();
HInstruction* other_index = other_bounds_check->InputAt(0);
HInstruction* other_array_length = other_bounds_check->InputAt(1);
ValueBound other_value = ValueBound::AsValueBound(other_index);
@@ -1787,9 +1811,11 @@ class BCEVisitor final : public HGraphVisitor {
// ensure upper bound cannot cause an infinite loop.
HInstruction* control = loop->GetHeader()->GetLastInstruction();
if (control->IsIf()) {
- HInstruction* if_expr = control->AsIf()->InputAt(0);
+ // TODO: Remove "OrNull".
+ HInstruction* if_expr = control->AsIfOrNull()->InputAt(0);
if (if_expr->IsCondition()) {
- HCondition* condition = if_expr->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = if_expr->AsConditionOrNull();
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 c9f42b52f5..07f018b0a9 100644
--- a/compiler/optimizing/code_generator.cc
+++ b/compiler/optimizing/code_generator.cc
@@ -514,7 +514,8 @@ void CodeGenerator::CreateCommonInvokeLocationSummary(
locations->SetOut(visitor->GetReturnLocation(invoke->GetType()));
if (invoke->IsInvokeStaticOrDirect()) {
- HInvokeStaticOrDirect* call = invoke->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* call = invoke->AsInvokeStaticOrDirectOrNull();
MethodLoadKind method_load_kind = call->GetMethodLoadKind();
CodePtrLocation code_ptr_location = call->GetCodePtrLocation();
if (code_ptr_location == CodePtrLocation::kCallCriticalNative) {
@@ -998,7 +999,8 @@ void CodeGenerator::AllocateLocations(HInstruction* instruction) {
}
} else if (locations->Intrinsified() &&
instruction->IsInvokeStaticOrDirect() &&
- !instruction->AsInvokeStaticOrDirect()->HasCurrentMethodInput()) {
+ // TODO: Remove "OrNull".
+ !instruction->AsInvokeStaticOrDirectOrNull()->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;
@@ -1232,7 +1234,8 @@ void CodeGenerator::RecordPcInfo(HInstruction* instruction,
return;
}
if (instruction->IsRem()) {
- DataType::Type type = instruction->AsRem()->GetResultType();
+ // TODO: Remove "OrNull".
+ DataType::Type type = instruction->AsRemOrNull()->GetResultType();
if ((type == DataType::Type::kFloat32) || (type == DataType::Type::kFloat64)) {
return;
}
@@ -1355,7 +1358,8 @@ void CodeGenerator::RecordCatchBlockInfo() {
dex_pc_list_for_verification.push_back(block->GetDexPc());
}
DCHECK(block->GetFirstInstruction()->IsNop());
- DCHECK(block->GetFirstInstruction()->AsNop()->NeedsEnvironment());
+ // TODO: Remove "OrNull".
+ DCHECK(block->GetFirstInstruction()->AsNopOrNull()->NeedsEnvironment());
HEnvironment* const environment = block->GetFirstInstruction()->GetEnvironment();
DCHECK(environment != nullptr);
HEnvironment* outer_environment = environment;
@@ -1414,25 +1418,29 @@ void CodeGenerator::EmitVRegInfo(HEnvironment* environment,
case Location::kConstant: {
DCHECK_EQ(current, location.GetConstant());
if (current->IsLongConstant()) {
- int64_t value = current->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = current->AsLongConstantOrNull()->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()) {
- int64_t value = bit_cast<int64_t, double>(current->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int64_t value = bit_cast<int64_t, double>(current->AsDoubleConstantOrNull()->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()) {
- int32_t value = current->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = current->AsIntConstantOrNull()->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();
- int32_t value = bit_cast<int32_t, float>(current->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int32_t value = bit_cast<int32_t, float>(current->AsFloatConstantOrNull()->GetValue());
stack_map_stream->AddDexRegisterEntry(Kind::kConstant, value);
}
break;
@@ -1556,15 +1564,18 @@ 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) {
- while (current_phi != nullptr && current_phi->AsPhi()->GetRegNumber() < vreg) {
+ // TODO: Remove "OrNull".
+ while (current_phi != nullptr && current_phi->AsPhiOrNull()->GetRegNumber() < vreg) {
HInstruction* next_phi = current_phi->GetNext();
DCHECK(next_phi == nullptr ||
- current_phi->AsPhi()->GetRegNumber() <= next_phi->AsPhi()->GetRegNumber())
+ // TODO: Remove "OrNull".
+ current_phi->AsPhiOrNull()->GetRegNumber() <= next_phi->AsPhiOrNull()->GetRegNumber())
<< "Phis need to be sorted by vreg number to keep this a linear-time loop.";
current_phi = next_phi;
}
- if (current_phi == nullptr || current_phi->AsPhi()->GetRegNumber() != vreg) {
+ // TODO: Remove "OrNull".
+ if (current_phi == nullptr || current_phi->AsPhiOrNull()->GetRegNumber() != vreg) {
stack_map_stream->AddDexRegisterEntry(DexRegisterLocation::Kind::kNone, 0);
} else {
Location location = current_phi->GetLocations()->Out();
@@ -1834,8 +1845,8 @@ void SlowPathCode::RestoreLiveRegisters(CodeGenerator* codegen, LocationSummary*
void CodeGenerator::CreateSystemArrayCopyLocationSummary(HInvoke* invoke) {
// Check to see if we have known failures that will cause us to have to bail out
// to the runtime, and just generate the runtime call directly.
- HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant();
- HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstant();
+ HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstantOrNull();
+ HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstantOrNull();
// The positions must be non-negative.
if ((src_pos != nullptr && src_pos->GetValue() < 0) ||
@@ -1845,7 +1856,7 @@ void CodeGenerator::CreateSystemArrayCopyLocationSummary(HInvoke* invoke) {
}
// The length must be >= 0.
- HIntConstant* length = invoke->InputAt(4)->AsIntConstant();
+ HIntConstant* length = invoke->InputAt(4)->AsIntConstantOrNull();
if (length != nullptr) {
int32_t len = length->GetValue();
if (len < 0) {
diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h
index 9872efaa4a..59ae213960 100644
--- a/compiler/optimizing/code_generator.h
+++ b/compiler/optimizing/code_generator.h
@@ -552,37 +552,45 @@ class CodeGenerator : public DeletableArenaObject<kArenaAllocCodeGenerator> {
static int8_t GetInt8ValueOf(HConstant* constant) {
DCHECK(constant->IsIntConstant());
- return constant->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsIntConstantOrNull()->GetValue();
}
static int16_t GetInt16ValueOf(HConstant* constant) {
DCHECK(constant->IsIntConstant());
- return constant->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsIntConstantOrNull()->GetValue();
}
static int32_t GetInt32ValueOf(HConstant* constant) {
if (constant->IsIntConstant()) {
- return constant->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsIntConstantOrNull()->GetValue();
} else if (constant->IsNullConstant()) {
return 0;
} else {
DCHECK(constant->IsFloatConstant());
- return bit_cast<int32_t, float>(constant->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return bit_cast<int32_t, float>(constant->AsFloatConstantOrNull()->GetValue());
}
}
static int64_t GetInt64ValueOf(HConstant* constant) {
if (constant->IsIntConstant()) {
- return constant->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsIntConstantOrNull()->GetValue();
} else if (constant->IsNullConstant()) {
return 0;
} else if (constant->IsFloatConstant()) {
- return bit_cast<int32_t, float>(constant->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return bit_cast<int32_t, float>(constant->AsFloatConstantOrNull()->GetValue());
} else if (constant->IsLongConstant()) {
- return constant->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsLongConstantOrNull()->GetValue();
} else {
DCHECK(constant->IsDoubleConstant());
- return bit_cast<int64_t, double>(constant->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return bit_cast<int64_t, double>(constant->AsDoubleConstantOrNull()->GetValue());
}
}
diff --git a/compiler/optimizing/code_generator_arm64.cc b/compiler/optimizing/code_generator_arm64.cc
index 5492400b13..cfe33fc350 100644
--- a/compiler/optimizing/code_generator_arm64.cc
+++ b/compiler/optimizing/code_generator_arm64.cc
@@ -225,7 +225,8 @@ class BoundsCheckSlowPathARM64 : public SlowPathCodeARM64 {
locations->InAt(1),
LocationFrom(calling_convention.GetRegisterAt(1)),
DataType::Type::kInt32);
- QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt()
+ // TODO: Remove "OrNull".
+ QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt()
? kQuickThrowStringBounds
: kQuickThrowArrayBounds;
arm64_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this);
@@ -340,7 +341,8 @@ class LoadStringSlowPathARM64 : public SlowPathCodeARM64 {
SaveLiveRegisters(codegen, locations);
InvokeRuntimeCallingConvention calling_convention;
- const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex();
+ // TODO: Remove "OrNull".
+ const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex();
__ Mov(calling_convention.GetRegisterAt(0).W(), string_index.index_);
arm64_codegen->InvokeRuntime(kQuickResolveString, instruction_, instruction_->GetDexPc(), this);
CheckEntrypointTypes<kQuickResolveString, void*, uint32_t>();
@@ -492,7 +494,8 @@ class DeoptimizationSlowPathARM64 : public SlowPathCodeARM64 {
SaveLiveRegisters(codegen, locations);
InvokeRuntimeCallingConvention calling_convention;
__ Mov(calling_convention.GetRegisterAt(0),
- static_cast<uint32_t>(instruction_->AsDeoptimize()->GetDeoptimizationKind()));
+ // TODO: Remove "OrNull".
+ static_cast<uint32_t>(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind()));
arm64_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this);
CheckEntrypointTypes<kQuickDeoptimize, void, DeoptimizationKind>();
}
@@ -615,7 +618,8 @@ class ReadBarrierForHeapReferenceSlowPathARM64 : public SlowPathCodeARM64 {
// instructions does not support the HIntermediateAddress
// instruction.
DCHECK(!(instruction_->IsArrayGet() &&
- instruction_->AsArrayGet()->GetArray()->IsIntermediateAddress()));
+ // TODO: Remove "OrNull".
+ instruction_->AsArrayGetOrNull()->GetArray()->IsIntermediateAddress()));
__ Bind(GetEntryLabel());
@@ -679,7 +683,8 @@ class ReadBarrierForHeapReferenceSlowPathARM64 : public SlowPathCodeARM64 {
// object.
DCHECK(instruction_->IsInvoke()) << instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- HInvoke* invoke = instruction_->AsInvoke();
+ // TODO: Remove "OrNull".
+ HInvoke* invoke = instruction_->AsInvokeOrNull();
DCHECK(IsUnsafeGetObject(invoke) ||
IsVarHandleGet(invoke) ||
IsUnsafeCASObject(invoke) ||
@@ -1560,16 +1565,20 @@ const Arm64InstructionSetFeatures& CodeGeneratorARM64::GetInstructionSetFeatures
void CodeGeneratorARM64::MoveConstant(CPURegister destination, HConstant* constant) {
if (constant->IsIntConstant()) {
- __ Mov(Register(destination), constant->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Mov(Register(destination), constant->AsIntConstantOrNull()->GetValue());
} else if (constant->IsLongConstant()) {
- __ Mov(Register(destination), constant->AsLongConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Mov(Register(destination), constant->AsLongConstantOrNull()->GetValue());
} else if (constant->IsNullConstant()) {
__ Mov(Register(destination), 0);
} else if (constant->IsFloatConstant()) {
- __ Fmov(VRegister(destination), constant->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Fmov(VRegister(destination), constant->AsFloatConstantOrNull()->GetValue());
} else {
DCHECK(constant->IsDoubleConstant());
- __ Fmov(VRegister(destination), constant->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Fmov(VRegister(destination), constant->AsDoubleConstantOrNull()->GetValue());
}
}
@@ -2262,7 +2271,9 @@ void InstructionCodeGeneratorARM64::HandleFieldSet(HInstruction* instruction,
WriteBarrierKind write_barrier_kind) {
DCHECK(instruction->IsInstanceFieldSet() || instruction->IsStaticFieldSet());
bool is_predicated =
- instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet();
+ instruction->IsInstanceFieldSet() &&
+ // TODO: Remove "OrNull".
+ instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet();
Register obj = InputRegisterAt(instruction, 0);
CPURegister value = InputCPURegisterOrZeroRegAt(instruction, 1);
@@ -2529,7 +2540,8 @@ void InstructionCodeGeneratorARM64::VisitDataProcWithShifterOp(
__ And(out, left, right_operand);
break;
case HInstruction::kNeg:
- DCHECK(instruction->InputAt(0)->AsConstant()->IsArithmeticZero());
+ // TODO: Remove "OrNull".
+ DCHECK(instruction->InputAt(0)->AsConstantOrNull()->IsArithmeticZero());
__ Neg(out, right_operand);
break;
case HInstruction::kOr:
@@ -2565,7 +2577,8 @@ void LocationsBuilderARM64::VisitIntermediateAddressIndex(HIntermediateAddressIn
LocationSummary* locations =
new (GetGraph()->GetAllocator()) LocationSummary(instruction, LocationSummary::kNoCall);
- HIntConstant* shift = instruction->GetShift()->AsIntConstant();
+ // TODO: Remove "OrNull".
+ HIntConstant* shift = instruction->GetShift()->AsIntConstantOrNull();
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
@@ -2583,7 +2596,8 @@ void InstructionCodeGeneratorARM64::VisitIntermediateAddressIndex(
HIntermediateAddressIndex* instruction) {
Register index_reg = InputRegisterAt(instruction, 0);
uint32_t shift = Int64FromLocation(instruction->GetLocations()->InAt(2));
- uint32_t offset = instruction->GetOffset()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ uint32_t offset = instruction->GetOffset()->AsIntConstantOrNull()->GetValue();
if (shift == 0) {
__ Add(OutputRegister(instruction), index_reg, offset);
@@ -2599,7 +2613,8 @@ void LocationsBuilderARM64::VisitMultiplyAccumulate(HMultiplyAccumulate* instr)
HInstruction* accumulator = instr->InputAt(HMultiplyAccumulate::kInputAccumulatorIndex);
if (instr->GetOpKind() == HInstruction::kSub &&
accumulator->IsConstant() &&
- accumulator->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ accumulator->AsConstantOrNull()->IsArithmeticZero()) {
// Don't allocate register for Mneg instruction.
} else {
locations->SetInAt(HMultiplyAccumulate::kInputAccumulatorIndex,
@@ -2636,7 +2651,8 @@ void InstructionCodeGeneratorARM64::VisitMultiplyAccumulate(HMultiplyAccumulate*
} else {
DCHECK(instr->GetOpKind() == HInstruction::kSub);
HInstruction* accum_instr = instr->InputAt(HMultiplyAccumulate::kInputAccumulatorIndex);
- if (accum_instr->IsConstant() && accum_instr->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ if (accum_instr->IsConstant() && accum_instr->AsConstantOrNull()->IsArithmeticZero()) {
__ Mneg(res, mul_left, mul_right);
} else {
Register accumulator = InputRegisterAt(instr, HMultiplyAccumulate::kInputAccumulatorIndex);
@@ -2661,7 +2677,8 @@ void LocationsBuilderARM64::VisitArrayGet(HArrayGet* instruction) {
// CodeGeneratorARM64::GenerateFieldLoadWithBakerReadBarrier()
// only if the offset is too big.
uint32_t offset = CodeGenerator::GetArrayDataOffset(instruction);
- uint32_t index = instruction->GetIndex()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ uint32_t index = instruction->GetIndex()->AsIntConstantOrNull()->GetValue();
offset += index << DataType::SizeShift(DataType::Type::kReference);
if (offset >= kReferenceLoadMinFarOffset) {
locations->AddTemp(FixedTempLocation());
@@ -2775,8 +2792,11 @@ void InstructionCodeGeneratorARM64::VisitArrayGet(HArrayGet* instruction) {
// input instruction has done it already. See the comment in
// `TryExtractArrayAccessAddress()`.
if (kIsDebugBuild) {
- HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddress();
- DCHECK_EQ(interm_addr->GetOffset()->AsIntConstant()->GetValueAsUint64(), offset);
+ // TODO: Remove "OrNull".
+ HIntermediateAddress* interm_addr =
+ instruction->GetArray()->AsIntermediateAddressOrNull();
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(interm_addr->GetOffset()->AsIntConstantOrNull()->GetValueAsUint64(), offset);
}
temp = obj;
} else {
@@ -2887,8 +2907,11 @@ void InstructionCodeGeneratorARM64::VisitArraySet(HArraySet* instruction) {
// input instruction has done it already. See the comment in
// `TryExtractArrayAccessAddress()`.
if (kIsDebugBuild) {
- HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddress();
- DCHECK(interm_addr->GetOffset()->AsIntConstant()->GetValueAsUint64() == offset);
+ // TODO: Remove "OrNull".
+ HIntermediateAddress* interm_addr =
+ instruction->GetArray()->AsIntermediateAddressOrNull();
+ // TODO: Remove "OrNull".
+ DCHECK(interm_addr->GetOffset()->AsIntConstantOrNull()->GetValueAsUint64() == offset);
}
temp = array;
} else {
@@ -3099,8 +3122,9 @@ void InstructionCodeGeneratorARM64::VisitClinitCheck(HClinitCheck* check) {
}
static bool IsFloatingPointZeroConstant(HInstruction* inst) {
- return (inst->IsFloatConstant() && (inst->AsFloatConstant()->IsArithmeticZero()))
- || (inst->IsDoubleConstant() && (inst->AsDoubleConstant()->IsArithmeticZero()));
+ // TODO: Remove "OrNull".
+ return (inst->IsFloatConstant() && (inst->AsFloatConstantOrNull()->IsArithmeticZero()))
+ || (inst->IsDoubleConstant() && (inst->AsDoubleConstantOrNull()->IsArithmeticZero()));
}
void InstructionCodeGeneratorARM64::GenerateFcmp(HInstruction* instruction) {
@@ -3684,7 +3708,8 @@ void InstructionCodeGeneratorARM64::HandleGoto(HInstruction* got, HBasicBlock* s
return; // `GenerateSuspendCheck()` emitted the jump.
}
if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) {
- GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr);
+ // TODO: Remove "OrNull".
+ GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr);
codegen_->MaybeGenerateMarkingRegisterCheck(/* code= */ __LINE__);
}
if (!codegen_->GoesToNextBlock(block, successor)) {
@@ -3722,12 +3747,14 @@ void InstructionCodeGeneratorARM64::GenerateTestAndBranch(HInstruction* instruct
return;
} else if (cond->IsIntConstant()) {
// Constant condition, statically compared against "true" (integer value 1).
- if (cond->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (cond->AsIntConstantOrNull()->IsTrue()) {
if (true_target != nullptr) {
__ B(true_target);
}
} else {
- DCHECK(cond->AsIntConstant()->IsFalse()) << cond->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << cond->AsIntConstantOrNull()->GetValue();
if (false_target != nullptr) {
__ B(false_target);
}
@@ -3755,7 +3782,8 @@ 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.
- HCondition* condition = cond->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = cond->AsConditionOrNull();
DataType::Type type = condition->InputAt(0)->GetType();
if (DataType::IsFloatingPointType(type)) {
@@ -3888,8 +3916,8 @@ void LocationsBuilderARM64::VisitSelect(HSelect* select) {
locations->SetInAt(1, Location::RequiresFpuRegister());
locations->SetOut(Location::RequiresFpuRegister(), Location::kNoOutputOverlap);
} else {
- HConstant* cst_true_value = select->GetTrueValue()->AsConstant();
- HConstant* cst_false_value = select->GetFalseValue()->AsConstant();
+ HConstant* cst_true_value = select->GetTrueValue()->AsConstantOrNull();
+ HConstant* cst_false_value = select->GetFalseValue()->AsConstantOrNull();
bool is_true_value_constant = cst_true_value != nullptr;
bool is_false_value_constant = cst_false_value != nullptr;
// Ask VIXL whether we should synthesize constants in registers.
@@ -3924,17 +3952,20 @@ void InstructionCodeGeneratorARM64::VisitSelect(HSelect* select) {
if (IsBooleanValueOrMaterializedCondition(cond)) {
if (cond->IsCondition() && cond->GetNext() == select) {
// Use the condition flags set by the previous instruction.
- csel_cond = GetConditionForSelect(cond->AsCondition());
+ // TODO: Remove "OrNull".
+ csel_cond = GetConditionForSelect(cond->AsConditionOrNull());
} else {
__ Cmp(InputRegisterAt(select, 2), 0);
csel_cond = ne;
}
} else if (IsConditionOnFloatingPointValues(cond)) {
GenerateFcmp(cond);
- csel_cond = GetConditionForSelect(cond->AsCondition());
+ // TODO: Remove "OrNull".
+ csel_cond = GetConditionForSelect(cond->AsConditionOrNull());
} else {
__ Cmp(InputRegisterAt(cond, 0), InputOperandAt(cond, 1));
- csel_cond = GetConditionForSelect(cond->AsCondition());
+ // TODO: Remove "OrNull".
+ csel_cond = GetConditionForSelect(cond->AsConditionOrNull());
}
if (DataType::IsFloatingPointType(select->GetType())) {
@@ -5937,7 +5968,8 @@ void LocationsBuilderARM64::VisitParallelMove(HParallelMove* instruction ATTRIBU
void InstructionCodeGeneratorARM64::VisitParallelMove(HParallelMove* instruction) {
if (instruction->GetNext()->IsSuspendCheck() &&
instruction->GetBlock()->GetLoopInformation() != nullptr) {
- HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck();
+ // TODO: Remove "OrNull".
+ HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull();
// The back edge will generate the suspend check.
codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction);
}
@@ -6877,8 +6909,10 @@ void CodeGeneratorARM64::GenerateArrayLoadWithBakerReadBarrier(HArrayGet* instru
// input instruction has done it already. See the comment in
// `TryExtractArrayAccessAddress()`.
if (kIsDebugBuild) {
- HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddress();
- DCHECK_EQ(interm_addr->GetOffset()->AsIntConstant()->GetValueAsUint64(), data_offset);
+ // TODO: Remove "OrNull".
+ HIntermediateAddress* interm_addr = instruction->GetArray()->AsIntermediateAddressOrNull();
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(interm_addr->GetOffset()->AsIntConstantOrNull()->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 1e1aee99aa..c13708a7e4 100644
--- a/compiler/optimizing/code_generator_arm_vixl.cc
+++ b/compiler/optimizing/code_generator_arm_vixl.cc
@@ -492,7 +492,8 @@ class BoundsCheckSlowPathARMVIXL : public SlowPathCodeARMVIXL {
locations->InAt(1),
LocationFrom(calling_convention.GetRegisterAt(1)),
DataType::Type::kInt32);
- QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt()
+ // TODO: Remove "OrNull".
+ QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt()
? kQuickThrowStringBounds
: kQuickThrowArrayBounds;
arm_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this);
@@ -578,10 +579,12 @@ class LoadStringSlowPathARMVIXL : public SlowPathCodeARMVIXL {
void EmitNativeCode(CodeGenerator* codegen) override {
DCHECK(instruction_->IsLoadString());
- DCHECK_EQ(instruction_->AsLoadString()->GetLoadKind(), HLoadString::LoadKind::kBssEntry);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction_->AsLoadStringOrNull()->GetLoadKind(), HLoadString::LoadKind::kBssEntry);
LocationSummary* locations = instruction_->GetLocations();
DCHECK(!locations->GetLiveRegisters()->ContainsCoreRegister(locations->Out().reg()));
- const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex();
+ // TODO: Remove "OrNull".
+ const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex();
CodeGeneratorARMVIXL* arm_codegen = down_cast<CodeGeneratorARMVIXL*>(codegen);
__ Bind(GetEntryLabel());
@@ -675,7 +678,8 @@ class DeoptimizationSlowPathARMVIXL : public SlowPathCodeARMVIXL {
SaveLiveRegisters(codegen, locations);
InvokeRuntimeCallingConventionARMVIXL calling_convention;
__ Mov(calling_convention.GetRegisterAt(0),
- static_cast<uint32_t>(instruction_->AsDeoptimize()->GetDeoptimizationKind()));
+ // TODO: Remove "OrNull".
+ static_cast<uint32_t>(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind()));
arm_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this);
CheckEntrypointTypes<kQuickDeoptimize, void, DeoptimizationKind>();
@@ -776,7 +780,8 @@ class ReadBarrierForHeapReferenceSlowPathARMVIXL : public SlowPathCodeARMVIXL {
// instructions does not support the HIntermediateAddress
// instruction.
DCHECK(!(instruction_->IsArrayGet() &&
- instruction_->AsArrayGet()->GetArray()->IsIntermediateAddress()));
+ // TODO: Remove "OrNull".
+ instruction_->AsArrayGetOrNull()->GetArray()->IsIntermediateAddress()));
__ Bind(GetEntryLabel());
SaveLiveRegisters(codegen, locations);
@@ -839,7 +844,8 @@ class ReadBarrierForHeapReferenceSlowPathARMVIXL : public SlowPathCodeARMVIXL {
// object.
DCHECK(instruction_->IsInvoke()) << instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- HInvoke* invoke = instruction_->AsInvoke();
+ // TODO: Remove "OrNull".
+ HInvoke* invoke = instruction_->AsInvokeOrNull();
DCHECK(IsUnsafeGetObject(invoke) || IsVarHandleGet(invoke) || IsVarHandleCASFamily(invoke))
<< invoke->GetIntrinsic();
DCHECK_EQ(offset_, 0U);
@@ -1847,7 +1853,8 @@ static bool CanEncodeConstantAs8BitImmediate(HConstant* constant) {
static Location Arm8BitEncodableConstantOrRegister(HInstruction* constant) {
DCHECK(!DataType::IsFloatingPointType(constant->GetType()));
- if (constant->IsConstant() && CanEncodeConstantAs8BitImmediate(constant->AsConstant())) {
+ // TODO: Remove "OrNull".
+ if (constant->IsConstant() && CanEncodeConstantAs8BitImmediate(constant->AsConstantOrNull())) {
return Location::ConstantLocation(constant);
}
@@ -1901,7 +1908,8 @@ vixl32::Label* CodeGeneratorARMVIXL::GetFinalLabel(HInstruction* instruction,
if (next->IsGoto() && (info == nullptr ||
!info->IsBackEdge(*block) ||
!info->HasSuspendCheck())) {
- final_label = GetLabelOf(next->AsGoto()->GetSuccessor());
+ // TODO: Remove "OrNull".
+ final_label = GetLabelOf(next->AsGotoOrNull()->GetSuccessor());
}
return final_label;
@@ -2793,7 +2801,8 @@ void InstructionCodeGeneratorARMVIXL::HandleGoto(HInstruction* got, HBasicBlock*
return;
}
if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) {
- GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr);
+ // TODO: Remove "OrNull".
+ GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr);
codegen_->MaybeGenerateMarkingRegisterCheck(/* code= */ 2);
}
if (!codegen_->GoesToNextBlock(block, successor)) {
@@ -2877,12 +2886,14 @@ void InstructionCodeGeneratorARMVIXL::GenerateTestAndBranch(HInstruction* instru
return;
} else if (cond->IsIntConstant()) {
// Constant condition, statically compared against "true" (integer value 1).
- if (cond->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (cond->AsIntConstantOrNull()->IsTrue()) {
if (true_target != nullptr) {
__ B(true_target);
}
} else {
- DCHECK(cond->AsIntConstant()->IsFalse()) << Int32ConstantFrom(cond);
+ // TODO: Remove "OrNull".
+ DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << Int32ConstantFrom(cond);
if (false_target != nullptr) {
__ B(false_target);
}
@@ -2916,7 +2927,8 @@ void InstructionCodeGeneratorARMVIXL::GenerateTestAndBranch(HInstruction* instru
} else {
// Condition has not been materialized. Use its inputs as the comparison and
// its condition as the branch condition.
- HCondition* condition = cond->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = cond->AsConditionOrNull();
// If this is a long or FP comparison that has been folded into
// the HCondition, generate the comparison directly.
@@ -3059,7 +3071,8 @@ void InstructionCodeGeneratorARMVIXL::VisitSelect(HSelect* select) {
Location src;
if (condition->IsIntConstant()) {
- if (condition->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ if (condition->AsIntConstantOrNull()->IsFalse()) {
src = first;
} else {
src = second;
@@ -3099,7 +3112,8 @@ void InstructionCodeGeneratorARMVIXL::VisitSelect(HSelect* select) {
__ Cmp(InputRegisterAt(select, 2), 0);
cond = invert ? std::make_pair(eq, ne) : std::make_pair(ne, eq);
} else {
- cond = GenerateTest(condition->AsCondition(), invert, codegen_);
+ // TODO: Remove "OrNull".
+ cond = GenerateTest(condition->AsConditionOrNull(), invert, codegen_);
}
const size_t instr_count = out.IsRegisterPair() ? 4 : 2;
@@ -4054,7 +4068,8 @@ void InstructionCodeGeneratorARMVIXL::VisitTypeConversion(HTypeConversion* conve
} else {
DCHECK(in.IsConstant());
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ Mov(OutputRegister(conversion), static_cast<int32_t>(value));
}
break;
@@ -5896,7 +5911,9 @@ void InstructionCodeGeneratorARMVIXL::HandleFieldSet(HInstruction* instruction,
std::optional<vixl::aarch32::Label> pred_is_null;
bool is_predicated =
- instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet();
+ instruction->IsInstanceFieldSet() &&
+ // TODO: Remove "OrNull".
+ instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet();
bool is_volatile = field_info.IsVolatile();
bool atomic_ldrd_strd = codegen_->GetInstructionSetFeatures().HasAtomicLdrdAndStrd();
DataType::Type field_type = field_info.GetFieldType();
@@ -6093,8 +6110,9 @@ void LocationsBuilderARMVIXL::HandleFieldGet(HInstruction* instruction,
Location LocationsBuilderARMVIXL::ArithmeticZeroOrFpuRegister(HInstruction* input) {
DCHECK(DataType::IsFloatingPointType(input->GetType())) << input->GetType();
- if ((input->IsFloatConstant() && (input->AsFloatConstant()->IsArithmeticZero())) ||
- (input->IsDoubleConstant() && (input->AsDoubleConstant()->IsArithmeticZero()))) {
+ // TODO: Remove "OrNull".
+ if ((input->IsFloatConstant() && (input->AsFloatConstantOrNull()->IsArithmeticZero())) ||
+ (input->IsDoubleConstant() && (input->AsDoubleConstantOrNull()->IsArithmeticZero()))) {
return Location::ConstantLocation(input);
} else {
return Location::RequiresFpuRegister();
@@ -6104,7 +6122,9 @@ Location LocationsBuilderARMVIXL::ArithmeticZeroOrFpuRegister(HInstruction* inpu
Location LocationsBuilderARMVIXL::ArmEncodableConstantOrRegister(HInstruction* constant,
Opcode opcode) {
DCHECK(!DataType::IsFloatingPointType(constant->GetType()));
- if (constant->IsConstant() && CanEncodeConstantAsImmediate(constant->AsConstant(), opcode)) {
+ if (constant->IsConstant() &&
+ // TODO: Remove "OrNull".
+ CanEncodeConstantAsImmediate(constant->AsConstantOrNull(), opcode)) {
return Location::ConstantLocation(constant);
}
return Location::RequiresRegister();
@@ -6539,7 +6559,8 @@ void LocationsBuilderARMVIXL::VisitArrayGet(HArrayGet* instruction) {
// CodeGeneratorARMVIXL::GenerateFieldLoadWithBakerReadBarrier()
// only if the offset is too big.
uint32_t offset = CodeGenerator::GetArrayDataOffset(instruction);
- uint32_t index = instruction->GetIndex()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ uint32_t index = instruction->GetIndex()->AsIntConstantOrNull()->GetValue();
offset += index << DataType::SizeShift(DataType::Type::kReference);
if (offset >= kReferenceLoadMinFarOffset) {
locations->AddTemp(Location::RequiresRegister());
@@ -6624,7 +6645,8 @@ void InstructionCodeGeneratorARMVIXL::VisitArrayGet(HArrayGet* instruction) {
// input instruction has done it already. See the comment in
// `TryExtractArrayAccessAddress()`.
if (kIsDebugBuild) {
- HIntermediateAddress* tmp = array_instr->AsIntermediateAddress();
+ // TODO: Remove "OrNull".
+ HIntermediateAddress* tmp = array_instr->AsIntermediateAddressOrNull();
DCHECK_EQ(Uint64ConstantFrom(tmp->GetOffset()), data_offset);
}
temp = obj;
@@ -6709,7 +6731,8 @@ void InstructionCodeGeneratorARMVIXL::VisitArrayGet(HArrayGet* instruction) {
// input instruction has done it already. See the comment in
// `TryExtractArrayAccessAddress()`.
if (kIsDebugBuild) {
- HIntermediateAddress* tmp = array_instr->AsIntermediateAddress();
+ // TODO: Remove "OrNull".
+ HIntermediateAddress* tmp = array_instr->AsIntermediateAddressOrNull();
DCHECK_EQ(Uint64ConstantFrom(tmp->GetOffset()), data_offset);
}
temp = obj;
@@ -6860,7 +6883,8 @@ void InstructionCodeGeneratorARMVIXL::VisitArraySet(HArraySet* instruction) {
// input instruction has done it already. See the comment in
// `TryExtractArrayAccessAddress()`.
if (kIsDebugBuild) {
- HIntermediateAddress* tmp = array_instr->AsIntermediateAddress();
+ // TODO: Remove "OrNull".
+ HIntermediateAddress* tmp = array_instr->AsIntermediateAddressOrNull();
DCHECK_EQ(Uint64ConstantFrom(tmp->GetOffset()), data_offset);
}
temp = array;
@@ -7240,7 +7264,8 @@ void LocationsBuilderARMVIXL::VisitParallelMove(HParallelMove* instruction ATTRI
void InstructionCodeGeneratorARMVIXL::VisitParallelMove(HParallelMove* instruction) {
if (instruction->GetNext()->IsSuspendCheck() &&
instruction->GetBlock()->GetLoopInformation() != nullptr) {
- HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck();
+ // TODO: Remove "OrNull".
+ HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull();
// The back edge will generate the suspend check.
codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction);
}
@@ -7410,7 +7435,8 @@ void ParallelMoveResolverARMVIXL::EmitMove(size_t index) {
destination.GetHighStackIndex(kArmWordSize));
}
} else if (constant->IsDoubleConstant()) {
- double value = constant->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double value = constant->AsDoubleConstantOrNull()->GetValue();
if (destination.IsFpuRegisterPair()) {
__ Vmov(DRegisterFrom(destination), value);
} else {
@@ -7427,7 +7453,8 @@ void ParallelMoveResolverARMVIXL::EmitMove(size_t index) {
}
} else {
DCHECK(constant->IsFloatConstant()) << constant->DebugName();
- float value = constant->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float value = constant->AsFloatConstantOrNull()->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 99805928e4..2306f073be 100644
--- a/compiler/optimizing/code_generator_utils.cc
+++ b/compiler/optimizing/code_generator_utils.cc
@@ -140,7 +140,8 @@ 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.
- HIf* if_instr = cond->GetBlock()->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instr = cond->GetBlock()->GetLastInstruction()->AsIfOrNull();
HBasicBlock* successor = nullptr;
switch (cond->GetCondition()) {
case kCondGT:
@@ -227,7 +228,9 @@ 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()) &&
- IsComparedValueNonNegativeInBlock(value, user->AsCondition(), target_user->GetBlock())) {
+ // TODO: Remove "OrNull".
+ IsComparedValueNonNegativeInBlock(
+ value, user->AsConditionOrNull(), 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 ce02bfa21a..b73d0d3614 100644
--- a/compiler/optimizing/code_generator_vector_arm64_neon.cc
+++ b/compiler/optimizing/code_generator_vector_arm64_neon.cc
@@ -47,9 +47,11 @@ inline bool NEONCanEncodeConstantAsImmediate(HConstant* constant, HInstruction*
if (constant->IsLongConstant()) {
return false;
} else if (constant->IsFloatConstant()) {
- return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstantOrNull()->GetValue());
} else if (constant->IsDoubleConstant()) {
- return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstantOrNull()->GetValue());
}
int64_t value = CodeGenerator::GetInt64ValueOf(constant);
return IsUint<8>(value);
@@ -62,7 +64,9 @@ inline bool NEONCanEncodeConstantAsImmediate(HConstant* constant, HInstruction*
// encoded into the instruction.
// - register location otherwise.
inline Location NEONEncodableConstantOrRegister(HInstruction* constant, HInstruction* instr) {
- if (constant->IsConstant() && NEONCanEncodeConstantAsImmediate(constant->AsConstant(), instr)) {
+ if (constant->IsConstant() &&
+ // TODO: Remove "OrNull".
+ NEONCanEncodeConstantAsImmediate(constant->AsConstantOrNull(), instr)) {
return Location::ConstantLocation(constant);
}
@@ -91,7 +95,8 @@ void LocationsBuilderARM64Neon::VisitVecReplicateScalar(HVecReplicateScalar* ins
case DataType::Type::kFloat32:
case DataType::Type::kFloat64:
if (input->IsConstant() &&
- NEONCanEncodeConstantAsImmediate(input->AsConstant(), instruction)) {
+ // TODO: Remove "OrNull".
+ NEONCanEncodeConstantAsImmediate(input->AsConstantOrNull(), instruction)) {
locations->SetInAt(0, Location::ConstantLocation(input));
locations->SetOut(Location::RequiresFpuRegister());
} else {
@@ -148,7 +153,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecReplicateScalar(HVecReplicateSca
case DataType::Type::kFloat32:
DCHECK_EQ(4u, instruction->GetVectorLength());
if (src_loc.IsConstant()) {
- __ Fmov(dst.V4S(), src_loc.GetConstant()->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Fmov(dst.V4S(), src_loc.GetConstant()->AsFloatConstantOrNull()->GetValue());
} else {
__ Dup(dst.V4S(), VRegisterFrom(src_loc).V4S(), 0);
}
@@ -156,7 +162,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecReplicateScalar(HVecReplicateSca
case DataType::Type::kFloat64:
DCHECK_EQ(2u, instruction->GetVectorLength());
if (src_loc.IsConstant()) {
- __ Fmov(dst.V2D(), src_loc.GetConstant()->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Fmov(dst.V2D(), src_loc.GetConstant()->AsDoubleConstantOrNull()->GetValue());
} else {
__ Dup(dst.V2D(), VRegisterFrom(src_loc).V2D(), 0);
}
@@ -896,7 +903,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecShl(HVecShl* instruction) {
LocationSummary* locations = instruction->GetLocations();
VRegister lhs = VRegisterFrom(locations->InAt(0));
VRegister dst = VRegisterFrom(locations->Out());
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
case DataType::Type::kInt8:
@@ -930,7 +938,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecShr(HVecShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
VRegister lhs = VRegisterFrom(locations->InAt(0));
VRegister dst = VRegisterFrom(locations->Out());
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
case DataType::Type::kInt8:
@@ -964,7 +973,8 @@ void InstructionCodeGeneratorARM64Neon::VisitVecUShr(HVecUShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
VRegister lhs = VRegisterFrom(locations->InAt(0));
VRegister dst = VRegisterFrom(locations->Out());
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
case DataType::Type::kInt8:
@@ -1136,8 +1146,10 @@ void LocationsBuilderARM64Neon::VisitVecSADAccumulate(HVecSADAccumulate* instruc
CreateVecAccumLocations(GetGraph()->GetAllocator(), instruction);
// Some conversions require temporary registers.
LocationSummary* locations = instruction->GetLocations();
- HVecOperation* a = instruction->InputAt(1)->AsVecOperation();
- HVecOperation* b = instruction->InputAt(2)->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull();
+ // TODO: Remove "OrNull".
+ HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull();
DCHECK_EQ(HVecOperation::ToSignedType(a->GetPackedType()),
HVecOperation::ToSignedType(b->GetPackedType()));
switch (a->GetPackedType()) {
@@ -1183,8 +1195,10 @@ 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).
- HVecOperation* a = instruction->InputAt(1)->AsVecOperation();
- HVecOperation* b = instruction->InputAt(2)->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull();
+ // TODO: Remove "OrNull".
+ HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull();
DCHECK_EQ(HVecOperation::ToSignedType(a->GetPackedType()),
HVecOperation::ToSignedType(b->GetPackedType()));
switch (a->GetPackedType()) {
@@ -1323,7 +1337,8 @@ void LocationsBuilderARM64Neon::VisitVecDotProd(HVecDotProd* instruction) {
locations->SetOut(Location::SameAsFirstInput());
// For Int8 and Uint8 general case we need a temp register.
- if ((DataType::Size(instruction->InputAt(1)->AsVecOperation()->GetPackedType()) == 1) &&
+ // TODO: Remove "OrNull".
+ if ((DataType::Size(instruction->InputAt(1)->AsVecOperationOrNull()->GetPackedType()) == 1) &&
!ShouldEmitDotProductInstructions(codegen_)) {
locations->AddTemp(Location::RequiresFpuRegister());
}
@@ -1335,8 +1350,10 @@ void InstructionCodeGeneratorARM64Neon::VisitVecDotProd(HVecDotProd* instruction
VRegister acc = VRegisterFrom(locations->InAt(0));
VRegister left = VRegisterFrom(locations->InAt(1));
VRegister right = VRegisterFrom(locations->InAt(2));
- HVecOperation* a = instruction->InputAt(1)->AsVecOperation();
- HVecOperation* b = instruction->InputAt(2)->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull();
+ // TODO: Remove "OrNull".
+ HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull();
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 4c16c3eb38..aa4bbad0ce 100644
--- a/compiler/optimizing/code_generator_vector_arm64_sve.cc
+++ b/compiler/optimizing/code_generator_vector_arm64_sve.cc
@@ -45,9 +45,11 @@ static bool SVECanEncodeConstantAsImmediate(HConstant* constant, HInstruction* i
if (constant->IsLongConstant()) {
return false;
} else if (constant->IsFloatConstant()) {
- return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstantOrNull()->GetValue());
} else if (constant->IsDoubleConstant()) {
- return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstantOrNull()->GetValue());
}
// TODO: Make use of shift part of DUP instruction.
int64_t value = CodeGenerator::GetInt64ValueOf(constant);
@@ -62,7 +64,9 @@ static bool SVECanEncodeConstantAsImmediate(HConstant* constant, HInstruction* i
// encoded into the instruction.
// - register location otherwise.
inline Location SVEEncodableConstantOrRegister(HInstruction* constant, HInstruction* instr) {
- if (constant->IsConstant() && SVECanEncodeConstantAsImmediate(constant->AsConstant(), instr)) {
+ if (constant->IsConstant() &&
+ // TODO: Remove "OrNull".
+ SVECanEncodeConstantAsImmediate(constant->AsConstantOrNull(), instr)) {
return Location::ConstantLocation(constant);
}
@@ -91,7 +95,8 @@ void LocationsBuilderARM64Sve::VisitVecReplicateScalar(HVecReplicateScalar* inst
case DataType::Type::kFloat32:
case DataType::Type::kFloat64:
if (input->IsConstant() &&
- SVECanEncodeConstantAsImmediate(input->AsConstant(), instruction)) {
+ // TODO: Remove "OrNull".
+ SVECanEncodeConstantAsImmediate(input->AsConstantOrNull(), instruction)) {
locations->SetInAt(0, Location::ConstantLocation(input));
locations->SetOut(Location::RequiresFpuRegister());
} else {
@@ -145,14 +150,16 @@ void InstructionCodeGeneratorARM64Sve::VisitVecReplicateScalar(HVecReplicateScal
break;
case DataType::Type::kFloat32:
if (src_loc.IsConstant()) {
- __ Fdup(dst.VnS(), src_loc.GetConstant()->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Fdup(dst.VnS(), src_loc.GetConstant()->AsFloatConstantOrNull()->GetValue());
} else {
__ Dup(dst.VnS(), ZRegisterFrom(src_loc).VnS(), 0);
}
break;
case DataType::Type::kFloat64:
if (src_loc.IsConstant()) {
- __ Fdup(dst.VnD(), src_loc.GetConstant()->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ __ Fdup(dst.VnD(), src_loc.GetConstant()->AsDoubleConstantOrNull()->GetValue());
} else {
__ Dup(dst.VnD(), ZRegisterFrom(src_loc).VnD(), 0);
}
@@ -769,7 +776,8 @@ void InstructionCodeGeneratorARM64Sve::VisitVecShl(HVecShl* instruction) {
const ZRegister lhs = ZRegisterFrom(locations->InAt(0));
const ZRegister dst = ZRegisterFrom(locations->Out());
const PRegisterM p_reg = LoopPReg().Merging();
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
ValidateVectorLength(instruction);
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
@@ -802,7 +810,8 @@ void InstructionCodeGeneratorARM64Sve::VisitVecShr(HVecShr* instruction) {
const ZRegister lhs = ZRegisterFrom(locations->InAt(0));
const ZRegister dst = ZRegisterFrom(locations->Out());
const PRegisterM p_reg = LoopPReg().Merging();
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
ValidateVectorLength(instruction);
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
@@ -835,7 +844,8 @@ void InstructionCodeGeneratorARM64Sve::VisitVecUShr(HVecUShr* instruction) {
const ZRegister lhs = ZRegisterFrom(locations->InAt(0));
const ZRegister dst = ZRegisterFrom(locations->Out());
const PRegisterM p_reg = LoopPReg().Merging();
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
ValidateVectorLength(instruction);
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
@@ -1029,8 +1039,10 @@ 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();
- HVecOperation* a = instruction->InputAt(1)->AsVecOperation();
- HVecOperation* b = instruction->InputAt(2)->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull();
+ // TODO: Remove "OrNull".
+ HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull();
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 e8ecf28386..0ee6564dfc 100644
--- a/compiler/optimizing/code_generator_vector_arm_vixl.cc
+++ b/compiler/optimizing/code_generator_vector_arm_vixl.cc
@@ -657,7 +657,8 @@ void InstructionCodeGeneratorARMVIXL::VisitVecShl(HVecShl* instruction) {
LocationSummary* locations = instruction->GetLocations();
vixl32::DRegister lhs = DRegisterFrom(locations->InAt(0));
vixl32::DRegister dst = DRegisterFrom(locations->Out());
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
case DataType::Type::kInt8:
@@ -687,7 +688,8 @@ void InstructionCodeGeneratorARMVIXL::VisitVecShr(HVecShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
vixl32::DRegister lhs = DRegisterFrom(locations->InAt(0));
vixl32::DRegister dst = DRegisterFrom(locations->Out());
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
case DataType::Type::kInt8:
@@ -717,7 +719,8 @@ void InstructionCodeGeneratorARMVIXL::VisitVecUShr(HVecUShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
vixl32::DRegister lhs = DRegisterFrom(locations->InAt(0));
vixl32::DRegister dst = DRegisterFrom(locations->Out());
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint8:
case DataType::Type::kInt8:
@@ -827,8 +830,10 @@ 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).
- HVecOperation* a = instruction->InputAt(1)->AsVecOperation();
- HVecOperation* b = instruction->InputAt(2)->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* a = instruction->InputAt(1)->AsVecOperationOrNull();
+ // TODO: Remove "OrNull".
+ HVecOperation* b = instruction->InputAt(2)->AsVecOperationOrNull();
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 343a6e1af4..5fb63d3808 100644
--- a/compiler/optimizing/code_generator_vector_x86.cc
+++ b/compiler/optimizing/code_generator_vector_x86.cc
@@ -997,7 +997,8 @@ void LocationsBuilderX86::VisitVecShl(HVecShl* instruction) {
void InstructionCodeGeneratorX86::VisitVecShl(HVecShl* instruction) {
LocationSummary* locations = instruction->GetLocations();
DCHECK(locations->InAt(0).Equals(locations->Out()));
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dst = locations->Out().AsFpuRegister<XmmRegister>();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint16:
@@ -1026,7 +1027,8 @@ void LocationsBuilderX86::VisitVecShr(HVecShr* instruction) {
void InstructionCodeGeneratorX86::VisitVecShr(HVecShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
DCHECK(locations->InAt(0).Equals(locations->Out()));
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dst = locations->Out().AsFpuRegister<XmmRegister>();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint16:
@@ -1051,7 +1053,8 @@ void LocationsBuilderX86::VisitVecUShr(HVecUShr* instruction) {
void InstructionCodeGeneratorX86::VisitVecUShr(HVecUShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
DCHECK(locations->InAt(0).Equals(locations->Out()));
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dst = locations->Out().AsFpuRegister<XmmRegister>();
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 fb6e4e753f..72c766fca0 100644
--- a/compiler/optimizing/code_generator_vector_x86_64.cc
+++ b/compiler/optimizing/code_generator_vector_x86_64.cc
@@ -980,7 +980,8 @@ void LocationsBuilderX86_64::VisitVecShl(HVecShl* instruction) {
void InstructionCodeGeneratorX86_64::VisitVecShl(HVecShl* instruction) {
LocationSummary* locations = instruction->GetLocations();
DCHECK(locations->InAt(0).Equals(locations->Out()));
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dst = locations->Out().AsFpuRegister<XmmRegister>();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint16:
@@ -1009,7 +1010,8 @@ void LocationsBuilderX86_64::VisitVecShr(HVecShr* instruction) {
void InstructionCodeGeneratorX86_64::VisitVecShr(HVecShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
DCHECK(locations->InAt(0).Equals(locations->Out()));
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dst = locations->Out().AsFpuRegister<XmmRegister>();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint16:
@@ -1034,7 +1036,8 @@ void LocationsBuilderX86_64::VisitVecUShr(HVecUShr* instruction) {
void InstructionCodeGeneratorX86_64::VisitVecUShr(HVecUShr* instruction) {
LocationSummary* locations = instruction->GetLocations();
DCHECK(locations->InAt(0).Equals(locations->Out()));
- int32_t value = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dst = locations->Out().AsFpuRegister<XmmRegister>();
switch (instruction->GetPackedType()) {
case DataType::Type::kUint16:
diff --git a/compiler/optimizing/code_generator_x86.cc b/compiler/optimizing/code_generator_x86.cc
index 3dacbdc2c4..e19d49b6db 100644
--- a/compiler/optimizing/code_generator_x86.cc
+++ b/compiler/optimizing/code_generator_x86.cc
@@ -164,7 +164,8 @@ class BoundsCheckSlowPathX86 : public SlowPathCode {
// Are we using an array length from memory?
if (!length_loc.IsValid()) {
DCHECK(instruction_->InputAt(1)->IsArrayLength());
- HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLength();
+ // TODO: Remove "OrNull".
+ HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLengthOrNull();
DCHECK(array_length->IsEmittedAtUseSite());
uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length);
Location array_loc = array_length->GetLocations()->InAt(0);
@@ -206,7 +207,8 @@ class BoundsCheckSlowPathX86 : public SlowPathCode {
DataType::Type::kInt32);
}
- QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt()
+ // TODO: Remove "OrNull".
+ QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt()
? kQuickThrowStringBounds
: kQuickThrowArrayBounds;
x86_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this);
@@ -273,7 +275,8 @@ class LoadStringSlowPathX86 : public SlowPathCode {
SaveLiveRegisters(codegen, locations);
InvokeRuntimeCallingConvention calling_convention;
- const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex();
+ // TODO: Remove "OrNull".
+ const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex();
__ movl(calling_convention.GetRegisterAt(0), Immediate(string_index.index_));
x86_codegen->InvokeRuntime(kQuickResolveString, instruction_, instruction_->GetDexPc(), this);
CheckEntrypointTypes<kQuickResolveString, void*, uint32_t>();
@@ -367,7 +370,8 @@ class TypeCheckSlowPathX86 : public SlowPathCode {
if (kPoisonHeapReferences &&
instruction_->IsCheckCast() &&
- instruction_->AsCheckCast()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) {
+ // TODO: Remove "OrNull".
+ instruction_->AsCheckCastOrNull()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) {
// First, unpoison the `cls` reference that was poisoned for direct memory comparison.
__ UnpoisonHeapReference(locations->InAt(1).AsRegister<Register>());
}
@@ -432,7 +436,8 @@ class DeoptimizationSlowPathX86 : public SlowPathCode {
InvokeRuntimeCallingConvention calling_convention;
x86_codegen->Load32BitValue(
calling_convention.GetRegisterAt(0),
- static_cast<uint32_t>(instruction_->AsDeoptimize()->GetDeoptimizationKind()));
+ // TODO: Remove "OrNull".
+ static_cast<uint32_t>(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind()));
x86_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this);
CheckEntrypointTypes<kQuickDeoptimize, void, DeoptimizationKind>();
}
@@ -603,7 +608,8 @@ class ReadBarrierMarkAndUpdateFieldSlowPathX86 : public SlowPathCode {
DCHECK((instruction_->IsInvoke() && instruction_->GetLocations()->Intrinsified()))
<< "Unexpected instruction in read barrier marking and field updating slow path: "
<< instruction_->DebugName();
- HInvoke* invoke = instruction_->AsInvoke();
+ // TODO: Remove "OrNull".
+ HInvoke* invoke = instruction_->AsInvokeOrNull();
DCHECK(IsUnsafeCASObject(invoke) || IsVarHandleCASFamily(invoke)) << invoke->GetIntrinsic();
__ Bind(GetEntryLabel());
@@ -836,13 +842,17 @@ class ReadBarrierForHeapReferenceSlowPathX86 : public SlowPathCode {
// to an object field within an object.
DCHECK(instruction_->IsInvoke()) << instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- DCHECK((instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) ||
- (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObjectVolatile) ||
- (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObject) ||
- (instruction_->AsInvoke()->GetIntrinsic() ==
+ // TODO: Remove "OrNull".
+ DCHECK((instruction_->AsInvokeOrNull()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) ||
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
+ Intrinsics::kUnsafeGetObjectVolatile) ||
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
+ Intrinsics::kJdkUnsafeGetObject) ||
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
Intrinsics::kJdkUnsafeGetObjectVolatile) ||
- (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObjectAcquire))
- << instruction_->AsInvoke()->GetIntrinsic();
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
+ Intrinsics::kJdkUnsafeGetObjectAcquire))
+ << instruction_->AsInvokeOrNull()->GetIntrinsic();
DCHECK_EQ(offset_, 0U);
DCHECK(index_.IsRegisterPair());
// UnsafeGet's offset location is a register pair, the low
@@ -1836,7 +1846,8 @@ void InstructionCodeGeneratorX86::HandleGoto(HInstruction* got, HBasicBlock* suc
}
if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) {
- GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr);
+ // TODO: Remove "OrNull".
+ GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr);
}
if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) {
__ jmp(codegen_->GetLabelOf(successor));
@@ -1930,7 +1941,8 @@ void InstructionCodeGeneratorX86::GenerateLongComparesAndJumps(HCondition* cond,
}
if (right.IsConstant()) {
- int64_t value = right.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = right.GetConstant()->AsLongConstantOrNull()->GetValue();
int32_t val_high = High32Bits(value);
int32_t val_low = Low32Bits(value);
@@ -1982,7 +1994,7 @@ void InstructionCodeGeneratorX86::GenerateFPCompare(Location lhs,
Location rhs,
HInstruction* insn,
bool is_double) {
- HX86LoadFromConstantTable* const_area = insn->InputAt(1)->AsX86LoadFromConstantTable();
+ HX86LoadFromConstantTable* const_area = insn->InputAt(1)->AsX86LoadFromConstantTableOrNull();
if (is_double) {
if (rhs.IsFpuRegister()) {
__ ucomisd(lhs.AsFpuRegister<XmmRegister>(), rhs.AsFpuRegister<XmmRegister>());
@@ -1990,7 +2002,8 @@ void InstructionCodeGeneratorX86::GenerateFPCompare(Location lhs,
DCHECK(const_area->IsEmittedAtUseSite());
__ ucomisd(lhs.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- const_area->GetConstant()->AsDoubleConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -2004,7 +2017,8 @@ void InstructionCodeGeneratorX86::GenerateFPCompare(Location lhs,
DCHECK(const_area->IsEmittedAtUseSite());
__ ucomiss(lhs.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- const_area->GetConstant()->AsFloatConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -2076,12 +2090,14 @@ void InstructionCodeGeneratorX86::GenerateTestAndBranch(HInstruction* instructio
return;
} else if (cond->IsIntConstant()) {
// Constant condition, statically compared against "true" (integer value 1).
- if (cond->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (cond->AsIntConstantOrNull()->IsTrue()) {
if (true_target != nullptr) {
__ jmp(true_target);
}
} else {
- DCHECK(cond->AsIntConstant()->IsFalse()) << cond->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << cond->AsIntConstantOrNull()->GetValue();
if (false_target != nullptr) {
__ jmp(false_target);
}
@@ -2100,9 +2116,11 @@ void InstructionCodeGeneratorX86::GenerateTestAndBranch(HInstruction* instructio
if (IsBooleanValueOrMaterializedCondition(cond)) {
if (AreEflagsSetFrom(cond, instruction)) {
if (true_target == nullptr) {
- __ j(X86Condition(cond->AsCondition()->GetOppositeCondition()), false_target);
+ // TODO: Remove "OrNull".
+ __ j(X86Condition(cond->AsConditionOrNull()->GetOppositeCondition()), false_target);
} else {
- __ j(X86Condition(cond->AsCondition()->GetCondition()), true_target);
+ // TODO: Remove "OrNull".
+ __ j(X86Condition(cond->AsConditionOrNull()->GetCondition()), true_target);
}
} else {
// Materialized condition, compare against 0.
@@ -2121,7 +2139,8 @@ void InstructionCodeGeneratorX86::GenerateTestAndBranch(HInstruction* instructio
} else {
// Condition has not been materialized, use its inputs as the comparison and
// its condition as the branch condition.
- HCondition* condition = cond->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = cond->AsConditionOrNull();
// If this is a long or FP comparison that has been folded into
// the HCondition, generate the comparison directly.
@@ -2254,7 +2273,8 @@ void InstructionCodeGeneratorX86::VisitSelect(HSelect* select) {
// Figure out how to test the 'condition'.
if (select_condition->IsCondition()) {
- HCondition* condition = select_condition->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = select_condition->AsConditionOrNull();
if (!condition->IsEmittedAtUseSite()) {
// This was a previously materialized condition.
// Can we use the existing condition code?
@@ -3152,7 +3172,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movzxb(out.AsRegister<Register>(), in.AsRegister<ByteRegister>());
} else {
DCHECK(in.GetConstant()->IsIntConstant());
- int32_t value = in.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<uint8_t>(value)));
}
break;
@@ -3161,7 +3182,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movzxb(out.AsRegister<Register>(), in.AsRegisterPairLow<ByteRegister>());
} else {
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<uint8_t>(value)));
}
break;
@@ -3182,7 +3204,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movsxb(out.AsRegister<Register>(), in.AsRegister<ByteRegister>());
} else {
DCHECK(in.GetConstant()->IsIntConstant());
- int32_t value = in.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<int8_t>(value)));
}
break;
@@ -3191,7 +3214,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movsxb(out.AsRegister<Register>(), in.AsRegisterPairLow<ByteRegister>());
} else {
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<int8_t>(value)));
}
break;
@@ -3213,7 +3237,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movzxw(out.AsRegister<Register>(), Address(ESP, in.GetStackIndex()));
} else {
DCHECK(in.GetConstant()->IsIntConstant());
- int32_t value = in.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<uint16_t>(value)));
}
break;
@@ -3224,7 +3249,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movzxw(out.AsRegister<Register>(), Address(ESP, in.GetStackIndex()));
} else {
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<uint16_t>(value)));
}
break;
@@ -3245,7 +3271,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movsxw(out.AsRegister<Register>(), Address(ESP, in.GetStackIndex()));
} else {
DCHECK(in.GetConstant()->IsIntConstant());
- int32_t value = in.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = in.GetConstant()->AsIntConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<int16_t>(value)));
}
break;
@@ -3256,7 +3283,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
__ movsxw(out.AsRegister<Register>(), Address(ESP, in.GetStackIndex()));
} else {
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<int16_t>(value)));
}
break;
@@ -3277,7 +3305,8 @@ void InstructionCodeGeneratorX86::VisitTypeConversion(HTypeConversion* conversio
} else {
DCHECK(in.IsConstant());
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(out.AsRegister<Register>(), Immediate(static_cast<int32_t>(value)));
}
break;
@@ -3528,7 +3557,8 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) {
first.AsRegister<Register>(), second.AsRegister<Register>(), TIMES_1, 0));
}
} else if (second.IsConstant()) {
- int32_t value = second.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = second.GetConstant()->AsIntConstantOrNull()->GetValue();
if (out.AsRegister<Register>() == first.AsRegister<Register>()) {
__ addl(out.AsRegister<Register>(), Immediate(value));
} else {
@@ -3551,7 +3581,8 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) {
Address(ESP, second.GetHighStackIndex(kX86WordSize)));
} else {
DCHECK(second.IsConstant()) << second;
- int64_t value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
__ addl(first.AsRegisterPairLow<Register>(), Immediate(Low32Bits(value)));
__ adcl(first.AsRegisterPairHigh<Register>(), Immediate(High32Bits(value)));
}
@@ -3562,11 +3593,13 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) {
if (second.IsFpuRegister()) {
__ addss(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (add->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ addss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- const_area->GetConstant()->AsFloatConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -3580,11 +3613,13 @@ void InstructionCodeGeneratorX86::VisitAdd(HAdd* add) {
if (second.IsFpuRegister()) {
__ addsd(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (add->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = add->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ addsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- const_area->GetConstant()->AsDoubleConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -3640,7 +3675,8 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) {
__ subl(first.AsRegister<Register>(), second.AsRegister<Register>());
} else if (second.IsConstant()) {
__ subl(first.AsRegister<Register>(),
- Immediate(second.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ subl(first.AsRegister<Register>(), Address(ESP, second.GetStackIndex()));
}
@@ -3657,7 +3693,8 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) {
Address(ESP, second.GetHighStackIndex(kX86WordSize)));
} else {
DCHECK(second.IsConstant()) << second;
- int64_t value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
__ subl(first.AsRegisterPairLow<Register>(), Immediate(Low32Bits(value)));
__ sbbl(first.AsRegisterPairHigh<Register>(), Immediate(High32Bits(value)));
}
@@ -3668,11 +3705,13 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) {
if (second.IsFpuRegister()) {
__ subss(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (sub->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ subss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- const_area->GetConstant()->AsFloatConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -3686,11 +3725,13 @@ void InstructionCodeGeneratorX86::VisitSub(HSub* sub) {
if (second.IsFpuRegister()) {
__ subsd(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (sub->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = sub->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ subsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- const_area->GetConstant()->AsDoubleConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -3758,7 +3799,8 @@ 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()) {
- Immediate imm(mul->InputAt(1)->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ Immediate imm(mul->InputAt(1)->AsIntConstantOrNull()->GetValue());
__ imull(out.AsRegister<Register>(), first.AsRegister<Register>(), imm);
} else if (second.IsRegister()) {
DCHECK(first.Equals(out));
@@ -3787,7 +3829,8 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) {
if (second.IsConstant()) {
DCHECK(second.GetConstant()->IsLongConstant());
- int64_t value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
int32_t low_value = Low32Bits(value);
int32_t high_value = High32Bits(value);
Immediate low(low_value);
@@ -3857,11 +3900,13 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) {
if (second.IsFpuRegister()) {
__ mulss(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (mul->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ mulss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- const_area->GetConstant()->AsFloatConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -3876,11 +3921,13 @@ void InstructionCodeGeneratorX86::VisitMul(HMul* mul) {
if (second.IsFpuRegister()) {
__ mulsd(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (mul->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = mul->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ mulsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- const_area->GetConstant()->AsDoubleConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -4000,7 +4047,8 @@ void InstructionCodeGeneratorX86::DivRemOneOrMinusOne(HBinaryOperation* instruct
Register out_register = locations->Out().AsRegister<Register>();
Register input_register = locations->InAt(0).AsRegister<Register>();
- int32_t imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t imm = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
DCHECK(imm == 1 || imm == -1);
@@ -4041,7 +4089,8 @@ void InstructionCodeGeneratorX86::DivByPowerOfTwo(HDiv* instruction) {
Register out_register = locations->Out().AsRegister<Register>();
Register input_register = locations->InAt(0).AsRegister<Register>();
- int32_t imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t imm = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
DCHECK(IsPowerOfTwo(AbsOrMin(imm)));
uint32_t abs_imm = static_cast<uint32_t>(AbsOrMin(imm));
@@ -4064,7 +4113,8 @@ void InstructionCodeGeneratorX86::GenerateDivRemWithAnyConstant(HBinaryOperation
DCHECK(instruction->IsDiv() || instruction->IsRem());
LocationSummary* locations = instruction->GetLocations();
- int imm = locations->InAt(1).GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int imm = locations->InAt(1).GetConstant()->AsIntConstantOrNull()->GetValue();
Register eax = locations->InAt(0).AsRegister<Register>();
Register out = locations->Out().AsRegister<Register>();
@@ -4142,7 +4192,8 @@ void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instr
DCHECK_EQ(is_div ? EAX : EDX, out.AsRegister<Register>());
if (second.IsConstant()) {
- int32_t imm = second.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t imm = second.GetConstant()->AsIntConstantOrNull()->GetValue();
if (imm == 0) {
// Do not generate anything for 0. DivZeroCheck would forbid any generated code.
@@ -4150,9 +4201,11 @@ void InstructionCodeGeneratorX86::GenerateDivRemIntegral(HBinaryOperation* instr
DivRemOneOrMinusOne(instruction);
} else if (IsPowerOfTwo(AbsOrMin(imm))) {
if (is_div) {
- DivByPowerOfTwo(instruction->AsDiv());
+ // TODO: Remove "OrNull".
+ DivByPowerOfTwo(instruction->AsDivOrNull());
} else {
- RemByPowerOfTwo(instruction->AsRem());
+ // TODO: Remove "OrNull".
+ RemByPowerOfTwo(instruction->AsRemOrNull());
}
} else {
DCHECK(imm <= -2 || imm >= 2);
@@ -4270,11 +4323,13 @@ void InstructionCodeGeneratorX86::VisitDiv(HDiv* div) {
if (second.IsFpuRegister()) {
__ divss(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (div->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ divss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- const_area->GetConstant()->AsFloatConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsFloatConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -4288,11 +4343,13 @@ void InstructionCodeGeneratorX86::VisitDiv(HDiv* div) {
if (second.IsFpuRegister()) {
__ divsd(first.AsFpuRegister<XmmRegister>(), second.AsFpuRegister<XmmRegister>());
} else if (div->InputAt(1)->IsX86LoadFromConstantTable()) {
- HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTable();
+ // TODO: Remove "OrNull".
+ HX86LoadFromConstantTable* const_area = div->InputAt(1)->AsX86LoadFromConstantTableOrNull();
DCHECK(const_area->IsEmittedAtUseSite());
__ divsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- const_area->GetConstant()->AsDoubleConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ const_area->GetConstant()->AsDoubleConstantOrNull()->GetValue(),
const_area->GetBaseMethodAddress(),
const_area->GetLocations()->InAt(0).AsRegister<Register>()));
} else {
@@ -4712,7 +4769,8 @@ void InstructionCodeGeneratorX86::VisitDivZeroCheck(HDivZeroCheck* instruction)
__ j(kEqual, slow_path->GetEntryLabel());
} else {
DCHECK(value.IsConstant()) << value;
- if (value.GetConstant()->AsIntConstant()->GetValue() == 0) {
+ // TODO: Remove "OrNull".
+ if (value.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) {
__ jmp(slow_path->GetEntryLabel());
}
}
@@ -4726,7 +4784,8 @@ void InstructionCodeGeneratorX86::VisitDivZeroCheck(HDivZeroCheck* instruction)
__ j(kEqual, slow_path->GetEntryLabel());
} else {
DCHECK(value.IsConstant()) << value;
- if (value.GetConstant()->AsLongConstant()->GetValue() == 0) {
+ // TODO: Remove "OrNull".
+ if (value.GetConstant()->AsLongConstantOrNull()->GetValue() == 0) {
__ jmp(slow_path->GetEntryLabel());
}
}
@@ -4781,7 +4840,9 @@ void InstructionCodeGeneratorX86::HandleShift(HBinaryOperation* op) {
__ shrl(first_reg, second_reg);
}
} else {
- int32_t shift = second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance;
+ // TODO: Remove "OrNull".
+ int32_t shift =
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance;
if (shift == 0) {
return;
}
@@ -4809,7 +4870,9 @@ void InstructionCodeGeneratorX86::HandleShift(HBinaryOperation* op) {
}
} else {
// Shift by a constant.
- int32_t shift = second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance;
+ // TODO: Remove "OrNull".
+ int32_t shift =
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance;
// Nothing to do if the shift is 0, as the input is already the output.
if (shift != 0) {
if (op->IsShl()) {
@@ -4966,7 +5029,9 @@ void InstructionCodeGeneratorX86::VisitRor(HRor* ror) {
Register second_reg = second.AsRegister<Register>();
__ rorl(first_reg, second_reg);
} else {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance);
+ // TODO: Remove "OrNull".
+ Immediate imm(
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance);
__ rorl(first_reg, imm);
}
return;
@@ -4987,7 +5052,9 @@ void InstructionCodeGeneratorX86::VisitRor(HRor* ror) {
__ cmovl(kNotEqual, first_reg_hi, first_reg_lo);
__ cmovl(kNotEqual, first_reg_lo, temp_reg);
} else {
- int32_t shift_amt = second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance;
+ // TODO: Remove "OrNull".
+ int32_t shift_amt =
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance;
if (shift_amt == 0) {
// Already fine.
return;
@@ -5230,7 +5297,8 @@ void InstructionCodeGeneratorX86::VisitCompare(HCompare* compare) {
if (right.IsConstant()) {
DCHECK(right.GetConstant()->IsLongConstant());
right_is_const = true;
- int64_t val = right.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t val = right.GetConstant()->AsLongConstantOrNull()->GetValue();
val_low = Low32Bits(val);
val_high = High32Bits(val);
}
@@ -5331,11 +5399,13 @@ HInvokeStaticOrDirect::DispatchInfo CodeGeneratorX86::GetSupportedInvokeStaticOr
Register CodeGeneratorX86::GetInvokeExtraParameter(HInvoke* invoke, Register temp) {
if (invoke->IsInvokeStaticOrDirect()) {
- return GetInvokeStaticOrDirectExtraParameter(invoke->AsInvokeStaticOrDirect(), temp);
+ // TODO: Remove "OrNull".
+ return GetInvokeStaticOrDirectExtraParameter(invoke->AsInvokeStaticOrDirectOrNull(), temp);
}
DCHECK(invoke->IsInvokeInterface());
+ // TODO: Remove "OrNull".
Location location =
- invoke->GetLocations()->InAt(invoke->AsInvokeInterface()->GetSpecialInputIndex());
+ invoke->GetLocations()->InAt(invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex());
return location.AsRegister<Register>();
}
@@ -5375,13 +5445,15 @@ void CodeGeneratorX86::LoadMethod(MethodLoadKind load_kind, Location temp, HInvo
break;
}
case MethodLoadKind::kBootImageRelRo: {
+ // TODO: Remove "OrNull".
size_t index = invoke->IsInvokeInterface()
- ? invoke->AsInvokeInterface()->GetSpecialInputIndex()
- : invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex();
+ ? invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex()
+ : invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex();
Register base_reg = GetInvokeExtraParameter(invoke, temp.AsRegister<Register>());
__ movl(temp.AsRegister<Register>(), Address(base_reg, kPlaceholder32BitOffset));
RecordBootImageRelRoPatch(
- invoke->InputAt(index)->AsX86ComputeBaseMethodAddress(),
+ // TODO: Remove "OrNull".
+ invoke->InputAt(index)->AsX86ComputeBaseMethodAddressOrNull(),
GetBootImageOffset(invoke));
break;
}
@@ -5562,11 +5634,13 @@ void CodeGeneratorX86::RecordBootImageRelRoPatch(HX86ComputeBaseMethodAddress* m
}
void CodeGeneratorX86::RecordBootImageMethodPatch(HInvoke* invoke) {
+ // TODO: Remove "OrNull".
size_t index = invoke->IsInvokeInterface()
- ? invoke->AsInvokeInterface()->GetSpecialInputIndex()
- : invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex();
+ ? invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex()
+ : invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex();
+ // TODO: Remove "OrNull".
HX86ComputeBaseMethodAddress* method_address =
- invoke->InputAt(index)->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(index)->AsX86ComputeBaseMethodAddressOrNull();
boot_image_method_patches_.emplace_back(
method_address,
invoke->GetResolvedMethodReference().dex_file,
@@ -5575,15 +5649,17 @@ void CodeGeneratorX86::RecordBootImageMethodPatch(HInvoke* invoke) {
}
void CodeGeneratorX86::RecordMethodBssEntryPatch(HInvoke* invoke) {
+ // TODO: Remove "OrNull".
size_t index = invoke->IsInvokeInterface()
- ? invoke->AsInvokeInterface()->GetSpecialInputIndex()
- : invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex();
+ ? invoke->AsInvokeInterfaceOrNull()->GetSpecialInputIndex()
+ : invoke->AsInvokeStaticOrDirectOrNull()->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)->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(index)->AsX86ComputeBaseMethodAddressOrNull();
// Add the patch entry and bind its label at the end of the instruction.
method_bss_entry_patches_.emplace_back(
method_address,
@@ -5593,16 +5669,18 @@ void CodeGeneratorX86::RecordMethodBssEntryPatch(HInvoke* invoke) {
}
void CodeGeneratorX86::RecordBootImageTypePatch(HLoadClass* load_class) {
+ // TODO: Remove "OrNull".
HX86ComputeBaseMethodAddress* method_address =
- load_class->InputAt(0)->AsX86ComputeBaseMethodAddress();
+ load_class->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull();
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)->AsX86ComputeBaseMethodAddress();
+ load_class->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull();
ArenaDeque<X86PcRelativePatchInfo>* patches = nullptr;
switch (load_class->GetLoadKind()) {
case HLoadClass::LoadKind::kBssEntry:
@@ -5624,24 +5702,27 @@ Label* CodeGeneratorX86::NewTypeBssEntryPatch(HLoadClass* load_class) {
}
void CodeGeneratorX86::RecordBootImageStringPatch(HLoadString* load_string) {
+ // TODO: Remove "OrNull".
HX86ComputeBaseMethodAddress* method_address =
- load_string->InputAt(0)->AsX86ComputeBaseMethodAddress();
+ load_string->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull();
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)->AsX86ComputeBaseMethodAddress();
+ load_string->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull();
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())->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull();
boot_image_jni_entrypoint_patches_.emplace_back(
method_address,
invoke->GetResolvedMethodReference().dex_file,
@@ -5653,16 +5734,18 @@ 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())->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull();
DCHECK(method_address != nullptr);
Register method_address_reg =
invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()).AsRegister<Register>();
__ 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())->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull();
DCHECK(method_address != nullptr);
Register method_address_reg =
invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()).AsRegister<Register>();
@@ -5681,8 +5764,9 @@ 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())->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(invoke->GetSpecialInputIndex())->AsX86ComputeBaseMethodAddressOrNull();
DCHECK(method_address != nullptr);
Register method_address_reg =
invoke->GetLocations()->InAt(invoke->GetSpecialInputIndex()).AsRegister<Register>();
@@ -6101,7 +6185,9 @@ void InstructionCodeGeneratorX86::HandleFieldSet(HInstruction* instruction,
DataType::Type field_type = field_info.GetFieldType();
uint32_t offset = field_info.GetFieldOffset().Uint32Value();
bool is_predicated =
- instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet();
+ instruction->IsInstanceFieldSet() &&
+ // TODO: Remove "OrNull".
+ instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet();
Address field_addr(base, offset);
@@ -6355,8 +6441,9 @@ 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()->AsIntConstant()->GetValue() << TIMES_4) + data_offset;
+ (index.GetConstant()->AsIntConstantOrNull()->GetValue() << TIMES_4) + data_offset;
codegen_->MaybeGenerateReadBarrierSlow(instruction, out_loc, out_loc, obj_loc, offset);
} else {
codegen_->MaybeGenerateReadBarrierSlow(
@@ -6595,7 +6682,8 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) {
value.AsRegisterPairHigh<Register>());
} else {
DCHECK(value.IsConstant());
- int64_t val = value.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t val = value.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(CodeGeneratorX86::ArrayAddress(array, index, TIMES_8, data_offset),
Immediate(Low32Bits(val)));
codegen_->MaybeRecordImplicitNullCheck(instruction);
@@ -6612,7 +6700,9 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) {
__ movss(address, value.AsFpuRegister<XmmRegister>());
} else {
DCHECK(value.IsConstant());
- int32_t v = bit_cast<int32_t, float>(value.GetConstant()->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int32_t v =
+ bit_cast<int32_t, float>(value.GetConstant()->AsFloatConstantOrNull()->GetValue());
__ movl(address, Immediate(v));
}
codegen_->MaybeRecordImplicitNullCheck(instruction);
@@ -6628,7 +6718,9 @@ void InstructionCodeGeneratorX86::VisitArraySet(HArraySet* instruction) {
DCHECK(value.IsConstant());
Address address_hi =
CodeGeneratorX86::ArrayAddress(array, index, TIMES_8, offset + kX86WordSize);
- int64_t v = bit_cast<int64_t, double>(value.GetConstant()->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int64_t v =
+ bit_cast<int64_t, double>(value.GetConstant()->AsDoubleConstantOrNull()->GetValue());
__ movl(address, Immediate(Low32Bits(v)));
codegen_->MaybeRecordImplicitNullCheck(instruction);
__ movl(address_hi, Immediate(High32Bits(v)));
@@ -6720,7 +6812,9 @@ void InstructionCodeGeneratorX86::VisitBoundsCheck(HBoundsCheck* instruction) {
if (array_length->IsEmittedAtUseSite()) {
// Address the length field in the array.
DCHECK(array_length->IsArrayLength());
- uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLength());
+ // TODO: Remove "OrNull".
+ uint32_t len_offset =
+ CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLengthOrNull());
Location array_loc = array_length->GetLocations()->InAt(0);
Address array_len(array_loc.AsRegister<Register>(), len_offset);
if (is_string_compressed_char_at) {
@@ -6757,7 +6851,8 @@ void LocationsBuilderX86::VisitParallelMove(HParallelMove* instruction ATTRIBUTE
void InstructionCodeGeneratorX86::VisitParallelMove(HParallelMove* instruction) {
if (instruction->GetNext()->IsSuspendCheck() &&
instruction->GetBlock()->GetLoopInformation() != nullptr) {
- HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck();
+ // TODO: Remove "OrNull".
+ HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull();
// The back edge will generate the suspend check.
codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction);
}
@@ -6936,7 +7031,8 @@ void ParallelMoveResolverX86::EmitMove(size_t index) {
__ movl(Address(ESP, destination.GetStackIndex()), Immediate(value));
}
} else if (constant->IsFloatConstant()) {
- float fp_value = constant->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float fp_value = constant->AsFloatConstantOrNull()->GetValue();
int32_t value = bit_cast<int32_t, float>(fp_value);
Immediate imm(value);
if (destination.IsFpuRegister()) {
@@ -6956,7 +7052,8 @@ void ParallelMoveResolverX86::EmitMove(size_t index) {
__ movl(Address(ESP, destination.GetStackIndex()), imm);
}
} else if (constant->IsLongConstant()) {
- int64_t value = constant->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = constant->AsLongConstantOrNull()->GetValue();
int32_t low_value = Low32Bits(value);
int32_t high_value = High32Bits(value);
Immediate low(low_value);
@@ -6970,7 +7067,8 @@ void ParallelMoveResolverX86::EmitMove(size_t index) {
}
} else {
DCHECK(constant->IsDoubleConstant());
- double dbl_value = constant->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double dbl_value = constant->AsDoubleConstantOrNull()->GetValue();
int64_t value = bit_cast<int64_t, double>(dbl_value);
int32_t low_value = Low32Bits(value);
int32_t high_value = High32Bits(value);
@@ -7244,7 +7342,8 @@ void InstructionCodeGeneratorX86::VisitLoadClass(HLoadClass* cls) NO_THREAD_SAFE
DCHECK(!codegen_->GetCompilerOptions().IsBootImage());
Register method_address = locations->InAt(0).AsRegister<Register>();
__ movl(out, Address(method_address, CodeGeneratorX86::kPlaceholder32BitOffset));
- codegen_->RecordBootImageRelRoPatch(cls->InputAt(0)->AsX86ComputeBaseMethodAddress(),
+ // TODO: Remove "OrNull".
+ codegen_->RecordBootImageRelRoPatch(cls->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(),
CodeGenerator::GetBootImageOffset(cls));
break;
}
@@ -7437,7 +7536,8 @@ void InstructionCodeGeneratorX86::VisitLoadString(HLoadString* load) NO_THREAD_S
DCHECK(!codegen_->GetCompilerOptions().IsBootImage());
Register method_address = locations->InAt(0).AsRegister<Register>();
__ movl(out, Address(method_address, CodeGeneratorX86::kPlaceholder32BitOffset));
- codegen_->RecordBootImageRelRoPatch(load->InputAt(0)->AsX86ComputeBaseMethodAddress(),
+ // TODO: Remove "OrNull".
+ codegen_->RecordBootImageRelRoPatch(load->InputAt(0)->AsX86ComputeBaseMethodAddressOrNull(),
CodeGenerator::GetBootImageOffset(load));
return;
}
@@ -8193,14 +8293,17 @@ void InstructionCodeGeneratorX86::HandleBitwiseOperation(HBinaryOperation* instr
} else if (second.IsConstant()) {
if (instruction->IsAnd()) {
__ andl(first.AsRegister<Register>(),
- Immediate(second.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else if (instruction->IsOr()) {
__ orl(first.AsRegister<Register>(),
- Immediate(second.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
DCHECK(instruction->IsXor());
__ xorl(first.AsRegister<Register>(),
- Immediate(second.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue()));
}
} else {
if (instruction->IsAnd()) {
@@ -8243,7 +8346,8 @@ void InstructionCodeGeneratorX86::HandleBitwiseOperation(HBinaryOperation* instr
}
} else {
DCHECK(second.IsConstant()) << second;
- int64_t value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
int32_t low_value = Low32Bits(value);
int32_t high_value = High32Bits(value);
Immediate low(low_value);
@@ -8783,13 +8887,17 @@ void InstructionCodeGeneratorX86::VisitX86LoadFromConstantTable(HX86LoadFromCons
case DataType::Type::kFloat32:
__ movss(out.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- value->AsFloatConstant()->GetValue(), insn->GetBaseMethodAddress(), const_area));
+ // TODO: Remove "OrNull".
+ value->AsFloatConstantOrNull()->GetValue(),
+ insn->GetBaseMethodAddress(),
+ const_area));
break;
case DataType::Type::kFloat64:
__ movsd(out.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- value->AsDoubleConstant()->GetValue(),
+ // TODO: Remove "OrNull".
+ value->AsDoubleConstantOrNull()->GetValue(),
insn->GetBaseMethodAddress(),
const_area));
break;
@@ -8797,7 +8905,10 @@ void InstructionCodeGeneratorX86::VisitX86LoadFromConstantTable(HX86LoadFromCons
case DataType::Type::kInt32:
__ movl(out.AsRegister<Register>(),
codegen_->LiteralInt32Address(
- value->AsIntConstant()->GetValue(), insn->GetBaseMethodAddress(), const_area));
+ // TODO: Remove "OrNull".
+ value->AsIntConstantOrNull()->GetValue(),
+ insn->GetBaseMethodAddress(),
+ const_area));
break;
default:
@@ -8972,7 +9083,9 @@ Address CodeGeneratorX86::ArrayAddress(Register obj,
ScaleFactor scale,
uint32_t data_offset) {
return index.IsConstant()
- ? Address(obj, (index.GetConstant()->AsIntConstant()->GetValue() << scale) + data_offset)
+ ? Address(obj,
+ // TODO: Remove "OrNull".
+ (index.GetConstant()->AsIntConstantOrNull()->GetValue() << scale) + data_offset)
: Address(obj, index.AsRegister<Register>(), scale, data_offset);
}
diff --git a/compiler/optimizing/code_generator_x86_64.cc b/compiler/optimizing/code_generator_x86_64.cc
index df2bef747f..1170cd946f 100644
--- a/compiler/optimizing/code_generator_x86_64.cc
+++ b/compiler/optimizing/code_generator_x86_64.cc
@@ -215,7 +215,8 @@ class BoundsCheckSlowPathX86_64 : public SlowPathCode {
// Are we using an array length from memory?
if (!length_loc.IsValid()) {
DCHECK(instruction_->InputAt(1)->IsArrayLength());
- HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLength();
+ // TODO: Remove "OrNull".
+ HArrayLength* array_length = instruction_->InputAt(1)->AsArrayLengthOrNull();
DCHECK(array_length->IsEmittedAtUseSite());
uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length);
Location array_loc = array_length->GetLocations()->InAt(0);
@@ -251,7 +252,8 @@ class BoundsCheckSlowPathX86_64 : public SlowPathCode {
DataType::Type::kInt32);
}
- QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheck()->IsStringCharAt()
+ // TODO: Remove "OrNull".
+ QuickEntrypointEnum entrypoint = instruction_->AsBoundsCheckOrNull()->IsStringCharAt()
? kQuickThrowStringBounds
: kQuickThrowArrayBounds;
x86_64_codegen->InvokeRuntime(entrypoint, instruction_, instruction_->GetDexPc(), this);
@@ -343,7 +345,8 @@ class LoadStringSlowPathX86_64 : public SlowPathCode {
__ Bind(GetEntryLabel());
SaveLiveRegisters(codegen, locations);
- const dex::StringIndex string_index = instruction_->AsLoadString()->GetStringIndex();
+ // TODO: Remove "OrNull".
+ const dex::StringIndex string_index = instruction_->AsLoadStringOrNull()->GetStringIndex();
// Custom calling convention: RAX serves as both input and output.
__ movl(CpuRegister(RAX), Immediate(string_index.index_));
x86_64_codegen->InvokeRuntime(kQuickResolveString,
@@ -379,7 +382,8 @@ class TypeCheckSlowPathX86_64 : public SlowPathCode {
if (kPoisonHeapReferences &&
instruction_->IsCheckCast() &&
- instruction_->AsCheckCast()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) {
+ // TODO: Remove "OrNull".
+ instruction_->AsCheckCastOrNull()->GetTypeCheckKind() == TypeCheckKind::kInterfaceCheck) {
// First, unpoison the `cls` reference that was poisoned for direct memory comparison.
__ UnpoisonHeapReference(locations->InAt(1).AsRegister<CpuRegister>());
}
@@ -439,7 +443,8 @@ class DeoptimizationSlowPathX86_64 : public SlowPathCode {
InvokeRuntimeCallingConvention calling_convention;
x86_64_codegen->Load32BitValue(
CpuRegister(calling_convention.GetRegisterAt(0)),
- static_cast<uint32_t>(instruction_->AsDeoptimize()->GetDeoptimizationKind()));
+ // TODO: Remove "OrNull".
+ static_cast<uint32_t>(instruction_->AsDeoptimizeOrNull()->GetDeoptimizationKind()));
x86_64_codegen->InvokeRuntime(kQuickDeoptimize, instruction_, instruction_->GetDexPc(), this);
CheckEntrypointTypes<kQuickDeoptimize, void, DeoptimizationKind>();
}
@@ -617,7 +622,8 @@ class ReadBarrierMarkAndUpdateFieldSlowPathX86_64 : public SlowPathCode {
DCHECK((instruction_->IsInvoke() && instruction_->GetLocations()->Intrinsified()))
<< "Unexpected instruction in read barrier marking and field updating slow path: "
<< instruction_->DebugName();
- HInvoke* invoke = instruction_->AsInvoke();
+ // TODO: Remove "OrNull".
+ HInvoke* invoke = instruction_->AsInvokeOrNull();
DCHECK(IsUnsafeCASObject(invoke) || IsVarHandleCASFamily(invoke)) << invoke->GetIntrinsic();
__ Bind(GetEntryLabel());
@@ -853,13 +859,17 @@ class ReadBarrierForHeapReferenceSlowPathX86_64 : public SlowPathCode {
// to an object field within an object.
DCHECK(instruction_->IsInvoke()) << instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- DCHECK((instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) ||
- (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kUnsafeGetObjectVolatile) ||
- (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObject) ||
- (instruction_->AsInvoke()->GetIntrinsic() ==
+ // TODO: Remove "OrNull".
+ DCHECK((instruction_->AsInvokeOrNull()->GetIntrinsic() == Intrinsics::kUnsafeGetObject) ||
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
+ Intrinsics::kUnsafeGetObjectVolatile) ||
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
+ Intrinsics::kJdkUnsafeGetObject) ||
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
Intrinsics::kJdkUnsafeGetObjectVolatile) ||
- (instruction_->AsInvoke()->GetIntrinsic() == Intrinsics::kJdkUnsafeGetObjectAcquire))
- << instruction_->AsInvoke()->GetIntrinsic();
+ (instruction_->AsInvokeOrNull()->GetIntrinsic() ==
+ Intrinsics::kJdkUnsafeGetObjectAcquire))
+ << instruction_->AsInvokeOrNull()->GetIntrinsic();
DCHECK_EQ(offset_, 0U);
DCHECK(index_.IsRegister());
}
@@ -1840,7 +1850,8 @@ void CodeGeneratorX86_64::Move(Location destination, Location source) {
} else if (source.IsConstant()) {
HConstant* constant = source.GetConstant();
if (constant->IsLongConstant()) {
- Load64BitValue(dest, constant->AsLongConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ Load64BitValue(dest, constant->AsLongConstantOrNull()->GetValue());
} else if (constant->IsDoubleConstant()) {
Load64BitValue(dest, GetInt64ValueOf(constant));
} else {
@@ -1980,7 +1991,8 @@ void InstructionCodeGeneratorX86_64::HandleGoto(HInstruction* got, HBasicBlock*
}
if (block->IsEntryBlock() && (previous != nullptr) && previous->IsSuspendCheck()) {
- GenerateSuspendCheck(previous->AsSuspendCheck(), nullptr);
+ // TODO: Remove "OrNull".
+ GenerateSuspendCheck(previous->AsSuspendCheckOrNull(), nullptr);
}
if (!codegen_->GoesToNextBlock(got->GetBlock(), successor)) {
__ jmp(codegen_->GetLabelOf(successor));
@@ -2052,7 +2064,8 @@ void InstructionCodeGeneratorX86_64::GenerateCompareTest(HCondition* condition)
} else if (right.IsConstant()) {
__ ucomiss(left.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- right.GetConstant()->AsFloatConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ right.GetConstant()->AsFloatConstantOrNull()->GetValue()));
} else {
DCHECK(right.IsStackSlot());
__ ucomiss(left.AsFpuRegister<XmmRegister>(),
@@ -2066,7 +2079,8 @@ void InstructionCodeGeneratorX86_64::GenerateCompareTest(HCondition* condition)
} else if (right.IsConstant()) {
__ ucomisd(left.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- right.GetConstant()->AsDoubleConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ right.GetConstant()->AsDoubleConstantOrNull()->GetValue()));
} else {
DCHECK(right.IsDoubleStackSlot());
__ ucomisd(left.AsFpuRegister<XmmRegister>(),
@@ -2141,12 +2155,14 @@ void InstructionCodeGeneratorX86_64::GenerateTestAndBranch(HInstruction* instruc
return;
} else if (cond->IsIntConstant()) {
// Constant condition, statically compared against "true" (integer value 1).
- if (cond->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (cond->AsIntConstantOrNull()->IsTrue()) {
if (true_target != nullptr) {
__ jmp(true_target);
}
} else {
- DCHECK(cond->AsIntConstant()->IsFalse()) << cond->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ DCHECK(cond->AsIntConstantOrNull()->IsFalse()) << cond->AsIntConstantOrNull()->GetValue();
if (false_target != nullptr) {
__ jmp(false_target);
}
@@ -2165,9 +2181,12 @@ void InstructionCodeGeneratorX86_64::GenerateTestAndBranch(HInstruction* instruc
if (IsBooleanValueOrMaterializedCondition(cond)) {
if (AreEflagsSetFrom(cond, instruction)) {
if (true_target == nullptr) {
- __ j(X86_64IntegerCondition(cond->AsCondition()->GetOppositeCondition()), false_target);
+ // TODO: Remove "OrNull".
+ __ j(X86_64IntegerCondition(cond->AsConditionOrNull()->GetOppositeCondition()),
+ false_target);
} else {
- __ j(X86_64IntegerCondition(cond->AsCondition()->GetCondition()), true_target);
+ // TODO: Remove "OrNull".
+ __ j(X86_64IntegerCondition(cond->AsConditionOrNull()->GetCondition()), true_target);
}
} else {
// Materialized condition, compare against 0.
@@ -2186,7 +2205,8 @@ 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.
- HCondition* condition = cond->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = cond->AsConditionOrNull();
// If this is a long or FP comparison that has been folded into
// the HCondition, generate the comparison directly.
@@ -2315,7 +2335,8 @@ void InstructionCodeGeneratorX86_64::VisitSelect(HSelect* select) {
// Figure out how to test the 'condition'.
if (select_condition->IsCondition()) {
- HCondition* condition = select_condition->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = select_condition->AsConditionOrNull();
if (!condition->IsEmittedAtUseSite()) {
// This was a previously materialized condition.
// Can we use the existing condition code?
@@ -2435,7 +2456,8 @@ void InstructionCodeGeneratorX86_64::HandleCondition(HCondition* cond) {
case DataType::Type::kFloat32: {
XmmRegister lhs_reg = lhs.AsFpuRegister<XmmRegister>();
if (rhs.IsConstant()) {
- float value = rhs.GetConstant()->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float value = rhs.GetConstant()->AsFloatConstantOrNull()->GetValue();
__ ucomiss(lhs_reg, codegen_->LiteralFloatAddress(value));
} else if (rhs.IsStackSlot()) {
__ ucomiss(lhs_reg, Address(CpuRegister(RSP), rhs.GetStackIndex()));
@@ -2448,7 +2470,8 @@ void InstructionCodeGeneratorX86_64::HandleCondition(HCondition* cond) {
case DataType::Type::kFloat64: {
XmmRegister lhs_reg = lhs.AsFpuRegister<XmmRegister>();
if (rhs.IsConstant()) {
- double value = rhs.GetConstant()->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double value = rhs.GetConstant()->AsDoubleConstantOrNull()->GetValue();
__ ucomisd(lhs_reg, codegen_->LiteralDoubleAddress(value));
} else if (rhs.IsDoubleStackSlot()) {
__ ucomisd(lhs_reg, Address(CpuRegister(RSP), rhs.GetStackIndex()));
@@ -2609,7 +2632,8 @@ void InstructionCodeGeneratorX86_64::VisitCompare(HCompare* compare) {
case DataType::Type::kFloat32: {
XmmRegister left_reg = left.AsFpuRegister<XmmRegister>();
if (right.IsConstant()) {
- float value = right.GetConstant()->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float value = right.GetConstant()->AsFloatConstantOrNull()->GetValue();
__ ucomiss(left_reg, codegen_->LiteralFloatAddress(value));
} else if (right.IsStackSlot()) {
__ ucomiss(left_reg, Address(CpuRegister(RSP), right.GetStackIndex()));
@@ -2623,7 +2647,8 @@ void InstructionCodeGeneratorX86_64::VisitCompare(HCompare* compare) {
case DataType::Type::kFloat64: {
XmmRegister left_reg = left.AsFpuRegister<XmmRegister>();
if (right.IsConstant()) {
- double value = right.GetConstant()->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double value = right.GetConstant()->AsDoubleConstantOrNull()->GetValue();
__ ucomisd(left_reg, codegen_->LiteralDoubleAddress(value));
} else if (right.IsDoubleStackSlot()) {
__ ucomisd(left_reg, Address(CpuRegister(RSP), right.GetStackIndex()));
@@ -3411,7 +3436,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
} else {
DCHECK(in.IsConstant());
DCHECK(in.GetConstant()->IsLongConstant());
- int64_t value = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = in.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(out.AsRegister<CpuRegister>(), Immediate(static_cast<int32_t>(value)));
}
break;
@@ -3537,7 +3563,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
if (in.IsRegister()) {
__ cvtsi2ss(out.AsFpuRegister<XmmRegister>(), in.AsRegister<CpuRegister>(), false);
} else if (in.IsConstant()) {
- int32_t v = in.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t v = in.GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dest = out.AsFpuRegister<XmmRegister>();
codegen_->Load32BitValue(dest, static_cast<float>(v));
} else {
@@ -3550,7 +3577,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
if (in.IsRegister()) {
__ cvtsi2ss(out.AsFpuRegister<XmmRegister>(), in.AsRegister<CpuRegister>(), true);
} else if (in.IsConstant()) {
- int64_t v = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t v = in.GetConstant()->AsLongConstantOrNull()->GetValue();
XmmRegister dest = out.AsFpuRegister<XmmRegister>();
codegen_->Load32BitValue(dest, static_cast<float>(v));
} else {
@@ -3563,7 +3591,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
if (in.IsFpuRegister()) {
__ cvtsd2ss(out.AsFpuRegister<XmmRegister>(), in.AsFpuRegister<XmmRegister>());
} else if (in.IsConstant()) {
- double v = in.GetConstant()->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double v = in.GetConstant()->AsDoubleConstantOrNull()->GetValue();
XmmRegister dest = out.AsFpuRegister<XmmRegister>();
codegen_->Load32BitValue(dest, static_cast<float>(v));
} else {
@@ -3589,7 +3618,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
if (in.IsRegister()) {
__ cvtsi2sd(out.AsFpuRegister<XmmRegister>(), in.AsRegister<CpuRegister>(), false);
} else if (in.IsConstant()) {
- int32_t v = in.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t v = in.GetConstant()->AsIntConstantOrNull()->GetValue();
XmmRegister dest = out.AsFpuRegister<XmmRegister>();
codegen_->Load64BitValue(dest, static_cast<double>(v));
} else {
@@ -3602,7 +3632,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
if (in.IsRegister()) {
__ cvtsi2sd(out.AsFpuRegister<XmmRegister>(), in.AsRegister<CpuRegister>(), true);
} else if (in.IsConstant()) {
- int64_t v = in.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t v = in.GetConstant()->AsLongConstantOrNull()->GetValue();
XmmRegister dest = out.AsFpuRegister<XmmRegister>();
codegen_->Load64BitValue(dest, static_cast<double>(v));
} else {
@@ -3615,7 +3646,8 @@ void InstructionCodeGeneratorX86_64::VisitTypeConversion(HTypeConversion* conver
if (in.IsFpuRegister()) {
__ cvtss2sd(out.AsFpuRegister<XmmRegister>(), in.AsFpuRegister<XmmRegister>());
} else if (in.IsConstant()) {
- float v = in.GetConstant()->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float v = in.GetConstant()->AsFloatConstantOrNull()->GetValue();
XmmRegister dest = out.AsFpuRegister<XmmRegister>();
codegen_->Load64BitValue(dest, static_cast<double>(v));
} else {
@@ -3688,10 +3720,13 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) {
} else if (second.IsConstant()) {
if (out.AsRegister<Register>() == first.AsRegister<Register>()) {
__ addl(out.AsRegister<CpuRegister>(),
- Immediate(second.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(second.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ leal(out.AsRegister<CpuRegister>(), Address(
- first.AsRegister<CpuRegister>(), second.GetConstant()->AsIntConstant()->GetValue()));
+ first.AsRegister<CpuRegister>(),
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsIntConstantOrNull()->GetValue()));
}
} else {
DCHECK(first.Equals(locations->Out()));
@@ -3712,7 +3747,8 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) {
}
} else {
DCHECK(second.IsConstant());
- int64_t value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
int32_t int32_value = Low32Bits(value);
DCHECK_EQ(int32_value, value);
if (out.AsRegister<Register>() == first.AsRegister<Register>()) {
@@ -3731,7 +3767,8 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) {
} else if (second.IsConstant()) {
__ addss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- second.GetConstant()->AsFloatConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsFloatConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsStackSlot());
__ addss(first.AsFpuRegister<XmmRegister>(),
@@ -3746,7 +3783,8 @@ void InstructionCodeGeneratorX86_64::VisitAdd(HAdd* add) {
} else if (second.IsConstant()) {
__ addsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- second.GetConstant()->AsDoubleConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsDoubleConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsDoubleStackSlot());
__ addsd(first.AsFpuRegister<XmmRegister>(),
@@ -3798,7 +3836,8 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) {
if (second.IsRegister()) {
__ subl(first.AsRegister<CpuRegister>(), second.AsRegister<CpuRegister>());
} else if (second.IsConstant()) {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ Immediate imm(second.GetConstant()->AsIntConstantOrNull()->GetValue());
__ subl(first.AsRegister<CpuRegister>(), imm);
} else {
__ subl(first.AsRegister<CpuRegister>(), Address(CpuRegister(RSP), second.GetStackIndex()));
@@ -3807,7 +3846,8 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) {
}
case DataType::Type::kInt64: {
if (second.IsConstant()) {
- int64_t value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
DCHECK(IsInt<32>(value));
__ subq(first.AsRegister<CpuRegister>(), Immediate(static_cast<int32_t>(value)));
} else {
@@ -3822,7 +3862,8 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) {
} else if (second.IsConstant()) {
__ subss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- second.GetConstant()->AsFloatConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsFloatConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsStackSlot());
__ subss(first.AsFpuRegister<XmmRegister>(),
@@ -3837,7 +3878,8 @@ void InstructionCodeGeneratorX86_64::VisitSub(HSub* sub) {
} else if (second.IsConstant()) {
__ subsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- second.GetConstant()->AsDoubleConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsDoubleConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsDoubleStackSlot());
__ subsd(first.AsFpuRegister<XmmRegister>(),
@@ -3870,7 +3912,8 @@ void LocationsBuilderX86_64::VisitMul(HMul* mul) {
locations->SetInAt(0, Location::RequiresRegister());
locations->SetInAt(1, Location::Any());
if (mul->InputAt(1)->IsLongConstant() &&
- IsInt<32>(mul->InputAt(1)->AsLongConstant()->GetValue())) {
+ // TODO: Remove "OrNull".
+ IsInt<32>(mul->InputAt(1)->AsLongConstantOrNull()->GetValue())) {
// Can use 3 operand multiply.
locations->SetOut(Location::RequiresRegister(), Location::kNoOutputOverlap);
} else {
@@ -3901,7 +3944,8 @@ 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()) {
- Immediate imm(mul->InputAt(1)->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ Immediate imm(mul->InputAt(1)->AsIntConstantOrNull()->GetValue());
__ imull(out.AsRegister<CpuRegister>(), first.AsRegister<CpuRegister>(), imm);
} else if (second.IsRegister()) {
DCHECK(first.Equals(out));
@@ -3917,7 +3961,8 @@ 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()) {
- int64_t value = mul->InputAt(1)->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = mul->InputAt(1)->AsLongConstantOrNull()->GetValue();
if (IsInt<32>(value)) {
__ imulq(out.AsRegister<CpuRegister>(), first.AsRegister<CpuRegister>(),
Immediate(static_cast<int32_t>(value)));
@@ -3945,7 +3990,8 @@ void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) {
} else if (second.IsConstant()) {
__ mulss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- second.GetConstant()->AsFloatConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsFloatConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsStackSlot());
__ mulss(first.AsFpuRegister<XmmRegister>(),
@@ -3961,7 +4007,8 @@ void InstructionCodeGeneratorX86_64::VisitMul(HMul* mul) {
} else if (second.IsConstant()) {
__ mulsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- second.GetConstant()->AsDoubleConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsDoubleConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsDoubleStackSlot());
__ mulsd(first.AsFpuRegister<XmmRegister>(),
@@ -4209,7 +4256,8 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemWithAnyConstant(HBinaryOperat
// TODO: can these branches be written as one?
if (instruction->GetResultType() == DataType::Type::kInt32) {
- int imm = second.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int imm = second.GetConstant()->AsIntConstantOrNull()->GetValue();
CalculateMagicAndShiftForDivRem(imm, false /* is_long= */, &magic, &shift);
@@ -4241,7 +4289,8 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemWithAnyConstant(HBinaryOperat
__ movl(eax, edx);
}
} else {
- int64_t imm = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t imm = second.GetConstant()->AsLongConstantOrNull()->GetValue();
DCHECK_EQ(instruction->GetResultType(), DataType::Type::kInt64);
@@ -4317,9 +4366,11 @@ void InstructionCodeGeneratorX86_64::GenerateDivRemIntegral(HBinaryOperation* in
DivRemOneOrMinusOne(instruction);
} else if (IsPowerOfTwo(AbsOrMin(imm))) {
if (is_div) {
- DivByPowerOfTwo(instruction->AsDiv());
+ // TODO: Remove "OrNull".
+ DivByPowerOfTwo(instruction->AsDivOrNull());
} else {
- RemByPowerOfTwo(instruction->AsRem());
+ // TODO: Remove "OrNull".
+ RemByPowerOfTwo(instruction->AsRemOrNull());
}
} else {
DCHECK(imm <= -2 || imm >= 2);
@@ -4407,7 +4458,8 @@ void InstructionCodeGeneratorX86_64::VisitDiv(HDiv* div) {
} else if (second.IsConstant()) {
__ divss(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralFloatAddress(
- second.GetConstant()->AsFloatConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsFloatConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsStackSlot());
__ divss(first.AsFpuRegister<XmmRegister>(),
@@ -4422,7 +4474,8 @@ void InstructionCodeGeneratorX86_64::VisitDiv(HDiv* div) {
} else if (second.IsConstant()) {
__ divsd(first.AsFpuRegister<XmmRegister>(),
codegen_->LiteralDoubleAddress(
- second.GetConstant()->AsDoubleConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ second.GetConstant()->AsDoubleConstantOrNull()->GetValue()));
} else {
DCHECK(second.IsDoubleStackSlot());
__ divsd(first.AsFpuRegister<XmmRegister>(),
@@ -4752,7 +4805,8 @@ void InstructionCodeGeneratorX86_64::VisitDivZeroCheck(HDivZeroCheck* instructio
__ j(kEqual, slow_path->GetEntryLabel());
} else {
DCHECK(value.IsConstant()) << value;
- if (value.GetConstant()->AsIntConstant()->GetValue() == 0) {
+ // TODO: Remove "OrNull".
+ if (value.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) {
__ jmp(slow_path->GetEntryLabel());
}
}
@@ -4767,7 +4821,8 @@ void InstructionCodeGeneratorX86_64::VisitDivZeroCheck(HDivZeroCheck* instructio
__ j(kEqual, slow_path->GetEntryLabel());
} else {
DCHECK(value.IsConstant()) << value;
- if (value.GetConstant()->AsLongConstant()->GetValue() == 0) {
+ // TODO: Remove "OrNull".
+ if (value.GetConstant()->AsLongConstantOrNull()->GetValue() == 0) {
__ jmp(slow_path->GetEntryLabel());
}
}
@@ -4817,7 +4872,9 @@ void InstructionCodeGeneratorX86_64::HandleShift(HBinaryOperation* op) {
__ shrl(first_reg, second_reg);
}
} else {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance);
+ // TODO: Remove "OrNull".
+ Immediate imm(
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance);
if (op->IsShl()) {
__ shll(first_reg, imm);
} else if (op->IsShr()) {
@@ -4839,7 +4896,9 @@ void InstructionCodeGeneratorX86_64::HandleShift(HBinaryOperation* op) {
__ shrq(first_reg, second_reg);
}
} else {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance);
+ // TODO: Remove "OrNull".
+ Immediate imm(
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance);
if (op->IsShl()) {
__ shlq(first_reg, imm);
} else if (op->IsShr()) {
@@ -4886,7 +4945,9 @@ void InstructionCodeGeneratorX86_64::VisitRor(HRor* ror) {
CpuRegister second_reg = second.AsRegister<CpuRegister>();
__ rorl(first_reg, second_reg);
} else {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxIntShiftDistance);
+ // TODO: Remove "OrNull".
+ Immediate imm(
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxIntShiftDistance);
__ rorl(first_reg, imm);
}
break;
@@ -4895,7 +4956,9 @@ void InstructionCodeGeneratorX86_64::VisitRor(HRor* ror) {
CpuRegister second_reg = second.AsRegister<CpuRegister>();
__ rorq(first_reg, second_reg);
} else {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue() & kMaxLongShiftDistance);
+ // TODO: Remove "OrNull".
+ Immediate imm(
+ second.GetConstant()->AsIntConstantOrNull()->GetValue() & kMaxLongShiftDistance);
__ rorq(first_reg, imm);
}
break;
@@ -5415,7 +5478,9 @@ 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() && instruction->AsInstanceFieldSet()->GetIsPredicatedSet();
+ instruction->IsInstanceFieldSet() &&
+ // TODO: Remove "OrNull".
+ instruction->AsInstanceFieldSetOrNull()->GetIsPredicatedSet();
NearLabel pred_is_null;
if (is_predicated) {
@@ -5667,8 +5732,9 @@ 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()->AsIntConstant()->GetValue() << TIMES_4) + data_offset;
+ (index.GetConstant()->AsIntConstantOrNull()->GetValue() << TIMES_4) + data_offset;
codegen_->MaybeGenerateReadBarrierSlow(instruction, out_loc, out_loc, obj_loc, offset);
} else {
codegen_->MaybeGenerateReadBarrierSlow(
@@ -5902,7 +5968,8 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) {
__ movq(address, value.AsRegister<CpuRegister>());
codegen_->MaybeRecordImplicitNullCheck(instruction);
} else {
- int64_t v = value.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t v = value.GetConstant()->AsLongConstantOrNull()->GetValue();
Address address_high =
CodeGeneratorX86_64::ArrayAddress(array, index, TIMES_8, offset + sizeof(int32_t));
codegen_->MoveInt64ToAddress(address, address_high, v, instruction);
@@ -5917,7 +5984,9 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) {
__ movss(address, value.AsFpuRegister<XmmRegister>());
} else {
DCHECK(value.IsConstant());
- int32_t v = bit_cast<int32_t, float>(value.GetConstant()->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int32_t v =
+ bit_cast<int32_t, float>(value.GetConstant()->AsFloatConstantOrNull()->GetValue());
__ movl(address, Immediate(v));
}
codegen_->MaybeRecordImplicitNullCheck(instruction);
@@ -5931,7 +6000,9 @@ void InstructionCodeGeneratorX86_64::VisitArraySet(HArraySet* instruction) {
__ movsd(address, value.AsFpuRegister<XmmRegister>());
codegen_->MaybeRecordImplicitNullCheck(instruction);
} else {
- int64_t v = bit_cast<int64_t, double>(value.GetConstant()->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ int64_t v =
+ bit_cast<int64_t, double>(value.GetConstant()->AsDoubleConstantOrNull()->GetValue());
Address address_high =
CodeGeneratorX86_64::ArrayAddress(array, index, TIMES_8, offset + sizeof(int32_t));
codegen_->MoveInt64ToAddress(address, address_high, v, instruction);
@@ -6018,7 +6089,9 @@ void InstructionCodeGeneratorX86_64::VisitBoundsCheck(HBoundsCheck* instruction)
if (array_length->IsEmittedAtUseSite()) {
// Address the length field in the array.
DCHECK(array_length->IsArrayLength());
- uint32_t len_offset = CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLength());
+ // TODO: Remove "OrNull".
+ uint32_t len_offset =
+ CodeGenerator::GetArrayLengthOffset(array_length->AsArrayLengthOrNull());
Location array_loc = array_length->GetLocations()->InAt(0);
Address array_len(array_loc.AsRegister<CpuRegister>(), len_offset);
if (mirror::kUseStringCompression && instruction->IsStringCharAt()) {
@@ -6091,7 +6164,8 @@ void LocationsBuilderX86_64::VisitParallelMove(HParallelMove* instruction ATTRIB
void InstructionCodeGeneratorX86_64::VisitParallelMove(HParallelMove* instruction) {
if (instruction->GetNext()->IsSuspendCheck() &&
instruction->GetBlock()->GetLoopInformation() != nullptr) {
- HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheck();
+ // TODO: Remove "OrNull".
+ HSuspendCheck* suspend_check = instruction->GetNext()->AsSuspendCheckOrNull();
// The back edge will generate the suspend check.
codegen_->ClearSpillSlotsFromLoopPhisInStackMap(suspend_check, instruction);
}
@@ -6222,7 +6296,8 @@ void ParallelMoveResolverX86_64::EmitMove(size_t index) {
__ movl(Address(CpuRegister(RSP), destination.GetStackIndex()), Immediate(value));
}
} else if (constant->IsLongConstant()) {
- int64_t value = constant->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = constant->AsLongConstantOrNull()->GetValue();
if (destination.IsRegister()) {
codegen_->Load64BitValue(destination.AsRegister<CpuRegister>(), value);
} else {
@@ -6230,7 +6305,8 @@ void ParallelMoveResolverX86_64::EmitMove(size_t index) {
codegen_->Store64BitValueToStack(destination, value);
}
} else if (constant->IsFloatConstant()) {
- float fp_value = constant->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float fp_value = constant->AsFloatConstantOrNull()->GetValue();
if (destination.IsFpuRegister()) {
XmmRegister dest = destination.AsFpuRegister<XmmRegister>();
codegen_->Load32BitValue(dest, fp_value);
@@ -6241,7 +6317,8 @@ void ParallelMoveResolverX86_64::EmitMove(size_t index) {
}
} else {
DCHECK(constant->IsDoubleConstant()) << constant->DebugName();
- double fp_value = constant->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double fp_value = constant->AsDoubleConstantOrNull()->GetValue();
int64_t value = bit_cast<int64_t, double>(fp_value);
if (destination.IsFpuRegister()) {
XmmRegister dest = destination.AsFpuRegister<XmmRegister>();
@@ -7452,7 +7529,8 @@ void InstructionCodeGeneratorX86_64::HandleBitwiseOperation(HBinaryOperation* in
__ xorl(first.AsRegister<CpuRegister>(), second.AsRegister<CpuRegister>());
}
} else if (second.IsConstant()) {
- Immediate imm(second.GetConstant()->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ Immediate imm(second.GetConstant()->AsIntConstantOrNull()->GetValue());
if (instruction->IsAnd()) {
__ andl(first.AsRegister<CpuRegister>(), imm);
} else if (instruction->IsOr()) {
@@ -7479,7 +7557,8 @@ void InstructionCodeGeneratorX86_64::HandleBitwiseOperation(HBinaryOperation* in
int64_t value = 0;
if (second.IsConstant()) {
second_is_constant = true;
- value = second.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ value = second.GetConstant()->AsLongConstantOrNull()->GetValue();
}
bool is_int32_value = IsInt<32>(value);
@@ -8024,7 +8103,8 @@ void CodeGeneratorX86_64::GenerateIntCompare(CpuRegister lhs, Location rhs) {
void CodeGeneratorX86_64::GenerateLongCompare(Location lhs, Location rhs) {
CpuRegister lhs_reg = lhs.AsRegister<CpuRegister>();
if (rhs.IsConstant()) {
- int64_t value = rhs.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = rhs.GetConstant()->AsLongConstantOrNull()->GetValue();
Compare64BitValue(lhs_reg, value);
} else if (rhs.IsDoubleStackSlot()) {
__ cmpq(lhs_reg, Address(CpuRegister(RSP), rhs.GetStackIndex()));
@@ -8038,7 +8118,9 @@ Address CodeGeneratorX86_64::ArrayAddress(CpuRegister obj,
ScaleFactor scale,
uint32_t data_offset) {
return index.IsConstant()
- ? Address(obj, (index.GetConstant()->AsIntConstant()->GetValue() << scale) + data_offset)
+ ? Address(obj,
+ // TODO: Remove "OrNull".
+ (index.GetConstant()->AsIntConstantOrNull()->GetValue() << scale) + data_offset)
: Address(obj, index.AsRegister<CpuRegister>(), scale, data_offset);
}
diff --git a/compiler/optimizing/code_sinking.cc b/compiler/optimizing/code_sinking.cc
index d759a16f48..8a3066521f 100644
--- a/compiler/optimizing/code_sinking.cc
+++ b/compiler/optimizing/code_sinking.cc
@@ -53,7 +53,8 @@ void CodeSinking::UncommonBranchSinking() {
// actual last instruction.
if (last->IsTryBoundary()) {
// We have an exit try boundary. Fetch the previous instruction.
- DCHECK(!last->AsTryBoundary()->IsEntry());
+ // TODO: Remove "OrNull".
+ DCHECK(!last->AsTryBoundaryOrNull()->IsEntry());
if (last->GetPrevious() == nullptr) {
DCHECK(exit_predecessor->IsSingleTryBoundary());
exit_predecessor = exit_predecessor->GetSinglePredecessor();
@@ -80,7 +81,8 @@ static bool IsInterestingInstruction(HInstruction* instruction) {
// Volatile stores cannot be moved.
if (instruction->IsInstanceFieldSet()) {
- if (instruction->AsInstanceFieldSet()->IsVolatile()) {
+ // TODO: Remove "OrNull".
+ if (instruction->AsInstanceFieldSetOrNull()->IsVolatile()) {
return false;
}
}
@@ -93,7 +95,8 @@ 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()) {
- HConstructorFence* ctor_fence = instruction->AsConstructorFence();
+ // TODO: Remove "OrNull".
+ HConstructorFence* ctor_fence = instruction->AsConstructorFenceOrNull();
// A fence with "0" inputs is dead and should've been removed in a prior pass.
DCHECK_NE(0u, ctor_fence->InputCount());
@@ -215,7 +218,8 @@ 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.
- block = user->AsPhi()->IsCatchPhi()
+ // TODO: Remove "OrNull".
+ block = user->AsPhiOrNull()->IsCatchPhi()
? block->GetDominator()
: block->GetPredecessors()[use.GetIndex()];
}
@@ -314,7 +318,8 @@ static HInstruction* FindIdealPosition(HInstruction* instruction,
DCHECK(insert_pos->IsControlFlow());
// Avoid splitting HCondition from HIf to prevent unnecessary materialization.
if (insert_pos->IsIf()) {
- HInstruction* if_input = insert_pos->AsIf()->InputAt(0);
+ // TODO: Remove "OrNull".
+ HInstruction* if_input = insert_pos->AsIfOrNull()->InputAt(0);
if (if_input == insert_pos->GetPrevious()) {
insert_pos = if_input;
}
@@ -381,7 +386,9 @@ 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() && block->GetLastInstruction()->AsTryBoundary()->IsEntry();
+ block->EndsWithTryBoundary() &&
+ // TODO: Remove "OrNull".
+ block->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry();
ArrayRef<HBasicBlock* const> successors =
ends_with_try_boundary_entry ? block->GetNormalSuccessors() :
ArrayRef<HBasicBlock* const>(block->GetSuccessors());
@@ -571,7 +578,8 @@ void CodeSinking::ReturnSinking() {
continue;
}
- HReturn* ret = pred->GetLastInstruction()->AsReturn();
+ // TODO: Remove "OrNull".
+ HReturn* ret = pred->GetLastInstruction()->AsReturnOrNull();
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.
@@ -596,7 +604,8 @@ void CodeSinking::ReturnSinking() {
continue;
}
- HReturnVoid* ret = pred->GetLastInstruction()->AsReturnVoid();
+ // TODO: Remove "OrNull".
+ HReturnVoid* ret = pred->GetLastInstruction()->AsReturnVoidOrNull();
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 5f71cb906c..53768efad6 100644
--- a/compiler/optimizing/common_arm.h
+++ b/compiler/optimizing/common_arm.h
@@ -155,12 +155,14 @@ inline vixl::aarch32::DRegister DRegisterFromS(vixl::aarch32::SRegister s) {
inline int32_t Int32ConstantFrom(HInstruction* instr) {
if (instr->IsIntConstant()) {
- return instr->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return instr->AsIntConstantOrNull()->GetValue();
} else if (instr->IsNullConstant()) {
return 0;
} else {
DCHECK(instr->IsLongConstant()) << instr->DebugName();
- const int64_t ret = instr->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ const int64_t ret = instr->AsLongConstantOrNull()->GetValue();
DCHECK_GE(ret, std::numeric_limits<int32_t>::min());
DCHECK_LE(ret, std::numeric_limits<int32_t>::max());
return ret;
@@ -174,18 +176,21 @@ inline int32_t Int32ConstantFrom(Location location) {
inline int64_t Int64ConstantFrom(Location location) {
HConstant* instr = location.GetConstant();
if (instr->IsIntConstant()) {
- return instr->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return instr->AsIntConstantOrNull()->GetValue();
} else if (instr->IsNullConstant()) {
return 0;
} else {
DCHECK(instr->IsLongConstant()) << instr->DebugName();
- return instr->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return instr->AsLongConstantOrNull()->GetValue();
}
}
inline uint64_t Uint64ConstantFrom(HInstruction* instr) {
DCHECK(instr->IsConstant()) << instr->DebugName();
- return instr->AsConstant()->GetValueAsUint64();
+ // TODO: Remove "OrNull".
+ return instr->AsConstantOrNull()->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 e2ef8d52f2..4c3f6d208c 100644
--- a/compiler/optimizing/common_arm64.h
+++ b/compiler/optimizing/common_arm64.h
@@ -260,9 +260,11 @@ inline bool Arm64CanEncodeConstantAsImmediate(HConstant* constant, HInstruction*
if (constant->IsLongConstant()) {
return false;
} else if (constant->IsFloatConstant()) {
- return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return vixl::aarch64::Assembler::IsImmFP32(constant->AsFloatConstantOrNull()->GetValue());
} else if (constant->IsDoubleConstant()) {
- return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return vixl::aarch64::Assembler::IsImmFP64(constant->AsDoubleConstantOrNull()->GetValue());
}
return IsUint<8>(value);
}
@@ -312,7 +314,9 @@ inline bool Arm64CanEncodeConstantAsImmediate(HConstant* constant, HInstruction*
}
inline Location ARM64EncodableConstantOrRegister(HInstruction* constant, HInstruction* instr) {
- if (constant->IsConstant() && Arm64CanEncodeConstantAsImmediate(constant->AsConstant(), instr)) {
+ if (constant->IsConstant() &&
+ // TODO: Remove "OrNull".
+ Arm64CanEncodeConstantAsImmediate(constant->AsConstantOrNull(), instr)) {
return Location::ConstantLocation(constant);
}
diff --git a/compiler/optimizing/constant_folding.cc b/compiler/optimizing/constant_folding.cc
index 06d19e3f29..c27d22c8d6 100644
--- a/compiler/optimizing/constant_folding.cc
+++ b/compiler/optimizing/constant_folding.cc
@@ -132,7 +132,8 @@ 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);
- if (check_input->IsConstant() && !check_input->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ if (check_input->IsConstant() && !check_input->AsConstantOrNull()->IsArithmeticZero()) {
inst->ReplaceWith(check_input);
inst->GetBlock()->RemoveInstruction(inst);
}
@@ -194,7 +195,8 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) {
if (!if_input->IsCondition()) {
return;
}
- HCondition* condition = if_input->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = if_input->AsConditionOrNull();
// We want either `==` or `!=`, since we cannot make assumptions for other conditions e.g. `>`
if (!condition->IsEqual() && !condition->IsNotEqual()) {
@@ -217,7 +219,8 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) {
// }
// Similarly with variable != constant, except that we can make guarantees in the else case.
- HConstant* constant = left->IsConstant() ? left->AsConstant() : right->AsConstant();
+ // TODO: Remove "OrNull".
+ HConstant* constant = left->IsConstant() ? left->AsConstantOrNull() : right->AsConstantOrNull();
HInstruction* variable = left->IsConstant() ? right : left;
// Don't deal with floats/doubles since they bring a lot of edge cases e.g.
@@ -238,15 +241,18 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) {
}
// Update left and right to be the ones from the HCompare.
- left = variable->AsCompare()->GetLeft();
- right = variable->AsCompare()->GetRight();
+ // TODO: Remove "OrNull".
+ left = variable->AsCompareOrNull()->GetLeft();
+ // TODO: Remove "OrNull".
+ right = variable->AsCompareOrNull()->GetRight();
// Re-check that one of them to be a constant and not the other.
if (left->IsConstant() == right->IsConstant()) {
return;
}
- constant = left->IsConstant() ? left->AsConstant() : right->AsConstant();
+ // TODO: Remove "OrNull".
+ constant = left->IsConstant() ? left->AsConstantOrNull() : right->AsConstantOrNull();
variable = left->IsConstant() ? right : left;
// Re-check floating point values.
@@ -268,12 +274,14 @@ void HConstantFoldingVisitor::VisitIf(HIf* inst) {
// we cannot make an assumption for the `else` branch.
if (variable->GetType() == DataType::Type::kBool &&
constant->IsIntConstant() &&
- (constant->AsIntConstant()->IsTrue() || constant->AsIntConstant()->IsFalse())) {
+ // TODO: Remove "OrNull".
+ (constant->AsIntConstantOrNull()->IsTrue() || constant->AsIntConstantOrNull()->IsFalse())) {
HBasicBlock* other_starting_block =
condition->IsEqual() ? inst->IfFalseSuccessor() : inst->IfTrueSuccessor();
DCHECK_NE(other_starting_block, starting_block);
- HConstant* other_constant = constant->AsIntConstant()->IsTrue() ?
+ // TODO: Remove "OrNull".
+ HConstant* other_constant = constant->AsIntConstantOrNull()->IsTrue() ?
GetGraph()->GetIntConstant(0) :
GetGraph()->GetIntConstant(1);
DCHECK_NE(other_constant, constant);
@@ -285,7 +293,8 @@ void HConstantFoldingVisitor::VisitArrayLength(HArrayLength* inst) {
HInstruction* input = inst->InputAt(0);
if (input->IsLoadString()) {
DCHECK(inst->IsStringLength());
- HLoadString* load_string = input->AsLoadString();
+ // TODO: Remove "OrNull".
+ HLoadString* load_string = input->AsLoadStringOrNull();
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)));
@@ -305,7 +314,8 @@ void HConstantFoldingVisitor::VisitTypeConversion(HTypeConversion* inst) {
void InstructionWithAbsorbingInputSimplifier::VisitShift(HBinaryOperation* instruction) {
DCHECK(instruction->IsShl() || instruction->IsShr() || instruction->IsUShr());
HInstruction* left = instruction->GetLeft();
- if (left->IsConstant() && left->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ if (left->IsConstant() && left->AsConstantOrNull()->IsArithmeticZero()) {
// Replace code looking like
// SHL dst, 0, shift_amount
// with
@@ -365,7 +375,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitAbove(HAbove* instruction) {
instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 0));
instruction->GetBlock()->RemoveInstruction(instruction);
} else if (instruction->GetLeft()->IsConstant() &&
- instruction->GetLeft()->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ instruction->GetLeft()->AsConstantOrNull()->IsArithmeticZero()) {
// Replace code looking like
// ABOVE dst, 0, src // unsigned 0 > src is always false
// with
@@ -383,7 +394,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitAboveOrEqual(HAboveOrEqual* i
instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 1));
instruction->GetBlock()->RemoveInstruction(instruction);
} else if (instruction->GetRight()->IsConstant() &&
- instruction->GetRight()->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ instruction->GetRight()->AsConstantOrNull()->IsArithmeticZero()) {
// Replace code looking like
// ABOVE_OR_EQUAL dst, src, 0 // unsigned src >= 0 is always true
// with
@@ -401,7 +413,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitBelow(HBelow* instruction) {
instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 0));
instruction->GetBlock()->RemoveInstruction(instruction);
} else if (instruction->GetRight()->IsConstant() &&
- instruction->GetRight()->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ instruction->GetRight()->AsConstantOrNull()->IsArithmeticZero()) {
// Replace code looking like
// BELOW dst, src, 0 // unsigned src < 0 is always false
// with
@@ -419,7 +432,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitBelowOrEqual(HBelowOrEqual* i
instruction->ReplaceWith(GetGraph()->GetConstant(DataType::Type::kBool, 1));
instruction->GetBlock()->RemoveInstruction(instruction);
} else if (instruction->GetLeft()->IsConstant() &&
- instruction->GetLeft()->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ instruction->GetLeft()->AsConstantOrNull()->IsArithmeticZero()) {
// Replace code looking like
// BELOW_OR_EQUAL dst, 0, src // unsigned 0 <= src is always true
// with
@@ -501,7 +515,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitAnd(HAnd* instruction) {
// CONSTANT 0
HInstruction* hnot = (left->IsNot() ? left : right);
HInstruction* hother = (left->IsNot() ? right : left);
- HInstruction* src = hnot->AsNot()->GetInput();
+ // TODO: Remove "OrNull".
+ HInstruction* src = hnot->AsNotOrNull()->GetInput();
if (src == hother) {
instruction->ReplaceWith(GetGraph()->GetConstant(type, 0));
@@ -514,9 +529,10 @@ 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->AsFloatConstant()->IsNaN()) ||
- (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstant()->IsNaN()))) {
+ ((input_cst->IsFloatConstant() && input_cst->AsFloatConstantOrNull()->IsNaN()) ||
+ (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstantOrNull()->IsNaN()))) {
// Replace code looking like
// CMP{G,L}-{FLOAT,DOUBLE} dst, src, NaN
// with
@@ -574,7 +590,8 @@ void InstructionWithAbsorbingInputSimplifier::VisitRem(HRem* instruction) {
HBasicBlock* block = instruction->GetBlock();
if (instruction->GetLeft()->IsConstant() &&
- instruction->GetLeft()->AsConstant()->IsArithmeticZero()) {
+ // TODO: Remove "OrNull".
+ instruction->GetLeft()->AsConstantOrNull()->IsArithmeticZero()) {
// Replace code looking like
// REM dst, 0, src
// with
@@ -583,7 +600,7 @@ void InstructionWithAbsorbingInputSimplifier::VisitRem(HRem* instruction) {
block->RemoveInstruction(instruction);
}
- HConstant* cst_right = instruction->GetRight()->AsConstant();
+ HConstant* cst_right = instruction->GetRight()->AsConstantOrNull();
if (((cst_right != nullptr) &&
(cst_right->IsOne() || cst_right->IsMinusOne())) ||
(instruction->GetLeft() == instruction->GetRight())) {
diff --git a/compiler/optimizing/constant_folding_test.cc b/compiler/optimizing/constant_folding_test.cc
index 741fd3f822..4573dce4aa 100644
--- a/compiler/optimizing/constant_folding_test.cc
+++ b/compiler/optimizing/constant_folding_test.cc
@@ -128,7 +128,8 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingNegation) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- ASSERT_EQ(inst->AsIntConstant()->GetValue(), -1);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), -1);
};
// Expected difference after dead code elimination.
@@ -189,7 +190,8 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingNegation) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsLongConstant());
- ASSERT_EQ(inst->AsLongConstant()->GetValue(), INT64_C(-4294967296));
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), INT64_C(-4294967296));
};
// Expected difference after dead code elimination.
@@ -250,7 +252,8 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition1) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- ASSERT_EQ(inst->AsIntConstant()->GetValue(), 3);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -329,13 +332,16 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnAddition2) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst1 = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst1->IsIntConstant());
- ASSERT_EQ(inst1->AsIntConstant()->GetValue(), 12);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst1->AsIntConstantOrNull()->GetValue(), 12);
HInstruction* inst2 = inst1->GetPrevious();
ASSERT_TRUE(inst2->IsIntConstant());
- ASSERT_EQ(inst2->AsIntConstant()->GetValue(), 9);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst2->AsIntConstantOrNull()->GetValue(), 9);
HInstruction* inst3 = inst2->GetPrevious();
ASSERT_TRUE(inst3->IsIntConstant());
- ASSERT_EQ(inst3->AsIntConstant()->GetValue(), 3);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst3->AsIntConstantOrNull()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -400,7 +406,8 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingOnSubtraction) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- ASSERT_EQ(inst->AsIntConstant()->GetValue(), 1);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsIntConstantOrNull()->GetValue(), 1);
};
// Expected difference after dead code elimination.
@@ -463,7 +470,8 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingOnAddition) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsLongConstant());
- ASSERT_EQ(inst->AsLongConstant()->GetValue(), 3);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -527,7 +535,8 @@ TEST_F(ConstantFoldingTest, LongConstantFoldingOnSubtraction) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsLongConstant());
- ASSERT_EQ(inst->AsLongConstant()->GetValue(), 1);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsLongConstantOrNull()->GetValue(), 1);
};
// Expected difference after dead code elimination.
@@ -627,16 +636,20 @@ TEST_F(ConstantFoldingTest, IntConstantFoldingAndJumps) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst1 = graph->GetBlocks()[4]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst1->IsIntConstant());
- ASSERT_EQ(inst1->AsIntConstant()->GetValue(), 20);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst1->AsIntConstantOrNull()->GetValue(), 20);
HInstruction* inst2 = inst1->GetPrevious();
ASSERT_TRUE(inst2->IsIntConstant());
- ASSERT_EQ(inst2->AsIntConstant()->GetValue(), 12);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst2->AsIntConstantOrNull()->GetValue(), 12);
HInstruction* inst3 = inst2->GetPrevious();
ASSERT_TRUE(inst3->IsIntConstant());
- ASSERT_EQ(inst3->AsIntConstant()->GetValue(), 7);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst3->AsIntConstantOrNull()->GetValue(), 7);
HInstruction* inst4 = inst3->GetPrevious();
ASSERT_TRUE(inst4->IsIntConstant());
- ASSERT_EQ(inst4->AsIntConstant()->GetValue(), 3);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst4->AsIntConstantOrNull()->GetValue(), 3);
};
// Expected difference after dead code elimination.
@@ -712,7 +725,8 @@ TEST_F(ConstantFoldingTest, ConstantCondition) {
auto check_after_cf = [](HGraph* graph) {
HInstruction* inst = graph->GetBlocks()[1]->GetFirstInstruction()->InputAt(0);
ASSERT_TRUE(inst->IsIntConstant());
- ASSERT_EQ(inst->AsIntConstant()->GetValue(), 1);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(inst->AsIntConstantOrNull()->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 77e156608b..13c887ed1c 100644
--- a/compiler/optimizing/critical_native_abi_fixup_arm.cc
+++ b/compiler/optimizing/critical_native_abi_fixup_arm.cc
@@ -97,9 +97,11 @@ bool CriticalNativeAbiFixupArm::Run() {
for (HInstructionIterator it(block->GetInstructions()); !it.Done(); it.Advance()) {
HInstruction* instruction = it.Current();
if (instruction->IsInvokeStaticOrDirect() &&
- instruction->AsInvokeStaticOrDirect()->GetCodePtrLocation() ==
+ // TODO: Remove "OrNull".
+ instruction->AsInvokeStaticOrDirectOrNull()->GetCodePtrLocation() ==
CodePtrLocation::kCallCriticalNative) {
- FixUpArguments(instruction->AsInvokeStaticOrDirect());
+ // TODO: Remove "OrNull".
+ FixUpArguments(instruction->AsInvokeStaticOrDirectOrNull());
}
}
}
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc
index cf49e39849..5840651467 100644
--- a/compiler/optimizing/dead_code_elimination.cc
+++ b/compiler/optimizing/dead_code_elimination.cc
@@ -47,23 +47,29 @@ static void MarkReachableBlocks(HGraph* graph, ArenaBitVector* visited) {
ArrayRef<HBasicBlock* const> live_successors(block->GetSuccessors());
HInstruction* last_instruction = block->GetLastInstruction();
if (last_instruction->IsIf()) {
- HIf* if_instruction = last_instruction->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instruction = last_instruction->AsIfOrNull();
HInstruction* condition = if_instruction->InputAt(0);
if (condition->IsIntConstant()) {
- if (condition->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (condition->AsIntConstantOrNull()->IsTrue()) {
live_successors = live_successors.SubArray(0u, 1u);
DCHECK_EQ(live_successors[0], if_instruction->IfTrueSuccessor());
} else {
- DCHECK(condition->AsIntConstant()->IsFalse()) << condition->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ DCHECK(condition->AsIntConstantOrNull()->IsFalse())
+ << condition->AsIntConstantOrNull()->GetValue();
live_successors = live_successors.SubArray(1u, 1u);
DCHECK_EQ(live_successors[0], if_instruction->IfFalseSuccessor());
}
}
} else if (last_instruction->IsPackedSwitch()) {
- HPackedSwitch* switch_instruction = last_instruction->AsPackedSwitch();
+ // TODO: Remove "OrNull".
+ HPackedSwitch* switch_instruction = last_instruction->AsPackedSwitchOrNull();
HInstruction* switch_input = switch_instruction->InputAt(0);
if (switch_input->IsIntConstant()) {
- int32_t switch_value = switch_input->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t switch_value = switch_input->AsIntConstantOrNull()->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"
@@ -136,16 +142,21 @@ static HConstant* Evaluate(HCondition* condition, HInstruction* left, HInstructi
}
if (left->IsIntConstant()) {
- return condition->Evaluate(left->AsIntConstant(), right->AsIntConstant());
+ // TODO: Remove "OrNull".
+ return condition->Evaluate(left->AsIntConstantOrNull(), right->AsIntConstantOrNull());
} else if (left->IsNullConstant()) {
- return condition->Evaluate(left->AsNullConstant(), right->AsNullConstant());
+ // TODO: Remove "OrNull".
+ return condition->Evaluate(left->AsNullConstantOrNull(), right->AsNullConstantOrNull());
} else if (left->IsLongConstant()) {
- return condition->Evaluate(left->AsLongConstant(), right->AsLongConstant());
+ // TODO: Remove "OrNull".
+ return condition->Evaluate(left->AsLongConstantOrNull(), right->AsLongConstantOrNull());
} else if (left->IsFloatConstant()) {
- return condition->Evaluate(left->AsFloatConstant(), right->AsFloatConstant());
+ // TODO: Remove "OrNull".
+ return condition->Evaluate(left->AsFloatConstantOrNull(), right->AsFloatConstantOrNull());
} else {
DCHECK(left->IsDoubleConstant());
- return condition->Evaluate(left->AsDoubleConstant(), right->AsDoubleConstant());
+ // TODO: Remove "OrNull".
+ return condition->Evaluate(left->AsDoubleConstantOrNull(), right->AsDoubleConstantOrNull());
}
}
@@ -154,7 +165,8 @@ static bool RemoveNonNullControlDependences(HBasicBlock* block, HBasicBlock* thr
if (!block->EndsWithIf()) {
return false;
}
- HIf* ifs = block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* ifs = block->GetLastInstruction()->AsIfOrNull();
// Find either:
// if obj == null
// throws
@@ -267,7 +279,8 @@ 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()) {
- if (it.Current()->IsInvoke() && it.Current()->AsInvoke()->AlwaysThrows()) {
+ // TODO: Remove "OrNull".
+ if (it.Current()->IsInvoke() && it.Current()->AsInvokeOrNull()->AlwaysThrows()) {
throwing_invoke = it.Current();
break;
}
@@ -362,13 +375,15 @@ bool HDeadCodeElimination::SimplifyIfs() {
bool has_only_phi_condition_and_if =
!has_only_phi_and_if &&
first->IsCondition() &&
- HasInput(first->AsCondition(), block->GetFirstPhi()) &&
+ // TODO: Remove "OrNull".
+ HasInput(first->AsConditionOrNull(), block->GetFirstPhi()) &&
(first->GetNext() == last) &&
(last->InputAt(0) == first) &&
first->HasOnlyOneNonEnvironmentUse();
if (has_only_phi_and_if || has_only_phi_condition_and_if) {
- HPhi* phi = block->GetFirstPhi()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = block->GetFirstPhi()->AsPhiOrNull();
bool phi_input_is_left = (first->InputAt(0) == phi);
// Walk over all inputs of the phis and update the control flow of
@@ -384,9 +399,11 @@ bool HDeadCodeElimination::SimplifyIfs() {
} else {
DCHECK(has_only_phi_condition_and_if);
if (phi_input_is_left) {
- value_to_check = Evaluate(first->AsCondition(), input, first->InputAt(1));
+ // TODO: Remove "OrNull".
+ value_to_check = Evaluate(first->AsConditionOrNull(), input, first->InputAt(1));
} else {
- value_to_check = Evaluate(first->AsCondition(), first->InputAt(0), input);
+ // TODO: Remove "OrNull".
+ value_to_check = Evaluate(first->AsConditionOrNull(), first->InputAt(0), input);
}
}
if (value_to_check == nullptr) {
@@ -395,12 +412,16 @@ bool HDeadCodeElimination::SimplifyIfs() {
} else {
HBasicBlock* predecessor_to_update = block->GetPredecessors()[i];
HBasicBlock* successor_to_update = nullptr;
- if (value_to_check->AsIntConstant()->IsTrue()) {
- successor_to_update = last->AsIf()->IfTrueSuccessor();
+ // TODO: Remove "OrNull".
+ if (value_to_check->AsIntConstantOrNull()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ successor_to_update = last->AsIfOrNull()->IfTrueSuccessor();
} else {
- DCHECK(value_to_check->AsIntConstant()->IsFalse())
- << value_to_check->AsIntConstant()->GetValue();
- successor_to_update = last->AsIf()->IfFalseSuccessor();
+ // TODO: Remove "OrNull".
+ DCHECK(value_to_check->AsIntConstantOrNull()->IsFalse())
+ << value_to_check->AsIntConstantOrNull()->GetValue();
+ // TODO: Remove "OrNull".
+ successor_to_update = last->AsIfOrNull()->IfFalseSuccessor();
}
predecessor_to_update->ReplaceSuccessor(block, successor_to_update);
phi->RemoveInputAt(i);
@@ -421,7 +442,8 @@ 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.
- HInstruction* result = first->AsCondition()->TryStaticEvaluation();
+ // TODO: Remove "OrNull".
+ HInstruction* result = first->AsConditionOrNull()->TryStaticEvaluation();
if (result != nullptr) {
first->ReplaceWith(result);
block->RemoveInstruction(first);
@@ -454,7 +476,8 @@ bool HDeadCodeElimination::SimplifyIfs() {
void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) {
DCHECK(block->GetLastInstruction()->IsIf());
- HIf* if_instruction = block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull();
if (if_instruction->InputAt(0)->IsConstant()) {
// Constant values are handled in RemoveDeadBlocks.
return;
@@ -477,7 +500,8 @@ void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) {
}
HInstruction* input = if_instruction->InputAt(0);
- HInstruction* dominator_input = dominator->GetLastInstruction()->AsIf()->InputAt(0);
+ // TODO: Remove "OrNull".
+ HInstruction* dominator_input = dominator->GetLastInstruction()->AsIfOrNull()->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
@@ -486,8 +510,10 @@ void HDeadCodeElimination::MaybeAddPhi(HBasicBlock* block) {
return;
}
- HCondition* block_cond = input->AsCondition();
- HCondition* dominator_cond = dominator_input->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* block_cond = input->AsConditionOrNull();
+ // TODO: Remove "OrNull".
+ HCondition* dominator_cond = dominator_input->AsConditionOrNull();
if (block_cond->GetLeft() != dominator_cond->GetLeft() ||
block_cond->GetRight() != dominator_cond->GetRight() ||
@@ -510,10 +536,12 @@ 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()->AsIf()->IfTrueSuccessor()->Dominates(pred);
+ dominator->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor()->Dominates(pred);
+ // TODO: Remove "OrNull".
const bool dominated_by_false =
- dominator->GetLastInstruction()->AsIf()->IfFalseSuccessor()->Dominates(pred);
+ dominator->GetLastInstruction()->AsIfOrNull()->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:
@@ -644,12 +672,14 @@ void HDeadCodeElimination::RemoveTry(HBasicBlock* try_entry,
/* out */ bool* any_block_in_loop) {
// Update all try entries.
DCHECK(try_entry->EndsWithTryBoundary());
- DCHECK(try_entry->GetLastInstruction()->AsTryBoundary()->IsEntry());
+ // TODO: Remove "OrNull".
+ DCHECK(try_entry->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry());
DisconnectHandlersAndUpdateTryBoundary(try_entry, any_block_in_loop);
for (HBasicBlock* other_try_entry : try_belonging_info.coalesced_try_entries) {
DCHECK(other_try_entry->EndsWithTryBoundary());
- DCHECK(other_try_entry->GetLastInstruction()->AsTryBoundary()->IsEntry());
+ // TODO: Remove "OrNull".
+ DCHECK(other_try_entry->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry());
DisconnectHandlersAndUpdateTryBoundary(other_try_entry, any_block_in_loop);
}
@@ -663,7 +693,8 @@ void HDeadCodeElimination::RemoveTry(HBasicBlock* try_entry,
if (block->EndsWithTryBoundary()) {
// Try exits.
- DCHECK(!block->GetLastInstruction()->AsTryBoundary()->IsEntry());
+ // TODO: Remove "OrNull".
+ DCHECK(!block->GetLastInstruction()->AsTryBoundaryOrNull()->IsEntry());
DisconnectHandlersAndUpdateTryBoundary(block, any_block_in_loop);
if (block->GetSingleSuccessor()->IsExitBlock()) {
@@ -712,10 +743,13 @@ 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());
- HTryBoundary* try_boundary = it->first->GetLastInstruction()->AsTryBoundary();
+ // TODO: Remove "OrNull".
+ HTryBoundary* try_boundary = it->first->GetLastInstruction()->AsTryBoundaryOrNull();
for (auto other_it = next(it); other_it != tries.end(); /*other_it++ in the loop*/) {
DCHECK(other_it->first->EndsWithTryBoundary());
- HTryBoundary* other_try_boundary = other_it->first->GetLastInstruction()->AsTryBoundary();
+ // TODO: Remove "OrNull".
+ HTryBoundary* other_try_boundary =
+ other_it->first->GetLastInstruction()->AsTryBoundaryOrNull();
if (try_boundary->HasSameExceptionHandlersAs(*other_try_boundary)) {
// Merge the entries as they are really the same one.
// Block merging.
@@ -855,7 +889,8 @@ void HDeadCodeElimination::UpdateGraphFlags() {
has_simd = true;
} else if (instruction->IsBoundsCheck()) {
has_bounds_checks = true;
- } else if (instruction->IsInvoke() && instruction->AsInvoke()->AlwaysThrows()) {
+ // TODO: Remove "OrNull".
+ } else if (instruction->IsInvoke() && instruction->AsInvokeOrNull()->AlwaysThrows()) {
has_always_throwing_invokes = true;
}
}
diff --git a/compiler/optimizing/escape.cc b/compiler/optimizing/escape.cc
index cebe94fd0d..6fffe22277 100644
--- a/compiler/optimizing/escape.cc
+++ b/compiler/optimizing/escape.cc
@@ -24,7 +24,8 @@ 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()) ||
- (reference->IsNewInstance() && reference->AsNewInstance()->IsFinalizable())) {
+ // TODO: Remove "OrNull".
+ (reference->IsNewInstance() && reference->AsNewInstanceOrNull()->IsFinalizable())) {
if (!escape_visitor(reference)) {
return;
}
@@ -105,7 +106,8 @@ void CalculateEscape(HInstruction* reference,
*is_singleton_and_not_returned = true;
*is_singleton_and_not_deopt_visible = true;
- if (reference->IsNewInstance() && reference->AsNewInstance()->IsFinalizable()) {
+ // TODO: Remove "OrNull".
+ if (reference->IsNewInstance() && reference->AsNewInstanceOrNull()->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 596049f369..e694273e0b 100644
--- a/compiler/optimizing/graph_checker.cc
+++ b/compiler/optimizing/graph_checker.cc
@@ -53,7 +53,8 @@ static bool IsExitTryBoundaryIntoExitBlock(HBasicBlock* block) {
return false;
}
- HTryBoundary* boundary = block->GetLastInstruction()->AsTryBoundary();
+ // TODO: Remove "OrNull".
+ HTryBoundary* boundary = block->GetLastInstruction()->AsTryBoundaryOrNull();
return block->GetPredecessors().size() == 1u &&
boundary->GetNormalFlowSuccessor()->IsExitBlock() &&
!boundary->IsEntry();
@@ -247,7 +248,8 @@ void GraphChecker::VisitBasicBlock(HBasicBlock* block) {
AddError(StringPrintf("Block %d doesn't have a Nop as its first instruction.",
current_block_->GetBlockId()));
} else {
- HNop* nop = block->GetFirstInstruction()->AsNop();
+ // TODO: Remove "OrNull".
+ HNop* nop = block->GetFirstInstruction()->AsNopOrNull();
if (!nop->NeedsEnvironment()) {
AddError(
StringPrintf("%s:%d is a Nop and the first instruction of block %d, but it doesn't "
@@ -658,7 +660,8 @@ 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()) {
- HPhi* catch_phi = phi_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* catch_phi = phi_it.Current()->AsPhiOrNull();
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 "
@@ -747,8 +750,9 @@ 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<uint32_t>(check->InputAt(input_pos)->AsIntConstant()->GetValue());
+ static_cast<uint32_t>(check->InputAt(input_pos)->AsIntConstantOrNull()->GetValue());
if (actual_value != expected_value) {
AddError(StringPrintf("%s:%d (bitstring) has %s 0x%x, not 0x%x as expected.",
check->DebugName(),
@@ -944,7 +948,8 @@ static bool IsSameSizeConstant(const HInstruction* insn1, const HInstruction* in
static bool IsConstantEquivalent(const HInstruction* insn1,
const HInstruction* insn2,
BitVector* visited) {
- if (insn1->IsPhi() && insn1->AsPhi()->IsVRegEquivalentOf(insn2)) {
+ // TODO: Remove "OrNull".
+ if (insn1->IsPhi() && insn1->AsPhiOrNull()->IsVRegEquivalentOf(insn2)) {
HConstInputsRef insn1_inputs = insn1->GetInputs();
HConstInputsRef insn2_inputs = insn2->GetInputs();
if (insn1_inputs.size() != insn2_inputs.size()) {
@@ -964,7 +969,9 @@ static bool IsConstantEquivalent(const HInstruction* insn1,
}
return true;
} else if (IsSameSizeConstant(insn1, insn2)) {
- return insn1->AsConstant()->GetValueAsUint64() == insn2->AsConstant()->GetValueAsUint64();
+ // TODO: Remove "OrNull".
+ return insn1->AsConstantOrNull()->GetValueAsUint64() ==
+ insn2->AsConstantOrNull()->GetValueAsUint64();
} else {
return false;
}
@@ -1058,7 +1065,8 @@ void GraphChecker::VisitPhi(HPhi* phi) {
// phis which can be constructed artifically.
if (phi->IsCatchPhi()) {
HInstruction* next_phi = phi->GetNext();
- if (next_phi != nullptr && phi->GetRegNumber() > next_phi->AsPhi()->GetRegNumber()) {
+ // TODO: Remove "OrNull".
+ if (next_phi != nullptr && phi->GetRegNumber() > next_phi->AsPhiOrNull()->GetRegNumber()) {
AddError(StringPrintf("Catch phis %d and %d in block %d are not sorted by their "
"vreg numbers.",
phi->GetId(),
@@ -1074,7 +1082,8 @@ void GraphChecker::VisitPhi(HPhi* phi) {
for (HInstructionIterator phi_it(phi->GetBlock()->GetPhis());
!phi_it.Done();
phi_it.Advance()) {
- HPhi* other_phi = phi_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* other_phi = phi_it.Current()->AsPhiOrNull();
if (phi != other_phi && phi->GetRegNumber() == other_phi->GetRegNumber()) {
if (phi->GetType() == other_phi->GetType()) {
std::stringstream type_str;
@@ -1117,7 +1126,8 @@ void GraphChecker::VisitPhi(HPhi* phi) {
void GraphChecker::HandleBooleanInput(HInstruction* instruction, size_t input_index) {
HInstruction* input = instruction->InputAt(input_index);
if (input->IsIntConstant()) {
- int32_t value = input->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = input->AsIntConstantOrNull()->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 b5d712736f..f391bcbcbe 100644
--- a/compiler/optimizing/graph_test.cc
+++ b/compiler/optimizing/graph_test.cc
@@ -92,16 +92,20 @@ TEST_F(GraphTest, IfSuccessorSimpleJoinBlock1) {
if_block->AddSuccessor(return_block);
return_block->AddSuccessor(exit_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), if_true);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_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);
graph->SimplifyCFG();
// Ensure we still have the same if true block.
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), if_true);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), if_true);
// Ensure the critical edge has been removed.
- HBasicBlock* false_block = if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor();
+ // TODO: Remove "OrNull".
+ HBasicBlock* false_block = if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor();
ASSERT_NE(false_block, return_block);
// Ensure the new block branches to the join block.
@@ -124,16 +128,20 @@ TEST_F(GraphTest, IfSuccessorSimpleJoinBlock2) {
if_block->AddSuccessor(if_false);
return_block->AddSuccessor(exit_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), if_false);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), return_block);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), if_false);
graph->SimplifyCFG();
// Ensure we still have the same if true block.
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), if_false);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), if_false);
// Ensure the critical edge has been removed.
- HBasicBlock* true_block = if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor();
+ // TODO: Remove "OrNull".
+ HBasicBlock* true_block = if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor();
ASSERT_NE(true_block, return_block);
// Ensure the new block branches to the join block.
@@ -154,13 +162,16 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges1) {
if_block->AddSuccessor(return_block);
return_block->AddSuccessor(exit_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), if_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_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);
graph->BuildDominatorTree();
// Ensure we still have the same if false block.
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), return_block);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor(), return_block);
// Ensure there is only one back edge.
ASSERT_EQ(if_block->GetPredecessors().size(), 2u);
@@ -169,7 +180,8 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges1) {
// Ensure the new block is the back edge.
ASSERT_EQ(if_block->GetPredecessors()[1],
- if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor());
+ // TODO: Remove "OrNull".
+ if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor());
}
// Test that the successors of an if block stay consistent after a SimplifyCFG.
@@ -186,13 +198,16 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges2) {
if_block->AddSuccessor(if_block);
return_block->AddSuccessor(exit_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), if_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);
graph->BuildDominatorTree();
// Ensure we still have the same if true block.
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block);
+ // TODO: Remove "OrNull".
+ ASSERT_EQ(if_block->GetLastInstruction()->AsIfOrNull()->IfTrueSuccessor(), return_block);
// Ensure there is only one back edge.
ASSERT_EQ(if_block->GetPredecessors().size(), 2u);
@@ -201,7 +216,8 @@ TEST_F(GraphTest, IfSuccessorMultipleBackEdges2) {
// Ensure the new block is the back edge.
ASSERT_EQ(if_block->GetPredecessors()[1],
- if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor());
+ // TODO: Remove "OrNull".
+ if_block->GetLastInstruction()->AsIfOrNull()->IfFalseSuccessor());
}
// Test that the successors of an if block stay consistent after a SimplifyCFG.
@@ -222,12 +238,15 @@ TEST_F(GraphTest, IfSuccessorMultiplePreHeaders1) {
if_block->AddSuccessor(return_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), loop_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), 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);
graph->BuildDominatorTree();
- HIf* if_instr = if_block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instr = if_block->GetLastInstruction()->AsIfOrNull();
// Ensure we still have the same if false block.
ASSERT_EQ(if_instr->IfFalseSuccessor(), return_block);
@@ -257,12 +276,15 @@ TEST_F(GraphTest, IfSuccessorMultiplePreHeaders2) {
if_block->AddSuccessor(return_block);
if_block->AddSuccessor(loop_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfTrueSuccessor(), return_block);
- ASSERT_EQ(if_block->GetLastInstruction()->AsIf()->IfFalseSuccessor(), 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);
graph->BuildDominatorTree();
- HIf* if_instr = if_block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instr = if_block->GetLastInstruction()->AsIfOrNull();
// 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 73bdd1e223..a264968b10 100644
--- a/compiler/optimizing/graph_visualizer.cc
+++ b/compiler/optimizing/graph_visualizer.cc
@@ -323,13 +323,17 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor {
stream << "#";
HConstant* constant = location.GetConstant();
if (constant->IsIntConstant()) {
- stream << constant->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ stream << constant->AsIntConstantOrNull()->GetValue();
} else if (constant->IsLongConstant()) {
- stream << constant->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ stream << constant->AsLongConstantOrNull()->GetValue();
} else if (constant->IsFloatConstant()) {
- stream << constant->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ stream << constant->AsFloatConstantOrNull()->GetValue();
} else if (constant->IsDoubleConstant()) {
- stream << constant->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ stream << constant->AsDoubleConstantOrNull()->GetValue();
} else if (constant->IsNullConstant()) {
stream << "null";
}
@@ -625,7 +629,8 @@ class HGraphVisualizerPrinter : public HGraphDelegateVisitor {
void VisitVecDotProd(HVecDotProd* instruction) override {
VisitVecOperation(instruction);
- DataType::Type arg_type = instruction->InputAt(1)->AsVecOperation()->GetPackedType();
+ // TODO: Remove "OrNull".
+ DataType::Type arg_type = instruction->InputAt(1)->AsVecOperationOrNull()->GetPackedType();
StartAttributeStream("type") << (instruction->IsZeroExtending() ?
DataType::ToUnsigned(arg_type) :
DataType::ToSigned(arg_type));
@@ -747,13 +752,14 @@ 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->AsLoadClass()->GetLoadedClassRTI()
+ ? instruction->AsLoadClassOrNull()->GetLoadedClassRTI()
: instruction->GetReferenceTypeInfo()
: instruction->IsInstanceOf()
- ? instruction->AsInstanceOf()->GetTargetClassRTI()
- : instruction->AsCheckCast()->GetTargetClassRTI();
+ ? instruction->AsInstanceOfOrNull()->GetTargetClassRTI()
+ : instruction->AsCheckCastOrNull()->GetTargetClassRTI();
ScopedObjectAccess soa(Thread::Current());
if (info.IsValid()) {
StartAttributeStream("klass")
diff --git a/compiler/optimizing/gvn.cc b/compiler/optimizing/gvn.cc
index a6ca057cfc..cccb381bc6 100644
--- a/compiler/optimizing/gvn.cc
+++ b/compiler/optimizing/gvn.cc
@@ -498,10 +498,12 @@ 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()) {
- if (current->IsBinaryOperation() && current->AsBinaryOperation()->IsCommutative()) {
+ // TODO: Remove "OrNull".
+ if (current->IsBinaryOperation() && current->AsBinaryOperationOrNull()->IsCommutative()) {
// For commutative ops, (x op y) will be treated the same as (y op x)
// after fixed ordering.
- current->AsBinaryOperation()->OrderInputs();
+ // TODO: Remove "OrNull".
+ current->AsBinaryOperationOrNull()->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 be6c268f5d..e54d12b931 100644
--- a/compiler/optimizing/induction_var_analysis.cc
+++ b/compiler/optimizing/induction_var_analysis.cc
@@ -89,12 +89,14 @@ static bool IsGuardedBy(const HLoopInformation* loop,
if (!control->IsIf()) {
return false;
}
- HIf* ifs = control->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* ifs = control->AsIfOrNull();
HInstruction* if_expr = ifs->InputAt(0);
if (if_expr->IsCondition()) {
+ // TODO: Remove "OrNull".
IfCondition other_cmp = ifs->IfTrueSuccessor() == entry
- ? if_expr->AsCondition()->GetCondition()
- : if_expr->AsCondition()->GetOppositeCondition();
+ ? if_expr->AsConditionOrNull()->GetCondition()
+ : if_expr->AsConditionOrNull()->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) {
@@ -435,9 +437,10 @@ 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->AsTypeConversion()->GetInputType(),
- instruction->AsTypeConversion()->GetResultType());
+ instruction->AsTypeConversionOrNull()->GetInputType(),
+ instruction->AsTypeConversionOrNull()->GetResultType());
} else if (instruction->IsBoundsCheck()) {
info = LookupInfo(loop, instruction->InputAt(0)); // Pass-through.
}
@@ -473,7 +476,8 @@ 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()) {
- AssignCycle(scc[i]->AsPhi(), ArrayRef<HInstruction* const>(scc));
+ // TODO: Remove "OrNull".
+ AssignCycle(scc[i]->AsPhiOrNull(), ArrayRef<HInstruction* const>(scc));
}
}
@@ -548,7 +552,8 @@ 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()) {
- update = SolveConversion(loop, phi, instruction->AsTypeConversion(), cycle, &type);
+ // TODO: Remove "OrNull".
+ update = SolveConversion(loop, phi, instruction->AsTypeConversionOrNull(), cycle, &type);
}
if (update == nullptr) {
return;
@@ -998,7 +1003,8 @@ HInductionVarAnalysis::InductionInfo* HInductionVarAnalysis::SolveConversion(
void HInductionVarAnalysis::VisitControl(const HLoopInformation* loop) {
HInstruction* control = loop->GetHeader()->GetLastInstruction();
if (control->IsIf()) {
- HIf* ifs = control->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* ifs = control->AsIfOrNull();
HBasicBlock* if_true = ifs->IfTrueSuccessor();
HBasicBlock* if_false = ifs->IfFalseSuccessor();
HInstruction* if_expr = ifs->InputAt(0);
@@ -1006,7 +1012,8 @@ void HInductionVarAnalysis::VisitControl(const HLoopInformation* loop) {
// loop-header: ....
// if (condition) goto X
if (if_expr->IsCondition()) {
- HCondition* condition = if_expr->AsCondition();
+ // TODO: Remove "OrNull".
+ HCondition* condition = if_expr->AsConditionOrNull();
const HBasicBlock* context = condition->GetBlock();
InductionInfo* a = LookupInfo(loop, condition->InputAt(0));
InductionInfo* b = LookupInfo(loop, condition->InputAt(1));
@@ -1252,7 +1259,8 @@ bool HInductionVarAnalysis::RewriteBreakLoop(const HBasicBlock* context,
return false;
}
// Simple terminating i != U condition, used nowhere else.
- HIf* ifs = loop->GetHeader()->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* ifs = loop->GetHeader()->GetLastInstruction()->AsIfOrNull();
HInstruction* cond = ifs->InputAt(0);
if (ifs->GetPrevious() != cond || !cond->HasOnlyOneNonEnvironmentUse()) {
return false;
@@ -1515,9 +1523,11 @@ bool HInductionVarAnalysis::InductionEqual(InductionInfo* info1,
std::string HInductionVarAnalysis::FetchToString(HInstruction* fetch) {
DCHECK(fetch != nullptr);
if (fetch->IsIntConstant()) {
- return std::to_string(fetch->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return std::to_string(fetch->AsIntConstantOrNull()->GetValue());
} else if (fetch->IsLongConstant()) {
- return std::to_string(fetch->AsLongConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return std::to_string(fetch->AsLongConstantOrNull()->GetValue());
}
return std::to_string(fetch->GetId()) + ":" + fetch->DebugName();
}
@@ -1609,7 +1619,8 @@ 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()) {
- HPhi* loop_header_phi = current_phi->InputAt(index)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* loop_header_phi = current_phi->InputAt(index)->AsPhiOrNull();
auto it = cached_values.find(loop_header_phi);
if (it != cached_values.end()) {
current_value += it->second;
@@ -1650,7 +1661,8 @@ bool HInductionVarAnalysis::IsPathologicalCase() {
for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
DCHECK(it.Current()->IsLoopHeaderPhi());
- HPhi* phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.Current()->AsPhiOrNull();
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 9b78699ead..107a2c38da 100644
--- a/compiler/optimizing/induction_var_range.cc
+++ b/compiler/optimizing/induction_var_range.cc
@@ -171,8 +171,9 @@ 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());
- DCHECK_NE(loop->Contains(*GetLoopControl(loop)->AsIf()->IfTrueSuccessor()),
- loop->Contains(*GetLoopControl(loop)->AsIf()->IfFalseSuccessor()));
+ // TODO: Remove "OrNull".
+ DCHECK_NE(loop->Contains(*GetLoopControl(loop)->AsIfOrNull()->IfTrueSuccessor()),
+ loop->Contains(*GetLoopControl(loop)->AsIfOrNull()->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));
@@ -182,8 +183,10 @@ 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);
- HBasicBlock* then_block = loop_control->AsIf()->IfTrueSuccessor();
- HBasicBlock* else_block = loop_control->AsIf()->IfFalseSuccessor();
+ // TODO: Remove "OrNull".
+ HBasicBlock* then_block = loop_control->AsIfOrNull()->IfTrueSuccessor();
+ // TODO: Remove "OrNull".
+ HBasicBlock* else_block = loop_control->AsIfOrNull()->IfFalseSuccessor();
HBasicBlock* loop_exit_block = loop->Contains(*then_block) ? else_block : then_block;
return loop_exit_block->Dominates(context);
}
@@ -735,13 +738,15 @@ InductionVarRange::Value InductionVarRange::GetFetch(const HBasicBlock* context,
return is_min ? Value(0) : Value(std::numeric_limits<int32_t>::max());
} else if (instruction->InputAt(0)->IsNewArray()) {
return GetFetch(
- context, loop, instruction->InputAt(0)->AsNewArray()->GetLength(), trip, is_min);
+ // TODO: Remove "OrNull".
+ context, loop, instruction->InputAt(0)->AsNewArrayOrNull()->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++);
- if (instruction->AsTypeConversion()->GetInputType() == DataType::Type::kInt32 &&
- instruction->AsTypeConversion()->GetResultType() == DataType::Type::kInt64) {
+ // TODO: Remove "OrNull".
+ if (instruction->AsTypeConversionOrNull()->GetInputType() == DataType::Type::kInt32 &&
+ instruction->AsTypeConversionOrNull()->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 3e1212bec8..356a04ab19 100644
--- a/compiler/optimizing/induction_var_range.h
+++ b/compiler/optimizing/induction_var_range.h
@@ -139,7 +139,8 @@ class InductionVarRange {
void ReVisit(const HLoopInformation* loop) {
induction_analysis_->induction_.erase(loop);
for (HInstructionIterator it(loop->GetHeader()->GetPhis()); !it.Done(); it.Advance()) {
- induction_analysis_->cycles_.erase(it.Current()->AsPhi());
+ // TODO: Remove "OrNull".
+ induction_analysis_->cycles_.erase(it.Current()->AsPhiOrNull());
}
induction_analysis_->VisitLoop(loop);
}
diff --git a/compiler/optimizing/induction_var_range_test.cc b/compiler/optimizing/induction_var_range_test.cc
index d879897959..9c84a75f06 100644
--- a/compiler/optimizing/induction_var_range_test.cc
+++ b/compiler/optimizing/induction_var_range_test.cc
@@ -50,7 +50,8 @@ class InductionVarRangeTest : public OptimizingUnitTest {
void ExpectInt(int32_t value, HInstruction* i) {
ASSERT_TRUE(i->IsIntConstant());
- EXPECT_EQ(value, i->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ EXPECT_EQ(value, i->AsIntConstantOrNull()->GetValue());
}
//
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index 4bf62f3c26..2185fc0c4e 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -180,7 +180,7 @@ bool HInliner::Run() {
for (HBasicBlock* block : blocks) {
for (HInstruction* instruction = block->GetFirstInstruction(); instruction != nullptr;) {
HInstruction* next = instruction->GetNext();
- HInvoke* call = instruction->AsInvoke();
+ HInvoke* call = instruction->AsInvokeOrNull();
// As long as the call is not intrinsified, it is worth trying to inline.
if (call != nullptr && !codegen_->IsImplementedIntrinsic(call)) {
if (honor_noinline_directives) {
@@ -467,7 +467,8 @@ bool HInliner::TryInline(HInvoke* invoke_instruction) {
ArtMethod* resolved_method = invoke_instruction->GetResolvedMethod();
if (resolved_method == nullptr) {
DCHECK(invoke_instruction->IsInvokeStaticOrDirect());
- DCHECK(invoke_instruction->AsInvokeStaticOrDirect()->IsStringInit());
+ // TODO: Remove "OrNull".
+ DCHECK(invoke_instruction->AsInvokeStaticOrDirectOrNull()->IsStringInit());
LOG_FAIL_NO_STAT() << "Not inlining a String.<init> method";
return false;
}
@@ -1146,9 +1147,10 @@ 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->AsInvokeVirtual()->GetVTableIndex()
- : invoke_instruction->AsInvokeInterface()->GetImtIndex();
+ ? invoke_instruction->AsInvokeVirtualOrNull()->GetVTableIndex()
+ : invoke_instruction->AsInvokeInterfaceOrNull()->GetImtIndex();
// Check whether we are actually calling the same method among
// the different types seen.
@@ -1464,7 +1466,8 @@ bool HInliner::IsInliningSupported(const HInvoke* invoke_instruction,
}
if (invoke_instruction->IsInvokeStaticOrDirect() &&
- invoke_instruction->AsInvokeStaticOrDirect()->IsStaticWithImplicitClinitCheck()) {
+ // TODO: Remove "OrNull".
+ invoke_instruction->AsInvokeStaticOrDirectOrNull()->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)
@@ -1850,15 +1853,21 @@ void HInliner::SubstituteArguments(HGraph* callee_graph,
if (argument->IsNullConstant()) {
current->ReplaceWith(callee_graph->GetNullConstant());
} else if (argument->IsIntConstant()) {
- current->ReplaceWith(callee_graph->GetIntConstant(argument->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ current->ReplaceWith(
+ callee_graph->GetIntConstant(argument->AsIntConstantOrNull()->GetValue()));
} else if (argument->IsLongConstant()) {
- current->ReplaceWith(callee_graph->GetLongConstant(argument->AsLongConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ current->ReplaceWith(
+ callee_graph->GetLongConstant(argument->AsLongConstantOrNull()->GetValue()));
} else if (argument->IsFloatConstant()) {
+ // TODO: Remove "OrNull".
current->ReplaceWith(
- callee_graph->GetFloatConstant(argument->AsFloatConstant()->GetValue()));
+ callee_graph->GetFloatConstant(argument->AsFloatConstantOrNull()->GetValue()));
} else if (argument->IsDoubleConstant()) {
+ // TODO: Remove "OrNull".
current->ReplaceWith(
- callee_graph->GetDoubleConstant(argument->AsDoubleConstant()->GetValue()));
+ callee_graph->GetDoubleConstant(argument->AsDoubleConstantOrNull()->GetValue()));
} else if (argument->GetType() == DataType::Type::kReference) {
if (!resolved_method->IsStatic() && parameter_index == 0 && receiver_type.IsValid()) {
run_rtp = true;
@@ -1866,7 +1875,8 @@ void HInliner::SubstituteArguments(HGraph* callee_graph,
} else {
current->SetReferenceTypeInfoIfValid(argument->GetReferenceTypeInfo());
}
- current->AsParameterValue()->SetCanBeNull(argument->CanBeNull());
+ // TODO: Remove "OrNull".
+ current->AsParameterValueOrNull()->SetCanBeNull(argument->CanBeNull());
}
++parameter_index;
}
@@ -2327,7 +2337,8 @@ bool HInliner::ReturnTypeMoreSpecific(HInstruction* return_replacement,
return_replacement)) {
return true;
} else if (return_replacement->IsInstanceFieldGet()) {
- HInstanceFieldGet* field_get = return_replacement->AsInstanceFieldGet();
+ // TODO: Remove "OrNull".
+ HInstanceFieldGet* field_get = return_replacement->AsInstanceFieldGetOrNull();
if (field_get->GetFieldInfo().GetField() ==
GetClassRoot<mirror::Object>()->GetInstanceField(0)) {
return true;
diff --git a/compiler/optimizing/instruction_builder.cc b/compiler/optimizing/instruction_builder.cc
index 2576b02c9f..f461be9df1 100644
--- a/compiler/optimizing/instruction_builder.cc
+++ b/compiler/optimizing/instruction_builder.cc
@@ -268,12 +268,14 @@ void HInstructionBuilder::PropagateLocalsToCatchBlocks() {
if (local_value == nullptr) {
// This is the first instruction throwing into `catch_block` where
// `vreg` is undefined. Delete the catch phi.
- catch_block->RemovePhi(handler_value->AsPhi());
+ // TODO: Remove "OrNull".
+ catch_block->RemovePhi(handler_value->AsPhiOrNull());
(*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.
- handler_value->AsPhi()->AddInput(local_value);
+ // TODO: Remove "OrNull".
+ handler_value->AsPhiOrNull()->AddInput(local_value);
}
}
}
@@ -321,7 +323,8 @@ 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()) {
- HPhi* phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.Current()->AsPhiOrNull();
size_t vreg = phi->GetRegNumber();
for (HBasicBlock* predecessor : block->GetPredecessors()) {
HInstruction* value = ValueOfLocalAt(predecessor, vreg);
@@ -1467,7 +1470,8 @@ 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).
- HNewInstance* new_inst = allocation->AsNewInstance();
+ // TODO: Remove "OrNull".
+ HNewInstance* new_inst = allocation->AsNewInstanceOrNull();
HLoadClass* load_class = new_inst->GetLoadClass();
Thread* self = Thread::Current();
@@ -1836,15 +1840,20 @@ bool HInstructionBuilder::SetupInvokeArguments(HInstruction* invoke,
if (invoke->IsInvokeStaticOrDirect() &&
HInvokeStaticOrDirect::NeedsCurrentMethodInput(
- invoke->AsInvokeStaticOrDirect()->GetDispatchInfo())) {
- DCHECK_EQ(argument_index, invoke->AsInvokeStaticOrDirect()->GetCurrentMethodIndex());
+ // TODO: Remove "OrNull".
+ invoke->AsInvokeStaticOrDirectOrNull()->GetDispatchInfo())) {
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(argument_index, invoke->AsInvokeStaticOrDirectOrNull()->GetCurrentMethodIndex());
DCHECK(invoke->InputAt(argument_index) == nullptr);
invoke->SetRawInputAt(argument_index, graph_->GetCurrentMethod());
}
if (invoke->IsInvokeInterface() &&
- (invoke->AsInvokeInterface()->GetHiddenArgumentLoadKind() == MethodLoadKind::kRecursive)) {
- invoke->SetRawInputAt(invoke->AsInvokeInterface()->GetNumberOfArguments() - 1,
+ // TODO: Remove "OrNull".
+ (invoke->AsInvokeInterfaceOrNull()->GetHiddenArgumentLoadKind() ==
+ MethodLoadKind::kRecursive)) {
+ // TODO: Remove "OrNull".
+ invoke->SetRawInputAt(invoke->AsInvokeInterfaceOrNull()->GetNumberOfArguments() - 1,
graph_->GetCurrentMethod());
}
@@ -1856,7 +1865,8 @@ bool HInstructionBuilder::HandleInvoke(HInvoke* invoke,
const char* shorty,
bool is_unresolved) {
DCHECK_IMPLIES(invoke->IsInvokeStaticOrDirect(),
- !invoke->AsInvokeStaticOrDirect()->IsStringInit());
+ // TODO: Remove "OrNull".
+ !invoke->AsInvokeStaticOrDirectOrNull()->IsStringInit());
ReceiverArg receiver_arg = (invoke->GetInvokeType() == InvokeType::kStatic)
? ReceiverArg::kNone
@@ -1914,7 +1924,8 @@ 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);
- instruction->AsCondition()->SetBias(ComparisonBias::kLtBias);
+ // TODO: Remove "OrNull".
+ instruction->AsConditionOrNull()->SetBias(ComparisonBias::kLtBias);
break;
}
case Intrinsics::kStringCharAt:
@@ -2061,7 +2072,8 @@ bool HInstructionBuilder::HandleStringInit(HInvoke* invoke,
const InstructionOperands& operands,
const char* shorty) {
DCHECK(invoke->IsInvokeStaticOrDirect());
- DCHECK(invoke->AsInvokeStaticOrDirect()->IsStringInit());
+ // TODO: Remove "OrNull".
+ DCHECK(invoke->AsInvokeStaticOrDirectOrNull()->IsStringInit());
if (!SetupInvokeArguments(invoke, operands, shorty, ReceiverArg::kIgnored)) {
return false;
@@ -2077,7 +2089,8 @@ 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()) {
- ssa_builder_->AddUninitializedString(arg_this->AsNewInstance());
+ // TODO: Remove "OrNull".
+ ssa_builder_->AddUninitializedString(arg_this->AsNewInstanceOrNull());
} else {
DCHECK(arg_this->IsPhi());
// We can get a phi as input of a String.<init> if there is a loop between the
@@ -2366,8 +2379,10 @@ void HInstructionBuilder::BuildCheckedDivRem(uint16_t out_vreg,
}
if (!second_is_constant ||
- (type == DataType::Type::kInt32 && second->AsIntConstant()->GetValue() == 0) ||
- (type == DataType::Type::kInt64 && second->AsLongConstant()->GetValue() == 0)) {
+ // TODO: Remove "OrNull".
+ (type == DataType::Type::kInt32 && second->AsIntConstantOrNull()->GetValue() == 0) ||
+ // TODO: Remove "OrNull".
+ (type == DataType::Type::kInt64 && second->AsLongConstantOrNull()->GetValue() == 0)) {
second = new (allocator_) HDivZeroCheck(second, dex_pc);
AppendInstruction(second);
}
@@ -2863,7 +2878,8 @@ bool HInstructionBuilder::ProcessDexInstruction(const Instruction& instruction,
uint32_t reg_number = instruction.VRegB();
HInstruction* value = (*current_locals_)[reg_number];
if (value->IsIntConstant()) {
- DCHECK_EQ(value->AsIntConstant()->GetValue(), 0);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(value->AsIntConstantOrNull()->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 0c2fd5de56..43129d1704 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -192,8 +192,10 @@ bool AreAllBitsSet(HConstant* constant) {
bool InstructionSimplifierVisitor::TryMoveNegOnInputsAfterBinop(HBinaryOperation* binop) {
DCHECK(binop->IsAdd() || binop->IsSub());
DCHECK(binop->GetLeft()->IsNeg() && binop->GetRight()->IsNeg());
- HNeg* left_neg = binop->GetLeft()->AsNeg();
- HNeg* right_neg = binop->GetRight()->AsNeg();
+ // TODO: Remove "OrNull".
+ HNeg* left_neg = binop->GetLeft()->AsNegOrNull();
+ // TODO: Remove "OrNull".
+ HNeg* right_neg = binop->GetRight()->AsNegOrNull();
if (!left_neg->HasOnlyOneNonEnvironmentUse() ||
!right_neg->HasOnlyOneNonEnvironmentUse()) {
return false;
@@ -313,7 +315,8 @@ 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;
- HVecBinaryOperation* vec_binop = binop->AsVecBinaryOperation();
+ // TODO: Remove "OrNull".
+ HVecBinaryOperation* vec_binop = binop->AsVecBinaryOperationOrNull();
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).
@@ -371,7 +374,8 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) {
: kMaxIntShiftDistance;
if (shift_amount->IsConstant()) {
- int64_t cst = Int64FromConstant(shift_amount->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t cst = Int64FromConstant(shift_amount->AsConstantOrNull());
int64_t masked_cst = cst & implicit_mask;
if (masked_cst == 0) {
// Replace code looking like
@@ -412,7 +416,8 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) {
shift_amount->IsAdd() ||
shift_amount->IsSub()) {
int64_t required_result = shift_amount->IsAnd() ? implicit_mask : 0;
- HBinaryOperation* bin_op = shift_amount->AsBinaryOperation();
+ // TODO: Remove "OrNull".
+ HBinaryOperation* bin_op = shift_amount->AsBinaryOperationOrNull();
HConstant* mask = bin_op->GetConstantRight();
if (mask != nullptr && (Int64FromConstant(mask) & implicit_mask) == required_result) {
instruction->ReplaceInput(bin_op->GetLeastConstantLeft(), 1);
@@ -424,7 +429,8 @@ 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)) {
- instruction->ReplaceInput(shift_amount->AsTypeConversion()->GetInput(), 1);
+ // TODO: Remove "OrNull".
+ instruction->ReplaceInput(shift_amount->AsTypeConversionOrNull()->GetInput(), 1);
RecordSimplification();
return;
}
@@ -434,7 +440,8 @@ void InstructionSimplifierVisitor::VisitShift(HBinaryOperation* instruction) {
static bool IsSubRegBitsMinusOther(HSub* sub, size_t reg_bits, HInstruction* other) {
return (sub->GetRight() == other &&
sub->GetLeft()->IsConstant() &&
- (Int64FromConstant(sub->GetLeft()->AsConstant()) & (reg_bits - 1)) == 0);
+ // TODO: Remove "OrNull".
+ (Int64FromConstant(sub->GetLeft()->AsConstantOrNull()) & (reg_bits - 1)) == 0);
}
bool InstructionSimplifierVisitor::ReplaceRotateWithRor(HBinaryOperation* op,
@@ -467,8 +474,10 @@ 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())) {
- HUShr* ushr = left->IsUShr() ? left->AsUShr() : right->AsUShr();
- HShl* shl = left->IsShl() ? left->AsShl() : right->AsShl();
+ // TODO: Remove "OrNull".
+ HUShr* ushr = left->IsUShr() ? left->AsUShrOrNull() : right->AsUShrOrNull();
+ // TODO: Remove "OrNull".
+ HShl* shl = left->IsShl() ? left->AsShlOrNull() : right->AsShlOrNull();
DCHECK(DataType::IsIntOrLongType(ushr->GetType()));
if (ushr->GetType() == shl->GetType() &&
ushr->GetLeft() == shl->GetLeft()) {
@@ -503,8 +512,10 @@ bool InstructionSimplifierVisitor::TryReplaceWithRotateConstantPattern(HBinaryOp
HShl* shl) {
DCHECK(op->IsAdd() || op->IsXor() || op->IsOr());
size_t reg_bits = DataType::Size(ushr->GetType()) * kBitsPerByte;
- size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstant());
- size_t ldist = Int64FromConstant(shl->GetRight()->AsConstant());
+ // TODO: Remove "OrNull".
+ size_t rdist = Int64FromConstant(ushr->GetRight()->AsConstantOrNull());
+ // TODO: Remove "OrNull".
+ size_t ldist = Int64FromConstant(shl->GetRight()->AsConstantOrNull());
if (((ldist + rdist) & (reg_bits - 1)) == 0) {
ReplaceRotateWithRor(op, ushr, shl);
return true;
@@ -534,7 +545,8 @@ 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();
- HNeg* neg = neg_is_left ? shl->GetRight()->AsNeg() : ushr->GetRight()->AsNeg();
+ // TODO: Remove "OrNull".
+ HNeg* neg = neg_is_left ? shl->GetRight()->AsNegOrNull() : ushr->GetRight()->AsNegOrNull();
// 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);
@@ -566,8 +578,12 @@ 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() && IsSubRegBitsMinusOther(shl_shift->AsSub(), reg_bits, ushr_shift)) ||
- (ushr_shift->IsSub() && IsSubRegBitsMinusOther(ushr_shift->AsSub(), reg_bits, shl_shift))) {
+ 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))) {
return ReplaceRotateWithRor(op, ushr, shl);
}
return false;
@@ -789,12 +805,14 @@ 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.
- if (input_const->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (input_const->AsIntConstantOrNull()->IsTrue()) {
// Replace (bool_value == true) with bool_value
equal->ReplaceWith(input_value);
block->RemoveInstruction(equal);
RecordSimplification();
- } else if (input_const->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ } else if (input_const->AsIntConstantOrNull()->IsFalse()) {
// Replace (bool_value == false) with !bool_value
equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, equal));
block->RemoveInstruction(equal);
@@ -821,12 +839,14 @@ 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.
- if (input_const->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (input_const->AsIntConstantOrNull()->IsTrue()) {
// Replace (bool_value != true) with !bool_value
not_equal->ReplaceWith(GetGraph()->InsertOppositeCondition(input_value, not_equal));
block->RemoveInstruction(not_equal);
RecordSimplification();
- } else if (input_const->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ } else if (input_const->AsIntConstantOrNull()->IsFalse()) {
// Replace (bool_value != false) with bool_value
not_equal->ReplaceWith(input_value);
block->RemoveInstruction(not_equal);
@@ -851,10 +871,12 @@ void InstructionSimplifierVisitor::VisitBooleanNot(HBooleanNot* bool_not) {
if (input->IsIntConstant()) {
// Replace !(true/false) with false/true.
- if (input->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (input->AsIntConstantOrNull()->IsTrue()) {
replace_with = GetGraph()->GetIntConstant(0);
} else {
- DCHECK(input->AsIntConstant()->IsFalse()) << input->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ DCHECK(input->AsIntConstantOrNull()->IsFalse()) << input->AsIntConstantOrNull()->GetValue();
replace_with = GetGraph()->GetIntConstant(1);
}
} else if (input->IsBooleanNot()) {
@@ -865,7 +887,8 @@ 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.
- replace_with = GetGraph()->InsertOppositeCondition(input->AsCondition(), bool_not);
+ // TODO: Remove "OrNull".
+ replace_with = GetGraph()->InsertOppositeCondition(input->AsConditionOrNull(), bool_not);
}
if (replace_with != nullptr) {
@@ -933,8 +956,10 @@ static HInstruction* AllowInMinMax(IfCondition cmp,
if (IsInt64AndGet(b, /*out*/ &value) &&
(((cmp == kCondLT || cmp == kCondLE) && c->IsMax()) ||
((cmp == kCondGT || cmp == kCondGE) && c->IsMin()))) {
- HConstant* other = c->AsBinaryOperation()->GetConstantRight();
- if (other != nullptr && a == c->AsBinaryOperation()->GetLeastConstantLeft()) {
+ // TODO: Remove "OrNull".
+ HConstant* other = c->AsBinaryOperationOrNull()->GetConstantRight();
+ // TODO: Remove "OrNull".
+ if (other != nullptr && a == c->AsBinaryOperationOrNull()->GetLeastConstantLeft()) {
int64_t other_value = Int64FromConstant(other);
bool is_max = (cmp == kCondLT || cmp == kCondLE);
// Allow the max for a < 100 ? max(a, -100) : ..
@@ -1028,24 +1053,32 @@ void InstructionSimplifierVisitor::VisitSelect(HSelect* select) {
// Replace (cond ? x : x) with (x).
replace_with = true_value;
} else if (condition->IsIntConstant()) {
- if (condition->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (condition->AsIntConstantOrNull()->IsTrue()) {
// Replace (true ? x : y) with (x).
replace_with = true_value;
} else {
// Replace (false ? x : y) with (y).
- DCHECK(condition->AsIntConstant()->IsFalse()) << condition->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ DCHECK(condition->AsIntConstantOrNull()->IsFalse())
+ << condition->AsIntConstantOrNull()->GetValue();
replace_with = false_value;
}
} else if (true_value->IsIntConstant() && false_value->IsIntConstant()) {
- if (true_value->AsIntConstant()->IsTrue() && false_value->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ if (true_value->AsIntConstantOrNull()->IsTrue() &&
+ false_value->AsIntConstantOrNull()->IsFalse()) {
// Replace (cond ? true : false) with (cond).
replace_with = condition;
- } else if (true_value->AsIntConstant()->IsFalse() && false_value->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ } else if (true_value->AsIntConstantOrNull()->IsFalse() &&
+ false_value->AsIntConstantOrNull()->IsTrue()) {
// Replace (cond ? false : true) with (!cond).
replace_with = GetGraph()->InsertOppositeCondition(condition, select);
}
} else if (condition->IsCondition()) {
- IfCondition cmp = condition->AsCondition()->GetCondition();
+ // TODO: Remove "OrNull".
+ IfCondition cmp = condition->AsConditionOrNull()->GetCondition();
HInstruction* a = condition->InputAt(0);
HInstruction* b = condition->InputAt(1);
DataType::Type t_type = true_value->GetType();
@@ -1126,7 +1159,8 @@ 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()) {
- input = input->AsNewArray()->GetLength();
+ // TODO: Remove "OrNull".
+ input = input->AsNewArrayOrNull()->GetLength();
if (input->IsIntConstant()) {
instruction->ReplaceWith(input);
}
@@ -1144,7 +1178,8 @@ void InstructionSimplifierVisitor::VisitArraySet(HArraySet* instruction) {
}
if (value->IsArrayGet()) {
- if (value->AsArrayGet()->GetArray() == instruction->GetArray()) {
+ // TODO: Remove "OrNull".
+ if (value->AsArrayGetOrNull()->GetArray() == instruction->GetArray()) {
// If the code is just swapping elements in the array, no need for a type check.
instruction->ClearTypeCheck();
return;
@@ -1220,16 +1255,21 @@ static bool CanRemoveRedundantAnd(HConstant* and_right,
static inline bool TryReplaceFieldOrArrayGetType(HInstruction* maybe_get, DataType::Type new_type) {
if (maybe_get->IsInstanceFieldGet()) {
- maybe_get->AsInstanceFieldGet()->SetType(new_type);
+ // TODO: Remove "OrNull".
+ maybe_get->AsInstanceFieldGetOrNull()->SetType(new_type);
return true;
} else if (maybe_get->IsPredicatedInstanceFieldGet()) {
- maybe_get->AsPredicatedInstanceFieldGet()->SetType(new_type);
+ // TODO: Remove "OrNull".
+ maybe_get->AsPredicatedInstanceFieldGetOrNull()->SetType(new_type);
return true;
} else if (maybe_get->IsStaticFieldGet()) {
- maybe_get->AsStaticFieldGet()->SetType(new_type);
+ // TODO: Remove "OrNull".
+ maybe_get->AsStaticFieldGetOrNull()->SetType(new_type);
return true;
- } else if (maybe_get->IsArrayGet() && !maybe_get->AsArrayGet()->IsStringCharAt()) {
- maybe_get->AsArrayGet()->SetType(new_type);
+ // TODO: Remove "OrNull".
+ } else if (maybe_get->IsArrayGet() && !maybe_get->AsArrayGetOrNull()->IsStringCharAt()) {
+ // TODO: Remove "OrNull".
+ maybe_get->AsArrayGetOrNull()->SetType(new_type);
return true;
} else {
return false;
@@ -1264,20 +1304,27 @@ static bool IsTypeConversionForStoringIntoNoWiderFieldOnly(HTypeConversion* type
for (const HUseListNode<HInstruction*>& use : type_conversion->GetUses()) {
HInstruction* instruction = use.GetUser();
if (instruction->IsInstanceFieldSet() &&
- instruction->AsInstanceFieldSet()->GetFieldType() == result_type) {
- DCHECK_EQ(instruction->AsInstanceFieldSet()->GetValue(), type_conversion);
+ // TODO: Remove "OrNull".
+ instruction->AsInstanceFieldSetOrNull()->GetFieldType() == result_type) {
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction->AsInstanceFieldSetOrNull()->GetValue(), type_conversion);
continue;
}
if (instruction->IsStaticFieldSet() &&
- instruction->AsStaticFieldSet()->GetFieldType() == result_type) {
- DCHECK_EQ(instruction->AsStaticFieldSet()->GetValue(), type_conversion);
+ // TODO: Remove "OrNull".
+ instruction->AsStaticFieldSetOrNull()->GetFieldType() == result_type) {
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction->AsStaticFieldSetOrNull()->GetValue(), type_conversion);
continue;
}
if (instruction->IsArraySet() &&
- instruction->AsArraySet()->GetComponentType() == result_type &&
+ // TODO: Remove "OrNull".
+ instruction->AsArraySetOrNull()->GetComponentType() == result_type &&
// not index use.
- instruction->AsArraySet()->GetIndex() != type_conversion) {
- DCHECK_EQ(instruction->AsArraySet()->GetValue(), type_conversion);
+ // TODO: Remove "OrNull".
+ instruction->AsArraySetOrNull()->GetIndex() != type_conversion) {
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction->AsArraySetOrNull()->GetValue(), type_conversion);
continue;
}
// The use is not as a store value, or the field/element type is not the
@@ -1300,7 +1347,8 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct
}
if (input->IsTypeConversion()) {
- HTypeConversion* input_conversion = input->AsTypeConversion();
+ // TODO: Remove "OrNull".
+ HTypeConversion* input_conversion = input->AsTypeConversionOrNull();
HInstruction* original_input = input_conversion->GetInput();
DataType::Type original_type = original_input->GetType();
@@ -1342,12 +1390,14 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct
// Optimization only applies to lossy Type Conversions.
!IsTypeConversionLossless(input_type, result_type)) {
DCHECK(DataType::IsIntegralType(input_type));
- HShr* shr_op = input->AsShr();
+ // TODO: Remove "OrNull".
+ HShr* shr_op = input->AsShrOrNull();
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.
- HAnd* and_op = shr_left->AsAnd();
+ // TODO: Remove "OrNull".
+ HAnd* and_op = shr_left->AsAndOrNull();
HConstant* and_right = and_op->GetConstantRight();
HInstruction* and_left = and_op->GetLeastConstantLeft();
if (and_right != nullptr &&
@@ -1370,7 +1420,8 @@ void InstructionSimplifierVisitor::VisitTypeConversion(HTypeConversion* instruct
}
} else if (input->IsAnd() && DataType::IsIntegralType(result_type)) {
DCHECK(DataType::IsIntegralType(input_type));
- HAnd* input_and = input->AsAnd();
+ // TODO: Remove "OrNull".
+ HAnd* input_and = input->AsAndOrNull();
HConstant* constant = input_and->GetConstantRight();
if (constant != nullptr) {
int64_t value = Int64FromConstant(constant);
@@ -1456,7 +1507,8 @@ void InstructionSimplifierVisitor::VisitAdd(HAdd* instruction) {
}
}
- HNeg* neg = left_is_neg ? left->AsNeg() : right->AsNeg();
+ // TODO: Remove first "OrNull", keep the second.
+ HNeg* neg = left_is_neg ? left->AsNegOrNull() : right->AsNegOrNull();
if (left_is_neg != right_is_neg && neg->HasOnlyOneNonEnvironmentUse()) {
// Replace code looking like
// NEG tmp, b
@@ -1567,7 +1619,9 @@ 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;
- size_t shift = Int64FromConstant(input_other->InputAt(1)->AsConstant()) & (reg_bits - 1);
+ // TODO: Remove "OrNull".
+ size_t shift =
+ Int64FromConstant(input_other->InputAt(1)->AsConstantOrNull()) & (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".
@@ -1675,8 +1729,9 @@ static bool RecognizeAndSimplifyClassCheck(HCondition* condition) {
HInstruction* input_one = condition->InputAt(0);
HInstruction* input_two = condition->InputAt(1);
HLoadClass* load_class = input_one->IsLoadClass()
- ? input_one->AsLoadClass()
- : input_two->AsLoadClass();
+ // TODO: Remove "OrNull".
+ ? input_one->AsLoadClassOrNull()
+ : input_two->AsLoadClassOrNull();
if (load_class == nullptr) {
return false;
}
@@ -1688,8 +1743,8 @@ static bool RecognizeAndSimplifyClassCheck(HCondition* condition) {
}
HInstanceFieldGet* field_get = (load_class == input_one)
- ? input_two->AsInstanceFieldGet()
- : input_one->AsInstanceFieldGet();
+ ? input_two->AsInstanceFieldGetOrNull()
+ : input_one->AsInstanceFieldGetOrNull();
if (field_get == nullptr) {
return false;
}
@@ -1755,7 +1810,8 @@ 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.
- if (!left->IsCompare() || !right->IsConstant() || right->AsIntConstant()->GetValue() != 0) {
+ // TODO: Remove "OrNull".
+ if (!left->IsCompare() || !right->IsConstant() || right->AsIntConstantOrNull()->GetValue() != 0) {
// Conversion is not possible.
return;
}
@@ -1782,7 +1838,8 @@ void InstructionSimplifierVisitor::VisitCondition(HCondition* condition) {
left->RemoveEnvironmentUsers();
// We have decided to fold the HCompare into the HCondition. Transfer the information.
- condition->SetBias(left->AsCompare()->GetBias());
+ // TODO: Remove "OrNull".
+ condition->SetBias(left->AsCompareOrNull()->GetBias());
// Replace the operands of the HCondition.
condition->ReplaceInput(left->InputAt(0), 0);
@@ -1840,13 +1897,15 @@ void InstructionSimplifierVisitor::VisitDiv(HDiv* instruction) {
// MUL dst, src, 1 / constant
HConstant* reciprocal = nullptr;
if (type == DataType::Type::kFloat64) {
- double value = input_cst->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double value = input_cst->AsDoubleConstantOrNull()->GetValue();
if (CanDivideByReciprocalMultiplyDouble(bit_cast<int64_t, double>(value))) {
reciprocal = GetGraph()->GetDoubleConstant(1.0 / value);
}
} else {
DCHECK_EQ(type, DataType::Type::kFloat32);
- float value = input_cst->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float value = input_cst->AsFloatConstantOrNull()->GetValue();
if (CanDivideByReciprocalMultiplyFloat(bit_cast<int32_t, float>(value))) {
reciprocal = GetGraph()->GetFloatConstant(1.0f / value);
}
@@ -1873,7 +1932,8 @@ static HDiv* FindDivWithInputsInBasicBlock(HInstruction* dividend,
user->IsDiv() &&
user->InputAt(0) == dividend &&
user->InputAt(1) == divisor) {
- return user->AsDiv();
+ // TODO: Remove "OrNull".
+ return user->AsDivOrNull();
}
}
return nullptr;
@@ -1963,9 +2023,10 @@ void InstructionSimplifierVisitor::VisitMul(HMul* instruction) {
return;
}
+ // TODO: Remove "OrNull".
if (DataType::IsFloatingPointType(type) &&
- ((input_cst->IsFloatConstant() && input_cst->AsFloatConstant()->GetValue() == 2.0f) ||
- (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstant()->GetValue() == 2.0))) {
+ ((input_cst->IsFloatConstant() && input_cst->AsFloatConstantOrNull()->GetValue() == 2.0f) ||
+ (input_cst->IsDoubleConstant() && input_cst->AsDoubleConstantOrNull()->GetValue() == 2.0))) {
// Replace code looking like
// FP_MUL dst, src, 2.0
// with
@@ -2046,7 +2107,8 @@ void InstructionSimplifierVisitor::VisitNeg(HNeg* instruction) {
// NEG dst, tmp
// with
// src
- HNeg* previous_neg = input->AsNeg();
+ // TODO: Remove "OrNull".
+ HNeg* previous_neg = input->AsNegOrNull();
instruction->ReplaceWith(previous_neg->GetInput());
instruction->GetBlock()->RemoveInstruction(instruction);
// We perform the optimization even if the input negation has environment
@@ -2072,7 +2134,8 @@ 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.
- HSub* sub = input->AsSub();
+ // TODO: Remove "OrNull".
+ HSub* sub = input->AsSubOrNull();
HSub* new_sub = new (GetGraph()->GetAllocator()) HSub(
instruction->GetType(), sub->GetRight(), sub->GetLeft());
instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, new_sub);
@@ -2094,7 +2157,8 @@ 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.
- HNot* previous_not = input->AsNot();
+ // TODO: Remove "OrNull".
+ HNot* previous_not = input->AsNotOrNull();
instruction->ReplaceWith(previous_not->GetInput());
instruction->GetBlock()->RemoveInstruction(instruction);
if (!previous_not->HasUses()) {
@@ -2181,7 +2245,8 @@ void InstructionSimplifierVisitor::VisitSub(HSub* instruction) {
HInstruction* left = instruction->GetLeft();
HInstruction* right = instruction->GetRight();
if (left->IsConstant()) {
- if (Int64FromConstant(left->AsConstant()) == 0) {
+ // TODO: Remove "OrNull".
+ if (Int64FromConstant(left->AsConstantOrNull()) == 0) {
// Replace code looking like
// SUB dst, 0, src
// with
@@ -2208,7 +2273,8 @@ void InstructionSimplifierVisitor::VisitSub(HSub* instruction) {
// SUB dst, a, tmp
// with
// ADD dst, a, b
- HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left, right->AsNeg()->GetInput());
+ // TODO: Remove "OrNull".
+ HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left, right->AsNegOrNull()->GetInput());
instruction->GetBlock()->ReplaceAndRemoveInstructionWith(instruction, add);
RecordSimplification();
right->GetBlock()->RemoveInstruction(right);
@@ -2224,7 +2290,8 @@ void InstructionSimplifierVisitor::VisitSub(HSub* instruction) {
// NEG dst, tmp
// The second version is not intrinsically better, but enables more
// transformations.
- HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left->AsNeg()->GetInput(), right);
+ // TODO: Remove "OrNull".
+ HAdd* add = new(GetGraph()->GetAllocator()) HAdd(type, left->AsNegOrNull()->GetInput(), right);
instruction->GetBlock()->InsertInstructionBefore(add, instruction);
HNeg* neg = new (GetGraph()->GetAllocator()) HNeg(instruction->GetType(), add);
instruction->GetBlock()->InsertInstructionBefore(neg, instruction);
@@ -2364,7 +2431,8 @@ static bool IsArrayLengthOf(HInstruction* potential_length, HInstruction* potent
}
if (potential_array->IsNewArray()) {
- return potential_array->AsNewArray()->GetLength() == potential_length;
+ // TODO: Remove "OrNull".
+ return potential_array->AsNewArrayOrNull()->GetLength() == potential_length;
}
return false;
@@ -2431,7 +2499,8 @@ void InstructionSimplifierVisitor::SimplifySystemArrayCopy(HInvoke* instruction)
(source_component_type == destination_component_type)) {
ClassLinker* class_linker = Runtime::Current()->GetClassLinker();
PointerSize image_size = class_linker->GetImagePointerSize();
- HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* invoke = instruction->AsInvokeStaticOrDirectOrNull();
ObjPtr<mirror::Class> system = invoke->GetResolvedMethod()->GetDeclaringClass();
ArtMethod* method = nullptr;
switch (source_component_type) {
@@ -2547,7 +2616,8 @@ void InstructionSimplifierVisitor::SimplifyStringIndexOf(HInvoke* invoke) {
DCHECK(invoke->GetIntrinsic() == Intrinsics::kStringIndexOf ||
invoke->GetIntrinsic() == Intrinsics::kStringIndexOfAfter);
if (invoke->InputAt(0)->IsLoadString()) {
- HLoadString* load_string = invoke->InputAt(0)->AsLoadString();
+ // TODO: Remove "OrNull".
+ HLoadString* load_string = invoke->InputAt(0)->AsLoadStringOrNull();
const DexFile& dex_file = load_string->GetDexFile();
uint32_t utf16_length;
const char* data =
@@ -2603,11 +2673,13 @@ void InstructionSimplifierVisitor::SimplifyReturnThis(HInvoke* invoke) {
static bool NoEscapeForStringBufferReference(HInstruction* reference, HInstruction* user) {
if (user->IsInvokeStaticOrDirect()) {
// Any constructor on StringBuffer is okay.
- return user->AsInvokeStaticOrDirect()->GetResolvedMethod() != nullptr &&
- user->AsInvokeStaticOrDirect()->GetResolvedMethod()->IsConstructor() &&
+ // TODO: Remove "OrNull".
+ return user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod() != nullptr &&
+ user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod()->IsConstructor() &&
user->InputAt(0) == reference;
} else if (user->IsInvokeVirtual()) {
- switch (user->AsInvokeVirtual()->GetIntrinsic()) {
+ // TODO: Remove "OrNull".
+ switch (user->AsInvokeVirtualOrNull()->GetIntrinsic()) {
case Intrinsics::kStringBufferLength:
case Intrinsics::kStringBufferToString:
DCHECK_EQ(user->InputAt(0), reference);
@@ -2678,7 +2750,8 @@ static bool TryReplaceStringBuilderAppend(HInvoke* invoke) {
}
// Then we should see the arguments.
if (user->IsInvokeVirtual()) {
- HInvokeVirtual* as_invoke_virtual = user->AsInvokeVirtual();
+ // TODO: Remove "OrNull".
+ HInvokeVirtual* as_invoke_virtual = user->AsInvokeVirtualOrNull();
DCHECK(!seen_constructor);
DCHECK(!seen_constructor_fence);
StringBuilderAppend::Argument arg;
@@ -2714,7 +2787,8 @@ static bool TryReplaceStringBuilderAppend(HInvoke* invoke) {
has_fp_args = true;
break;
case Intrinsics::kStringBuilderAppendCharSequence: {
- ReferenceTypeInfo rti = user->AsInvokeVirtual()->InputAt(1)->GetReferenceTypeInfo();
+ // TODO: Remove "OrNull".
+ ReferenceTypeInfo rti = user->AsInvokeVirtualOrNull()->InputAt(1)->GetReferenceTypeInfo();
if (!rti.IsValid()) {
return false;
}
@@ -2746,9 +2820,12 @@ static bool TryReplaceStringBuilderAppend(HInvoke* invoke) {
args[num_args] = as_invoke_virtual->InputAt(1u);
++num_args;
} else if (user->IsInvokeStaticOrDirect() &&
- user->AsInvokeStaticOrDirect()->GetResolvedMethod() != nullptr &&
- user->AsInvokeStaticOrDirect()->GetResolvedMethod()->IsConstructor() &&
- user->AsInvokeStaticOrDirect()->GetNumberOfArguments() == 1u) {
+ // TODO: Remove "OrNull".
+ user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod() != nullptr &&
+ // TODO: Remove "OrNull".
+ user->AsInvokeStaticOrDirectOrNull()->GetResolvedMethod()->IsConstructor() &&
+ // TODO: Remove "OrNull".
+ user->AsInvokeStaticOrDirectOrNull()->GetNumberOfArguments() == 1u) {
// After arguments, we should see the constructor.
// We accept only the constructor with no extra arguments.
DCHECK(!seen_constructor);
@@ -2887,7 +2964,8 @@ bool InstructionSimplifierVisitor::CanUseKnownBootImageVarHandle(HInvoke* invoke
if (!var_handle_instruction->IsStaticFieldGet()) {
return false;
}
- ArtField* field = var_handle_instruction->AsStaticFieldGet()->GetFieldInfo().GetField();
+ // TODO: Remove "OrNull".
+ ArtField* field = var_handle_instruction->AsStaticFieldGetOrNull()->GetFieldInfo().GetField();
DCHECK(field->IsStatic());
if (!field->IsFinal()) {
return false;
@@ -2910,9 +2988,11 @@ bool InstructionSimplifierVisitor::CanUseKnownBootImageVarHandle(HInvoke* invoke
is_in_boot_image = compiler_options.IsImageClass(descriptor);
}
CHECK_EQ(is_in_boot_image,
- load_class->IsLoadClass() && load_class->AsLoadClass()->IsInBootImage());
+ // TODO: Remove "OrNull".
+ load_class->IsLoadClass() && load_class->AsLoadClassOrNull()->IsInBootImage());
}
- if (!load_class->IsLoadClass() || !load_class->AsLoadClass()->IsInBootImage()) {
+ // TODO: Remove "OrNull".
+ if (!load_class->IsLoadClass() || !load_class->AsLoadClassOrNull()->IsInBootImage()) {
return false;
}
@@ -3108,7 +3188,8 @@ void InstructionSimplifierVisitor::VisitInvoke(HInvoke* instruction) {
void InstructionSimplifierVisitor::VisitDeoptimize(HDeoptimize* deoptimize) {
HInstruction* cond = deoptimize->InputAt(0);
if (cond->IsConstant()) {
- if (cond->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ if (cond->AsIntConstantOrNull()->IsFalse()) {
// Never deopt: instruction can be removed.
if (deoptimize->GuardsAnInput()) {
deoptimize->ReplaceWith(deoptimize->GuardedInput());
@@ -3141,11 +3222,15 @@ bool InstructionSimplifierVisitor::TryHandleAssociativeAndCommutativeOperation(
HBinaryOperation* y;
if (instruction->GetKind() == left->GetKind() && right->IsConstant()) {
- const2 = right->AsConstant();
- y = left->AsBinaryOperation();
+ // TODO: Remove "OrNull".
+ const2 = right->AsConstantOrNull();
+ // TODO: Remove "OrNull".
+ y = left->AsBinaryOperationOrNull();
} else if (left->IsConstant() && instruction->GetKind() == right->GetKind()) {
- const2 = left->AsConstant();
- y = right->AsBinaryOperation();
+ // TODO: Remove "OrNull".
+ const2 = left->AsConstantOrNull();
+ // TODO: Remove "OrNull".
+ y = right->AsBinaryOperationOrNull();
} else {
// The node does not match the pattern.
return false;
@@ -3176,7 +3261,8 @@ bool InstructionSimplifierVisitor::TryHandleAssociativeAndCommutativeOperation(
}
static HBinaryOperation* AsAddOrSub(HInstruction* binop) {
- return (binop->IsAdd() || binop->IsSub()) ? binop->AsBinaryOperation() : nullptr;
+ // TODO: Remove "OrNull".
+ return (binop->IsAdd() || binop->IsSub()) ? binop->AsBinaryOperationOrNull() : nullptr;
}
// Helper function that performs addition statically, considering the result type.
@@ -3215,13 +3301,15 @@ bool InstructionSimplifierVisitor::TrySubtractionChainSimplification(
HInstruction* left = instruction->GetLeft();
HInstruction* right = instruction->GetRight();
// Variable names as described above.
- HConstant* const2 = right->IsConstant() ? right->AsConstant() : left->AsConstant();
+ // TODO: Remove first "OrNull", keep the second.
+ HConstant* const2 = right->IsConstant() ? right->AsConstantOrNull() : left->AsConstantOrNull();
if (const2 == nullptr) {
return false;
}
HBinaryOperation* y = (AsAddOrSub(left) != nullptr)
- ? left->AsBinaryOperation()
+ // TODO: Remove "OrNull".
+ ? left->AsBinaryOperationOrNull()
: 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
@@ -3231,7 +3319,9 @@ bool InstructionSimplifierVisitor::TrySubtractionChainSimplification(
}
left = y->GetLeft();
- HConstant* const1 = left->IsConstant() ? left->AsConstant() : y->GetRight()->AsConstant();
+ // TODO: Remove first "OrNull", keep the second.
+ HConstant* const1 =
+ left->IsConstant() ? left->AsConstantOrNull() : 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 05a518d544..1aeb63867a 100644
--- a/compiler/optimizing/instruction_simplifier_arm.cc
+++ b/compiler/optimizing/instruction_simplifier_arm.cc
@@ -105,7 +105,8 @@ bool InstructionSimplifierArmVisitor::TryMergeIntoShifterOperand(HInstruction* u
return false;
}
- bool is_commutative = use->AsBinaryOperation()->IsCommutative();
+ // TODO: Remove "OrNull".
+ bool is_commutative = use->AsBinaryOperationOrNull()->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 671900bd9d..a4e558b42d 100644
--- a/compiler/optimizing/instruction_simplifier_arm64.cc
+++ b/compiler/optimizing/instruction_simplifier_arm64.cc
@@ -107,7 +107,8 @@ bool InstructionSimplifierArm64Visitor::TryMergeIntoShifterOperand(HInstruction*
right = use->InputAt(1);
} else {
DCHECK(use->IsNeg());
- right = use->AsNeg()->InputAt(0);
+ // TODO: Remove "OrNull".
+ right = use->AsNegOrNull()->InputAt(0);
left = GetGraph()->GetConstant(right->GetType(), 0);
}
DCHECK(left == bitfield_op || right == bitfield_op);
@@ -119,7 +120,8 @@ bool InstructionSimplifierArm64Visitor::TryMergeIntoShifterOperand(HInstruction*
return false;
}
- bool is_commutative = use->IsBinaryOperation() && use->AsBinaryOperation()->IsCommutative();
+ // TODO: Remove "OrNull".
+ bool is_commutative = use->IsBinaryOperation() && use->AsBinaryOperationOrNull()->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 34daae21ee..3357e53737 100644
--- a/compiler/optimizing/instruction_simplifier_shared.cc
+++ b/compiler/optimizing/instruction_simplifier_shared.cc
@@ -52,7 +52,8 @@ bool TrySimpleMultiplyAccumulatePatterns(HMul* mul,
} else {
DCHECK(input_binop->IsSub());
if (input_binop->GetRight()->IsConstant() &&
- input_binop->GetRight()->AsConstant()->IsMinusOne()) {
+ // TODO: Remove "OrNull".
+ input_binop->GetRight()->AsConstantOrNull()->IsMinusOne()) {
// Interpret
// a * (b - (-1))
// as
@@ -60,7 +61,8 @@ bool TrySimpleMultiplyAccumulatePatterns(HMul* mul,
input_b = input_binop->GetLeft();
op_kind = HInstruction::kAdd;
} else if (input_binop->GetLeft()->IsConstant() &&
- input_binop->GetLeft()->AsConstant()->IsOne()) {
+ // TODO: Remove "OrNull".
+ input_binop->GetLeft()->AsConstantOrNull()->IsOne()) {
// Interpret
// a * (1 - b)
// as
@@ -122,7 +124,8 @@ 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;
- HBinaryOperation* binop = use->AsBinaryOperation();
+ // TODO: Remove "OrNull".
+ HBinaryOperation* binop = use->AsBinaryOperationOrNull();
HInstruction* binop_left = binop->GetLeft();
HInstruction* binop_right = binop->GetRight();
// Be careful after GVN. This should not happen since the `HMul` has only
@@ -175,11 +178,13 @@ bool TryCombineMultiplyAccumulate(HMul* mul, InstructionSet isa) {
HInstruction* left = mul->GetLeft();
HInstruction* right = mul->GetRight();
if ((right->IsAdd() || right->IsSub()) &&
- TrySimpleMultiplyAccumulatePatterns(mul, right->AsBinaryOperation(), left)) {
+ // TODO: Remove "OrNull".
+ TrySimpleMultiplyAccumulatePatterns(mul, right->AsBinaryOperationOrNull(), left)) {
return true;
}
if ((left->IsAdd() || left->IsSub()) &&
- TrySimpleMultiplyAccumulatePatterns(mul, left->AsBinaryOperation(), right)) {
+ // TODO: Remove "OrNull".
+ TrySimpleMultiplyAccumulatePatterns(mul, left->AsBinaryOperationOrNull(), right)) {
return true;
}
return false;
@@ -214,7 +219,8 @@ bool TryMergeNegatedInput(HBinaryOperation* op) {
// AND dst, src, tmp (respectively ORR, EOR)
// with
// BIC dst, src, mask (respectively ORN, EON)
- HInstruction* src = hnot->AsNot()->GetInput();
+ // TODO: Remove "OrNull".
+ HInstruction* src = hnot->AsNotOrNull()->GetInput();
HBitwiseNegatedRight* neg_op = new (hnot->GetBlock()->GetGraph()->GetAllocator())
HBitwiseNegatedRight(op->GetType(), op->GetKind(), hother, src, op->GetDexPc());
@@ -234,13 +240,15 @@ bool TryExtractArrayAccessAddress(HInstruction* access,
HInstruction* index,
size_t data_offset) {
if (index->IsConstant() ||
- (index->IsBoundsCheck() && index->AsBoundsCheck()->GetIndex()->IsConstant())) {
+ // TODO: Remove "OrNull".
+ (index->IsBoundsCheck() && index->AsBoundsCheckOrNull()->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() &&
- access->AsArraySet()->GetValue()->GetType() == DataType::Type::kReference) {
+ // TODO: Remove "OrNull".
+ access->AsArraySetOrNull()->GetValue()->GetType() == DataType::Type::kReference) {
// The access may require a runtime call or the original array pointer.
return false;
}
@@ -300,7 +308,8 @@ bool TryExtractVecArrayAccessAddress(HVecMemoryOperation* access, HInstruction*
for (const HUseListNode<HInstruction*>& use : index->GetUses()) {
HInstruction* user = use.GetUser();
if (user->IsVecMemoryOperation() && user != access) {
- HVecMemoryOperation* another_access = user->AsVecMemoryOperation();
+ // TODO: Remove "OrNull".
+ HVecMemoryOperation* another_access = user->AsVecMemoryOperationOrNull();
DataType::Type another_packed_type = another_access->GetPackedType();
uint32_t another_data_offset = mirror::Array::DataOffset(
DataType::Size(another_packed_type)).Uint32Value();
@@ -310,9 +319,13 @@ bool TryExtractVecArrayAccessAddress(HVecMemoryOperation* access, HInstruction*
break;
}
} else if (user->IsIntermediateAddressIndex()) {
- 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();
+ // 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();
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 01489f8bcb..fe9d429984 100644
--- a/compiler/optimizing/instruction_simplifier_shared.h
+++ b/compiler/optimizing/instruction_simplifier_shared.h
@@ -26,16 +26,18 @@ namespace helpers {
inline bool CanFitInShifterOperand(HInstruction* instruction) {
if (instruction->IsTypeConversion()) {
- HTypeConversion* conversion = instruction->AsTypeConversion();
+ // TODO: Remove "OrNull".
+ HTypeConversion* conversion = instruction->AsTypeConversionOrNull();
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 {
- return (instruction->IsShl() && instruction->AsShl()->InputAt(1)->IsIntConstant()) ||
- (instruction->IsShr() && instruction->AsShr()->InputAt(1)->IsIntConstant()) ||
- (instruction->IsUShr() && instruction->AsUShr()->InputAt(1)->IsIntConstant());
+ // 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());
}
}
@@ -54,7 +56,8 @@ inline bool HasShifterOperand(HInstruction* instr, InstructionSet isa) {
// t3 = Sub(*, t2)
inline bool IsSubRightSubLeftShl(HSub *sub) {
HInstruction* right = sub->GetRight();
- return right->IsSub() && right->AsSub()->GetLeft()->IsShl();
+ // TODO: Remove "OrNull".
+ return right->IsSub() && right->AsSubOrNull()->GetLeft()->IsShl();
}
} // namespace helpers
diff --git a/compiler/optimizing/instruction_simplifier_x86_shared.cc b/compiler/optimizing/instruction_simplifier_x86_shared.cc
index 74c5ca2466..39ae39e27e 100644
--- a/compiler/optimizing/instruction_simplifier_x86_shared.cc
+++ b/compiler/optimizing/instruction_simplifier_x86_shared.cc
@@ -37,7 +37,8 @@ bool TryCombineAndNot(HAnd* instruction) {
if (left->IsNot() ^ right->IsNot()) {
bool left_is_not = left->IsNot();
HInstruction* other_ins = (left_is_not ? right : left);
- HNot* not_ins = (left_is_not ? left : right)->AsNot();
+ // TODO: Remove "OrNull".
+ HNot* not_ins = (left_is_not ? left : right)->AsNotOrNull();
// Only do the simplification if instruction has only one use
// and thus can be safely removed.
if (not_ins->HasOnlyOneNonEnvironmentUse()) {
@@ -123,12 +124,14 @@ bool TryGenerateMaskUptoLeastSetBit(HXor* instruction) {
bool AreLeastSetBitInputs(HInstruction* to_test, HInstruction* other) {
if (to_test->IsAdd()) {
- HAdd* add = to_test->AsAdd();
+ // TODO: Remove "OrNull".
+ HAdd* add = to_test->AsAddOrNull();
HConstant* cst = add->GetConstantRight();
return cst != nullptr && cst->IsMinusOne() && other == add->GetLeastConstantLeft();
}
if (to_test->IsSub()) {
- HSub* sub = to_test->AsSub();
+ // TODO: Remove "OrNull".
+ HSub* sub = to_test->AsSubOrNull();
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 774deec438..f832d9c8bf 100644
--- a/compiler/optimizing/intrinsics.cc
+++ b/compiler/optimizing/intrinsics.cc
@@ -151,7 +151,8 @@ 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() &&
- !invoke->AsInvokeStaticOrDirect()->HasPcRelativeMethodLoadKind()) {
+ // TODO: Remove "OrNull".
+ !invoke->AsInvokeStaticOrDirectOrNull()->HasPcRelativeMethodLoadKind()) {
return false;
}
if (!compiler_options.IsBootImage() &&
@@ -209,7 +210,8 @@ void IntrinsicVisitor::ComputeIntegerValueOfLocations(HInvoke* invoke,
}
}
if (input->IsIntConstant()) {
- int32_t value = input->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = input->AsIntConstantOrNull()->GetValue();
if (static_cast<uint32_t>(value) - static_cast<uint32_t>(low) <
static_cast<uint32_t>(high - low + 1)) {
// No call, we shall use direct pointer to the Integer object.
@@ -234,7 +236,8 @@ void IntrinsicVisitor::ComputeIntegerValueOfLocations(HInvoke* invoke,
DCHECK(compiler_options.IsAotCompiler());
DCHECK(CheckIntegerCache(self, runtime->GetClassLinker(), boot_image_live_objects, cache));
if (input->IsIntConstant()) {
- int32_t value = input->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = input->AsIntConstantOrNull()->GetValue();
// Retrieve the `value` from the lowest cached Integer.
ObjPtr<mirror::Object> low_integer =
IntrinsicObjects::GetIntegerValueOfObject(boot_image_live_objects, 0u);
@@ -308,7 +311,8 @@ IntrinsicVisitor::IntegerValueOfInfo IntrinsicVisitor::ComputeIntegerValueOfInfo
info.length = dchecked_integral_cast<uint32_t>(high - info.low + 1);
if (invoke->InputAt(0)->IsIntConstant()) {
- int32_t input_value = invoke->InputAt(0)->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t input_value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
uint32_t index = static_cast<uint32_t>(input_value) - static_cast<uint32_t>(info.low);
if (index < static_cast<uint32_t>(info.length)) {
info.value_boot_image_reference = IntrinsicObjects::EncodePatch(
@@ -343,7 +347,8 @@ IntrinsicVisitor::IntegerValueOfInfo IntrinsicVisitor::ComputeIntegerValueOfInfo
IntrinsicObjects::GetIntegerValueOfCache(boot_image_live_objects)->GetLength());
if (invoke->InputAt(0)->IsIntConstant()) {
- int32_t input_value = invoke->InputAt(0)->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t input_value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
uint32_t index = static_cast<uint32_t>(input_value) - static_cast<uint32_t>(info.low);
if (index < static_cast<uint32_t>(info.length)) {
ObjPtr<mirror::Object> integer =
diff --git a/compiler/optimizing/intrinsics.h b/compiler/optimizing/intrinsics.h
index 893cd04411..017c3d123b 100644
--- a/compiler/optimizing/intrinsics.h
+++ b/compiler/optimizing/intrinsics.h
@@ -71,7 +71,8 @@ class IntrinsicVisitor : public ValueObject {
CodeGenerator* codegen,
InvokeDexCallingConventionVisitor* calling_convention_visitor) {
if (kIsDebugBuild && invoke->IsInvokeStaticOrDirect()) {
- HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirectOrNull();
// 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 b34f6a0126..01138ff9d9 100644
--- a/compiler/optimizing/intrinsics_arm64.cc
+++ b/compiler/optimizing/intrinsics_arm64.cc
@@ -103,7 +103,8 @@ class ReadBarrierSystemArrayCopySlowPathARM64 : public SlowPathCodeARM64 {
<< "Unexpected instruction in read barrier arraycopy slow path: "
<< instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
const int32_t element_size = DataType::Size(DataType::Type::kReference);
@@ -1897,7 +1898,8 @@ constexpr size_t kShortConstStringEqualsCutoffInBytes = 32;
static const char* GetConstString(HInstruction* candidate, uint32_t* utf16_length) {
if (candidate->IsLoadString()) {
- HLoadString* load_string = candidate->AsLoadString();
+ // TODO: Remove "OrNull".
+ HLoadString* load_string = candidate->AsLoadStringOrNull();
const DexFile& dex_file = load_string->GetDexFile();
return dex_file.StringDataAndUtf16LengthByIdx(load_string->GetStringIndex(), utf16_length);
}
@@ -2107,7 +2109,8 @@ static void GenerateVisitStringIndexOf(HInvoke* invoke,
SlowPathCodeARM64* slow_path = nullptr;
HInstruction* code_point = invoke->InputAt(1);
if (code_point->IsIntConstant()) {
- if (static_cast<uint32_t>(code_point->AsIntConstant()->GetValue()) > 0xFFFFU) {
+ // TODO: Remove "OrNull".
+ if (static_cast<uint32_t>(code_point->AsIntConstantOrNull()->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);
@@ -2582,7 +2585,7 @@ static constexpr int32_t kSystemArrayCopyCharThreshold = 192;
static void SetSystemArrayCopyLocationRequires(LocationSummary* locations,
uint32_t at,
HInstruction* input) {
- HIntConstant* const_input = input->AsIntConstant();
+ HIntConstant* const_input = input->AsIntConstantOrNull();
if (const_input != nullptr && !vixl::aarch64::Assembler::IsImmAddSub(const_input->GetValue())) {
locations->SetInAt(at, Location::RequiresRegister());
} else {
@@ -2593,8 +2596,8 @@ static void SetSystemArrayCopyLocationRequires(LocationSummary* locations,
void IntrinsicLocationsBuilderARM64::VisitSystemArrayCopyChar(HInvoke* invoke) {
// Check to see if we have known failures that will cause us to have to bail out
// to the runtime, and just generate the runtime call directly.
- HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant();
- HIntConstant* dst_pos = invoke->InputAt(3)->AsIntConstant();
+ HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstantOrNull();
+ HIntConstant* dst_pos = invoke->InputAt(3)->AsIntConstantOrNull();
// The positions must be non-negative.
if ((src_pos != nullptr && src_pos->GetValue() < 0) ||
@@ -2605,7 +2608,7 @@ void IntrinsicLocationsBuilderARM64::VisitSystemArrayCopyChar(HInvoke* invoke) {
// The length must be >= 0 and not so long that we would (currently) prefer libcore's
// native implementation.
- HIntConstant* length = invoke->InputAt(4)->AsIntConstant();
+ HIntConstant* length = invoke->InputAt(4)->AsIntConstantOrNull();
if (length != nullptr) {
int32_t len = length->GetValue();
if (len < 0 || len > kSystemArrayCopyCharThreshold) {
@@ -2638,7 +2641,8 @@ static void CheckSystemArrayCopyPosition(MacroAssembler* masm,
bool length_is_input_length = false) {
const int32_t length_offset = mirror::Array::LengthOffset().Int32Value();
if (pos.IsConstant()) {
- int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (pos_const == 0) {
if (!length_is_input_length) {
// Check that length(input) >= length.
@@ -2694,7 +2698,8 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm,
const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value();
if (src_pos.IsConstant()) {
- int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ Add(src_base, src, element_size * constant + data_offset);
} else {
__ Add(src_base, src, data_offset);
@@ -2702,7 +2707,8 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm,
}
if (dst_pos.IsConstant()) {
- int32_t constant = dst_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = dst_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ Add(dst_base, dst, element_size * constant + data_offset);
} else {
__ Add(dst_base, dst, data_offset);
@@ -2711,7 +2717,8 @@ static void GenSystemArrayCopyAddresses(MacroAssembler* masm,
if (src_end.IsValid()) {
if (copy_length.IsConstant()) {
- int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue();
__ Add(src_end, src_base, element_size * constant);
} else {
__ Add(src_end, src_base, Operand(XRegisterFrom(copy_length), LSL, element_size_shift));
@@ -2752,8 +2759,11 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopyChar(HInvoke* invoke) {
__ B(slow_path->GetEntryLabel(), hi);
} else {
// We have already checked in the LocationsBuilder for the constant case.
- DCHECK_GE(length.GetConstant()->AsIntConstant()->GetValue(), 0);
- DCHECK_LE(length.GetConstant()->AsIntConstant()->GetValue(), kSystemArrayCopyCharThreshold);
+ // TODO: Remove "OrNull".
+ DCHECK_GE(length.GetConstant()->AsIntConstantOrNull()->GetValue(), 0);
+ // TODO: Remove "OrNull".
+ DCHECK_LE(length.GetConstant()->AsIntConstantOrNull()->GetValue(),
+ kSystemArrayCopyCharThreshold);
}
Register src_curr_addr = WRegisterFrom(locations->GetTemp(0));
@@ -2857,7 +2867,8 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopyChar(HInvoke* invoke) {
};
if (length.IsConstant()) {
- const int32_t constant_length = length.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ const int32_t constant_length = length.GetConstant()->AsIntConstantOrNull()->GetValue();
if (constant_length >= unroll_threshold) {
__ Mov(length_tmp, constant_length - chars_per_block);
emitHeadLoop();
@@ -2903,8 +2914,8 @@ void IntrinsicLocationsBuilderARM64::VisitSystemArrayCopy(HInvoke* invoke) {
// Check to see if we have known failures that will cause us to have to bail out
// to the runtime, and just generate the runtime call directly.
- HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant();
- HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstant();
+ HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstantOrNull();
+ HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstantOrNull();
// The positions must be non-negative.
if ((src_pos != nullptr && src_pos->GetValue() < 0) ||
@@ -2914,7 +2925,7 @@ void IntrinsicLocationsBuilderARM64::VisitSystemArrayCopy(HInvoke* invoke) {
}
// The length must be >= 0.
- HIntConstant* length = invoke->InputAt(4)->AsIntConstant();
+ HIntConstant* length = invoke->InputAt(4)->AsIntConstantOrNull();
if (length != nullptr) {
int32_t len = length->GetValue();
if (len < 0 || len >= kSystemArrayCopyThreshold) {
@@ -2998,9 +3009,11 @@ 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()) {
- int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (dest_pos.IsConstant()) {
- int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (optimizations.GetDestinationIsSource()) {
// Checked when building locations.
DCHECK_GE(src_pos_constant, dest_pos_constant);
@@ -3010,7 +3023,8 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) {
}
// Checked when building locations.
DCHECK(!optimizations.GetDestinationIsSource() ||
- (src_pos_constant >= dest_pos.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ (src_pos_constant >= dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
if (!optimizations.GetDestinationIsSource()) {
__ Cmp(src, dest);
@@ -3283,7 +3297,8 @@ void IntrinsicCodeGeneratorARM64::VisitSystemArrayCopy(HInvoke* invoke) {
__ Cbnz(temp2, intrinsic_slow_path->GetEntryLabel());
}
- if (length.IsConstant() && length.GetConstant()->AsIntConstant()->GetValue() == 0) {
+ // TODO: Remove "OrNull".
+ if (length.IsConstant() && length.GetConstant()->AsIntConstantOrNull()->GetValue() == 0) {
// Null constant length: not need to emit the loop code at all.
} else {
Register src_curr_addr = temp1.X();
@@ -3490,7 +3505,8 @@ void IntrinsicCodeGeneratorARM64::VisitIntegerValueOf(HInvoke* invoke) {
CheckEntrypointTypes<kQuickAllocObjectWithChecks, void*, mirror::Class*>();
};
if (invoke->InputAt(0)->IsConstant()) {
- int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
if (static_cast<uint32_t>(value - info.low) < info.length) {
// Just embed the j.l.Integer in the code.
DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference);
@@ -3865,7 +3881,8 @@ void IntrinsicCodeGeneratorARM64::VisitCRC32UpdateBytes(HInvoke* invoke) {
Register array = XRegisterFrom(locations->InAt(1));
Location offset = locations->InAt(2);
if (offset.IsConstant()) {
- int32_t offset_value = offset.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t offset_value = offset.GetConstant()->AsIntConstantOrNull()->GetValue();
__ Add(ptr, array, array_data_offset + offset_value);
} else {
__ Add(ptr, array, array_data_offset);
@@ -4362,7 +4379,8 @@ class VarHandleSlowPathARM64 : public IntrinsicSlowPathARM64 {
private:
HInvoke* GetInvoke() const {
- return GetInstruction()->AsInvoke();
+ // TODO: Remove "OrNull".
+ return GetInstruction()->AsInvokeOrNull();
}
mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const {
diff --git a/compiler/optimizing/intrinsics_arm_vixl.cc b/compiler/optimizing/intrinsics_arm_vixl.cc
index 266b5bc799..c99e9122ce 100644
--- a/compiler/optimizing/intrinsics_arm_vixl.cc
+++ b/compiler/optimizing/intrinsics_arm_vixl.cc
@@ -133,7 +133,8 @@ class ReadBarrierSystemArrayCopySlowPathARMVIXL : public SlowPathCodeARMVIXL {
<< "Unexpected instruction in read barrier arraycopy slow path: "
<< instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
DataType::Type type = DataType::Type::kReference;
const int32_t element_size = DataType::Size(type);
@@ -882,7 +883,8 @@ constexpr size_t kShortConstStringEqualsCutoffInBytes = 16;
static const char* GetConstString(HInstruction* candidate, uint32_t* utf16_length) {
if (candidate->IsLoadString()) {
- HLoadString* load_string = candidate->AsLoadString();
+ // TODO: Remove "OrNull".
+ HLoadString* load_string = candidate->AsLoadStringOrNull();
const DexFile& dex_file = load_string->GetDexFile();
return dex_file.StringDataAndUtf16LengthByIdx(load_string->GetStringIndex(), utf16_length);
}
@@ -1252,9 +1254,9 @@ void IntrinsicLocationsBuilderARMVIXL::VisitSystemArrayCopy(HInvoke* invoke) {
return;
}
- HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant();
- HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstant();
- HIntConstant* length = invoke->InputAt(4)->AsIntConstant();
+ HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstantOrNull();
+ HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstantOrNull();
+ HIntConstant* length = invoke->InputAt(4)->AsIntConstantOrNull();
if (src_pos != nullptr && !assembler_->ShifterOperandCanAlwaysHold(src_pos->GetValue())) {
locations->SetInAt(1, Location::RequiresRegister());
@@ -2458,7 +2460,8 @@ void IntrinsicCodeGeneratorARMVIXL::VisitIntegerValueOf(HInvoke* invoke) {
CheckEntrypointTypes<kQuickAllocObjectWithChecks, void*, mirror::Class*>();
};
if (invoke->InputAt(0)->IsConstant()) {
- int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
if (static_cast<uint32_t>(value - info.low) < info.length) {
// Just embed the j.l.Integer in the code.
DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference);
@@ -3993,7 +3996,8 @@ class VarHandleSlowPathARMVIXL : public IntrinsicSlowPathARMVIXL {
private:
HInvoke* GetInvoke() const {
- return GetInstruction()->AsInvoke();
+ // TODO: Remove "OrNull".
+ return GetInstruction()->AsInvokeOrNull();
}
mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const {
diff --git a/compiler/optimizing/intrinsics_utils.h b/compiler/optimizing/intrinsics_utils.h
index 13cabdafed..5422275ba7 100644
--- a/compiler/optimizing/intrinsics_utils.h
+++ b/compiler/optimizing/intrinsics_utils.h
@@ -63,16 +63,19 @@ class IntrinsicSlowPath : public TSlowPathCode {
Location method_loc = MoveArguments(codegen);
if (invoke_->IsInvokeStaticOrDirect()) {
- HInvokeStaticOrDirect* invoke_static_or_direct = invoke_->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* invoke_static_or_direct = invoke_->AsInvokeStaticOrDirectOrNull();
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()) {
- codegen->GenerateVirtualCall(invoke_->AsInvokeVirtual(), method_loc, this);
+ // TODO: Remove "OrNull".
+ codegen->GenerateVirtualCall(invoke_->AsInvokeVirtualOrNull(), method_loc, this);
} else {
DCHECK(invoke_->IsInvokePolymorphic());
- codegen->GenerateInvokePolymorphicCall(invoke_->AsInvokePolymorphic(), this);
+ // TODO: Remove "OrNull".
+ codegen->GenerateInvokePolymorphicCall(invoke_->AsInvokePolymorphicOrNull(), this);
}
// Copy the result back to the expected output.
@@ -113,7 +116,8 @@ 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;
- const char* shorty = dex_file->GetShorty(invoke->AsInvokePolymorphic()->GetProtoIndex());
+ // TODO: Remove "OrNull".
+ const char* shorty = dex_file->GetShorty(invoke->AsInvokePolymorphicOrNull()->GetProtoIndex());
DCHECK_LT(index, strlen(shorty));
return DataType::FromShorty(shorty[index]);
@@ -206,10 +210,12 @@ static inline ArtField* GetBootImageVarHandleField(HInvoke* invoke)
var_handle_instruction = var_handle_instruction->InputAt(0);
}
DCHECK(var_handle_instruction->IsStaticFieldGet());
- ArtField* field = var_handle_instruction->AsStaticFieldGet()->GetFieldInfo().GetField();
+ // TODO: Remove "OrNull".
+ ArtField* field = var_handle_instruction->AsStaticFieldGetOrNull()->GetFieldInfo().GetField();
DCHECK(field->IsStatic());
DCHECK(field->IsFinal());
- DCHECK(var_handle_instruction->InputAt(0)->AsLoadClass()->IsInBootImage());
+ // TODO: Remove "OrNull".
+ DCHECK(var_handle_instruction->InputAt(0)->AsLoadClassOrNull()->IsInBootImage());
ObjPtr<mirror::Object> 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 75ec85985a..8baa2a24e4 100644
--- a/compiler/optimizing/intrinsics_x86.cc
+++ b/compiler/optimizing/intrinsics_x86.cc
@@ -87,7 +87,8 @@ class ReadBarrierSystemArrayCopySlowPathX86 : public SlowPathCode {
<< "Unexpected instruction in read barrier arraycopy slow path: "
<< instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
int32_t element_size = DataType::Size(DataType::Type::kReference);
uint32_t offset = mirror::Array::DataOffset(element_size).Uint32Value();
@@ -119,7 +120,8 @@ class ReadBarrierSystemArrayCopySlowPathX86 : public SlowPathCode {
__ Bind(&loop);
// value = src_array[i + src_pos]
if (src_pos.IsConstant()) {
- int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
int32_t adjusted_offset = offset + constant * element_size;
__ movl(temp2, Address(src, temp1, ScaleFactor::TIMES_4, adjusted_offset));
} else {
@@ -142,7 +144,8 @@ class ReadBarrierSystemArrayCopySlowPathX86 : public SlowPathCode {
__ MaybePoisonHeapReference(temp2);
// dest_array[i + dest_pos] = value
if (dest_pos.IsConstant()) {
- int32_t constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
int32_t adjusted_offset = offset + constant * element_size;
__ movl(Address(dest, temp1, ScaleFactor::TIMES_4, adjusted_offset), temp2);
} else {
@@ -393,7 +396,8 @@ void IntrinsicLocationsBuilderX86::VisitMathRoundFloat(HInvoke* invoke) {
return;
}
- HInvokeStaticOrDirect* static_or_direct = invoke->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* static_or_direct = invoke->AsInvokeStaticOrDirectOrNull();
DCHECK(static_or_direct != nullptr);
LocationSummary* locations =
new (allocator_) LocationSummary(invoke, LocationSummary::kNoCall, kIntrinsified);
@@ -429,8 +433,9 @@ 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)->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(1)->AsX86ComputeBaseMethodAddressOrNull();
Register constant_area = locations->InAt(1).AsRegister<Register>();
__ comiss(t2, codegen_->LiteralInt32Address(bit_cast<int32_t, float>(0.5f),
method_address,
@@ -523,7 +528,8 @@ static void GenLowestOneBit(X86Assembler* assembler,
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
if (value == 0) {
if (is_long) {
__ xorl(out_loc.AsRegisterPairLow<Register>(), out_loc.AsRegisterPairLow<Register>());
@@ -774,9 +780,9 @@ void IntrinsicCodeGeneratorX86::VisitMathNextAfter(HInvoke* invoke) {
static void CreateSystemArrayCopyLocations(HInvoke* invoke) {
// We need at least two of the positions or length to be an integer constant,
// or else we won't have enough free registers.
- HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant();
- HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstant();
- HIntConstant* length = invoke->InputAt(4)->AsIntConstant();
+ HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstantOrNull();
+ HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstantOrNull();
+ HIntConstant* length = invoke->InputAt(4)->AsIntConstantOrNull();
int num_constants =
((src_pos != nullptr) ? 1 : 0)
@@ -833,13 +839,15 @@ static void CheckPosition(X86Assembler* assembler,
const uint32_t length_offset = mirror::Array::LengthOffset().Uint32Value();
if (pos.IsConstant()) {
- int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (pos_const == 0) {
if (!length_is_input_length) {
// Check that length(input) >= length.
if (length.IsConstant()) {
__ cmpl(Address(input, length_offset),
- Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ cmpl(Address(input, length_offset), length.AsRegister<Register>());
}
@@ -853,7 +861,8 @@ static void CheckPosition(X86Assembler* assembler,
// Check that (length(input) - pos) >= length.
if (length.IsConstant()) {
- __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ cmpl(temp, length.AsRegister<Register>());
}
@@ -878,7 +887,8 @@ static void CheckPosition(X86Assembler* assembler,
__ movl(temp, Address(input, length_offset));
__ subl(temp, pos_reg);
if (length.IsConstant()) {
- __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ cmpl(temp, length.AsRegister<Register>());
}
@@ -929,7 +939,8 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke,
// We need the count in ECX.
if (length.IsConstant()) {
- __ movl(count, Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ __ movl(count, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ movl(count, length.AsRegister<Register>());
}
@@ -947,13 +958,15 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke,
const uint32_t data_offset = mirror::Array::DataOffset(data_size).Uint32Value();
if (src_pos.IsConstant()) {
- int32_t src_pos_const = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t src_pos_const = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(src_base, Address(src, data_size * src_pos_const + data_offset));
} else {
__ leal(src_base, Address(src, src_pos.AsRegister<Register>(), scale_factor, data_offset));
}
if (dest_pos.IsConstant()) {
- int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(dest_base, Address(dest, data_size * dest_pos_const + data_offset));
} else {
__ leal(dest_base, Address(dest, dest_pos.AsRegister<Register>(), scale_factor, data_offset));
@@ -1204,7 +1217,8 @@ static void GenerateStringIndexOf(HInvoke* invoke,
SlowPathCode* slow_path = nullptr;
HInstruction* code_point = invoke->InputAt(1);
if (code_point->IsIntConstant()) {
- if (static_cast<uint32_t>(code_point->AsIntConstant()->GetValue()) >
+ // TODO: Remove "OrNull".
+ if (static_cast<uint32_t>(code_point->AsIntConstantOrNull()->GetValue()) >
std::numeric_limits<uint16_t>::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.
@@ -1444,8 +1458,9 @@ void IntrinsicCodeGeneratorX86::VisitStringGetCharsNoCheck(HInvoke* invoke) {
// public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin);
Register obj = locations->InAt(0).AsRegister<Register>();
Location srcBegin = locations->InAt(1);
+ // TODO: Remove "OrNull".
int srcBegin_value =
- srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstant()->GetValue() : 0;
+ srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstantOrNull()->GetValue() : 0;
Register srcEnd = locations->InAt(2).AsRegister<Register>();
Register dst = locations->InAt(3).AsRegister<Register>();
Register dstBegin = locations->InAt(4).AsRegister<Register>();
@@ -1598,7 +1613,8 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86Assemble
case DataType::Type::kInt8:
if (value_loc.IsConstant()) {
__ movb(Address(address, 0),
- Immediate(value_loc.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(value_loc.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ movb(Address(address, 0), value_loc.AsRegister<ByteRegister>());
}
@@ -1606,7 +1622,8 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86Assemble
case DataType::Type::kInt16:
if (value_loc.IsConstant()) {
__ movw(Address(address, 0),
- Immediate(value_loc.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(value_loc.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ movw(Address(address, 0), value_loc.AsRegister<Register>());
}
@@ -1614,14 +1631,16 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86Assemble
case DataType::Type::kInt32:
if (value_loc.IsConstant()) {
__ movl(Address(address, 0),
- Immediate(value_loc.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(value_loc.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ movl(Address(address, 0), value_loc.AsRegister<Register>());
}
break;
case DataType::Type::kInt64:
if (value_loc.IsConstant()) {
- int64_t value = value_loc.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = value_loc.GetConstant()->AsLongConstantOrNull()->GetValue();
__ movl(Address(address, 0), Immediate(Low32Bits(value)));
__ movl(Address(address, 4), Immediate(High32Bits(value)));
} else {
@@ -2551,7 +2570,8 @@ static void GenBitCount(X86Assembler* assembler,
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
int32_t result = is_long
? POPCOUNT(static_cast<uint64_t>(value))
: POPCOUNT(static_cast<uint32_t>(value));
@@ -2618,7 +2638,8 @@ static void GenLeadingZeros(X86Assembler* assembler,
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
if (value == 0) {
value = is_long ? 64 : 32;
} else {
@@ -2722,7 +2743,8 @@ static void GenTrailingZeros(X86Assembler* assembler,
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
if (value == 0) {
value = is_long ? 64 : 32;
} else {
@@ -2812,7 +2834,8 @@ static void GenSystemArrayCopyBaseAddress(X86Assembler* assembler,
const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value();
if (pos.IsConstant()) {
- int32_t constant = pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(base, Address(array, element_size * constant + data_offset));
} else {
__ leal(base, Address(array, pos.AsRegister<Register>(), scale_factor, data_offset));
@@ -2833,7 +2856,8 @@ static void GenSystemArrayCopyEndAddress(X86Assembler* assembler,
const ScaleFactor scale_factor = static_cast<ScaleFactor>(DataType::SizeShift(type));
if (copy_length.IsConstant()) {
- int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(end, Address(base, element_size * constant));
} else {
__ leal(end, Address(base, copy_length.AsRegister<Register>(), scale_factor, 0));
@@ -2907,9 +2931,11 @@ 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()) {
- int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (dest_pos.IsConstant()) {
- int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (optimizations.GetDestinationIsSource()) {
// Checked when building locations.
DCHECK_GE(src_pos_constant, dest_pos_constant);
@@ -2931,7 +2957,8 @@ void IntrinsicCodeGeneratorX86::VisitSystemArrayCopy(HInvoke* invoke) {
__ j(kNotEqual, &conditions_on_positions_validated);
}
if (dest_pos.IsConstant()) {
- int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ cmpl(src_pos.AsRegister<Register>(), Immediate(dest_pos_constant));
__ j(kLess, intrinsic_slow_path->GetEntryLabel());
} else {
@@ -3267,7 +3294,8 @@ void IntrinsicCodeGeneratorX86::VisitSystemArrayCopy(HInvoke* invoke) {
static void RequestBaseMethodAddressInRegister(HInvoke* invoke) {
LocationSummary* locations = invoke->GetLocations();
if (locations != nullptr) {
- HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirectOrNull();
// 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()) {
@@ -3300,17 +3328,20 @@ void IntrinsicCodeGeneratorX86::VisitIntegerValueOf(HInvoke* invoke) {
Register out = locations->Out().AsRegister<Register>();
auto allocate_instance = [&]() {
DCHECK_EQ(out, InvokeRuntimeCallingConvention().GetRegisterAt(0));
- codegen_->LoadIntrinsicDeclaringClass(out, invoke->AsInvokeStaticOrDirect());
+ // TODO: Remove "OrNull".
+ codegen_->LoadIntrinsicDeclaringClass(out, invoke->AsInvokeStaticOrDirectOrNull());
codegen_->InvokeRuntime(kQuickAllocObjectInitialized, invoke, invoke->GetDexPc());
CheckEntrypointTypes<kQuickAllocObjectWithChecks, void*, mirror::Class*>();
};
if (invoke->InputAt(0)->IsConstant()) {
- int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
if (static_cast<uint32_t>(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(
- out, info.value_boot_image_reference, invoke->AsInvokeStaticOrDirect());
+ // TODO: Remove "OrNull".
+ out, info.value_boot_image_reference, invoke->AsInvokeStaticOrDirectOrNull());
} else {
DCHECK(locations->CanCall());
// Allocate and initialize a new j.l.Integer.
@@ -3333,9 +3364,11 @@ void IntrinsicCodeGeneratorX86::VisitIntegerValueOf(HInvoke* invoke) {
"Check heap reference size.");
if (codegen_->GetCompilerOptions().IsBootImage()) {
DCHECK_EQ(invoke->InputCount(), invoke->GetNumberOfArguments() + 1u);
- size_t method_address_index = invoke->AsInvokeStaticOrDirect()->GetSpecialInputIndex();
+ // TODO: Remove "OrNull".
+ size_t method_address_index = invoke->AsInvokeStaticOrDirectOrNull()->GetSpecialInputIndex();
+ // TODO: Remove "OrNull".
HX86ComputeBaseMethodAddress* method_address =
- invoke->InputAt(method_address_index)->AsX86ComputeBaseMethodAddress();
+ invoke->InputAt(method_address_index)->AsX86ComputeBaseMethodAddressOrNull();
DCHECK(method_address != nullptr);
Register method_address_reg =
invoke->GetLocations()->InAt(method_address_index).AsRegister<Register>();
@@ -3347,8 +3380,9 @@ 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->AsInvokeStaticOrDirect());
+ out, mid_array_boot_image_offset, invoke->AsInvokeStaticOrDirectOrNull());
DCHECK_NE(out, in);
__ movl(out, Address(out, in, TIMES_4, 0));
}
@@ -3387,7 +3421,8 @@ void IntrinsicCodeGeneratorX86::VisitReferenceGetReferent(HInvoke* invoke) {
// Load the java.lang.ref.Reference class, use the output register as a temporary.
codegen_->LoadIntrinsicDeclaringClass(out.AsRegister<Register>(),
- invoke->AsInvokeStaticOrDirect());
+ // TODO: Remove "OrNull".
+ invoke->AsInvokeStaticOrDirectOrNull());
// 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 5406450dec..3a441f3c3b 100644
--- a/compiler/optimizing/intrinsics_x86_64.cc
+++ b/compiler/optimizing/intrinsics_x86_64.cc
@@ -83,7 +83,8 @@ class ReadBarrierSystemArrayCopySlowPathX86_64 : public SlowPathCode {
<< "Unexpected instruction in read barrier arraycopy slow path: "
<< instruction_->DebugName();
DCHECK(instruction_->GetLocations()->Intrinsified());
- DCHECK_EQ(instruction_->AsInvoke()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(instruction_->AsInvokeOrNull()->GetIntrinsic(), Intrinsics::kSystemArrayCopy);
int32_t element_size = DataType::Size(DataType::Type::kReference);
@@ -617,8 +618,8 @@ void IntrinsicCodeGeneratorX86_64::VisitMathNextAfter(HInvoke* invoke) {
static void CreateSystemArrayCopyLocations(HInvoke* invoke) {
// Check to see if we have known failures that will cause us to have to bail out
// to the runtime, and just generate the runtime call directly.
- HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstant();
- HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstant();
+ HIntConstant* src_pos = invoke->InputAt(1)->AsIntConstantOrNull();
+ HIntConstant* dest_pos = invoke->InputAt(3)->AsIntConstantOrNull();
// The positions must be non-negative.
if ((src_pos != nullptr && src_pos->GetValue() < 0) ||
@@ -628,7 +629,7 @@ static void CreateSystemArrayCopyLocations(HInvoke* invoke) {
}
// The length must be > 0.
- HIntConstant* length = invoke->InputAt(4)->AsIntConstant();
+ HIntConstant* length = invoke->InputAt(4)->AsIntConstantOrNull();
if (length != nullptr) {
int32_t len = length->GetValue();
if (len < 0) {
@@ -663,13 +664,15 @@ static void CheckPosition(X86_64Assembler* assembler,
const uint32_t length_offset = mirror::Array::LengthOffset().Uint32Value();
if (pos.IsConstant()) {
- int32_t pos_const = pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t pos_const = pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (pos_const == 0) {
if (!length_is_input_length) {
// Check that length(input) >= length.
if (length.IsConstant()) {
__ cmpl(Address(input, length_offset),
- Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ cmpl(Address(input, length_offset), length.AsRegister<CpuRegister>());
}
@@ -683,7 +686,8 @@ static void CheckPosition(X86_64Assembler* assembler,
// Check that (length(input) - pos) >= length.
if (length.IsConstant()) {
- __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ cmpl(temp, length.AsRegister<CpuRegister>());
}
@@ -708,7 +712,8 @@ static void CheckPosition(X86_64Assembler* assembler,
__ movl(temp, Address(input, length_offset));
__ subl(temp, pos_reg);
if (length.IsConstant()) {
- __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ __ cmpl(temp, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ cmpl(temp, length.AsRegister<CpuRegister>());
}
@@ -765,7 +770,8 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke,
// We need the count in RCX.
if (length.IsConstant()) {
- __ movl(count, Immediate(length.GetConstant()->AsIntConstant()->GetValue()));
+ // TODO: Remove "OrNull".
+ __ movl(count, Immediate(length.GetConstant()->AsIntConstantOrNull()->GetValue()));
} else {
__ movl(count, length.AsRegister<CpuRegister>());
}
@@ -777,13 +783,15 @@ static void SystemArrayCopyPrimitive(HInvoke* invoke,
const uint32_t data_offset = mirror::Array::DataOffset(data_size).Uint32Value();
if (src_pos.IsConstant()) {
- int32_t src_pos_const = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t src_pos_const = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(src_base, Address(src, data_size * src_pos_const + data_offset));
} else {
__ leal(src_base, Address(src, src_pos.AsRegister<CpuRegister>(), scale_factor, data_offset));
}
if (dest_pos.IsConstant()) {
- int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_const = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(dest_base, Address(dest, data_size * dest_pos_const + data_offset));
} else {
__ leal(dest_base,
@@ -863,21 +871,24 @@ static void GenSystemArrayCopyAddresses(X86_64Assembler* assembler,
const uint32_t data_offset = mirror::Array::DataOffset(element_size).Uint32Value();
if (src_pos.IsConstant()) {
- int32_t constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(src_base, Address(src, element_size * constant + data_offset));
} else {
__ leal(src_base, Address(src, src_pos.AsRegister<CpuRegister>(), scale_factor, data_offset));
}
if (dst_pos.IsConstant()) {
- int32_t constant = dst_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = dst_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(dst_base, Address(dst, element_size * constant + data_offset));
} else {
__ leal(dst_base, Address(dst, dst_pos.AsRegister<CpuRegister>(), scale_factor, data_offset));
}
if (copy_length.IsConstant()) {
- int32_t constant = copy_length.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t constant = copy_length.GetConstant()->AsIntConstantOrNull()->GetValue();
__ leal(src_end, Address(src_base, element_size * constant));
} else {
__ leal(src_end, Address(src_base, copy_length.AsRegister<CpuRegister>(), scale_factor, 0));
@@ -921,9 +932,11 @@ 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()) {
- int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t src_pos_constant = src_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (dest_pos.IsConstant()) {
- int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
if (optimizations.GetDestinationIsSource()) {
// Checked when building locations.
DCHECK_GE(src_pos_constant, dest_pos_constant);
@@ -945,7 +958,8 @@ void IntrinsicCodeGeneratorX86_64::VisitSystemArrayCopy(HInvoke* invoke) {
__ j(kNotEqual, &conditions_on_positions_validated);
}
if (dest_pos.IsConstant()) {
- int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t dest_pos_constant = dest_pos.GetConstant()->AsIntConstantOrNull()->GetValue();
__ cmpl(src_pos.AsRegister<CpuRegister>(), Immediate(dest_pos_constant));
__ j(kLess, intrinsic_slow_path->GetEntryLabel());
} else {
@@ -1423,7 +1437,8 @@ static void GenerateStringIndexOf(HInvoke* invoke,
SlowPathCode* slow_path = nullptr;
HInstruction* code_point = invoke->InputAt(1);
if (code_point->IsIntConstant()) {
- if (static_cast<uint32_t>(code_point->AsIntConstant()->GetValue()) >
+ // TODO: Remove "OrNull".
+ if (static_cast<uint32_t>(code_point->AsIntConstantOrNull()->GetValue()) >
std::numeric_limits<uint16_t>::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.
@@ -1654,8 +1669,9 @@ void IntrinsicCodeGeneratorX86_64::VisitStringGetCharsNoCheck(HInvoke* invoke) {
// public void getChars(int srcBegin, int srcEnd, char[] dst, int dstBegin);
CpuRegister obj = locations->InAt(0).AsRegister<CpuRegister>();
Location srcBegin = locations->InAt(1);
+ // TODO: Remove "OrNull".
int srcBegin_value =
- srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstant()->GetValue() : 0;
+ srcBegin.IsConstant() ? srcBegin.GetConstant()->AsIntConstantOrNull()->GetValue() : 0;
CpuRegister srcEnd = locations->InAt(2).AsRegister<CpuRegister>();
CpuRegister dst = locations->InAt(3).AsRegister<CpuRegister>();
CpuRegister dstBegin = locations->InAt(4).AsRegister<CpuRegister>();
@@ -1811,7 +1827,8 @@ static void GenPoke(LocationSummary* locations, DataType::Type size, X86_64Assem
break;
case DataType::Type::kInt64:
if (value.IsConstant()) {
- int64_t v = value.GetConstant()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t v = value.GetConstant()->AsLongConstantOrNull()->GetValue();
DCHECK(IsInt<32>(v));
int32_t v_32 = v;
__ movq(Address(address, 0), Immediate(v_32));
@@ -2738,7 +2755,8 @@ static void GenBitCount(X86_64Assembler* assembler,
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
int32_t result = is_long
? POPCOUNT(static_cast<uint64_t>(value))
: POPCOUNT(static_cast<uint32_t>(value));
@@ -2796,7 +2814,8 @@ static void GenOneBit(X86_64Assembler* assembler,
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
if (value == 0) {
__ xorl(out, out); // Clears upper bits too.
return;
@@ -2929,7 +2948,8 @@ static void GenLeadingZeros(X86_64Assembler* assembler,
int zero_value_result = is_long ? 64 : 32;
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
if (value == 0) {
value = zero_value_result;
} else {
@@ -3002,7 +3022,8 @@ static void GenTrailingZeros(X86_64Assembler* assembler,
int zero_value_result = is_long ? 64 : 32;
if (invoke->InputAt(0)->IsConstant()) {
// Evaluate this at compile time.
- int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t value = Int64FromConstant(invoke->InputAt(0)->AsConstantOrNull());
if (value == 0) {
value = zero_value_result;
} else {
@@ -3077,7 +3098,8 @@ void IntrinsicCodeGeneratorX86_64::VisitIntegerValueOf(HInvoke* invoke) {
CheckEntrypointTypes<kQuickAllocObjectWithChecks, void*, mirror::Class*>();
};
if (invoke->InputAt(0)->IsIntConstant()) {
- int32_t value = invoke->InputAt(0)->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = invoke->InputAt(0)->AsIntConstantOrNull()->GetValue();
if (static_cast<uint32_t>(value - info.low) < info.length) {
// Just embed the j.l.Integer in the code.
DCHECK_NE(info.value_boot_image_reference, IntegerValueOfInfo::kInvalidReference);
@@ -3383,7 +3405,8 @@ class VarHandleSlowPathX86_64 : public IntrinsicSlowPathX86_64 {
private:
HInvoke* GetInvoke() const {
- return GetInstruction()->AsInvoke();
+ // TODO: Remove "OrNull".
+ return GetInstruction()->AsInvokeOrNull();
}
mirror::VarHandle::AccessModeTemplate GetAccessModeTemplate() const {
diff --git a/compiler/optimizing/live_ranges_test.cc b/compiler/optimizing/live_ranges_test.cc
index fb1a23eef4..4e1a49b41b 100644
--- a/compiler/optimizing/live_ranges_test.cc
+++ b/compiler/optimizing/live_ranges_test.cc
@@ -311,7 +311,8 @@ TEST_F(LiveRangesTest, Loop2) {
liveness.Analyze();
// Test for the 0 constant.
- HIntConstant* constant = liveness.GetInstructionFromSsaIndex(0)->AsIntConstant();
+ // TODO: Remove "OrNull".
+ HIntConstant* constant = liveness.GetInstructionFromSsaIndex(0)->AsIntConstantOrNull();
LiveInterval* interval = constant->GetLiveInterval();
LiveRange* range = interval->GetFirstRange();
ASSERT_EQ(2u, range->GetStart());
@@ -321,7 +322,8 @@ TEST_F(LiveRangesTest, Loop2) {
ASSERT_TRUE(range->GetNext() == nullptr);
// Test for the loop phi.
- HPhi* phi = liveness.GetInstructionFromSsaIndex(1)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = liveness.GetInstructionFromSsaIndex(1)->AsPhiOrNull();
interval = phi->GetLiveInterval();
range = interval->GetFirstRange();
ASSERT_EQ(10u, range->GetStart());
@@ -332,7 +334,8 @@ TEST_F(LiveRangesTest, Loop2) {
ASSERT_EQ(24u, range->GetEnd());
// Test for the add instruction.
- HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAdd();
+ // TODO: Remove "OrNull".
+ HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAddOrNull();
interval = add->GetLiveInterval();
range = interval->GetFirstRange();
ASSERT_EQ(18u, range->GetStart());
@@ -406,7 +409,8 @@ TEST_F(LiveRangesTest, CFG4) {
ASSERT_TRUE(range->GetNext() == nullptr);
// Test for the first add.
- HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAdd();
+ // TODO: Remove "OrNull".
+ HAdd* add = liveness.GetInstructionFromSsaIndex(2)->AsAddOrNull();
interval = add->GetLiveInterval();
range = interval->GetFirstRange();
ASSERT_EQ(16u, range->GetStart());
@@ -414,14 +418,16 @@ TEST_F(LiveRangesTest, CFG4) {
ASSERT_TRUE(range->GetNext() == nullptr);
// Test for the second add.
- add = liveness.GetInstructionFromSsaIndex(3)->AsAdd();
+ // TODO: Remove "OrNull".
+ add = liveness.GetInstructionFromSsaIndex(3)->AsAddOrNull();
interval = add->GetLiveInterval();
range = interval->GetFirstRange();
ASSERT_EQ(22u, range->GetStart());
ASSERT_EQ(26u, range->GetEnd());
ASSERT_TRUE(range->GetNext() == nullptr);
- HPhi* phi = liveness.GetInstructionFromSsaIndex(4)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = liveness.GetInstructionFromSsaIndex(4)->AsPhiOrNull();
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 b46e3e18d9..9a63da4c05 100644
--- a/compiler/optimizing/load_store_analysis.cc
+++ b/compiler/optimizing/load_store_analysis.cc
@@ -51,9 +51,10 @@ 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()->AsIntConstant()->GetValue()
- : -idx1->GetConstantRight()->AsIntConstant()->GetValue();
+ ? idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue()
+ : -idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue();
int64_t l2 = 0;
int64_t h1 = l1 + (vector_length1 - 1);
int64_t h2 = l2 + (vector_length2 - 1);
@@ -79,12 +80,14 @@ 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()->AsIntConstant()->GetValue()
- : -idx1->GetConstantRight()->AsIntConstant()->GetValue();
+ ? idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue()
+ : -idx1->GetConstantRight()->AsIntConstantOrNull()->GetValue();
+ // TODO: Remove "OrNull".
int64_t l2 = idx2->IsAdd()
- ? idx2->GetConstantRight()->AsIntConstant()->GetValue()
- : -idx2->GetConstantRight()->AsIntConstant()->GetValue();
+ ? idx2->GetConstantRight()->AsIntConstantOrNull()->GetValue()
+ : -idx2->GetConstantRight()->AsIntConstantOrNull()->GetValue();
int64_t h1 = l1 + (vector_length1 - 1);
int64_t h2 = l2 + (vector_length2 - 1);
return CanIntegerRangesOverlap(l1, h1, l2, h2);
@@ -129,11 +132,14 @@ void ReferenceInfo::PrunePartialEscapeWrites() {
bool HeapLocationCollector::InstructionEligibleForLSERemoval(HInstruction* inst) const {
if (inst->IsNewInstance()) {
- return !inst->AsNewInstance()->NeedsChecks();
+ // TODO: Remove "OrNull".
+ return !inst->AsNewInstanceOrNull()->NeedsChecks();
} else if (inst->IsNewArray()) {
- HInstruction* array_length = inst->AsNewArray()->GetLength();
+ // TODO: Remove "OrNull".
+ HInstruction* array_length = inst->AsNewArrayOrNull()->GetLength();
+ // TODO: Remove "OrNull".
bool known_array_length =
- array_length->IsIntConstant() && array_length->AsIntConstant()->GetValue() >= 0;
+ array_length->IsIntConstant() && array_length->AsIntConstantOrNull()->GetValue() >= 0;
return known_array_length &&
std::all_of(inst->GetUses().cbegin(),
inst->GetUses().cend(),
@@ -223,8 +229,10 @@ bool HeapLocationCollector::CanArrayElementsAlias(const HInstruction* idx1,
// [CONST1] and [CONST2].
if (idx1->IsIntConstant() && idx2->IsIntConstant()) {
- int64_t l1 = idx1->AsIntConstant()->GetValue();
- int64_t l2 = idx2->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t l1 = idx1->AsIntConstantOrNull()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t l2 = idx2->AsIntConstantOrNull()->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);
@@ -233,33 +241,39 @@ bool HeapLocationCollector::CanArrayElementsAlias(const HInstruction* idx1,
}
// [i+CONST] and [i].
+ // TODO: Remove "OrNull".
if (idx1->IsBinaryOperation() &&
- idx1->AsBinaryOperation()->GetConstantRight() != nullptr &&
- idx1->AsBinaryOperation()->GetLeastConstantLeft() == idx2) {
- return CanBinaryOpAndIndexAlias(idx1->AsBinaryOperation(),
+ idx1->AsBinaryOperationOrNull()->GetConstantRight() != nullptr &&
+ idx1->AsBinaryOperationOrNull()->GetLeastConstantLeft() == idx2) {
+ // TODO: Remove "OrNull".
+ return CanBinaryOpAndIndexAlias(idx1->AsBinaryOperationOrNull(),
vector_length1,
idx2,
vector_length2);
}
// [i] and [i+CONST].
+ // TODO: Remove "OrNull".
if (idx2->IsBinaryOperation() &&
- idx2->AsBinaryOperation()->GetConstantRight() != nullptr &&
- idx2->AsBinaryOperation()->GetLeastConstantLeft() == idx1) {
- return CanBinaryOpAndIndexAlias(idx2->AsBinaryOperation(),
+ idx2->AsBinaryOperationOrNull()->GetConstantRight() != nullptr &&
+ idx2->AsBinaryOperationOrNull()->GetLeastConstantLeft() == idx1) {
+ // TODO: Remove "OrNull".
+ return CanBinaryOpAndIndexAlias(idx2->AsBinaryOperationOrNull(),
vector_length2,
idx1,
vector_length1);
}
// [i+CONST1] and [i+CONST2].
+ // TODO: Remove "OrNull".
if (idx1->IsBinaryOperation() &&
- idx1->AsBinaryOperation()->GetConstantRight() != nullptr &&
+ idx1->AsBinaryOperationOrNull()->GetConstantRight() != nullptr &&
idx2->IsBinaryOperation() &&
- idx2->AsBinaryOperation()->GetConstantRight() != nullptr) {
- return CanBinaryOpsAlias(idx1->AsBinaryOperation(),
+ idx2->AsBinaryOperationOrNull()->GetConstantRight() != nullptr) {
+ // TODO: Remove "OrNull".
+ return CanBinaryOpsAlias(idx1->AsBinaryOperationOrNull(),
vector_length1,
- idx2->AsBinaryOperation(),
+ idx2->AsBinaryOperationOrNull(),
vector_length2);
}
diff --git a/compiler/optimizing/load_store_analysis.h b/compiler/optimizing/load_store_analysis.h
index c46a5b9cc1..97a7cf6e78 100644
--- a/compiler/optimizing/load_store_analysis.h
+++ b/compiler/optimizing/load_store_analysis.h
@@ -334,9 +334,11 @@ class HeapLocationCollector : public HGraphVisitor {
size_t vector_length = HeapLocation::kScalar;
const bool is_vec_op = instruction->IsVecStore() || instruction->IsVecLoad();
if (instruction->IsArraySet()) {
- type = instruction->AsArraySet()->GetComponentType();
+ // TODO: Remove "OrNull".
+ type = instruction->AsArraySetOrNull()->GetComponentType();
} else if (is_vec_op) {
- HVecOperation* vec_op = instruction->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* vec_op = instruction->AsVecOperationOrNull();
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 9cabb12a9f..b44db65dc2 100644
--- a/compiler/optimizing/load_store_elimination.cc
+++ b/compiler/optimizing/load_store_elimination.cc
@@ -736,7 +736,8 @@ class LSEVisitor final : private HGraphDelegateVisitor {
use.GetUser()->MoveBefore(instruction);
}
DCHECK(use.GetUser()->StrictlyDominates(instruction));
- return use.GetUser()->AsTypeConversion();
+ // TODO: Remove "OrNull".
+ return use.GetUser()->AsTypeConversionOrNull();
}
}
@@ -975,9 +976,13 @@ class LSEVisitor final : private HGraphDelegateVisitor {
}
void HandleAcquireLoad(HInstruction* instruction) {
- DCHECK((instruction->IsInstanceFieldGet() && instruction->AsInstanceFieldGet()->IsVolatile()) ||
- (instruction->IsStaticFieldGet() && instruction->AsStaticFieldGet()->IsVolatile()) ||
- (instruction->IsMonitorOperation() && instruction->AsMonitorOperation()->IsEnter()))
+ // TODO: Remove "OrNull".
+ DCHECK((instruction->IsInstanceFieldGet() &&
+ instruction->AsInstanceFieldGetOrNull()->IsVolatile()) ||
+ (instruction->IsStaticFieldGet() &&
+ instruction->AsStaticFieldGetOrNull()->IsVolatile()) ||
+ (instruction->IsMonitorOperation() &&
+ instruction->AsMonitorOperationOrNull()->IsEnter()))
<< "Unexpected instruction " << instruction->GetId() << ": " << instruction->DebugName();
// Acquire operations e.g. MONITOR_ENTER change the thread's view of the memory, so we must
@@ -995,9 +1000,13 @@ class LSEVisitor final : private HGraphDelegateVisitor {
}
void HandleReleaseStore(HInstruction* instruction) {
- DCHECK((instruction->IsInstanceFieldSet() && instruction->AsInstanceFieldSet()->IsVolatile()) ||
- (instruction->IsStaticFieldSet() && instruction->AsStaticFieldSet()->IsVolatile()) ||
- (instruction->IsMonitorOperation() && !instruction->AsMonitorOperation()->IsEnter()))
+ // TODO: Remove "OrNull".
+ DCHECK((instruction->IsInstanceFieldSet() &&
+ instruction->AsInstanceFieldSetOrNull()->IsVolatile()) ||
+ (instruction->IsStaticFieldSet() &&
+ instruction->AsStaticFieldSetOrNull()->IsVolatile()) ||
+ (instruction->IsMonitorOperation() &&
+ !instruction->AsMonitorOperationOrNull()->IsEnter()))
<< "Unexpected instruction " << instruction->GetId() << ": " << instruction->DebugName();
// Release operations e.g. MONITOR_EXIT do not affect this thread's view of the memory, but
@@ -1105,8 +1114,9 @@ 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->AsNewInstance()->IsFinalizable();
+ reference->IsNewInstance() && reference->AsNewInstanceOrNull()->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.
@@ -1331,7 +1341,8 @@ class LSEVisitor final : private HGraphDelegateVisitor {
}
if (ref_info->IsSingletonAndRemovable()) {
if (new_array->GetLength()->IsIntConstant() &&
- new_array->GetLength()->AsIntConstant()->GetValue() >= 0) {
+ // TODO: Remove "OrNull".
+ new_array->GetLength()->AsIntConstantOrNull()->GetValue() >= 0) {
// new_array can potentially be eliminated.
singleton_new_instances_.push_back(new_array);
} else {
@@ -1665,8 +1676,9 @@ 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->AsNewInstance()->IsFinalizable();
+ reference->IsNewInstance() && reference->AsNewInstanceOrNull()->IsFinalizable();
if (ref_info->IsSingleton() &&
block->GetLoopInformation()->Contains(*reference->GetBlock()) &&
!is_finalizable) {
@@ -2399,7 +2411,9 @@ bool LSEVisitor::MaterializeLoopPhis(ArrayRef<const size_t> 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()];
- block->AddPhi(phi_placeholder_replacements_[phi_placeholder_index].GetInstruction()->AsPhi());
+ // TODO: Remove "OrNull".
+ block->AddPhi(
+ phi_placeholder_replacements_[phi_placeholder_index].GetInstruction()->AsPhiOrNull());
}
if (type == DataType::Type::kReference) {
ScopedArenaAllocator local_allocator(allocator_.GetArenaStack());
@@ -3379,7 +3393,8 @@ class PartialLoadStoreEliminationHelper {
} else if (ins->IsInstanceFieldGet()) {
// IFieldGet[obj] => PredicatedIFieldGet[PartialValue, obj]
HInstruction* new_fget = new (GetGraph()->GetAllocator()) HPredicatedInstanceFieldGet(
- ins->AsInstanceFieldGet(),
+ // TODO: Remove "OrNull".
+ ins->AsInstanceFieldGetOrNull(),
GetMaterialization(ins->GetBlock()),
helper_->lse_->GetPartialValueAt(OriginalNewInstance(), ins));
MaybeRecordStat(helper_->lse_->stats_, MethodCompilationStat::kPredicatedLoadAdded);
@@ -3405,7 +3420,8 @@ class PartialLoadStoreEliminationHelper {
ins->GetBlock()->RemoveInstruction(ins);
} else if (ins->IsInstanceFieldSet()) {
// Any predicated sets shouldn't require movement.
- ins->AsInstanceFieldSet()->SetIsPredicatedSet();
+ // TODO: Remove "OrNull".
+ ins->AsInstanceFieldSetOrNull()->SetIsPredicatedSet();
MaybeRecordStat(helper_->lse_->stats_, MethodCompilationStat::kPredicatedStoreAdded);
HInstruction* merged_inst = GetMaterialization(ins->GetBlock());
ins->ReplaceInput(merged_inst, idx);
@@ -3474,7 +3490,8 @@ class PartialLoadStoreEliminationHelper {
}
} else if (use.GetUser()->IsConstructorFence()) {
LSE_VLOG << "User " << *use.GetUser() << " being moved to materialization!";
- constructor_fences.push_back({use.GetUser()->AsConstructorFence(), use.GetIndex()});
+ // TODO: Remove "OrNull".
+ constructor_fences.push_back({use.GetUser()->AsConstructorFenceOrNull(), use.GetIndex()});
} else {
LSE_VLOG << "User " << *use.GetUser() << " not contained in cohort!";
to_remove.push_back(use.GetUser());
@@ -3645,7 +3662,8 @@ class PartialLoadStoreEliminationHelper {
for (HInstruction* ins :
MakeSTLInstructionIteratorRange(HInstructionIterator(blk->GetInstructions()))) {
if (ins->IsNewInstance()) {
- materializations.push_back(ins->AsNewInstance());
+ // TODO: Remove "OrNull".
+ materializations.push_back(ins->AsNewInstanceOrNull());
still_unsorted.SetBit(ins->GetId());
}
}
@@ -3699,7 +3717,8 @@ class PartialLoadStoreEliminationHelper {
if (ri->IsPartialSingleton() &&
ri->GetReference()->GetBlock() != nullptr &&
ri->GetNoEscapeSubgraph()->ContainsBlock(ri->GetReference()->GetBlock())) {
- RecordHeapRefField(ri->GetReference()->AsNewInstance(), i);
+ // TODO: Remove "OrNull".
+ RecordHeapRefField(ri->GetReference()->AsNewInstanceOrNull(), i);
}
}
}
@@ -3725,7 +3744,8 @@ class PartialLoadStoreEliminationHelper {
void NotifyNewMaterialization(HInstruction* ins) {
if (ins->IsPhi()) {
- new_ref_phis_.push_back(ins->AsPhi());
+ // TODO: Remove "OrNull".
+ new_ref_phis_.push_back(ins->AsPhiOrNull());
}
}
@@ -3773,7 +3793,8 @@ HInstruction* LSEVisitor::SetupPartialMaterialization(PartialLoadStoreEliminatio
}
HBasicBlock* bb = helper.GetOrCreateMaterializationBlock(entry, pred_idx);
CHECK(bb != nullptr) << "entry " << entry->GetBlockId() << " -> " << old_pred->GetBlockId();
- HNewInstance* repl_create = new_inst->Clone(GetGraph()->GetAllocator())->AsNewInstance();
+ // TODO: Remove "OrNull".
+ HNewInstance* repl_create = new_inst->Clone(GetGraph()->GetAllocator())->AsNewInstanceOrNull();
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 98f1260261..2126f9ec87 100644
--- a/compiler/optimizing/load_store_elimination_test.cc
+++ b/compiler/optimizing/load_store_elimination_test.cc
@@ -392,17 +392,21 @@ class PartialComparisonTestGroup
PartialComparisonKind kind = GetParam();
if (ins->IsIntConstant()) {
if (kind.IsDefinitelyTrue()) {
- EXPECT_TRUE(ins->AsIntConstant()->IsTrue()) << kind << " " << *ins;
+ // TODO: Remove "OrNull".
+ EXPECT_TRUE(ins->AsIntConstantOrNull()->IsTrue()) << kind << " " << *ins;
} else if (kind.IsDefinitelyFalse()) {
- EXPECT_TRUE(ins->AsIntConstant()->IsFalse()) << kind << " " << *ins;
+ // TODO: Remove "OrNull".
+ EXPECT_TRUE(ins->AsIntConstantOrNull()->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) {
- EXPECT_TRUE(ins->AsIntConstant()->IsFalse()) << kind << " " << *ins;
+ // TODO: Remove "OrNull".
+ EXPECT_TRUE(ins->AsIntConstantOrNull()->IsFalse()) << kind << " " << *ins;
} else {
- EXPECT_TRUE(ins->AsIntConstant()->IsTrue()) << kind << " " << *ins;
+ // TODO: Remove "OrNull".
+ EXPECT_TRUE(ins->AsIntConstantOrNull()->IsTrue()) << kind << " " << *ins;
}
}
return;
@@ -413,10 +417,14 @@ class PartialComparisonTestGroup
if (placement == ComparisonPlacement::kInEscape) {
// Should be the same type.
ASSERT_TRUE(ins->IsEqual() || ins->IsNotEqual()) << *ins;
- HInstruction* other = kind.position_ == Position::kLeft ? ins->AsBinaryOperation()->GetRight()
- : ins->AsBinaryOperation()->GetLeft();
+ // TODO: Remove "OrNull".
+ HInstruction* other = kind.position_ == Position::kLeft
+ ? ins->AsBinaryOperationOrNull()->GetRight()
+ : ins->AsBinaryOperationOrNull()->GetLeft();
if (kind.target_ == Target::kSelf) {
- EXPECT_INS_EQ(ins->AsBinaryOperation()->GetLeft(), ins->AsBinaryOperation()->GetRight())
+ // TODO: Remove "OrNull".
+ EXPECT_INS_EQ(ins->AsBinaryOperationOrNull()->GetLeft(),
+ ins->AsBinaryOperationOrNull()->GetRight())
<< " ins is: " << *ins;
} else if (kind.target_ == Target::kNull) {
EXPECT_INS_EQ(other, graph_->GetNullConstant()) << " ins is: " << *ins;
@@ -6786,14 +6794,14 @@ TEST_F(LoadStoreEliminationTest, PartialLoopPhis1) {
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
EXPECT_INS_REMOVED(read_bottom) << *read_bottom;
ASSERT_TRUE(pred_get != nullptr);
- HPhi* inst_return_phi = pred_get->GetTarget()->AsPhi();
+ HPhi* inst_return_phi = pred_get->GetTarget()->AsPhiOrNull();
ASSERT_TRUE(inst_return_phi != nullptr) << pred_get->GetTarget()->DumpWithArgs();
EXPECT_INS_EQ(inst_return_phi->InputAt(0),
FindSingleInstruction<HNewInstance>(graph_, case1->GetSinglePredecessor()));
EXPECT_INS_EQ(inst_return_phi->InputAt(1),
FindSingleInstruction<HNewInstance>(graph_, case2->GetSinglePredecessor()));
EXPECT_INS_EQ(inst_return_phi->InputAt(2), graph_->GetNullConstant());
- HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhi();
+ HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhiOrNull();
ASSERT_TRUE(inst_value_phi != nullptr) << pred_get->GetDefaultValue()->DumpWithArgs();
EXPECT_INS_EQ(inst_value_phi->InputAt(0), graph_->GetIntConstant(0));
EXPECT_INS_EQ(inst_value_phi->InputAt(1), graph_->GetIntConstant(0));
@@ -6966,14 +6974,14 @@ TEST_F(LoadStoreEliminationTest, PartialLoopPhis2) {
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
EXPECT_INS_REMOVED(read_bottom) << *read_bottom;
ASSERT_TRUE(pred_get != nullptr);
- HPhi* inst_return_phi = pred_get->GetTarget()->AsPhi();
+ HPhi* inst_return_phi = pred_get->GetTarget()->AsPhiOrNull();
ASSERT_TRUE(inst_return_phi != nullptr) << pred_get->GetTarget()->DumpWithArgs();
EXPECT_INS_EQ(inst_return_phi->InputAt(0),
FindSingleInstruction<HNewInstance>(graph_, case1->GetSinglePredecessor()));
EXPECT_INS_EQ(inst_return_phi->InputAt(1),
FindSingleInstruction<HNewInstance>(graph_, case2->GetSinglePredecessor()));
EXPECT_INS_EQ(inst_return_phi->InputAt(2), graph_->GetNullConstant());
- HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhi();
+ HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhiOrNull();
ASSERT_TRUE(inst_value_phi != nullptr) << pred_get->GetDefaultValue()->DumpWithArgs();
EXPECT_INS_EQ(inst_value_phi->InputAt(0), graph_->GetIntConstant(0));
EXPECT_INS_EQ(inst_value_phi->InputAt(1), graph_->GetIntConstant(0));
@@ -7113,12 +7121,12 @@ TEST_F(LoadStoreEliminationTest, PartialLoopPhis3) {
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
EXPECT_INS_REMOVED(read_bottom) << *read_bottom;
ASSERT_TRUE(pred_get != nullptr);
- HPhi* inst_return_phi = pred_get->GetTarget()->AsPhi();
+ HPhi* inst_return_phi = pred_get->GetTarget()->AsPhiOrNull();
ASSERT_TRUE(inst_return_phi != nullptr) << pred_get->GetTarget()->DumpWithArgs();
EXPECT_INS_EQ(inst_return_phi->InputAt(0), graph_->GetNullConstant());
EXPECT_INS_EQ(inst_return_phi->InputAt(1),
FindSingleInstruction<HNewInstance>(graph_, escape->GetSinglePredecessor()));
- HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhi();
+ HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhiOrNull();
ASSERT_TRUE(inst_value_phi != nullptr) << pred_get->GetDefaultValue()->DumpWithArgs();
HPhi* loop_header_phi = FindSingleInstruction<HPhi>(graph_, loop_header);
HPhi* loop_merge_phi = FindSingleInstruction<HPhi>(graph_, loop_merge);
@@ -7257,12 +7265,12 @@ TEST_F(LoadStoreEliminationTest, PartialLoopPhis4) {
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
EXPECT_INS_REMOVED(read_bottom) << *read_bottom;
ASSERT_TRUE(pred_get != nullptr);
- HPhi* inst_return_phi = pred_get->GetTarget()->AsPhi();
+ HPhi* inst_return_phi = pred_get->GetTarget()->AsPhiOrNull();
ASSERT_TRUE(inst_return_phi != nullptr) << pred_get->GetTarget()->DumpWithArgs();
EXPECT_INS_EQ(inst_return_phi->InputAt(0), graph_->GetNullConstant());
EXPECT_INS_EQ(inst_return_phi->InputAt(1),
FindSingleInstruction<HNewInstance>(graph_, escape->GetSinglePredecessor()));
- HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhi();
+ HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhiOrNull();
ASSERT_TRUE(inst_value_phi != nullptr) << pred_get->GetDefaultValue()->DumpWithArgs();
HPhi* loop_header_phi = FindSingleInstruction<HPhi>(graph_, loop_header);
HPhi* loop_merge_phi = FindSingleInstruction<HPhi>(graph_, loop_merge);
@@ -7401,12 +7409,12 @@ TEST_F(LoadStoreEliminationTest, PartialLoopPhis5) {
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
EXPECT_INS_REMOVED(read_bottom) << *read_bottom;
ASSERT_TRUE(pred_get != nullptr);
- HPhi* inst_return_phi = pred_get->GetTarget()->AsPhi();
+ HPhi* inst_return_phi = pred_get->GetTarget()->AsPhiOrNull();
ASSERT_TRUE(inst_return_phi != nullptr) << pred_get->GetTarget()->DumpWithArgs();
EXPECT_INS_EQ(inst_return_phi->InputAt(0), graph_->GetNullConstant());
EXPECT_INS_EQ(inst_return_phi->InputAt(1),
FindSingleInstruction<HNewInstance>(graph_, escape->GetSinglePredecessor()));
- HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhi();
+ HPhi* inst_value_phi = pred_get->GetDefaultValue()->AsPhiOrNull();
ASSERT_TRUE(inst_value_phi != nullptr) << pred_get->GetDefaultValue()->DumpWithArgs();
HPhi* loop_header_phi = FindSingleInstruction<HPhi>(graph_, loop_header);
HPhi* loop_merge_phi = FindSingleInstruction<HPhi>(graph_, loop_merge);
@@ -7562,7 +7570,7 @@ TEST_F(LoadStoreEliminationTest, PartialLoopPhis6) {
FindSingleInstruction<HPredicatedInstanceFieldGet>(graph_, breturn);
EXPECT_INS_REMOVED(read_bottom) << *read_bottom;
ASSERT_TRUE(pred_get != nullptr);
- HPhi* inst_return_phi = pred_get->GetTarget()->AsPhi();
+ HPhi* inst_return_phi = pred_get->GetTarget()->AsPhiOrNull();
ASSERT_TRUE(inst_return_phi != nullptr) << pred_get->GetTarget()->DumpWithArgs();
EXPECT_INS_EQ(inst_return_phi->InputAt(0),
FindSingleInstruction<HNewInstance>(graph_, escape->GetSinglePredecessor()));
diff --git a/compiler/optimizing/locations.cc b/compiler/optimizing/locations.cc
index f40b7f4f0c..a1506ceea9 100644
--- a/compiler/optimizing/locations.cc
+++ b/compiler/optimizing/locations.cc
@@ -62,7 +62,7 @@ Location Location::RegisterOrConstant(HInstruction* instruction) {
}
Location Location::RegisterOrInt32Constant(HInstruction* instruction) {
- HConstant* constant = instruction->AsConstant();
+ HConstant* constant = instruction->AsConstantOrNull();
if (constant != nullptr) {
int64_t value = CodeGenerator::GetInt64ValueOf(constant);
if (IsInt<32>(value)) {
@@ -73,7 +73,7 @@ Location Location::RegisterOrInt32Constant(HInstruction* instruction) {
}
Location Location::FpuRegisterOrInt32Constant(HInstruction* instruction) {
- HConstant* constant = instruction->AsConstant();
+ HConstant* constant = instruction->AsConstantOrNull();
if (constant != nullptr) {
int64_t value = CodeGenerator::GetInt64ValueOf(constant);
if (IsInt<32>(value)) {
@@ -99,7 +99,8 @@ void Location::DCheckInstructionIsConstant(HInstruction* instruction) {
DCHECK(instruction != nullptr);
DCHECK(instruction->IsConstant());
DCHECK_EQ(reinterpret_cast<uintptr_t>(instruction),
- reinterpret_cast<uintptr_t>(instruction->AsConstant()));
+ // TODO: Remove "OrNull".
+ reinterpret_cast<uintptr_t>(instruction->AsConstantOrNull()));
}
std::ostream& operator<<(std::ostream& os, const Location& location) {
diff --git a/compiler/optimizing/loop_analysis.cc b/compiler/optimizing/loop_analysis.cc
index 95e81533da..5933d3d306 100644
--- a/compiler/optimizing/loop_analysis.cc
+++ b/compiler/optimizing/loop_analysis.cc
@@ -42,7 +42,7 @@ void LoopAnalysis::CalculateLoopBasicProperties(HLoopInformation* loop_info,
// not cause loop peeling to happen as they either cannot be inside a loop, or by
// definition cannot be loop exits (unconditional instructions), or are not beneficial for
// the optimization.
- HIf* hif = block->GetLastInstruction()->AsIf();
+ HIf* hif = block->GetLastInstruction()->AsIfOrNull();
if (hif != nullptr && !loop_info->Contains(*hif->InputAt(0)->GetBlock())) {
analysis_results->invariant_exits_num_++;
}
diff --git a/compiler/optimizing/loop_optimization.cc b/compiler/optimizing/loop_optimization.cc
index d5e34634c8..4c517482c8 100644
--- a/compiler/optimizing/loop_optimization.cc
+++ b/compiler/optimizing/loop_optimization.cc
@@ -732,7 +732,8 @@ 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()) {
- HPhi* phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.Current()->AsPhiOrNull();
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
@@ -891,8 +892,9 @@ 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()->AsIf();
+ helper.GetBasicBlockMap()->Get(loop_info->GetHeader())->GetLastInstruction()->AsIfOrNull();
int32_t constant = loop_info->Contains(*copy_hif->IfTrueSuccessor()) ? 1 : 0;
copy_hif->ReplaceInput(graph_->GetIntConstant(constant), 0u);
}
@@ -920,7 +922,8 @@ bool HLoopOptimization::TryPeelingForLoopInvariantExitsElimination(LoopAnalysisI
for (auto entry : *hir_map) {
HInstruction* copy = entry.second;
if (copy->IsIf()) {
- TryToEvaluateIfCondition(copy->AsIf(), graph_);
+ // TODO: Remove "OrNull".
+ TryToEvaluateIfCondition(copy->AsIfOrNull(), graph_);
}
}
}
@@ -959,7 +962,8 @@ bool HLoopOptimization::TryFullUnrolling(LoopAnalysisInfo* analysis_info, bool g
//
HLoopInformation* loop_info = analysis_info->GetLoopInfo();
PeelByCount(loop_info, trip_count, &induction_range_);
- HIf* loop_hif = loop_info->GetHeader()->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* loop_hif = loop_info->GetHeader()->GetLastInstruction()->AsIfOrNull();
int32_t constant = loop_info->Contains(*loop_hif->IfTrueSuccessor()) ? 0 : 1;
loop_hif->ReplaceInput(graph_->GetIntConstant(constant), 0u);
}
@@ -1367,7 +1371,8 @@ void HLoopOptimization::GenerateNewLoop(LoopNode* node,
if (i != vector_map_->end() && !i->second->IsInBlock()) {
Insert(vector_body_, i->second);
if (IsInPredicatedVectorizationMode() && i->second->IsVecOperation()) {
- HVecOperation* op = i->second->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* op = i->second->AsVecOperationOrNull();
op->SetMergingGoverningPredicate(set_pred);
}
// Deal with instructions that need an environment, such as the scalar intrinsics.
@@ -1384,7 +1389,8 @@ void HLoopOptimization::GenerateNewLoop(LoopNode* node,
for (auto i = reductions_->begin(); i != reductions_->end(); ++i) {
if (!i->first->IsPhi()) {
DCHECK(i->second->IsPhi());
- GenerateVecReductionPhiInputs(i->second->AsPhi(), i->first);
+ // TODO: Remove "OrNull".
+ GenerateVecReductionPhiInputs(i->second->AsPhiOrNull(), i->first);
}
}
// Finalize phi inputs for the loop index.
@@ -1407,7 +1413,8 @@ bool HLoopOptimization::VectorizeDef(LoopNode* node,
return false;
}
if (instruction->IsArraySet()) {
- DataType::Type type = instruction->AsArraySet()->GetComponentType();
+ // TODO: Remove "OrNull".
+ DataType::Type type = instruction->AsArraySetOrNull()->GetComponentType();
HInstruction* base = instruction->InputAt(0);
HInstruction* index = instruction->InputAt(1);
HInstruction* value = instruction->InputAt(2);
@@ -1483,7 +1490,8 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node,
return true;
} else if (instruction->IsArrayGet()) {
// Deal with vector restrictions.
- bool is_string_char_at = instruction->AsArrayGet()->IsStringCharAt();
+ // TODO: Remove "OrNull".
+ bool is_string_char_at = instruction->AsArrayGetOrNull()->IsStringCharAt();
if (is_string_char_at && (HasVectorRestrictions(restrictions, kNoStringCharAt) ||
IsInPredicatedVectorizationMode())) {
@@ -1518,7 +1526,8 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node,
}
// Accept a reduction.
if (generate_code) {
- GenerateVecReductionPhi(instruction->AsPhi());
+ // TODO: Remove "OrNull".
+ GenerateVecReductionPhi(instruction->AsPhiOrNull());
}
return true;
}
@@ -1526,7 +1535,8 @@ bool HLoopOptimization::VectorizeUse(LoopNode* node,
return false;
} else if (instruction->IsTypeConversion()) {
// Accept particular type conversions.
- HTypeConversion* conversion = instruction->AsTypeConversion();
+ // TODO: Remove "OrNull".
+ HTypeConversion* conversion = instruction->AsTypeConversionOrNull();
HInstruction* opa = conversion->InputAt(0);
DataType::Type from = conversion->GetInputType();
DataType::Type to = conversion->GetResultType();
@@ -1862,7 +1872,8 @@ void HLoopOptimization::GenerateVecInv(HInstruction* org, DataType::Type type) {
vector_length_,
0u);
vector_preheader_->InsertInstructionBefore(set_pred, vector);
- vector->AsVecOperation()->SetMergingGoverningPredicate(set_pred);
+ // TODO: Remove "OrNull".
+ vector->AsVecOperationOrNull()->SetMergingGoverningPredicate(set_pred);
}
}
vector_map_->Put(org, vector);
@@ -1898,7 +1909,8 @@ void HLoopOptimization::GenerateVecMem(HInstruction* org,
vector = new (global_allocator_) HVecStore(
global_allocator_, base, opa, opb, type, org->GetSideEffects(), vector_length_, dex_pc);
} else {
- is_string_char_at = org->AsArrayGet()->IsStringCharAt();
+ // TODO: Remove "OrNull".
+ is_string_char_at = org->AsArrayGetOrNull()->IsStringCharAt();
vector = new (global_allocator_) HVecLoad(global_allocator_,
base,
opa,
@@ -1913,22 +1925,26 @@ 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) {
- vector->AsVecMemoryOperation()->SetAlignment( // forced
+ // TODO: Remove "OrNull".
+ vector->AsVecMemoryOperationOrNull()->SetAlignment( // forced
Alignment(GetVectorSizeInBytes(), 0));
}
} else {
- vector->AsVecMemoryOperation()->SetAlignment( // adjusted/original
+ // TODO: Remove "OrNull".
+ vector->AsVecMemoryOperationOrNull()->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) {
- DataType::Type component_type = org->AsArraySet()->GetComponentType();
+ // TODO: Remove "OrNull".
+ DataType::Type component_type = org->AsArraySetOrNull()->GetComponentType();
vector = new (global_allocator_) HArraySet(
org->InputAt(0), opa, opb, component_type, org->GetSideEffects(), dex_pc);
} else {
- bool is_string_char_at = org->AsArrayGet()->IsStringCharAt();
+ // TODO: Remove "OrNull".
+ bool is_string_char_at = org->AsArrayGetOrNull()->IsStringCharAt();
vector = new (global_allocator_) HArrayGet(
org->InputAt(0), opa, org->GetType(), org->GetSideEffects(), dex_pc, is_string_char_at);
}
@@ -1972,7 +1988,8 @@ 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.
- HVecOperation* red_vector = new_red->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* red_vector = new_red->AsVecOperationOrNull();
HVecReduce::ReductionKind kind = GetReductionKind(red_vector);
uint32_t vector_length = red_vector->GetVectorLength();
DataType::Type type = red_vector->GetPackedType();
@@ -1999,15 +2016,18 @@ void HLoopOptimization::GenerateVecReductionPhiInputs(HPhi* phi, HInstruction* r
vector_length,
0u);
vector_preheader_->InsertInstructionBefore(set_pred, new_init);
- new_init->AsVecOperation()->SetMergingGoverningPredicate(set_pred);
+ // TODO: Remove "OrNull".
+ new_init->AsVecOperationOrNull()->SetMergingGoverningPredicate(set_pred);
}
} else {
new_init = ReduceAndExtractIfNeeded(new_init);
}
// Set the phi inputs.
DCHECK(new_phi->IsPhi());
- new_phi->AsPhi()->AddInput(new_init);
- new_phi->AsPhi()->AddInput(new_red);
+ // TODO: Remove "OrNull".
+ new_phi->AsPhiOrNull()->AddInput(new_init);
+ // TODO: Remove "OrNull".
+ new_phi->AsPhiOrNull()->AddInput(new_red);
// New feed value for next phi (safe mutation in iteration).
reductions_->find(phi)->second = new_phi;
}
@@ -2017,7 +2037,8 @@ HInstruction* HLoopOptimization::ReduceAndExtractIfNeeded(HInstruction* instruct
HInstruction* input = instruction->InputAt(1);
if (HVecOperation::ReturnsSIMDValue(input)) {
DCHECK(!input->IsPhi());
- HVecOperation* input_vector = input->AsVecOperation();
+ // TODO: Remove "OrNull".
+ HVecOperation* input_vector = input->AsVecOperationOrNull();
uint32_t vector_length = input_vector->GetVectorLength();
DataType::Type type = input_vector->GetPackedType();
HVecReduce::ReductionKind kind = GetReductionKind(input_vector);
@@ -2041,7 +2062,8 @@ HInstruction* HLoopOptimization::ReduceAndExtractIfNeeded(HInstruction* instruct
0u);
exit->InsertInstructionBefore(set_pred, reduce);
reduce->SetMergingGoverningPredicate(set_pred);
- instruction->AsVecOperation()->SetMergingGoverningPredicate(set_pred);
+ // TODO: Remove "OrNull".
+ instruction->AsVecOperationOrNull()->SetMergingGoverningPredicate(set_pred);
}
}
}
@@ -2521,11 +2543,13 @@ 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()) {
- if (TrySetPhiReduction(it.Current()->AsPhi())) {
+ // TODO: Remove "OrNull".
+ if (TrySetPhiReduction(it.Current()->AsPhiOrNull())) {
continue;
} else if (phi == nullptr) {
// Found the first candidate for main induction.
- phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ phi = it.Current()->AsPhiOrNull();
} else {
return false;
}
diff --git a/compiler/optimizing/loop_optimization_test.cc b/compiler/optimizing/loop_optimization_test.cc
index 7f694fb655..36976519c0 100644
--- a/compiler/optimizing/loop_optimization_test.cc
+++ b/compiler/optimizing/loop_optimization_test.cc
@@ -324,7 +324,8 @@ TEST_F(LoopOptimizationTest, SimplifyLoopSinglePreheader) {
EXPECT_EQ(preheader1->GetSingleSuccessor(), new_preheader);
EXPECT_EQ(new_preheader->GetPhis().CountSize(), 1u);
- HPhi* new_preheader_phi = new_preheader->GetFirstPhi()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* new_preheader_phi = new_preheader->GetFirstPhi()->AsPhiOrNull();
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 83b58763a4..b0c7b8a711 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -183,7 +183,8 @@ 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()) {
- phi_it.Current()->AsPhi()->RemoveInputAt(use_index);
+ // TODO: Remove "OrNull".
+ phi_it.Current()->AsPhiOrNull()->RemoveInputAt(use_index);
}
}
}
@@ -582,7 +583,8 @@ 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()) {
- HPhi* phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.Current()->AsPhiOrNull();
HInstruction* first_instr = phi->InputAt(first);
HInstruction* second_instr = phi->InputAt(second);
phi->ReplaceInput(first_instr, second);
@@ -681,7 +683,8 @@ void HGraph::TransformLoopToSinglePreheaderFormat(HBasicBlock* header) {
// Fix the data-flow.
for (HInstructionIterator it(header->GetPhis()); !it.Done(); it.Advance()) {
- HPhi* header_phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* header_phi = it.Current()->AsPhiOrNull();
HPhi* preheader_phi = new (GetAllocator()) HPhi(GetAllocator(),
header_phi->GetRegNumber(),
@@ -736,7 +739,8 @@ void HGraph::SimplifyLoop(HBasicBlock* header) {
HInstruction* first_instruction = header->GetFirstInstruction();
if (first_instruction != nullptr && first_instruction->IsSuspendCheck()) {
// Called from DeadBlockElimination. Update SuspendCheck pointer.
- info->SetSuspendCheck(first_instruction->AsSuspendCheck());
+ // TODO: Remove "OrNull".
+ info->SetSuspendCheck(first_instruction->AsSuspendCheckOrNull());
}
}
@@ -1283,7 +1287,8 @@ void HBasicBlock::RemovePhi(HPhi* phi, bool ensure_safety) {
void HBasicBlock::RemoveInstructionOrPhi(HInstruction* instruction, bool ensure_safety) {
if (instruction->IsPhi()) {
- RemovePhi(instruction->AsPhi(), ensure_safety);
+ // TODO: Remove "OrNull".
+ RemovePhi(instruction->AsPhiOrNull(), ensure_safety);
} else {
RemoveInstruction(instruction, ensure_safety);
}
@@ -1321,7 +1326,8 @@ 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.
- HInstruction* initial = instruction->AsPhi()->InputAt(0);
+ // TODO: Remove "OrNull".
+ HInstruction* initial = instruction->AsPhiOrNull()->InputAt(0);
SetRawEnvAt(i, initial);
initial->AddEnvUseAt(this, i);
} else {
@@ -1576,7 +1582,8 @@ void HInstruction::ReplaceUsesDominatedBy(HInstruction* dominator,
if (dominated) {
user->ReplaceInput(replacement, index);
- } else if (user->IsPhi() && !user->AsPhi()->IsCatchPhi()) {
+ // TODO: Remove "OrNull".
+ } else if (user->IsPhi() && !user->AsPhiOrNull()->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.
@@ -1682,7 +1689,8 @@ size_t HConstructorFence::RemoveConstructorFences(HInstruction* instruction) {
++it;
if (use_instruction->IsConstructorFence()) {
- HConstructorFence* ctor_fence = use_instruction->AsConstructorFence();
+ // TODO: Remove "OrNull".
+ HConstructorFence* ctor_fence = use_instruction->AsConstructorFenceOrNull();
size_t input_index = use_node.GetIndex();
// Process the candidate instruction for removal
@@ -1818,7 +1826,8 @@ void HGraphVisitor::VisitBasicBlock(HBasicBlock* block) {
HConstant* HTypeConversion::TryStaticEvaluation() const {
HGraph* graph = GetBlock()->GetGraph();
if (GetInput()->IsIntConstant()) {
- int32_t value = GetInput()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int32_t value = GetInput()->AsIntConstantOrNull()->GetValue();
switch (GetResultType()) {
case DataType::Type::kInt8:
return graph->GetIntConstant(static_cast<int8_t>(value), GetDexPc());
@@ -1838,7 +1847,8 @@ HConstant* HTypeConversion::TryStaticEvaluation() const {
return nullptr;
}
} else if (GetInput()->IsLongConstant()) {
- int64_t value = GetInput()->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ int64_t value = GetInput()->AsLongConstantOrNull()->GetValue();
switch (GetResultType()) {
case DataType::Type::kInt8:
return graph->GetIntConstant(static_cast<int8_t>(value), GetDexPc());
@@ -1858,7 +1868,8 @@ HConstant* HTypeConversion::TryStaticEvaluation() const {
return nullptr;
}
} else if (GetInput()->IsFloatConstant()) {
- float value = GetInput()->AsFloatConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ float value = GetInput()->AsFloatConstantOrNull()->GetValue();
switch (GetResultType()) {
case DataType::Type::kInt32:
if (std::isnan(value))
@@ -1882,7 +1893,8 @@ HConstant* HTypeConversion::TryStaticEvaluation() const {
return nullptr;
}
} else if (GetInput()->IsDoubleConstant()) {
- double value = GetInput()->AsDoubleConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ double value = GetInput()->AsDoubleConstantOrNull()->GetValue();
switch (GetResultType()) {
case DataType::Type::kInt32:
if (std::isnan(value))
@@ -1911,14 +1923,18 @@ HConstant* HTypeConversion::TryStaticEvaluation() const {
HConstant* HUnaryOperation::TryStaticEvaluation() const {
if (GetInput()->IsIntConstant()) {
- return Evaluate(GetInput()->AsIntConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetInput()->AsIntConstantOrNull());
} else if (GetInput()->IsLongConstant()) {
- return Evaluate(GetInput()->AsLongConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetInput()->AsLongConstantOrNull());
} else if (kEnableFloatingPointStaticEvaluation) {
if (GetInput()->IsFloatConstant()) {
- return Evaluate(GetInput()->AsFloatConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetInput()->AsFloatConstantOrNull());
} else if (GetInput()->IsDoubleConstant()) {
- return Evaluate(GetInput()->AsDoubleConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetInput()->AsDoubleConstantOrNull());
}
}
return nullptr;
@@ -1926,24 +1942,30 @@ HConstant* HUnaryOperation::TryStaticEvaluation() const {
HConstant* HBinaryOperation::TryStaticEvaluation() const {
if (GetLeft()->IsIntConstant() && GetRight()->IsIntConstant()) {
- return Evaluate(GetLeft()->AsIntConstant(), GetRight()->AsIntConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetLeft()->AsIntConstantOrNull(), GetRight()->AsIntConstantOrNull());
} 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();
- return Evaluate(GetLeft()->AsLongConstant(), GetRight()->AsIntConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetLeft()->AsLongConstantOrNull(), GetRight()->AsIntConstantOrNull());
} else if (GetRight()->IsLongConstant()) {
- return Evaluate(GetLeft()->AsLongConstant(), GetRight()->AsLongConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetLeft()->AsLongConstantOrNull(), GetRight()->AsLongConstantOrNull());
}
} else if (GetLeft()->IsNullConstant() && GetRight()->IsNullConstant()) {
// The binop(null, null) case is only valid for equal and not-equal conditions.
DCHECK(IsEqual() || IsNotEqual()) << DebugName();
- return Evaluate(GetLeft()->AsNullConstant(), GetRight()->AsNullConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetLeft()->AsNullConstantOrNull(), GetRight()->AsNullConstantOrNull());
} else if (kEnableFloatingPointStaticEvaluation) {
if (GetLeft()->IsFloatConstant() && GetRight()->IsFloatConstant()) {
- return Evaluate(GetLeft()->AsFloatConstant(), GetRight()->AsFloatConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetLeft()->AsFloatConstantOrNull(), GetRight()->AsFloatConstantOrNull());
} else if (GetLeft()->IsDoubleConstant() && GetRight()->IsDoubleConstant()) {
- return Evaluate(GetLeft()->AsDoubleConstant(), GetRight()->AsDoubleConstant());
+ // TODO: Remove "OrNull".
+ return Evaluate(GetLeft()->AsDoubleConstantOrNull(), GetRight()->AsDoubleConstantOrNull());
}
}
return nullptr;
@@ -1951,9 +1973,11 @@ HConstant* HBinaryOperation::TryStaticEvaluation() const {
HConstant* HBinaryOperation::GetConstantRight() const {
if (GetRight()->IsConstant()) {
- return GetRight()->AsConstant();
+ // TODO: Remove "OrNull".
+ return GetRight()->AsConstantOrNull();
} else if (IsCommutative() && GetLeft()->IsConstant()) {
- return GetLeft()->AsConstant();
+ // TODO: Remove "OrNull".
+ return GetLeft()->AsConstantOrNull();
} else {
return nullptr;
}
@@ -2148,7 +2172,8 @@ void HInstruction::MoveBeforeFirstUserAndOutOfLoops() {
DCHECK(insert_pos->IsControlFlow());
// Avoid splitting HCondition from HIf to prevent unnecessary materialization.
if (insert_pos->IsIf()) {
- HInstruction* if_input = insert_pos->AsIf()->InputAt(0);
+ // TODO: Remove "OrNull".
+ HInstruction* if_input = insert_pos->AsIfOrNull()->InputAt(0);
if (if_input == insert_pos->GetPrevious()) {
insert_pos = if_input;
}
@@ -2265,7 +2290,8 @@ HBasicBlock* HBasicBlock::SplitAfterForInlining(HInstruction* cursor) {
const HTryBoundary* HBasicBlock::ComputeTryEntryOfSuccessors() const {
if (EndsWithTryBoundary()) {
- HTryBoundary* try_boundary = GetLastInstruction()->AsTryBoundary();
+ // TODO: Remove "OrNull".
+ HTryBoundary* try_boundary = GetLastInstruction()->AsTryBoundaryOrNull();
if (try_boundary->IsEntry()) {
DCHECK(!IsTryBlock());
return try_boundary;
@@ -2337,7 +2363,9 @@ bool HBasicBlock::HasSinglePhi() const {
ArrayRef<HBasicBlock* const> HBasicBlock::GetNormalSuccessors() const {
if (EndsWithTryBoundary()) {
// The normal-flow successor of HTryBoundary is always stored at index zero.
- DCHECK_EQ(successors_[0], GetLastInstruction()->AsTryBoundary()->GetNormalFlowSuccessor());
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(successors_[0],
+ GetLastInstruction()->AsTryBoundaryOrNull()->GetNormalFlowSuccessor());
return ArrayRef<HBasicBlock* const>(successors_).SubArray(0u, 1u);
} else {
// All successors of blocks not ending with TryBoundary are normal.
@@ -2347,7 +2375,8 @@ ArrayRef<HBasicBlock* const> HBasicBlock::GetNormalSuccessors() const {
ArrayRef<HBasicBlock* const> HBasicBlock::GetExceptionalSuccessors() const {
if (EndsWithTryBoundary()) {
- return GetLastInstruction()->AsTryBoundary()->GetExceptionHandlers();
+ // TODO: Remove "OrNull".
+ return GetLastInstruction()->AsTryBoundaryOrNull()->GetExceptionHandlers();
} else {
// Blocks not ending with TryBoundary do not have exceptional successors.
return ArrayRef<HBasicBlock* const>();
@@ -2472,7 +2501,8 @@ 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.
- DCHECK_EQ(last_instruction->AsTryBoundary()->GetNormalFlowSuccessor(), this);
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(last_instruction->AsTryBoundaryOrNull()->GetNormalFlowSuccessor(), this);
while (predecessor->GetSuccessors().size() > 1) {
HBasicBlock* handler = predecessor->GetSuccessors()[1];
DCHECK(handler->IsCatchBlock());
@@ -2552,13 +2582,15 @@ 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()) {
- HPhi* phi = phi_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = phi_it.Current()->AsPhiOrNull();
phi->ReplaceWith(phi->InputAt(1 - this_index));
successor->RemovePhi(phi);
}
} else {
for (HInstructionIterator phi_it(successor->GetPhis()); !phi_it.Done(); phi_it.Advance()) {
- phi_it.Current()->AsPhi()->RemoveInputAt(this_index);
+ // TODO: Remove "OrNull".
+ phi_it.Current()->AsPhiOrNull()->RemoveInputAt(this_index);
}
}
}
@@ -2581,7 +2613,8 @@ void HBasicBlock::RemoveCatchPhiUsesAndInstruction(bool building_dominator_tree)
RemoveInstruction(insn, /* ensure_safety= */ !building_dominator_tree);
}
for (HInstructionIterator it(GetPhis()); !it.Done(); it.Advance()) {
- HPhi* insn = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* insn = it.Current()->AsPhiOrNull();
RemoveCatchPhiUsesOfDeadInstruction(insn);
// If we are building the dominator tree, we removed all input records previously.
@@ -2908,7 +2941,8 @@ HInstruction* HGraph::InlineInto(HGraph* outer_graph, HInvoke* invoke) {
const bool saw_try_boundary = last->IsTryBoundary();
if (saw_try_boundary) {
DCHECK(predecessor->IsSingleTryBoundary());
- DCHECK(!last->AsTryBoundary()->IsEntry());
+ // TODO: Remove "OrNull".
+ DCHECK(!last->AsTryBoundaryOrNull()->IsEntry());
predecessor = predecessor->GetSinglePredecessor();
last = predecessor->GetLastInstruction();
}
@@ -2930,8 +2964,9 @@ 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()->AsTryBoundary()));
+ *new_block->GetLastInstruction()->AsTryBoundaryOrNull()));
} else {
// We either have `Throw->TryBoundary` or `Throw`. We want to point the whole chain to the
// exit, so we recompute `predecessor`
@@ -3014,21 +3049,26 @@ 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->AsIntConstant()->GetValue(), current->GetDexPc());
+ current->AsIntConstantOrNull()->GetValue(), current->GetDexPc());
} else if (current->IsLongConstant()) {
+ // TODO: Remove "OrNull".
replacement = outer_graph->GetLongConstant(
- current->AsLongConstant()->GetValue(), current->GetDexPc());
+ current->AsLongConstantOrNull()->GetValue(), current->GetDexPc());
} else if (current->IsFloatConstant()) {
+ // TODO: Remove "OrNull".
replacement = outer_graph->GetFloatConstant(
- current->AsFloatConstant()->GetValue(), current->GetDexPc());
+ current->AsFloatConstantOrNull()->GetValue(), current->GetDexPc());
} else if (current->IsDoubleConstant()) {
+ // TODO: Remove "OrNull".
replacement = outer_graph->GetDoubleConstant(
- current->AsDoubleConstant()->GetValue(), current->GetDexPc());
+ current->AsDoubleConstantOrNull()->GetValue(), current->GetDexPc());
} else if (current->IsParameterValue()) {
if (kIsDebugBuild &&
invoke->IsInvokeStaticOrDirect() &&
- invoke->AsInvokeStaticOrDirect()->IsStaticWithExplicitClinitCheck()) {
+ // TODO: Remove "OrNull".
+ invoke->AsInvokeStaticOrDirectOrNull()->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;
@@ -3208,7 +3248,8 @@ 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.
- CheckAgainstUpperBound(rti, AsBoundType()->GetUpperBound());
+ // TODO: Remove "OrNull".
+ CheckAgainstUpperBound(rti, AsBoundTypeOrNull()->GetUpperBound());
}
}
reference_type_handle_ = rti.GetTypeHandle();
@@ -3222,7 +3263,8 @@ void HInstruction::SetReferenceTypeInfoIfValid(ReferenceTypeInfo rti) {
}
bool HBoundType::InstructionDataEquals(const HInstruction* other) const {
- const HBoundType* other_bt = other->AsBoundType();
+ // TODO: Remove "OrNull".
+ const HBoundType* other_bt = other->AsBoundTypeOrNull();
ScopedObjectAccess soa(Thread::Current());
return GetUpperBound().IsEqual(other_bt->GetUpperBound()) &&
GetUpperCanBeNull() == other_bt->GetUpperCanBeNull() &&
@@ -3362,7 +3404,8 @@ bool HInvokeVirtual::CanDoImplicitNullCheckOn(HInstruction* obj) const {
}
bool HLoadClass::InstructionDataEquals(const HInstruction* other) const {
- const HLoadClass* other_load_class = other->AsLoadClass();
+ // TODO: Remove "OrNull".
+ const HLoadClass* other_load_class = other->AsLoadClassOrNull();
// 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_ ||
@@ -3383,7 +3426,8 @@ bool HLoadClass::InstructionDataEquals(const HInstruction* other) const {
}
bool HLoadString::InstructionDataEquals(const HInstruction* other) const {
- const HLoadString* other_load_string = other->AsLoadString();
+ // TODO: Remove "OrNull".
+ const HLoadString* other_load_string = other->AsLoadStringOrNull();
// 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_ ||
@@ -3415,9 +3459,11 @@ HInstruction* ReplaceInstrOrPhiByClone(HInstruction* instr) {
HBasicBlock* block = instr->GetBlock();
if (instr->IsPhi()) {
- HPhi* phi = instr->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = instr->AsPhiOrNull();
DCHECK(!phi->HasEnvironment());
- HPhi* phi_clone = clone->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi_clone = clone->AsPhiOrNull();
block->ReplaceAndRemovePhiWith(phi, phi_clone);
} else {
block->ReplaceAndRemoveInstructionWith(instr, clone);
@@ -3425,7 +3471,8 @@ HInstruction* ReplaceInstrOrPhiByClone(HInstruction* instr) {
clone->CopyEnvironmentFrom(instr->GetEnvironment());
HLoopInformation* loop_info = block->GetLoopInformation();
if (instr->IsSuspendCheck() && loop_info != nullptr) {
- loop_info->SetSuspendCheck(clone->AsSuspendCheck());
+ // TODO: Remove "OrNull".
+ loop_info->SetSuspendCheck(clone->AsSuspendCheckOrNull());
}
}
}
@@ -3442,7 +3489,8 @@ HInstruction* HGraph::InsertOppositeCondition(HInstruction* cond, HInstruction*
HInstruction* lhs = cond->InputAt(0);
HInstruction* rhs = cond->InputAt(1);
HInstruction* replacement = nullptr;
- switch (cond->AsCondition()->GetOppositeCondition()) { // get *opposite*
+ // TODO: Remove "OrNull".
+ switch (cond->AsConditionOrNull()->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;
@@ -3460,7 +3508,8 @@ HInstruction* HGraph::InsertOppositeCondition(HInstruction* cond, HInstruction*
cursor->GetBlock()->InsertInstructionBefore(replacement, cursor);
return replacement;
} else if (cond->IsIntConstant()) {
- HIntConstant* int_const = cond->AsIntConstant();
+ // TODO: Remove "OrNull".
+ HIntConstant* int_const = cond->AsIntConstantOrNull();
if (int_const->IsFalse()) {
return GetIntConstant(1);
} else {
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 5ca723a3c3..53396dbb72 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -2366,7 +2366,8 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> {
HInstruction* prev_not_move = GetPreviousDisregardingMoves();
while (prev_not_move != nullptr && prev_not_move->IsEmittedAtUseSite()) {
if (prev_not_move->IsNullCheck()) {
- return prev_not_move->AsNullCheck();
+ // TODO: Remove "OrNull".
+ return prev_not_move->AsNullCheckOrNull();
}
prev_not_move = prev_not_move->GetPreviousDisregardingMoves();
}
@@ -2552,8 +2553,8 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> {
#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();
FOR_EACH_INSTRUCTION(INSTRUCTION_TYPE_CAST)
#undef INSTRUCTION_TYPE_CAST
@@ -3165,14 +3166,18 @@ class HPhi final : public HVariableInputSizeInstruction {
return other != nullptr
&& other->IsPhi()
&& other->GetBlock() == GetBlock()
- && other->AsPhi()->GetRegNumber() == GetRegNumber();
+ // TODO: Remove "OrNull".
+ && other->AsPhiOrNull()->GetRegNumber() == GetRegNumber();
}
bool HasEquivalentPhi() const {
- if (GetPrevious() != nullptr && GetPrevious()->AsPhi()->GetRegNumber() == GetRegNumber()) {
+ // TODO: Remove "OrNull".
+ if (GetPrevious() != nullptr &&
+ GetPrevious()->AsPhiOrNull()->GetRegNumber() == GetRegNumber()) {
return true;
}
- if (GetNext() != nullptr && GetNext()->AsPhi()->GetRegNumber() == GetRegNumber()) {
+ // TODO: Remove "OrNull".
+ if (GetNext() != nullptr && GetNext()->AsPhiOrNull()->GetRegNumber() == GetRegNumber()) {
return true;
}
return false;
@@ -3183,9 +3188,11 @@ class HPhi final : public HVariableInputSizeInstruction {
// It assumes that phis with the same dex register are adjacent.
HPhi* GetNextEquivalentPhiWithSameType() {
HInstruction* next = GetNext();
- while (next != nullptr && next->AsPhi()->GetRegNumber() == reg_number_) {
+ // TODO: Remove "OrNull".
+ while (next != nullptr && next->AsPhiOrNull()->GetRegNumber() == reg_number_) {
if (next->GetType() == GetType()) {
- return next->AsPhi();
+ // TODO: Remove "OrNull".
+ return next->AsPhiOrNull();
}
next = next->GetNext();
}
@@ -3306,7 +3313,8 @@ class HIntConstant final : public HConstant {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsIntConstant()) << other->DebugName();
- return other->AsIntConstant()->value_ == value_;
+ // TODO: Remove "OrNull".
+ return other->AsIntConstantOrNull()->value_ == value_;
}
size_t ComputeHashCode() const override { return GetValue(); }
@@ -3350,7 +3358,8 @@ class HLongConstant final : public HConstant {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsLongConstant()) << other->DebugName();
- return other->AsLongConstant()->value_ == value_;
+ // TODO: Remove "OrNull".
+ return other->AsLongConstantOrNull()->value_ == value_;
}
size_t ComputeHashCode() const override { return static_cast<size_t>(GetValue()); }
@@ -3386,7 +3395,8 @@ class HFloatConstant final : public HConstant {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsFloatConstant()) << other->DebugName();
- return other->AsFloatConstant()->GetValueAsUint64() == GetValueAsUint64();
+ // TODO: Remove "OrNull".
+ return other->AsFloatConstantOrNull()->GetValueAsUint64() == GetValueAsUint64();
}
size_t ComputeHashCode() const override { return static_cast<size_t>(GetValue()); }
@@ -3443,7 +3453,8 @@ class HDoubleConstant final : public HConstant {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsDoubleConstant()) << other->DebugName();
- return other->AsDoubleConstant()->GetValueAsUint64() == GetValueAsUint64();
+ // TODO: Remove "OrNull".
+ return other->AsDoubleConstantOrNull()->GetValueAsUint64() == GetValueAsUint64();
}
size_t ComputeHashCode() const override { return static_cast<size_t>(GetValue()); }
@@ -3640,7 +3651,8 @@ class HDeoptimize final : public HVariableInputSizeInstruction {
bool InstructionDataEquals(const HInstruction* other) const override {
return (other->CanBeMoved() == CanBeMoved()) &&
- (other->AsDeoptimize()->GetDeoptimizationKind() == GetDeoptimizationKind());
+ // TODO: Remove "OrNull".
+ (other->AsDeoptimizeOrNull()->GetDeoptimizationKind() == GetDeoptimizationKind());
}
bool NeedsEnvironment() const override { return true; }
@@ -3749,8 +3761,9 @@ 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 {
- return other->AsClassTableGet()->GetIndex() == index_ &&
- other->AsClassTableGet()->GetPackedFields() == GetPackedFields();
+ // TODO: Remove "OrNull".
+ return other->AsClassTableGetOrNull()->GetIndex() == index_ &&
+ other->AsClassTableGetOrNull()->GetPackedFields() == GetPackedFields();
}
TableKind GetTableKind() const { return GetPackedField<TableKindField>(); }
@@ -3986,7 +3999,8 @@ class HCondition : public HBinaryOperation {
void SetBias(ComparisonBias bias) { SetPackedField<ComparisonBiasField>(bias); }
bool InstructionDataEquals(const HInstruction* other) const override {
- return GetPackedFields() == other->AsCondition()->GetPackedFields();
+ // TODO: Remove "OrNull".
+ return GetPackedFields() == other->AsConditionOrNull()->GetPackedFields();
}
bool IsFPConditionTrueIfNaN() const {
@@ -4511,7 +4525,8 @@ class HCompare final : public HBinaryOperation {
}
bool InstructionDataEquals(const HInstruction* other) const override {
- return GetPackedFields() == other->AsCompare()->GetPackedFields();
+ // TODO: Remove "OrNull".
+ return GetPackedFields() == other->AsCompareOrNull()->GetPackedFields();
}
ComparisonBias GetBias() const { return GetPackedField<ComparisonBiasField>(); }
@@ -4611,7 +4626,8 @@ class HNewInstance final : public HExpression<1> {
input = input->InputAt(0);
}
DCHECK(input->IsLoadClass());
- return input->AsLoadClass();
+ // TODO: Remove "OrNull".
+ return input->AsLoadClassOrNull();
}
bool IsStringAlloc() const;
@@ -4743,7 +4759,8 @@ class HInvoke : public HVariableInputSizeInstruction {
bool CanBeMoved() const override { return IsIntrinsic() && !DoesAnyWrite(); }
bool InstructionDataEquals(const HInstruction* other) const override {
- return intrinsic_ != Intrinsics::kNone && intrinsic_ == other->AsInvoke()->intrinsic_;
+ // TODO: Remove "OrNull".
+ return intrinsic_ != Intrinsics::kNone && intrinsic_ == other->AsInvokeOrNull()->intrinsic_;
}
uint32_t* GetIntrinsicOptimizations() {
@@ -5348,7 +5365,8 @@ class HNewArray final : public HExpression<2> {
HLoadClass* GetLoadClass() const {
DCHECK(InputAt(0)->IsLoadClass());
- return InputAt(0)->AsLoadClass();
+ // TODO: Remove "OrNull".
+ return InputAt(0)->AsLoadClassOrNull();
}
HInstruction* GetLength() const {
@@ -6288,7 +6306,8 @@ class HInstanceFieldGet final : public HExpression<1> {
bool CanBeMoved() const override { return !IsVolatile(); }
bool InstructionDataEquals(const HInstruction* other) const override {
- const HInstanceFieldGet* other_get = other->AsInstanceFieldGet();
+ // TODO: Remove "OrNull".
+ const HInstanceFieldGet* other_get = other->AsInstanceFieldGetOrNull();
return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue();
}
@@ -6377,7 +6396,8 @@ class HPredicatedInstanceFieldGet final : public HExpression<2> {
}
bool InstructionDataEquals(const HInstruction* other) const override {
- const HPredicatedInstanceFieldGet* other_get = other->AsPredicatedInstanceFieldGet();
+ // TODO: Remove "OrNull".
+ const HPredicatedInstanceFieldGet* other_get = other->AsPredicatedInstanceFieldGetOrNull();
return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue() &&
GetDefaultValue() == other_get->GetDefaultValue();
}
@@ -7437,7 +7457,8 @@ class HClinitCheck final : public HExpression<1> {
HLoadClass* GetLoadClass() const {
DCHECK(InputAt(0)->IsLoadClass());
- return InputAt(0)->AsLoadClass();
+ // TODO: Remove "OrNull".
+ return InputAt(0)->AsLoadClassOrNull();
}
DECLARE_INSTRUCTION(ClinitCheck);
@@ -7477,7 +7498,8 @@ class HStaticFieldGet final : public HExpression<1> {
bool CanBeMoved() const override { return !IsVolatile(); }
bool InstructionDataEquals(const HInstruction* other) const override {
- const HStaticFieldGet* other_get = other->AsStaticFieldGet();
+ // TODO: Remove "OrNull".
+ const HStaticFieldGet* other_get = other->AsStaticFieldGetOrNull();
return GetFieldOffset().SizeValue() == other_get->GetFieldOffset().SizeValue();
}
@@ -7612,7 +7634,8 @@ class HStringBuilderAppend final : public HVariableInputSizeInstruction {
}
HIntConstant* GetFormat() {
- return InputAt(FormatIndex())->AsIntConstant();
+ // TODO: Remove "OrNull".
+ return InputAt(FormatIndex())->AsIntConstantOrNull();
}
bool NeedsEnvironment() const override { return true; }
@@ -7875,21 +7898,24 @@ class HTypeCheckInstruction : public HVariableInputSizeInstruction {
DCHECK_NE(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck);
HInstruction* load_class = InputAt(1);
DCHECK(load_class->IsLoadClass());
- return load_class->AsLoadClass();
+ // TODO: Remove "OrNull".
+ return load_class->AsLoadClassOrNull();
}
uint32_t GetBitstringPathToRoot() const {
DCHECK_EQ(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck);
HInstruction* path_to_root = InputAt(2);
DCHECK(path_to_root->IsIntConstant());
- return static_cast<uint32_t>(path_to_root->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return static_cast<uint32_t>(path_to_root->AsIntConstantOrNull()->GetValue());
}
uint32_t GetBitstringMask() const {
DCHECK_EQ(GetTypeCheckKind(), TypeCheckKind::kBitstringCheck);
HInstruction* mask = InputAt(3);
DCHECK(mask->IsIntConstant());
- return static_cast<uint32_t>(mask->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ return static_cast<uint32_t>(mask->AsIntConstantOrNull()->GetValue());
}
bool IsClonable() const override { return true; }
@@ -8693,9 +8719,11 @@ class HBlocksInLoopReversePostOrderIterator : public ValueObject {
// Returns int64_t value of a properly typed constant.
inline int64_t Int64FromConstant(HConstant* constant) {
if (constant->IsIntConstant()) {
- return constant->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsIntConstantOrNull()->GetValue();
} else if (constant->IsLongConstant()) {
- return constant->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ return constant->AsLongConstantOrNull()->GetValue();
} else {
DCHECK(constant->IsNullConstant()) << constant->DebugName();
return 0;
@@ -8705,10 +8733,12 @@ 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()) {
- *value = instruction->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ *value = instruction->AsIntConstantOrNull()->GetValue();
return true;
} else if (instruction->IsLongConstant()) {
- *value = instruction->AsLongConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ *value = instruction->AsLongConstantOrNull()->GetValue();
return true;
} else if (instruction->IsNullConstant()) {
*value = 0;
@@ -8725,7 +8755,8 @@ inline bool IsInt64Value(HInstruction* instruction, int64_t value) {
// Returns true iff instruction is a zero bit pattern.
inline bool IsZeroBitPattern(HInstruction* instruction) {
- return instruction->IsConstant() && instruction->AsConstant()->IsZeroBitPattern();
+ // TODO: Remove "OrNull".
+ return instruction->IsConstant() && instruction->AsConstantOrNull()->IsZeroBitPattern();
}
// Implement HInstruction::Is##type() for concrete instructions.
@@ -8752,10 +8783,10 @@ inline bool IsZeroBitPattern(HInstruction* instruction) {
#undef INSTRUCTION_TYPE_CHECK_RESULT
#define INSTRUCTION_TYPE_CAST(type, super) \
- inline const H##type* HInstruction::As##type() const { \
+ inline const H##type* HInstruction::As##type##OrNull() const { \
return Is##type() ? down_cast<const H##type*>(this) : nullptr; \
} \
- inline H##type* HInstruction::As##type() { \
+ inline H##type* HInstruction::As##type##OrNull() { \
return Is##type() ? down_cast<H##type*>(this) : nullptr; \
}
@@ -8786,7 +8817,8 @@ inline HInstruction* HuntForDeclaration(HInstruction* instruction) {
instruction->IsNullCheck() ||
instruction->IsNewArray()) {
instruction = instruction->IsNewArray()
- ? instruction->AsNewArray()->GetLength()
+ // TODO: Remove "OrNull".
+ ? instruction->AsNewArrayOrNull()->GetLength()
: instruction->InputAt(0);
}
return instruction;
diff --git a/compiler/optimizing/nodes_shared.cc b/compiler/optimizing/nodes_shared.cc
index b3a7ad9a05..6216da8234 100644
--- a/compiler/optimizing/nodes_shared.cc
+++ b/compiler/optimizing/nodes_shared.cc
@@ -33,17 +33,22 @@ void HDataProcWithShifterOp::GetOpInfoFromInstruction(HInstruction* instruction,
DCHECK(CanFitInShifterOperand(instruction));
if (instruction->IsShl()) {
*op_kind = kLSL;
- *shift_amount = instruction->AsShl()->GetRight()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ *shift_amount = instruction->AsShlOrNull()->GetRight()->AsIntConstantOrNull()->GetValue();
} else if (instruction->IsShr()) {
*op_kind = kASR;
- *shift_amount = instruction->AsShr()->GetRight()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ *shift_amount = instruction->AsShrOrNull()->GetRight()->AsIntConstantOrNull()->GetValue();
} else if (instruction->IsUShr()) {
*op_kind = kLSR;
- *shift_amount = instruction->AsUShr()->GetRight()->AsIntConstant()->GetValue();
+ // TODO: Remove "OrNull".
+ *shift_amount = instruction->AsUShrOrNull()->GetRight()->AsIntConstantOrNull()->GetValue();
} else {
DCHECK(instruction->IsTypeConversion());
- DataType::Type result_type = instruction->AsTypeConversion()->GetResultType();
- DataType::Type input_type = instruction->AsTypeConversion()->GetInputType();
+ // TODO: Remove "OrNull".
+ DataType::Type result_type = instruction->AsTypeConversionOrNull()->GetResultType();
+ // TODO: Remove "OrNull".
+ DataType::Type input_type = instruction->AsTypeConversionOrNull()->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 27e610328f..b91cc3e5fd 100644
--- a/compiler/optimizing/nodes_shared.h
+++ b/compiler/optimizing/nodes_shared.h
@@ -47,7 +47,8 @@ class HMultiplyAccumulate final : public HExpression<3> {
bool CanBeMoved() const override { return true; }
bool InstructionDataEquals(const HInstruction* other) const override {
- return op_kind_ == other->AsMultiplyAccumulate()->op_kind_;
+ // TODO: Remove "OrNull".
+ return op_kind_ == other->AsMultiplyAccumulateOrNull()->op_kind_;
}
InstructionKind GetOpKind() const { return op_kind_; }
@@ -215,7 +216,8 @@ 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 {
- const HDataProcWithShifterOp* other = other_instr->AsDataProcWithShifterOp();
+ // TODO: Remove "OrNull".
+ const HDataProcWithShifterOp* other = other_instr->AsDataProcWithShifterOpOrNull();
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 73f6c40a0d..223c06e1dc 100644
--- a/compiler/optimizing/nodes_vector.h
+++ b/compiler/optimizing/nodes_vector.h
@@ -142,7 +142,8 @@ class HVecOperation : public HVariableInputSizeInstruction {
DCHECK(IsPredicated());
HInstruction* pred_input = InputAt(InputCount() - 1);
DCHECK(pred_input->IsVecPredSetOperation());
- return pred_input->AsVecPredSetOperation();
+ // TODO: Remove "OrNull".
+ return pred_input->AsVecPredSetOperationOrNull();
}
// Returns whether two vector operations are predicated by the same vector predicate
@@ -188,7 +189,8 @@ 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());
- const HVecOperation* o = other->AsVecOperation();
+ // TODO: Remove "OrNull".
+ const HVecOperation* o = other->AsVecOperationOrNull();
return GetVectorLength() == o->GetVectorLength() && GetPackedType() == o->GetPackedType();
}
@@ -350,7 +352,8 @@ class HVecMemoryOperation : public HVecOperation {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsVecMemoryOperation());
- const HVecMemoryOperation* o = other->AsVecMemoryOperation();
+ // TODO: Remove "OrNull".
+ const HVecMemoryOperation* o = other->AsVecMemoryOperationOrNull();
return HVecOperation::InstructionDataEquals(o) && GetAlignment() == o->GetAlignment();
}
@@ -371,7 +374,8 @@ inline static bool HasConsistentPackedTypes(HInstruction* input, DataType::Type
return input->GetType() == HVecOperation::kSIMDType; // carries SIMD
}
DCHECK(input->IsVecOperation());
- DataType::Type input_type = input->AsVecOperation()->GetPackedType();
+ // TODO: Remove "OrNull".
+ DataType::Type input_type = input->AsVecOperationOrNull()->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);
@@ -465,7 +469,8 @@ class HVecReduce final : public HVecUnaryOperation {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsVecReduce());
- const HVecReduce* o = other->AsVecReduce();
+ // TODO: Remove "OrNull".
+ const HVecReduce* o = other->AsVecReduceOrNull();
return HVecOperation::InstructionDataEquals(o) && GetReductionKind() == o->GetReductionKind();
}
@@ -492,7 +497,10 @@ class HVecCnv final : public HVecUnaryOperation {
DCHECK_NE(GetInputType(), GetResultType()); // actual convert
}
- DataType::Type GetInputType() const { return InputAt(0)->AsVecOperation()->GetPackedType(); }
+ DataType::Type GetInputType() const {
+ // TODO: Remove "OrNull".
+ return InputAt(0)->AsVecOperationOrNull()->GetPackedType();
+ }
DataType::Type GetResultType() const { return GetPackedType(); }
bool CanBeMoved() const override { return true; }
@@ -646,7 +654,8 @@ class HVecHalvingAdd final : public HVecBinaryOperation {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsVecHalvingAdd());
- const HVecHalvingAdd* o = other->AsVecHalvingAdd();
+ // TODO: Remove "OrNull".
+ const HVecHalvingAdd* o = other->AsVecHalvingAddOrNull();
return HVecOperation::InstructionDataEquals(o) && IsRounded() == o->IsRounded();
}
@@ -1036,7 +1045,8 @@ class HVecMultiplyAccumulate final : public HVecOperation {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsVecMultiplyAccumulate());
- const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulate();
+ // TODO: Remove "OrNull".
+ const HVecMultiplyAccumulate* o = other->AsVecMultiplyAccumulateOrNull();
return HVecOperation::InstructionDataEquals(o) && GetOpKind() == o->GetOpKind();
}
@@ -1076,8 +1086,9 @@ class HVecSADAccumulate final : public HVecOperation {
DCHECK(HasConsistentPackedTypes(accumulator, packed_type));
DCHECK(sad_left->IsVecOperation());
DCHECK(sad_right->IsVecOperation());
- DCHECK_EQ(ToSignedType(sad_left->AsVecOperation()->GetPackedType()),
- ToSignedType(sad_right->AsVecOperation()->GetPackedType()));
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(ToSignedType(sad_left->AsVecOperationOrNull()->GetPackedType()),
+ ToSignedType(sad_right->AsVecOperationOrNull()->GetPackedType()));
SetRawInputAt(0, accumulator);
SetRawInputAt(1, sad_left);
SetRawInputAt(2, sad_right);
@@ -1124,8 +1135,9 @@ class HVecDotProd final : public HVecOperation {
DCHECK(DataType::IsIntegralType(packed_type));
DCHECK(left->IsVecOperation());
DCHECK(right->IsVecOperation());
- DCHECK_EQ(ToSignedType(left->AsVecOperation()->GetPackedType()),
- ToSignedType(right->AsVecOperation()->GetPackedType()));
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(ToSignedType(left->AsVecOperationOrNull()->GetPackedType()),
+ ToSignedType(right->AsVecOperationOrNull()->GetPackedType()));
SetRawInputAt(0, accumulator);
SetRawInputAt(1, left);
SetRawInputAt(2, right);
@@ -1179,7 +1191,8 @@ class HVecLoad final : public HVecMemoryOperation {
bool InstructionDataEquals(const HInstruction* other) const override {
DCHECK(other->IsVecLoad());
- const HVecLoad* o = other->AsVecLoad();
+ // TODO: Remove "OrNull".
+ const HVecLoad* o = other->AsVecLoadOrNull();
return HVecMemoryOperation::InstructionDataEquals(o) && IsStringCharAt() == o->IsStringCharAt();
}
@@ -1310,7 +1323,10 @@ 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 { return InputAt(0)->AsIntConstant()->IsTrue(); }
+ bool IsSetTrue() const {
+ // TODO: Remove "OrNull".
+ return InputAt(0)->AsIntConstantOrNull()->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 e246390aa5..04f9763060 100644
--- a/compiler/optimizing/nodes_x86.h
+++ b/compiler/optimizing/nodes_x86.h
@@ -52,11 +52,13 @@ class HX86LoadFromConstantTable final : public HExpression<2> {
}
HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
- return InputAt(0)->AsX86ComputeBaseMethodAddress();
+ // TODO: Remove "OrNull".
+ return InputAt(0)->AsX86ComputeBaseMethodAddressOrNull();
}
HConstant* GetConstant() const {
- return InputAt(1)->AsConstant();
+ // TODO: Remove "OrNull".
+ return InputAt(1)->AsConstantOrNull();
}
DECLARE_INSTRUCTION(X86LoadFromConstantTable);
@@ -79,7 +81,8 @@ class HX86FPNeg final : public HExpression<2> {
}
HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
- return InputAt(1)->AsX86ComputeBaseMethodAddress();
+ // TODO: Remove "OrNull".
+ return InputAt(1)->AsX86ComputeBaseMethodAddressOrNull();
}
DECLARE_INSTRUCTION(X86FPNeg);
@@ -110,7 +113,8 @@ class HX86PackedSwitch final : public HExpression<2> {
int32_t GetNumEntries() const { return num_entries_; }
HX86ComputeBaseMethodAddress* GetBaseMethodAddress() const {
- return InputAt(1)->AsX86ComputeBaseMethodAddress();
+ // TODO: Remove "OrNull".
+ return InputAt(1)->AsX86ComputeBaseMethodAddressOrNull();
}
HBasicBlock* GetDefaultBlock() const {
diff --git a/compiler/optimizing/optimizing_unit_test.h b/compiler/optimizing/optimizing_unit_test.h
index 2e05c41f01..ceffce9333 100644
--- a/compiler/optimizing/optimizing_unit_test.h
+++ b/compiler/optimizing/optimizing_unit_test.h
@@ -407,8 +407,9 @@ 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->AsLoadClass() : cls->AsClinitCheck()->GetLoadClass();
+ cls->IsLoadClass() ? cls->AsLoadClassOrNull() : cls->AsClinitCheckOrNull()->GetLoadClass();
return new (GetAllocator()) HNewInstance(cls,
dex_pc,
load->GetTypeIndex(),
@@ -592,7 +593,8 @@ class PatternMatchGraphVisitor final : public HGraphVisitor {
explicit KindWrapper(F f) : f_(f) {} \
void operator()(HInstruction* h) override { \
if constexpr (std::is_invocable_v<F, H##nm*>) { \
- f_(h->As##nm()); \
+ /* TODO: Remove "OrNull". */ \
+ f_(h->As##nm##OrNull()); \
} else { \
LOG(FATAL) << "Incorrect call with " << #nm; \
} \
diff --git a/compiler/optimizing/pc_relative_fixups_x86.cc b/compiler/optimizing/pc_relative_fixups_x86.cc
index d3da3d3ce1..56341f106f 100644
--- a/compiler/optimizing/pc_relative_fixups_x86.cc
+++ b/compiler/optimizing/pc_relative_fixups_x86.cc
@@ -62,7 +62,7 @@ class PCRelativeHandlerVisitor final : public HGraphVisitor {
}
void VisitReturn(HReturn* ret) override {
- HConstant* value = ret->InputAt(0)->AsConstant();
+ HConstant* value = ret->InputAt(0)->AsConstantOrNull();
if ((value != nullptr && DataType::IsFloatingPointType(value->GetType()))) {
ReplaceInput(ret, value, 0, true);
}
@@ -95,7 +95,7 @@ class PCRelativeHandlerVisitor final : public HGraphVisitor {
}
void BinaryFP(HBinaryOperation* bin) {
- HConstant* rhs = bin->InputAt(1)->AsConstant();
+ HConstant* rhs = bin->InputAt(1)->AsConstantOrNull();
if (rhs != nullptr && DataType::IsFloatingPointType(rhs->GetType())) {
ReplaceInput(bin, rhs, 1, false);
}
@@ -193,7 +193,7 @@ class PCRelativeHandlerVisitor final : public HGraphVisitor {
}
void HandleInvoke(HInvoke* invoke) {
- HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirect();
+ HInvokeStaticOrDirect* invoke_static_or_direct = invoke->AsInvokeStaticOrDirectOrNull();
// If this is an invoke-static/-direct with PC-relative addressing (within boot image
// or using .bss or .data.bimg.rel.ro), we need the PC-relative address base.
@@ -207,7 +207,7 @@ class PCRelativeHandlerVisitor final : public HGraphVisitor {
base_added = true;
}
- HInvokeInterface* invoke_interface = invoke->AsInvokeInterface();
+ HInvokeInterface* invoke_interface = invoke->AsInvokeInterfaceOrNull();
if (invoke_interface != nullptr &&
IsPcRelativeMethodLoadKind(invoke_interface->GetHiddenArgumentLoadKind())) {
HX86ComputeBaseMethodAddress* method_address = GetPCRelativeBasePointer(invoke);
@@ -219,7 +219,7 @@ class PCRelativeHandlerVisitor final : public HGraphVisitor {
// Ensure that we can load FP arguments from the constant area.
HInputsRef inputs = invoke->GetInputs();
for (size_t i = 0; i < inputs.size(); i++) {
- HConstant* input = inputs[i]->AsConstant();
+ HConstant* input = inputs[i]->AsConstantOrNull();
if (input != nullptr && DataType::IsFloatingPointType(input->GetType())) {
ReplaceInput(invoke, input, i, true);
}
diff --git a/compiler/optimizing/prepare_for_register_allocation.cc b/compiler/optimizing/prepare_for_register_allocation.cc
index 398b10abf3..741bef7627 100644
--- a/compiler/optimizing/prepare_for_register_allocation.cc
+++ b/compiler/optimizing/prepare_for_register_allocation.cc
@@ -58,7 +58,8 @@ void PrepareForRegisterAllocation::VisitNullCheck(HNullCheck* check) {
// so do it ourselves now to not prevent optimizations.
while (next->IsBoundType()) {
next = next->GetNext();
- VisitBoundType(next->GetPrevious()->AsBoundType());
+ // TODO: Remove "OrNull".
+ VisitBoundType(next->GetPrevious()->AsBoundTypeOrNull());
}
if (next->CanDoImplicitNullCheckOn(check->InputAt(0))) {
check->MarkEmittedAtUseSite();
@@ -123,14 +124,18 @@ void PrepareForRegisterAllocation::VisitClinitCheck(HClinitCheck* check) {
CanMoveClinitCheck(check, user)) {
implicit_clinit = user;
if (user->IsInvokeStaticOrDirect()) {
- DCHECK(user->AsInvokeStaticOrDirect()->IsStaticWithExplicitClinitCheck());
- user->AsInvokeStaticOrDirect()->RemoveExplicitClinitCheck(
+ // TODO: Remove "OrNull".
+ DCHECK(user->AsInvokeStaticOrDirectOrNull()->IsStaticWithExplicitClinitCheck());
+ // TODO: Remove "OrNull".
+ user->AsInvokeStaticOrDirectOrNull()->RemoveExplicitClinitCheck(
HInvokeStaticOrDirect::ClinitCheckRequirement::kImplicit);
} else {
DCHECK(user->IsNewInstance());
// We delegate the initialization duty to the allocation.
- if (user->AsNewInstance()->GetEntrypoint() == kQuickAllocObjectInitialized) {
- user->AsNewInstance()->SetEntrypoint(kQuickAllocObjectResolved);
+ // TODO: Remove "OrNull".
+ if (user->AsNewInstanceOrNull()->GetEntrypoint() == kQuickAllocObjectInitialized) {
+ // TODO: Remove "OrNull".
+ user->AsNewInstanceOrNull()->SetEntrypoint(kQuickAllocObjectResolved);
}
}
break;
@@ -146,7 +151,8 @@ 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()) {
- user->AsInvokeStaticOrDirect()->RemoveExplicitClinitCheck(
+ // TODO: Remove "OrNull".
+ user->AsInvokeStaticOrDirectOrNull()->RemoveExplicitClinitCheck(
HInvokeStaticOrDirect::ClinitCheckRequirement::kNone);
}
}
@@ -184,7 +190,8 @@ bool PrepareForRegisterAllocation::CanEmitConditionAt(HCondition* condition,
return true;
}
- if (user->IsSelect() && user->AsSelect()->GetCondition() == condition) {
+ // TODO: Remove "OrNull".
+ if (user->IsSelect() && user->AsSelectOrNull()->GetCondition() == condition) {
return true;
}
@@ -212,7 +219,8 @@ 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()) {
- HNewInstance* new_inst = allocation_inst->AsNewInstance();
+ // TODO: Remove "OrNull".
+ HNewInstance* new_inst = allocation_inst->AsNewInstanceOrNull();
// 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) {
@@ -268,7 +276,8 @@ bool PrepareForRegisterAllocation::CanMoveClinitCheck(HInstruction* input,
return false;
}
- if (user->IsNewInstance() && user->AsNewInstance()->IsPartialMaterialization()) {
+ // TODO: Remove "OrNull".
+ if (user->IsNewInstance() && user->AsNewInstanceOrNull()->IsPartialMaterialization()) {
return false;
}
diff --git a/compiler/optimizing/reference_type_propagation.cc b/compiler/optimizing/reference_type_propagation.cc
index 91bae5f49b..4fddee1874 100644
--- a/compiler/optimizing/reference_type_propagation.cc
+++ b/compiler/optimizing/reference_type_propagation.cc
@@ -132,7 +132,8 @@ void ReferenceTypePropagation::Visit(ArrayRef<HInstruction* const> instructions)
for (HInstruction* instruction : instructions) {
if (instruction->IsPhi()) {
// Need to force phis to recalculate null-ness.
- instruction->AsPhi()->SetCanBeNull(false);
+ // TODO: Remove "OrNull".
+ instruction->AsPhiOrNull()->SetCanBeNull(false);
}
}
for (HInstruction* instruction : instructions) {
@@ -163,7 +164,8 @@ static bool ShouldCreateBoundType(HInstruction* position,
return true;
}
- HBoundType* existing_bound_type = position->AsBoundType();
+ // TODO: Remove "OrNull".
+ HBoundType* existing_bound_type = position->AsBoundTypeOrNull();
if (existing_bound_type->GetUpperBound().IsSupertypeOf(upper_bound)) {
if (kIsDebugBuild) {
// Check that the existing HBoundType dominates all the uses.
@@ -253,8 +255,9 @@ static void BoundTypeForClassCheck(HInstruction* check) {
HInstruction* input_one = compare->InputAt(0);
HInstruction* input_two = compare->InputAt(1);
HLoadClass* load_class = input_one->IsLoadClass()
- ? input_one->AsLoadClass()
- : input_two->AsLoadClass();
+ // TODO: Remove "OrNull".
+ ? input_one->AsLoadClassOrNull()
+ : input_two->AsLoadClassOrNull();
if (load_class == nullptr) {
return;
}
@@ -286,13 +289,15 @@ static void BoundTypeForClassCheck(HInstruction* check) {
}
if (check->IsIf()) {
+ // TODO: Remove "OrNull".
HBasicBlock* trueBlock = compare->IsEqual()
- ? check->AsIf()->IfTrueSuccessor()
- : check->AsIf()->IfFalseSuccessor();
+ ? check->AsIfOrNull()->IfTrueSuccessor()
+ : check->AsIfOrNull()->IfFalseSuccessor();
BoundTypeIn(receiver, trueBlock, /* start_instruction= */ nullptr, class_rti);
} else {
DCHECK(check->IsDeoptimize());
- if (compare->IsEqual() && check->AsDeoptimize()->GuardsAnInput()) {
+ // TODO: Remove "OrNull".
+ if (compare->IsEqual() && check->AsDeoptimizeOrNull()->GuardsAnInput()) {
check->SetReferenceTypeInfo(class_rti);
}
}
@@ -318,7 +323,8 @@ 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()) {
- VisitPhi(it.Current()->AsPhi());
+ // TODO: Remove "OrNull".
+ VisitPhi(it.Current()->AsPhiOrNull());
}
// Handle instructions. Since RTP may add HBoundType instructions just after the
@@ -335,7 +341,7 @@ void ReferenceTypePropagation::RTPVisitor::VisitBasicBlock(HBasicBlock* block) {
}
void ReferenceTypePropagation::RTPVisitor::BoundTypeForIfNotNull(HBasicBlock* block) {
- HIf* ifInstruction = block->GetLastInstruction()->AsIf();
+ HIf* ifInstruction = block->GetLastInstruction()->AsIfOrNull();
if (ifInstruction == nullptr) {
return;
}
@@ -391,14 +397,18 @@ static bool MatchIfInstanceOf(HIf* ifInstruction,
HInstruction* input = ifInstruction->InputAt(0);
if (input->IsEqual()) {
- HInstruction* rhs = input->AsEqual()->GetConstantRight();
+ // TODO: Remove "OrNull".
+ HInstruction* rhs = input->AsEqualOrNull()->GetConstantRight();
if (rhs != nullptr) {
- HInstruction* lhs = input->AsEqual()->GetLeastConstantLeft();
+ // TODO: Remove "OrNull".
+ HInstruction* lhs = input->AsEqualOrNull()->GetLeastConstantLeft();
if (lhs->IsInstanceOf() && rhs->IsIntConstant()) {
- if (rhs->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ if (rhs->AsIntConstantOrNull()->IsTrue()) {
// Case (1a)
*trueBranch = ifInstruction->IfTrueSuccessor();
- } else if (rhs->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ } else if (rhs->AsIntConstantOrNull()->IsFalse()) {
// Case (2a)
*trueBranch = ifInstruction->IfFalseSuccessor();
} else {
@@ -406,19 +416,24 @@ static bool MatchIfInstanceOf(HIf* ifInstruction,
// In those cases, we cannot do the match if+instance-of.
return false;
}
- *instanceOf = lhs->AsInstanceOf();
+ // TODO: Remove "OrNull".
+ *instanceOf = lhs->AsInstanceOfOrNull();
return true;
}
}
} else if (input->IsNotEqual()) {
- HInstruction* rhs = input->AsNotEqual()->GetConstantRight();
+ // TODO: Remove "OrNull".
+ HInstruction* rhs = input->AsNotEqualOrNull()->GetConstantRight();
if (rhs != nullptr) {
- HInstruction* lhs = input->AsNotEqual()->GetLeastConstantLeft();
+ // TODO: Remove "OrNull".
+ HInstruction* lhs = input->AsNotEqualOrNull()->GetLeastConstantLeft();
if (lhs->IsInstanceOf() && rhs->IsIntConstant()) {
- if (rhs->AsIntConstant()->IsFalse()) {
+ // TODO: Remove "OrNull".
+ if (rhs->AsIntConstantOrNull()->IsFalse()) {
// Case (1b)
*trueBranch = ifInstruction->IfTrueSuccessor();
- } else if (rhs->AsIntConstant()->IsTrue()) {
+ // TODO: Remove "OrNull".
+ } else if (rhs->AsIntConstantOrNull()->IsTrue()) {
// Case (2b)
*trueBranch = ifInstruction->IfFalseSuccessor();
} else {
@@ -426,20 +441,23 @@ static bool MatchIfInstanceOf(HIf* ifInstruction,
// In those cases, we cannot do the match if+instance-of.
return false;
}
- *instanceOf = lhs->AsInstanceOf();
+ // TODO: Remove "OrNull".
+ *instanceOf = lhs->AsInstanceOfOrNull();
return true;
}
}
} else if (input->IsInstanceOf()) {
// Case (1c)
- *instanceOf = input->AsInstanceOf();
+ // TODO: Remove "OrNull".
+ *instanceOf = input->AsInstanceOfOrNull();
*trueBranch = ifInstruction->IfTrueSuccessor();
return true;
} else if (input->IsBooleanNot()) {
HInstruction* not_input = input->InputAt(0);
if (not_input->IsInstanceOf()) {
// Case (2c)
- *instanceOf = not_input->AsInstanceOf();
+ // TODO: Remove "OrNull".
+ *instanceOf = not_input->AsInstanceOfOrNull();
*trueBranch = ifInstruction->IfFalseSuccessor();
return true;
}
@@ -453,7 +471,7 @@ static bool MatchIfInstanceOf(HIf* ifInstruction,
// If that's the case insert an HBoundType instruction to bound the type of `x`
// to `ClassX` in the scope of the dominated blocks.
void ReferenceTypePropagation::RTPVisitor::BoundTypeForIfInstanceOf(HBasicBlock* block) {
- HIf* ifInstruction = block->GetLastInstruction()->AsIf();
+ HIf* ifInstruction = block->GetLastInstruction()->AsIfOrNull();
if (ifInstruction == nullptr) {
return;
}
@@ -494,10 +512,12 @@ void ReferenceTypePropagation::RTPVisitor::BoundTypeForIfInstanceOf(HBasicBlock*
void ReferenceTypePropagation::RTPVisitor::SetClassAsTypeInfo(HInstruction* instr,
ObjPtr<mirror::Class> klass,
bool is_exact) {
- if (instr->IsInvokeStaticOrDirect() && instr->AsInvokeStaticOrDirect()->IsStringInit()) {
+ // TODO: Remove "OrNull".
+ if (instr->IsInvokeStaticOrDirect() && instr->AsInvokeStaticOrDirectOrNull()->IsStringInit()) {
// Calls to String.<init> are replaced with a StringFactory.
if (kIsDebugBuild) {
- HInvokeStaticOrDirect* invoke = instr->AsInvokeStaticOrDirect();
+ // TODO: Remove "OrNull".
+ HInvokeStaticOrDirect* invoke = instr->AsInvokeStaticOrDirectOrNull();
ClassLinker* cl = Runtime::Current()->GetClassLinker();
Thread* self = Thread::Current();
StackHandleScope<2> hs(self);
@@ -704,7 +724,7 @@ void ReferenceTypePropagation::RTPVisitor::VisitBoundType(HBoundType* instr) {
}
void ReferenceTypePropagation::RTPVisitor::VisitCheckCast(HCheckCast* check_cast) {
- HBoundType* bound_type = check_cast->GetNext()->AsBoundType();
+ HBoundType* bound_type = check_cast->GetNext()->AsBoundTypeOrNull();
if (bound_type == nullptr || bound_type->GetUpperBound().IsValid()) {
// The next instruction is not an uninitialized BoundType. This must be
// an RTP pass after SsaBuilder and we do not need to do anything.
@@ -759,7 +779,8 @@ void ReferenceTypePropagation::FixUpInstructionType(HInstruction* instruction,
HandleCache* handle_cache) {
if (instruction->IsSelect()) {
ScopedObjectAccess soa(Thread::Current());
- HSelect* select = instruction->AsSelect();
+ // TODO: Remove "OrNull".
+ HSelect* select = instruction->AsSelectOrNull();
ReferenceTypeInfo false_rti = select->GetFalseValue()->GetReferenceTypeInfo();
ReferenceTypeInfo true_rti = select->GetTrueValue()->GetReferenceTypeInfo();
select->SetReferenceTypeInfo(MergeTypes(false_rti, true_rti, handle_cache));
@@ -837,9 +858,11 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateReferenceTypeInfo(HInstruction*
ReferenceTypeInfo previous_rti = instr->GetReferenceTypeInfo();
if (instr->IsBoundType()) {
- UpdateBoundType(instr->AsBoundType());
+ // TODO: Remove "OrNull".
+ UpdateBoundType(instr->AsBoundTypeOrNull());
} else if (instr->IsPhi()) {
- UpdatePhi(instr->AsPhi());
+ // TODO: Remove "OrNull".
+ UpdatePhi(instr->AsPhiOrNull());
} else if (instr->IsNullCheck()) {
ReferenceTypeInfo parent_rti = instr->InputAt(0)->GetReferenceTypeInfo();
if (parent_rti.IsValid()) {
@@ -848,7 +871,8 @@ 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.
- UpdateArrayGet(instr->AsArrayGet());
+ // TODO: Remove "OrNull".
+ UpdateArrayGet(instr->AsArrayGetOrNull());
} else {
LOG(FATAL) << "Invalid instruction (should not get here)";
}
@@ -949,7 +973,8 @@ void ReferenceTypePropagation::RTPVisitor::UpdatePhi(HPhi* instr) {
}
constexpr bool ReferenceTypePropagation::RTPVisitor::IsUpdateable(const HInstruction* instr) {
- return (instr->IsPhi() && instr->AsPhi()->IsLive()) ||
+ // TODO: Remove "OrNull".
+ return (instr->IsPhi() && instr->AsPhiOrNull()->IsLive()) ||
instr->IsBoundType() ||
instr->IsNullCheck() ||
instr->IsArrayGet();
@@ -966,7 +991,8 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateNullability(HInstruction* instr
bool existing_can_be_null = instr->CanBeNull();
if (instr->IsPhi()) {
- HPhi* phi = instr->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = instr->AsPhiOrNull();
bool new_can_be_null = false;
for (HInstruction* input : phi->GetInputs()) {
if (input->CanBeNull()) {
@@ -976,7 +1002,8 @@ bool ReferenceTypePropagation::RTPVisitor::UpdateNullability(HInstruction* instr
}
phi->SetCanBeNull(new_can_be_null);
} else if (instr->IsBoundType()) {
- HBoundType* bound_type = instr->AsBoundType();
+ // TODO: Remove "OrNull".
+ HBoundType* bound_type = instr->AsBoundTypeOrNull();
bound_type->SetCanBeNull(instr->InputAt(0)->CanBeNull() && bound_type->GetUpperCanBeNull());
}
return existing_can_be_null != instr->CanBeNull();
@@ -1004,7 +1031,8 @@ void ReferenceTypePropagation::RTPVisitor::AddDependentInstructionsToWorklist(
HInstruction* instruction) {
for (const HUseListNode<HInstruction*>& use : instruction->GetUses()) {
HInstruction* user = use.GetUser();
- if ((user->IsPhi() && user->AsPhi()->IsLive())
+ // TODO: Remove "OrNull".
+ if ((user->IsPhi() && user->AsPhiOrNull()->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 2b012fcd67..5211e09a38 100644
--- a/compiler/optimizing/reference_type_propagation_test.cc
+++ b/compiler/optimizing/reference_type_propagation_test.cc
@@ -333,7 +333,8 @@ void LoopReferenceTypePropagationTestGroup::RunVisitListTest(Func mutator) {
}
for (HBasicBlock* blk : succ_blocks) {
CHECK(single_value[blk]->IsPhi()) << blk->GetBlockId();
- blk->AddPhi(single_value[blk]->AsPhi());
+ // TODO: Remove "OrNull".
+ blk->AddPhi(single_value[blk]->AsPhiOrNull());
}
auto vals = MakeTransformRange(succ_blocks, [&](HBasicBlock* blk) {
DCHECK(single_value[blk]->IsPhi());
@@ -421,7 +422,8 @@ void NonLoopReferenceTypePropagationTestGroup::RunVisitListTest(Func mutator) {
for (const auto& [pred, index] : ZipCount(MakeIterationRange(blk->GetPredecessors()))) {
my_val->SetRawInputAt(index, single_value[pred]);
}
- blk->AddPhi(my_val->AsPhi());
+ // TODO: Remove "OrNull".
+ blk->AddPhi(my_val->AsPhiOrNull());
}
auto vals = MakeTransformRange(succ_blocks, [&](HBasicBlock* blk) { return single_value[blk]; });
std::vector<HInstruction*> ins(vals.begin(), vals.end());
@@ -485,13 +487,15 @@ TEST_P(LoopReferenceTypePropagationTestGroup, RunVisitTest) {
return uid(g);
}
};
- HPhi* nulled_phi = lo.null_insertion_ >= 0 ? lst[lo.null_insertion_]->AsPhi() : nullptr;
+ // TODO: Remove "OrNull".
+ HPhi* nulled_phi = lo.null_insertion_ >= 0 ? lst[lo.null_insertion_]->AsPhiOrNull() : 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) {
- ins->AsPhi()->SetCanBeNull(next_null());
+ // TODO: Remove "OrNull".
+ ins->AsPhiOrNull()->SetCanBeNull(next_null());
});
});
}
diff --git a/compiler/optimizing/register_allocation_resolver.cc b/compiler/optimizing/register_allocation_resolver.cc
index 982595b8e7..969a2733b1 100644
--- a/compiler/optimizing/register_allocation_resolver.cc
+++ b/compiler/optimizing/register_allocation_resolver.cc
@@ -76,7 +76,8 @@ void RegisterAllocationResolver::Resolve(ArrayRef<HInstruction* const> safepoint
} else if (instruction->IsCurrentMethod()) {
// The current method is always at offset 0.
DCHECK_IMPLIES(current->HasSpillSlot(), (current->GetSpillSlot() == 0));
- } else if (instruction->IsPhi() && instruction->AsPhi()->IsCatchPhi()) {
+ // TODO: Remove "OrNull".
+ } else if (instruction->IsPhi() && instruction->AsPhiOrNull()->IsCatchPhi()) {
DCHECK(current->HasSpillSlot());
size_t slot = current->GetSpillSlot()
+ spill_slots
@@ -351,7 +352,8 @@ void RegisterAllocationResolver::ConnectSiblings(LiveInterval* interval) {
}
} else {
DCHECK(use.GetUser()->IsInvoke());
- DCHECK(use.GetUser()->AsInvoke()->GetIntrinsic() != Intrinsics::kNone);
+ // TODO: Remove "OrNull".
+ DCHECK(use.GetUser()->AsInvokeOrNull()->GetIntrinsic() != Intrinsics::kNone);
}
}
}
@@ -538,7 +540,8 @@ void RegisterAllocationResolver::AddInputMoveFor(HInstruction* input,
move->SetLifetimePosition(user->GetLifetimePosition());
user->GetBlock()->InsertInstructionBefore(move, user);
} else {
- move = previous->AsParallelMove();
+ // TODO: Remove "OrNull".
+ move = previous->AsParallelMoveOrNull();
}
DCHECK_EQ(move->GetLifetimePosition(), user->GetLifetimePosition());
AddMove(move, source, destination, nullptr, input->GetType());
@@ -587,13 +590,14 @@ void RegisterAllocationResolver::InsertParallelMoveAt(size_t position,
at->GetBlock()->InsertInstructionBefore(move, at);
} else {
DCHECK(at->IsParallelMove());
- move = at->AsParallelMove();
+ // TODO: Remove "OrNull".
+ move = at->AsParallelMoveOrNull();
}
}
} else if (IsInstructionEnd(position)) {
// Move must happen after the instruction.
DCHECK(!at->IsControlFlow());
- move = at->GetNext()->AsParallelMove();
+ move = at->GetNext()->AsParallelMoveOrNull();
// This is a parallel move for connecting siblings in a same block. We need to
// differentiate it with moves for connecting blocks, and input moves.
if (move == nullptr || move->GetLifetimePosition() > position) {
@@ -617,7 +621,8 @@ void RegisterAllocationResolver::InsertParallelMoveAt(size_t position,
move->SetLifetimePosition(position);
at->GetBlock()->InsertInstructionBefore(move, at);
} else {
- move = previous->AsParallelMove();
+ // TODO: Remove "OrNull".
+ move = previous->AsParallelMoveOrNull();
}
}
DCHECK_EQ(move->GetLifetimePosition(), position);
@@ -645,12 +650,14 @@ void RegisterAllocationResolver::InsertParallelMoveAtExitOf(HBasicBlock* block,
size_t position = last->GetLifetimePosition();
if (previous == nullptr ||
!previous->IsParallelMove() ||
- previous->AsParallelMove()->GetLifetimePosition() != position) {
+ // TODO: Remove "OrNull".
+ previous->AsParallelMoveOrNull()->GetLifetimePosition() != position) {
move = new (allocator_) HParallelMove(allocator_);
move->SetLifetimePosition(position);
block->InsertInstructionBefore(move, last);
} else {
- move = previous->AsParallelMove();
+ // TODO: Remove "OrNull".
+ move = previous->AsParallelMoveOrNull();
}
AddMove(move, source, destination, instruction, instruction->GetType());
}
@@ -663,7 +670,7 @@ void RegisterAllocationResolver::InsertParallelMoveAtEntryOf(HBasicBlock* block,
if (source.Equals(destination)) return;
HInstruction* first = block->GetFirstInstruction();
- HParallelMove* move = first->AsParallelMove();
+ HParallelMove* move = first->AsParallelMoveOrNull();
size_t position = block->GetLifetimeStart();
// This is a parallel move for connecting blocks. We need to differentiate
// it with moves for connecting siblings in a same block, and input moves.
@@ -687,7 +694,7 @@ void RegisterAllocationResolver::InsertMoveAfter(HInstruction* instruction,
}
size_t position = instruction->GetLifetimePosition() + 1;
- HParallelMove* move = instruction->GetNext()->AsParallelMove();
+ HParallelMove* move = instruction->GetNext()->AsParallelMoveOrNull();
// This is a parallel move for moving the output of an instruction. We need
// to differentiate with input moves, moves for connecting siblings in a
// and moves for connecting blocks.
diff --git a/compiler/optimizing/register_allocator_graph_color.cc b/compiler/optimizing/register_allocator_graph_color.cc
index a7c891d4e7..8b96f32ef7 100644
--- a/compiler/optimizing/register_allocator_graph_color.cc
+++ b/compiler/optimizing/register_allocator_graph_color.cc
@@ -1044,13 +1044,16 @@ void RegisterAllocatorGraphColor::SplitAtRegisterUses(LiveInterval* interval) {
}
void RegisterAllocatorGraphColor::AllocateSpillSlotForCatchPhi(HInstruction* instruction) {
- if (instruction->IsPhi() && instruction->AsPhi()->IsCatchPhi()) {
- HPhi* phi = instruction->AsPhi();
+ // TODO: Remove "OrNull".
+ if (instruction->IsPhi() && instruction->AsPhiOrNull()->IsCatchPhi()) {
+ // TODO: Remove "OrNull".
+ HPhi* phi = instruction->AsPhiOrNull();
LiveInterval* interval = phi->GetLiveInterval();
HInstruction* previous_phi = phi->GetPrevious();
DCHECK(previous_phi == nullptr ||
- previous_phi->AsPhi()->GetRegNumber() <= phi->GetRegNumber())
+ // TODO: Remove "OrNull".
+ previous_phi->AsPhiOrNull()->GetRegNumber() <= phi->GetRegNumber())
<< "Phis expected to be sorted by vreg number, "
<< "so that equivalent phis are adjacent.";
@@ -1953,7 +1956,8 @@ void RegisterAllocatorGraphColor::AllocateSpillSlots(ArrayRef<InterferenceNode*
// We already have a spill slot for this value that we can reuse.
} else if (defined_by->IsParameterValue()) {
// Parameters already have a stack slot.
- parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValue()));
+ // TODO: Remove "OrNull".
+ parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValueOrNull()));
} 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 ffa9937cc5..cbb9002c46 100644
--- a/compiler/optimizing/register_allocator_linear_scan.cc
+++ b/compiler/optimizing/register_allocator_linear_scan.cc
@@ -259,8 +259,10 @@ void RegisterAllocatorLinearScan::ProcessInstruction(HInstruction* instruction)
current->ResetSearchCache();
CheckForFixedOutput(instruction);
- if (instruction->IsPhi() && instruction->AsPhi()->IsCatchPhi()) {
- AllocateSpillSlotForCatchPhi(instruction->AsPhi());
+ // TODO: Remove "OrNull".
+ if (instruction->IsPhi() && instruction->AsPhiOrNull()->IsCatchPhi()) {
+ // TODO: Remove "OrNull".
+ AllocateSpillSlotForCatchPhi(instruction->AsPhiOrNull());
}
// If needed, add interval to the list of unhandled intervals.
@@ -1128,11 +1130,13 @@ void RegisterAllocatorLinearScan::AllocateSpillSlotFor(LiveInterval* interval) {
}
HInstruction* defined_by = parent->GetDefinedBy();
- DCHECK_IMPLIES(defined_by->IsPhi(), !defined_by->AsPhi()->IsCatchPhi());
+ // TODO: Remove "OrNull".
+ DCHECK_IMPLIES(defined_by->IsPhi(), !defined_by->AsPhiOrNull()->IsCatchPhi());
if (defined_by->IsParameterValue()) {
// Parameters have their own stack slot.
- parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValue()));
+ // TODO: Remove "OrNull".
+ parent->SetSpillSlot(codegen_->GetStackSlotOfParameter(defined_by->AsParameterValueOrNull()));
return;
}
@@ -1208,7 +1212,9 @@ void RegisterAllocatorLinearScan::AllocateSpillSlotForCatchPhi(HPhi* phi) {
LiveInterval* interval = phi->GetLiveInterval();
HInstruction* previous_phi = phi->GetPrevious();
- DCHECK(previous_phi == nullptr || previous_phi->AsPhi()->GetRegNumber() <= phi->GetRegNumber())
+ DCHECK(previous_phi == nullptr ||
+ // TODO: Remove "OrNull".
+ previous_phi->AsPhiOrNull()->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 d316aa5dc2..a123bf858e 100644
--- a/compiler/optimizing/register_allocator_test.cc
+++ b/compiler/optimizing/register_allocator_test.cc
@@ -338,7 +338,8 @@ void RegisterAllocatorTest::Loop3(Strategy strategy) {
ASSERT_TRUE(register_allocator->Validate(false));
HBasicBlock* loop_header = graph->GetBlocks()[2];
- HPhi* phi = loop_header->GetFirstPhi()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = loop_header->GetFirstPhi()->AsPhiOrNull();
LiveInterval* phi_interval = phi->GetLiveInterval();
LiveInterval* loop_update = phi->InputAt(1)->GetLiveInterval();
@@ -347,7 +348,8 @@ void RegisterAllocatorTest::Loop3(Strategy strategy) {
ASSERT_NE(phi_interval->GetRegister(), loop_update->GetRegister());
HBasicBlock* return_block = graph->GetBlocks()[3];
- HReturn* ret = return_block->GetLastInstruction()->AsReturn();
+ // TODO: Remove "OrNull".
+ HReturn* ret = return_block->GetLastInstruction()->AsReturnOrNull();
ASSERT_EQ(phi_interval->GetRegister(), ret->InputAt(0)->GetLiveInterval()->GetRegister());
}
@@ -366,8 +368,10 @@ TEST_F(RegisterAllocatorTest, FirstRegisterUse) {
SsaLivenessAnalysis liveness(graph, &codegen, GetScopedAllocator());
liveness.Analyze();
- HXor* first_xor = graph->GetBlocks()[1]->GetFirstInstruction()->AsXor();
- HXor* last_xor = graph->GetBlocks()[1]->GetLastInstruction()->GetPrevious()->AsXor();
+ // TODO: Remove "OrNull".
+ HXor* first_xor = graph->GetBlocks()[1]->GetFirstInstruction()->AsXorOrNull();
+ // TODO: Remove "OrNull".
+ HXor* last_xor = graph->GetBlocks()[1]->GetLastInstruction()->GetPrevious()->AsXorOrNull();
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 116f52605e..299418adfe 100644
--- a/compiler/optimizing/scheduler.cc
+++ b/compiler/optimizing/scheduler.cc
@@ -150,7 +150,8 @@ size_t SideEffectDependencyAnalysis::MemoryDependencyAnalysis::FieldAccessHeapLo
DCHECK(heap_location_collector_ != nullptr);
HInstruction* ref = instr->IsPredicatedInstanceFieldGet()
- ? instr->AsPredicatedInstanceFieldGet()->GetTarget()
+ // TODO: Remove "OrNull".
+ ? instr->AsPredicatedInstanceFieldGetOrNull()->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.
@@ -490,9 +491,11 @@ SchedulingNode* CriticalPathSchedulingNodeSelector::SelectMaterializedCondition(
DCHECK(instruction != nullptr);
if (instruction->IsIf()) {
- condition = instruction->AsIf()->InputAt(0)->AsCondition();
+ // TODO: Remove first "OrNull", keep the second.
+ condition = instruction->AsIfOrNull()->InputAt(0)->AsConditionOrNull();
} else if (instruction->IsSelect()) {
- condition = instruction->AsSelect()->GetCondition()->AsCondition();
+ // TODO: Remove first "OrNull", keep the second.
+ condition = instruction->AsSelectOrNull()->GetCondition()->AsConditionOrNull();
}
SchedulingNode* condition_node = (condition != nullptr) ? graph.GetNode(condition) : nullptr;
@@ -733,10 +736,15 @@ bool HScheduler::IsSchedulable(const HInstruction* instruction) const {
instruction->IsClassTableGet() ||
instruction->IsCurrentMethod() ||
instruction->IsDivZeroCheck() ||
- (instruction->IsInstanceFieldGet() && !instruction->AsInstanceFieldGet()->IsVolatile()) ||
+ (instruction->IsInstanceFieldGet() &&
+ // TODO: Remove "OrNull".
+ !instruction->AsInstanceFieldGetOrNull()->IsVolatile()) ||
(instruction->IsPredicatedInstanceFieldGet() &&
- !instruction->AsPredicatedInstanceFieldGet()->IsVolatile()) ||
- (instruction->IsInstanceFieldSet() && !instruction->AsInstanceFieldSet()->IsVolatile()) ||
+ // TODO: Remove "OrNull".
+ !instruction->AsPredicatedInstanceFieldGetOrNull()->IsVolatile()) ||
+ (instruction->IsInstanceFieldSet() &&
+ // TODO: Remove "OrNull".
+ !instruction->AsInstanceFieldSetOrNull()->IsVolatile()) ||
instruction->IsInstanceOf() ||
instruction->IsInvokeInterface() ||
instruction->IsInvokeStaticOrDirect() ||
@@ -752,8 +760,12 @@ bool HScheduler::IsSchedulable(const HInstruction* instruction) const {
instruction->IsReturn() ||
instruction->IsReturnVoid() ||
instruction->IsSelect() ||
- (instruction->IsStaticFieldGet() && !instruction->AsStaticFieldGet()->IsVolatile()) ||
- (instruction->IsStaticFieldSet() && !instruction->AsStaticFieldSet()->IsVolatile()) ||
+ (instruction->IsStaticFieldGet() &&
+ // TODO: Remove "OrNull".
+ !instruction->AsStaticFieldGetOrNull()->IsVolatile()) ||
+ (instruction->IsStaticFieldSet() &&
+ // TODO: Remove "OrNull".
+ !instruction->AsStaticFieldSetOrNull()->IsVolatile()) ||
instruction->IsSuspendCheck() ||
instruction->IsTypeConversion();
}
diff --git a/compiler/optimizing/scheduler_arm.cc b/compiler/optimizing/scheduler_arm.cc
index 3f931c4c49..cded09ac67 100644
--- a/compiler/optimizing/scheduler_arm.cc
+++ b/compiler/optimizing/scheduler_arm.cc
@@ -109,7 +109,8 @@ void SchedulingLatencyVisitorARM::VisitRor(HRor* instr) {
// HandleLongRotate
HInstruction* rhs = instr->GetRight();
if (rhs->IsConstant()) {
- uint64_t rot = Uint64ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance;
+ // TODO: Remove "OrNull".
+ uint64_t rot = Uint64ConstantFrom(rhs->AsConstantOrNull()) & kMaxLongShiftDistance;
if (rot != 0u) {
last_visited_internal_latency_ = 3 * kArmIntegerOpLatency;
last_visited_latency_ = kArmIntegerOpLatency;
@@ -143,7 +144,8 @@ void SchedulingLatencyVisitorARM::HandleShiftLatencies(HBinaryOperation* instr)
if (!rhs->IsConstant()) {
last_visited_internal_latency_ = 8 * kArmIntegerOpLatency;
} else {
- uint32_t shift_value = Int32ConstantFrom(rhs->AsConstant()) & kMaxLongShiftDistance;
+ // TODO: Remove "OrNull".
+ uint32_t shift_value = Int32ConstantFrom(rhs->AsConstantOrNull()) & kMaxLongShiftDistance;
if (shift_value == 1 || shift_value >= 32) {
last_visited_internal_latency_ = kArmIntegerOpLatency;
} else {
@@ -833,7 +835,8 @@ void SchedulingLatencyVisitorARM::VisitDiv(HDiv* instruction) {
case DataType::Type::kInt32: {
HInstruction* rhs = instruction->GetRight();
if (rhs->IsConstant()) {
- int32_t imm = Int32ConstantFrom(rhs->AsConstant());
+ // TODO: Remove "OrNull".
+ int32_t imm = Int32ConstantFrom(rhs->AsConstantOrNull());
HandleDivRemConstantIntegralLatencies(imm);
} else {
last_visited_latency_ = kArmDivIntegerLatency;
@@ -901,7 +904,8 @@ void SchedulingLatencyVisitorARM::VisitRem(HRem* instruction) {
case DataType::Type::kInt32: {
HInstruction* rhs = instruction->GetRight();
if (rhs->IsConstant()) {
- int32_t imm = Int32ConstantFrom(rhs->AsConstant());
+ // TODO: Remove "OrNull".
+ int32_t imm = Int32ConstantFrom(rhs->AsConstantOrNull());
HandleDivRemConstantIntegralLatencies(imm);
} else {
last_visited_internal_latency_ = kArmDivIntegerLatency;
diff --git a/compiler/optimizing/scheduler_arm64.cc b/compiler/optimizing/scheduler_arm64.cc
index 3071afd951..0c178f6d6e 100644
--- a/compiler/optimizing/scheduler_arm64.cc
+++ b/compiler/optimizing/scheduler_arm64.cc
@@ -91,7 +91,8 @@ void SchedulingLatencyVisitorARM64::VisitDiv(HDiv* instr) {
default:
// Follow the code path used by code generation.
if (instr->GetRight()->IsConstant()) {
- int64_t imm = Int64FromConstant(instr->GetRight()->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t imm = Int64FromConstant(instr->GetRight()->AsConstantOrNull());
if (imm == 0) {
last_visited_internal_latency_ = 0;
last_visited_latency_ = 0;
@@ -159,7 +160,8 @@ void SchedulingLatencyVisitorARM64::VisitRem(HRem* instruction) {
} else {
// Follow the code path used by code generation.
if (instruction->GetRight()->IsConstant()) {
- int64_t imm = Int64FromConstant(instruction->GetRight()->AsConstant());
+ // TODO: Remove "OrNull".
+ int64_t imm = Int64FromConstant(instruction->GetRight()->AsConstantOrNull());
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 07065efbb7..54eac54c01 100644
--- a/compiler/optimizing/select_generator.cc
+++ b/compiler/optimizing/select_generator.cc
@@ -46,7 +46,9 @@ static bool IsSimpleBlock(HBasicBlock* block) {
} else if (instruction->CanBeMoved() &&
!instruction->HasSideEffects() &&
!instruction->CanThrow()) {
- if (instruction->IsSelect() && instruction->AsSelect()->GetCondition()->GetBlock() == block) {
+ if (instruction->IsSelect() &&
+ // TODO: Remove "OrNull".
+ instruction->AsSelectOrNull()->GetCondition()->GetBlock() == block) {
// Count one HCondition and HSelect in the same block as a single instruction.
// This enables finding nested selects.
continue;
@@ -75,7 +77,8 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) {
HPhi* select_phi = nullptr;
for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
- HPhi* phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.Current()->AsPhiOrNull();
if (select_phi == nullptr) {
// First phi found.
select_phi = phi;
@@ -90,7 +93,8 @@ static HPhi* GetSinglePhi(HBasicBlock* block, size_t index1, size_t index2) {
bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern(
HBasicBlock* block, ScopedArenaSafeMap<HInstruction*, HSelect*>* cache) {
DCHECK(block->GetLastInstruction()->IsIf());
- HIf* if_instruction = block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull();
HBasicBlock* true_block = if_instruction->IfTrueSuccessor();
HBasicBlock* false_block = if_instruction->IfFalseSuccessor();
DCHECK_NE(true_block, false_block);
@@ -216,7 +220,8 @@ bool HSelectGenerator::TryGenerateSelectSimpleDiamondPattern(
HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block) {
DCHECK(block->GetLastInstruction()->IsIf());
- HIf* if_instruction = block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* if_instruction = block->GetLastInstruction()->AsIfOrNull();
HBasicBlock* true_block = if_instruction->IfTrueSuccessor();
HBasicBlock* false_block = if_instruction->IfFalseSuccessor();
DCHECK_NE(true_block, false_block);
@@ -231,7 +236,8 @@ 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() ||
- inner_if_block->GetLastInstruction()->AsIf()->InputAt(0) !=
+ // TODO: Remove "OrNull".
+ inner_if_block->GetLastInstruction()->AsIfOrNull()->InputAt(0) !=
inner_if_block->GetFirstInstruction() ||
inner_if_block->GetLastInstruction()->GetPrevious() !=
inner_if_block->GetFirstInstruction() ||
@@ -239,7 +245,8 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block)
return nullptr;
}
- HIf* inner_if_instruction = inner_if_block->GetLastInstruction()->AsIf();
+ // TODO: Remove "OrNull".
+ HIf* inner_if_instruction = inner_if_block->GetLastInstruction()->AsIfOrNull();
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()) {
@@ -262,7 +269,8 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block)
return nullptr;
}
- HPhi* first_phi = first_merge->GetFirstPhi()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* first_phi = first_merge->GetFirstPhi()->AsPhiOrNull();
// 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.
@@ -284,7 +292,8 @@ HBasicBlock* HSelectGenerator::TryFixupDoubleDiamondPattern(HBasicBlock* block)
}
size_t index = second_merge->GetPredecessorIndexOf(merges_into_second_merge);
- HPhi* second_phi = second_merge->GetFirstPhi()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* second_phi = second_merge->GetFirstPhi()->AsPhiOrNull();
// 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 08ccbeee0d..09ca850eee 100644
--- a/compiler/optimizing/ssa_builder.cc
+++ b/compiler/optimizing/ssa_builder.cc
@@ -56,7 +56,8 @@ 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();
- DCHECK_EQ(0, int_operand->AsIntConstant()->GetValue());
+ // TODO: Remove "OrNull".
+ DCHECK_EQ(0, int_operand->AsIntConstantOrNull()->GetValue());
equality_instr->ReplaceInput(graph_->GetNullConstant(), int_operand == right ? 1 : 0);
}
}
@@ -66,7 +67,8 @@ void SsaBuilder::EquivalentPhisCleanup() {
// The order doesn't matter here.
for (HBasicBlock* block : graph_->GetReversePostOrder()) {
for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
- HPhi* phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.Current()->AsPhiOrNull();
HPhi* next = phi->GetNextEquivalentPhiWithSameType();
if (next != nullptr) {
// Make sure we do not replace a live phi with a dead phi. A live phi
@@ -88,18 +90,21 @@ void SsaBuilder::EquivalentPhisCleanup() {
void SsaBuilder::FixEnvironmentPhis() {
for (HBasicBlock* block : graph_->GetReversePostOrder()) {
for (HInstructionIterator it_phis(block->GetPhis()); !it_phis.Done(); it_phis.Advance()) {
- HPhi* phi = it_phis.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it_phis.Current()->AsPhiOrNull();
// 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;
- if (next->AsPhi()->IsDead()) {
+ // TODO: Remove "OrNull".
+ if (next->AsPhiOrNull()->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()));
- if (next->AsPhi()->IsDead()) continue;
+ // TODO: Remove "OrNull".
+ if (next->AsPhiOrNull()->IsDead()) continue;
}
// We found a live phi equivalent. Update the environment uses of `phi` with it.
phi->ReplaceWith(next);
@@ -113,12 +118,15 @@ 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.
- bool add_all_live_phis = instruction->IsPhi() && instruction->AsPhi()->IsDead();
+ // TODO: Remove "OrNull".
+ bool add_all_live_phis = instruction->IsPhi() && instruction->AsPhiOrNull()->IsDead();
for (const HUseListNode<HInstruction*>& use : instruction->GetUses()) {
HInstruction* user = use.GetUser();
- if (user->IsPhi() && user->AsPhi()->IsLive()) {
+ // TODO: Remove "OrNull".
+ if (user->IsPhi() && user->AsPhiOrNull()->IsLive()) {
if (add_all_live_phis || user->GetType() != instruction->GetType()) {
- worklist->push_back(user->AsPhi());
+ // TODO: Remove "OrNull".
+ worklist->push_back(user->AsPhiOrNull());
}
}
}
@@ -130,7 +138,8 @@ static bool TypePhiFromInputs(HPhi* phi) {
DataType::Type common_type = phi->GetType();
for (HInstruction* input : phi->GetInputs()) {
- if (input->IsPhi() && input->AsPhi()->IsDead()) {
+ // TODO: Remove "OrNull".
+ if (input->IsPhi() && input->AsPhiOrNull()->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;
@@ -204,7 +213,8 @@ bool SsaBuilder::TypeInputsOfPhi(HPhi* phi, ScopedArenaVector<HPhi*>* worklist)
phi->ReplaceInput(equivalent, i);
if (equivalent->IsPhi()) {
- worklist->push_back(equivalent->AsPhi());
+ // TODO: Remove "OrNull".
+ worklist->push_back(equivalent->AsPhiOrNull());
}
}
}
@@ -241,7 +251,8 @@ void SsaBuilder::RunPrimitiveTypePropagation() {
for (HBasicBlock* block : graph_->GetReversePostOrder()) {
if (block->IsLoopHeader()) {
for (HInstructionIterator phi_it(block->GetPhis()); !phi_it.Done(); phi_it.Advance()) {
- HPhi* phi = phi_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = phi_it.Current()->AsPhiOrNull();
if (phi->IsLive()) {
worklist.push_back(phi);
}
@@ -253,7 +264,8 @@ 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.
- HPhi* phi = phi_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = phi_it.Current()->AsPhiOrNull();
if (phi->IsLive()) {
UpdatePrimitiveType(phi, &worklist);
}
@@ -283,7 +295,8 @@ static HArrayGet* FindFloatOrDoubleEquivalentOfArrayGet(HArrayGet* aget) {
DCHECK(DataType::IsIntOrLongType(type));
HInstruction* next = aget->GetNext();
if (next != nullptr && next->IsArrayGet()) {
- HArrayGet* next_aget = next->AsArrayGet();
+ // TODO: Remove "OrNull".
+ HArrayGet* next_aget = next->AsArrayGetOrNull();
if (next_aget->IsEquivalentOf(aget)) {
return next_aget;
}
@@ -395,7 +408,8 @@ 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.
- worklist.push_back(equivalent->AsPhi());
+ // TODO: Remove "OrNull".
+ worklist.push_back(equivalent->AsPhiOrNull());
}
}
// Refine the side effects of this floating point aset. Note that we do this even if
@@ -442,7 +456,8 @@ bool SsaBuilder::ReplaceUninitializedStringPhis() {
return false;
}
DCHECK(str->IsNewInstance());
- AddUninitializedString(str->AsNewInstance());
+ // TODO: Remove "OrNull".
+ AddUninitializedString(str->AsNewInstanceOrNull());
str->ReplaceUsesDominatedBy(invoke, invoke);
str->ReplaceEnvUsesDominatedBy(invoke, invoke);
invoke->RemoveInputAt(invoke->InputCount() - 1);
@@ -478,11 +493,13 @@ void SsaBuilder::RemoveRedundantUninitializedStrings() {
// class is always initialized at the point of running Java code, we can remove
// that check.
if (input->IsClinitCheck()) {
- load_class = input->InputAt(0)->AsLoadClass();
+ // TODO: Remove "OrNull".
+ load_class = input->InputAt(0)->AsLoadClassOrNull();
input->ReplaceWith(load_class);
input->GetBlock()->RemoveInstruction(input);
} else {
- load_class = input->AsLoadClass();
+ // TODO: Remove "OrNull".
+ load_class = input->AsLoadClassOrNull();
DCHECK(new_instance->IsStringAlloc());
DCHECK(!load_class->NeedsAccessCheck()) << "String class is always accessible";
}
@@ -503,7 +520,8 @@ static bool HasPhiEquivalentAtLoopEntry(HGraph* graph) {
for (HBasicBlock* block : graph->GetReversePostOrder()) {
if (block->IsLoopHeader()) {
for (HInstructionIterator it(block->GetPhis()); !it.Done(); it.Advance()) {
- if (it.Current()->AsPhi()->HasEquivalentPhi()) {
+ // TODO: Remove "OrNull".
+ if (it.Current()->AsPhiOrNull()->HasEquivalentPhi()) {
return true;
}
}
@@ -604,7 +622,7 @@ GraphAnalysisResult SsaBuilder::BuildSsa() {
*/
HFloatConstant* SsaBuilder::GetFloatEquivalent(HIntConstant* constant) {
// We place the floating point constant next to this constant.
- HFloatConstant* result = constant->GetNext()->AsFloatConstant();
+ HFloatConstant* result = constant->GetNext()->AsFloatConstantOrNull();
if (result == nullptr) {
float value = bit_cast<float, int32_t>(constant->GetValue());
result = new (graph_->GetAllocator()) HFloatConstant(value);
@@ -626,7 +644,7 @@ HFloatConstant* SsaBuilder::GetFloatEquivalent(HIntConstant* constant) {
*/
HDoubleConstant* SsaBuilder::GetDoubleEquivalent(HLongConstant* constant) {
// We place the floating point constant next to this constant.
- HDoubleConstant* result = constant->GetNext()->AsDoubleConstant();
+ HDoubleConstant* result = constant->GetNext()->AsDoubleConstantOrNull();
if (result == nullptr) {
double value = bit_cast<double, int64_t>(constant->GetValue());
result = new (graph_->GetAllocator()) HDoubleConstant(value);
@@ -653,14 +671,16 @@ HPhi* SsaBuilder::GetFloatDoubleOrReferenceEquivalentOfPhi(HPhi* phi, DataType::
// We place the floating point /reference phi next to this phi.
HInstruction* next = phi->GetNext();
if (next != nullptr &&
- next->AsPhi()->GetRegNumber() == phi->GetRegNumber() &&
+ // TODO: Remove "OrNull".
+ next->AsPhiOrNull()->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 ||
- (next->AsPhi()->GetRegNumber() != phi->GetRegNumber()) ||
+ // TODO: Remove "OrNull".
+ (next->AsPhiOrNull()->GetRegNumber() != phi->GetRegNumber()) ||
(next->GetType() != type)) {
ArenaAllocator* allocator = graph_->GetAllocator();
HInputsRef inputs = phi->GetInputs();
@@ -677,7 +697,8 @@ 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.
- HPhi* next_phi = next->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* next_phi = next->AsPhiOrNull();
DCHECK_EQ(next_phi->GetType(), type);
return next_phi->IsLive() ? next_phi : nullptr;
}
@@ -710,23 +731,30 @@ HArrayGet* SsaBuilder::GetFloatOrDoubleEquivalentOfArrayGet(HArrayGet* aget) {
HInstruction* SsaBuilder::GetFloatOrDoubleEquivalent(HInstruction* value, DataType::Type type) {
if (value->IsArrayGet()) {
- return GetFloatOrDoubleEquivalentOfArrayGet(value->AsArrayGet());
+ // TODO: Remove "OrNull".
+ return GetFloatOrDoubleEquivalentOfArrayGet(value->AsArrayGetOrNull());
} else if (value->IsLongConstant()) {
- return GetDoubleEquivalent(value->AsLongConstant());
+ // TODO: Remove "OrNull".
+ return GetDoubleEquivalent(value->AsLongConstantOrNull());
} else if (value->IsIntConstant()) {
- return GetFloatEquivalent(value->AsIntConstant());
+ // TODO: Remove "OrNull".
+ return GetFloatEquivalent(value->AsIntConstantOrNull());
} else if (value->IsPhi()) {
- return GetFloatDoubleOrReferenceEquivalentOfPhi(value->AsPhi(), type);
+ // TODO: Remove "OrNull".
+ return GetFloatDoubleOrReferenceEquivalentOfPhi(value->AsPhiOrNull(), type);
} else {
return nullptr;
}
}
HInstruction* SsaBuilder::GetReferenceTypeEquivalent(HInstruction* value) {
- if (value->IsIntConstant() && value->AsIntConstant()->GetValue() == 0) {
+ // TODO: Remove "OrNull".
+ if (value->IsIntConstant() && value->AsIntConstantOrNull()->GetValue() == 0) {
return graph_->GetNullConstant();
} else if (value->IsPhi()) {
- return GetFloatDoubleOrReferenceEquivalentOfPhi(value->AsPhi(), DataType::Type::kReference);
+ // TODO: Remove "OrNull".
+ return GetFloatDoubleOrReferenceEquivalentOfPhi(
+ value->AsPhiOrNull(), DataType::Type::kReference);
} else {
return nullptr;
}
diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc
index 317e0999d7..b36ccbe02b 100644
--- a/compiler/optimizing/ssa_liveness_analysis.cc
+++ b/compiler/optimizing/ssa_liveness_analysis.cc
@@ -496,7 +496,8 @@ size_t LiveInterval::NumberOfSpillSlotsNeeded() const {
if (definition->IsPhi()) {
definition = definition->InputAt(1); // SIMD always appears on back-edge
}
- return definition->AsVecOperation()->GetVectorNumberOfBytes() / kVRegSize;
+ // TODO: Remove "OrNull".
+ return definition->AsVecOperationOrNull()->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 ce343dffec..2a1697d7a2 100644
--- a/compiler/optimizing/ssa_phi_elimination.cc
+++ b/compiler/optimizing/ssa_phi_elimination.cc
@@ -45,7 +45,8 @@ 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()) {
- HPhi* phi = inst_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = inst_it.Current()->AsPhiOrNull();
if (phi->IsDead()) {
continue;
}
@@ -76,7 +77,7 @@ void SsaDeadPhiElimination::MarkDeadPhis() {
HPhi* phi = worklist.back();
worklist.pop_back();
for (HInstruction* raw_input : phi->GetInputs()) {
- HPhi* input = raw_input->AsPhi();
+ HPhi* input = raw_input->AsPhiOrNull();
if (input != nullptr && input->IsDead()) {
// Input is a dead phi. Revive it and add to the worklist. We make sure
// that the phi was not dead initially (see definition of `initially_live`).
@@ -97,7 +98,8 @@ void SsaDeadPhiElimination::EliminateDeadPhis() {
HInstruction* next = nullptr;
HPhi* phi;
while (current != nullptr) {
- phi = current->AsPhi();
+ // TODO: Remove "OrNull".
+ phi = current->AsPhiOrNull();
next = current->GetNext();
if (phi->IsDead()) {
// Make sure the phi is only used by other dead phis.
@@ -105,7 +107,8 @@ void SsaDeadPhiElimination::EliminateDeadPhis() {
for (const HUseListNode<HInstruction*>& use : phi->GetUses()) {
HInstruction* user = use.GetUser();
DCHECK(user->IsLoopHeaderPhi());
- DCHECK(user->AsPhi()->IsDead());
+ // TODO: Remove "OrNull".
+ DCHECK(user->AsPhiOrNull()->IsDead());
}
}
// Remove the phi from use lists of its inputs.
@@ -135,7 +138,8 @@ 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()) {
- worklist.push_back(inst_it.Current()->AsPhi());
+ // TODO: Remove "OrNull".
+ worklist.push_back(inst_it.Current()->AsPhiOrNull());
}
}
@@ -197,9 +201,11 @@ bool SsaRedundantPhiElimination::Run() {
continue;
} else if (input->IsPhi()) {
if (!visited_phis_in_cycle.IsBitSet(input->GetId())) {
- cycle_worklist.push_back(input->AsPhi());
+ // TODO: Remove "OrNull".
+ cycle_worklist.push_back(input->AsPhiOrNull());
visited_phis_in_cycle.SetBit(input->GetId());
- catch_phi_in_cycle |= input->AsPhi()->IsCatchPhi();
+ // TODO: Remove "OrNull".
+ catch_phi_in_cycle |= input->AsPhiOrNull()->IsCatchPhi();
irreducible_loop_phi_in_cycle |= input->IsIrreducibleLoopHeaderPhi();
} else {
// Already visited, nothing to do.
@@ -248,7 +254,8 @@ bool SsaRedundantPhiElimination::Run() {
for (const HUseListNode<HInstruction*>& use : current->GetUses()) {
HInstruction* user = use.GetUser();
if (user->IsPhi() && !visited_phis_in_cycle.IsBitSet(user->GetId())) {
- worklist.push_back(user->AsPhi());
+ // TODO: Remove "OrNull".
+ worklist.push_back(user->AsPhiOrNull());
}
}
DCHECK(candidate->StrictlyDominates(current));
diff --git a/compiler/optimizing/superblock_cloner.cc b/compiler/optimizing/superblock_cloner.cc
index 7c0097c6f6..f323c8af2d 100644
--- a/compiler/optimizing/superblock_cloner.cc
+++ b/compiler/optimizing/superblock_cloner.cc
@@ -175,8 +175,10 @@ 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()) {
- HPhi* orig_phi = it.Current()->AsPhi();
- HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* orig_phi = it.Current()->AsPhiOrNull();
+ // TODO: Remove "OrNull".
+ HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull();
HInstruction* orig_phi_input = orig_phi->InputAt(this_index);
// Remove corresponding input for original phi.
orig_phi->RemoveInputAt(this_index);
@@ -205,8 +207,10 @@ 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()) {
- HPhi* orig_phi = it.Current()->AsPhi();
- HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* orig_phi = it.Current()->AsPhiOrNull();
+ // TODO: Remove "OrNull".
+ HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull();
HInstruction* orig_phi_input = orig_phi->InputAt(orig_index);
copy_phi->AddInput(orig_phi_input);
}
@@ -221,7 +225,8 @@ 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()) {
- HPhi* orig_phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* orig_phi = it.Current()->AsPhiOrNull();
HInstruction* orig_phi_input = orig_phi->InputAt(orig_index);
orig_phi->AddInput(orig_phi_input);
}
@@ -249,8 +254,10 @@ 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()) {
- HPhi* orig_phi = it.Current()->AsPhi();
- HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* orig_phi = it.Current()->AsPhiOrNull();
+ // TODO: Remove "OrNull".
+ HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull();
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);
@@ -547,8 +554,10 @@ void SuperblockCloner::ResolveDataFlow() {
HBasicBlock* orig_block = entry.first;
for (HInstructionIterator it(orig_block->GetPhis()); !it.Done(); it.Advance()) {
- HPhi* orig_phi = it.Current()->AsPhi();
- HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* orig_phi = it.Current()->AsPhiOrNull();
+ // TODO: Remove "OrNull".
+ HPhi* copy_phi = GetInstrCopy(orig_phi)->AsPhiOrNull();
ResolvePhi(orig_phi);
ResolvePhi(copy_phi);
}
@@ -669,7 +678,8 @@ void SuperblockCloner::FixSubgraphClosedSSAAfterCloning() {
for (auto it : live_outs_) {
DCHECK(it.first != it.second);
HInstruction* orig_value = it.first;
- HPhi* phi = it.second->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = it.second->AsPhiOrNull();
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);
@@ -1001,7 +1011,8 @@ 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()) {
- HPhi* phi = inst_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = inst_it.Current()->AsPhiOrNull();
if (ArePhiInputsTheSame(phi)) {
phi->ReplaceWith(phi->InputAt(0));
orig_block->RemovePhi(phi);
@@ -1010,7 +1021,8 @@ void SuperblockCloner::CleanUp() {
HBasicBlock* copy_block = GetBlockCopy(orig_block);
for (HInstructionIterator inst_it(copy_block->GetPhis()); !inst_it.Done(); inst_it.Advance()) {
- HPhi* phi = inst_it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* phi = inst_it.Current()->AsPhiOrNull();
if (ArePhiInputsTheSame(phi)) {
phi->ReplaceWith(phi->InputAt(0));
copy_block->RemovePhi(phi);
@@ -1032,8 +1044,10 @@ 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_);
- copy_block->AddPhi(copy_instr->AsPhi());
- copy_instr->AsPhi()->RemoveAllInputs();
+ // TODO: Remove "OrNull".
+ copy_block->AddPhi(copy_instr->AsPhiOrNull());
+ // TODO: Remove "OrNull".
+ copy_instr->AsPhiOrNull()->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 ea2563ea7d..7c90562909 100644
--- a/compiler/optimizing/superblock_cloner_test.cc
+++ b/compiler/optimizing/superblock_cloner_test.cc
@@ -432,7 +432,8 @@ TEST_F(SuperblockClonerTest, LoopPeelingMultipleBackEdges) {
HInstructionIterator it(header->GetPhis());
DCHECK(!it.Done());
- HPhi* loop_phi = it.Current()->AsPhi();
+ // TODO: Remove "OrNull".
+ HPhi* loop_phi = it.Current()->AsPhiOrNull();
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 eb70b670fe..390c6e9f8f 100644
--- a/compiler/optimizing/write_barrier_elimination.cc
+++ b/compiler/optimizing/write_barrier_elimination.cc
@@ -52,10 +52,13 @@ class WBEVisitor final : public HGraphVisitor {
auto it = current_write_barriers_.find(obj);
if (it != current_write_barriers_.end()) {
DCHECK(it->second->IsInstanceFieldSet());
- DCHECK(it->second->AsInstanceFieldSet()->GetWriteBarrierKind() !=
+ // TODO: Remove "OrNull".
+ DCHECK(it->second->AsInstanceFieldSetOrNull()->GetWriteBarrierKind() !=
WriteBarrierKind::kDontEmit);
DCHECK_EQ(it->second->GetBlock(), instruction->GetBlock());
- it->second->AsInstanceFieldSet()->SetWriteBarrierKind(WriteBarrierKind::kEmitNoNullCheck);
+ // TODO: Remove "OrNull".
+ it->second->AsInstanceFieldSetOrNull()->SetWriteBarrierKind(
+ WriteBarrierKind::kEmitNoNullCheck);
instruction->SetWriteBarrierKind(WriteBarrierKind::kDontEmit);
MaybeRecordStat(stats_, MethodCompilationStat::kRemovedWriteBarrier);
} else {
@@ -79,9 +82,12 @@ class WBEVisitor final : public HGraphVisitor {
auto it = current_write_barriers_.find(cls);
if (it != current_write_barriers_.end()) {
DCHECK(it->second->IsStaticFieldSet());
- DCHECK(it->second->AsStaticFieldSet()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit);
+ // TODO: Remove "OrNull".
+ DCHECK(it->second->AsStaticFieldSetOrNull()->GetWriteBarrierKind() !=
+ WriteBarrierKind::kDontEmit);
DCHECK_EQ(it->second->GetBlock(), instruction->GetBlock());
- it->second->AsStaticFieldSet()->SetWriteBarrierKind(WriteBarrierKind::kEmitNoNullCheck);
+ // TODO: Remove "OrNull".
+ it->second->AsStaticFieldSetOrNull()->SetWriteBarrierKind(WriteBarrierKind::kEmitNoNullCheck);
instruction->SetWriteBarrierKind(WriteBarrierKind::kDontEmit);
MaybeRecordStat(stats_, MethodCompilationStat::kRemovedWriteBarrier);
} else {
@@ -107,10 +113,13 @@ class WBEVisitor final : public HGraphVisitor {
auto it = current_write_barriers_.find(arr);
if (it != current_write_barriers_.end()) {
DCHECK(it->second->IsArraySet());
- DCHECK(it->second->AsArraySet()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit);
+ // TODO: Remove "OrNull".
+ DCHECK(it->second->AsArraySetOrNull()->GetWriteBarrierKind() != WriteBarrierKind::kDontEmit);
DCHECK_EQ(it->second->GetBlock(), instruction->GetBlock());
// We never skip the null check in ArraySets so that value is already set.
- DCHECK(it->second->AsArraySet()->GetWriteBarrierKind() == WriteBarrierKind::kEmitNoNullCheck);
+ // TODO: Remove "OrNull".
+ DCHECK(it->second->AsArraySetOrNull()->GetWriteBarrierKind() ==
+ WriteBarrierKind::kEmitNoNullCheck);
instruction->SetWriteBarrierKind(WriteBarrierKind::kDontEmit);
MaybeRecordStat(stats_, MethodCompilationStat::kRemovedWriteBarrier);
} else {
diff --git a/compiler/optimizing/x86_memory_gen.cc b/compiler/optimizing/x86_memory_gen.cc
index e266618980..d86869ce0f 100644
--- a/compiler/optimizing/x86_memory_gen.cc
+++ b/compiler/optimizing/x86_memory_gen.cc
@@ -33,7 +33,7 @@ class MemoryOperandVisitor final : public HGraphVisitor {
private:
void VisitBoundsCheck(HBoundsCheck* check) override {
// Replace the length by the array itself, so that we can do compares to memory.
- HArrayLength* array_len = check->InputAt(1)->AsArrayLength();
+ HArrayLength* array_len = check->InputAt(1)->AsArrayLengthOrNull();
// We only want to replace an ArrayLength.
if (array_len == nullptr) {