compilers.h revision b34f69ab43aaf7a6e6045c95f398baf566ef5023
1b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray/* 2b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * Copyright (C) 2014 The Android Open Source Project 3b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * 4b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * Licensed under the Apache License, Version 2.0 (the "License"); 5b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * you may not use this file except in compliance with the License. 6b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * You may obtain a copy of the License at 7b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * 8b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * http://www.apache.org/licenses/LICENSE-2.0 9b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * 10b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * Unless required by applicable law or agreed to in writing, software 11b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * distributed under the License is distributed on an "AS IS" BASIS, 12b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * See the License for the specific language governing permissions and 14b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * limitations under the License. 15b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray */ 16b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 17b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray#ifndef ART_COMPILER_COMPILERS_H_ 18b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray#define ART_COMPILER_COMPILERS_H_ 19b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 20b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray#include "compiler.h" 21b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 22b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffraynamespace art { 23b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 24b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffrayclass QuickCompiler : public Compiler { 25b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray public: 26b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray QuickCompiler() : Compiler(100) {} 27b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 28b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray void Init(CompilerDriver& driver) const; 29b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 30b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray void UnInit(CompilerDriver& driver) const; 31b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 32b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray CompiledMethod* Compile(CompilerDriver& driver, 33b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile::CodeItem* code_item, 34b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t access_flags, 35b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray InvokeType invoke_type, 36b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint16_t class_def_idx, 37b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t method_idx, 38b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray jobject class_loader, 39b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile& dex_file) const; 40b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 41b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray CompiledMethod* JniCompile(CompilerDriver& driver, 42b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t access_flags, 43b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t method_idx, 44b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile& dex_file) const; 45b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 46b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uintptr_t GetEntryPointOf(mirror::ArtMethod* method) const; 47b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 48b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray bool WriteElf(art::File* file, 49b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray OatWriter* oat_writer, 50b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const std::vector<const art::DexFile*>& dex_files, 51b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const std::string& android_root, 52b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray bool is_host, const CompilerDriver& driver) const 53b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray OVERRIDE 54b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 55b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 56b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray Backend* GetCodeGenerator(CompilationUnit* cu, void* compilation_unit) const; 57b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 58b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray void InitCompilationUnit(CompilationUnit& cu) const {} 59b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 60b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray /* 61b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * @brief Generate and return Dwarf CFI initialization, if supported by the 62b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * backend. 63b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * @param driver CompilerDriver for this compile. 64b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * @returns nullptr if not supported by backend or a vector of bytes for CFI DWARF 65b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * information. 66b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray * @note This is used for backtrace information in generated code. 67b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray */ 68b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray std::vector<uint8_t>* GetCallFrameInformationInitialization(const CompilerDriver& driver) const 69b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray OVERRIDE; 70b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 71b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray private: 72b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(QuickCompiler); 73b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray}; 74b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 75b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffrayclass OptimizingCompiler : public QuickCompiler { 76b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray public: 77b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray OptimizingCompiler() { } 78b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 79b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray CompiledMethod* Compile(CompilerDriver& driver, 80b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile::CodeItem* code_item, 81b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t access_flags, 82b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray InvokeType invoke_type, 83b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint16_t class_def_idx, 84b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t method_idx, 85b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray jobject class_loader, 86b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile& dex_file) const; 87b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 88b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray CompiledMethod* TryCompile(CompilerDriver& driver, 89b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile::CodeItem* code_item, 90b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t access_flags, 91b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray InvokeType invoke_type, 92b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint16_t class_def_idx, 93b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray uint32_t method_idx, 94b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray jobject class_loader, 95b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray const DexFile& dex_file) const; 96b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 97b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray private: 98b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray DISALLOW_COPY_AND_ASSIGN(OptimizingCompiler); 99b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray}; 100b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 101b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray} // namespace art 102b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray 103b34f69ab43aaf7a6e6045c95f398baf566ef5023Nicolas Geoffray#endif // ART_COMPILER_COMPILERS_H_ 104