Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [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_DEX_QUICK_QUICK_COMPILER_H_ |
| 18 | #define ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_ |
| 19 | |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 20 | #include "compiler.h" |
Alex Light | 705ad49 | 2015-09-21 11:36:30 -0700 | [diff] [blame] | 21 | #include "dex/mir_graph.h" |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 22 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 23 | namespace art { |
| 24 | |
Mathieu Chartier | 736b560 | 2015-09-02 14:54:11 -0700 | [diff] [blame] | 25 | namespace mirror { |
| 26 | class DexCache; |
| 27 | } |
| 28 | |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 29 | class Compiler; |
| 30 | class CompilerDriver; |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 31 | class Mir2Lir; |
| 32 | class PassManager; |
Andreas Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 33 | |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 34 | class QuickCompiler : public Compiler { |
| 35 | public: |
| 36 | virtual ~QuickCompiler(); |
| 37 | |
| 38 | void Init() OVERRIDE; |
| 39 | |
| 40 | void UnInit() const OVERRIDE; |
| 41 | |
| 42 | bool CanCompileMethod(uint32_t method_idx, const DexFile& dex_file, CompilationUnit* cu) const |
| 43 | OVERRIDE; |
| 44 | |
| 45 | CompiledMethod* Compile(const DexFile::CodeItem* code_item, |
| 46 | uint32_t access_flags, |
| 47 | InvokeType invoke_type, |
| 48 | uint16_t class_def_idx, |
| 49 | uint32_t method_idx, |
| 50 | jobject class_loader, |
Mathieu Chartier | 736b560 | 2015-09-02 14:54:11 -0700 | [diff] [blame] | 51 | const DexFile& dex_file, |
| 52 | Handle<mirror::DexCache> dex_cache) const OVERRIDE; |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 53 | |
| 54 | CompiledMethod* JniCompile(uint32_t access_flags, |
| 55 | uint32_t method_idx, |
| 56 | const DexFile& dex_file) const OVERRIDE; |
| 57 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 58 | uintptr_t GetEntryPointOf(ArtMethod* method) const OVERRIDE |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 59 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 60 | |
David Srbecky | 1109fb3 | 2015-04-07 20:21:06 +0100 | [diff] [blame] | 61 | static Mir2Lir* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit); |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 62 | |
| 63 | void InitCompilationUnit(CompilationUnit& cu) const OVERRIDE; |
| 64 | |
| 65 | static Compiler* Create(CompilerDriver* driver); |
| 66 | |
| 67 | const PassManager* GetPreOptPassManager() const { |
| 68 | return pre_opt_pass_manager_.get(); |
| 69 | } |
| 70 | const PassManager* GetPostOptPassManager() const { |
| 71 | return post_opt_pass_manager_.get(); |
| 72 | } |
| 73 | |
| 74 | protected: |
| 75 | explicit QuickCompiler(CompilerDriver* driver); |
| 76 | |
| 77 | private: |
Alex Light | 705ad49 | 2015-09-21 11:36:30 -0700 | [diff] [blame] | 78 | bool CanCompileInstruction(const MIR* mir, const DexFile& dex_file) const; |
| 79 | |
Mathieu Chartier | 5bdab12 | 2015-01-26 18:30:19 -0800 | [diff] [blame] | 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 Gampe | 53c913b | 2014-08-12 23:19:23 -0700 | [diff] [blame] | 84 | |
| 85 | } // namespace art |
| 86 | |
| 87 | #endif // ART_COMPILER_DEX_QUICK_QUICK_COMPILER_H_ |