Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 1 | // Copyright 2011 Google Inc. All Rights Reserved. |
| 2 | |
| 3 | #ifndef ART_SRC_RUNTIME_H_ |
| 4 | #define ART_SRC_RUNTIME_H_ |
| 5 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 6 | #include "src/globals.h" |
| 7 | #include "src/macros.h" |
| 8 | #include "src/stringpiece.h" |
Carl Shapiro | b557353 | 2011-07-12 18:22:59 -0700 | [diff] [blame] | 9 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 10 | namespace art { |
| 11 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 12 | class ClassLinker; |
| 13 | class Heap; |
| 14 | class ThreadList; |
| 15 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 16 | class Runtime { |
| 17 | public: |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 18 | // Creates and initializes a new runtime. |
| 19 | static Runtime* Create(); |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 20 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 21 | // Compiles a dex file. |
| 22 | static void Compile(const StringPiece& filename); |
Carl Shapiro | b557353 | 2011-07-12 18:22:59 -0700 | [diff] [blame] | 23 | |
Elliott Hughes | ffe6736 | 2011-07-17 12:09:27 -0700 | [diff] [blame^] | 24 | // 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 Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 31 | // 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 Shapiro | b557353 | 2011-07-12 18:22:59 -0700 | [diff] [blame] | 38 | |
| 39 | private: |
Elliott Hughes | ffe6736 | 2011-07-17 12:09:27 -0700 | [diff] [blame^] | 40 | static void PlatformAbort(const char*, int); |
| 41 | |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 42 | Runtime() : class_linker_(NULL), heap_(NULL), thread_list_(NULL) {} |
| 43 | |
| 44 | // Initializes a new uninitialized runtime. |
| 45 | bool Init(); |
| 46 | |
| 47 | ClassLinker* class_linker_; |
| 48 | |
| 49 | Heap* heap_; |
| 50 | |
Carl Shapiro | b557353 | 2011-07-12 18:22:59 -0700 | [diff] [blame] | 51 | ThreadList* thread_list_; |
Carl Shapiro | 61e019d | 2011-07-14 16:53:09 -0700 | [diff] [blame] | 52 | |
| 53 | DISALLOW_COPY_AND_ASSIGN(Runtime); |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 54 | }; |
| 55 | |
| 56 | } // namespace art |
| 57 | |
Carl Shapiro | 1fb8620 | 2011-06-27 17:43:13 -0700 | [diff] [blame] | 58 | #endif // ART_SRC_RUNTIME_H_ |