2 * Copyright (C) 2011 The Android Open Source Project
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 #ifndef ART_RUNTIME_RUNTIME_H_
18 #define ART_RUNTIME_RUNTIME_H_
29 #include "arch/instruction_set.h"
30 #include "base/macros.h"
31 #include "experimental_flags.h"
33 #include "instrumentation.h"
34 #include "jobject_comparator.h"
35 #include "method_reference.h"
36 #include "object_callbacks.h"
38 #include "process_state.h"
39 #include "profiler_options.h"
40 #include "quick/quick_method_frame_info.h"
41 #include "runtime_stats.h"
49 class GarbageCollector;
50 } // namespace collector
65 template<class T> class ObjectArray;
66 template<class T> class PrimitiveArray;
67 typedef PrimitiveArray<int8_t> ByteArray;
73 enum class VerifyMode : int8_t;
74 } // namespace verifier
79 class CompilerCallbacks;
86 class NullPointerHandler;
88 struct RuntimeArgumentMap;
90 class StackOverflowHandler;
91 class SuspensionHandler;
97 typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions;
99 // Not all combinations of flags are valid. You may not visit all roots as well as the new roots
100 // (no logical reason to do this). You also may not start logging new roots and stop logging new
101 // roots (also no logical reason to do this).
102 enum VisitRootFlags : uint8_t {
103 kVisitRootFlagAllRoots = 0x1,
104 kVisitRootFlagNewRoots = 0x2,
105 kVisitRootFlagStartLoggingNewRoots = 0x4,
106 kVisitRootFlagStopLoggingNewRoots = 0x8,
107 kVisitRootFlagClearRootLog = 0x10,
108 // Non moving means we can have optimizations where we don't visit some roots if they are
109 // definitely reachable from another location. E.g. ArtMethod and ArtField roots.
110 kVisitRootFlagNonMoving = 0x20,
115 // Parse raw runtime options.
116 static bool ParseOptions(const RuntimeOptions& raw_options,
117 bool ignore_unrecognized,
118 RuntimeArgumentMap* runtime_options);
120 // Creates and initializes a new runtime.
121 static bool Create(RuntimeArgumentMap&& runtime_options)
122 SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
124 // Creates and initializes a new runtime.
125 static bool Create(const RuntimeOptions& raw_options, bool ignore_unrecognized)
126 SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
128 // IsAotCompiler for compilers that don't have a running runtime. Only dex2oat currently.
129 bool IsAotCompiler() const {
130 return !UseJitCompilation() && IsCompiler();
133 // IsCompiler is any runtime which has a running compiler, either dex2oat or JIT.
134 bool IsCompiler() const {
135 return compiler_callbacks_ != nullptr;
138 // If a compiler, are we compiling a boot image?
139 bool IsCompilingBootImage() const;
141 bool CanRelocate() const;
143 bool ShouldRelocate() const {
144 return must_relocate_ && CanRelocate();
147 bool MustRelocateIfPossible() const {
148 return must_relocate_;
151 bool IsDex2OatEnabled() const {
152 return dex2oat_enabled_ && IsImageDex2OatEnabled();
155 bool IsImageDex2OatEnabled() const {
156 return image_dex2oat_enabled_;
159 CompilerCallbacks* GetCompilerCallbacks() {
160 return compiler_callbacks_;
163 void SetCompilerCallbacks(CompilerCallbacks* callbacks) {
164 CHECK(callbacks != nullptr);
165 compiler_callbacks_ = callbacks;
168 bool IsZygote() const {
172 bool IsExplicitGcDisabled() const {
173 return is_explicit_gc_disabled_;
176 std::string GetCompilerExecutable() const;
177 std::string GetPatchoatExecutable() const;
179 const std::vector<std::string>& GetCompilerOptions() const {
180 return compiler_options_;
183 void AddCompilerOption(std::string option) {
184 compiler_options_.push_back(option);
187 const std::vector<std::string>& GetImageCompilerOptions() const {
188 return image_compiler_options_;
191 const std::string& GetImageLocation() const {
192 return image_location_;
195 const ProfilerOptions& GetProfilerOptions() const {
196 return profiler_options_;
199 // Starts a runtime, which may cause threads to be started and code to run.
200 bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_);
202 bool IsShuttingDown(Thread* self);
203 bool IsShuttingDownLocked() const REQUIRES(Locks::runtime_shutdown_lock_) {
204 return shutting_down_;
207 size_t NumberOfThreadsBeingBorn() const REQUIRES(Locks::runtime_shutdown_lock_) {
208 return threads_being_born_;
211 void StartThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_) {
212 threads_being_born_++;
215 void EndThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_);
217 bool IsStarted() const {
221 bool IsFinishedStarting() const {
222 return finished_starting_;
225 static Runtime* Current() {
229 // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most
230 // callers should prefer.
231 NO_RETURN static void Abort() REQUIRES(!Locks::abort_lock_);
233 // Returns the "main" ThreadGroup, used when attaching user threads.
234 jobject GetMainThreadGroup() const;
236 // Returns the "system" ThreadGroup, used when attaching our internal threads.
237 jobject GetSystemThreadGroup() const;
239 // Returns the system ClassLoader which represents the CLASSPATH.
240 jobject GetSystemClassLoader() const;
242 // Attaches the calling native thread to the runtime.
243 bool AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group,
246 void CallExitHook(jint status);
248 // Detaches the current native thread from the runtime.
249 void DetachCurrentThread() REQUIRES(!Locks::mutator_lock_);
251 void DumpForSigQuit(std::ostream& os);
252 void DumpLockHolders(std::ostream& os);
256 const std::string& GetBootClassPathString() const {
257 return boot_class_path_string_;
260 const std::string& GetClassPathString() const {
261 return class_path_string_;
264 ClassLinker* GetClassLinker() const {
265 return class_linker_;
268 size_t GetDefaultStackSize() const {
269 return default_stack_size_;
272 gc::Heap* GetHeap() const {
276 InternTable* GetInternTable() const {
277 DCHECK(intern_table_ != nullptr);
278 return intern_table_;
281 JavaVMExt* GetJavaVM() const {
285 size_t GetMaxSpinsBeforeThinkLockInflation() const {
286 return max_spins_before_thin_lock_inflation_;
289 MonitorList* GetMonitorList() const {
290 return monitor_list_;
293 MonitorPool* GetMonitorPool() const {
294 return monitor_pool_;
297 // Is the given object the special object used to mark a cleared JNI weak global?
298 bool IsClearedJniWeakGlobal(mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_);
300 // Get the special object used to mark a cleared JNI weak global.
301 mirror::Object* GetClearedJniWeakGlobal() SHARED_REQUIRES(Locks::mutator_lock_);
303 mirror::Throwable* GetPreAllocatedOutOfMemoryError() SHARED_REQUIRES(Locks::mutator_lock_);
305 mirror::Throwable* GetPreAllocatedNoClassDefFoundError()
306 SHARED_REQUIRES(Locks::mutator_lock_);
308 const std::vector<std::string>& GetProperties() const {
312 ThreadList* GetThreadList() const {
316 static const char* GetVersion() {
320 void DisallowNewSystemWeaks() SHARED_REQUIRES(Locks::mutator_lock_);
321 void AllowNewSystemWeaks() SHARED_REQUIRES(Locks::mutator_lock_);
322 void BroadcastForNewSystemWeaks() SHARED_REQUIRES(Locks::mutator_lock_);
324 // Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If
325 // clean_dirty is true then dirty roots will be marked as non-dirty after visiting.
326 void VisitRoots(RootVisitor* visitor, VisitRootFlags flags = kVisitRootFlagAllRoots)
327 SHARED_REQUIRES(Locks::mutator_lock_);
329 // Visit image roots, only used for hprof since the GC uses the image space mod union table
331 void VisitImageRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_);
333 // Visit all of the roots we can do safely do concurrently.
334 void VisitConcurrentRoots(RootVisitor* visitor,
335 VisitRootFlags flags = kVisitRootFlagAllRoots)
336 SHARED_REQUIRES(Locks::mutator_lock_);
338 // Visit all of the non thread roots, we can do this with mutators unpaused.
339 void VisitNonThreadRoots(RootVisitor* visitor)
340 SHARED_REQUIRES(Locks::mutator_lock_);
342 void VisitTransactionRoots(RootVisitor* visitor)
343 SHARED_REQUIRES(Locks::mutator_lock_);
345 // Visit all of the thread roots.
346 void VisitThreadRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_);
348 // Flip thread roots from from-space refs to to-space refs.
349 size_t FlipThreadRoots(Closure* thread_flip_visitor, Closure* flip_callback,
350 gc::collector::GarbageCollector* collector)
351 REQUIRES(!Locks::mutator_lock_);
353 // Visit all other roots which must be done with mutators suspended.
354 void VisitNonConcurrentRoots(RootVisitor* visitor)
355 SHARED_REQUIRES(Locks::mutator_lock_);
357 // Sweep system weaks, the system weak is deleted if the visitor return null. Otherwise, the
358 // system weak is updated to be the visitor's returned value.
359 void SweepSystemWeaks(IsMarkedVisitor* visitor)
360 SHARED_REQUIRES(Locks::mutator_lock_);
362 // Constant roots are the roots which never change after the runtime is initialized, they only
363 // need to be visited once per GC cycle.
364 void VisitConstantRoots(RootVisitor* visitor)
365 SHARED_REQUIRES(Locks::mutator_lock_);
367 // Returns a special method that calls into a trampoline for runtime method resolution
368 ArtMethod* GetResolutionMethod();
370 bool HasResolutionMethod() const {
371 return resolution_method_ != nullptr;
374 void SetResolutionMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_);
376 ArtMethod* CreateResolutionMethod() SHARED_REQUIRES(Locks::mutator_lock_);
378 // Returns a special method that calls into a trampoline for runtime imt conflicts.
379 ArtMethod* GetImtConflictMethod();
380 ArtMethod* GetImtUnimplementedMethod();
382 bool HasImtConflictMethod() const {
383 return imt_conflict_method_ != nullptr;
386 void FixupConflictTables();
387 void SetImtConflictMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_);
388 void SetImtUnimplementedMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_);
390 ArtMethod* CreateImtConflictMethod(LinearAlloc* linear_alloc)
391 SHARED_REQUIRES(Locks::mutator_lock_);
393 // Returns a special method that describes all callee saves being spilled to the stack.
394 enum CalleeSaveType {
398 kLastCalleeSaveType // Value used for iteration
401 bool HasCalleeSaveMethod(CalleeSaveType type) const {
402 return callee_save_methods_[type] != 0u;
405 ArtMethod* GetCalleeSaveMethod(CalleeSaveType type)
406 SHARED_REQUIRES(Locks::mutator_lock_);
408 ArtMethod* GetCalleeSaveMethodUnchecked(CalleeSaveType type)
409 SHARED_REQUIRES(Locks::mutator_lock_);
411 QuickMethodFrameInfo GetCalleeSaveMethodFrameInfo(CalleeSaveType type) const {
412 return callee_save_method_frame_infos_[type];
415 QuickMethodFrameInfo GetRuntimeMethodFrameInfo(ArtMethod* method)
416 SHARED_REQUIRES(Locks::mutator_lock_);
418 static size_t GetCalleeSaveMethodOffset(CalleeSaveType type) {
419 return OFFSETOF_MEMBER(Runtime, callee_save_methods_[type]);
422 InstructionSet GetInstructionSet() const {
423 return instruction_set_;
426 void SetInstructionSet(InstructionSet instruction_set);
428 void SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type);
430 ArtMethod* CreateCalleeSaveMethod() SHARED_REQUIRES(Locks::mutator_lock_);
432 int32_t GetStat(int kind);
434 RuntimeStats* GetStats() {
438 bool HasStatsEnabled() const {
439 return stats_enabled_;
442 void ResetStats(int kinds);
444 void SetStatsEnabled(bool new_state)
445 REQUIRES(!Locks::instrument_entrypoints_lock_, !Locks::mutator_lock_);
447 enum class NativeBridgeAction { // private
456 // Returns true if JIT compilations are enabled. GetJit() will be not null in this case.
457 bool UseJitCompilation() const;
458 // Returns true if profile saving is enabled. GetJit() will be not null in this case.
459 bool SaveProfileInfo() const;
461 void PreZygoteFork();
463 void InitNonZygoteOrPostFork(
464 JNIEnv* env, bool is_system_server, NativeBridgeAction action, const char* isa);
466 const instrumentation::Instrumentation* GetInstrumentation() const {
467 return &instrumentation_;
470 instrumentation::Instrumentation* GetInstrumentation() {
471 return &instrumentation_;
474 void RegisterAppInfo(const std::vector<std::string>& code_paths,
475 const std::string& profile_output_filename,
476 const std::string& foreign_dex_profile_path,
477 const std::string& app_dir);
478 void NotifyDexLoaded(const std::string& dex_location);
480 // Transaction support.
481 bool IsActiveTransaction() const {
482 return preinitialization_transaction_ != nullptr;
484 void EnterTransactionMode(Transaction* transaction);
485 void ExitTransactionMode();
486 bool IsTransactionAborted() const;
488 void AbortTransactionAndThrowAbortError(Thread* self, const std::string& abort_message)
489 SHARED_REQUIRES(Locks::mutator_lock_);
490 void ThrowTransactionAbortError(Thread* self)
491 SHARED_REQUIRES(Locks::mutator_lock_);
493 void RecordWriteFieldBoolean(mirror::Object* obj, MemberOffset field_offset, uint8_t value,
494 bool is_volatile) const;
495 void RecordWriteFieldByte(mirror::Object* obj, MemberOffset field_offset, int8_t value,
496 bool is_volatile) const;
497 void RecordWriteFieldChar(mirror::Object* obj, MemberOffset field_offset, uint16_t value,
498 bool is_volatile) const;
499 void RecordWriteFieldShort(mirror::Object* obj, MemberOffset field_offset, int16_t value,
500 bool is_volatile) const;
501 void RecordWriteField32(mirror::Object* obj, MemberOffset field_offset, uint32_t value,
502 bool is_volatile) const;
503 void RecordWriteField64(mirror::Object* obj, MemberOffset field_offset, uint64_t value,
504 bool is_volatile) const;
505 void RecordWriteFieldReference(mirror::Object* obj, MemberOffset field_offset,
506 mirror::Object* value, bool is_volatile) const;
507 void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const
508 SHARED_REQUIRES(Locks::mutator_lock_);
509 void RecordStrongStringInsertion(mirror::String* s) const
510 REQUIRES(Locks::intern_table_lock_);
511 void RecordWeakStringInsertion(mirror::String* s) const
512 REQUIRES(Locks::intern_table_lock_);
513 void RecordStrongStringRemoval(mirror::String* s) const
514 REQUIRES(Locks::intern_table_lock_);
515 void RecordWeakStringRemoval(mirror::String* s) const
516 REQUIRES(Locks::intern_table_lock_);
518 void SetFaultMessage(const std::string& message) REQUIRES(!fault_message_lock_);
519 // Only read by the signal handler, NO_THREAD_SAFETY_ANALYSIS to prevent lock order violations
520 // with the unexpected_signal_lock_.
521 const std::string& GetFaultMessage() NO_THREAD_SAFETY_ANALYSIS {
522 return fault_message_;
525 void AddCurrentRuntimeFeaturesAsDex2OatArguments(std::vector<std::string>* arg_vector) const;
527 bool ExplicitStackOverflowChecks() const {
528 return !implicit_so_checks_;
531 bool IsVerificationEnabled() const;
532 bool IsVerificationSoftFail() const;
534 bool IsDexFileFallbackEnabled() const {
535 return allow_dex_file_fallback_;
538 const std::vector<std::string>& GetCpuAbilist() const {
542 bool IsRunningOnMemoryTool() const {
543 return is_running_on_memory_tool_;
546 void SetTargetSdkVersion(int32_t version) {
547 target_sdk_version_ = version;
550 int32_t GetTargetSdkVersion() const {
551 return target_sdk_version_;
554 uint32_t GetZygoteMaxFailedBoots() const {
555 return zygote_max_failed_boots_;
558 bool AreExperimentalFlagsEnabled(ExperimentalFlags flags) {
559 return (experimental_flags_ & flags) != ExperimentalFlags::kNone;
562 lambda::BoxTable* GetLambdaBoxTable() const {
563 return lambda_box_table_.get();
566 // Create the JIT and instrumentation and code cache.
569 ArenaPool* GetArenaPool() {
570 return arena_pool_.get();
572 ArenaPool* GetJitArenaPool() {
573 return jit_arena_pool_.get();
575 const ArenaPool* GetArenaPool() const {
576 return arena_pool_.get();
579 void ReclaimArenaPoolMemory();
581 LinearAlloc* GetLinearAlloc() {
582 return linear_alloc_.get();
585 jit::JitOptions* GetJITOptions() {
586 return jit_options_.get();
589 bool IsDebuggable() const;
591 bool IsNativeDebuggable() const {
592 return is_native_debuggable_;
595 void SetNativeDebuggable(bool value) {
596 is_native_debuggable_ = value;
599 // Returns the build fingerprint, if set. Otherwise an empty string is returned.
600 std::string GetFingerprint() {
604 // Called from class linker.
605 void SetSentinel(mirror::Object* sentinel) SHARED_REQUIRES(Locks::mutator_lock_);
607 // Create a normal LinearAlloc or low 4gb version if we are 64 bit AOT compiler.
608 LinearAlloc* CreateLinearAlloc();
610 OatFileManager& GetOatFileManager() const {
611 DCHECK(oat_file_manager_ != nullptr);
612 return *oat_file_manager_;
615 double GetHashTableMinLoadFactor() const;
616 double GetHashTableMaxLoadFactor() const;
618 void SetSafeMode(bool mode) {
622 bool GetDumpNativeStackOnSigQuit() const {
623 return dump_native_stack_on_sig_quit_;
626 bool GetPrunedDalvikCache() const {
627 return pruned_dalvik_cache_;
630 void SetPrunedDalvikCache(bool pruned) {
631 pruned_dalvik_cache_ = pruned;
634 void UpdateProcessState(ProcessState process_state);
636 // Returns true if we currently care about long mutator pause.
637 bool InJankPerceptibleProcessState() const {
638 return process_state_ == kProcessStateJankPerceptible;
641 void RegisterSensitiveThread() const;
643 void SetZygoteNoThreadSection(bool val) {
644 zygote_no_threads_ = val;
647 bool IsZygoteNoThreadSection() const {
648 return zygote_no_threads_;
651 // Returns if the code can be deoptimized. Code may be compiled with some
652 // optimization that makes it impossible to deoptimize.
653 bool IsDeoptimizeable(uintptr_t code) const SHARED_REQUIRES(Locks::mutator_lock_);
655 // Returns a saved copy of the environment (getenv/setenv values).
656 // Used by Fork to protect against overwriting LD_LIBRARY_PATH, etc.
657 char** GetEnvSnapshot() const {
658 return env_snapshot_.GetSnapshot();
662 static void InitPlatformSignalHandlers();
668 bool Init(RuntimeArgumentMap&& runtime_options)
669 SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_);
670 void InitNativeMethods() REQUIRES(!Locks::mutator_lock_);
671 void InitThreadGroups(Thread* self);
672 void RegisterRuntimeNativeMethods(JNIEnv* env);
674 void StartDaemonThreads();
675 void StartSignalCatcher();
677 void MaybeSaveJitProfilingInfo();
679 // A pointer to the active runtime or null.
680 static Runtime* instance_;
682 // NOTE: these must match the gc::ProcessState values as they come directly from the framework.
683 static constexpr int kProfileForground = 0;
684 static constexpr int kProfileBackground = 1;
686 // 64 bit so that we can share the same asm offsets for both 32 and 64 bits.
687 uint64_t callee_save_methods_[kLastCalleeSaveType];
688 GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_;
689 GcRoot<mirror::Throwable> pre_allocated_NoClassDefFoundError_;
690 ArtMethod* resolution_method_;
691 ArtMethod* imt_conflict_method_;
692 // Unresolved method has the same behavior as the conflict method, it is used by the class linker
693 // for differentiating between unfilled imt slots vs conflict slots in superclasses.
694 ArtMethod* imt_unimplemented_method_;
696 // Special sentinel object used to invalid conditions in JNI (cleared weak references) and
697 // JDWP (invalid references).
698 GcRoot<mirror::Object> sentinel_;
700 InstructionSet instruction_set_;
701 QuickMethodFrameInfo callee_save_method_frame_infos_[kLastCalleeSaveType];
703 CompilerCallbacks* compiler_callbacks_;
706 bool is_concurrent_gc_enabled_;
707 bool is_explicit_gc_disabled_;
708 bool dex2oat_enabled_;
709 bool image_dex2oat_enabled_;
711 std::string compiler_executable_;
712 std::string patchoat_executable_;
713 std::vector<std::string> compiler_options_;
714 std::vector<std::string> image_compiler_options_;
715 std::string image_location_;
717 std::string boot_class_path_string_;
718 std::string class_path_string_;
719 std::vector<std::string> properties_;
721 // The default stack size for managed threads created by the runtime.
722 size_t default_stack_size_;
726 std::unique_ptr<ArenaPool> jit_arena_pool_;
727 std::unique_ptr<ArenaPool> arena_pool_;
728 // Special low 4gb pool for compiler linear alloc. We need ArtFields to be in low 4gb if we are
729 // compiling using a 32 bit image on a 64 bit compiler in case we resolve things in the image
730 // since the field arrays are int arrays in this case.
731 std::unique_ptr<ArenaPool> low_4gb_arena_pool_;
733 // Shared linear alloc for now.
734 std::unique_ptr<LinearAlloc> linear_alloc_;
736 // The number of spins that are done before thread suspension is used to forcibly inflate.
737 size_t max_spins_before_thin_lock_inflation_;
738 MonitorList* monitor_list_;
739 MonitorPool* monitor_pool_;
741 ThreadList* thread_list_;
743 InternTable* intern_table_;
745 ClassLinker* class_linker_;
747 SignalCatcher* signal_catcher_;
748 std::string stack_trace_file_;
752 std::unique_ptr<jit::Jit> jit_;
753 std::unique_ptr<jit::JitOptions> jit_options_;
755 std::unique_ptr<lambda::BoxTable> lambda_box_table_;
757 // Fault message, printed when we get a SIGSEGV.
758 Mutex fault_message_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
759 std::string fault_message_ GUARDED_BY(fault_message_lock_);
761 // A non-zero value indicates that a thread has been created but not yet initialized. Guarded by
762 // the shutdown lock so that threads aren't born while we're shutting down.
763 size_t threads_being_born_ GUARDED_BY(Locks::runtime_shutdown_lock_);
765 // Waited upon until no threads are being born.
766 std::unique_ptr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_);
768 // Set when runtime shutdown is past the point that new threads may attach.
769 bool shutting_down_ GUARDED_BY(Locks::runtime_shutdown_lock_);
771 // The runtime is starting to shutdown but is blocked waiting on shutdown_cond_.
772 bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_);
776 // New flag added which tells us if the runtime has finished starting. If
777 // this flag is set then the Daemon threads are created and the class loader
778 // is created. This flag is needed for knowing if its safe to request CMS.
779 bool finished_starting_;
781 // Hooks supported by JNI_CreateJavaVM
782 jint (*vfprintf_)(FILE* stream, const char* format, va_list ap);
783 void (*exit_)(jint status);
789 const bool is_running_on_memory_tool_;
791 std::string profile_output_filename_;
792 ProfilerOptions profiler_options_;
794 std::unique_ptr<TraceConfig> trace_config_;
796 instrumentation::Instrumentation instrumentation_;
798 jobject main_thread_group_;
799 jobject system_thread_group_;
801 // As returned by ClassLoader.getSystemClassLoader().
802 jobject system_class_loader_;
804 // If true, then we dump the GC cumulative timings on shutdown.
805 bool dump_gc_performance_on_shutdown_;
807 // Transaction used for pre-initializing classes at compilation time.
808 Transaction* preinitialization_transaction_;
810 // If kNone, verification is disabled. kEnable by default.
811 verifier::VerifyMode verify_;
813 // If true, the runtime may use dex files directly with the interpreter if an oat file is not
815 bool allow_dex_file_fallback_;
817 // List of supported cpu abis.
818 std::vector<std::string> cpu_abilist_;
820 // Specifies target SDK version to allow workarounds for certain API levels.
821 int32_t target_sdk_version_;
823 // Implicit checks flags.
824 bool implicit_null_checks_; // NullPointer checks are implicit.
825 bool implicit_so_checks_; // StackOverflow checks are implicit.
826 bool implicit_suspend_checks_; // Thread suspension checks are implicit.
828 // Whether or not the sig chain (and implicitly the fault handler) should be
829 // disabled. Tools like dex2oat or patchoat don't need them. This enables
830 // building a statically link version of dex2oat.
833 // Force the use of native bridge even if the app ISA matches the runtime ISA.
834 bool force_native_bridge_;
836 // Whether or not a native bridge has been loaded.
838 // The native bridge allows running native code compiled for a foreign ISA. The way it works is,
839 // if standard dlopen fails to load native library associated with native activity, it calls to
840 // the native bridge to load it and then gets the trampoline for the entry to native activity.
842 // The option 'native_bridge_library_filename' specifies the name of the native bridge.
843 // When non-empty the native bridge will be loaded from the given file. An empty value means
844 // that there's no native bridge.
845 bool is_native_bridge_loaded_;
847 // Whether we are running under native debugger.
848 bool is_native_debuggable_;
850 // The maximum number of failed boots we allow before pruning the dalvik cache
851 // and trying again. This option is only inspected when we're running as a
853 uint32_t zygote_max_failed_boots_;
855 // Enable experimental opcodes that aren't fully specified yet. The intent is to
856 // eventually publish them as public-usable opcodes, but they aren't ready yet.
858 // Experimental opcodes should not be used by other production code.
859 ExperimentalFlags experimental_flags_;
861 // Contains the build fingerprint, if given as a parameter.
862 std::string fingerprint_;
864 // Oat file manager, keeps track of what oat files are open.
865 OatFileManager* oat_file_manager_;
867 // Whether or not we are on a low RAM device.
868 bool is_low_memory_mode_;
870 // Whether the application should run in safe mode, that is, interpreter only.
873 // Whether threads should dump their native stack on SIGQUIT.
874 bool dump_native_stack_on_sig_quit_;
876 // Whether the dalvik cache was pruned when initializing the runtime.
877 bool pruned_dalvik_cache_;
879 // Whether or not we currently care about pause times.
880 ProcessState process_state_;
882 // Whether zygote code is in a section that should not start threads.
883 bool zygote_no_threads_;
885 // Saved environment.
888 EnvSnapshot() = default;
890 char** GetSnapshot() const;
893 std::unique_ptr<char*[]> c_env_vector_;
894 std::vector<std::unique_ptr<std::string>> name_value_pairs_;
896 DISALLOW_COPY_AND_ASSIGN(EnvSnapshot);
899 DISALLOW_COPY_AND_ASSIGN(Runtime);
901 std::ostream& operator<<(std::ostream& os, const Runtime::CalleeSaveType& rhs);
905 #endif // ART_RUNTIME_RUNTIME_H_