blob: 958d9abbcab77180318ebec57e86cb8e497d2382 [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:
Shih-wei Liaoc486c112011-09-13 16:43:52 -070015 explicit Compiler(InstructionSet insns);
Ian Rogers2c8f6532011-09-02 17:16:34 -070016
Brian Carlstrom8a487412011-08-29 20:08:52 -070017 // 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 Carlstrom9ea1cb12011-08-24 23:18:18 -070022
Brian Carlstrom16192862011-09-12 17:50:06 -070023 void SetVerbose(bool verbose) {
24 verbose_ = verbose;
25 }
26
27 bool IsVerbose() const {
28 return verbose_;
29 }
30
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070031 private:
32 // Attempt to resolve all type, methods, fields, and strings
33 // referenced from code in the dex file following PathClassLoader
34 // ordering semantics.
35 void Resolve(const ClassLoader* class_loader);
36 void ResolveDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
37
Brian Carlstrom83db7722011-08-26 17:32:56 -070038 void Compile(const ClassLoader* class_loader);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070039 void CompileDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
40 void CompileClass(Class* klass);
41 void CompileMethod(Method* klass);
Brian Carlstrom83db7722011-08-26 17:32:56 -070042
43 // After compiling, walk all the DexCaches and set the code and
Brian Carlstrom9cc262e2011-08-28 12:45:30 -070044 // method pointers of CodeAndDirectMethods entries in the DexCaches.
45 void SetCodeAndDirectMethods(const ClassLoader* class_loader);
Brian Carlstrom8a487412011-08-29 20:08:52 -070046 void SetCodeAndDirectMethodsDexFile(const DexFile& dex_file);
Ian Rogers2c8f6532011-09-02 17:16:34 -070047
48 InstructionSet instruction_set_;
49 JniCompiler jni_compiler_;
Shih-wei Liaoc486c112011-09-13 16:43:52 -070050 ByteArray* abstract_method_error_stub_;
Ian Rogers2c8f6532011-09-02 17:16:34 -070051
Brian Carlstrom16192862011-09-12 17:50:06 -070052 bool verbose_;
53
Ian Rogers2c8f6532011-09-02 17:16:34 -070054 DISALLOW_COPY_AND_ASSIGN(Compiler);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070055};
56
57} // namespace art
58
59#endif // ART_SRC_COMPILER_H_