blob: 563bbde3596cc8b41b59d18afd0b32239e825d91 [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
Ian Rogersd6b1f612011-09-27 13:38:14 -070011int oatVRegOffsetFromMethod(art::Method* method, int reg);
12
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070013namespace art {
14
15class Compiler {
16 public:
Shih-wei Liaoc486c112011-09-13 16:43:52 -070017 explicit Compiler(InstructionSet insns);
Ian Rogers2c8f6532011-09-02 17:16:34 -070018
Brian Carlstrom8a487412011-08-29 20:08:52 -070019 // Compile all Methods of all the Classes of all the DexFiles that are part of a ClassLoader.
20 void CompileAll(const ClassLoader* class_loader);
21
22 // Compile a single Method
23 void CompileOne(Method* method);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070024
Brian Carlstrom16192862011-09-12 17:50:06 -070025 void SetVerbose(bool verbose) {
26 verbose_ = verbose;
27 }
28
29 bool IsVerbose() const {
30 return verbose_;
31 }
32
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070033 private:
34 // Attempt to resolve all type, methods, fields, and strings
35 // referenced from code in the dex file following PathClassLoader
36 // ordering semantics.
37 void Resolve(const ClassLoader* class_loader);
38 void ResolveDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
39
jeffhao98eacac2011-09-14 16:11:53 -070040 void Verify(const ClassLoader* class_loader);
41 void VerifyDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
42
Brian Carlstroma5a97a22011-09-15 14:08:49 -070043 void InitializeClassesWithoutClinit(const ClassLoader* class_loader);
44 void InitializeClassesWithoutClinit(const ClassLoader* class_loader, const DexFile& dex_file);
45
Brian Carlstrom83db7722011-08-26 17:32:56 -070046 void Compile(const ClassLoader* class_loader);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070047 void CompileDexFile(const ClassLoader* class_loader, const DexFile& dex_file);
48 void CompileClass(Class* klass);
49 void CompileMethod(Method* klass);
Brian Carlstrom83db7722011-08-26 17:32:56 -070050
51 // After compiling, walk all the DexCaches and set the code and
Brian Carlstrom9cc262e2011-08-28 12:45:30 -070052 // method pointers of CodeAndDirectMethods entries in the DexCaches.
53 void SetCodeAndDirectMethods(const ClassLoader* class_loader);
Brian Carlstrom8a487412011-08-29 20:08:52 -070054 void SetCodeAndDirectMethodsDexFile(const DexFile& dex_file);
Ian Rogers2c8f6532011-09-02 17:16:34 -070055
56 InstructionSet instruction_set_;
57 JniCompiler jni_compiler_;
Shih-wei Liaoc486c112011-09-13 16:43:52 -070058 ByteArray* abstract_method_error_stub_;
Ian Rogers2c8f6532011-09-02 17:16:34 -070059
Brian Carlstrom16192862011-09-12 17:50:06 -070060 bool verbose_;
61
Ian Rogers2c8f6532011-09-02 17:16:34 -070062 DISALLOW_COPY_AND_ASSIGN(Compiler);
Brian Carlstrom9ea1cb12011-08-24 23:18:18 -070063};
64
65} // namespace art
66
67#endif // ART_SRC_COMPILER_H_