Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 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 | #ifndef ART_COMPILER_OPTIMIZING_INLINER_H_ |
| 18 | #define ART_COMPILER_OPTIMIZING_INLINER_H_ |
| 19 | |
| 20 | #include "invoke_type.h" |
| 21 | #include "optimization.h" |
| 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | class CompilerDriver; |
| 26 | class DexCompilationUnit; |
| 27 | class HGraph; |
| 28 | class HInvoke; |
| 29 | class OptimizingCompilerStats; |
| 30 | |
| 31 | class HInliner : public HOptimization { |
| 32 | public: |
| 33 | HInliner(HGraph* outer_graph, |
| 34 | const DexCompilationUnit& outer_compilation_unit, |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 35 | const DexCompilationUnit& caller_compilation_unit, |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 36 | CompilerDriver* compiler_driver, |
Nicolas Geoffray | 454a481 | 2015-06-09 10:37:32 +0100 | [diff] [blame] | 37 | StackHandleScopeCollection* handles, |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 38 | OptimizingCompilerStats* stats, |
| 39 | size_t depth = 0) |
David Brazdil | 69ba7b7 | 2015-06-23 18:27:30 +0100 | [diff] [blame] | 40 | : HOptimization(outer_graph, kInlinerPassName, stats), |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 41 | outer_compilation_unit_(outer_compilation_unit), |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 42 | caller_compilation_unit_(caller_compilation_unit), |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 43 | compiler_driver_(compiler_driver), |
Nicolas Geoffray | 454a481 | 2015-06-09 10:37:32 +0100 | [diff] [blame] | 44 | depth_(depth), |
| 45 | handles_(handles) {} |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 46 | |
| 47 | void Run() OVERRIDE; |
| 48 | |
Andreas Gampe | 7c3952f | 2015-02-19 18:21:24 -0800 | [diff] [blame] | 49 | static constexpr const char* kInlinerPassName = "inliner"; |
| 50 | |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 51 | private: |
Vladimir Marko | b2c431e | 2015-08-19 12:45:42 +0000 | [diff] [blame^] | 52 | bool TryInline(HInvoke* invoke_instruction, uint32_t method_index) const; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 53 | bool TryBuildAndInline(ArtMethod* resolved_method, |
Nicolas Geoffray | c0365b1 | 2015-03-18 18:31:52 +0000 | [diff] [blame] | 54 | HInvoke* invoke_instruction, |
Nicolas Geoffray | d23eeef | 2015-05-18 22:31:29 +0100 | [diff] [blame] | 55 | bool same_dex_file) const; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 56 | |
| 57 | const DexCompilationUnit& outer_compilation_unit_; |
Nicolas Geoffray | 9437b78 | 2015-03-25 10:08:51 +0000 | [diff] [blame] | 58 | const DexCompilationUnit& caller_compilation_unit_; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 59 | CompilerDriver* const compiler_driver_; |
Nicolas Geoffray | ef87c5d | 2015-01-30 12:41:14 +0000 | [diff] [blame] | 60 | const size_t depth_; |
Nicolas Geoffray | 454a481 | 2015-06-09 10:37:32 +0100 | [diff] [blame] | 61 | StackHandleScopeCollection* const handles_; |
Nicolas Geoffray | e53798a | 2014-12-01 10:31:54 +0000 | [diff] [blame] | 62 | |
| 63 | DISALLOW_COPY_AND_ASSIGN(HInliner); |
| 64 | }; |
| 65 | |
| 66 | } // namespace art |
| 67 | |
| 68 | #endif // ART_COMPILER_OPTIMIZING_INLINER_H_ |