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