blob: 0f6a9453be7a3644606c27619814def6fd3ae011 [file] [log] [blame]
Nicolas Geoffraye53798a2014-12-01 10:31:54 +00001/*
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
23namespace art {
24
Vladimir Markodc151b22015-10-15 18:02:30 +010025class CodeGenerator;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000026class CompilerDriver;
27class DexCompilationUnit;
28class HGraph;
29class HInvoke;
30class OptimizingCompilerStats;
31
32class HInliner : public HOptimization {
33 public:
34 HInliner(HGraph* outer_graph,
Vladimir Markodc151b22015-10-15 18:02:30 +010035 CodeGenerator* codegen,
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000036 const DexCompilationUnit& outer_compilation_unit,
Nicolas Geoffray9437b782015-03-25 10:08:51 +000037 const DexCompilationUnit& caller_compilation_unit,
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000038 CompilerDriver* compiler_driver,
Nicolas Geoffray454a4812015-06-09 10:37:32 +010039 StackHandleScopeCollection* handles,
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000040 OptimizingCompilerStats* stats,
41 size_t depth = 0)
David Brazdil69ba7b72015-06-23 18:27:30 +010042 : HOptimization(outer_graph, kInlinerPassName, stats),
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000043 outer_compilation_unit_(outer_compilation_unit),
Nicolas Geoffray9437b782015-03-25 10:08:51 +000044 caller_compilation_unit_(caller_compilation_unit),
Vladimir Markodc151b22015-10-15 18:02:30 +010045 codegen_(codegen),
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000046 compiler_driver_(compiler_driver),
Nicolas Geoffray454a4812015-06-09 10:37:32 +010047 depth_(depth),
Nicolas Geoffraye418dda2015-08-11 20:03:09 -070048 number_of_inlined_instructions_(0),
Nicolas Geoffray454a4812015-06-09 10:37:32 +010049 handles_(handles) {}
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000050
51 void Run() OVERRIDE;
52
Andreas Gampe7c3952f2015-02-19 18:21:24 -080053 static constexpr const char* kInlinerPassName = "inliner";
54
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000055 private:
Nicolas Geoffraye418dda2015-08-11 20:03:09 -070056 bool TryInline(HInvoke* invoke_instruction);
Mathieu Chartiere401d142015-04-22 13:56:20 -070057 bool TryBuildAndInline(ArtMethod* resolved_method,
Nicolas Geoffrayc0365b12015-03-18 18:31:52 +000058 HInvoke* invoke_instruction,
Nicolas Geoffraye418dda2015-08-11 20:03:09 -070059 bool same_dex_file);
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000060
61 const DexCompilationUnit& outer_compilation_unit_;
Nicolas Geoffray9437b782015-03-25 10:08:51 +000062 const DexCompilationUnit& caller_compilation_unit_;
Vladimir Markodc151b22015-10-15 18:02:30 +010063 CodeGenerator* const codegen_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000064 CompilerDriver* const compiler_driver_;
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000065 const size_t depth_;
Nicolas Geoffraye418dda2015-08-11 20:03:09 -070066 size_t number_of_inlined_instructions_;
Nicolas Geoffray454a4812015-06-09 10:37:32 +010067 StackHandleScopeCollection* const handles_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000068
69 DISALLOW_COPY_AND_ASSIGN(HInliner);
70};
71
72} // namespace art
73
74#endif // ART_COMPILER_OPTIMIZING_INLINER_H_