blob: e818a1c52b31d40b83fb65ced09d5785fa7a8097 [file] [log] [blame]
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_COMPILER_H_
4#define ART_SRC_COMPILER_H_
5
Ian Rogers2c8f6532011-09-02 17:16:34 -07006#include "constants.h"
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -07007#include "dex_file.h"
Ian Rogers2c8f6532011-09-02 17:16:34 -07008#include "jni_compiler.h"
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -07009#include "object.h"
10
11namespace art {
12
13class Compiler {
14 public:
Ian Rogers2c8f6532011-09-02 17:16:34 -070015 explicit Compiler(InstructionSet insns) : instruction_set_(insns),
16 jni_compiler_(insns) {}
17
Brian Carlstrom8a487412011-08-29 20:08:52 -070018 // Compile all Methods of all the Classes of all the DexFiles that are part of a ClassLoader.
19 void CompileAll(const ClassLoader* class_loader);
20
21 // Compile a single Method
22 void CompileOne(Method* method);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070023
24 private:
25 // Attempt to resolve all type, methods, fields, and strings
26 // referenced from code in the dex file following PathClassLoader
27 // ordering semantics.
28 void Resolve(const ClassLoader* class_loader);
29 void ResolveDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
30
Brian Carlstrom83db7722011-08-26 17:32:56 -070031 void Compile(const ClassLoader* class_loader);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070032 void CompileDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
33 void CompileClass(Class* klass);
34 void CompileMethod(Method* klass);
Brian Carlstrom83db7722011-08-26 17:32:56 -070035
36 // After compiling, walk all the DexCaches and set the code and
Brian Carlstrom9cc262e2011-08-28 12:45:30 -070037 // method pointers of CodeAndDirectMethods entries in the DexCaches.
38 void SetCodeAndDirectMethods(const ClassLoader* class_loader);
Brian Carlstrom8a487412011-08-29 20:08:52 -070039 void SetCodeAndDirectMethodsDexFile(const DexFile& dex_file);
Ian Rogers2c8f6532011-09-02 17:16:34 -070040
41 InstructionSet instruction_set_;
42 JniCompiler jni_compiler_;
43
44 DISALLOW_COPY_AND_ASSIGN(Compiler);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070045};
46
47} // namespace art
48
49#endif // ART_SRC_COMPILER_H_