blob: cbccccbea968e882cd8d4e62063b456750cb6a28 [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
Elliott Hughesffe67362011-07-17 12:09:27 -070024 // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
25 // callers should prefer.
26 // This isn't marked ((noreturn)) because then gcc will merge multiple calls
27 // in a single function together. This reduces code size slightly, but means
28 // that the native stack trace we get may point at the wrong call site.
29 static void Abort(const char* file, int line);
30
Carl Shapiro61e019d2011-07-14 16:53:09 -070031 // Attaches the current native thread to the runtime.
32 bool AttachCurrentThread();
33
34 // Detaches the current native thread from the runtime.
35 bool DetachCurrentThread();
36
37 ~Runtime();
Carl Shapirob5573532011-07-12 18:22:59 -070038
39 private:
Elliott Hughesffe67362011-07-17 12:09:27 -070040 static void PlatformAbort(const char*, int);
41
Carl Shapiro69759ea2011-07-21 18:13:35 -070042 Runtime() : class_linker_(NULL), thread_list_(NULL) {}
Carl Shapiro61e019d2011-07-14 16:53:09 -070043
44 // Initializes a new uninitialized runtime.
45 bool Init();
46
47 ClassLinker* class_linker_;
48
Carl Shapirob5573532011-07-12 18:22:59 -070049 ThreadList* thread_list_;
Carl Shapiro61e019d2011-07-14 16:53:09 -070050
51 DISALLOW_COPY_AND_ASSIGN(Runtime);
Carl Shapiro1fb86202011-06-27 17:43:13 -070052};
53
54} // namespace art
55
Carl Shapiro1fb86202011-06-27 17:43:13 -070056#endif // ART_SRC_RUNTIME_H_