blob: f697b4a627d1d919a63f6e82e2509e21eb8de87f [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
Brian Carlstrom578bbdc2011-07-21 14:07:47 -07006#include <vector>
7
8#include "globals.h"
9#include "macros.h"
Brian Carlstrom7e49dca2011-07-22 18:07:34 -070010#include "dex_file.h"
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070011#include "stringpiece.h"
Carl Shapirob5573532011-07-12 18:22:59 -070012
Carl Shapiro1fb86202011-06-27 17:43:13 -070013namespace art {
14
Carl Shapiro61e019d2011-07-14 16:53:09 -070015class ClassLinker;
16class Heap;
17class ThreadList;
18
Carl Shapiro1fb86202011-06-27 17:43:13 -070019class Runtime {
20 public:
Carl Shapiro61e019d2011-07-14 16:53:09 -070021 // Creates and initializes a new runtime.
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070022 static Runtime* Create(std::vector<RawDexFile*> boot_class_path);
Carl Shapiro1fb86202011-06-27 17:43:13 -070023
Carl Shapiro61e019d2011-07-14 16:53:09 -070024 // Compiles a dex file.
25 static void Compile(const StringPiece& filename);
Carl Shapirob5573532011-07-12 18:22:59 -070026
Elliott Hughesffe67362011-07-17 12:09:27 -070027 // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
28 // callers should prefer.
29 // This isn't marked ((noreturn)) because then gcc will merge multiple calls
30 // in a single function together. This reduces code size slightly, but means
31 // that the native stack trace we get may point at the wrong call site.
32 static void Abort(const char* file, int line);
33
Carl Shapiro61e019d2011-07-14 16:53:09 -070034 // Attaches the current native thread to the runtime.
35 bool AttachCurrentThread();
36
37 // Detaches the current native thread from the runtime.
38 bool DetachCurrentThread();
39
40 ~Runtime();
Carl Shapirob5573532011-07-12 18:22:59 -070041
42 private:
Elliott Hughesffe67362011-07-17 12:09:27 -070043 static void PlatformAbort(const char*, int);
44
Carl Shapiro69759ea2011-07-21 18:13:35 -070045 Runtime() : class_linker_(NULL), thread_list_(NULL) {}
Carl Shapiro61e019d2011-07-14 16:53:09 -070046
47 // Initializes a new uninitialized runtime.
Brian Carlstrom578bbdc2011-07-21 14:07:47 -070048 bool Init(std::vector<RawDexFile*> boot_class_path);
Carl Shapiro61e019d2011-07-14 16:53:09 -070049
50 ClassLinker* class_linker_;
51
Carl Shapirob5573532011-07-12 18:22:59 -070052 ThreadList* thread_list_;
Carl Shapiro61e019d2011-07-14 16:53:09 -070053
54 DISALLOW_COPY_AND_ASSIGN(Runtime);
Carl Shapiro1fb86202011-06-27 17:43:13 -070055};
56
57} // namespace art
58
Carl Shapiro1fb86202011-06-27 17:43:13 -070059#endif // ART_SRC_RUNTIME_H_