xref: /aosp_15_r20/art/runtime/runtime.h (revision 795d594fd825385562da6b089ea9b2033f3abf5a)
1*795d594fSAndroid Build Coastguard Worker /*
2*795d594fSAndroid Build Coastguard Worker  * Copyright (C) 2011 The Android Open Source Project
3*795d594fSAndroid Build Coastguard Worker  *
4*795d594fSAndroid Build Coastguard Worker  * Licensed under the Apache License, Version 2.0 (the "License");
5*795d594fSAndroid Build Coastguard Worker  * you may not use this file except in compliance with the License.
6*795d594fSAndroid Build Coastguard Worker  * You may obtain a copy of the License at
7*795d594fSAndroid Build Coastguard Worker  *
8*795d594fSAndroid Build Coastguard Worker  *      http://www.apache.org/licenses/LICENSE-2.0
9*795d594fSAndroid Build Coastguard Worker  *
10*795d594fSAndroid Build Coastguard Worker  * Unless required by applicable law or agreed to in writing, software
11*795d594fSAndroid Build Coastguard Worker  * distributed under the License is distributed on an "AS IS" BASIS,
12*795d594fSAndroid Build Coastguard Worker  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13*795d594fSAndroid Build Coastguard Worker  * See the License for the specific language governing permissions and
14*795d594fSAndroid Build Coastguard Worker  * limitations under the License.
15*795d594fSAndroid Build Coastguard Worker  */
16*795d594fSAndroid Build Coastguard Worker 
17*795d594fSAndroid Build Coastguard Worker #ifndef ART_RUNTIME_RUNTIME_H_
18*795d594fSAndroid Build Coastguard Worker #define ART_RUNTIME_RUNTIME_H_
19*795d594fSAndroid Build Coastguard Worker 
20*795d594fSAndroid Build Coastguard Worker #include <jni.h>
21*795d594fSAndroid Build Coastguard Worker #include <stdio.h>
22*795d594fSAndroid Build Coastguard Worker 
23*795d594fSAndroid Build Coastguard Worker #include <iosfwd>
24*795d594fSAndroid Build Coastguard Worker #include <memory>
25*795d594fSAndroid Build Coastguard Worker #include <optional>
26*795d594fSAndroid Build Coastguard Worker #include <set>
27*795d594fSAndroid Build Coastguard Worker #include <string>
28*795d594fSAndroid Build Coastguard Worker #include <utility>
29*795d594fSAndroid Build Coastguard Worker #include <vector>
30*795d594fSAndroid Build Coastguard Worker 
31*795d594fSAndroid Build Coastguard Worker #include "app_info.h"
32*795d594fSAndroid Build Coastguard Worker #include "base/locks.h"
33*795d594fSAndroid Build Coastguard Worker #include "base/macros.h"
34*795d594fSAndroid Build Coastguard Worker #include "base/mem_map.h"
35*795d594fSAndroid Build Coastguard Worker #include "base/metrics/metrics.h"
36*795d594fSAndroid Build Coastguard Worker #include "base/os.h"
37*795d594fSAndroid Build Coastguard Worker #include "base/unix_file/fd_file.h"
38*795d594fSAndroid Build Coastguard Worker #include "compat_framework.h"
39*795d594fSAndroid Build Coastguard Worker #include "deoptimization_kind.h"
40*795d594fSAndroid Build Coastguard Worker #include "dex/dex_file_types.h"
41*795d594fSAndroid Build Coastguard Worker #include "experimental_flags.h"
42*795d594fSAndroid Build Coastguard Worker #include "gc_root.h"
43*795d594fSAndroid Build Coastguard Worker #include "instrumentation.h"
44*795d594fSAndroid Build Coastguard Worker #include "jdwp_provider.h"
45*795d594fSAndroid Build Coastguard Worker #include "jni/jni_id_manager.h"
46*795d594fSAndroid Build Coastguard Worker #include "jni_id_type.h"
47*795d594fSAndroid Build Coastguard Worker #include "metrics/reporter.h"
48*795d594fSAndroid Build Coastguard Worker #include "obj_ptr.h"
49*795d594fSAndroid Build Coastguard Worker #include "offsets.h"
50*795d594fSAndroid Build Coastguard Worker #include "process_state.h"
51*795d594fSAndroid Build Coastguard Worker #include "quick/quick_method_frame_info.h"
52*795d594fSAndroid Build Coastguard Worker #include "reflective_value_visitor.h"
53*795d594fSAndroid Build Coastguard Worker #include "runtime_stats.h"
54*795d594fSAndroid Build Coastguard Worker 
55*795d594fSAndroid Build Coastguard Worker namespace art HIDDEN {
56*795d594fSAndroid Build Coastguard Worker 
57*795d594fSAndroid Build Coastguard Worker namespace gc {
58*795d594fSAndroid Build Coastguard Worker class AbstractSystemWeakHolder;
59*795d594fSAndroid Build Coastguard Worker class Heap;
60*795d594fSAndroid Build Coastguard Worker }  // namespace gc
61*795d594fSAndroid Build Coastguard Worker 
62*795d594fSAndroid Build Coastguard Worker namespace hiddenapi {
63*795d594fSAndroid Build Coastguard Worker enum class EnforcementPolicy;
64*795d594fSAndroid Build Coastguard Worker }  // namespace hiddenapi
65*795d594fSAndroid Build Coastguard Worker 
66*795d594fSAndroid Build Coastguard Worker namespace jit {
67*795d594fSAndroid Build Coastguard Worker class Jit;
68*795d594fSAndroid Build Coastguard Worker class JitCodeCache;
69*795d594fSAndroid Build Coastguard Worker class JitOptions;
70*795d594fSAndroid Build Coastguard Worker }  // namespace jit
71*795d594fSAndroid Build Coastguard Worker 
72*795d594fSAndroid Build Coastguard Worker namespace jni {
73*795d594fSAndroid Build Coastguard Worker class SmallLrtAllocator;
74*795d594fSAndroid Build Coastguard Worker }  // namespace jni
75*795d594fSAndroid Build Coastguard Worker 
76*795d594fSAndroid Build Coastguard Worker namespace mirror {
77*795d594fSAndroid Build Coastguard Worker class Array;
78*795d594fSAndroid Build Coastguard Worker class ClassLoader;
79*795d594fSAndroid Build Coastguard Worker class DexCache;
80*795d594fSAndroid Build Coastguard Worker template<class T> class ObjectArray;
81*795d594fSAndroid Build Coastguard Worker template<class T> class PrimitiveArray;
82*795d594fSAndroid Build Coastguard Worker using ByteArray = PrimitiveArray<int8_t>;
83*795d594fSAndroid Build Coastguard Worker class String;
84*795d594fSAndroid Build Coastguard Worker class Throwable;
85*795d594fSAndroid Build Coastguard Worker }  // namespace mirror
86*795d594fSAndroid Build Coastguard Worker namespace ti {
87*795d594fSAndroid Build Coastguard Worker class Agent;
88*795d594fSAndroid Build Coastguard Worker class AgentSpec;
89*795d594fSAndroid Build Coastguard Worker }  // namespace ti
90*795d594fSAndroid Build Coastguard Worker namespace verifier {
91*795d594fSAndroid Build Coastguard Worker class MethodVerifier;
92*795d594fSAndroid Build Coastguard Worker enum class VerifyMode : int8_t;
93*795d594fSAndroid Build Coastguard Worker }  // namespace verifier
94*795d594fSAndroid Build Coastguard Worker class ArenaPool;
95*795d594fSAndroid Build Coastguard Worker class ArtMethod;
96*795d594fSAndroid Build Coastguard Worker enum class CalleeSaveType: uint32_t;
97*795d594fSAndroid Build Coastguard Worker class ClassLinker;
98*795d594fSAndroid Build Coastguard Worker class CompilerCallbacks;
99*795d594fSAndroid Build Coastguard Worker class Dex2oatImageTest;
100*795d594fSAndroid Build Coastguard Worker class DexFile;
101*795d594fSAndroid Build Coastguard Worker enum class InstructionSet;
102*795d594fSAndroid Build Coastguard Worker class InternTable;
103*795d594fSAndroid Build Coastguard Worker class IsMarkedVisitor;
104*795d594fSAndroid Build Coastguard Worker class JavaVMExt;
105*795d594fSAndroid Build Coastguard Worker class LinearAlloc;
106*795d594fSAndroid Build Coastguard Worker class MonitorList;
107*795d594fSAndroid Build Coastguard Worker class MonitorPool;
108*795d594fSAndroid Build Coastguard Worker class NullPointerHandler;
109*795d594fSAndroid Build Coastguard Worker class OatFileAssistantTest;
110*795d594fSAndroid Build Coastguard Worker class OatFileManager;
111*795d594fSAndroid Build Coastguard Worker class Plugin;
112*795d594fSAndroid Build Coastguard Worker struct RuntimeArgumentMap;
113*795d594fSAndroid Build Coastguard Worker class RuntimeCallbacks;
114*795d594fSAndroid Build Coastguard Worker class SignalCatcher;
115*795d594fSAndroid Build Coastguard Worker class StackOverflowHandler;
116*795d594fSAndroid Build Coastguard Worker class SuspensionHandler;
117*795d594fSAndroid Build Coastguard Worker class ThreadList;
118*795d594fSAndroid Build Coastguard Worker class ThreadPool;
119*795d594fSAndroid Build Coastguard Worker class Trace;
120*795d594fSAndroid Build Coastguard Worker struct TraceConfig;
121*795d594fSAndroid Build Coastguard Worker 
122*795d594fSAndroid Build Coastguard Worker using RuntimeOptions = std::vector<std::pair<std::string, const void*>>;
123*795d594fSAndroid Build Coastguard Worker 
124*795d594fSAndroid Build Coastguard Worker class Runtime {
125*795d594fSAndroid Build Coastguard Worker  public:
126*795d594fSAndroid Build Coastguard Worker   // Parse raw runtime options.
127*795d594fSAndroid Build Coastguard Worker   EXPORT static bool ParseOptions(const RuntimeOptions& raw_options,
128*795d594fSAndroid Build Coastguard Worker                                   bool ignore_unrecognized,
129*795d594fSAndroid Build Coastguard Worker                                   RuntimeArgumentMap* runtime_options);
130*795d594fSAndroid Build Coastguard Worker 
131*795d594fSAndroid Build Coastguard Worker   // Creates and initializes a new runtime.
132*795d594fSAndroid Build Coastguard Worker   EXPORT static bool Create(RuntimeArgumentMap&& runtime_options)
133*795d594fSAndroid Build Coastguard Worker       SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
134*795d594fSAndroid Build Coastguard Worker 
135*795d594fSAndroid Build Coastguard Worker   // Creates and initializes a new runtime.
136*795d594fSAndroid Build Coastguard Worker   EXPORT static bool Create(const RuntimeOptions& raw_options, bool ignore_unrecognized)
137*795d594fSAndroid Build Coastguard Worker       SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
138*795d594fSAndroid Build Coastguard Worker 
139*795d594fSAndroid Build Coastguard Worker   enum class RuntimeDebugState {
140*795d594fSAndroid Build Coastguard Worker     // This doesn't support any debug features / method tracing. This is the expected state usually.
141*795d594fSAndroid Build Coastguard Worker     kNonJavaDebuggable,
142*795d594fSAndroid Build Coastguard Worker     // This supports method tracing and a restricted set of debug features (for ex: redefinition
143*795d594fSAndroid Build Coastguard Worker     // isn't supported). We transition to this state when method tracing has started or when the
144*795d594fSAndroid Build Coastguard Worker     // debugger was attached and transition back to NonDebuggable once the tracing has stopped /
145*795d594fSAndroid Build Coastguard Worker     // the debugger agent has detached..
146*795d594fSAndroid Build Coastguard Worker     kJavaDebuggable,
147*795d594fSAndroid Build Coastguard Worker     // The runtime was started as a debuggable runtime. This allows us to support the extended set
148*795d594fSAndroid Build Coastguard Worker     // of debug features (for ex: redefinition). We never transition out of this state.
149*795d594fSAndroid Build Coastguard Worker     kJavaDebuggableAtInit
150*795d594fSAndroid Build Coastguard Worker   };
151*795d594fSAndroid Build Coastguard Worker 
152*795d594fSAndroid Build Coastguard Worker   bool EnsurePluginLoaded(const char* plugin_name, std::string* error_msg);
153*795d594fSAndroid Build Coastguard Worker   bool EnsurePerfettoPlugin(std::string* error_msg);
154*795d594fSAndroid Build Coastguard Worker 
155*795d594fSAndroid Build Coastguard Worker   // IsAotCompiler for compilers that don't have a running runtime. Only dex2oat currently.
IsAotCompiler()156*795d594fSAndroid Build Coastguard Worker   bool IsAotCompiler() const {
157*795d594fSAndroid Build Coastguard Worker     return !UseJitCompilation() && IsCompiler();
158*795d594fSAndroid Build Coastguard Worker   }
159*795d594fSAndroid Build Coastguard Worker 
160*795d594fSAndroid Build Coastguard Worker   // IsCompiler is any runtime which has a running compiler, either dex2oat or JIT.
IsCompiler()161*795d594fSAndroid Build Coastguard Worker   bool IsCompiler() const {
162*795d594fSAndroid Build Coastguard Worker     return compiler_callbacks_ != nullptr;
163*795d594fSAndroid Build Coastguard Worker   }
164*795d594fSAndroid Build Coastguard Worker 
165*795d594fSAndroid Build Coastguard Worker   // If a compiler, are we compiling a boot image?
166*795d594fSAndroid Build Coastguard Worker   bool IsCompilingBootImage() const;
167*795d594fSAndroid Build Coastguard Worker 
168*795d594fSAndroid Build Coastguard Worker   bool CanRelocate() const;
169*795d594fSAndroid Build Coastguard Worker 
ShouldRelocate()170*795d594fSAndroid Build Coastguard Worker   bool ShouldRelocate() const {
171*795d594fSAndroid Build Coastguard Worker     return must_relocate_ && CanRelocate();
172*795d594fSAndroid Build Coastguard Worker   }
173*795d594fSAndroid Build Coastguard Worker 
MustRelocateIfPossible()174*795d594fSAndroid Build Coastguard Worker   bool MustRelocateIfPossible() const {
175*795d594fSAndroid Build Coastguard Worker     return must_relocate_;
176*795d594fSAndroid Build Coastguard Worker   }
177*795d594fSAndroid Build Coastguard Worker 
IsImageDex2OatEnabled()178*795d594fSAndroid Build Coastguard Worker   bool IsImageDex2OatEnabled() const {
179*795d594fSAndroid Build Coastguard Worker     return image_dex2oat_enabled_;
180*795d594fSAndroid Build Coastguard Worker   }
181*795d594fSAndroid Build Coastguard Worker 
GetCompilerCallbacks()182*795d594fSAndroid Build Coastguard Worker   CompilerCallbacks* GetCompilerCallbacks() {
183*795d594fSAndroid Build Coastguard Worker     return compiler_callbacks_;
184*795d594fSAndroid Build Coastguard Worker   }
185*795d594fSAndroid Build Coastguard Worker 
SetCompilerCallbacks(CompilerCallbacks * callbacks)186*795d594fSAndroid Build Coastguard Worker   void SetCompilerCallbacks(CompilerCallbacks* callbacks) {
187*795d594fSAndroid Build Coastguard Worker     CHECK(callbacks != nullptr);
188*795d594fSAndroid Build Coastguard Worker     compiler_callbacks_ = callbacks;
189*795d594fSAndroid Build Coastguard Worker   }
190*795d594fSAndroid Build Coastguard Worker 
IsZygote()191*795d594fSAndroid Build Coastguard Worker   bool IsZygote() const {
192*795d594fSAndroid Build Coastguard Worker     return is_zygote_;
193*795d594fSAndroid Build Coastguard Worker   }
194*795d594fSAndroid Build Coastguard Worker 
IsPrimaryZygote()195*795d594fSAndroid Build Coastguard Worker   bool IsPrimaryZygote() const {
196*795d594fSAndroid Build Coastguard Worker     return is_primary_zygote_;
197*795d594fSAndroid Build Coastguard Worker   }
198*795d594fSAndroid Build Coastguard Worker 
IsSystemServer()199*795d594fSAndroid Build Coastguard Worker   bool IsSystemServer() const {
200*795d594fSAndroid Build Coastguard Worker     return is_system_server_;
201*795d594fSAndroid Build Coastguard Worker   }
202*795d594fSAndroid Build Coastguard Worker 
SetAsSystemServer()203*795d594fSAndroid Build Coastguard Worker   void SetAsSystemServer() {
204*795d594fSAndroid Build Coastguard Worker     is_system_server_ = true;
205*795d594fSAndroid Build Coastguard Worker     is_zygote_ = false;
206*795d594fSAndroid Build Coastguard Worker     is_primary_zygote_ = false;
207*795d594fSAndroid Build Coastguard Worker   }
208*795d594fSAndroid Build Coastguard Worker 
SetAsZygoteChild(bool is_system_server,bool is_zygote)209*795d594fSAndroid Build Coastguard Worker   void SetAsZygoteChild(bool is_system_server, bool is_zygote) {
210*795d594fSAndroid Build Coastguard Worker     // System server should have been set earlier in SetAsSystemServer.
211*795d594fSAndroid Build Coastguard Worker     CHECK_EQ(is_system_server_, is_system_server);
212*795d594fSAndroid Build Coastguard Worker     is_zygote_ = is_zygote;
213*795d594fSAndroid Build Coastguard Worker     is_primary_zygote_ = false;
214*795d594fSAndroid Build Coastguard Worker   }
215*795d594fSAndroid Build Coastguard Worker 
IsExplicitGcDisabled()216*795d594fSAndroid Build Coastguard Worker   bool IsExplicitGcDisabled() const {
217*795d594fSAndroid Build Coastguard Worker     return is_explicit_gc_disabled_;
218*795d594fSAndroid Build Coastguard Worker   }
219*795d594fSAndroid Build Coastguard Worker 
IsEagerlyReleaseExplicitGcDisabled()220*795d594fSAndroid Build Coastguard Worker   bool IsEagerlyReleaseExplicitGcDisabled() const {
221*795d594fSAndroid Build Coastguard Worker     return is_eagerly_release_explicit_gc_disabled_;
222*795d594fSAndroid Build Coastguard Worker   }
223*795d594fSAndroid Build Coastguard Worker 
224*795d594fSAndroid Build Coastguard Worker   std::string GetCompilerExecutable() const;
225*795d594fSAndroid Build Coastguard Worker 
GetCompilerOptions()226*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetCompilerOptions() const {
227*795d594fSAndroid Build Coastguard Worker     return compiler_options_;
228*795d594fSAndroid Build Coastguard Worker   }
229*795d594fSAndroid Build Coastguard Worker 
AddCompilerOption(const std::string & option)230*795d594fSAndroid Build Coastguard Worker   void AddCompilerOption(const std::string& option) {
231*795d594fSAndroid Build Coastguard Worker     compiler_options_.push_back(option);
232*795d594fSAndroid Build Coastguard Worker   }
233*795d594fSAndroid Build Coastguard Worker 
GetImageCompilerOptions()234*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetImageCompilerOptions() const {
235*795d594fSAndroid Build Coastguard Worker     return image_compiler_options_;
236*795d594fSAndroid Build Coastguard Worker   }
237*795d594fSAndroid Build Coastguard Worker 
GetImageLocations()238*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetImageLocations() const {
239*795d594fSAndroid Build Coastguard Worker     return image_locations_;
240*795d594fSAndroid Build Coastguard Worker   }
241*795d594fSAndroid Build Coastguard Worker 
242*795d594fSAndroid Build Coastguard Worker   // Starts a runtime, which may cause threads to be started and code to run.
243*795d594fSAndroid Build Coastguard Worker   bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_);
244*795d594fSAndroid Build Coastguard Worker 
245*795d594fSAndroid Build Coastguard Worker   EXPORT bool IsShuttingDown(Thread* self);
IsShuttingDownLocked()246*795d594fSAndroid Build Coastguard Worker   bool IsShuttingDownLocked() const REQUIRES(Locks::runtime_shutdown_lock_) {
247*795d594fSAndroid Build Coastguard Worker     return shutting_down_.load(std::memory_order_relaxed);
248*795d594fSAndroid Build Coastguard Worker   }
IsShuttingDownUnsafe()249*795d594fSAndroid Build Coastguard Worker   bool IsShuttingDownUnsafe() const {
250*795d594fSAndroid Build Coastguard Worker     return shutting_down_.load(std::memory_order_relaxed);
251*795d594fSAndroid Build Coastguard Worker   }
SetShuttingDown()252*795d594fSAndroid Build Coastguard Worker   void SetShuttingDown() REQUIRES(Locks::runtime_shutdown_lock_) {
253*795d594fSAndroid Build Coastguard Worker     shutting_down_.store(true, std::memory_order_relaxed);
254*795d594fSAndroid Build Coastguard Worker   }
255*795d594fSAndroid Build Coastguard Worker 
NumberOfThreadsBeingBorn()256*795d594fSAndroid Build Coastguard Worker   size_t NumberOfThreadsBeingBorn() const REQUIRES(Locks::runtime_shutdown_lock_) {
257*795d594fSAndroid Build Coastguard Worker     return threads_being_born_;
258*795d594fSAndroid Build Coastguard Worker   }
259*795d594fSAndroid Build Coastguard Worker 
StartThreadBirth()260*795d594fSAndroid Build Coastguard Worker   void StartThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_) {
261*795d594fSAndroid Build Coastguard Worker     threads_being_born_++;
262*795d594fSAndroid Build Coastguard Worker   }
263*795d594fSAndroid Build Coastguard Worker 
264*795d594fSAndroid Build Coastguard Worker   EXPORT void EndThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_);
265*795d594fSAndroid Build Coastguard Worker 
IsStarted()266*795d594fSAndroid Build Coastguard Worker   bool IsStarted() const {
267*795d594fSAndroid Build Coastguard Worker     return started_;
268*795d594fSAndroid Build Coastguard Worker   }
269*795d594fSAndroid Build Coastguard Worker 
IsFinishedStarting()270*795d594fSAndroid Build Coastguard Worker   bool IsFinishedStarting() const {
271*795d594fSAndroid Build Coastguard Worker     return finished_starting_;
272*795d594fSAndroid Build Coastguard Worker   }
273*795d594fSAndroid Build Coastguard Worker 
274*795d594fSAndroid Build Coastguard Worker   EXPORT void RunRootClinits(Thread* self) REQUIRES_SHARED(Locks::mutator_lock_);
275*795d594fSAndroid Build Coastguard Worker 
Current()276*795d594fSAndroid Build Coastguard Worker   static Runtime* Current() {
277*795d594fSAndroid Build Coastguard Worker     return instance_;
278*795d594fSAndroid Build Coastguard Worker   }
279*795d594fSAndroid Build Coastguard Worker 
280*795d594fSAndroid Build Coastguard Worker   // Set the current runtime to be the given instance.
281*795d594fSAndroid Build Coastguard Worker   // Note that this function is not responsible for cleaning up the old instance or taking the
282*795d594fSAndroid Build Coastguard Worker   // ownership of the new instance.
283*795d594fSAndroid Build Coastguard Worker   //
284*795d594fSAndroid Build Coastguard Worker   // For test use only.
TestOnlySetCurrent(Runtime * instance)285*795d594fSAndroid Build Coastguard Worker   static void TestOnlySetCurrent(Runtime* instance) { instance_ = instance; }
286*795d594fSAndroid Build Coastguard Worker 
287*795d594fSAndroid Build Coastguard Worker   // Set whichever abort message locations are appropriate to copies of the argument. Used by
288*795d594fSAndroid Build Coastguard Worker   // Abort() and Thread::AbortInThis().
289*795d594fSAndroid Build Coastguard Worker   static void SetAbortMessage(const char* msg) REQUIRES(!Locks::abort_lock_);
290*795d594fSAndroid Build Coastguard Worker 
291*795d594fSAndroid Build Coastguard Worker   // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
292*795d594fSAndroid Build Coastguard Worker   // callers should prefer.
293*795d594fSAndroid Build Coastguard Worker   NO_RETURN EXPORT static void Abort(const char* msg) REQUIRES(!Locks::abort_lock_);
294*795d594fSAndroid Build Coastguard Worker 
295*795d594fSAndroid Build Coastguard Worker   // Returns the "main" ThreadGroup, used when attaching user threads.
296*795d594fSAndroid Build Coastguard Worker   jobject GetMainThreadGroup() const;
297*795d594fSAndroid Build Coastguard Worker 
298*795d594fSAndroid Build Coastguard Worker   // Returns the "system" ThreadGroup, used when attaching our internal threads.
299*795d594fSAndroid Build Coastguard Worker   EXPORT jobject GetSystemThreadGroup() const;
300*795d594fSAndroid Build Coastguard Worker 
301*795d594fSAndroid Build Coastguard Worker   // Returns the system ClassLoader which represents the CLASSPATH.
302*795d594fSAndroid Build Coastguard Worker   EXPORT jobject GetSystemClassLoader() const;
303*795d594fSAndroid Build Coastguard Worker 
304*795d594fSAndroid Build Coastguard Worker   // Attaches the calling native thread to the runtime.
305*795d594fSAndroid Build Coastguard Worker   EXPORT bool AttachCurrentThread(const char* thread_name,
306*795d594fSAndroid Build Coastguard Worker                                   bool as_daemon,
307*795d594fSAndroid Build Coastguard Worker                                   jobject thread_group,
308*795d594fSAndroid Build Coastguard Worker                                   bool create_peer,
309*795d594fSAndroid Build Coastguard Worker                                   bool should_run_callbacks = true);
310*795d594fSAndroid Build Coastguard Worker 
311*795d594fSAndroid Build Coastguard Worker   EXPORT void CallExitHook(jint status);
312*795d594fSAndroid Build Coastguard Worker 
313*795d594fSAndroid Build Coastguard Worker   // Detaches the current native thread from the runtime.
314*795d594fSAndroid Build Coastguard Worker   void DetachCurrentThread(bool should_run_callbacks = true) REQUIRES(!Locks::mutator_lock_);
315*795d594fSAndroid Build Coastguard Worker 
316*795d594fSAndroid Build Coastguard Worker   // If we are handling SIQQUIT return the time when we received it.
317*795d594fSAndroid Build Coastguard Worker   std::optional<uint64_t> SiqQuitNanoTime() const;
318*795d594fSAndroid Build Coastguard Worker 
319*795d594fSAndroid Build Coastguard Worker   void DumpDeoptimizations(std::ostream& os);
320*795d594fSAndroid Build Coastguard Worker   void DumpForSigQuit(std::ostream& os);
321*795d594fSAndroid Build Coastguard Worker   void DumpLockHolders(std::ostream& os);
322*795d594fSAndroid Build Coastguard Worker 
323*795d594fSAndroid Build Coastguard Worker   EXPORT ~Runtime();
324*795d594fSAndroid Build Coastguard Worker 
GetBootClassPath()325*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetBootClassPath() const {
326*795d594fSAndroid Build Coastguard Worker     return boot_class_path_;
327*795d594fSAndroid Build Coastguard Worker   }
328*795d594fSAndroid Build Coastguard Worker 
GetBootClassPathLocations()329*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetBootClassPathLocations() const {
330*795d594fSAndroid Build Coastguard Worker     DCHECK(boot_class_path_locations_.empty() ||
331*795d594fSAndroid Build Coastguard Worker            boot_class_path_locations_.size() == boot_class_path_.size());
332*795d594fSAndroid Build Coastguard Worker     return boot_class_path_locations_.empty() ? boot_class_path_ : boot_class_path_locations_;
333*795d594fSAndroid Build Coastguard Worker   }
334*795d594fSAndroid Build Coastguard Worker 
335*795d594fSAndroid Build Coastguard Worker   // Dynamically adds an element to boot class path.
336*795d594fSAndroid Build Coastguard Worker   EXPORT void AppendToBootClassPath(
337*795d594fSAndroid Build Coastguard Worker       const std::string& filename,
338*795d594fSAndroid Build Coastguard Worker       const std::string& location,
339*795d594fSAndroid Build Coastguard Worker       const std::vector<std::unique_ptr<const art::DexFile>>& dex_files);
340*795d594fSAndroid Build Coastguard Worker 
341*795d594fSAndroid Build Coastguard Worker   // Same as above, but takes raw pointers.
342*795d594fSAndroid Build Coastguard Worker   EXPORT void AppendToBootClassPath(const std::string& filename,
343*795d594fSAndroid Build Coastguard Worker                                     const std::string& location,
344*795d594fSAndroid Build Coastguard Worker                                     const std::vector<const art::DexFile*>& dex_files);
345*795d594fSAndroid Build Coastguard Worker 
346*795d594fSAndroid Build Coastguard Worker   // Same as above, but also takes a dex cache for each dex file.
347*795d594fSAndroid Build Coastguard Worker   EXPORT void AppendToBootClassPath(
348*795d594fSAndroid Build Coastguard Worker       const std::string& filename,
349*795d594fSAndroid Build Coastguard Worker       const std::string& location,
350*795d594fSAndroid Build Coastguard Worker       const std::vector<std::pair<const art::DexFile*, ObjPtr<mirror::DexCache>>>&
351*795d594fSAndroid Build Coastguard Worker           dex_files_and_cache);
352*795d594fSAndroid Build Coastguard Worker 
353*795d594fSAndroid Build Coastguard Worker   // Dynamically adds an element to boot class path and takes ownership of the dex files.
354*795d594fSAndroid Build Coastguard Worker   EXPORT void AddExtraBootDexFiles(const std::string& filename,
355*795d594fSAndroid Build Coastguard Worker                                    const std::string& location,
356*795d594fSAndroid Build Coastguard Worker                                    std::vector<std::unique_ptr<const art::DexFile>>&& dex_files);
357*795d594fSAndroid Build Coastguard Worker 
GetBootClassPathFiles()358*795d594fSAndroid Build Coastguard Worker   ArrayRef<File> GetBootClassPathFiles() { return ArrayRef<File>(boot_class_path_files_); }
359*795d594fSAndroid Build Coastguard Worker 
GetBootClassPathImageFiles()360*795d594fSAndroid Build Coastguard Worker   ArrayRef<File> GetBootClassPathImageFiles() {
361*795d594fSAndroid Build Coastguard Worker     return ArrayRef<File>(boot_class_path_image_files_);
362*795d594fSAndroid Build Coastguard Worker   }
363*795d594fSAndroid Build Coastguard Worker 
GetBootClassPathVdexFiles()364*795d594fSAndroid Build Coastguard Worker   ArrayRef<File> GetBootClassPathVdexFiles() { return ArrayRef<File>(boot_class_path_vdex_files_); }
365*795d594fSAndroid Build Coastguard Worker 
GetBootClassPathOatFiles()366*795d594fSAndroid Build Coastguard Worker   ArrayRef<File> GetBootClassPathOatFiles() { return ArrayRef<File>(boot_class_path_oat_files_); }
367*795d594fSAndroid Build Coastguard Worker 
368*795d594fSAndroid Build Coastguard Worker   // Returns the checksums for the boot image, extensions and extra boot class path dex files,
369*795d594fSAndroid Build Coastguard Worker   // based on the image spaces and boot class path dex files loaded in memory.
GetBootClassPathChecksums()370*795d594fSAndroid Build Coastguard Worker   const std::string& GetBootClassPathChecksums() const {
371*795d594fSAndroid Build Coastguard Worker     return boot_class_path_checksums_;
372*795d594fSAndroid Build Coastguard Worker   }
373*795d594fSAndroid Build Coastguard Worker 
GetClassPathString()374*795d594fSAndroid Build Coastguard Worker   const std::string& GetClassPathString() const {
375*795d594fSAndroid Build Coastguard Worker     return class_path_string_;
376*795d594fSAndroid Build Coastguard Worker   }
377*795d594fSAndroid Build Coastguard Worker 
GetClassLinker()378*795d594fSAndroid Build Coastguard Worker   ClassLinker* GetClassLinker() const {
379*795d594fSAndroid Build Coastguard Worker     return class_linker_;
380*795d594fSAndroid Build Coastguard Worker   }
381*795d594fSAndroid Build Coastguard Worker 
GetSmallLrtAllocator()382*795d594fSAndroid Build Coastguard Worker   jni::SmallLrtAllocator* GetSmallLrtAllocator() const {
383*795d594fSAndroid Build Coastguard Worker     return small_lrt_allocator_;
384*795d594fSAndroid Build Coastguard Worker   }
385*795d594fSAndroid Build Coastguard Worker 
GetJniIdManager()386*795d594fSAndroid Build Coastguard Worker   jni::JniIdManager* GetJniIdManager() const {
387*795d594fSAndroid Build Coastguard Worker     return jni_id_manager_.get();
388*795d594fSAndroid Build Coastguard Worker   }
389*795d594fSAndroid Build Coastguard Worker 
GetDefaultStackSize()390*795d594fSAndroid Build Coastguard Worker   size_t GetDefaultStackSize() const {
391*795d594fSAndroid Build Coastguard Worker     return default_stack_size_;
392*795d594fSAndroid Build Coastguard Worker   }
393*795d594fSAndroid Build Coastguard Worker 
GetFinalizerTimeoutMs()394*795d594fSAndroid Build Coastguard Worker   unsigned int GetFinalizerTimeoutMs() const {
395*795d594fSAndroid Build Coastguard Worker     return finalizer_timeout_ms_;
396*795d594fSAndroid Build Coastguard Worker   }
397*795d594fSAndroid Build Coastguard Worker 
GetHeap()398*795d594fSAndroid Build Coastguard Worker   gc::Heap* GetHeap() const {
399*795d594fSAndroid Build Coastguard Worker     return heap_;
400*795d594fSAndroid Build Coastguard Worker   }
401*795d594fSAndroid Build Coastguard Worker 
GetInternTable()402*795d594fSAndroid Build Coastguard Worker   InternTable* GetInternTable() const {
403*795d594fSAndroid Build Coastguard Worker     DCHECK(intern_table_ != nullptr);
404*795d594fSAndroid Build Coastguard Worker     return intern_table_;
405*795d594fSAndroid Build Coastguard Worker   }
406*795d594fSAndroid Build Coastguard Worker 
GetJavaVM()407*795d594fSAndroid Build Coastguard Worker   JavaVMExt* GetJavaVM() const {
408*795d594fSAndroid Build Coastguard Worker     return java_vm_.get();
409*795d594fSAndroid Build Coastguard Worker   }
410*795d594fSAndroid Build Coastguard Worker 
GetMaxSpinsBeforeThinLockInflation()411*795d594fSAndroid Build Coastguard Worker   size_t GetMaxSpinsBeforeThinLockInflation() const {
412*795d594fSAndroid Build Coastguard Worker     return max_spins_before_thin_lock_inflation_;
413*795d594fSAndroid Build Coastguard Worker   }
414*795d594fSAndroid Build Coastguard Worker 
GetMonitorList()415*795d594fSAndroid Build Coastguard Worker   MonitorList* GetMonitorList() const {
416*795d594fSAndroid Build Coastguard Worker     return monitor_list_;
417*795d594fSAndroid Build Coastguard Worker   }
418*795d594fSAndroid Build Coastguard Worker 
GetMonitorPool()419*795d594fSAndroid Build Coastguard Worker   MonitorPool* GetMonitorPool() const {
420*795d594fSAndroid Build Coastguard Worker     return monitor_pool_;
421*795d594fSAndroid Build Coastguard Worker   }
422*795d594fSAndroid Build Coastguard Worker 
423*795d594fSAndroid Build Coastguard Worker   // Is the given object the special object used to mark a cleared JNI weak global?
424*795d594fSAndroid Build Coastguard Worker   bool IsClearedJniWeakGlobal(ObjPtr<mirror::Object> obj) REQUIRES_SHARED(Locks::mutator_lock_);
425*795d594fSAndroid Build Coastguard Worker 
426*795d594fSAndroid Build Coastguard Worker   // Get the special object used to mark a cleared JNI weak global.
427*795d594fSAndroid Build Coastguard Worker   mirror::Object* GetClearedJniWeakGlobal() REQUIRES_SHARED(Locks::mutator_lock_);
428*795d594fSAndroid Build Coastguard Worker 
429*795d594fSAndroid Build Coastguard Worker   EXPORT mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenThrowingException()
430*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
431*795d594fSAndroid Build Coastguard Worker   EXPORT mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenThrowingOOME()
432*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
433*795d594fSAndroid Build Coastguard Worker   EXPORT mirror::Throwable* GetPreAllocatedOutOfMemoryErrorWhenHandlingStackOverflow()
434*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
435*795d594fSAndroid Build Coastguard Worker 
436*795d594fSAndroid Build Coastguard Worker   EXPORT mirror::Throwable* GetPreAllocatedNoClassDefFoundError()
437*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
438*795d594fSAndroid Build Coastguard Worker 
GetProperties()439*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetProperties() const {
440*795d594fSAndroid Build Coastguard Worker     return properties_;
441*795d594fSAndroid Build Coastguard Worker   }
442*795d594fSAndroid Build Coastguard Worker 
GetThreadList()443*795d594fSAndroid Build Coastguard Worker   ThreadList* GetThreadList() const {
444*795d594fSAndroid Build Coastguard Worker     return thread_list_;
445*795d594fSAndroid Build Coastguard Worker   }
446*795d594fSAndroid Build Coastguard Worker 
GetVersion()447*795d594fSAndroid Build Coastguard Worker   static const char* GetVersion() {
448*795d594fSAndroid Build Coastguard Worker     return "2.1.0";
449*795d594fSAndroid Build Coastguard Worker   }
450*795d594fSAndroid Build Coastguard Worker 
IsMethodHandlesEnabled()451*795d594fSAndroid Build Coastguard Worker   bool IsMethodHandlesEnabled() const {
452*795d594fSAndroid Build Coastguard Worker     return true;
453*795d594fSAndroid Build Coastguard Worker   }
454*795d594fSAndroid Build Coastguard Worker 
455*795d594fSAndroid Build Coastguard Worker   void DisallowNewSystemWeaks() REQUIRES_SHARED(Locks::mutator_lock_);
456*795d594fSAndroid Build Coastguard Worker   void AllowNewSystemWeaks() REQUIRES_SHARED(Locks::mutator_lock_);
457*795d594fSAndroid Build Coastguard Worker   // broadcast_for_checkpoint is true when we broadcast for making blocking threads to respond to
458*795d594fSAndroid Build Coastguard Worker   // checkpoint requests. It's false when we broadcast to unblock blocking threads after system weak
459*795d594fSAndroid Build Coastguard Worker   // access is reenabled.
460*795d594fSAndroid Build Coastguard Worker   void BroadcastForNewSystemWeaks(bool broadcast_for_checkpoint = false);
461*795d594fSAndroid Build Coastguard Worker 
462*795d594fSAndroid Build Coastguard Worker   // Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If
463*795d594fSAndroid Build Coastguard Worker   // clean_dirty is true then dirty roots will be marked as non-dirty after visiting.
464*795d594fSAndroid Build Coastguard Worker   EXPORT void VisitRoots(RootVisitor* visitor, VisitRootFlags flags = kVisitRootFlagAllRoots)
465*795d594fSAndroid Build Coastguard Worker       REQUIRES(!Locks::classlinker_classes_lock_, !Locks::trace_lock_)
466*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
467*795d594fSAndroid Build Coastguard Worker 
468*795d594fSAndroid Build Coastguard Worker   // Visit image roots, only used for hprof since the GC uses the image space mod union table
469*795d594fSAndroid Build Coastguard Worker   // instead.
470*795d594fSAndroid Build Coastguard Worker   EXPORT void VisitImageRoots(RootVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
471*795d594fSAndroid Build Coastguard Worker 
472*795d594fSAndroid Build Coastguard Worker   // Visit all of the roots we can safely visit concurrently.
473*795d594fSAndroid Build Coastguard Worker   void VisitConcurrentRoots(RootVisitor* visitor,
474*795d594fSAndroid Build Coastguard Worker                             VisitRootFlags flags = kVisitRootFlagAllRoots)
475*795d594fSAndroid Build Coastguard Worker       REQUIRES(!Locks::classlinker_classes_lock_, !Locks::trace_lock_)
476*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
477*795d594fSAndroid Build Coastguard Worker 
478*795d594fSAndroid Build Coastguard Worker   // Visit all of the non thread roots, we can do this with mutators unpaused.
479*795d594fSAndroid Build Coastguard Worker   void VisitNonThreadRoots(RootVisitor* visitor)
480*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
481*795d594fSAndroid Build Coastguard Worker 
482*795d594fSAndroid Build Coastguard Worker   // Sweep system weaks, the system weak is deleted if the visitor return null. Otherwise, the
483*795d594fSAndroid Build Coastguard Worker   // system weak is updated to be the visitor's returned value.
484*795d594fSAndroid Build Coastguard Worker   EXPORT void SweepSystemWeaks(IsMarkedVisitor* visitor) REQUIRES_SHARED(Locks::mutator_lock_);
485*795d594fSAndroid Build Coastguard Worker 
486*795d594fSAndroid Build Coastguard Worker   // Walk all reflective objects and visit their targets as well as any method/fields held by the
487*795d594fSAndroid Build Coastguard Worker   // runtime threads that are marked as being reflective.
488*795d594fSAndroid Build Coastguard Worker   EXPORT void VisitReflectiveTargets(ReflectiveValueVisitor* visitor)
489*795d594fSAndroid Build Coastguard Worker       REQUIRES(Locks::mutator_lock_);
490*795d594fSAndroid Build Coastguard Worker   // Helper for visiting reflective targets with lambdas for both field and method reflective
491*795d594fSAndroid Build Coastguard Worker   // targets.
492*795d594fSAndroid Build Coastguard Worker   template <typename FieldVis, typename MethodVis>
VisitReflectiveTargets(FieldVis && fv,MethodVis && mv)493*795d594fSAndroid Build Coastguard Worker   void VisitReflectiveTargets(FieldVis&& fv, MethodVis&& mv) REQUIRES(Locks::mutator_lock_) {
494*795d594fSAndroid Build Coastguard Worker     FunctionReflectiveValueVisitor frvv(fv, mv);
495*795d594fSAndroid Build Coastguard Worker     VisitReflectiveTargets(&frvv);
496*795d594fSAndroid Build Coastguard Worker   }
497*795d594fSAndroid Build Coastguard Worker 
498*795d594fSAndroid Build Coastguard Worker   // Returns a special method that calls into a trampoline for runtime method resolution
499*795d594fSAndroid Build Coastguard Worker   ArtMethod* GetResolutionMethod();
500*795d594fSAndroid Build Coastguard Worker 
HasResolutionMethod()501*795d594fSAndroid Build Coastguard Worker   bool HasResolutionMethod() const {
502*795d594fSAndroid Build Coastguard Worker     return resolution_method_ != nullptr;
503*795d594fSAndroid Build Coastguard Worker   }
504*795d594fSAndroid Build Coastguard Worker 
505*795d594fSAndroid Build Coastguard Worker   void SetResolutionMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
ClearResolutionMethod()506*795d594fSAndroid Build Coastguard Worker   void ClearResolutionMethod() {
507*795d594fSAndroid Build Coastguard Worker     resolution_method_ = nullptr;
508*795d594fSAndroid Build Coastguard Worker   }
509*795d594fSAndroid Build Coastguard Worker 
510*795d594fSAndroid Build Coastguard Worker   ArtMethod* CreateResolutionMethod() REQUIRES_SHARED(Locks::mutator_lock_);
511*795d594fSAndroid Build Coastguard Worker 
512*795d594fSAndroid Build Coastguard Worker   // Returns a special method that calls into a trampoline for runtime imt conflicts.
513*795d594fSAndroid Build Coastguard Worker   ArtMethod* GetImtConflictMethod();
514*795d594fSAndroid Build Coastguard Worker   ArtMethod* GetImtUnimplementedMethod();
515*795d594fSAndroid Build Coastguard Worker 
HasImtConflictMethod()516*795d594fSAndroid Build Coastguard Worker   bool HasImtConflictMethod() const {
517*795d594fSAndroid Build Coastguard Worker     return imt_conflict_method_ != nullptr;
518*795d594fSAndroid Build Coastguard Worker   }
519*795d594fSAndroid Build Coastguard Worker 
ClearImtConflictMethod()520*795d594fSAndroid Build Coastguard Worker   void ClearImtConflictMethod() {
521*795d594fSAndroid Build Coastguard Worker     imt_conflict_method_ = nullptr;
522*795d594fSAndroid Build Coastguard Worker   }
523*795d594fSAndroid Build Coastguard Worker 
524*795d594fSAndroid Build Coastguard Worker   void FixupConflictTables() REQUIRES_SHARED(Locks::mutator_lock_);
525*795d594fSAndroid Build Coastguard Worker   void SetImtConflictMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
526*795d594fSAndroid Build Coastguard Worker   void SetImtUnimplementedMethod(ArtMethod* method) REQUIRES_SHARED(Locks::mutator_lock_);
527*795d594fSAndroid Build Coastguard Worker 
528*795d594fSAndroid Build Coastguard Worker   ArtMethod* CreateImtConflictMethod(LinearAlloc* linear_alloc)
529*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
530*795d594fSAndroid Build Coastguard Worker 
ClearImtUnimplementedMethod()531*795d594fSAndroid Build Coastguard Worker   void ClearImtUnimplementedMethod() {
532*795d594fSAndroid Build Coastguard Worker     imt_unimplemented_method_ = nullptr;
533*795d594fSAndroid Build Coastguard Worker   }
534*795d594fSAndroid Build Coastguard Worker 
HasCalleeSaveMethod(CalleeSaveType type)535*795d594fSAndroid Build Coastguard Worker   bool HasCalleeSaveMethod(CalleeSaveType type) const {
536*795d594fSAndroid Build Coastguard Worker     return callee_save_methods_[static_cast<size_t>(type)] != 0u;
537*795d594fSAndroid Build Coastguard Worker   }
538*795d594fSAndroid Build Coastguard Worker 
539*795d594fSAndroid Build Coastguard Worker   ArtMethod* GetCalleeSaveMethod(CalleeSaveType type)
540*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
541*795d594fSAndroid Build Coastguard Worker 
542*795d594fSAndroid Build Coastguard Worker   ArtMethod* GetCalleeSaveMethodUnchecked(CalleeSaveType type)
543*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
544*795d594fSAndroid Build Coastguard Worker 
545*795d594fSAndroid Build Coastguard Worker   QuickMethodFrameInfo GetRuntimeMethodFrameInfo(ArtMethod* method)
546*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
547*795d594fSAndroid Build Coastguard Worker 
GetCalleeSaveMethodOffset(CalleeSaveType type)548*795d594fSAndroid Build Coastguard Worker   static constexpr size_t GetCalleeSaveMethodOffset(CalleeSaveType type) {
549*795d594fSAndroid Build Coastguard Worker     return OFFSETOF_MEMBER(Runtime, callee_save_methods_[static_cast<size_t>(type)]);
550*795d594fSAndroid Build Coastguard Worker   }
551*795d594fSAndroid Build Coastguard Worker 
GetInstrumentationOffset()552*795d594fSAndroid Build Coastguard Worker   static constexpr MemberOffset GetInstrumentationOffset() {
553*795d594fSAndroid Build Coastguard Worker     return MemberOffset(OFFSETOF_MEMBER(Runtime, instrumentation_));
554*795d594fSAndroid Build Coastguard Worker   }
555*795d594fSAndroid Build Coastguard Worker 
GetInstructionSet()556*795d594fSAndroid Build Coastguard Worker   InstructionSet GetInstructionSet() const {
557*795d594fSAndroid Build Coastguard Worker     return instruction_set_;
558*795d594fSAndroid Build Coastguard Worker   }
559*795d594fSAndroid Build Coastguard Worker 
560*795d594fSAndroid Build Coastguard Worker   EXPORT void SetInstructionSet(InstructionSet instruction_set);
561*795d594fSAndroid Build Coastguard Worker   void ClearInstructionSet();
562*795d594fSAndroid Build Coastguard Worker 
563*795d594fSAndroid Build Coastguard Worker   EXPORT void SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type);
564*795d594fSAndroid Build Coastguard Worker   void ClearCalleeSaveMethods();
565*795d594fSAndroid Build Coastguard Worker 
566*795d594fSAndroid Build Coastguard Worker   EXPORT ArtMethod* CreateCalleeSaveMethod() REQUIRES_SHARED(Locks::mutator_lock_);
567*795d594fSAndroid Build Coastguard Worker 
568*795d594fSAndroid Build Coastguard Worker   uint64_t GetStat(int kind);
569*795d594fSAndroid Build Coastguard Worker 
GetStats()570*795d594fSAndroid Build Coastguard Worker   RuntimeStats* GetStats() {
571*795d594fSAndroid Build Coastguard Worker     return &stats_;
572*795d594fSAndroid Build Coastguard Worker   }
573*795d594fSAndroid Build Coastguard Worker 
HasStatsEnabled()574*795d594fSAndroid Build Coastguard Worker   bool HasStatsEnabled() const {
575*795d594fSAndroid Build Coastguard Worker     return stats_enabled_;
576*795d594fSAndroid Build Coastguard Worker   }
577*795d594fSAndroid Build Coastguard Worker 
578*795d594fSAndroid Build Coastguard Worker   void ResetStats(int kinds);
579*795d594fSAndroid Build Coastguard Worker 
580*795d594fSAndroid Build Coastguard Worker   void SetStatsEnabled(bool new_state)
581*795d594fSAndroid Build Coastguard Worker       REQUIRES(!Locks::instrument_entrypoints_lock_, !Locks::mutator_lock_);
582*795d594fSAndroid Build Coastguard Worker 
583*795d594fSAndroid Build Coastguard Worker   enum class NativeBridgeAction {  // private
584*795d594fSAndroid Build Coastguard Worker     kUnload,
585*795d594fSAndroid Build Coastguard Worker     kInitialize
586*795d594fSAndroid Build Coastguard Worker   };
587*795d594fSAndroid Build Coastguard Worker 
GetJit()588*795d594fSAndroid Build Coastguard Worker   jit::Jit* GetJit() const {
589*795d594fSAndroid Build Coastguard Worker     return jit_.get();
590*795d594fSAndroid Build Coastguard Worker   }
591*795d594fSAndroid Build Coastguard Worker 
GetJitCodeCache()592*795d594fSAndroid Build Coastguard Worker   jit::JitCodeCache* GetJitCodeCache() const {
593*795d594fSAndroid Build Coastguard Worker     return jit_code_cache_.get();
594*795d594fSAndroid Build Coastguard Worker   }
595*795d594fSAndroid Build Coastguard Worker 
596*795d594fSAndroid Build Coastguard Worker   // Returns true if JIT compilations are enabled. GetJit() will be not null in this case.
597*795d594fSAndroid Build Coastguard Worker   EXPORT bool UseJitCompilation() const;
598*795d594fSAndroid Build Coastguard Worker 
599*795d594fSAndroid Build Coastguard Worker   void PreZygoteFork();
600*795d594fSAndroid Build Coastguard Worker   void PostZygoteFork();
601*795d594fSAndroid Build Coastguard Worker   void InitNonZygoteOrPostFork(
602*795d594fSAndroid Build Coastguard Worker       JNIEnv* env,
603*795d594fSAndroid Build Coastguard Worker       bool is_system_server,
604*795d594fSAndroid Build Coastguard Worker       bool is_child_zygote,
605*795d594fSAndroid Build Coastguard Worker       NativeBridgeAction action,
606*795d594fSAndroid Build Coastguard Worker       const char* isa,
607*795d594fSAndroid Build Coastguard Worker       bool profile_system_server = false);
608*795d594fSAndroid Build Coastguard Worker 
GetInstrumentation()609*795d594fSAndroid Build Coastguard Worker   const instrumentation::Instrumentation* GetInstrumentation() const {
610*795d594fSAndroid Build Coastguard Worker     return &instrumentation_;
611*795d594fSAndroid Build Coastguard Worker   }
612*795d594fSAndroid Build Coastguard Worker 
GetInstrumentation()613*795d594fSAndroid Build Coastguard Worker   instrumentation::Instrumentation* GetInstrumentation() {
614*795d594fSAndroid Build Coastguard Worker     return &instrumentation_;
615*795d594fSAndroid Build Coastguard Worker   }
616*795d594fSAndroid Build Coastguard Worker 
617*795d594fSAndroid Build Coastguard Worker   void RegisterAppInfo(const std::string& package_name,
618*795d594fSAndroid Build Coastguard Worker                        const std::vector<std::string>& code_paths,
619*795d594fSAndroid Build Coastguard Worker                        const std::string& profile_output_filename,
620*795d594fSAndroid Build Coastguard Worker                        const std::string& ref_profile_filename,
621*795d594fSAndroid Build Coastguard Worker                        int32_t code_type);
622*795d594fSAndroid Build Coastguard Worker 
SetActiveTransaction()623*795d594fSAndroid Build Coastguard Worker   void SetActiveTransaction() {
624*795d594fSAndroid Build Coastguard Worker     DCHECK(IsAotCompiler());
625*795d594fSAndroid Build Coastguard Worker     active_transaction_ = true;
626*795d594fSAndroid Build Coastguard Worker   }
627*795d594fSAndroid Build Coastguard Worker 
ClearActiveTransaction()628*795d594fSAndroid Build Coastguard Worker   void ClearActiveTransaction() {
629*795d594fSAndroid Build Coastguard Worker     DCHECK(IsAotCompiler());
630*795d594fSAndroid Build Coastguard Worker     active_transaction_ = false;
631*795d594fSAndroid Build Coastguard Worker   }
632*795d594fSAndroid Build Coastguard Worker 
IsActiveTransaction()633*795d594fSAndroid Build Coastguard Worker   bool IsActiveTransaction() {
634*795d594fSAndroid Build Coastguard Worker     if (kIsDebugBuild) {
635*795d594fSAndroid Build Coastguard Worker       DCheckNoTransactionCheckAllowed();
636*795d594fSAndroid Build Coastguard Worker     }
637*795d594fSAndroid Build Coastguard Worker     return active_transaction_;
638*795d594fSAndroid Build Coastguard Worker   }
639*795d594fSAndroid Build Coastguard Worker 
640*795d594fSAndroid Build Coastguard Worker   void SetFaultMessage(const std::string& message);
641*795d594fSAndroid Build Coastguard Worker 
642*795d594fSAndroid Build Coastguard Worker   void AddCurrentRuntimeFeaturesAsDex2OatArguments(std::vector<std::string>* arg_vector) const;
643*795d594fSAndroid Build Coastguard Worker 
GetImplicitStackOverflowChecks()644*795d594fSAndroid Build Coastguard Worker   bool GetImplicitStackOverflowChecks() const {
645*795d594fSAndroid Build Coastguard Worker     return implicit_so_checks_;
646*795d594fSAndroid Build Coastguard Worker   }
647*795d594fSAndroid Build Coastguard Worker 
GetImplicitSuspendChecks()648*795d594fSAndroid Build Coastguard Worker   bool GetImplicitSuspendChecks() const {
649*795d594fSAndroid Build Coastguard Worker     return implicit_suspend_checks_;
650*795d594fSAndroid Build Coastguard Worker   }
651*795d594fSAndroid Build Coastguard Worker 
GetImplicitNullChecks()652*795d594fSAndroid Build Coastguard Worker   bool GetImplicitNullChecks() const {
653*795d594fSAndroid Build Coastguard Worker     return implicit_null_checks_;
654*795d594fSAndroid Build Coastguard Worker   }
655*795d594fSAndroid Build Coastguard Worker 
656*795d594fSAndroid Build Coastguard Worker   void DisableVerifier();
657*795d594fSAndroid Build Coastguard Worker   bool IsVerificationEnabled() const;
658*795d594fSAndroid Build Coastguard Worker   EXPORT bool IsVerificationSoftFail() const;
659*795d594fSAndroid Build Coastguard Worker 
SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy)660*795d594fSAndroid Build Coastguard Worker   void SetHiddenApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy) {
661*795d594fSAndroid Build Coastguard Worker     hidden_api_policy_ = policy;
662*795d594fSAndroid Build Coastguard Worker   }
663*795d594fSAndroid Build Coastguard Worker 
GetHiddenApiEnforcementPolicy()664*795d594fSAndroid Build Coastguard Worker   hiddenapi::EnforcementPolicy GetHiddenApiEnforcementPolicy() const {
665*795d594fSAndroid Build Coastguard Worker     return hidden_api_policy_;
666*795d594fSAndroid Build Coastguard Worker   }
667*795d594fSAndroid Build Coastguard Worker 
SetCorePlatformApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy)668*795d594fSAndroid Build Coastguard Worker   void SetCorePlatformApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy) {
669*795d594fSAndroid Build Coastguard Worker     core_platform_api_policy_ = policy;
670*795d594fSAndroid Build Coastguard Worker   }
671*795d594fSAndroid Build Coastguard Worker 
GetCorePlatformApiEnforcementPolicy()672*795d594fSAndroid Build Coastguard Worker   hiddenapi::EnforcementPolicy GetCorePlatformApiEnforcementPolicy() const {
673*795d594fSAndroid Build Coastguard Worker     return core_platform_api_policy_;
674*795d594fSAndroid Build Coastguard Worker   }
675*795d594fSAndroid Build Coastguard Worker 
SetTestApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy)676*795d594fSAndroid Build Coastguard Worker   void SetTestApiEnforcementPolicy(hiddenapi::EnforcementPolicy policy) {
677*795d594fSAndroid Build Coastguard Worker     test_api_policy_ = policy;
678*795d594fSAndroid Build Coastguard Worker   }
679*795d594fSAndroid Build Coastguard Worker 
GetTestApiEnforcementPolicy()680*795d594fSAndroid Build Coastguard Worker   hiddenapi::EnforcementPolicy GetTestApiEnforcementPolicy() const {
681*795d594fSAndroid Build Coastguard Worker     return test_api_policy_;
682*795d594fSAndroid Build Coastguard Worker   }
683*795d594fSAndroid Build Coastguard Worker 
SetHiddenApiExemptions(const std::vector<std::string> & exemptions)684*795d594fSAndroid Build Coastguard Worker   void SetHiddenApiExemptions(const std::vector<std::string>& exemptions) {
685*795d594fSAndroid Build Coastguard Worker     hidden_api_exemptions_ = exemptions;
686*795d594fSAndroid Build Coastguard Worker   }
687*795d594fSAndroid Build Coastguard Worker 
GetHiddenApiExemptions()688*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetHiddenApiExemptions() {
689*795d594fSAndroid Build Coastguard Worker     return hidden_api_exemptions_;
690*795d594fSAndroid Build Coastguard Worker   }
691*795d594fSAndroid Build Coastguard Worker 
SetDedupeHiddenApiWarnings(bool value)692*795d594fSAndroid Build Coastguard Worker   void SetDedupeHiddenApiWarnings(bool value) {
693*795d594fSAndroid Build Coastguard Worker     dedupe_hidden_api_warnings_ = value;
694*795d594fSAndroid Build Coastguard Worker   }
695*795d594fSAndroid Build Coastguard Worker 
ShouldDedupeHiddenApiWarnings()696*795d594fSAndroid Build Coastguard Worker   bool ShouldDedupeHiddenApiWarnings() {
697*795d594fSAndroid Build Coastguard Worker     return dedupe_hidden_api_warnings_;
698*795d594fSAndroid Build Coastguard Worker   }
699*795d594fSAndroid Build Coastguard Worker 
SetHiddenApiEventLogSampleRate(uint32_t rate)700*795d594fSAndroid Build Coastguard Worker   void SetHiddenApiEventLogSampleRate(uint32_t rate) {
701*795d594fSAndroid Build Coastguard Worker     hidden_api_access_event_log_rate_ = rate;
702*795d594fSAndroid Build Coastguard Worker   }
703*795d594fSAndroid Build Coastguard Worker 
GetHiddenApiEventLogSampleRate()704*795d594fSAndroid Build Coastguard Worker   uint32_t GetHiddenApiEventLogSampleRate() const {
705*795d594fSAndroid Build Coastguard Worker     return hidden_api_access_event_log_rate_;
706*795d594fSAndroid Build Coastguard Worker   }
707*795d594fSAndroid Build Coastguard Worker 
GetProcessPackageName()708*795d594fSAndroid Build Coastguard Worker   const std::string& GetProcessPackageName() const {
709*795d594fSAndroid Build Coastguard Worker     return process_package_name_;
710*795d594fSAndroid Build Coastguard Worker   }
711*795d594fSAndroid Build Coastguard Worker 
SetProcessPackageName(const char * package_name)712*795d594fSAndroid Build Coastguard Worker   void SetProcessPackageName(const char* package_name) {
713*795d594fSAndroid Build Coastguard Worker     if (package_name == nullptr) {
714*795d594fSAndroid Build Coastguard Worker       process_package_name_.clear();
715*795d594fSAndroid Build Coastguard Worker     } else {
716*795d594fSAndroid Build Coastguard Worker       process_package_name_ = package_name;
717*795d594fSAndroid Build Coastguard Worker     }
718*795d594fSAndroid Build Coastguard Worker   }
719*795d594fSAndroid Build Coastguard Worker 
GetProcessDataDirectory()720*795d594fSAndroid Build Coastguard Worker   const std::string& GetProcessDataDirectory() const {
721*795d594fSAndroid Build Coastguard Worker     return process_data_directory_;
722*795d594fSAndroid Build Coastguard Worker   }
723*795d594fSAndroid Build Coastguard Worker 
SetProcessDataDirectory(const char * data_dir)724*795d594fSAndroid Build Coastguard Worker   void SetProcessDataDirectory(const char* data_dir) {
725*795d594fSAndroid Build Coastguard Worker     if (data_dir == nullptr) {
726*795d594fSAndroid Build Coastguard Worker       process_data_directory_.clear();
727*795d594fSAndroid Build Coastguard Worker     } else {
728*795d594fSAndroid Build Coastguard Worker       process_data_directory_ = data_dir;
729*795d594fSAndroid Build Coastguard Worker     }
730*795d594fSAndroid Build Coastguard Worker   }
731*795d594fSAndroid Build Coastguard Worker 
GetCpuAbilist()732*795d594fSAndroid Build Coastguard Worker   const std::vector<std::string>& GetCpuAbilist() const {
733*795d594fSAndroid Build Coastguard Worker     return cpu_abilist_;
734*795d594fSAndroid Build Coastguard Worker   }
735*795d594fSAndroid Build Coastguard Worker 
IsRunningOnMemoryTool()736*795d594fSAndroid Build Coastguard Worker   bool IsRunningOnMemoryTool() const {
737*795d594fSAndroid Build Coastguard Worker     return is_running_on_memory_tool_;
738*795d594fSAndroid Build Coastguard Worker   }
739*795d594fSAndroid Build Coastguard Worker 
SetTargetSdkVersion(uint32_t version)740*795d594fSAndroid Build Coastguard Worker   void SetTargetSdkVersion(uint32_t version) {
741*795d594fSAndroid Build Coastguard Worker     target_sdk_version_ = version;
742*795d594fSAndroid Build Coastguard Worker   }
743*795d594fSAndroid Build Coastguard Worker 
GetTargetSdkVersion()744*795d594fSAndroid Build Coastguard Worker   uint32_t GetTargetSdkVersion() const {
745*795d594fSAndroid Build Coastguard Worker     return target_sdk_version_;
746*795d594fSAndroid Build Coastguard Worker   }
747*795d594fSAndroid Build Coastguard Worker 
GetCompatFramework()748*795d594fSAndroid Build Coastguard Worker   CompatFramework& GetCompatFramework() {
749*795d594fSAndroid Build Coastguard Worker     return compat_framework_;
750*795d594fSAndroid Build Coastguard Worker   }
751*795d594fSAndroid Build Coastguard Worker 
GetZygoteMaxFailedBoots()752*795d594fSAndroid Build Coastguard Worker   uint32_t GetZygoteMaxFailedBoots() const {
753*795d594fSAndroid Build Coastguard Worker     return zygote_max_failed_boots_;
754*795d594fSAndroid Build Coastguard Worker   }
755*795d594fSAndroid Build Coastguard Worker 
AreExperimentalFlagsEnabled(ExperimentalFlags flags)756*795d594fSAndroid Build Coastguard Worker   bool AreExperimentalFlagsEnabled(ExperimentalFlags flags) {
757*795d594fSAndroid Build Coastguard Worker     return (experimental_flags_ & flags) != ExperimentalFlags::kNone;
758*795d594fSAndroid Build Coastguard Worker   }
759*795d594fSAndroid Build Coastguard Worker 
760*795d594fSAndroid Build Coastguard Worker   void CreateJitCodeCache(bool rwx_memory_allowed);
761*795d594fSAndroid Build Coastguard Worker 
762*795d594fSAndroid Build Coastguard Worker   // Create the JIT and instrumentation and code cache.
763*795d594fSAndroid Build Coastguard Worker   void CreateJit();
764*795d594fSAndroid Build Coastguard Worker 
GetLinearAllocArenaPool()765*795d594fSAndroid Build Coastguard Worker   ArenaPool* GetLinearAllocArenaPool() {
766*795d594fSAndroid Build Coastguard Worker     return linear_alloc_arena_pool_.get();
767*795d594fSAndroid Build Coastguard Worker   }
GetArenaPool()768*795d594fSAndroid Build Coastguard Worker   ArenaPool* GetArenaPool() {
769*795d594fSAndroid Build Coastguard Worker     return arena_pool_.get();
770*795d594fSAndroid Build Coastguard Worker   }
GetArenaPool()771*795d594fSAndroid Build Coastguard Worker   const ArenaPool* GetArenaPool() const {
772*795d594fSAndroid Build Coastguard Worker     return arena_pool_.get();
773*795d594fSAndroid Build Coastguard Worker   }
GetJitArenaPool()774*795d594fSAndroid Build Coastguard Worker   ArenaPool* GetJitArenaPool() {
775*795d594fSAndroid Build Coastguard Worker     return jit_arena_pool_.get();
776*795d594fSAndroid Build Coastguard Worker   }
777*795d594fSAndroid Build Coastguard Worker 
778*795d594fSAndroid Build Coastguard Worker   EXPORT void ReclaimArenaPoolMemory();
779*795d594fSAndroid Build Coastguard Worker 
GetLinearAlloc()780*795d594fSAndroid Build Coastguard Worker   LinearAlloc* GetLinearAlloc() {
781*795d594fSAndroid Build Coastguard Worker     return linear_alloc_.get();
782*795d594fSAndroid Build Coastguard Worker   }
783*795d594fSAndroid Build Coastguard Worker 
GetStartupLinearAlloc()784*795d594fSAndroid Build Coastguard Worker   LinearAlloc* GetStartupLinearAlloc() {
785*795d594fSAndroid Build Coastguard Worker     return startup_linear_alloc_.load(std::memory_order_relaxed);
786*795d594fSAndroid Build Coastguard Worker   }
787*795d594fSAndroid Build Coastguard Worker 
GetJITOptions()788*795d594fSAndroid Build Coastguard Worker   jit::JitOptions* GetJITOptions() {
789*795d594fSAndroid Build Coastguard Worker     return jit_options_.get();
790*795d594fSAndroid Build Coastguard Worker   }
791*795d594fSAndroid Build Coastguard Worker 
IsJavaDebuggable()792*795d594fSAndroid Build Coastguard Worker   bool IsJavaDebuggable() const {
793*795d594fSAndroid Build Coastguard Worker     return runtime_debug_state_ == RuntimeDebugState::kJavaDebuggable ||
794*795d594fSAndroid Build Coastguard Worker            runtime_debug_state_ == RuntimeDebugState::kJavaDebuggableAtInit;
795*795d594fSAndroid Build Coastguard Worker   }
796*795d594fSAndroid Build Coastguard Worker 
IsJavaDebuggableAtInit()797*795d594fSAndroid Build Coastguard Worker   bool IsJavaDebuggableAtInit() const {
798*795d594fSAndroid Build Coastguard Worker     return runtime_debug_state_ == RuntimeDebugState::kJavaDebuggableAtInit;
799*795d594fSAndroid Build Coastguard Worker   }
800*795d594fSAndroid Build Coastguard Worker 
SetProfileableFromShell(bool value)801*795d594fSAndroid Build Coastguard Worker   void SetProfileableFromShell(bool value) {
802*795d594fSAndroid Build Coastguard Worker     is_profileable_from_shell_ = value;
803*795d594fSAndroid Build Coastguard Worker   }
804*795d594fSAndroid Build Coastguard Worker 
IsProfileableFromShell()805*795d594fSAndroid Build Coastguard Worker   bool IsProfileableFromShell() const {
806*795d594fSAndroid Build Coastguard Worker     return is_profileable_from_shell_;
807*795d594fSAndroid Build Coastguard Worker   }
808*795d594fSAndroid Build Coastguard Worker 
SetProfileable(bool value)809*795d594fSAndroid Build Coastguard Worker   void SetProfileable(bool value) {
810*795d594fSAndroid Build Coastguard Worker     is_profileable_ = value;
811*795d594fSAndroid Build Coastguard Worker   }
812*795d594fSAndroid Build Coastguard Worker 
IsProfileable()813*795d594fSAndroid Build Coastguard Worker   bool IsProfileable() const {
814*795d594fSAndroid Build Coastguard Worker     return is_profileable_;
815*795d594fSAndroid Build Coastguard Worker   }
816*795d594fSAndroid Build Coastguard Worker 
817*795d594fSAndroid Build Coastguard Worker   EXPORT void SetRuntimeDebugState(RuntimeDebugState state);
818*795d594fSAndroid Build Coastguard Worker 
819*795d594fSAndroid Build Coastguard Worker   // Deoptimize the boot image, called for Java debuggable apps.
820*795d594fSAndroid Build Coastguard Worker   EXPORT void DeoptimizeBootImage() REQUIRES(Locks::mutator_lock_);
821*795d594fSAndroid Build Coastguard Worker 
IsNativeDebuggable()822*795d594fSAndroid Build Coastguard Worker   bool IsNativeDebuggable() const {
823*795d594fSAndroid Build Coastguard Worker     return is_native_debuggable_;
824*795d594fSAndroid Build Coastguard Worker   }
825*795d594fSAndroid Build Coastguard Worker 
SetNativeDebuggable(bool value)826*795d594fSAndroid Build Coastguard Worker   void SetNativeDebuggable(bool value) {
827*795d594fSAndroid Build Coastguard Worker     is_native_debuggable_ = value;
828*795d594fSAndroid Build Coastguard Worker   }
829*795d594fSAndroid Build Coastguard Worker 
830*795d594fSAndroid Build Coastguard Worker   void SetSignalHookDebuggable(bool value);
831*795d594fSAndroid Build Coastguard Worker 
AreNonStandardExitsEnabled()832*795d594fSAndroid Build Coastguard Worker   bool AreNonStandardExitsEnabled() const {
833*795d594fSAndroid Build Coastguard Worker     return non_standard_exits_enabled_;
834*795d594fSAndroid Build Coastguard Worker   }
835*795d594fSAndroid Build Coastguard Worker 
SetNonStandardExitsEnabled()836*795d594fSAndroid Build Coastguard Worker   void SetNonStandardExitsEnabled() {
837*795d594fSAndroid Build Coastguard Worker     non_standard_exits_enabled_ = true;
838*795d594fSAndroid Build Coastguard Worker   }
839*795d594fSAndroid Build Coastguard Worker 
AreAsyncExceptionsThrown()840*795d594fSAndroid Build Coastguard Worker   bool AreAsyncExceptionsThrown() const {
841*795d594fSAndroid Build Coastguard Worker     return async_exceptions_thrown_;
842*795d594fSAndroid Build Coastguard Worker   }
843*795d594fSAndroid Build Coastguard Worker 
SetAsyncExceptionsThrown()844*795d594fSAndroid Build Coastguard Worker   void SetAsyncExceptionsThrown() {
845*795d594fSAndroid Build Coastguard Worker     async_exceptions_thrown_ = true;
846*795d594fSAndroid Build Coastguard Worker   }
847*795d594fSAndroid Build Coastguard Worker 
848*795d594fSAndroid Build Coastguard Worker   // Returns the build fingerprint, if set. Otherwise an empty string is returned.
GetFingerprint()849*795d594fSAndroid Build Coastguard Worker   std::string GetFingerprint() {
850*795d594fSAndroid Build Coastguard Worker     return fingerprint_;
851*795d594fSAndroid Build Coastguard Worker   }
852*795d594fSAndroid Build Coastguard Worker 
853*795d594fSAndroid Build Coastguard Worker   // Called from class linker.
854*795d594fSAndroid Build Coastguard Worker   void SetSentinel(ObjPtr<mirror::Object> sentinel) REQUIRES_SHARED(Locks::mutator_lock_);
855*795d594fSAndroid Build Coastguard Worker   // For testing purpose only.
856*795d594fSAndroid Build Coastguard Worker   // TODO: Remove this when this is no longer needed (b/116087961).
857*795d594fSAndroid Build Coastguard Worker   EXPORT GcRoot<mirror::Object> GetSentinel() REQUIRES_SHARED(Locks::mutator_lock_);
858*795d594fSAndroid Build Coastguard Worker 
859*795d594fSAndroid Build Coastguard Worker   // Use a sentinel for marking entries in a table that have been cleared.
860*795d594fSAndroid Build Coastguard Worker   // This helps diagnosing in case code tries to wrongly access such
861*795d594fSAndroid Build Coastguard Worker   // entries.
GetWeakClassSentinel()862*795d594fSAndroid Build Coastguard Worker   static mirror::Class* GetWeakClassSentinel() {
863*795d594fSAndroid Build Coastguard Worker     return reinterpret_cast<mirror::Class*>(0xebadbeef);
864*795d594fSAndroid Build Coastguard Worker   }
865*795d594fSAndroid Build Coastguard Worker 
866*795d594fSAndroid Build Coastguard Worker   // Create a normal LinearAlloc or low 4gb version if we are 64 bit AOT compiler.
867*795d594fSAndroid Build Coastguard Worker   EXPORT LinearAlloc* CreateLinearAlloc();
868*795d594fSAndroid Build Coastguard Worker   // Setup linear-alloc allocators to stop using the current arena so that the
869*795d594fSAndroid Build Coastguard Worker   // next allocations, which would be after zygote fork, happens in userfaultfd
870*795d594fSAndroid Build Coastguard Worker   // visited space.
871*795d594fSAndroid Build Coastguard Worker   void SetupLinearAllocForPostZygoteFork(Thread* self)
872*795d594fSAndroid Build Coastguard Worker       REQUIRES(!Locks::mutator_lock_, !Locks::classlinker_classes_lock_);
873*795d594fSAndroid Build Coastguard Worker 
GetOatFileManager()874*795d594fSAndroid Build Coastguard Worker   OatFileManager& GetOatFileManager() const {
875*795d594fSAndroid Build Coastguard Worker     DCHECK(oat_file_manager_ != nullptr);
876*795d594fSAndroid Build Coastguard Worker     return *oat_file_manager_;
877*795d594fSAndroid Build Coastguard Worker   }
878*795d594fSAndroid Build Coastguard Worker 
879*795d594fSAndroid Build Coastguard Worker   double GetHashTableMinLoadFactor() const;
880*795d594fSAndroid Build Coastguard Worker   double GetHashTableMaxLoadFactor() const;
881*795d594fSAndroid Build Coastguard Worker 
IsSafeMode()882*795d594fSAndroid Build Coastguard Worker   bool IsSafeMode() const {
883*795d594fSAndroid Build Coastguard Worker     return safe_mode_;
884*795d594fSAndroid Build Coastguard Worker   }
885*795d594fSAndroid Build Coastguard Worker 
SetSafeMode(bool mode)886*795d594fSAndroid Build Coastguard Worker   void SetSafeMode(bool mode) {
887*795d594fSAndroid Build Coastguard Worker     safe_mode_ = mode;
888*795d594fSAndroid Build Coastguard Worker   }
889*795d594fSAndroid Build Coastguard Worker 
GetDumpNativeStackOnSigQuit()890*795d594fSAndroid Build Coastguard Worker   bool GetDumpNativeStackOnSigQuit() const {
891*795d594fSAndroid Build Coastguard Worker     return dump_native_stack_on_sig_quit_;
892*795d594fSAndroid Build Coastguard Worker   }
893*795d594fSAndroid Build Coastguard Worker 
894*795d594fSAndroid Build Coastguard Worker   EXPORT void UpdateProcessState(ProcessState process_state);
895*795d594fSAndroid Build Coastguard Worker 
896*795d594fSAndroid Build Coastguard Worker   // Returns true if we currently care about long mutator pause.
InJankPerceptibleProcessState()897*795d594fSAndroid Build Coastguard Worker   bool InJankPerceptibleProcessState() const {
898*795d594fSAndroid Build Coastguard Worker     return process_state_ == kProcessStateJankPerceptible;
899*795d594fSAndroid Build Coastguard Worker   }
900*795d594fSAndroid Build Coastguard Worker 
901*795d594fSAndroid Build Coastguard Worker   void RegisterSensitiveThread() const;
902*795d594fSAndroid Build Coastguard Worker 
SetZygoteNoThreadSection(bool val)903*795d594fSAndroid Build Coastguard Worker   void SetZygoteNoThreadSection(bool val) {
904*795d594fSAndroid Build Coastguard Worker     zygote_no_threads_ = val;
905*795d594fSAndroid Build Coastguard Worker   }
906*795d594fSAndroid Build Coastguard Worker 
IsZygoteNoThreadSection()907*795d594fSAndroid Build Coastguard Worker   bool IsZygoteNoThreadSection() const {
908*795d594fSAndroid Build Coastguard Worker     return zygote_no_threads_;
909*795d594fSAndroid Build Coastguard Worker   }
910*795d594fSAndroid Build Coastguard Worker 
911*795d594fSAndroid Build Coastguard Worker   // Returns if the code can be deoptimized asynchronously. Code may be compiled with some
912*795d594fSAndroid Build Coastguard Worker   // optimization that makes it impossible to deoptimize.
913*795d594fSAndroid Build Coastguard Worker   EXPORT bool IsAsyncDeoptimizeable(ArtMethod* method, uintptr_t code) const
914*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
915*795d594fSAndroid Build Coastguard Worker 
916*795d594fSAndroid Build Coastguard Worker   // Returns a saved copy of the environment (getenv/setenv values).
917*795d594fSAndroid Build Coastguard Worker   // Used by Fork to protect against overwriting LD_LIBRARY_PATH, etc.
GetEnvSnapshot()918*795d594fSAndroid Build Coastguard Worker   char** GetEnvSnapshot() const {
919*795d594fSAndroid Build Coastguard Worker     return env_snapshot_.GetSnapshot();
920*795d594fSAndroid Build Coastguard Worker   }
921*795d594fSAndroid Build Coastguard Worker 
922*795d594fSAndroid Build Coastguard Worker   EXPORT void AddSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
923*795d594fSAndroid Build Coastguard Worker   EXPORT void RemoveSystemWeakHolder(gc::AbstractSystemWeakHolder* holder);
924*795d594fSAndroid Build Coastguard Worker 
925*795d594fSAndroid Build Coastguard Worker   EXPORT void AttachAgent(JNIEnv* env, const std::string& agent_arg, jobject class_loader);
926*795d594fSAndroid Build Coastguard Worker 
GetAgents()927*795d594fSAndroid Build Coastguard Worker   const std::list<std::unique_ptr<ti::Agent>>& GetAgents() const {
928*795d594fSAndroid Build Coastguard Worker     return agents_;
929*795d594fSAndroid Build Coastguard Worker   }
930*795d594fSAndroid Build Coastguard Worker 
931*795d594fSAndroid Build Coastguard Worker   EXPORT RuntimeCallbacks* GetRuntimeCallbacks();
932*795d594fSAndroid Build Coastguard Worker 
HasLoadedPlugins()933*795d594fSAndroid Build Coastguard Worker   bool HasLoadedPlugins() const {
934*795d594fSAndroid Build Coastguard Worker     return !plugins_.empty();
935*795d594fSAndroid Build Coastguard Worker   }
936*795d594fSAndroid Build Coastguard Worker 
937*795d594fSAndroid Build Coastguard Worker   void InitThreadGroups(Thread* self);
938*795d594fSAndroid Build Coastguard Worker 
SetDumpGCPerformanceOnShutdown(bool value)939*795d594fSAndroid Build Coastguard Worker   void SetDumpGCPerformanceOnShutdown(bool value) {
940*795d594fSAndroid Build Coastguard Worker     dump_gc_performance_on_shutdown_ = value;
941*795d594fSAndroid Build Coastguard Worker   }
942*795d594fSAndroid Build Coastguard Worker 
GetDumpGCPerformanceOnShutdown()943*795d594fSAndroid Build Coastguard Worker   bool GetDumpGCPerformanceOnShutdown() const {
944*795d594fSAndroid Build Coastguard Worker     return dump_gc_performance_on_shutdown_;
945*795d594fSAndroid Build Coastguard Worker   }
946*795d594fSAndroid Build Coastguard Worker 
IncrementDeoptimizationCount(DeoptimizationKind kind)947*795d594fSAndroid Build Coastguard Worker   void IncrementDeoptimizationCount(DeoptimizationKind kind) {
948*795d594fSAndroid Build Coastguard Worker     DCHECK_LE(kind, DeoptimizationKind::kLast);
949*795d594fSAndroid Build Coastguard Worker     deoptimization_counts_[static_cast<size_t>(kind)]++;
950*795d594fSAndroid Build Coastguard Worker   }
951*795d594fSAndroid Build Coastguard Worker 
GetNumberOfDeoptimizations()952*795d594fSAndroid Build Coastguard Worker   uint32_t GetNumberOfDeoptimizations() const {
953*795d594fSAndroid Build Coastguard Worker     uint32_t result = 0;
954*795d594fSAndroid Build Coastguard Worker     for (size_t i = 0; i <= static_cast<size_t>(DeoptimizationKind::kLast); ++i) {
955*795d594fSAndroid Build Coastguard Worker       result += deoptimization_counts_[i];
956*795d594fSAndroid Build Coastguard Worker     }
957*795d594fSAndroid Build Coastguard Worker     return result;
958*795d594fSAndroid Build Coastguard Worker   }
959*795d594fSAndroid Build Coastguard Worker 
DenyArtApexDataFiles()960*795d594fSAndroid Build Coastguard Worker   bool DenyArtApexDataFiles() const {
961*795d594fSAndroid Build Coastguard Worker     return deny_art_apex_data_files_;
962*795d594fSAndroid Build Coastguard Worker   }
963*795d594fSAndroid Build Coastguard Worker 
GetMadviseWillNeedTotalDexSize()964*795d594fSAndroid Build Coastguard Worker   size_t GetMadviseWillNeedTotalDexSize() const {
965*795d594fSAndroid Build Coastguard Worker     return madvise_willneed_total_dex_size_;
966*795d594fSAndroid Build Coastguard Worker   }
967*795d594fSAndroid Build Coastguard Worker 
GetMadviseWillNeedSizeOdex()968*795d594fSAndroid Build Coastguard Worker   size_t GetMadviseWillNeedSizeOdex() const {
969*795d594fSAndroid Build Coastguard Worker     return madvise_willneed_odex_filesize_;
970*795d594fSAndroid Build Coastguard Worker   }
971*795d594fSAndroid Build Coastguard Worker 
GetMadviseWillNeedSizeArt()972*795d594fSAndroid Build Coastguard Worker   size_t GetMadviseWillNeedSizeArt() const {
973*795d594fSAndroid Build Coastguard Worker     return madvise_willneed_art_filesize_;
974*795d594fSAndroid Build Coastguard Worker   }
975*795d594fSAndroid Build Coastguard Worker 
GetJdwpOptions()976*795d594fSAndroid Build Coastguard Worker   const std::string& GetJdwpOptions() {
977*795d594fSAndroid Build Coastguard Worker     return jdwp_options_;
978*795d594fSAndroid Build Coastguard Worker   }
979*795d594fSAndroid Build Coastguard Worker 
GetJdwpProvider()980*795d594fSAndroid Build Coastguard Worker   JdwpProvider GetJdwpProvider() const {
981*795d594fSAndroid Build Coastguard Worker     return jdwp_provider_;
982*795d594fSAndroid Build Coastguard Worker   }
983*795d594fSAndroid Build Coastguard Worker 
GetJniIdType()984*795d594fSAndroid Build Coastguard Worker   JniIdType GetJniIdType() const {
985*795d594fSAndroid Build Coastguard Worker     return jni_ids_indirection_;
986*795d594fSAndroid Build Coastguard Worker   }
987*795d594fSAndroid Build Coastguard Worker 
CanSetJniIdType()988*795d594fSAndroid Build Coastguard Worker   bool CanSetJniIdType() const {
989*795d594fSAndroid Build Coastguard Worker     return GetJniIdType() == JniIdType::kSwapablePointer;
990*795d594fSAndroid Build Coastguard Worker   }
991*795d594fSAndroid Build Coastguard Worker 
992*795d594fSAndroid Build Coastguard Worker   // Changes the JniIdType to the given type. Only allowed if CanSetJniIdType(). All threads must be
993*795d594fSAndroid Build Coastguard Worker   // suspended to call this function.
994*795d594fSAndroid Build Coastguard Worker   EXPORT void SetJniIdType(JniIdType t);
995*795d594fSAndroid Build Coastguard Worker 
GetVerifierLoggingThresholdMs()996*795d594fSAndroid Build Coastguard Worker   uint32_t GetVerifierLoggingThresholdMs() const {
997*795d594fSAndroid Build Coastguard Worker     return verifier_logging_threshold_ms_;
998*795d594fSAndroid Build Coastguard Worker   }
999*795d594fSAndroid Build Coastguard Worker 
1000*795d594fSAndroid Build Coastguard Worker   // Atomically delete the thread pool if the reference count is 0.
1001*795d594fSAndroid Build Coastguard Worker   bool DeleteThreadPool() REQUIRES(!Locks::runtime_thread_pool_lock_);
1002*795d594fSAndroid Build Coastguard Worker 
1003*795d594fSAndroid Build Coastguard Worker   // Wait for all the thread workers to be attached.
1004*795d594fSAndroid Build Coastguard Worker   void WaitForThreadPoolWorkersToStart() REQUIRES(!Locks::runtime_thread_pool_lock_);
1005*795d594fSAndroid Build Coastguard Worker 
1006*795d594fSAndroid Build Coastguard Worker   // Scoped usage of the runtime thread pool. Prevents the pool from being
1007*795d594fSAndroid Build Coastguard Worker   // deleted. Note that the thread pool is only for startup and gets deleted after.
1008*795d594fSAndroid Build Coastguard Worker   class ScopedThreadPoolUsage {
1009*795d594fSAndroid Build Coastguard Worker    public:
1010*795d594fSAndroid Build Coastguard Worker     ScopedThreadPoolUsage();
1011*795d594fSAndroid Build Coastguard Worker     ~ScopedThreadPoolUsage();
1012*795d594fSAndroid Build Coastguard Worker 
1013*795d594fSAndroid Build Coastguard Worker     // Return the thread pool.
GetThreadPool()1014*795d594fSAndroid Build Coastguard Worker     ThreadPool* GetThreadPool() const {
1015*795d594fSAndroid Build Coastguard Worker       return thread_pool_;
1016*795d594fSAndroid Build Coastguard Worker     }
1017*795d594fSAndroid Build Coastguard Worker 
1018*795d594fSAndroid Build Coastguard Worker    private:
1019*795d594fSAndroid Build Coastguard Worker     ThreadPool* const thread_pool_;
1020*795d594fSAndroid Build Coastguard Worker   };
1021*795d594fSAndroid Build Coastguard Worker 
ReleaseStartupLinearAlloc()1022*795d594fSAndroid Build Coastguard Worker   LinearAlloc* ReleaseStartupLinearAlloc() {
1023*795d594fSAndroid Build Coastguard Worker     return startup_linear_alloc_.exchange(nullptr, std::memory_order_relaxed);
1024*795d594fSAndroid Build Coastguard Worker   }
1025*795d594fSAndroid Build Coastguard Worker 
LoadAppImageStartupCache()1026*795d594fSAndroid Build Coastguard Worker   bool LoadAppImageStartupCache() const {
1027*795d594fSAndroid Build Coastguard Worker     return load_app_image_startup_cache_;
1028*795d594fSAndroid Build Coastguard Worker   }
1029*795d594fSAndroid Build Coastguard Worker 
SetLoadAppImageStartupCacheEnabled(bool enabled)1030*795d594fSAndroid Build Coastguard Worker   void SetLoadAppImageStartupCacheEnabled(bool enabled) {
1031*795d594fSAndroid Build Coastguard Worker     load_app_image_startup_cache_ = enabled;
1032*795d594fSAndroid Build Coastguard Worker   }
1033*795d594fSAndroid Build Coastguard Worker 
1034*795d594fSAndroid Build Coastguard Worker   // Reset the startup completed status so that we can call NotifyStartupCompleted again. Should
1035*795d594fSAndroid Build Coastguard Worker   // only be used for testing.
1036*795d594fSAndroid Build Coastguard Worker   EXPORT void ResetStartupCompleted();
1037*795d594fSAndroid Build Coastguard Worker 
1038*795d594fSAndroid Build Coastguard Worker   // Notify the runtime that application startup is considered completed. Only has effect for the
1039*795d594fSAndroid Build Coastguard Worker   // first call. Returns whether this was the first call.
1040*795d594fSAndroid Build Coastguard Worker   bool NotifyStartupCompleted();
1041*795d594fSAndroid Build Coastguard Worker 
1042*795d594fSAndroid Build Coastguard Worker   // Notify the runtime that the application finished loading some dex/odex files. This is
1043*795d594fSAndroid Build Coastguard Worker   // called everytime we load a set of dex files in a class loader.
1044*795d594fSAndroid Build Coastguard Worker   void NotifyDexFileLoaded();
1045*795d594fSAndroid Build Coastguard Worker 
1046*795d594fSAndroid Build Coastguard Worker   // Return true if startup is already completed.
1047*795d594fSAndroid Build Coastguard Worker   EXPORT bool GetStartupCompleted() const;
1048*795d594fSAndroid Build Coastguard Worker 
IsVerifierMissingKThrowFatal()1049*795d594fSAndroid Build Coastguard Worker   bool IsVerifierMissingKThrowFatal() const {
1050*795d594fSAndroid Build Coastguard Worker     return verifier_missing_kthrow_fatal_;
1051*795d594fSAndroid Build Coastguard Worker   }
1052*795d594fSAndroid Build Coastguard Worker 
IsJavaZygoteForkLoopRequired()1053*795d594fSAndroid Build Coastguard Worker   bool IsJavaZygoteForkLoopRequired() const {
1054*795d594fSAndroid Build Coastguard Worker     return force_java_zygote_fork_loop_;
1055*795d594fSAndroid Build Coastguard Worker   }
1056*795d594fSAndroid Build Coastguard Worker 
IsPerfettoHprofEnabled()1057*795d594fSAndroid Build Coastguard Worker   bool IsPerfettoHprofEnabled() const {
1058*795d594fSAndroid Build Coastguard Worker     return perfetto_hprof_enabled_;
1059*795d594fSAndroid Build Coastguard Worker   }
1060*795d594fSAndroid Build Coastguard Worker 
IsPerfettoJavaHeapStackProfEnabled()1061*795d594fSAndroid Build Coastguard Worker   bool IsPerfettoJavaHeapStackProfEnabled() const {
1062*795d594fSAndroid Build Coastguard Worker     return perfetto_javaheapprof_enabled_;
1063*795d594fSAndroid Build Coastguard Worker   }
1064*795d594fSAndroid Build Coastguard Worker 
IsMonitorTimeoutEnabled()1065*795d594fSAndroid Build Coastguard Worker   bool IsMonitorTimeoutEnabled() const {
1066*795d594fSAndroid Build Coastguard Worker     return monitor_timeout_enable_;
1067*795d594fSAndroid Build Coastguard Worker   }
1068*795d594fSAndroid Build Coastguard Worker 
GetMonitorTimeoutNs()1069*795d594fSAndroid Build Coastguard Worker   uint64_t GetMonitorTimeoutNs() const {
1070*795d594fSAndroid Build Coastguard Worker     return monitor_timeout_ns_;
1071*795d594fSAndroid Build Coastguard Worker   }
1072*795d594fSAndroid Build Coastguard Worker 
1073*795d594fSAndroid Build Coastguard Worker   // Return whether this is system server and it is being profiled.
1074*795d594fSAndroid Build Coastguard Worker   bool IsSystemServerProfiled() const;
1075*795d594fSAndroid Build Coastguard Worker 
1076*795d594fSAndroid Build Coastguard Worker   // Return whether we should load oat files as executable or not.
1077*795d594fSAndroid Build Coastguard Worker   bool GetOatFilesExecutable() const;
1078*795d594fSAndroid Build Coastguard Worker 
GetMetrics()1079*795d594fSAndroid Build Coastguard Worker   metrics::ArtMetrics* GetMetrics() { return &metrics_; }
1080*795d594fSAndroid Build Coastguard Worker 
GetAppInfo()1081*795d594fSAndroid Build Coastguard Worker   AppInfo* GetAppInfo() { return &app_info_; }
1082*795d594fSAndroid Build Coastguard Worker 
1083*795d594fSAndroid Build Coastguard Worker   void RequestMetricsReport(bool synchronous = true);
1084*795d594fSAndroid Build Coastguard Worker 
1085*795d594fSAndroid Build Coastguard Worker   static void MadviseFileForRange(size_t madvise_size_limit_bytes,
1086*795d594fSAndroid Build Coastguard Worker                                   size_t map_size_bytes,
1087*795d594fSAndroid Build Coastguard Worker                                   const uint8_t* map_begin,
1088*795d594fSAndroid Build Coastguard Worker                                   const uint8_t* map_end,
1089*795d594fSAndroid Build Coastguard Worker                                   const std::string& file_name);
1090*795d594fSAndroid Build Coastguard Worker 
GetApexVersions()1091*795d594fSAndroid Build Coastguard Worker   const std::string& GetApexVersions() const {
1092*795d594fSAndroid Build Coastguard Worker     return apex_versions_;
1093*795d594fSAndroid Build Coastguard Worker   }
1094*795d594fSAndroid Build Coastguard Worker 
1095*795d594fSAndroid Build Coastguard Worker   // Return whether a boot image has a profile. This means it's an in-memory
1096*795d594fSAndroid Build Coastguard Worker   // image rather that an image loaded from disk.
1097*795d594fSAndroid Build Coastguard Worker   bool HasImageWithProfile() const;
1098*795d594fSAndroid Build Coastguard Worker 
GetNoSigChain()1099*795d594fSAndroid Build Coastguard Worker   bool GetNoSigChain() const {
1100*795d594fSAndroid Build Coastguard Worker     return no_sig_chain_;
1101*795d594fSAndroid Build Coastguard Worker   }
1102*795d594fSAndroid Build Coastguard Worker 
1103*795d594fSAndroid Build Coastguard Worker   void AddGeneratedCodeRange(const void* start, size_t size);
1104*795d594fSAndroid Build Coastguard Worker   void RemoveGeneratedCodeRange(const void* start, size_t size)
1105*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
1106*795d594fSAndroid Build Coastguard Worker 
1107*795d594fSAndroid Build Coastguard Worker   // Trigger a flag reload from system properties or device congfigs.
1108*795d594fSAndroid Build Coastguard Worker   //
1109*795d594fSAndroid Build Coastguard Worker   // Should only be called from runtime init and zygote post fork as
1110*795d594fSAndroid Build Coastguard Worker   // we don't want to change the runtime config midway during execution.
1111*795d594fSAndroid Build Coastguard Worker   //
1112*795d594fSAndroid Build Coastguard Worker   // The caller argument should be the name of the function making this call
1113*795d594fSAndroid Build Coastguard Worker   // and will be used to enforce the appropriate names.
1114*795d594fSAndroid Build Coastguard Worker   //
1115*795d594fSAndroid Build Coastguard Worker   // See Flags::ReloadAllFlags as well.
1116*795d594fSAndroid Build Coastguard Worker   static void ReloadAllFlags(const std::string& caller);
1117*795d594fSAndroid Build Coastguard Worker 
1118*795d594fSAndroid Build Coastguard Worker   // Parses /apex/apex-info-list.xml to build a string containing apex versions of boot classpath
1119*795d594fSAndroid Build Coastguard Worker   // jars, which is encoded into .oat files.
1120*795d594fSAndroid Build Coastguard Worker   static std::string GetApexVersions(ArrayRef<const std::string> boot_class_path_locations);
1121*795d594fSAndroid Build Coastguard Worker 
AllowInMemoryCompilation()1122*795d594fSAndroid Build Coastguard Worker   bool AllowInMemoryCompilation() const { return allow_in_memory_compilation_; }
1123*795d594fSAndroid Build Coastguard Worker 
1124*795d594fSAndroid Build Coastguard Worker   // Used by plugin code to attach a hook for OOME.
SetOutOfMemoryErrorHook(void (* hook)())1125*795d594fSAndroid Build Coastguard Worker   void SetOutOfMemoryErrorHook(void (*hook)()) {
1126*795d594fSAndroid Build Coastguard Worker     out_of_memory_error_hook_ = hook;
1127*795d594fSAndroid Build Coastguard Worker   }
1128*795d594fSAndroid Build Coastguard Worker 
OutOfMemoryErrorHook()1129*795d594fSAndroid Build Coastguard Worker   void OutOfMemoryErrorHook() {
1130*795d594fSAndroid Build Coastguard Worker     if (out_of_memory_error_hook_ != nullptr) {
1131*795d594fSAndroid Build Coastguard Worker       out_of_memory_error_hook_();
1132*795d594fSAndroid Build Coastguard Worker     }
1133*795d594fSAndroid Build Coastguard Worker   }
1134*795d594fSAndroid Build Coastguard Worker 
AreMetricsInitialized()1135*795d594fSAndroid Build Coastguard Worker   bool AreMetricsInitialized() const { return metrics_reporter_ != nullptr; }
1136*795d594fSAndroid Build Coastguard Worker 
1137*795d594fSAndroid Build Coastguard Worker   // For `artd` only.
1138*795d594fSAndroid Build Coastguard Worker   EXPORT static void AllowPageSizeAccess();
1139*795d594fSAndroid Build Coastguard Worker 
1140*795d594fSAndroid Build Coastguard Worker  private:
1141*795d594fSAndroid Build Coastguard Worker   static void InitPlatformSignalHandlers();
1142*795d594fSAndroid Build Coastguard Worker 
1143*795d594fSAndroid Build Coastguard Worker   Runtime();
1144*795d594fSAndroid Build Coastguard Worker 
HandlesSignalsInCompiledCode()1145*795d594fSAndroid Build Coastguard Worker   bool HandlesSignalsInCompiledCode() const {
1146*795d594fSAndroid Build Coastguard Worker     return !no_sig_chain_ &&
1147*795d594fSAndroid Build Coastguard Worker            (implicit_null_checks_ || implicit_so_checks_ || implicit_suspend_checks_);
1148*795d594fSAndroid Build Coastguard Worker   }
1149*795d594fSAndroid Build Coastguard Worker 
1150*795d594fSAndroid Build Coastguard Worker   void BlockSignals();
1151*795d594fSAndroid Build Coastguard Worker 
1152*795d594fSAndroid Build Coastguard Worker   bool Init(RuntimeArgumentMap&& runtime_options)
1153*795d594fSAndroid Build Coastguard Worker       SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
1154*795d594fSAndroid Build Coastguard Worker   void InitNativeMethods() REQUIRES(!Locks::mutator_lock_);
1155*795d594fSAndroid Build Coastguard Worker   void RegisterRuntimeNativeMethods(JNIEnv* env);
1156*795d594fSAndroid Build Coastguard Worker   void InitMetrics();
1157*795d594fSAndroid Build Coastguard Worker 
1158*795d594fSAndroid Build Coastguard Worker   void StartDaemonThreads() REQUIRES_SHARED(Locks::mutator_lock_);
1159*795d594fSAndroid Build Coastguard Worker   void StartSignalCatcher();
1160*795d594fSAndroid Build Coastguard Worker 
1161*795d594fSAndroid Build Coastguard Worker   void MaybeSaveJitProfilingInfo();
1162*795d594fSAndroid Build Coastguard Worker 
1163*795d594fSAndroid Build Coastguard Worker   // Visit all of the thread roots.
1164*795d594fSAndroid Build Coastguard Worker   void VisitThreadRoots(RootVisitor* visitor, VisitRootFlags flags)
1165*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
1166*795d594fSAndroid Build Coastguard Worker 
1167*795d594fSAndroid Build Coastguard Worker   // Visit all other roots which must be done with mutators suspended.
1168*795d594fSAndroid Build Coastguard Worker   void VisitNonConcurrentRoots(RootVisitor* visitor, VisitRootFlags flags)
1169*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
1170*795d594fSAndroid Build Coastguard Worker 
1171*795d594fSAndroid Build Coastguard Worker   // Constant roots are the roots which never change after the runtime is initialized, they only
1172*795d594fSAndroid Build Coastguard Worker   // need to be visited once per GC cycle.
1173*795d594fSAndroid Build Coastguard Worker   void VisitConstantRoots(RootVisitor* visitor)
1174*795d594fSAndroid Build Coastguard Worker       REQUIRES_SHARED(Locks::mutator_lock_);
1175*795d594fSAndroid Build Coastguard Worker 
1176*795d594fSAndroid Build Coastguard Worker   // Note: To be lock-free, GetFaultMessage temporarily replaces the lock message with null.
1177*795d594fSAndroid Build Coastguard Worker   //       As such, there is a window where a call will return an empty string. In general,
1178*795d594fSAndroid Build Coastguard Worker   //       only aborting code should retrieve this data (via GetFaultMessageForAbortLogging
1179*795d594fSAndroid Build Coastguard Worker   //       friend).
1180*795d594fSAndroid Build Coastguard Worker   std::string GetFaultMessage();
1181*795d594fSAndroid Build Coastguard Worker 
1182*795d594fSAndroid Build Coastguard Worker   ThreadPool* AcquireThreadPool() REQUIRES(!Locks::runtime_thread_pool_lock_);
1183*795d594fSAndroid Build Coastguard Worker   void ReleaseThreadPool() REQUIRES(!Locks::runtime_thread_pool_lock_);
1184*795d594fSAndroid Build Coastguard Worker 
1185*795d594fSAndroid Build Coastguard Worker   // Caches the apex versions produced by `GetApexVersions`.
1186*795d594fSAndroid Build Coastguard Worker   void InitializeApexVersions();
1187*795d594fSAndroid Build Coastguard Worker 
1188*795d594fSAndroid Build Coastguard Worker   void AppendToBootClassPath(const std::string& filename, const std::string& location);
1189*795d594fSAndroid Build Coastguard Worker 
1190*795d594fSAndroid Build Coastguard Worker   void DCheckNoTransactionCheckAllowed();
1191*795d594fSAndroid Build Coastguard Worker 
1192*795d594fSAndroid Build Coastguard Worker   // Don't use EXPORT ("default" visibility), because quick_entrypoints_x86.o
1193*795d594fSAndroid Build Coastguard Worker   // refers to this symbol and it can't link with R_386_PC32 relocation.
1194*795d594fSAndroid Build Coastguard Worker   // A pointer to the active runtime or null.
1195*795d594fSAndroid Build Coastguard Worker   LIBART_PROTECTED static Runtime* instance_;
1196*795d594fSAndroid Build Coastguard Worker 
1197*795d594fSAndroid Build Coastguard Worker   static constexpr uint32_t kCalleeSaveSize = 6u;
1198*795d594fSAndroid Build Coastguard Worker 
1199*795d594fSAndroid Build Coastguard Worker   // 64 bit so that we can share the same asm offsets for both 32 and 64 bits.
1200*795d594fSAndroid Build Coastguard Worker   uint64_t callee_save_methods_[kCalleeSaveSize];
1201*795d594fSAndroid Build Coastguard Worker   // Pre-allocated exceptions (see Runtime::Init).
1202*795d594fSAndroid Build Coastguard Worker   GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_when_throwing_exception_;
1203*795d594fSAndroid Build Coastguard Worker   GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_when_throwing_oome_;
1204*795d594fSAndroid Build Coastguard Worker   GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_when_handling_stack_overflow_;
1205*795d594fSAndroid Build Coastguard Worker   GcRoot<mirror::Throwable> pre_allocated_NoClassDefFoundError_;
1206*795d594fSAndroid Build Coastguard Worker   ArtMethod* resolution_method_;
1207*795d594fSAndroid Build Coastguard Worker   ArtMethod* imt_conflict_method_;
1208*795d594fSAndroid Build Coastguard Worker   // Unresolved method has the same behavior as the conflict method, it is used by the class linker
1209*795d594fSAndroid Build Coastguard Worker   // for differentiating between unfilled imt slots vs conflict slots in superclasses.
1210*795d594fSAndroid Build Coastguard Worker   ArtMethod* imt_unimplemented_method_;
1211*795d594fSAndroid Build Coastguard Worker 
1212*795d594fSAndroid Build Coastguard Worker   // Special sentinel object used to invalid conditions in JNI (cleared weak references) and
1213*795d594fSAndroid Build Coastguard Worker   // JDWP (invalid references).
1214*795d594fSAndroid Build Coastguard Worker   GcRoot<mirror::Object> sentinel_;
1215*795d594fSAndroid Build Coastguard Worker 
1216*795d594fSAndroid Build Coastguard Worker   InstructionSet instruction_set_;
1217*795d594fSAndroid Build Coastguard Worker 
1218*795d594fSAndroid Build Coastguard Worker   CompilerCallbacks* compiler_callbacks_;
1219*795d594fSAndroid Build Coastguard Worker   bool is_zygote_;
1220*795d594fSAndroid Build Coastguard Worker   bool is_primary_zygote_;
1221*795d594fSAndroid Build Coastguard Worker   bool is_system_server_;
1222*795d594fSAndroid Build Coastguard Worker   bool must_relocate_;
1223*795d594fSAndroid Build Coastguard Worker   bool is_concurrent_gc_enabled_;
1224*795d594fSAndroid Build Coastguard Worker   bool is_explicit_gc_disabled_;
1225*795d594fSAndroid Build Coastguard Worker   bool is_eagerly_release_explicit_gc_disabled_;
1226*795d594fSAndroid Build Coastguard Worker   bool image_dex2oat_enabled_;
1227*795d594fSAndroid Build Coastguard Worker 
1228*795d594fSAndroid Build Coastguard Worker   std::string compiler_executable_;
1229*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> compiler_options_;
1230*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> image_compiler_options_;
1231*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> image_locations_;
1232*795d594fSAndroid Build Coastguard Worker 
1233*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> boot_class_path_;
1234*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> boot_class_path_locations_;
1235*795d594fSAndroid Build Coastguard Worker   std::string boot_class_path_checksums_;
1236*795d594fSAndroid Build Coastguard Worker   std::vector<File> boot_class_path_files_;
1237*795d594fSAndroid Build Coastguard Worker   std::vector<File> boot_class_path_image_files_;
1238*795d594fSAndroid Build Coastguard Worker   std::vector<File> boot_class_path_vdex_files_;
1239*795d594fSAndroid Build Coastguard Worker   std::vector<File> boot_class_path_oat_files_;
1240*795d594fSAndroid Build Coastguard Worker   std::string class_path_string_;
1241*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> properties_;
1242*795d594fSAndroid Build Coastguard Worker 
1243*795d594fSAndroid Build Coastguard Worker   std::list<ti::AgentSpec> agent_specs_;
1244*795d594fSAndroid Build Coastguard Worker   std::list<std::unique_ptr<ti::Agent>> agents_;
1245*795d594fSAndroid Build Coastguard Worker   std::vector<Plugin> plugins_;
1246*795d594fSAndroid Build Coastguard Worker 
1247*795d594fSAndroid Build Coastguard Worker   // The default stack size for managed threads created by the runtime.
1248*795d594fSAndroid Build Coastguard Worker   size_t default_stack_size_;
1249*795d594fSAndroid Build Coastguard Worker 
1250*795d594fSAndroid Build Coastguard Worker   // Finalizers running for longer than this many milliseconds abort the runtime.
1251*795d594fSAndroid Build Coastguard Worker   unsigned int finalizer_timeout_ms_;
1252*795d594fSAndroid Build Coastguard Worker 
1253*795d594fSAndroid Build Coastguard Worker   gc::Heap* heap_;
1254*795d594fSAndroid Build Coastguard Worker 
1255*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<ArenaPool> jit_arena_pool_;
1256*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<ArenaPool> arena_pool_;
1257*795d594fSAndroid Build Coastguard Worker   // This pool is used for linear alloc if we are using userfaultfd GC, or if
1258*795d594fSAndroid Build Coastguard Worker   // low 4gb pool is required for compiler linear alloc. Otherwise, use
1259*795d594fSAndroid Build Coastguard Worker   // arena_pool_.
1260*795d594fSAndroid Build Coastguard Worker   // We need ArtFields to be in low 4gb if we are compiling using a 32 bit image
1261*795d594fSAndroid Build Coastguard Worker   // on a 64 bit compiler in case we resolve things in the image since the field
1262*795d594fSAndroid Build Coastguard Worker   // arrays are int arrays in this case.
1263*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<ArenaPool> linear_alloc_arena_pool_;
1264*795d594fSAndroid Build Coastguard Worker 
1265*795d594fSAndroid Build Coastguard Worker   // Shared linear alloc for now.
1266*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<LinearAlloc> linear_alloc_;
1267*795d594fSAndroid Build Coastguard Worker 
1268*795d594fSAndroid Build Coastguard Worker   // Linear alloc used for allocations during startup. Will be deleted after
1269*795d594fSAndroid Build Coastguard Worker   // startup. Atomic because the pointer can be concurrently updated to null.
1270*795d594fSAndroid Build Coastguard Worker   std::atomic<LinearAlloc*> startup_linear_alloc_;
1271*795d594fSAndroid Build Coastguard Worker 
1272*795d594fSAndroid Build Coastguard Worker   // The number of spins that are done before thread suspension is used to forcibly inflate.
1273*795d594fSAndroid Build Coastguard Worker   size_t max_spins_before_thin_lock_inflation_;
1274*795d594fSAndroid Build Coastguard Worker   MonitorList* monitor_list_;
1275*795d594fSAndroid Build Coastguard Worker   MonitorPool* monitor_pool_;
1276*795d594fSAndroid Build Coastguard Worker 
1277*795d594fSAndroid Build Coastguard Worker   ThreadList* thread_list_;
1278*795d594fSAndroid Build Coastguard Worker 
1279*795d594fSAndroid Build Coastguard Worker   InternTable* intern_table_;
1280*795d594fSAndroid Build Coastguard Worker 
1281*795d594fSAndroid Build Coastguard Worker   ClassLinker* class_linker_;
1282*795d594fSAndroid Build Coastguard Worker 
1283*795d594fSAndroid Build Coastguard Worker   SignalCatcher* signal_catcher_;
1284*795d594fSAndroid Build Coastguard Worker 
1285*795d594fSAndroid Build Coastguard Worker   jni::SmallLrtAllocator* small_lrt_allocator_;
1286*795d594fSAndroid Build Coastguard Worker 
1287*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<jni::JniIdManager> jni_id_manager_;
1288*795d594fSAndroid Build Coastguard Worker 
1289*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<JavaVMExt> java_vm_;
1290*795d594fSAndroid Build Coastguard Worker 
1291*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<jit::Jit> jit_;
1292*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<jit::JitCodeCache> jit_code_cache_;
1293*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<jit::JitOptions> jit_options_;
1294*795d594fSAndroid Build Coastguard Worker 
1295*795d594fSAndroid Build Coastguard Worker   // Runtime thread pool. The pool is only for startup and gets deleted after.
1296*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<ThreadPool> thread_pool_ GUARDED_BY(Locks::runtime_thread_pool_lock_);
1297*795d594fSAndroid Build Coastguard Worker   size_t thread_pool_ref_count_ GUARDED_BY(Locks::runtime_thread_pool_lock_);
1298*795d594fSAndroid Build Coastguard Worker 
1299*795d594fSAndroid Build Coastguard Worker   // Fault message, printed when we get a SIGSEGV. Stored as a native-heap object and accessed
1300*795d594fSAndroid Build Coastguard Worker   // lock-free, so needs to be atomic.
1301*795d594fSAndroid Build Coastguard Worker   std::atomic<std::string*> fault_message_;
1302*795d594fSAndroid Build Coastguard Worker 
1303*795d594fSAndroid Build Coastguard Worker   // A non-zero value indicates that a thread has been created but not yet initialized. Guarded by
1304*795d594fSAndroid Build Coastguard Worker   // the shutdown lock so that threads aren't born while we're shutting down.
1305*795d594fSAndroid Build Coastguard Worker   size_t threads_being_born_ GUARDED_BY(Locks::runtime_shutdown_lock_);
1306*795d594fSAndroid Build Coastguard Worker 
1307*795d594fSAndroid Build Coastguard Worker   // Waited upon until no threads are being born.
1308*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_);
1309*795d594fSAndroid Build Coastguard Worker 
1310*795d594fSAndroid Build Coastguard Worker   // Set when runtime shutdown is past the point that new threads may attach.  Usually
1311*795d594fSAndroid Build Coastguard Worker   // GUARDED_BY(Locks::runtime_shutdown_lock_). But we need to check it in Abort without the
1312*795d594fSAndroid Build Coastguard Worker   // lock, because we may already own it.
1313*795d594fSAndroid Build Coastguard Worker   std::atomic<bool> shutting_down_;
1314*795d594fSAndroid Build Coastguard Worker 
1315*795d594fSAndroid Build Coastguard Worker   // The runtime is starting to shutdown but is blocked waiting on shutdown_cond_.
1316*795d594fSAndroid Build Coastguard Worker   bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_);
1317*795d594fSAndroid Build Coastguard Worker 
1318*795d594fSAndroid Build Coastguard Worker   bool started_;
1319*795d594fSAndroid Build Coastguard Worker 
1320*795d594fSAndroid Build Coastguard Worker   // New flag added which tells us if the runtime has finished starting. If
1321*795d594fSAndroid Build Coastguard Worker   // this flag is set then the Daemon threads are created and the class loader
1322*795d594fSAndroid Build Coastguard Worker   // is created. This flag is needed for knowing if its safe to request CMS.
1323*795d594fSAndroid Build Coastguard Worker   bool finished_starting_;
1324*795d594fSAndroid Build Coastguard Worker 
1325*795d594fSAndroid Build Coastguard Worker   // Hooks supported by JNI_CreateJavaVM
1326*795d594fSAndroid Build Coastguard Worker   jint (*vfprintf_)(FILE* stream, const char* format, va_list ap);
1327*795d594fSAndroid Build Coastguard Worker   void (*exit_)(jint status);
1328*795d594fSAndroid Build Coastguard Worker   void (*abort_)();
1329*795d594fSAndroid Build Coastguard Worker 
1330*795d594fSAndroid Build Coastguard Worker   bool stats_enabled_;
1331*795d594fSAndroid Build Coastguard Worker   RuntimeStats stats_;
1332*795d594fSAndroid Build Coastguard Worker 
1333*795d594fSAndroid Build Coastguard Worker   const bool is_running_on_memory_tool_;
1334*795d594fSAndroid Build Coastguard Worker 
1335*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<TraceConfig> trace_config_;
1336*795d594fSAndroid Build Coastguard Worker 
1337*795d594fSAndroid Build Coastguard Worker   instrumentation::Instrumentation instrumentation_;
1338*795d594fSAndroid Build Coastguard Worker 
1339*795d594fSAndroid Build Coastguard Worker   jobject main_thread_group_;
1340*795d594fSAndroid Build Coastguard Worker   jobject system_thread_group_;
1341*795d594fSAndroid Build Coastguard Worker 
1342*795d594fSAndroid Build Coastguard Worker   // As returned by ClassLoader.getSystemClassLoader().
1343*795d594fSAndroid Build Coastguard Worker   jobject system_class_loader_;
1344*795d594fSAndroid Build Coastguard Worker 
1345*795d594fSAndroid Build Coastguard Worker   // If true, then we dump the GC cumulative timings on shutdown.
1346*795d594fSAndroid Build Coastguard Worker   bool dump_gc_performance_on_shutdown_;
1347*795d594fSAndroid Build Coastguard Worker 
1348*795d594fSAndroid Build Coastguard Worker   // Transactions are handled by the `AotClassLinker` but we keep a simple flag
1349*795d594fSAndroid Build Coastguard Worker   // in the `Runtime` for quick transaction checks.
1350*795d594fSAndroid Build Coastguard Worker   // Code that's not AOT-specific but needs some transaction-specific behavior
1351*795d594fSAndroid Build Coastguard Worker   // shall check this flag and, for an active transaction, make virtual calls
1352*795d594fSAndroid Build Coastguard Worker   // through `ClassLinker` to `AotClassLinker` to implement that behavior.
1353*795d594fSAndroid Build Coastguard Worker   bool active_transaction_;
1354*795d594fSAndroid Build Coastguard Worker 
1355*795d594fSAndroid Build Coastguard Worker   // If kNone, verification is disabled. kEnable by default.
1356*795d594fSAndroid Build Coastguard Worker   verifier::VerifyMode verify_;
1357*795d594fSAndroid Build Coastguard Worker 
1358*795d594fSAndroid Build Coastguard Worker   // List of supported cpu abis.
1359*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> cpu_abilist_;
1360*795d594fSAndroid Build Coastguard Worker 
1361*795d594fSAndroid Build Coastguard Worker   // Specifies target SDK version to allow workarounds for certain API levels.
1362*795d594fSAndroid Build Coastguard Worker   uint32_t target_sdk_version_;
1363*795d594fSAndroid Build Coastguard Worker 
1364*795d594fSAndroid Build Coastguard Worker   // ART counterpart for the compat framework (go/compat-framework).
1365*795d594fSAndroid Build Coastguard Worker   CompatFramework compat_framework_;
1366*795d594fSAndroid Build Coastguard Worker 
1367*795d594fSAndroid Build Coastguard Worker   // Implicit checks flags.
1368*795d594fSAndroid Build Coastguard Worker   bool implicit_null_checks_;       // NullPointer checks are implicit.
1369*795d594fSAndroid Build Coastguard Worker   bool implicit_so_checks_;         // StackOverflow checks are implicit.
1370*795d594fSAndroid Build Coastguard Worker   bool implicit_suspend_checks_;    // Thread suspension checks are implicit.
1371*795d594fSAndroid Build Coastguard Worker 
1372*795d594fSAndroid Build Coastguard Worker   // Whether or not the sig chain (and implicitly the fault handler) should be
1373*795d594fSAndroid Build Coastguard Worker   // disabled. Tools like dex2oat don't need them. This enables
1374*795d594fSAndroid Build Coastguard Worker   // building a statically link version of dex2oat.
1375*795d594fSAndroid Build Coastguard Worker   bool no_sig_chain_;
1376*795d594fSAndroid Build Coastguard Worker 
1377*795d594fSAndroid Build Coastguard Worker   // Force the use of native bridge even if the app ISA matches the runtime ISA.
1378*795d594fSAndroid Build Coastguard Worker   bool force_native_bridge_;
1379*795d594fSAndroid Build Coastguard Worker 
1380*795d594fSAndroid Build Coastguard Worker   // Whether or not a native bridge has been loaded.
1381*795d594fSAndroid Build Coastguard Worker   //
1382*795d594fSAndroid Build Coastguard Worker   // The native bridge allows running native code compiled for a foreign ISA. The way it works is,
1383*795d594fSAndroid Build Coastguard Worker   // if standard dlopen fails to load native library associated with native activity, it calls to
1384*795d594fSAndroid Build Coastguard Worker   // the native bridge to load it and then gets the trampoline for the entry to native activity.
1385*795d594fSAndroid Build Coastguard Worker   //
1386*795d594fSAndroid Build Coastguard Worker   // The option 'native_bridge_library_filename' specifies the name of the native bridge.
1387*795d594fSAndroid Build Coastguard Worker   // When non-empty the native bridge will be loaded from the given file. An empty value means
1388*795d594fSAndroid Build Coastguard Worker   // that there's no native bridge.
1389*795d594fSAndroid Build Coastguard Worker   bool is_native_bridge_loaded_;
1390*795d594fSAndroid Build Coastguard Worker 
1391*795d594fSAndroid Build Coastguard Worker   // Whether we are running under native debugger.
1392*795d594fSAndroid Build Coastguard Worker   bool is_native_debuggable_;
1393*795d594fSAndroid Build Coastguard Worker 
1394*795d594fSAndroid Build Coastguard Worker   // whether or not any async exceptions have ever been thrown. This is used to speed up the
1395*795d594fSAndroid Build Coastguard Worker   // MterpShouldSwitchInterpreters function.
1396*795d594fSAndroid Build Coastguard Worker   bool async_exceptions_thrown_;
1397*795d594fSAndroid Build Coastguard Worker 
1398*795d594fSAndroid Build Coastguard Worker   // Whether anything is going to be using the shadow-frame APIs to force a function to return
1399*795d594fSAndroid Build Coastguard Worker   // early. Doing this requires that (1) we be debuggable and (2) that mterp is exited.
1400*795d594fSAndroid Build Coastguard Worker   bool non_standard_exits_enabled_;
1401*795d594fSAndroid Build Coastguard Worker 
1402*795d594fSAndroid Build Coastguard Worker   // Whether Java code needs to be debuggable.
1403*795d594fSAndroid Build Coastguard Worker   RuntimeDebugState runtime_debug_state_;
1404*795d594fSAndroid Build Coastguard Worker 
1405*795d594fSAndroid Build Coastguard Worker   bool monitor_timeout_enable_;
1406*795d594fSAndroid Build Coastguard Worker   uint64_t monitor_timeout_ns_;
1407*795d594fSAndroid Build Coastguard Worker 
1408*795d594fSAndroid Build Coastguard Worker   // Whether or not this application can be profiled by the shell user,
1409*795d594fSAndroid Build Coastguard Worker   // even when running on a device that is running in user mode.
1410*795d594fSAndroid Build Coastguard Worker   bool is_profileable_from_shell_ = false;
1411*795d594fSAndroid Build Coastguard Worker 
1412*795d594fSAndroid Build Coastguard Worker   // Whether or not this application can be profiled by system services on a
1413*795d594fSAndroid Build Coastguard Worker   // device running in user mode, but not necessarily by the shell user.
1414*795d594fSAndroid Build Coastguard Worker   bool is_profileable_ = false;
1415*795d594fSAndroid Build Coastguard Worker 
1416*795d594fSAndroid Build Coastguard Worker   // The maximum number of failed boots we allow before pruning the dalvik cache
1417*795d594fSAndroid Build Coastguard Worker   // and trying again. This option is only inspected when we're running as a
1418*795d594fSAndroid Build Coastguard Worker   // zygote.
1419*795d594fSAndroid Build Coastguard Worker   uint32_t zygote_max_failed_boots_;
1420*795d594fSAndroid Build Coastguard Worker 
1421*795d594fSAndroid Build Coastguard Worker   // Enable experimental opcodes that aren't fully specified yet. The intent is to
1422*795d594fSAndroid Build Coastguard Worker   // eventually publish them as public-usable opcodes, but they aren't ready yet.
1423*795d594fSAndroid Build Coastguard Worker   //
1424*795d594fSAndroid Build Coastguard Worker   // Experimental opcodes should not be used by other production code.
1425*795d594fSAndroid Build Coastguard Worker   ExperimentalFlags experimental_flags_;
1426*795d594fSAndroid Build Coastguard Worker 
1427*795d594fSAndroid Build Coastguard Worker   // Contains the build fingerprint, if given as a parameter.
1428*795d594fSAndroid Build Coastguard Worker   std::string fingerprint_;
1429*795d594fSAndroid Build Coastguard Worker 
1430*795d594fSAndroid Build Coastguard Worker   // Oat file manager, keeps track of what oat files are open.
1431*795d594fSAndroid Build Coastguard Worker   OatFileManager* oat_file_manager_;
1432*795d594fSAndroid Build Coastguard Worker 
1433*795d594fSAndroid Build Coastguard Worker   // Whether or not we are on a low RAM device.
1434*795d594fSAndroid Build Coastguard Worker   bool is_low_memory_mode_;
1435*795d594fSAndroid Build Coastguard Worker 
1436*795d594fSAndroid Build Coastguard Worker   // Limiting size (in bytes) for applying MADV_WILLNEED on vdex files
1437*795d594fSAndroid Build Coastguard Worker   // or uncompressed dex files in APKs.
1438*795d594fSAndroid Build Coastguard Worker   // A 0 for this will turn off madvising to MADV_WILLNEED
1439*795d594fSAndroid Build Coastguard Worker   size_t madvise_willneed_total_dex_size_;
1440*795d594fSAndroid Build Coastguard Worker 
1441*795d594fSAndroid Build Coastguard Worker   // Limiting size (in bytes) for applying MADV_WILLNEED on odex files
1442*795d594fSAndroid Build Coastguard Worker   // A 0 for this will turn off madvising to MADV_WILLNEED
1443*795d594fSAndroid Build Coastguard Worker   size_t madvise_willneed_odex_filesize_;
1444*795d594fSAndroid Build Coastguard Worker 
1445*795d594fSAndroid Build Coastguard Worker   // Limiting size (in bytes) for applying MADV_WILLNEED on art files
1446*795d594fSAndroid Build Coastguard Worker   // A 0 for this will turn off madvising to MADV_WILLNEED
1447*795d594fSAndroid Build Coastguard Worker   size_t madvise_willneed_art_filesize_;
1448*795d594fSAndroid Build Coastguard Worker 
1449*795d594fSAndroid Build Coastguard Worker   // Whether the application should run in safe mode, that is, interpreter only.
1450*795d594fSAndroid Build Coastguard Worker   bool safe_mode_;
1451*795d594fSAndroid Build Coastguard Worker 
1452*795d594fSAndroid Build Coastguard Worker   // Whether access checks on hidden API should be performed.
1453*795d594fSAndroid Build Coastguard Worker   hiddenapi::EnforcementPolicy hidden_api_policy_;
1454*795d594fSAndroid Build Coastguard Worker 
1455*795d594fSAndroid Build Coastguard Worker   // Whether access checks on core platform API should be performed.
1456*795d594fSAndroid Build Coastguard Worker   hiddenapi::EnforcementPolicy core_platform_api_policy_;
1457*795d594fSAndroid Build Coastguard Worker 
1458*795d594fSAndroid Build Coastguard Worker   // Whether access checks on test API should be performed.
1459*795d594fSAndroid Build Coastguard Worker   hiddenapi::EnforcementPolicy test_api_policy_;
1460*795d594fSAndroid Build Coastguard Worker 
1461*795d594fSAndroid Build Coastguard Worker   // List of signature prefixes of methods that have been removed from the blocklist, and treated
1462*795d594fSAndroid Build Coastguard Worker   // as if SDK.
1463*795d594fSAndroid Build Coastguard Worker   std::vector<std::string> hidden_api_exemptions_;
1464*795d594fSAndroid Build Coastguard Worker 
1465*795d594fSAndroid Build Coastguard Worker   // Do not warn about the same hidden API access violation twice.
1466*795d594fSAndroid Build Coastguard Worker   // This is only used for testing.
1467*795d594fSAndroid Build Coastguard Worker   bool dedupe_hidden_api_warnings_;
1468*795d594fSAndroid Build Coastguard Worker 
1469*795d594fSAndroid Build Coastguard Worker   // How often to log hidden API access to the event log. An integer between 0
1470*795d594fSAndroid Build Coastguard Worker   // (never) and 0x10000 (always).
1471*795d594fSAndroid Build Coastguard Worker   uint32_t hidden_api_access_event_log_rate_;
1472*795d594fSAndroid Build Coastguard Worker 
1473*795d594fSAndroid Build Coastguard Worker   // The package of the app running in this process.
1474*795d594fSAndroid Build Coastguard Worker   std::string process_package_name_;
1475*795d594fSAndroid Build Coastguard Worker 
1476*795d594fSAndroid Build Coastguard Worker   // The data directory of the app running in this process.
1477*795d594fSAndroid Build Coastguard Worker   std::string process_data_directory_;
1478*795d594fSAndroid Build Coastguard Worker 
1479*795d594fSAndroid Build Coastguard Worker   // Whether threads should dump their native stack on SIGQUIT.
1480*795d594fSAndroid Build Coastguard Worker   bool dump_native_stack_on_sig_quit_;
1481*795d594fSAndroid Build Coastguard Worker 
1482*795d594fSAndroid Build Coastguard Worker   // Whether or not we currently care about pause times.
1483*795d594fSAndroid Build Coastguard Worker   ProcessState process_state_;
1484*795d594fSAndroid Build Coastguard Worker 
1485*795d594fSAndroid Build Coastguard Worker   // Whether zygote code is in a section that should not start threads.
1486*795d594fSAndroid Build Coastguard Worker   bool zygote_no_threads_;
1487*795d594fSAndroid Build Coastguard Worker 
1488*795d594fSAndroid Build Coastguard Worker   // The string containing requested jdwp options
1489*795d594fSAndroid Build Coastguard Worker   std::string jdwp_options_;
1490*795d594fSAndroid Build Coastguard Worker 
1491*795d594fSAndroid Build Coastguard Worker   // The jdwp provider we were configured with.
1492*795d594fSAndroid Build Coastguard Worker   JdwpProvider jdwp_provider_;
1493*795d594fSAndroid Build Coastguard Worker 
1494*795d594fSAndroid Build Coastguard Worker   // True if jmethodID and jfieldID are opaque Indices. When false (the default) these are simply
1495*795d594fSAndroid Build Coastguard Worker   // pointers. This is set by -Xopaque-jni-ids:{true,false}.
1496*795d594fSAndroid Build Coastguard Worker   JniIdType jni_ids_indirection_;
1497*795d594fSAndroid Build Coastguard Worker 
1498*795d594fSAndroid Build Coastguard Worker   // Set to false in cases where we want to directly control when jni-id
1499*795d594fSAndroid Build Coastguard Worker   // indirection is changed. This is intended only for testing JNI id swapping.
1500*795d594fSAndroid Build Coastguard Worker   bool automatically_set_jni_ids_indirection_;
1501*795d594fSAndroid Build Coastguard Worker 
1502*795d594fSAndroid Build Coastguard Worker   // True if files in /data/misc/apexdata/com.android.art are considered untrustworthy.
1503*795d594fSAndroid Build Coastguard Worker   bool deny_art_apex_data_files_;
1504*795d594fSAndroid Build Coastguard Worker 
1505*795d594fSAndroid Build Coastguard Worker   // Whether to allow compiling the boot classpath in memory when the given boot image is unusable.
1506*795d594fSAndroid Build Coastguard Worker   bool allow_in_memory_compilation_ = false;
1507*795d594fSAndroid Build Coastguard Worker 
1508*795d594fSAndroid Build Coastguard Worker   // Saved environment.
1509*795d594fSAndroid Build Coastguard Worker   class EnvSnapshot {
1510*795d594fSAndroid Build Coastguard Worker    public:
1511*795d594fSAndroid Build Coastguard Worker     EnvSnapshot() = default;
1512*795d594fSAndroid Build Coastguard Worker     void TakeSnapshot();
1513*795d594fSAndroid Build Coastguard Worker     char** GetSnapshot() const;
1514*795d594fSAndroid Build Coastguard Worker 
1515*795d594fSAndroid Build Coastguard Worker    private:
1516*795d594fSAndroid Build Coastguard Worker     std::unique_ptr<char*[]> c_env_vector_;
1517*795d594fSAndroid Build Coastguard Worker     std::vector<std::unique_ptr<std::string>> name_value_pairs_;
1518*795d594fSAndroid Build Coastguard Worker 
1519*795d594fSAndroid Build Coastguard Worker     DISALLOW_COPY_AND_ASSIGN(EnvSnapshot);
1520*795d594fSAndroid Build Coastguard Worker   } env_snapshot_;
1521*795d594fSAndroid Build Coastguard Worker 
1522*795d594fSAndroid Build Coastguard Worker   // Generic system-weak holders.
1523*795d594fSAndroid Build Coastguard Worker   std::vector<gc::AbstractSystemWeakHolder*> system_weak_holders_;
1524*795d594fSAndroid Build Coastguard Worker 
1525*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<RuntimeCallbacks> callbacks_;
1526*795d594fSAndroid Build Coastguard Worker 
1527*795d594fSAndroid Build Coastguard Worker   std::atomic<uint32_t> deoptimization_counts_[
1528*795d594fSAndroid Build Coastguard Worker       static_cast<uint32_t>(DeoptimizationKind::kLast) + 1];
1529*795d594fSAndroid Build Coastguard Worker 
1530*795d594fSAndroid Build Coastguard Worker   MemMap protected_fault_page_;
1531*795d594fSAndroid Build Coastguard Worker 
1532*795d594fSAndroid Build Coastguard Worker   uint32_t verifier_logging_threshold_ms_;
1533*795d594fSAndroid Build Coastguard Worker 
1534*795d594fSAndroid Build Coastguard Worker   bool load_app_image_startup_cache_ = false;
1535*795d594fSAndroid Build Coastguard Worker 
1536*795d594fSAndroid Build Coastguard Worker   // If startup has completed, must happen at most once.
1537*795d594fSAndroid Build Coastguard Worker   std::atomic<bool> startup_completed_ = false;
1538*795d594fSAndroid Build Coastguard Worker 
1539*795d594fSAndroid Build Coastguard Worker   bool verifier_missing_kthrow_fatal_;
1540*795d594fSAndroid Build Coastguard Worker   bool force_java_zygote_fork_loop_;
1541*795d594fSAndroid Build Coastguard Worker   bool perfetto_hprof_enabled_;
1542*795d594fSAndroid Build Coastguard Worker   bool perfetto_javaheapprof_enabled_;
1543*795d594fSAndroid Build Coastguard Worker 
1544*795d594fSAndroid Build Coastguard Worker   // Called on out of memory error
1545*795d594fSAndroid Build Coastguard Worker   void (*out_of_memory_error_hook_)();
1546*795d594fSAndroid Build Coastguard Worker 
1547*795d594fSAndroid Build Coastguard Worker   metrics::ArtMetrics metrics_;
1548*795d594fSAndroid Build Coastguard Worker   std::unique_ptr<metrics::MetricsReporter> metrics_reporter_;
1549*795d594fSAndroid Build Coastguard Worker 
1550*795d594fSAndroid Build Coastguard Worker   // Apex versions of boot classpath jars concatenated in a string. The format
1551*795d594fSAndroid Build Coastguard Worker   // is of the type:
1552*795d594fSAndroid Build Coastguard Worker   // '/apex1_version/apex2_version//'
1553*795d594fSAndroid Build Coastguard Worker   //
1554*795d594fSAndroid Build Coastguard Worker   // When the apex is the factory version, we don't encode it (for example in
1555*795d594fSAndroid Build Coastguard Worker   // the third entry in the example above).
1556*795d594fSAndroid Build Coastguard Worker   std::string apex_versions_;
1557*795d594fSAndroid Build Coastguard Worker 
1558*795d594fSAndroid Build Coastguard Worker   // The info about the application code paths.
1559*795d594fSAndroid Build Coastguard Worker   AppInfo app_info_;
1560*795d594fSAndroid Build Coastguard Worker 
1561*795d594fSAndroid Build Coastguard Worker   // Note: See comments on GetFaultMessage.
1562*795d594fSAndroid Build Coastguard Worker   friend std::string GetFaultMessageForAbortLogging();
1563*795d594fSAndroid Build Coastguard Worker   friend class Dex2oatImageTest;
1564*795d594fSAndroid Build Coastguard Worker   friend class ScopedThreadPoolUsage;
1565*795d594fSAndroid Build Coastguard Worker   friend class OatFileAssistantTest;
1566*795d594fSAndroid Build Coastguard Worker   class SetupLinearAllocForZygoteFork;
1567*795d594fSAndroid Build Coastguard Worker 
1568*795d594fSAndroid Build Coastguard Worker   DISALLOW_COPY_AND_ASSIGN(Runtime);
1569*795d594fSAndroid Build Coastguard Worker };
1570*795d594fSAndroid Build Coastguard Worker 
GetMetrics()1571*795d594fSAndroid Build Coastguard Worker inline metrics::ArtMetrics* GetMetrics() { return Runtime::Current()->GetMetrics(); }
1572*795d594fSAndroid Build Coastguard Worker 
1573*795d594fSAndroid Build Coastguard Worker }  // namespace art
1574*795d594fSAndroid Build Coastguard Worker 
1575*795d594fSAndroid Build Coastguard Worker #endif  // ART_RUNTIME_RUNTIME_H_
1576