runtime.h revision dd6712578b6aa8a292bc6249295b6d2a7b182717
1/* 2 * Copyright (C) 2011 The Android Open Source Project 3 * 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 7 * 8 * http://www.apache.org/licenses/LICENSE-2.0 9 * 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. 15 */ 16 17#ifndef ART_RUNTIME_RUNTIME_H_ 18#define ART_RUNTIME_RUNTIME_H_ 19 20#include <jni.h> 21#include <stdio.h> 22 23#include <iosfwd> 24#include <set> 25#include <string> 26#include <utility> 27#include <vector> 28 29#include "arch/instruction_set.h" 30#include "base/macros.h" 31#include "gc_root.h" 32#include "instrumentation.h" 33#include "jobject_comparator.h" 34#include "method_reference.h" 35#include "object_callbacks.h" 36#include "offsets.h" 37#include "profiler_options.h" 38#include "quick/quick_method_frame_info.h" 39#include "runtime_stats.h" 40#include "safe_map.h" 41 42namespace art { 43 44namespace gc { 45 class Heap; 46 namespace collector { 47 class GarbageCollector; 48 } // namespace collector 49} // namespace gc 50 51namespace jit { 52 class Jit; 53 class JitOptions; 54} // namespace jit 55 56namespace lambda { 57 class BoxTable; 58} // namespace lambda 59 60namespace mirror { 61 class ClassLoader; 62 class Array; 63 template<class T> class ObjectArray; 64 template<class T> class PrimitiveArray; 65 typedef PrimitiveArray<int8_t> ByteArray; 66 class String; 67 class Throwable; 68} // namespace mirror 69namespace verifier { 70 class MethodVerifier; 71 enum class VerifyMode : int8_t; 72} // namespace verifier 73class ArenaPool; 74class ArtMethod; 75class ClassLinker; 76class Closure; 77class CompilerCallbacks; 78class DexFile; 79class InternTable; 80class JavaVMExt; 81class LinearAlloc; 82class MonitorList; 83class MonitorPool; 84class NullPointerHandler; 85class SignalCatcher; 86class StackOverflowHandler; 87class SuspensionHandler; 88class ThreadList; 89class Trace; 90struct TraceConfig; 91class Transaction; 92 93typedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; 94typedef SafeMap<MethodReference, SafeMap<uint32_t, std::set<uint32_t>>, 95 MethodReferenceComparator> MethodRefToStringInitRegMap; 96 97// Not all combinations of flags are valid. You may not visit all roots as well as the new roots 98// (no logical reason to do this). You also may not start logging new roots and stop logging new 99// roots (also no logical reason to do this). 100enum VisitRootFlags : uint8_t { 101 kVisitRootFlagAllRoots = 0x1, 102 kVisitRootFlagNewRoots = 0x2, 103 kVisitRootFlagStartLoggingNewRoots = 0x4, 104 kVisitRootFlagStopLoggingNewRoots = 0x8, 105 kVisitRootFlagClearRootLog = 0x10, 106 // Non moving means we can have optimizations where we don't visit some roots if they are 107 // definitely reachable from another location. E.g. ArtMethod and ArtField roots. 108 kVisitRootFlagNonMoving = 0x20, 109}; 110 111class Runtime { 112 public: 113 // Creates and initializes a new runtime. 114 static bool Create(const RuntimeOptions& options, bool ignore_unrecognized) 115 SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_); 116 117 // IsAotCompiler for compilers that don't have a running runtime. Only dex2oat currently. 118 bool IsAotCompiler() const { 119 return !UseJit() && IsCompiler(); 120 } 121 122 // IsCompiler is any runtime which has a running compiler, either dex2oat or JIT. 123 bool IsCompiler() const { 124 return compiler_callbacks_ != nullptr; 125 } 126 127 // If a compiler, are we compiling a boot image? 128 bool IsCompilingBootImage() const; 129 130 bool CanRelocate() const; 131 132 bool ShouldRelocate() const { 133 return must_relocate_ && CanRelocate(); 134 } 135 136 bool MustRelocateIfPossible() const { 137 return must_relocate_; 138 } 139 140 bool IsDex2OatEnabled() const { 141 return dex2oat_enabled_ && IsImageDex2OatEnabled(); 142 } 143 144 bool IsImageDex2OatEnabled() const { 145 return image_dex2oat_enabled_; 146 } 147 148 CompilerCallbacks* GetCompilerCallbacks() { 149 return compiler_callbacks_; 150 } 151 152 bool IsZygote() const { 153 return is_zygote_; 154 } 155 156 bool IsExplicitGcDisabled() const { 157 return is_explicit_gc_disabled_; 158 } 159 160 std::string GetCompilerExecutable() const; 161 std::string GetPatchoatExecutable() const; 162 163 const std::vector<std::string>& GetCompilerOptions() const { 164 return compiler_options_; 165 } 166 167 void AddCompilerOption(std::string option) { 168 compiler_options_.push_back(option); 169 } 170 171 const std::vector<std::string>& GetImageCompilerOptions() const { 172 return image_compiler_options_; 173 } 174 175 const std::string& GetImageLocation() const { 176 return image_location_; 177 } 178 179 const ProfilerOptions& GetProfilerOptions() const { 180 return profiler_options_; 181 } 182 183 // Starts a runtime, which may cause threads to be started and code to run. 184 bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_); 185 186 bool IsShuttingDown(Thread* self); 187 bool IsShuttingDownLocked() const REQUIRES(Locks::runtime_shutdown_lock_) { 188 return shutting_down_; 189 } 190 191 size_t NumberOfThreadsBeingBorn() const REQUIRES(Locks::runtime_shutdown_lock_) { 192 return threads_being_born_; 193 } 194 195 void StartThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_) { 196 threads_being_born_++; 197 } 198 199 void EndThreadBirth() REQUIRES(Locks::runtime_shutdown_lock_); 200 201 bool IsStarted() const { 202 return started_; 203 } 204 205 bool IsFinishedStarting() const { 206 return finished_starting_; 207 } 208 209 static Runtime* Current() { 210 return instance_; 211 } 212 213 // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most 214 // callers should prefer. 215 NO_RETURN static void Abort() REQUIRES(!Locks::abort_lock_); 216 217 // Returns the "main" ThreadGroup, used when attaching user threads. 218 jobject GetMainThreadGroup() const; 219 220 // Returns the "system" ThreadGroup, used when attaching our internal threads. 221 jobject GetSystemThreadGroup() const; 222 223 // Returns the system ClassLoader which represents the CLASSPATH. 224 jobject GetSystemClassLoader() const; 225 226 // Attaches the calling native thread to the runtime. 227 bool AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group, 228 bool create_peer); 229 230 void CallExitHook(jint status); 231 232 // Detaches the current native thread from the runtime. 233 void DetachCurrentThread() REQUIRES(!Locks::mutator_lock_); 234 235 void DumpForSigQuit(std::ostream& os); 236 void DumpLockHolders(std::ostream& os); 237 238 ~Runtime(); 239 240 const std::string& GetBootClassPathString() const { 241 return boot_class_path_string_; 242 } 243 244 const std::string& GetClassPathString() const { 245 return class_path_string_; 246 } 247 248 ClassLinker* GetClassLinker() const { 249 return class_linker_; 250 } 251 252 size_t GetDefaultStackSize() const { 253 return default_stack_size_; 254 } 255 256 gc::Heap* GetHeap() const { 257 return heap_; 258 } 259 260 InternTable* GetInternTable() const { 261 DCHECK(intern_table_ != nullptr); 262 return intern_table_; 263 } 264 265 JavaVMExt* GetJavaVM() const { 266 return java_vm_; 267 } 268 269 size_t GetMaxSpinsBeforeThinkLockInflation() const { 270 return max_spins_before_thin_lock_inflation_; 271 } 272 273 MonitorList* GetMonitorList() const { 274 return monitor_list_; 275 } 276 277 MonitorPool* GetMonitorPool() const { 278 return monitor_pool_; 279 } 280 281 // Is the given object the special object used to mark a cleared JNI weak global? 282 bool IsClearedJniWeakGlobal(mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_); 283 284 // Get the special object used to mark a cleared JNI weak global. 285 mirror::Object* GetClearedJniWeakGlobal() SHARED_REQUIRES(Locks::mutator_lock_); 286 287 mirror::Throwable* GetPreAllocatedOutOfMemoryError() SHARED_REQUIRES(Locks::mutator_lock_); 288 289 mirror::Throwable* GetPreAllocatedNoClassDefFoundError() 290 SHARED_REQUIRES(Locks::mutator_lock_); 291 292 const std::vector<std::string>& GetProperties() const { 293 return properties_; 294 } 295 296 ThreadList* GetThreadList() const { 297 return thread_list_; 298 } 299 300 static const char* GetVersion() { 301 return "2.1.0"; 302 } 303 304 void DisallowNewSystemWeaks() SHARED_REQUIRES(Locks::mutator_lock_); 305 void AllowNewSystemWeaks() SHARED_REQUIRES(Locks::mutator_lock_); 306 void EnsureNewSystemWeaksDisallowed() SHARED_REQUIRES(Locks::mutator_lock_); 307 void BroadcastForNewSystemWeaks() SHARED_REQUIRES(Locks::mutator_lock_); 308 309 // Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If 310 // clean_dirty is true then dirty roots will be marked as non-dirty after visiting. 311 void VisitRoots(RootVisitor* visitor, VisitRootFlags flags = kVisitRootFlagAllRoots) 312 SHARED_REQUIRES(Locks::mutator_lock_); 313 314 // Visit image roots, only used for hprof since the GC uses the image space mod union table 315 // instead. 316 void VisitImageRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_); 317 318 // Visit all of the roots we can do safely do concurrently. 319 void VisitConcurrentRoots(RootVisitor* visitor, 320 VisitRootFlags flags = kVisitRootFlagAllRoots) 321 SHARED_REQUIRES(Locks::mutator_lock_); 322 323 // Visit all of the non thread roots, we can do this with mutators unpaused. 324 void VisitNonThreadRoots(RootVisitor* visitor) 325 SHARED_REQUIRES(Locks::mutator_lock_); 326 327 void VisitTransactionRoots(RootVisitor* visitor) 328 SHARED_REQUIRES(Locks::mutator_lock_); 329 330 // Visit all of the thread roots. 331 void VisitThreadRoots(RootVisitor* visitor) SHARED_REQUIRES(Locks::mutator_lock_); 332 333 // Flip thread roots from from-space refs to to-space refs. 334 size_t FlipThreadRoots(Closure* thread_flip_visitor, Closure* flip_callback, 335 gc::collector::GarbageCollector* collector) 336 REQUIRES(!Locks::mutator_lock_); 337 338 // Visit all other roots which must be done with mutators suspended. 339 void VisitNonConcurrentRoots(RootVisitor* visitor) 340 SHARED_REQUIRES(Locks::mutator_lock_); 341 342 // Sweep system weaks, the system weak is deleted if the visitor return null. Otherwise, the 343 // system weak is updated to be the visitor's returned value. 344 void SweepSystemWeaks(IsMarkedVisitor* visitor) 345 SHARED_REQUIRES(Locks::mutator_lock_); 346 347 // Constant roots are the roots which never change after the runtime is initialized, they only 348 // need to be visited once per GC cycle. 349 void VisitConstantRoots(RootVisitor* visitor) 350 SHARED_REQUIRES(Locks::mutator_lock_); 351 352 // Returns a special method that calls into a trampoline for runtime method resolution 353 ArtMethod* GetResolutionMethod() SHARED_REQUIRES(Locks::mutator_lock_); 354 355 bool HasResolutionMethod() const { 356 return resolution_method_ != nullptr; 357 } 358 359 void SetResolutionMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_); 360 361 ArtMethod* CreateResolutionMethod() SHARED_REQUIRES(Locks::mutator_lock_); 362 363 // Returns a special method that calls into a trampoline for runtime imt conflicts. 364 ArtMethod* GetImtConflictMethod() SHARED_REQUIRES(Locks::mutator_lock_); 365 ArtMethod* GetImtUnimplementedMethod() SHARED_REQUIRES(Locks::mutator_lock_); 366 367 bool HasImtConflictMethod() const { 368 return imt_conflict_method_ != nullptr; 369 } 370 371 void SetImtConflictMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_); 372 void SetImtUnimplementedMethod(ArtMethod* method) SHARED_REQUIRES(Locks::mutator_lock_); 373 374 ArtMethod* CreateImtConflictMethod() SHARED_REQUIRES(Locks::mutator_lock_); 375 376 // Returns a special method that describes all callee saves being spilled to the stack. 377 enum CalleeSaveType { 378 kSaveAll, 379 kRefsOnly, 380 kRefsAndArgs, 381 kLastCalleeSaveType // Value used for iteration 382 }; 383 384 bool HasCalleeSaveMethod(CalleeSaveType type) const { 385 return callee_save_methods_[type] != 0u; 386 } 387 388 ArtMethod* GetCalleeSaveMethod(CalleeSaveType type) 389 SHARED_REQUIRES(Locks::mutator_lock_); 390 391 ArtMethod* GetCalleeSaveMethodUnchecked(CalleeSaveType type) 392 SHARED_REQUIRES(Locks::mutator_lock_); 393 394 QuickMethodFrameInfo GetCalleeSaveMethodFrameInfo(CalleeSaveType type) const { 395 return callee_save_method_frame_infos_[type]; 396 } 397 398 QuickMethodFrameInfo GetRuntimeMethodFrameInfo(ArtMethod* method) 399 SHARED_REQUIRES(Locks::mutator_lock_); 400 401 static size_t GetCalleeSaveMethodOffset(CalleeSaveType type) { 402 return OFFSETOF_MEMBER(Runtime, callee_save_methods_[type]); 403 } 404 405 InstructionSet GetInstructionSet() const { 406 return instruction_set_; 407 } 408 409 void SetInstructionSet(InstructionSet instruction_set); 410 411 void SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type); 412 413 ArtMethod* CreateCalleeSaveMethod() SHARED_REQUIRES(Locks::mutator_lock_); 414 415 int32_t GetStat(int kind); 416 417 RuntimeStats* GetStats() { 418 return &stats_; 419 } 420 421 bool HasStatsEnabled() const { 422 return stats_enabled_; 423 } 424 425 void ResetStats(int kinds); 426 427 void SetStatsEnabled(bool new_state) 428 REQUIRES(!Locks::instrument_entrypoints_lock_, !Locks::mutator_lock_); 429 430 enum class NativeBridgeAction { // private 431 kUnload, 432 kInitialize 433 }; 434 435 jit::Jit* GetJit() { 436 return jit_.get(); 437 } 438 bool UseJit() const { 439 return jit_.get() != nullptr; 440 } 441 442 void PreZygoteFork(); 443 bool InitZygote(); 444 void DidForkFromZygote(JNIEnv* env, NativeBridgeAction action, const char* isa); 445 446 const instrumentation::Instrumentation* GetInstrumentation() const { 447 return &instrumentation_; 448 } 449 450 instrumentation::Instrumentation* GetInstrumentation() { 451 return &instrumentation_; 452 } 453 454 void StartProfiler(const char* profile_output_filename); 455 void UpdateProfilerState(int state); 456 457 // Transaction support. 458 bool IsActiveTransaction() const { 459 return preinitialization_transaction_ != nullptr; 460 } 461 void EnterTransactionMode(Transaction* transaction); 462 void ExitTransactionMode(); 463 bool IsTransactionAborted() const; 464 465 void AbortTransactionAndThrowAbortError(Thread* self, const std::string& abort_message) 466 SHARED_REQUIRES(Locks::mutator_lock_); 467 void ThrowTransactionAbortError(Thread* self) 468 SHARED_REQUIRES(Locks::mutator_lock_); 469 470 void RecordWriteFieldBoolean(mirror::Object* obj, MemberOffset field_offset, uint8_t value, 471 bool is_volatile) const; 472 void RecordWriteFieldByte(mirror::Object* obj, MemberOffset field_offset, int8_t value, 473 bool is_volatile) const; 474 void RecordWriteFieldChar(mirror::Object* obj, MemberOffset field_offset, uint16_t value, 475 bool is_volatile) const; 476 void RecordWriteFieldShort(mirror::Object* obj, MemberOffset field_offset, int16_t value, 477 bool is_volatile) const; 478 void RecordWriteField32(mirror::Object* obj, MemberOffset field_offset, uint32_t value, 479 bool is_volatile) const; 480 void RecordWriteField64(mirror::Object* obj, MemberOffset field_offset, uint64_t value, 481 bool is_volatile) const; 482 void RecordWriteFieldReference(mirror::Object* obj, MemberOffset field_offset, 483 mirror::Object* value, bool is_volatile) const; 484 void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const 485 SHARED_REQUIRES(Locks::mutator_lock_); 486 void RecordStrongStringInsertion(mirror::String* s) const 487 REQUIRES(Locks::intern_table_lock_); 488 void RecordWeakStringInsertion(mirror::String* s) const 489 REQUIRES(Locks::intern_table_lock_); 490 void RecordStrongStringRemoval(mirror::String* s) const 491 REQUIRES(Locks::intern_table_lock_); 492 void RecordWeakStringRemoval(mirror::String* s) const 493 REQUIRES(Locks::intern_table_lock_); 494 495 void SetFaultMessage(const std::string& message) REQUIRES(!fault_message_lock_); 496 // Only read by the signal handler, NO_THREAD_SAFETY_ANALYSIS to prevent lock order violations 497 // with the unexpected_signal_lock_. 498 const std::string& GetFaultMessage() NO_THREAD_SAFETY_ANALYSIS { 499 return fault_message_; 500 } 501 502 void AddCurrentRuntimeFeaturesAsDex2OatArguments(std::vector<std::string>* arg_vector) const; 503 504 bool ExplicitStackOverflowChecks() const { 505 return !implicit_so_checks_; 506 } 507 508 bool IsVerificationEnabled() const; 509 bool IsVerificationSoftFail() const; 510 511 bool IsDexFileFallbackEnabled() const { 512 return allow_dex_file_fallback_; 513 } 514 515 const std::vector<std::string>& GetCpuAbilist() const { 516 return cpu_abilist_; 517 } 518 519 bool IsRunningOnMemoryTool() const { 520 return is_running_on_memory_tool_; 521 } 522 523 void SetTargetSdkVersion(int32_t version) { 524 target_sdk_version_ = version; 525 } 526 527 int32_t GetTargetSdkVersion() const { 528 return target_sdk_version_; 529 } 530 531 uint32_t GetZygoteMaxFailedBoots() const { 532 return zygote_max_failed_boots_; 533 } 534 535 bool AreExperimentalLambdasEnabled() const { 536 return experimental_lambdas_; 537 } 538 539 lambda::BoxTable* GetLambdaBoxTable() const { 540 return lambda_box_table_.get(); 541 } 542 543 // Create the JIT and instrumentation and code cache. 544 void CreateJit(); 545 546 ArenaPool* GetArenaPool() { 547 return arena_pool_.get(); 548 } 549 const ArenaPool* GetArenaPool() const { 550 return arena_pool_.get(); 551 } 552 LinearAlloc* GetLinearAlloc() { 553 return linear_alloc_.get(); 554 } 555 556 jit::JitOptions* GetJITOptions() { 557 return jit_options_.get(); 558 } 559 560 MethodRefToStringInitRegMap& GetStringInitMap() { 561 return method_ref_string_init_reg_map_; 562 } 563 564 bool IsDebuggable() const; 565 566 // Returns the build fingerprint, if set. Otherwise an empty string is returned. 567 std::string GetFingerprint() { 568 return fingerprint_; 569 } 570 571 private: 572 static void InitPlatformSignalHandlers(); 573 574 Runtime(); 575 576 void BlockSignals(); 577 578 bool Init(const RuntimeOptions& options, bool ignore_unrecognized) 579 SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_); 580 void InitNativeMethods() REQUIRES(!Locks::mutator_lock_); 581 void InitThreadGroups(Thread* self); 582 void RegisterRuntimeNativeMethods(JNIEnv* env); 583 584 void StartDaemonThreads(); 585 void StartSignalCatcher(); 586 587 // A pointer to the active runtime or null. 588 static Runtime* instance_; 589 590 // NOTE: these must match the gc::ProcessState values as they come directly from the framework. 591 static constexpr int kProfileForground = 0; 592 static constexpr int kProfileBackgrouud = 1; 593 594 // 64 bit so that we can share the same asm offsets for both 32 and 64 bits. 595 uint64_t callee_save_methods_[kLastCalleeSaveType]; 596 GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_; 597 GcRoot<mirror::Throwable> pre_allocated_NoClassDefFoundError_; 598 ArtMethod* resolution_method_; 599 ArtMethod* imt_conflict_method_; 600 // Unresolved method has the same behavior as the conflict method, it is used by the class linker 601 // for differentiating between unfilled imt slots vs conflict slots in superclasses. 602 ArtMethod* imt_unimplemented_method_; 603 604 // Special sentinel object used to invalid conditions in JNI (cleared weak references) and 605 // JDWP (invalid references). 606 GcRoot<mirror::Object> sentinel_; 607 608 InstructionSet instruction_set_; 609 QuickMethodFrameInfo callee_save_method_frame_infos_[kLastCalleeSaveType]; 610 611 CompilerCallbacks* compiler_callbacks_; 612 bool is_zygote_; 613 bool must_relocate_; 614 bool is_concurrent_gc_enabled_; 615 bool is_explicit_gc_disabled_; 616 bool dex2oat_enabled_; 617 bool image_dex2oat_enabled_; 618 619 std::string compiler_executable_; 620 std::string patchoat_executable_; 621 std::vector<std::string> compiler_options_; 622 std::vector<std::string> image_compiler_options_; 623 std::string image_location_; 624 625 std::string boot_class_path_string_; 626 std::string class_path_string_; 627 std::vector<std::string> properties_; 628 629 // The default stack size for managed threads created by the runtime. 630 size_t default_stack_size_; 631 632 gc::Heap* heap_; 633 634 std::unique_ptr<ArenaPool> arena_pool_; 635 // Special low 4gb pool for compiler linear alloc. We need ArtFields to be in low 4gb if we are 636 // compiling using a 32 bit image on a 64 bit compiler in case we resolve things in the image 637 // since the field arrays are int arrays in this case. 638 std::unique_ptr<ArenaPool> low_4gb_arena_pool_; 639 640 // Shared linear alloc for now. 641 std::unique_ptr<LinearAlloc> linear_alloc_; 642 643 // The number of spins that are done before thread suspension is used to forcibly inflate. 644 size_t max_spins_before_thin_lock_inflation_; 645 MonitorList* monitor_list_; 646 MonitorPool* monitor_pool_; 647 648 ThreadList* thread_list_; 649 650 InternTable* intern_table_; 651 652 ClassLinker* class_linker_; 653 654 SignalCatcher* signal_catcher_; 655 std::string stack_trace_file_; 656 657 JavaVMExt* java_vm_; 658 659 std::unique_ptr<jit::Jit> jit_; 660 std::unique_ptr<jit::JitOptions> jit_options_; 661 662 std::unique_ptr<lambda::BoxTable> lambda_box_table_; 663 664 // Fault message, printed when we get a SIGSEGV. 665 Mutex fault_message_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; 666 std::string fault_message_ GUARDED_BY(fault_message_lock_); 667 668 // A non-zero value indicates that a thread has been created but not yet initialized. Guarded by 669 // the shutdown lock so that threads aren't born while we're shutting down. 670 size_t threads_being_born_ GUARDED_BY(Locks::runtime_shutdown_lock_); 671 672 // Waited upon until no threads are being born. 673 std::unique_ptr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_); 674 675 // Set when runtime shutdown is past the point that new threads may attach. 676 bool shutting_down_ GUARDED_BY(Locks::runtime_shutdown_lock_); 677 678 // The runtime is starting to shutdown but is blocked waiting on shutdown_cond_. 679 bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_); 680 681 bool started_; 682 683 // New flag added which tells us if the runtime has finished starting. If 684 // this flag is set then the Daemon threads are created and the class loader 685 // is created. This flag is needed for knowing if its safe to request CMS. 686 bool finished_starting_; 687 688 // Hooks supported by JNI_CreateJavaVM 689 jint (*vfprintf_)(FILE* stream, const char* format, va_list ap); 690 void (*exit_)(jint status); 691 void (*abort_)(); 692 693 bool stats_enabled_; 694 RuntimeStats stats_; 695 696 const bool is_running_on_memory_tool_; 697 698 std::string profile_output_filename_; 699 ProfilerOptions profiler_options_; 700 bool profiler_started_; 701 702 std::unique_ptr<TraceConfig> trace_config_; 703 704 instrumentation::Instrumentation instrumentation_; 705 706 jobject main_thread_group_; 707 jobject system_thread_group_; 708 709 // As returned by ClassLoader.getSystemClassLoader(). 710 jobject system_class_loader_; 711 712 // If true, then we dump the GC cumulative timings on shutdown. 713 bool dump_gc_performance_on_shutdown_; 714 715 // Transaction used for pre-initializing classes at compilation time. 716 Transaction* preinitialization_transaction_; 717 718 // If kNone, verification is disabled. kEnable by default. 719 verifier::VerifyMode verify_; 720 721 // If true, the runtime may use dex files directly with the interpreter if an oat file is not 722 // available/usable. 723 bool allow_dex_file_fallback_; 724 725 // List of supported cpu abis. 726 std::vector<std::string> cpu_abilist_; 727 728 // Specifies target SDK version to allow workarounds for certain API levels. 729 int32_t target_sdk_version_; 730 731 // Implicit checks flags. 732 bool implicit_null_checks_; // NullPointer checks are implicit. 733 bool implicit_so_checks_; // StackOverflow checks are implicit. 734 bool implicit_suspend_checks_; // Thread suspension checks are implicit. 735 736 // Whether or not the sig chain (and implicitly the fault handler) should be 737 // disabled. Tools like dex2oat or patchoat don't need them. This enables 738 // building a statically link version of dex2oat. 739 bool no_sig_chain_; 740 741 // Whether or not a native bridge has been loaded. 742 // 743 // The native bridge allows running native code compiled for a foreign ISA. The way it works is, 744 // if standard dlopen fails to load native library associated with native activity, it calls to 745 // the native bridge to load it and then gets the trampoline for the entry to native activity. 746 // 747 // The option 'native_bridge_library_filename' specifies the name of the native bridge. 748 // When non-empty the native bridge will be loaded from the given file. An empty value means 749 // that there's no native bridge. 750 bool is_native_bridge_loaded_; 751 752 // The maximum number of failed boots we allow before pruning the dalvik cache 753 // and trying again. This option is only inspected when we're running as a 754 // zygote. 755 uint32_t zygote_max_failed_boots_; 756 757 // Enable experimental opcodes that aren't fully specified yet. The intent is to 758 // eventually publish them as public-usable opcodes, but they aren't ready yet. 759 // 760 // Experimental opcodes should not be used by other production code. 761 bool experimental_lambdas_; 762 763 MethodRefToStringInitRegMap method_ref_string_init_reg_map_; 764 765 // Contains the build fingerprint, if given as a parameter. 766 std::string fingerprint_; 767 768 DISALLOW_COPY_AND_ASSIGN(Runtime); 769}; 770std::ostream& operator<<(std::ostream& os, const Runtime::CalleeSaveType& rhs); 771 772} // namespace art 773 774#endif // ART_RUNTIME_RUNTIME_H_ 775