Nicolas Geoffray | f5df897 | 2014-02-14 18:37:08 +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_COMPILER_BACKEND_H_ |
| 18 | #define ART_COMPILER_COMPILER_BACKEND_H_ |
| 19 | |
| 20 | #include "dex_file.h" |
| 21 | #include "os.h" |
| 22 | |
| 23 | namespace art { |
| 24 | |
| 25 | class Backend; |
| 26 | class CompilationUnit; |
| 27 | class CompilerDriver; |
| 28 | class CompiledMethod; |
| 29 | class MIRGraph; |
| 30 | class OatWriter; |
| 31 | |
| 32 | namespace mirror { |
| 33 | class ArtMethod; |
| 34 | } |
| 35 | |
| 36 | class CompilerBackend { |
| 37 | public: |
| 38 | enum Kind { |
| 39 | kQuick, |
| 40 | kPortable |
| 41 | }; |
| 42 | |
| 43 | CompilerBackend(int warning) |
| 44 | : maximum_compilation_time_before_warning_(warning) {} |
| 45 | |
| 46 | static CompilerBackend* Create(Kind kind); |
| 47 | |
| 48 | virtual void Init(CompilerDriver& driver) const = 0; |
| 49 | |
| 50 | virtual void UnInit(CompilerDriver& driver) const = 0; |
| 51 | |
| 52 | virtual CompiledMethod* Compile(CompilerDriver& compiler, |
| 53 | const DexFile::CodeItem* code_item, |
| 54 | uint32_t access_flags, |
| 55 | InvokeType invoke_type, |
| 56 | uint16_t class_def_idx, |
| 57 | uint32_t method_idx, |
| 58 | jobject class_loader, |
| 59 | const DexFile& dex_file) const = 0; |
| 60 | |
| 61 | virtual CompiledMethod* JniCompile(CompilerDriver& driver, |
| 62 | uint32_t access_flags, |
| 63 | uint32_t method_idx, |
| 64 | const DexFile& dex_file) const = 0; |
| 65 | |
| 66 | virtual uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const = 0; |
| 67 | |
| 68 | virtual bool WriteElf(art::File* file, |
| 69 | OatWriter& oat_writer, |
| 70 | const std::vector<const art::DexFile*>& dex_files, |
| 71 | const std::string& android_root, |
| 72 | bool is_host, const CompilerDriver& driver) const |
| 73 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; |
| 74 | |
| 75 | virtual Backend* GetCodeGenerator(CompilationUnit* cu, |
| 76 | void* compilation_unit) const = 0; |
| 77 | |
| 78 | uint64_t GetMaximumCompilationTimeBeforeWarning() const { |
| 79 | return maximum_compilation_time_before_warning_; |
| 80 | } |
| 81 | |
| 82 | virtual bool IsPortable() const { return false; } |
| 83 | |
| 84 | virtual void InitCompilationUnit(CompilationUnit& cu) const = 0; |
| 85 | |
| 86 | virtual ~CompilerBackend() {} |
| 87 | |
| 88 | private: |
| 89 | uint64_t maximum_compilation_time_before_warning_; |
| 90 | |
| 91 | DISALLOW_COPY_AND_ASSIGN(CompilerBackend); |
| 92 | }; |
| 93 | |
| 94 | } // namespace art |
| 95 | |
| 96 | #endif // ART_COMPILER_DRIVER_COMPILER_BACKEND_H_ |