runtime.h revision ffe6736397d17457188727510f0a2953f69a383a
1// Copyright 2011 Google Inc. All Rights Reserved. 2 3#ifndef ART_SRC_RUNTIME_H_ 4#define ART_SRC_RUNTIME_H_ 5 6#include "src/globals.h" 7#include "src/macros.h" 8#include "src/stringpiece.h" 9 10namespace art { 11 12class ClassLinker; 13class Heap; 14class ThreadList; 15 16class Runtime { 17 public: 18 // Creates and initializes a new runtime. 19 static Runtime* Create(); 20 21 // Compiles a dex file. 22 static void Compile(const StringPiece& filename); 23 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 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(); 38 39 private: 40 static void PlatformAbort(const char*, int); 41 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 51 ThreadList* thread_list_; 52 53 DISALLOW_COPY_AND_ASSIGN(Runtime); 54}; 55 56} // namespace art 57 58#endif // ART_SRC_RUNTIME_H_ 59