blob: ffd75693133487756acaacf2b60320ffa624a28c [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
25class CompilerDriver;
26class DexCompilationUnit;
27class HGraph;
28class HInvoke;
29class OptimizingCompilerStats;
30
31class HInliner : public HOptimization {
32 public:
33 HInliner(HGraph* outer_graph,
34 const DexCompilationUnit& outer_compilation_unit,
Nicolas Geoffray9437b782015-03-25 10:08:51 +000035 const DexCompilationUnit& caller_compilation_unit,
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000036 CompilerDriver* compiler_driver,
Nicolas Geoffray454a4812015-06-09 10:37:32 +010037 StackHandleScopeCollection* handles,
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000038 OptimizingCompilerStats* stats,
39 size_t depth = 0)
David Brazdil69ba7b72015-06-23 18:27:30 +010040 : HOptimization(outer_graph, kInlinerPassName, stats),
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000041 outer_compilation_unit_(outer_compilation_unit),
Nicolas Geoffray9437b782015-03-25 10:08:51 +000042 caller_compilation_unit_(caller_compilation_unit),
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000043 compiler_driver_(compiler_driver),
Nicolas Geoffray454a4812015-06-09 10:37:32 +010044 depth_(depth),
45 handles_(handles) {}
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000046
47 void Run() OVERRIDE;
48
Andreas Gampe7c3952f2015-02-19 18:21:24 -080049 static constexpr const char* kInlinerPassName = "inliner";
50
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000051 private:
Vladimir Markob2c431e2015-08-19 12:45:42 +000052 bool TryInline(HInvoke* invoke_instruction, uint32_t method_index) const;
Mathieu Chartiere401d142015-04-22 13:56:20 -070053 bool TryBuildAndInline(ArtMethod* resolved_method,
Nicolas Geoffrayc0365b12015-03-18 18:31:52 +000054 HInvoke* invoke_instruction,
Nicolas Geoffrayd23eeef2015-05-18 22:31:29 +010055 bool same_dex_file) const;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000056
57 const DexCompilationUnit& outer_compilation_unit_;
Nicolas Geoffray9437b782015-03-25 10:08:51 +000058 const DexCompilationUnit& caller_compilation_unit_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000059 CompilerDriver* const compiler_driver_;
Nicolas Geoffrayef87c5d2015-01-30 12:41:14 +000060 const size_t depth_;
Nicolas Geoffray454a4812015-06-09 10:37:32 +010061 StackHandleScopeCollection* const handles_;
Nicolas Geoffraye53798a2014-12-01 10:31:54 +000062
63 DISALLOW_COPY_AND_ASSIGN(HInliner);
64};
65
66} // namespace art
67
68#endif // ART_COMPILER_OPTIMIZING_INLINER_H_