1556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain/*
2556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * Copyright (C) 2014 The Android Open Source Project
3556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain *
4556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * Licensed under the Apache License, Version 2.0 (the "License");
5556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * you may not use this file except in compliance with the License.
6556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * You may obtain a copy of the License at
7556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain *
8556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain *      http://www.apache.org/licenses/LICENSE-2.0
9556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain *
10556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * Unless required by applicable law or agreed to in writing, software
11556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * distributed under the License is distributed on an "AS IS" BASIS,
12556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * See the License for the specific language governing permissions and
14556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain * limitations under the License.
15556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain */
16556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain
1775be28332b278cff9039b54bfb228ac72f539cccRoland Levillain#include "optimization.h"
18556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain
19c7dd295a4e0cc1d15c0c96088e55a85389bade74Ian Rogers#include "base/dumpable.h"
2075be28332b278cff9039b54bfb228ac72f539cccRoland Levillain#include "graph_checker.h"
21556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain
22556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillainnamespace art {
23556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain
242d7352ba5311b8f57427b91b7a891e61497373c1David Brazdilvoid HOptimization::MaybeRecordStat(MethodCompilationStat compilation_stat, size_t count) const {
25acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle  if (stats_ != nullptr) {
262d7352ba5311b8f57427b91b7a891e61497373c1David Brazdil    stats_->RecordStat(compilation_stat, count);
27acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle  }
28acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle}
29acf735c13998ad2a175f5a17e7bfce220073279dCalin Juravle
3075be28332b278cff9039b54bfb228ac72f539cccRoland Levillainvoid HOptimization::Check() {
3175be28332b278cff9039b54bfb228ac72f539cccRoland Levillain  if (kIsDebugBuild) {
3275be28332b278cff9039b54bfb228ac72f539cccRoland Levillain    if (is_in_ssa_form_) {
3375be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      SSAChecker checker(graph_->GetArena(), graph_);
3475be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      checker.Run();
3575be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      if (!checker.IsValid()) {
363159674c0863f53cfbc1913d493550221ac47f02Nicolas Geoffray        LOG(FATAL) << "Error after " << GetPassName() << ": "
373159674c0863f53cfbc1913d493550221ac47f02Nicolas Geoffray                   << Dumpable<SSAChecker>(checker);
3875be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      }
3975be28332b278cff9039b54bfb228ac72f539cccRoland Levillain    } else {
4075be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      GraphChecker checker(graph_->GetArena(), graph_);
4175be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      checker.Run();
4275be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      if (!checker.IsValid()) {
433159674c0863f53cfbc1913d493550221ac47f02Nicolas Geoffray        LOG(FATAL) << "Error after " << GetPassName() << ": "
443159674c0863f53cfbc1913d493550221ac47f02Nicolas Geoffray                   << Dumpable<GraphChecker>(checker);
4575be28332b278cff9039b54bfb228ac72f539cccRoland Levillain      }
4675be28332b278cff9039b54bfb228ac72f539cccRoland Levillain    }
4775be28332b278cff9039b54bfb228ac72f539cccRoland Levillain  }
4875be28332b278cff9039b54bfb228ac72f539cccRoland Levillain}
49556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain
50556c3d193134f6461f3e1fe17c032b087c5931a0Roland Levillain}  // namespace art
51