runtime.h revision c0542af3e2170143ba40d89136e284997e16bf64
12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/*
22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project
32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes *
42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License");
52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License.
62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at
72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes *
82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes *      http://www.apache.org/licenses/LICENSE-2.0
92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes *
102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software
112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS,
122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and
142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License.
152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */
167b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_RUNTIME_H_
18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_RUNTIME_H_
196b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro
20a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include <jni.h>
21c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes#include <stdio.h>
22c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes
23e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes#include <iosfwd>
24799eb3a5555254427db269921042419bc30d4d86Hiroshi Yamauchi#include <set>
256ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <string>
26fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro#include <utility>
276ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <vector>
28578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom
29bad0267eaab9d6a522d05469ff90501deefdb88bMathieu Chartier#include "base/allocator.h"
30a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light#include "compiler_callbacks.h"
3194f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi#include "gc_root.h"
3262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers#include "instrumentation.h"
33576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include "instruction_set.h"
3400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers#include "jobject_comparator.h"
35c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle#include "nativebridge/native_bridge.h"
3683c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier#include "object_callbacks.h"
37576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include "offsets.h"
38c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle#include "profiler_options.h"
397624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko#include "quick/quick_method_frame_info.h"
409d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes#include "runtime_stats.h"
41a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include "safe_map.h"
42b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro
436b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art {
447b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
451d54e73444e017d3a65234e0f193846f3e27472bIan Rogersnamespace gc {
461d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  class Heap;
47576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers}  // namespace gc
482dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersnamespace mirror {
49ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom  class ArtMethod;
501d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  class ClassLoader;
51d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  class Array;
5288474b416eb257078e590bf9bc7957cee604a186Jeff Hao  template<class T> class ObjectArray;
531d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  template<class T> class PrimitiveArray;
541d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  typedef PrimitiveArray<int8_t> ByteArray;
551d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  class String;
561d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  class Throwable;
572dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers}  // namespace mirror
58c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartiernamespace verifier {
59c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartierclass MethodVerifier;
60c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier}
6161e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ClassLinker;
62fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiroclass DexFile;
63cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughesclass InternTable;
64b48b9eb6d181a1f52e2e605cf26a21505f1d46edIan Rogersclass JavaVMExt;
65c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughesclass MonitorList;
66ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogersclass MonitorPool;
67576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersclass NullPointerHandler;
68e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughesclass SignalCatcher;
69576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersclass StackOverflowHandler;
70576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersclass SuspensionHandler;
7161e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ThreadList;
722692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhaoclass Trace;
73d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertzclass Transaction;
7461e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
75e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogerstypedef std::vector<std::pair<std::string, const void*>> RuntimeOptions;
76e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers
77661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// Not all combinations of flags are valid. You may not visit all roots as well as the new roots
78661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// (no logical reason to do this). You also may not start logging new roots and stop logging new
79661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// roots (also no logical reason to do this).
80893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartierenum VisitRootFlags : uint8_t {
81893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  kVisitRootFlagAllRoots = 0x1,
82893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  kVisitRootFlagNewRoots = 0x2,
83893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  kVisitRootFlagStartLoggingNewRoots = 0x4,
84893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  kVisitRootFlagStopLoggingNewRoots = 0x8,
85893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  kVisitRootFlagClearRootLog = 0x10,
86893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier};
87893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier
881fb8620309a4e94d11879aabc33364acfa733904Carl Shapiroclass Runtime {
897b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro public:
9061e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  // Creates and initializes a new runtime.
91e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers  static bool Create(const RuntimeOptions& options, bool ignore_unrecognized)
92b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers      SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
9369b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom
94d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes  bool IsCompiler() const {
952b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko    return compiler_callbacks_ != nullptr;
962b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko  }
972b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko
98a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  bool CanRelocate() const {
99a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light    return !IsCompiler() || compiler_callbacks_->IsRelocationPossible();
100a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  }
101a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light
102a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  bool ShouldRelocate() const {
103a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light    return must_relocate_ && CanRelocate();
104a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  }
105a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light
106a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  bool MustRelocateIfPossible() const {
107a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light    return must_relocate_;
108a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  }
109a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light
1104fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray  bool IsDex2OatEnabled() const {
11164ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light    return dex2oat_enabled_ && IsImageDex2OatEnabled();
11264ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light  }
11364ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light
11464ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light  bool IsImageDex2OatEnabled() const {
11564ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light    return image_dex2oat_enabled_;
1164fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray  }
1174fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray
1182b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko  CompilerCallbacks* GetCompilerCallbacks() {
1192b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko    return compiler_callbacks_;
120d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes  }
121d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes
122caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom  bool IsZygote() const {
123caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom    return is_zygote_;
124caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom  }
125caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom
1268718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum  bool IsExplicitGcDisabled() const {
1278718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum    return is_explicit_gc_disabled_;
1288718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum  }
1298718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum
13012e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang  std::string GetCompilerExecutable() const;
131a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  std::string GetPatchoatExecutable() const;
13212e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang
1336449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  const std::vector<std::string>& GetCompilerOptions() const {
1346449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return compiler_options_;
135a024a0686c3b0fea13f362bff70d65981e5febc5buzbee  }
136a024a0686c3b0fea13f362bff70d65981e5febc5buzbee
1376449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  const std::vector<std::string>& GetImageCompilerOptions() const {
1386449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom    return image_compiler_options_;
1398447d84d847d4562d7a7bce62768c27e7d20a9aaAnwar Ghuloum  }
1408447d84d847d4562d7a7bce62768c27e7d20a9aaAnwar Ghuloum
141c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  const ProfilerOptions& GetProfilerOptions() const {
142c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle    return profiler_options_;
143c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  }
144c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle
14569b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom  // Starts a runtime, which may cause threads to be started and code to run.
146bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom  bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_);
1472ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro
148590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier  bool IsShuttingDown(Thread* self);
149590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier  bool IsShuttingDownLocked() const EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) {
1509af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers    return shutting_down_;
1519af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  }
1529af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
153120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  size_t NumberOfThreadsBeingBorn() const EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) {
154120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers    return threads_being_born_;
155120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  }
156120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
157120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  void StartThreadBirth() EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) {
158120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers    threads_being_born_++;
159120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  }
160120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
161120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  void EndThreadBirth() EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_);
162120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
1639af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  bool IsStarted() const {
1649af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers    return started_;
1659af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  }
166dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes
1677664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier  bool IsFinishedStarting() const {
1687664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier    return finished_starting_;
1697664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier  }
1707664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier
1712ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  static Runtime* Current() {
1722ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro    return instance_;
1732ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro  }
17461e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
175ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
176ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // callers should prefer.
177ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // This isn't marked ((noreturn)) because then gcc will merge multiple calls
178ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // in a single function together. This reduces code size slightly, but means
179ffe6736397d17457188727510f0a2953f69a383aElliott Hughes  // that the native stack trace we get may point at the wrong call site.
180b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers  static void Abort() LOCKS_EXCLUDED(Locks::abort_lock_);
181ffe6736397d17457188727510f0a2953f69a383aElliott Hughes
182365c10235438607541fa2259a5fec48061b90bd8Ian Rogers  // Returns the "main" ThreadGroup, used when attaching user threads.
183034f76b91225bea769d6185d7dad5e243af4ffa0Brian Carlstrom  jobject GetMainThreadGroup() const;
184365c10235438607541fa2259a5fec48061b90bd8Ian Rogers
185365c10235438607541fa2259a5fec48061b90bd8Ian Rogers  // Returns the "system" ThreadGroup, used when attaching our internal threads.
186034f76b91225bea769d6185d7dad5e243af4ffa0Brian Carlstrom  jobject GetSystemThreadGroup() const;
187365c10235438607541fa2259a5fec48061b90bd8Ian Rogers
188ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom  // Returns the system ClassLoader which represents the CLASSPATH.
189ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom  jobject GetSystemClassLoader() const;
190ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom
191462c94449720e0dc6b93d7138d835d345ccf67aeElliott Hughes  // Attaches the calling native thread to the runtime.
192664bebf92eb2151b9b570ccd42ac4b6056c3ea9cMathieu Chartier  bool AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group,
193664bebf92eb2151b9b570ccd42ac4b6056c3ea9cMathieu Chartier                           bool create_peer);
194b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro
195bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes  void CallExitHook(jint status);
196bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes
19761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  // Detaches the current native thread from the runtime.
198b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers  void DetachCurrentThread() LOCKS_EXCLUDED(Locks::mutator_lock_);
19961e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
20000f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers  void DumpForSigQuit(std::ostream& os)
201b363f666883860d40823d5528df3c98c897f74f4Mathieu Chartier      EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_);
20221a5bf2dc8c9cb3fbe5a30a88d1149c328e3aacaElliott Hughes  void DumpLockHolders(std::ostream& os);
203e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes
20461e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  ~Runtime();
205b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro
206a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom  const std::string& GetBootClassPathString() const {
207a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom    return boot_class_path_string_;
208b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom  }
209b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom
210a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom  const std::string& GetClassPathString() const {
211a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom    return class_path_string_;
2127a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro  }
2137a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro
214a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom  ClassLinker* GetClassLinker() const {
215a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom    return class_linker_;
2167ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
2177ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
2187ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  size_t GetDefaultStackSize() const {
2197ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes    return default_stack_size_;
2207ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
2217ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
2221d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  gc::Heap* GetHeap() const {
223b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes    return heap_;
224b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  }
225b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes
226cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes  InternTable* GetInternTable() const {
227e810452722ac83b294d1f7aa80bdd88e547d5af0Brian Carlstrom    DCHECK(intern_table_ != NULL);
228cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes    return intern_table_;
229cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes  }
230cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes
2310af5543f8ea20c3e655b2d748a1b7dcf283792feElliott Hughes  JavaVMExt* GetJavaVM() const {
232c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes    return java_vm_;
233f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes  }
234f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes
235d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers  size_t GetMaxSpinsBeforeThinkLockInflation() const {
236d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers    return max_spins_before_thin_lock_inflation_;
237d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers  }
238d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers
239c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes  MonitorList* GetMonitorList() const {
240c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes    return monitor_list_;
241c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes  }
242c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes
243ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers  MonitorPool* GetMonitorPool() const {
244ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers    return monitor_pool_;
245ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers  }
246ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers
247c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  // Is the given object the special object used to mark a cleared JNI weak global?
248c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  bool IsClearedJniWeakGlobal(mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
249c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers
250c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  // Get the special object used to mark a cleared JNI weak global.
251c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  mirror::Object* GetClearedJniWeakGlobal() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
252c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers
253ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi  mirror::Throwable* GetPreAllocatedOutOfMemoryError() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
254225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes
25563557459a4098294a9ff44d035241de2966047c0Ian Rogers  mirror::Throwable* GetPreAllocatedNoClassDefFoundError()
25663557459a4098294a9ff44d035241de2966047c0Ian Rogers      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
25763557459a4098294a9ff44d035241de2966047c0Ian Rogers
258225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes  const std::vector<std::string>& GetProperties() const {
259225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes    return properties_;
260225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes  }
261225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes
262d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes  ThreadList* GetThreadList() const {
263d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes    return thread_list_;
264d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes  }
265d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes
266491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom  static const char* GetVersion() {
2672153f93df36b59a61fed15bef8e7304010be04b5Andreas Gampe    return "2.1.0";
2687ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  }
2697ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
270c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier  void DisallowNewSystemWeaks() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_);
271c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier  void AllowNewSystemWeaks() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
272c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier
2731d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  // Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If
2741d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  // clean_dirty is true then dirty roots will be marked as non-dirty after visiting.
275893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  void VisitRoots(RootCallback* visitor, void* arg, VisitRootFlags flags = kVisitRootFlagAllRoots)
2761d54e73444e017d3a65234e0f193846f3e27472bIan Rogers      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
2771f87008b165d26541d832ff805250afdc89c253dBrian Carlstrom
2789ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier  // Visit all of the roots we can do safely do concurrently.
279893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  void VisitConcurrentRoots(RootCallback* visitor, void* arg,
280893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier                            VisitRootFlags flags = kVisitRootFlagAllRoots)
281c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
2829ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier
283858f1c5fd5e528d0b16040ced74d4636046a42d8Mathieu Chartier  // Visit all of the non thread roots, we can do this with mutators unpaused.
28483c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier  void VisitNonThreadRoots(RootCallback* visitor, void* arg)
285c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
286858f1c5fd5e528d0b16040ced74d4636046a42d8Mathieu Chartier
2879ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier  // Visit all other roots which must be done with mutators suspended.
28883c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier  void VisitNonConcurrentRoots(RootCallback* visitor, void* arg)
289c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
2909ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier
2916aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier  // Sweep system weaks, the system weak is deleted if the visitor return nullptr. Otherwise, the
2926aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier  // system weak is updated to be the visitor's returned value.
29383c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier  void SweepSystemWeaks(IsMarkedCallback* visitor, void* arg)
294ad2541a59c00c2c69e8973088891a2b5257c9780Mathieu Chartier      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
2956aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier
296893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  // Constant roots are the roots which never change after the runtime is initialized, they only
297893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  // need to be visited once per GC cycle.
298893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier  void VisitConstantRoots(RootCallback* callback, void* arg)
299893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
300893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier
3019af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  // Returns a special method that calls into a trampoline for runtime method resolution
302e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers  mirror::ArtMethod* GetResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
3039af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
3049af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  bool HasResolutionMethod() const {
30594f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    return !resolution_method_.IsNull();
3069af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  }
3079af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
308ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom  void SetResolutionMethod(mirror::ArtMethod* method) {
30994f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    resolution_method_ = GcRoot<mirror::ArtMethod>(method);
3109af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  }
3119af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
312ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom  mirror::ArtMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
3131984651929744dd603fd082e23eacd877b9bc177Ian Rogers
314e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers  // Returns a special method that calls into a trampoline for runtime imt conflicts.
315e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers  mirror::ArtMethod* GetImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
31688474b416eb257078e590bf9bc7957cee604a186Jeff Hao
31788474b416eb257078e590bf9bc7957cee604a186Jeff Hao  bool HasImtConflictMethod() const {
31894f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    return !imt_conflict_method_.IsNull();
31988474b416eb257078e590bf9bc7957cee604a186Jeff Hao  }
32088474b416eb257078e590bf9bc7957cee604a186Jeff Hao
32188474b416eb257078e590bf9bc7957cee604a186Jeff Hao  void SetImtConflictMethod(mirror::ArtMethod* method) {
32294f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    imt_conflict_method_ = GcRoot<mirror::ArtMethod>(method);
32388474b416eb257078e590bf9bc7957cee604a186Jeff Hao  }
32488474b416eb257078e590bf9bc7957cee604a186Jeff Hao
32588474b416eb257078e590bf9bc7957cee604a186Jeff Hao  mirror::ArtMethod* CreateImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
32688474b416eb257078e590bf9bc7957cee604a186Jeff Hao
32788474b416eb257078e590bf9bc7957cee604a186Jeff Hao  // Returns an imt with every entry set to conflict, used as default imt for all classes.
328ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi  mirror::ObjectArray<mirror::ArtMethod>* GetDefaultImt()
329e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
33088474b416eb257078e590bf9bc7957cee604a186Jeff Hao
33188474b416eb257078e590bf9bc7957cee604a186Jeff Hao  bool HasDefaultImt() const {
33294f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    return !default_imt_.IsNull();
33388474b416eb257078e590bf9bc7957cee604a186Jeff Hao  }
33488474b416eb257078e590bf9bc7957cee604a186Jeff Hao
33588474b416eb257078e590bf9bc7957cee604a186Jeff Hao  void SetDefaultImt(mirror::ObjectArray<mirror::ArtMethod>* imt) {
33694f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    default_imt_ = GcRoot<mirror::ObjectArray<mirror::ArtMethod>>(imt);
33788474b416eb257078e590bf9bc7957cee604a186Jeff Hao  }
33888474b416eb257078e590bf9bc7957cee604a186Jeff Hao
33988474b416eb257078e590bf9bc7957cee604a186Jeff Hao  mirror::ObjectArray<mirror::ArtMethod>* CreateDefaultImt(ClassLinker* cl)
34088474b416eb257078e590bf9bc7957cee604a186Jeff Hao      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
34188474b416eb257078e590bf9bc7957cee604a186Jeff Hao
342ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers  // Returns a special method that describes all callee saves being spilled to the stack.
3434f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  enum CalleeSaveType {
3444f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kSaveAll,
3454f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kRefsOnly,
3464f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kRefsAndArgs,
3474f0d07c783afef89703dce32c94440fc8621a29bIan Rogers    kLastCalleeSaveType  // Value used for iteration
3484f0d07c783afef89703dce32c94440fc8621a29bIan Rogers  };
3499af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
3509af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  bool HasCalleeSaveMethod(CalleeSaveType type) const {
35194f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi    return !callee_save_methods_[type].IsNull();
3529af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  }
3539af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
354ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi  mirror::ArtMethod* GetCalleeSaveMethod(CalleeSaveType type)
355e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
356ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi
357ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi  mirror::ArtMethod* GetCalleeSaveMethodUnchecked(CalleeSaveType type)
358e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
3599af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
3607624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  QuickMethodFrameInfo GetCalleeSaveMethodFrameInfo(CalleeSaveType type) const {
3617624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko    return callee_save_method_frame_infos_[type];
3627624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  }
3637624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko
364ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi  QuickMethodFrameInfo GetRuntimeMethodFrameInfo(mirror::ArtMethod* method)
365ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
3667624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko
367936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers  static size_t GetCalleeSaveMethodOffset(CalleeSaveType type) {
368936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers    return OFFSETOF_MEMBER(Runtime, callee_save_methods_[type]);
369936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers  }
370936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers
3717624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  InstructionSet GetInstructionSet() const {
3727624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko    return instruction_set_;
3737624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  }
3744f0d07c783afef89703dce32c94440fc8621a29bIan Rogers
3757624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  void SetInstructionSet(InstructionSet instruction_set);
3769af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
3777624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  void SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type);
37800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers
3797624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  mirror::ArtMethod* CreateCalleeSaveMethod(CalleeSaveType type)
380b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
381ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers
3829d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  int32_t GetStat(int kind);
3839d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
3849af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  RuntimeStats* GetStats() {
3859af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers    return &stats_;
3869af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers  }
3879d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
3889d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  bool HasStatsEnabled() const {
3899d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes    return stats_enabled_;
3909d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  }
3919d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
3929d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  void ResetStats(int kinds);
3939d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
3949d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  void SetStatsEnabled(bool new_state);
3959d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
3963de95a7b0a2d30cde6dc92b72c35df3a61002124Narayan Kamath  void PreZygoteFork();
397bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom  bool InitZygote();
398bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom  void DidForkFromZygote();
399caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom
4009bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers  const instrumentation::Instrumentation* GetInstrumentation() const {
4019bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers    return &instrumentation_;
4029bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers  }
4039bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers
40462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers  instrumentation::Instrumentation* GetInstrumentation() {
40562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers    return &instrumentation_;
40662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers  }
4072692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhao
408b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  bool UseCompileTimeClassPath() const {
409b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes    return use_compile_time_class_path_;
410b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  }
4119af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers
412e6da9af8dfe0a3e3fbc2be700554f6478380e7b9Mathieu Chartier  void AddMethodVerifier(verifier::MethodVerifier* verifier) LOCKS_EXCLUDED(method_verifier_lock_);
413e6da9af8dfe0a3e3fbc2be700554f6478380e7b9Mathieu Chartier  void RemoveMethodVerifier(verifier::MethodVerifier* verifier)
414e6da9af8dfe0a3e3fbc2be700554f6478380e7b9Mathieu Chartier      LOCKS_EXCLUDED(method_verifier_lock_);
415c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier
41600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers  const std::vector<const DexFile*>& GetCompileTimeClassPath(jobject class_loader);
41700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers  void SetCompileTimeClassPath(jobject class_loader, std::vector<const DexFile*>& class_path);
418b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes
419c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  void StartProfiler(const char* profile_output_filename);
42039c3bfbd03d85c63cfbe69f17ce5800ccc7d6c13Dave Allison  void UpdateProfilerState(int state);
4210aded089f565008ba5908e395e5914ca4f91f2deDave Allison
422d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  // Transaction support.
423ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz  bool IsActiveTransaction() const {
424ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz    return preinitialization_transaction_ != nullptr;
425ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz  }
426d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void EnterTransactionMode(Transaction* transaction);
427d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void ExitTransactionMode();
42837f05ef45e0393de812d51261dc293240c17294dFred Shih  void RecordWriteFieldBoolean(mirror::Object* obj, MemberOffset field_offset, uint8_t value,
42937f05ef45e0393de812d51261dc293240c17294dFred Shih                               bool is_volatile) const;
43037f05ef45e0393de812d51261dc293240c17294dFred Shih  void RecordWriteFieldByte(mirror::Object* obj, MemberOffset field_offset, int8_t value,
43137f05ef45e0393de812d51261dc293240c17294dFred Shih                            bool is_volatile) const;
43237f05ef45e0393de812d51261dc293240c17294dFred Shih  void RecordWriteFieldChar(mirror::Object* obj, MemberOffset field_offset, uint16_t value,
43337f05ef45e0393de812d51261dc293240c17294dFred Shih                            bool is_volatile) const;
43437f05ef45e0393de812d51261dc293240c17294dFred Shih  void RecordWriteFieldShort(mirror::Object* obj, MemberOffset field_offset, int16_t value,
43537f05ef45e0393de812d51261dc293240c17294dFred Shih                          bool is_volatile) const;
436d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordWriteField32(mirror::Object* obj, MemberOffset field_offset, uint32_t value,
437d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz                          bool is_volatile) const;
438d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordWriteField64(mirror::Object* obj, MemberOffset field_offset, uint64_t value,
439d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz                          bool is_volatile) const;
440d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordWriteFieldReference(mirror::Object* obj, MemberOffset field_offset,
441d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz                                 mirror::Object* value, bool is_volatile) const;
442d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const
443d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz      SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
444d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code) const
445d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz      EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
446d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code) const
447d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz      EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
448d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordStrongStringRemoval(mirror::String* s, uint32_t hash_code) const
449d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz      EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
450d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  void RecordWeakStringRemoval(mirror::String* s, uint32_t hash_code) const
451d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz      EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_);
452d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz
45315d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  void SetFaultMessage(const std::string& message);
45415d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  // Only read by the signal handler, NO_THREAD_SAFETY_ANALYSIS to prevent lock order violations
45515d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  // with the unexpected_signal_lock_.
45615d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  const std::string& GetFaultMessage() NO_THREAD_SAFETY_ANALYSIS {
45715d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier    return fault_message_;
45815d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  }
45915d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier
4608afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  void AddCurrentRuntimeFeaturesAsDex2OatArguments(std::vector<std::string>* arg_vector) const;
4618afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers
462b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  bool ExplicitNullChecks() const {
463b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison    return null_pointer_handler_ == nullptr;
464b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  }
465b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison
466b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  bool ExplicitSuspendChecks() const {
467b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison    return suspend_handler_ == nullptr;
468b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  }
469b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison
470b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  bool ExplicitStackOverflowChecks() const {
471b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison    return stack_overflow_handler_ == nullptr;
472b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  }
473b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison
4744a200f56b7075309316b04d550c9cc50f8314eddJeff Hao  bool IsVerificationEnabled() const {
4754a200f56b7075309316b04d550c9cc50f8314eddJeff Hao    return verify_;
4764a200f56b7075309316b04d550c9cc50f8314eddJeff Hao  }
4774a200f56b7075309316b04d550c9cc50f8314eddJeff Hao
478da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier  bool RunningOnValgrind() const {
479da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier    return running_on_valgrind_;
480da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier  }
481da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier
482f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao  void SetTargetSdkVersion(int32_t version) {
483f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao    target_sdk_version_ = version;
484f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao  }
485f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao
486f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao  int32_t GetTargetSdkVersion() const {
487f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao    return target_sdk_version_;
488f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao  }
489f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao
4908afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  static const char* GetDefaultInstructionSetFeatures() {
4918afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers    return kDefaultInstructionSetFeatures;
4928afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  }
4938afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers
494b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro private:
495457005c557b8762475db3220ce5a747d629f975bElliott Hughes  static void InitPlatformSignalHandlers();
496ffe6736397d17457188727510f0a2953f69a383aElliott Hughes
497dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes  Runtime();
49861e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
499c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes  void BlockSignals();
500c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes
501e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers  bool Init(const RuntimeOptions& options, bool ignore_unrecognized)
502b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers      SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
503b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers  void InitNativeMethods() LOCKS_EXCLUDED(Locks::mutator_lock_);
504365c10235438607541fa2259a5fec48061b90bd8Ian Rogers  void InitThreadGroups(Thread* self);
505ff17f1fd3ff32f93e45588eb2b158832d73f9afaElliott Hughes  void RegisterRuntimeNativeMethods(JNIEnv* env);
506d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes
50785d1545e985ac689db4bad7849880e843707c862Elliott Hughes  void StartDaemonThreads();
508d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes  void StartSignalCatcher();
50961e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
510b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  // A pointer to the active runtime or NULL.
511b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  static Runtime* instance_;
512b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes
5138afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  static const char* kDefaultInstructionSetFeatures;
5148afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers
5158afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  // NOTE: these must match the gc::ProcessState values as they come directly from the framework.
5168afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  static constexpr int kProfileForground = 0;
5178afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers  static constexpr int kProfileBackgrouud = 1;
5188afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers
51994f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi  GcRoot<mirror::ArtMethod> callee_save_methods_[kLastCalleeSaveType];
52094f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi  GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_;
52163557459a4098294a9ff44d035241de2966047c0Ian Rogers  GcRoot<mirror::Throwable> pre_allocated_NoClassDefFoundError_;
52294f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi  GcRoot<mirror::ArtMethod> resolution_method_;
52394f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi  GcRoot<mirror::ArtMethod> imt_conflict_method_;
52494f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi  GcRoot<mirror::ObjectArray<mirror::ArtMethod>> default_imt_;
5256ed19fd1b08abbc438781ae3e6fea111c1f92315Ian Rogers
526c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  // Special sentinel object used to invalid conditions in JNI (cleared weak references) and
527c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  // JDWP (invalid references).
528c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers  GcRoot<mirror::Object> sentinel_;
529c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers
5307624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  InstructionSet instruction_set_;
5317624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko  QuickMethodFrameInfo callee_save_method_frame_infos_[kLastCalleeSaveType];
5327624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko
5332b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko  CompilerCallbacks* compiler_callbacks_;
5349ca7a1fdd0daa546b790adb6a24dbc13c22df76aElliott Hughes  bool is_zygote_;
535a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  bool must_relocate_;
536069387a60cb2b72e116cc38b32e14403f092df8fMathieu Chartier  bool is_concurrent_gc_enabled_;
5378718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum  bool is_explicit_gc_disabled_;
5384fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray  bool dex2oat_enabled_;
53964ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light  bool image_dex2oat_enabled_;
5400a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom
54112e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang  std::string compiler_executable_;
542a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light  std::string patchoat_executable_;
5436449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  std::vector<std::string> compiler_options_;
5446449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom  std::vector<std::string> image_compiler_options_;
5457467ee05012e1fd9834df74663c1ebda46f5636bDragos Sbirlea
546a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom  std::string boot_class_path_string_;
547a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom  std::string class_path_string_;
5487ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes  std::vector<std::string> properties_;
5497ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes
550b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom  // The default stack size for managed threads created by the runtime.
551be759c63c6bb58b76ac71cad2c5a736bd31f374dElliott Hughes  size_t default_stack_size_;
552b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom
5531d54e73444e017d3a65234e0f193846f3e27472bIan Rogers  gc::Heap* heap_;
554b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes
555d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers  // The number of spins that are done before thread suspension is used to forcibly inflate.
556d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers  size_t max_spins_before_thin_lock_inflation_;
557c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes  MonitorList* monitor_list_;
558ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers  MonitorPool* monitor_pool_;
559c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes
560b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro  ThreadList* thread_list_;
56161e019d291583029c01b61b93bea750f2b663c37Carl Shapiro
562cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes  InternTable* intern_table_;
563cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes
564b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom  ClassLinker* class_linker_;
565b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom
566e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes  SignalCatcher* signal_catcher_;
56794ce37a3919a0bdb8855a3d3264a50df1dbc41beElliott Hughes  std::string stack_trace_file_;
568e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes
569c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes  JavaVMExt* java_vm_;
570f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes
57115d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  // Fault message, printed when we get a SIGSEGV.
57215d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  Mutex fault_message_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
57315d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier  std::string fault_message_ GUARDED_BY(fault_message_lock_);
57415d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier
575c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier  // Method verifier set, used so that we can update their GC roots.
576719d1a33f6569864f529e5a3fff59e7bca97aad0Ian Rogers  Mutex method_verifier_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
577c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier  std::set<verifier::MethodVerifier*> method_verifiers_;
578c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier
579120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  // A non-zero value indicates that a thread has been created but not yet initialized. Guarded by
580120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  // the shutdown lock so that threads aren't born while we're shutting down.
581120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  size_t threads_being_born_ GUARDED_BY(Locks::runtime_shutdown_lock_);
582120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
583120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  // Waited upon until no threads are being born.
584700a402244a1a423da4f3ba8032459f4b65fa18fIan Rogers  std::unique_ptr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_);
585120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
586120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  // Set when runtime shutdown is past the point that new threads may attach.
587120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  bool shutting_down_ GUARDED_BY(Locks::runtime_shutdown_lock_);
588120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
589120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  // The runtime is starting to shutdown but is blocked waiting on shutdown_cond_.
590120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers  bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_);
591120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers
592dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes  bool started_;
593dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes
5947664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier  // New flag added which tells us if the runtime has finished starting. If
5957664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier  // this flag is set then the Daemon threads are created and the class loader
5967664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier  // is created. This flag is needed for knowing if its safe to request CMS.
5977664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier  bool finished_starting_;
5987664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier
5996ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  // Hooks supported by JNI_CreateJavaVM
6006ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  jint (*vfprintf_)(FILE* stream, const char* format, va_list ap);
6016ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  void (*exit_)(jint status);
6026ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom  void (*abort_)();
6036ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom
6049d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  bool stats_enabled_;
6059d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes  RuntimeStats stats_;
6069d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes
607da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier  const bool running_on_valgrind_;
608da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier
6090aded089f565008ba5908e395e5914ca4f91f2deDave Allison  std::string profile_output_filename_;
610c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  ProfilerOptions profiler_options_;
611c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle  bool profiler_started_;
6120aded089f565008ba5908e395e5914ca4f91f2deDave Allison
613b5e81858a47dd7ed051135f6982fbc4e13d0f309jeffhao  bool method_trace_;
614b5e81858a47dd7ed051135f6982fbc4e13d0f309jeffhao  std::string method_trace_file_;
615b5e81858a47dd7ed051135f6982fbc4e13d0f309jeffhao  size_t method_trace_file_size_;
61662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers  instrumentation::Instrumentation instrumentation_;
6172692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhao
618bad0267eaab9d6a522d05469ff90501deefdb88bMathieu Chartier  typedef AllocationTrackingSafeMap<jobject, std::vector<const DexFile*>,
619bad0267eaab9d6a522d05469ff90501deefdb88bMathieu Chartier                                    kAllocatorTagCompileTimeClassPath, JobjectComparator>
620bad0267eaab9d6a522d05469ff90501deefdb88bMathieu Chartier      CompileTimeClassPaths;
621b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  CompileTimeClassPaths compile_time_class_paths_;
622b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes  bool use_compile_time_class_path_;
623131aef8c94292cc530da2fd91ee98d1432352959Elliott Hughes
624365c10235438607541fa2259a5fec48061b90bd8Ian Rogers  jobject main_thread_group_;
625365c10235438607541fa2259a5fec48061b90bd8Ian Rogers  jobject system_thread_group_;
626365c10235438607541fa2259a5fec48061b90bd8Ian Rogers
627ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom  // As returned by ClassLoader.getSystemClassLoader().
628ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom  jobject system_class_loader_;
629ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom
6302e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi  // If true, then we dump the GC cumulative timings on shutdown.
6312e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi  bool dump_gc_performance_on_shutdown_;
6322e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi
633d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz  // Transaction used for pre-initializing classes at compilation time.
634ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz  Transaction* preinitialization_transaction_;
635b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  NullPointerHandler* null_pointer_handler_;
636b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  SuspensionHandler* suspend_handler_;
637b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison  StackOverflowHandler* stack_overflow_handler_;
638d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz
6394a200f56b7075309316b04d550c9cc50f8314eddJeff Hao  // If false, verification is disabled. True by default.
6404a200f56b7075309316b04d550c9cc50f8314eddJeff Hao  bool verify_;
6414a200f56b7075309316b04d550c9cc50f8314eddJeff Hao
642f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao  // Specifies target SDK version to allow workarounds for certain API levels.
643f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao  int32_t target_sdk_version_;
644f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao
64569dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  // Implicit checks flags.
64669dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  bool implicit_null_checks_;       // NullPointer checks are implicit.
64769dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  bool implicit_so_checks_;         // StackOverflow checks are implicit.
64869dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison  bool implicit_suspend_checks_;    // Thread suspension checks are implicit.
64969dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison
650a68629ed992e2eef7b139b09e46ebe8fd3fb5ef2Calin Juravle  // The filename to the native bridge library. If this is not empty the native bridge will be
651a68629ed992e2eef7b139b09e46ebe8fd3fb5ef2Calin Juravle  // initialized and loaded from the given file (initialized and available). An empty value means
652a68629ed992e2eef7b139b09e46ebe8fd3fb5ef2Calin Juravle  // that there's no native bridge (initialized but not available).
653c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  //
654c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // The native bridge allows running native code compiled for a foreign ISA. The way it works is,
655c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // if standard dlopen fails to load native library associated with native activity, it calls to
656c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // the native bridge to load it and then gets the trampoline for the entry to native activity.
657a68629ed992e2eef7b139b09e46ebe8fd3fb5ef2Calin Juravle  std::string native_bridge_library_filename_;
658c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle
659c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // Native bridge library runtime callbacks. They represent the runtime interface to native bridge.
660c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  //
661c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // The interface is expected to expose the following methods:
662c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // getMethodShorty(): in the case of native method calling JNI native function CallXXXXMethodY(),
663c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  //   native bridge calls back to VM for the shorty of the method so that it can prepare based on
664c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  //   host calling convention.
665c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  // getNativeMethodCount() and getNativeMethods(): in case of JNI function UnregisterNatives(),
666c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  //   native bridge can call back to get all native methods of specified class so that all
667c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  //   corresponding trampolines can be destroyed.
668c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle  android::NativeBridgeRuntimeCallbacks native_bridge_art_callbacks_;
669c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle
67061e019d291583029c01b61b93bea750f2b663c37Carl Shapiro  DISALLOW_COPY_AND_ASSIGN(Runtime);
6717b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro};
6727b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
6736b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro}  // namespace art
6747b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro
675fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif  // ART_RUNTIME_RUNTIME_H_
676