runtime.h revision d1cc8363d4f4bbac7568b1d02a5ca481cd10830f
16b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro// Copyright 2011 Google Inc. All Rights Reserved.
27b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
31fb8620309a4e94d11879aabc33364acfa733904Carl Shapiro#ifndef ART_SRC_RUNTIME_H_
41fb8620309a4e94d11879aabc33364acfa733904Carl Shapiro#define ART_SRC_RUNTIME_H_
56b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro
6c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes#include <stdio.h>
7c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes
8e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes#include <iosfwd>
96ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <string>
10fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro#include <utility>
116ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <vector>
12578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom
13c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes#include <jni.h>
14c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes
15ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers#include "constants.h"
161f87008b165d26541d832ff805250afdc89c253dBrian Carlstrom#include "heap.h"
17578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom#include "globals.h"
18578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom#include "macros.h"
199d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes#include "runtime_stats.h"
20578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom#include "stringpiece.h"
2144753c3908fcd5ccc066bf0dceddeabfeacf9f24Brian Carlstrom#include "unordered_set.h"
22b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro
236b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art {
247b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
25161928613d3f097108319de60494fab1aab8d48aBrian Carlstromtemplate<class T> class PrimitiveArray;
26161928613d3f097108319de60494fab1aab8d48aBrian Carlstromtypedef PrimitiveArray<int8_t> ByteArray;
2761e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ClassLinker;
28aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstromclass ClassLoader;
29fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiroclass DexFile;
3061e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass Heap;
31cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughesclass InternTable;
32c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughesclass JavaVMExt;
33ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogersclass Method;
34c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughesclass MonitorList;
35e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughesclass SignalCatcher;
366ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstromclass String;
3761e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ThreadList;
3861e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
391fb8620309a4e94d11879aabc33364acfa733904Carl Shapiroclass Runtime {
407b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro public:
418a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom
428a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom  typedef std::vector<std::pair<StringPiece, const void*> > Options;
438a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom
448a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom  class ParsedOptions {
458a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom   public:
466ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom    // returns null if problem parsing and ignore_unrecognized is false
476ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom    static ParsedOptions* Create(const Options& options, bool ignore_unrecognized);
488a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom
4958ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom    std::string boot_class_path_;
5058ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom    std::string class_path_;
5158ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom    std::string host_prefix_;
5258ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom    std::vector<std::string> images_;
53515a5bc89282d6f910cae4d5852bb77124a47825Elliott Hughes    bool check_jni_;
54a09576416788b916095739e43a16917e7948f3a4Elliott Hughes    std::string jni_trace_;
559ca7a1fdd0daa546b790adb6a24dbc13c22df76aElliott Hughes    bool is_zygote_;
568a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom    size_t heap_initial_size_;
578a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom    size_t heap_maximum_size_;
58f734cf55d510976f4862b15e35fc86eae2a3daf8Brian Carlstrom    size_t stack_size_;
59bb1e8f0a07c12a8b0a2dd3cab6a1a7e825a54c6fElliott Hughes    size_t jni_globals_max_;
60bb1e8f0a07c12a8b0a2dd3cab6a1a7e825a54c6fElliott Hughes    size_t lock_profiling_threshold_;
6194ce37a3919a0bdb8855a3d3264a50df1dbc41beElliott Hughes    std::string stack_trace_file_;
62fc86162ce2a3467acb690e18cc8bd9b3daafc606Elliott Hughes    bool (*hook_is_sensitive_thread_)();
636ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom    jint (*hook_vfprintf_)(FILE* stream, const char* format, va_list ap);
646ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom    void (*hook_exit_)(jint status);
656ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom    void (*hook_abort_)();
6644753c3908fcd5ccc066bf0dceddeabfeacf9f24Brian Carlstrom    std::tr1::unordered_set<std::string> verbose_;
676ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom    std::vector<std::string> properties_;
686ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom
69a09576416788b916095739e43a16917e7948f3a4Elliott Hughes    bool IsVerbose(const std::string& key) const {
70a09576416788b916095739e43a16917e7948f3a4Elliott Hughes      return verbose_.find(key) != verbose_.end();
71a09576416788b916095739e43a16917e7948f3a4Elliott Hughes    }
72a09576416788b916095739e43a16917e7948f3a4Elliott Hughes
736ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom   private:
740cfe1fb7060576d047f7f894fc0d8b87de84fcabIan Rogers    ParsedOptions() {}
758a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom  };
762ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro
7761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  // Creates and initializes a new runtime.
782ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  static Runtime* Create(const Options& options, bool ignore_unrecognized);
7969b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom
800a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom  bool IsVerboseStartup() const {
810a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom    return verbose_startup_;
820a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom  }
830a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom
84caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom  bool IsZygote() const {
85caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom    return is_zygote_;
86caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom  }
87caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom
8858ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  const std::string& GetHostPrefix() const {
89307f75d6bcf7c32db7e1b43124dead628cc7ce96Elliott Hughes    DCHECK(!IsStarted());
9058ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom    return host_prefix_;
9158ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  }
9258ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom
9369b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  // Starts a runtime, which may cause threads to be started and code to run.
9469b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  void Start();
952ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro
9658ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  bool IsStarted() const;
97dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes
982ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  static Runtime* Current() {
992ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro    return instance_;
1002ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  }
10161e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
10261e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  // Compiles a dex file.
10361e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  static void Compile(const StringPiece& filename);
1041fb8620309a4e94d11879aabc33364acfa733904Carl Shapiro
105ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
106ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // callers should prefer.
107ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // This isn't marked ((noreturn)) because then gcc will merge multiple calls
108ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // in a single function together. This reduces code size slightly, but means
109ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // that the native stack trace we get may point at the wrong call site.
110ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  static void Abort(const char* file, int line);
111ffe6736397d17457188727510f0a2953f69a383aElliott Hughes
11261e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  // Attaches the current native thread to the runtime.
1135fe594f576225dd7d333835e39c448a71ea9b433Elliott Hughes  void AttachCurrentThread(const char* name, bool as_daemon);
114b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro
115bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes  void CallExitHook(jint status);
116bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes
11761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  // Detaches the current native thread from the runtime.
118d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes  void DetachCurrentThread();
11961e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
1208daa0929f08a3080ea64dbd4e997e72f411e6fc9Elliott Hughes  void Dump(std::ostream& os);
121e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes
12261e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  ~Runtime();
123b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro
1247ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  const std::string& GetBootClassPath() const {
1257ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes    return boot_class_path_;
126b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom  }
127b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom
128b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom  ClassLinker* GetClassLinker() const {
1297a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro    return class_linker_;
1307a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro  }
1317a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro
1327ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  const std::string& GetClassPath() const {
1337ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes    return class_path_;
1347ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
1357ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
1367ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  size_t GetDefaultStackSize() const {
1377ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes    return default_stack_size_;
1387ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
1397ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
140cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes  InternTable* GetInternTable() const {
141cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes    return intern_table_;
142cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes  }
143cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes
1440af5543f8ea20c3e655b2d748a1b7dcf283792feElliott Hughes  JavaVMExt* GetJavaVM() const {
145c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes    return java_vm_;
146f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes  }
147f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes
1487ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  const std::vector<std::string>& GetProperties() const {
1497ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes    return properties_;
1507ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
1517ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
152c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes  MonitorList* GetMonitorList() const {
153c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes    return monitor_list_;
154c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes  }
155c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes
156d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes  ThreadList* GetThreadList() const {
157d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes    return thread_list_;
158d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes  }
159d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes
1607ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  const char* GetVersion() const {
1617ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes    return "2.0.0";
1627ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
1637ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
164410c0c876f326e14c176a39ba21fc4dd3f7db8abElliott Hughes  void VisitRoots(Heap::RootVisitor* visitor, void* arg) const;
1651f87008b165d26541d832ff805250afdc89c253dBrian Carlstrom
166e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  bool HasJniStubArray() const;
167e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  ByteArray* GetJniStubArray() const;
168e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  void SetJniStubArray(ByteArray* jni_stub_array);
169ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
170e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  bool HasAbstractMethodErrorStubArray() const;
171e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  ByteArray* GetAbstractMethodErrorStubArray() const;
172e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  void SetAbstractMethodErrorStubArray(ByteArray* abstract_method_error_stub_array);
173ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
1741cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers  enum TrampolineType {
1751cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers    kInstanceMethod,
1761cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers    kStaticMethod,
1771cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers    kUnknownMethod,
1784f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kLastTrampolineMethodType  // Value used for iteration
1791cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers  };
1801cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers  static TrampolineType GetTrampolineType(Method* method);
1811cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers  bool HasResolutionStubArray(TrampolineType type) const;
1821cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers  ByteArray* GetResolutionStubArray(TrampolineType type) const;
1831cb0a1dfc32531c79a968aeac26ccb5525862497Ian Rogers  void SetResolutionStubArray(ByteArray* resolution_stub_array, TrampolineType type);
184ad25ac568407ceb14334e8551dd1c4dd0fd6993cIan Rogers
185ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers  // Returns a special method that describes all callee saves being spilled to the stack.
1864f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  enum CalleeSaveType {
1874f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kSaveAll,
1884f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kRefsOnly,
1894f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kRefsAndArgs,
1904f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kLastCalleeSaveType  // Value used for iteration
1914f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  };
1924f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  Method* CreateCalleeSaveMethod(InstructionSet insns, CalleeSaveType type);
1934f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  bool HasCalleeSaveMethod(CalleeSaveType type) const;
1944f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  Method* GetCalleeSaveMethod(CalleeSaveType type) const;
1954f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  void SetCalleeSaveMethod(Method* method, CalleeSaveType type);
1964f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
1974f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  Method* CreateRefOnlyCalleeSaveMethod(InstructionSet insns);
1984f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  Method* CreateRefAndArgsCalleeSaveMethod(InstructionSet insns);
199ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
2009d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  int32_t GetStat(int kind);
2019d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
2029d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  RuntimeStats* GetStats();
2039d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
2049d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  bool HasStatsEnabled() const {
2059d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes    return stats_enabled_;
2069d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  }
2079d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
2089d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  void ResetStats(int kinds);
2099d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
2109d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  void SetStatsEnabled(bool new_state);
2119d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
212caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom  void DidForkFromZygote();
213caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom
214b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro private:
215ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  static void PlatformAbort(const char*, int);
216ffe6736397d17457188727510f0a2953f69a383aElliott Hughes
217dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes  Runtime();
21861e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
219c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes  void BlockSignals();
220c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes
2218a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom  bool Init(const Options& options, bool ignore_unrecognized);
222038a806df72f884d22283a84a31c9a1d35ba1fdfElliott Hughes  void InitNativeMethods();
223ad7c2a3b4daa2abd707375444f4b0db7d69a3838Elliott Hughes  void RegisterRuntimeNativeMethods(JNIEnv*);
224d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes
22585d1545e985ac689db4bad7849880e843707c862Elliott Hughes  void StartDaemonThreads();
226d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes  void StartSignalCatcher();
22761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
2280a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom  bool verbose_startup_;
2299ca7a1fdd0daa546b790adb6a24dbc13c22df76aElliott Hughes  bool is_zygote_;
2300a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom
23158ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // The host prefix is used during cross compilation. It is removed
23258ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // from the start of host paths such as:
23347a0d5a6f221066c3daf7f67f2122ed9c9cd217cBrian Carlstrom  //    $ANDROID_PRODUCT_OUT/data/art-cache/boot.oat
23434f426c49ac2de8cea70acef6b9ecdd8e62209d2Brian Carlstrom  // to produce target paths such as
23547a0d5a6f221066c3daf7f67f2122ed9c9cd217cBrian Carlstrom  //    /system/framework/boot.oat
23658ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // Similarly it is prepended to target paths to arrive back at a
23758ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // host past. In both cases this is necessary because image and oat
23858ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // files embedded expect paths of dependent files (an image points
23958ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // to an oat file and an oat files to one or more dex files). These
24058ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  // files contain the expected target path.
24158ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom  std::string host_prefix_;
24258ae9416e197ae68ed12ed43d87407d4dfb15093Brian Carlstrom
2437ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  std::string boot_class_path_;
2447ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  std::string class_path_;
2457ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  std::vector<std::string> properties_;
2467ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
247b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom  // The default stack size for managed threads created by the runtime.
248be759c63c6bb58b76ac71cad2c5a736bd31f374dElliott Hughes  size_t default_stack_size_;
249b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom
250c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes  MonitorList* monitor_list_;
251c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes
252b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro  ThreadList* thread_list_;
25361e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
254cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes  InternTable* intern_table_;
255cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes
256b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom  ClassLinker* class_linker_;
257b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom
258e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes  SignalCatcher* signal_catcher_;
25994ce37a3919a0bdb8855a3d3264a50df1dbc41beElliott Hughes  std::string stack_trace_file_;
260e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes
261c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes  JavaVMExt* java_vm_;
262f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes
263161928613d3f097108319de60494fab1aab8d48aBrian Carlstrom  ByteArray* jni_stub_array_;
264161928613d3f097108319de60494fab1aab8d48aBrian Carlstrom
265e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom  ByteArray* abstract_method_error_stub_array_;
266e24fa61603a60ade3797e4a0c8b3fccb346cb048Brian Carlstrom
2674f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  ByteArray* resolution_stub_array_[kLastTrampolineMethodType];
268ad25ac568407ceb14334e8551dd1c4dd0fd6993cIan Rogers
2694f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  Method* callee_save_method_[kLastCalleeSaveType];
270ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
271aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom  // As returned by ClassLoader.getSystemClassLoader()
272aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom  ClassLoader* system_class_loader_;
273aded5f7ab991f3c1132851599d3bc60ff6707eedBrian Carlstrom
274dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes  bool started_;
275dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes
2766ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  // Hooks supported by JNI_CreateJavaVM
2776ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  jint (*vfprintf_)(FILE* stream, const char* format, va_list ap);
2786ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  void (*exit_)(jint status);
2796ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  void (*abort_)();
2806ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom
2819d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  bool stats_enabled_;
2829d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  RuntimeStats stats_;
2839d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
2842ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  // A pointer to the active runtime or NULL.
2852ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  static Runtime* instance_;
2862ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro
28761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  DISALLOW_COPY_AND_ASSIGN(Runtime);
2887b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro};
2897b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
2906b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro}  // namespace art
2917b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
2921fb8620309a4e94d11879aabc33364acfa733904Carl Shapiro#endif  // ART_SRC_RUNTIME_H_
293