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 | |
| 6 | #include "dex_file.h" |
| 7 | #include "object.h" |
| 8 | |
| 9 | namespace art { |
| 10 | |
| 11 | class Compiler { |
| 12 | public: |
Brian Carlstrom | bffb155 | 2011-08-25 12:23:53 -0700 | [diff] [blame] | 13 | // Compile the DexFiles on a classpath. Returns a ClassLoader for |
| 14 | // the path used by the classes that were compiled. This ClassLoader |
| 15 | // can be used with FindClass to lookup a compiled class by name. |
| 16 | const ClassLoader* Compile(std::vector<const DexFile*> class_path); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 17 | |
| 18 | private: |
| 19 | // Attempt to resolve all type, methods, fields, and strings |
| 20 | // referenced from code in the dex file following PathClassLoader |
| 21 | // ordering semantics. |
| 22 | void Resolve(const ClassLoader* class_loader); |
| 23 | void ResolveDexFile(const ClassLoader* class_loader, const DexFile& dex_file); |
| 24 | |
Brian Carlstrom | 83db772 | 2011-08-26 17:32:56 -0700 | [diff] [blame] | 25 | void Compile(const ClassLoader* class_loader); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 26 | void CompileDexFile(const ClassLoader* class_loader, const DexFile& dex_file); |
| 27 | void CompileClass(Class* klass); |
| 28 | void CompileMethod(Method* klass); |
Brian Carlstrom | 83db772 | 2011-08-26 17:32:56 -0700 | [diff] [blame] | 29 | |
| 30 | // After compiling, walk all the DexCaches and set the code and |
Brian Carlstrom | 9cc262e | 2011-08-28 12:45:30 -0700 | [diff] [blame] | 31 | // method pointers of CodeAndDirectMethods entries in the DexCaches. |
| 32 | void SetCodeAndDirectMethods(const ClassLoader* class_loader); |
| 33 | void SetCodeAndDirectMethodsDexFile(const ClassLoader* class_loader, const DexFile& dex_file); |
Brian Carlstrom | 9ea1cb1 | 2011-08-24 23:18:18 -0700 | [diff] [blame] | 34 | }; |
| 35 | |
| 36 | } // namespace art |
| 37 | |
| 38 | #endif // ART_SRC_COMPILER_H_ |