Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_COMPILER_H_ |
| 4 | #define ART_SRC_COMPILER_H_ |
| 5 | |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 6 | #include "constants.h" |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 7 | #include "dex_file.h" |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 8 | #include "jni_compiler.h" |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 9 | #include "object.h" |
| 10 | |
| 11 | namespace art { |
| 12 | |
| 13 | class Compiler { |
| 14 | public: |
Shih-wei Liao | c486c11 | 2011-09-13 16:43:52 -0700 | [diff] [blame] | 15 | explicit Compiler(InstructionSet insns); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 16 | |
Brian Carlstrom | 8a48741 | 2011-08-29 20:08:52 -0700 | [diff] [blame] | 17 | // Compile all Methods of all the Classes of all the DexFiles that are part of a ClassLoader. |
| 18 | void CompileAll(const ClassLoader* class_loader); |
| 19 | |
| 20 | // Compile a single Method |
| 21 | void CompileOne(Method* method); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 22 | |
| 23 | private: |
| 24 | // Attempt to resolve all type, methods, fields, and strings |
| 25 | // referenced from code in the dex file following PathClassLoader |
| 26 | // ordering semantics. |
| 27 | void Resolve(const ClassLoader* class_loader); |
| 28 | void ResolveDexFile(const ClassLoader* class_loader, const DexFile& dex_file); |
| 29 | |
Brian Carlstrom | 83db772 | 2011-08-26 17:32:56 -0700 | [diff] [blame] | 30 | void Compile(const ClassLoader* class_loader); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 31 | void CompileDexFile(const ClassLoader* class_loader, const DexFile& dex_file); |
| 32 | void CompileClass(Class* klass); |
| 33 | void CompileMethod(Method* klass); |
Brian Carlstrom | 83db772 | 2011-08-26 17:32:56 -0700 | [diff] [blame] | 34 | |
| 35 | // After compiling, walk all the DexCaches and set the code and |
Brian Carlstrom | 9cc262e | 2011-08-28 12:45:30 -0700 | [diff] [blame] | 36 | // method pointers of CodeAndDirectMethods entries in the DexCaches. |
| 37 | void SetCodeAndDirectMethods(const ClassLoader* class_loader); |
Brian Carlstrom | 8a48741 | 2011-08-29 20:08:52 -0700 | [diff] [blame] | 38 | void SetCodeAndDirectMethodsDexFile(const DexFile& dex_file); |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 39 | |
| 40 | InstructionSet instruction_set_; |
| 41 | JniCompiler jni_compiler_; |
Shih-wei Liao | c486c11 | 2011-09-13 16:43:52 -0700 | [diff] [blame] | 42 | ByteArray* abstract_method_error_stub_; |
Ian Rogers | 2c8f653 | 2011-09-02 17:16:34 -0700 | [diff] [blame] | 43 | |
| 44 | DISALLOW_COPY_AND_ASSIGN(Compiler); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 45 | }; |
| 46 | |
| 47 | } // namespace art |
| 48 | |
| 49 | #endif // ART_SRC_COMPILER_H_ |