blob: 5153a9e82e278c34d7ead1b68bb4d7c0b3ba5458 [file] [log] [blame]
Andreas Gampe53c913b2014-08-12 23:19:23 -07001/*
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_DEX_QUICK_QUICK_COMPILER_H_
18#define ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_
19
Mathieu Chartier5bdab122015-01-26 18:30:19 -080020#include "compiler.h"
21
Andreas Gampe53c913b2014-08-12 23:19:23 -070022namespace art {
23
24class Compiler;
25class CompilerDriver;
Mathieu Chartier5bdab122015-01-26 18:30:19 -080026class Mir2Lir;
27class PassManager;
Andreas Gampe53c913b2014-08-12 23:19:23 -070028
Mathieu Chartier5bdab122015-01-26 18:30:19 -080029class QuickCompiler : public Compiler {
30 public:
31 virtual ~QuickCompiler();
32
33 void Init() OVERRIDE;
34
35 void UnInit() const OVERRIDE;
36
37 bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const
38 OVERRIDE;
39
40 CompiledMethod* Compile(const DexFile::CodeItem* code_item,
41 uint32_t access_flags,
42 InvokeType invoke_type,
43 uint16_t class_def_idx,
44 uint32_t method_idx,
45 jobject class_loader,
46 const DexFile& dex_file) const OVERRIDE;
47
48 CompiledMethod* JniCompile(uint32_t access_flags,
49 uint32_t method_idx,
50 const DexFile& dex_file) const OVERRIDE;
51
52 uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE
53 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
54
55 bool WriteElf(art::File* file,
56 OatWriter* oat_writer,
57 const std::vector<const art::DexFile*>& dex_files,
58 const std::string& android_root,
59 bool is_host) const
60 OVERRIDE
61 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
62
63 Mir2Lir* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const;
64
65 void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE;
66
67 static Compiler* Create(CompilerDriver* driver);
68
69 const PassManager* GetPreOptPassManager() const {
70 return pre_opt_pass_manager_.get();
71 }
72 const PassManager* GetPostOptPassManager() const {
73 return post_opt_pass_manager_.get();
74 }
75
76 protected:
77 explicit QuickCompiler(CompilerDriver* driver);
78
79 private:
80 std::unique_ptr<PassManager> pre_opt_pass_manager_;
81 std::unique_ptr<PassManager> post_opt_pass_manager_;
82 DISALLOW_COPY_AND_ASSIGN(QuickCompiler);
83};
Andreas Gampe53c913b2014-08-12 23:19:23 -070084
85} // namespace art
86
87#endif // ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_