blob: 76f7676fcea2758200e2c003307112391bb9f559 [file] [log] [blame]
Carl Shapiro1fb86202011-06-27 17:43:13 -07001// Copyright 2011 Google Inc. All Rights Reserved.
2
3#ifndef ART_SRC_RUNTIME_H_
4#define ART_SRC_RUNTIME_H_
5
Carl Shapiro61e019d2011-07-14 16:53:09 -07006#include "src/globals.h"
7#include "src/macros.h"
8#include "src/stringpiece.h"
Carl Shapirob5573532011-07-12 18:22:59 -07009
Carl Shapiro1fb86202011-06-27 17:43:13 -070010namespace art {
11
Carl Shapiro61e019d2011-07-14 16:53:09 -070012class ClassLinker;
13class Heap;
14class ThreadList;
15
Carl Shapiro1fb86202011-06-27 17:43:13 -070016class Runtime {
17 public:
Carl Shapiro61e019d2011-07-14 16:53:09 -070018 // Creates and initializes a new runtime.
19 static Runtime* Create();
Carl Shapiro1fb86202011-06-27 17:43:13 -070020
Carl Shapiro61e019d2011-07-14 16:53:09 -070021 // Compiles a dex file.
22 static void Compile(const StringPiece& filename);
Carl Shapirob5573532011-07-12 18:22:59 -070023
Carl Shapiro61e019d2011-07-14 16:53:09 -070024 // Attaches the current native thread to the runtime.
25 bool AttachCurrentThread();
26
27 // Detaches the current native thread from the runtime.
28 bool DetachCurrentThread();
29
30 ~Runtime();
Carl Shapirob5573532011-07-12 18:22:59 -070031
32 private:
Carl Shapiro61e019d2011-07-14 16:53:09 -070033 Runtime() : class_linker_(NULL), heap_(NULL), thread_list_(NULL) {}
34
35 // Initializes a new uninitialized runtime.
36 bool Init();
37
38 ClassLinker* class_linker_;
39
40 Heap* heap_;
41
Carl Shapirob5573532011-07-12 18:22:59 -070042 ThreadList* thread_list_;
Carl Shapiro61e019d2011-07-14 16:53:09 -070043
44 DISALLOW_COPY_AND_ASSIGN(Runtime);
Carl Shapiro1fb86202011-06-27 17:43:13 -070045};
46
47} // namespace art
48
Carl Shapiro1fb86202011-06-27 17:43:13 -070049#endif // ART_SRC_RUNTIME_H_