summaryrefslogtreecommitdiff
path: root/compiler/optimizing/instruction_simplifier.cc
diff options
context:
space:
mode:
Diffstat (limited to 'compiler/optimizing/instruction_simplifier.cc')
-rw-r--r--compiler/optimizing/instruction_simplifier.cc18
1 files changed, 10 insertions, 8 deletions
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 049901b882..062b5a6b81 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -34,8 +34,12 @@ class InstructionSimplifierVisitor : public HGraphDelegateVisitor {
void RecordSimplification() {
simplification_occurred_ = true;
simplifications_at_current_position_++;
- if (stats_) {
- stats_->RecordStat(kInstructionSimplifications);
+ MaybeRecordStat(kInstructionSimplifications);
+ }
+
+ void MaybeRecordStat(MethodCompilationStat stat) {
+ if (stats_ != nullptr) {
+ stats_->RecordStat(stat);
}
}
@@ -463,9 +467,7 @@ void InstructionSimplifierVisitor::VisitCheckCast(HCheckCast* check_cast) {
if (object->IsNullConstant()) {
check_cast->GetBlock()->RemoveInstruction(check_cast);
- if (stats_ != nullptr) {
- stats_->RecordStat(MethodCompilationStat::kRemovedCheckedCast);
- }
+ MaybeRecordStat(MethodCompilationStat::kRemovedCheckedCast);
return;
}
@@ -473,9 +475,7 @@ void InstructionSimplifierVisitor::VisitCheckCast(HCheckCast* check_cast) {
if (TypeCheckHasKnownOutcome(load_class, object, &outcome)) {
if (outcome) {
check_cast->GetBlock()->RemoveInstruction(check_cast);
- if (stats_ != nullptr) {
- stats_->RecordStat(MethodCompilationStat::kRemovedCheckedCast);
- }
+ MaybeRecordStat(MethodCompilationStat::kRemovedCheckedCast);
if (!load_class->HasUses()) {
// We cannot rely on DCE to remove the class because the `HLoadClass` thinks it can throw.
// However, here we know that it cannot because the checkcast was successfull, hence
@@ -505,6 +505,7 @@ void InstructionSimplifierVisitor::VisitInstanceOf(HInstanceOf* instruction) {
HGraph* graph = GetGraph();
if (object->IsNullConstant()) {
+ MaybeRecordStat(kRemovedInstanceOf);
instruction->ReplaceWith(graph->GetIntConstant(0));
instruction->GetBlock()->RemoveInstruction(instruction);
RecordSimplification();
@@ -513,6 +514,7 @@ void InstructionSimplifierVisitor::VisitInstanceOf(HInstanceOf* instruction) {
bool outcome;
if (TypeCheckHasKnownOutcome(load_class, object, &outcome)) {
+ MaybeRecordStat(kRemovedInstanceOf);
if (outcome && can_be_null) {
// Type test will succeed, we just need a null test.
HNotEqual* test = new (graph->GetArena()) HNotEqual(graph->GetNullConstant(), object);