Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +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_COMPILERS_H_ |
| 18 | #define ART_COMPILER_COMPILERS_H_ |
| 19 | |
| 20 | #include "compiler.h" |
| 21 | |
| 22 | namespace art { |
| 23 | |
| 24 | class QuickCompiler : public Compiler { |
| 25 | public: |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 26 | explicit QuickCompiler(CompilerDriver* driver) : Compiler(driver, 100) {} |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 27 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 28 | void Init() const OVERRIDE; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 29 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 30 | void UnInit() const OVERRIDE; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 31 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 32 | CompiledMethod* Compile(const DexFile::CodeItem* code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 33 | uint32_t access_flags, |
| 34 | InvokeType invoke_type, |
| 35 | uint16_t class_def_idx, |
| 36 | uint32_t method_idx, |
| 37 | jobject class_loader, |
Nicolas Geoffray | 896362b | 2014-03-13 09:50:25 +0000 | [diff] [blame] | 38 | const DexFile& dex_file) const OVERRIDE; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 39 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 40 | CompiledMethod* JniCompile(uint32_t access_flags, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 41 | uint32_t method_idx, |
Nicolas Geoffray | 896362b | 2014-03-13 09:50:25 +0000 | [diff] [blame] | 42 | const DexFile& dex_file) const OVERRIDE; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 43 | |
Ian Rogers | b0fa5dc | 2014-04-28 16:47:08 -0700 | [diff] [blame] | 44 | uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const OVERRIDE |
| 45 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 46 | |
| 47 | bool WriteElf(art::File* file, |
| 48 | OatWriter* oat_writer, |
| 49 | const std::vector<const art::DexFile*>& dex_files, |
| 50 | const std::string& android_root, |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 51 | bool is_host) const |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 52 | OVERRIDE |
| 53 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 54 | |
Nicolas Geoffray | 896362b | 2014-03-13 09:50:25 +0000 | [diff] [blame] | 55 | Backend* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const OVERRIDE; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 56 | |
Nicolas Geoffray | 896362b | 2014-03-13 09:50:25 +0000 | [diff] [blame] | 57 | void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE {} |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 58 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 59 | private: |
| 60 | DISALLOW_COPY_AND_ASSIGN(QuickCompiler); |
| 61 | }; |
| 62 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 63 | class OptimizingCompiler FINAL : public QuickCompiler { |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 64 | public: |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 65 | explicit OptimizingCompiler(CompilerDriver* driver); |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 66 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 67 | CompiledMethod* Compile(const DexFile::CodeItem* code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 68 | uint32_t access_flags, |
| 69 | InvokeType invoke_type, |
| 70 | uint16_t class_def_idx, |
| 71 | uint32_t method_idx, |
| 72 | jobject class_loader, |
Nicolas Geoffray | 896362b | 2014-03-13 09:50:25 +0000 | [diff] [blame] | 73 | const DexFile& dex_file) const OVERRIDE; |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 74 | |
Ian Rogers | 72d3262 | 2014-05-06 16:20:11 -0700 | [diff] [blame] | 75 | CompiledMethod* TryCompile(const DexFile::CodeItem* code_item, |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 76 | uint32_t access_flags, |
| 77 | InvokeType invoke_type, |
| 78 | uint16_t class_def_idx, |
| 79 | uint32_t method_idx, |
| 80 | jobject class_loader, |
| 81 | const DexFile& dex_file) const; |
| 82 | |
| 83 | private: |
Ian Rogers | 700a402 | 2014-05-19 16:49:03 -0700 | [diff] [blame] | 84 | std::unique_ptr<std::ostream> visualizer_output_; |
Nicolas Geoffray | f635e63 | 2014-05-14 09:43:38 +0100 | [diff] [blame] | 85 | |
Nicolas Geoffray | b34f69a | 2014-03-07 15:28:39 +0000 | [diff] [blame] | 86 | DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler); |
| 87 | }; |
| 88 | |
| 89 | } // namespace art |
| 90 | |
| 91 | #endif // ART_COMPILER_COMPILERS_H_ |