1 /* 2 * Copyright (C) 2014 The Android Open Source Project 3 * 4 * Licensed under the Apache License, Version 2.0 (the "License"); 5 * you may not use this file except in compliance with the License. 6 * You may obtain a copy of the License at 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 10 * Unless required by applicable law or agreed to in writing, software 11 * distributed under the License is distributed on an "AS IS" BASIS, 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 * See the License for the specific language governing permissions and 14 * limitations under the License. 15 */ 16 17 #include "pass_driver_me_opts.h" 18 19 #include "base/logging.h" 20 #include "base/macros.h" 21 #include "bb_optimizations.h" 22 #include "dataflow_iterator.h" 23 #include "dataflow_iterator-inl.h" 24 #include "pass_driver_me_opts.h" 25 #include "pass_manager.h" 26 #include "post_opt_passes.h" 27 28 namespace art { 29 SetupPasses(PassManager * pass_manager)30void PassDriverMEOpts::SetupPasses(PassManager* pass_manager) { 31 /* 32 * Create the pass list. These passes are immutable and are shared across the threads. 33 * 34 * Advantage is that there will be no race conditions here. 35 * Disadvantage is the passes can't change their internal states depending on CompilationUnit: 36 * - This is not yet an issue: no current pass would require it. 37 */ 38 pass_manager->AddPass(new StringChange); 39 pass_manager->AddPass(new CacheFieldLoweringInfo); 40 pass_manager->AddPass(new CacheMethodLoweringInfo); 41 pass_manager->AddPass(new CalculatePredecessors); 42 pass_manager->AddPass(new DFSOrders); 43 pass_manager->AddPass(new ClassInitCheckElimination); 44 pass_manager->AddPass(new SpecialMethodInliner); 45 pass_manager->AddPass(new NullCheckElimination); 46 pass_manager->AddPass(new BBCombine); 47 pass_manager->AddPass(new CodeLayout); 48 pass_manager->AddPass(new GlobalValueNumberingPass); 49 pass_manager->AddPass(new DeadCodeEliminationPass); 50 pass_manager->AddPass(new GlobalValueNumberingCleanupPass); 51 pass_manager->AddPass(new ConstantPropagation); 52 pass_manager->AddPass(new MethodUseCount); 53 pass_manager->AddPass(new BBOptimizations); 54 pass_manager->AddPass(new SuspendCheckElimination); 55 } 56 ApplyPass(PassDataHolder * data,const Pass * pass)57void PassDriverMEOpts::ApplyPass(PassDataHolder* data, const Pass* pass) { 58 const PassME* const pass_me = down_cast<const PassME*>(pass); 59 DCHECK(pass_me != nullptr); 60 PassMEDataHolder* const pass_me_data_holder = down_cast<PassMEDataHolder*>(data); 61 // Set to dirty. 62 pass_me_data_holder->dirty = true; 63 // First call the base class' version. 64 PassDriver::ApplyPass(data, pass); 65 // Now we care about flags. 66 if ((pass_me->GetFlag(kOptimizationBasicBlockChange) == true) || 67 (pass_me->GetFlag(kOptimizationDefUsesChange) == true)) { 68 // Is it dirty at least? 69 if (pass_me_data_holder->dirty == true) { 70 CompilationUnit* c_unit = pass_me_data_holder->c_unit; 71 c_unit->mir_graph.get()->CalculateBasicBlockInformation(post_opt_pass_manager_); 72 } 73 } 74 } 75 76 } // namespace art 77