compilers.h revision b34f69ab43aaf7a6e6045c95f398baf566ef5023
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 22namespace art { 23 24class QuickCompiler : public Compiler { 25 public: 26 QuickCompiler() : Compiler(100) {} 27 28 void Init(CompilerDriver& driver) const; 29 30 void UnInit(CompilerDriver& driver) const; 31 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, 39 const DexFile& dex_file) const; 40 41 CompiledMethod* JniCompile(CompilerDriver& driver, 42 uint32_t access_flags, 43 uint32_t method_idx, 44 const DexFile& dex_file) const; 45 46 uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const; 47 48 bool WriteElf(art::File* file, 49 OatWriter* oat_writer, 50 const std::vector<const art::DexFile*>& dex_files, 51 const std::string& android_root, 52 bool is_host, const CompilerDriver& driver) const 53 OVERRIDE 54 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 55 56 Backend* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const; 57 58 void InitCompilationUnit(CompilationUnit& cu) const {} 59 60 /* 61 * @brief Generate and return Dwarf CFI initialization, if supported by the 62 * backend. 63 * @param driver CompilerDriver for this compile. 64 * @returns nullptr if not supported by backend or a vector of bytes for CFI DWARF 65 * information. 66 * @note This is used for backtrace information in generated code. 67 */ 68 std::vector<uint8_t>* GetCallFrameInformationInitialization(const CompilerDriver& driver) const 69 OVERRIDE; 70 71 private: 72 DISALLOW_COPY_AND_ASSIGN(QuickCompiler); 73}; 74 75class OptimizingCompiler : public QuickCompiler { 76 public: 77 OptimizingCompiler() { } 78 79 CompiledMethod* Compile(CompilerDriver& driver, 80 const DexFile::CodeItem* code_item, 81 uint32_t access_flags, 82 InvokeType invoke_type, 83 uint16_t class_def_idx, 84 uint32_t method_idx, 85 jobject class_loader, 86 const DexFile& dex_file) const; 87 88 CompiledMethod* TryCompile(CompilerDriver& driver, 89 const DexFile::CodeItem* code_item, 90 uint32_t access_flags, 91 InvokeType invoke_type, 92 uint16_t class_def_idx, 93 uint32_t method_idx, 94 jobject class_loader, 95 const DexFile& dex_file) const; 96 97 private: 98 DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler); 99}; 100 101} // namespace art 102 103#endif // ART_COMPILER_COMPILERS_H_ 104