blob: 9ff532c00c643267450a9de86bcf7e12a69015fd [file] [log] [blame]
// Copyright 2011 Google Inc. All Rights Reserved.
#include <vector>
#include "globals.h"
#include "macros.h"
#include "dex_file.h"
#include "stringpiece.h"
namespace art {
class ClassLinker;
class Heap;
class JniEnvironment;
class ThreadList;
class Runtime {
typedef std::vector<std::pair<const char*, void*> > Options;
// Creates and initializes a new runtime.
static Runtime* Create(const Options& options, bool ignore_unrecognized);
static Runtime* Create(const std::vector<DexFile*>& boot_class_path);
static Runtime* Current() {
return instance_;
// Compiles a dex file.
static void Compile(const StringPiece& filename);
// Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
// callers should prefer.
// This isn't marked ((noreturn)) because then gcc will merge multiple calls
// in a single function together. This reduces code size slightly, but means
// that the native stack trace we get may point at the wrong call site.
static void Abort(const char* file, int line);
// Attaches the current native thread to the runtime.
bool AttachCurrentThread(const char* name, JniEnvironment** jni_env);
bool AttachCurrentThreadAsDaemon(const char* name, JniEnvironment** jni_env);
// Detaches the current native thread from the runtime.
bool DetachCurrentThread();
ClassLinker* GetClassLinker() {
return class_linker_;
void SetVfprintfHook(void* hook);
void SetExitHook(void* hook);
void SetAbortHook(void* hook);
static void PlatformAbort(const char*, int);
Runtime() : class_linker_(NULL), thread_list_(NULL) {}
// Initializes a new uninitialized runtime.
bool Init(const std::vector<DexFile*>& boot_class_path);
ClassLinker* class_linker_;
ThreadList* thread_list_;
// A pointer to the active runtime or NULL.
static Runtime* instance_;
} // namespace art
#endif // ART_SRC_RUNTIME_H_