blob: 255dd23f33ba07dbb5bfb00cc17ca5449413102d [file] [log] [blame]
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +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_COMPILERS_H_
18#define ART_COMPILER_COMPILERS_H_
19
20#include "compiler.h"
21
22namespace art {
23
24class QuickCompiler : public Compiler {
25 public:
26 QuickCompiler() : Compiler(100) {}
27
Nicolas Geoffray896362b2014-03-13 09:50:25 +000028 void Init(CompilerDriver& driver) const OVERRIDE;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000029
Nicolas Geoffray896362b2014-03-13 09:50:25 +000030 void UnInit(CompilerDriver& driver) const OVERRIDE;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000031
32 CompiledMethod* Compile(CompilerDriver& driver,
33 const DexFile::CodeItem* code_item,
34 uint32_t access_flags,
35 InvokeType invoke_type,
36 uint16_t class_def_idx,
37 uint32_t method_idx,
38 jobject class_loader,
Nicolas Geoffray896362b2014-03-13 09:50:25 +000039 const DexFile& dex_file) const OVERRIDE;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000040
41 CompiledMethod* JniCompile(CompilerDriver& driver,
42 uint32_t access_flags,
43 uint32_t method_idx,
Nicolas Geoffray896362b2014-03-13 09:50:25 +000044 const DexFile& dex_file) const OVERRIDE;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000045
Ian Rogersb0fa5dc2014-04-28 16:47:08 -070046 uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE
47 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000048
49 bool WriteElf(art::File* file,
50 OatWriter* oat_writer,
51 const std::vector<const art::DexFile*>& dex_files,
52 const std::string& android_root,
53 bool is_host, const CompilerDriver& driver) const
54 OVERRIDE
55 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
56
Nicolas Geoffray896362b2014-03-13 09:50:25 +000057 Backend* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const OVERRIDE;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000058
Nicolas Geoffray896362b2014-03-13 09:50:25 +000059 void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE {}
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000060
61 /*
62 * @brief Generate and return Dwarf CFI initialization, if supported by the
63 * backend.
64 * @param driver CompilerDriver for this compile.
65 * @returns nullptr if not supported by backend or a vector of bytes for CFI DWARF
66 * information.
67 * @note This is used for backtrace information in generated code.
68 */
69 std::vector<uint8_t>* GetCallFrameInformationInitialization(const CompilerDriver& driver) const
70 OVERRIDE;
71
72 private:
73 DISALLOW_COPY_AND_ASSIGN(QuickCompiler);
74};
75
76class OptimizingCompiler : public QuickCompiler {
77 public:
78 OptimizingCompiler() { }
79
80 CompiledMethod* Compile(CompilerDriver& driver,
81 const DexFile::CodeItem* code_item,
82 uint32_t access_flags,
83 InvokeType invoke_type,
84 uint16_t class_def_idx,
85 uint32_t method_idx,
86 jobject class_loader,
Nicolas Geoffray896362b2014-03-13 09:50:25 +000087 const DexFile& dex_file) const OVERRIDE;
Nicolas Geoffrayb34f69a2014-03-07 15:28:39 +000088
89 CompiledMethod* TryCompile(CompilerDriver& driver,
90 const DexFile::CodeItem* code_item,
91 uint32_t access_flags,
92 InvokeType invoke_type,
93 uint16_t class_def_idx,
94 uint32_t method_idx,
95 jobject class_loader,
96 const DexFile& dex_file) const;
97
98 private:
99 DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler);
100};
101
102} // namespace art
103
104#endif // ART_COMPILER_COMPILERS_H_