runtime.h revision 719d1a33f6569864f529e5a3fff59e7bca97aad0
12faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes/* 22faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Copyright (C) 2011 The Android Open Source Project 32faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 42faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 52faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * you may not use this file except in compliance with the License. 62faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * You may obtain a copy of the License at 72faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 82faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 92faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * 102faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * Unless required by applicable law or agreed to in writing, software 112faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 122faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 132faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * See the License for the specific language governing permissions and 142faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes * limitations under the License. 152faa5f1271587cda765f26bcf2951065300a01ffElliott Hughes */ 167b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_RUNTIME_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_RUNTIME_H_ 196b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro 20a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include <jni.h> 21c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes#include <stdio.h> 22c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes 23e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes#include <iosfwd> 246ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <string> 25fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro#include <utility> 266ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <vector> 27578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom 28761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughes#include "base/macros.h" 29e222ee0b794f941af4fb1b32fb8224e32942ea7bElliott Hughes#include "base/stringpiece.h" 300de9f73afe3e835b63f2ee0c1416930656449f3fMathieu Chartier#include "gc/collector_type.h" 311d54e73444e017d3a65234e0f193846f3e27472bIan Rogers#include "gc/heap.h" 32a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include "globals.h" 330f3c55331439970e01af67f80ac117c473bc04cfElliott Hughes#include "instruction_set.h" 3462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers#include "instrumentation.h" 3500f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers#include "jobject_comparator.h" 3683c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier#include "object_callbacks.h" 379d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes#include "runtime_stats.h" 38a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include "safe_map.h" 39b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro 406b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art { 417b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 421d54e73444e017d3a65234e0f193846f3e27472bIan Rogersnamespace gc { 431d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class Heap; 441d54e73444e017d3a65234e0f193846f3e27472bIan Rogers} 452dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersnamespace mirror { 46ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom class ArtMethod; 471d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class ClassLoader; 48d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz class Array; 4988474b416eb257078e590bf9bc7957cee604a186Jeff Hao template<class T> class ObjectArray; 501d54e73444e017d3a65234e0f193846f3e27472bIan Rogers template<class T> class PrimitiveArray; 511d54e73444e017d3a65234e0f193846f3e27472bIan Rogers typedef PrimitiveArray<int8_t> ByteArray; 521d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class String; 531d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class Throwable; 542dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers} // namespace mirror 55c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartiernamespace verifier { 56c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartierclass MethodVerifier; 57c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier} 5861e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ClassLinker; 592b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Markoclass CompilerCallbacks; 60fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiroclass DexFile; 61cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughesclass InternTable; 62b48b9eb6d181a1f52e2e605cf26a21505f1d46edIan Rogersclass JavaVMExt; 63c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughesclass MonitorList; 64ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogersclass MonitorPool; 65e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughesclass SignalCatcher; 6661e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ThreadList; 672692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhaoclass Trace; 68d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertzclass Transaction; 6961e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 70661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// Not all combinations of flags are valid. You may not visit all roots as well as the new roots 71661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// (no logical reason to do this). You also may not start logging new roots and stop logging new 72661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// roots (also no logical reason to do this). 73893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartierenum VisitRootFlags : uint8_t { 74893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagAllRoots = 0x1, 75893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagNewRoots = 0x2, 76893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagStartLoggingNewRoots = 0x4, 77893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagStopLoggingNewRoots = 0x8, 78893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagClearRootLog = 0x10, 79893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier}; 80893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier 811fb8620309a4e94d11879aabc33364acfa733904Carl Shapiroclass Runtime { 827b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro public: 83f1a5adc87760f938b01df26d906295063546b259Elliott Hughes typedef std::vector<std::pair<std::string, const void*> > Options; 848a436595d36c1e4935984fcac249d7d877e00383Brian Carlstrom 8561e019d291583029c01b61b93bea750f2b663c37Carl Shapiro // Creates and initializes a new runtime. 8600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers static bool Create(const Options& options, bool ignore_unrecognized) 87b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_); 8869b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom 89d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes bool IsCompiler() const { 902b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko return compiler_callbacks_ != nullptr; 912b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko } 922b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko 932b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko CompilerCallbacks* GetCompilerCallbacks() { 942b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko return compiler_callbacks_; 95d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes } 96d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes 97caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom bool IsZygote() const { 98caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom return is_zygote_; 99caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom } 100caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom 1018718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum bool IsExplicitGcDisabled() const { 1028718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum return is_explicit_gc_disabled_; 1038718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum } 1048718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum 1056449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom const std::vector<std::string>& GetCompilerOptions() const { 1066449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom return compiler_options_; 107a024a0686c3b0fea13f362bff70d65981e5febc5buzbee } 108a024a0686c3b0fea13f362bff70d65981e5febc5buzbee 1096449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom const std::vector<std::string>& GetImageCompilerOptions() const { 1106449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom return image_compiler_options_; 1118447d84d847d4562d7a7bce62768c27e7d20a9aaAnwar Ghuloum } 1128447d84d847d4562d7a7bce62768c27e7d20a9aaAnwar Ghuloum 11369b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom // Starts a runtime, which may cause threads to be started and code to run. 114bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_); 1152ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro 116590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier bool IsShuttingDown(Thread* self); 117590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier bool IsShuttingDownLocked() const EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) { 1189af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return shutting_down_; 1199af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 1209af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 121120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers size_t NumberOfThreadsBeingBorn() const EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) { 122120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers return threads_being_born_; 123120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers } 124120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 125120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers void StartThreadBirth() EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) { 126120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers threads_being_born_++; 127120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers } 128120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 129120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers void EndThreadBirth() EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_); 130120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 1319af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers bool IsStarted() const { 1329af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return started_; 1339af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 134dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes 1357664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier bool IsFinishedStarting() const { 1367664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier return finished_starting_; 1377664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier } 1387664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier 1392ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro static Runtime* Current() { 1402ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro return instance_; 1412ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro } 14261e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 143ffe6736397d17457188727510f0a2953f69a383aElliott Hughes // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most 144ffe6736397d17457188727510f0a2953f69a383aElliott Hughes // callers should prefer. 145ffe6736397d17457188727510f0a2953f69a383aElliott Hughes // This isn't marked ((noreturn)) because then gcc will merge multiple calls 146ffe6736397d17457188727510f0a2953f69a383aElliott Hughes // in a single function together. This reduces code size slightly, but means 147ffe6736397d17457188727510f0a2953f69a383aElliott Hughes // that the native stack trace we get may point at the wrong call site. 148b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers static void Abort() LOCKS_EXCLUDED(Locks::abort_lock_); 149ffe6736397d17457188727510f0a2953f69a383aElliott Hughes 150365c10235438607541fa2259a5fec48061b90bd8Ian Rogers // Returns the "main" ThreadGroup, used when attaching user threads. 151034f76b91225bea769d6185d7dad5e243af4ffa0Brian Carlstrom jobject GetMainThreadGroup() const; 152365c10235438607541fa2259a5fec48061b90bd8Ian Rogers 153365c10235438607541fa2259a5fec48061b90bd8Ian Rogers // Returns the "system" ThreadGroup, used when attaching our internal threads. 154034f76b91225bea769d6185d7dad5e243af4ffa0Brian Carlstrom jobject GetSystemThreadGroup() const; 155365c10235438607541fa2259a5fec48061b90bd8Ian Rogers 156ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom // Returns the system ClassLoader which represents the CLASSPATH. 157ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom jobject GetSystemClassLoader() const; 158ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom 159462c94449720e0dc6b93d7138d835d345ccf67aeElliott Hughes // Attaches the calling native thread to the runtime. 160664bebf92eb2151b9b570ccd42ac4b6056c3ea9cMathieu Chartier bool AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group, 161664bebf92eb2151b9b570ccd42ac4b6056c3ea9cMathieu Chartier bool create_peer); 162b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro 163bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes void CallExitHook(jint status); 164bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes 16561e019d291583029c01b61b93bea750f2b663c37Carl Shapiro // Detaches the current native thread from the runtime. 166b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers void DetachCurrentThread() LOCKS_EXCLUDED(Locks::mutator_lock_); 16761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 16800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers void DumpForSigQuit(std::ostream& os) 169b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 17021a5bf2dc8c9cb3fbe5a30a88d1149c328e3aacaElliott Hughes void DumpLockHolders(std::ostream& os); 171e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes 17261e019d291583029c01b61b93bea750f2b663c37Carl Shapiro ~Runtime(); 173b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro 174a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom const std::string& GetBootClassPathString() const { 175a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom return boot_class_path_string_; 176b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom } 177b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom 178a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom const std::string& GetClassPathString() const { 179a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom return class_path_string_; 1807a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro } 1817a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro 182a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom ClassLinker* GetClassLinker() const { 183a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom return class_linker_; 1847ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes } 1857ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 1867ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes size_t GetDefaultStackSize() const { 1877ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes return default_stack_size_; 1887ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes } 1897ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 1901d54e73444e017d3a65234e0f193846f3e27472bIan Rogers gc::Heap* GetHeap() const { 191b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes return heap_; 192b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes } 193b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 194cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes InternTable* GetInternTable() const { 195e810452722ac83b294d1f7aa80bdd88e547d5af0Brian Carlstrom DCHECK(intern_table_ != NULL); 196cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes return intern_table_; 197cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes } 198cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes 1990af5543f8ea20c3e655b2d748a1b7dcf283792feElliott Hughes JavaVMExt* GetJavaVM() const { 200c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes return java_vm_; 201f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes } 202f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes 203d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers size_t GetMaxSpinsBeforeThinkLockInflation() const { 204d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers return max_spins_before_thin_lock_inflation_; 205d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers } 206d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers 207c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes MonitorList* GetMonitorList() const { 208c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes return monitor_list_; 209c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes } 210c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes 211ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers MonitorPool* GetMonitorPool() const { 212ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers return monitor_pool_; 213ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers } 214ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers 215a436fde2762664a3ecdda5eefcadd20b2e104f59Ian Rogers mirror::Throwable* GetPreAllocatedOutOfMemoryError() const 216a436fde2762664a3ecdda5eefcadd20b2e104f59Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 217225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes 218225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes const std::vector<std::string>& GetProperties() const { 219225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes return properties_; 220225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes } 221225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes 222d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes ThreadList* GetThreadList() const { 223d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes return thread_list_; 224d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes } 225d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes 226491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom static const char* GetVersion() { 2277ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes return "2.0.0"; 2287ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes } 2297ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 230c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier void DisallowNewSystemWeaks() EXCLUSIVE_LOCKS_REQUIRED(Locks::mutator_lock_); 231c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier void AllowNewSystemWeaks() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 232c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier 2331d54e73444e017d3a65234e0f193846f3e27472bIan Rogers // Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If 2341d54e73444e017d3a65234e0f193846f3e27472bIan Rogers // clean_dirty is true then dirty roots will be marked as non-dirty after visiting. 235893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier void VisitRoots(RootCallback* visitor, void* arg, VisitRootFlags flags = kVisitRootFlagAllRoots) 2361d54e73444e017d3a65234e0f193846f3e27472bIan Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2371f87008b165d26541d832ff805250afdc89c253dBrian Carlstrom 2389ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier // Visit all of the roots we can do safely do concurrently. 239893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier void VisitConcurrentRoots(RootCallback* visitor, void* arg, 240893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier VisitRootFlags flags = kVisitRootFlagAllRoots) 241c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2429ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier 243858f1c5fd5e528d0b16040ced74d4636046a42d8Mathieu Chartier // Visit all of the non thread roots, we can do this with mutators unpaused. 24483c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier void VisitNonThreadRoots(RootCallback* visitor, void* arg) 245c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 246858f1c5fd5e528d0b16040ced74d4636046a42d8Mathieu Chartier 2479ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier // Visit all other roots which must be done with mutators suspended. 24883c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier void VisitNonConcurrentRoots(RootCallback* visitor, void* arg) 249c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2509ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier 2516aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier // Sweep system weaks, the system weak is deleted if the visitor return nullptr. Otherwise, the 2526aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier // system weak is updated to be the visitor's returned value. 25383c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier void SweepSystemWeaks(IsMarkedCallback* visitor, void* arg) 254ad2541a59c00c2c69e8973088891a2b5257c9780Mathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2556aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier 256893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier // Constant roots are the roots which never change after the runtime is initialized, they only 257893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier // need to be visited once per GC cycle. 258893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier void VisitConstantRoots(RootCallback* callback, void* arg) 259893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 260893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier 2619af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers // Returns a special method that calls into a trampoline for runtime method resolution 262ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* GetResolutionMethod() const { 2639af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers CHECK(HasResolutionMethod()); 2649af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return resolution_method_; 2659af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 2669af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 2679af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers bool HasResolutionMethod() const { 2689af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return resolution_method_ != NULL; 2699af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 2709af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 271ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom void SetResolutionMethod(mirror::ArtMethod* method) { 2729af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers resolution_method_ = method; 2739af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 2749af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 275ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 2761984651929744dd603fd082e23eacd877b9bc177Ian Rogers 27788474b416eb257078e590bf9bc7957cee604a186Jeff Hao // Returns a special method that calls into a trampoline for runtime imt conflicts 27888474b416eb257078e590bf9bc7957cee604a186Jeff Hao mirror::ArtMethod* GetImtConflictMethod() const { 27988474b416eb257078e590bf9bc7957cee604a186Jeff Hao CHECK(HasImtConflictMethod()); 28088474b416eb257078e590bf9bc7957cee604a186Jeff Hao return imt_conflict_method_; 28188474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 28288474b416eb257078e590bf9bc7957cee604a186Jeff Hao 28388474b416eb257078e590bf9bc7957cee604a186Jeff Hao bool HasImtConflictMethod() const { 28488474b416eb257078e590bf9bc7957cee604a186Jeff Hao return imt_conflict_method_ != NULL; 28588474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 28688474b416eb257078e590bf9bc7957cee604a186Jeff Hao 28788474b416eb257078e590bf9bc7957cee604a186Jeff Hao void SetImtConflictMethod(mirror::ArtMethod* method) { 28888474b416eb257078e590bf9bc7957cee604a186Jeff Hao imt_conflict_method_ = method; 28988474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 29088474b416eb257078e590bf9bc7957cee604a186Jeff Hao 29188474b416eb257078e590bf9bc7957cee604a186Jeff Hao mirror::ArtMethod* CreateImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 29288474b416eb257078e590bf9bc7957cee604a186Jeff Hao 29388474b416eb257078e590bf9bc7957cee604a186Jeff Hao // Returns an imt with every entry set to conflict, used as default imt for all classes. 29488474b416eb257078e590bf9bc7957cee604a186Jeff Hao mirror::ObjectArray<mirror::ArtMethod>* GetDefaultImt() const { 29588474b416eb257078e590bf9bc7957cee604a186Jeff Hao CHECK(HasDefaultImt()); 29688474b416eb257078e590bf9bc7957cee604a186Jeff Hao return default_imt_; 29788474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 29888474b416eb257078e590bf9bc7957cee604a186Jeff Hao 29988474b416eb257078e590bf9bc7957cee604a186Jeff Hao bool HasDefaultImt() const { 30088474b416eb257078e590bf9bc7957cee604a186Jeff Hao return default_imt_ != NULL; 30188474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 30288474b416eb257078e590bf9bc7957cee604a186Jeff Hao 30388474b416eb257078e590bf9bc7957cee604a186Jeff Hao void SetDefaultImt(mirror::ObjectArray<mirror::ArtMethod>* imt) { 30488474b416eb257078e590bf9bc7957cee604a186Jeff Hao default_imt_ = imt; 30588474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 30688474b416eb257078e590bf9bc7957cee604a186Jeff Hao 30788474b416eb257078e590bf9bc7957cee604a186Jeff Hao mirror::ObjectArray<mirror::ArtMethod>* CreateDefaultImt(ClassLinker* cl) 30888474b416eb257078e590bf9bc7957cee604a186Jeff Hao SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 30988474b416eb257078e590bf9bc7957cee604a186Jeff Hao 310ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers // Returns a special method that describes all callee saves being spilled to the stack. 3114f0d07c783afef89703dce32c94440fc8621a29bIan Rogers enum CalleeSaveType { 3124f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kSaveAll, 3134f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kRefsOnly, 3144f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kRefsAndArgs, 3154f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kLastCalleeSaveType // Value used for iteration 3164f0d07c783afef89703dce32c94440fc8621a29bIan Rogers }; 3179af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 3189af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers bool HasCalleeSaveMethod(CalleeSaveType type) const { 319225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes return callee_save_methods_[type] != NULL; 3209af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 3219af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 322ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* GetCalleeSaveMethod(CalleeSaveType type) const { 323df1ce91ba97bc79a0637e5504b39318fb1c9f577Ian Rogers DCHECK(HasCalleeSaveMethod(type)); 324225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes return callee_save_methods_[type]; 3259af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 3269af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 327936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers static size_t GetCalleeSaveMethodOffset(CalleeSaveType type) { 328936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers return OFFSETOF_MEMBER(Runtime, callee_save_methods_[type]); 329936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers } 330936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers 331ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom void SetCalleeSaveMethod(mirror::ArtMethod* method, CalleeSaveType type); 3324f0d07c783afef89703dce32c94440fc8621a29bIan Rogers 333ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* CreateCalleeSaveMethod(InstructionSet instruction_set, 3342dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers CalleeSaveType type) 335b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3369af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 337ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* CreateRefOnlyCalleeSaveMethod(InstructionSet instruction_set) 338b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 33900f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 340ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* CreateRefAndArgsCalleeSaveMethod(InstructionSet instruction_set) 341b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 342ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers 3439d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes int32_t GetStat(int kind); 3449d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 3459af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers RuntimeStats* GetStats() { 3469af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return &stats_; 3479af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 3489d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 3499d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes bool HasStatsEnabled() const { 3509d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes return stats_enabled_; 3519d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes } 3529d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 3539d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes void ResetStats(int kinds); 3549d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 3559d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes void SetStatsEnabled(bool new_state); 3569d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 357cc236d74772dda5a4161d9bc5f497fd3d956eb87Mathieu Chartier bool PreZygoteFork(); 358bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom bool InitZygote(); 359bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom void DidForkFromZygote(); 360caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom 36162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers instrumentation::Instrumentation* GetInstrumentation() { 36262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return &instrumentation_; 36362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 3642692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhao 365b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes bool UseCompileTimeClassPath() const { 366b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes return use_compile_time_class_path_; 367b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes } 3689af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 369e6da9af8dfe0a3e3fbc2be700554f6478380e7b9Mathieu Chartier void AddMethodVerifier(verifier::MethodVerifier* verifier) LOCKS_EXCLUDED(method_verifier_lock_); 370e6da9af8dfe0a3e3fbc2be700554f6478380e7b9Mathieu Chartier void RemoveMethodVerifier(verifier::MethodVerifier* verifier) 371e6da9af8dfe0a3e3fbc2be700554f6478380e7b9Mathieu Chartier LOCKS_EXCLUDED(method_verifier_lock_); 372c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier 37300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers const std::vector<const DexFile*>& GetCompileTimeClassPath(jobject class_loader); 37400f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers void SetCompileTimeClassPath(jobject class_loader, std::vector<const DexFile*>& class_path); 375b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 3760aded089f565008ba5908e395e5914ca4f91f2deDave Allison void StartProfiler(const char *appDir, bool startImmediately = false); 3770aded089f565008ba5908e395e5914ca4f91f2deDave Allison 378d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz // Transaction support. 379d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz bool IsActiveTransaction() const; 380d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void EnterTransactionMode(Transaction* transaction); 381d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void ExitTransactionMode(); 382d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteField32(mirror::Object* obj, MemberOffset field_offset, uint32_t value, 383d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz bool is_volatile) const; 384d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteField64(mirror::Object* obj, MemberOffset field_offset, uint64_t value, 385d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz bool is_volatile) const; 386d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteFieldReference(mirror::Object* obj, MemberOffset field_offset, 387d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz mirror::Object* value, bool is_volatile) const; 388d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const 389d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 390d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordStrongStringInsertion(mirror::String* s, uint32_t hash_code) const 391d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 392d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWeakStringInsertion(mirror::String* s, uint32_t hash_code) const 393d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 394d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordStrongStringRemoval(mirror::String* s, uint32_t hash_code) const 395d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 396d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWeakStringRemoval(mirror::String* s, uint32_t hash_code) const 397d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 398d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz 39915d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier void SetFaultMessage(const std::string& message); 40015d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier // Only read by the signal handler, NO_THREAD_SAFETY_ANALYSIS to prevent lock order violations 40115d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier // with the unexpected_signal_lock_. 40215d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier const std::string& GetFaultMessage() NO_THREAD_SAFETY_ANALYSIS { 40315d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier return fault_message_; 40415d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier } 40515d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier 406b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro private: 407457005c557b8762475db3220ce5a747d629f975bElliott Hughes static void InitPlatformSignalHandlers(); 408ffe6736397d17457188727510f0a2953f69a383aElliott Hughes 409dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes Runtime(); 41061e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 411c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes void BlockSignals(); 412c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes 41300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers bool Init(const Options& options, bool ignore_unrecognized) 414b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_); 415b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers void InitNativeMethods() LOCKS_EXCLUDED(Locks::mutator_lock_); 416365c10235438607541fa2259a5fec48061b90bd8Ian Rogers void InitThreadGroups(Thread* self); 417ff17f1fd3ff32f93e45588eb2b158832d73f9afaElliott Hughes void RegisterRuntimeNativeMethods(JNIEnv* env); 418d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes 41985d1545e985ac689db4bad7849880e843707c862Elliott Hughes void StartDaemonThreads(); 420d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes void StartSignalCatcher(); 42161e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 422b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes // A pointer to the active runtime or NULL. 423b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes static Runtime* instance_; 424b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 4252b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko CompilerCallbacks* compiler_callbacks_; 4269ca7a1fdd0daa546b790adb6a24dbc13c22df76aElliott Hughes bool is_zygote_; 427069387a60cb2b72e116cc38b32e14403f092df8fMathieu Chartier bool is_concurrent_gc_enabled_; 4288718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum bool is_explicit_gc_disabled_; 4290a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom 4306449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom std::vector<std::string> compiler_options_; 4316449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom std::vector<std::string> image_compiler_options_; 4327467ee05012e1fd9834df74663c1ebda46f5636bDragos Sbirlea 433a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom std::string boot_class_path_string_; 434a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom std::string class_path_string_; 4357ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes std::vector<std::string> properties_; 4367ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 437b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom // The default stack size for managed threads created by the runtime. 438be759c63c6bb58b76ac71cad2c5a736bd31f374dElliott Hughes size_t default_stack_size_; 439b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom 4401d54e73444e017d3a65234e0f193846f3e27472bIan Rogers gc::Heap* heap_; 441b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 442d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers // The number of spins that are done before thread suspension is used to forcibly inflate. 443d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers size_t max_spins_before_thin_lock_inflation_; 444c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes MonitorList* monitor_list_; 445ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers MonitorPool* monitor_pool_; 446c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes 447b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro ThreadList* thread_list_; 44861e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 449cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes InternTable* intern_table_; 450cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes 451b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom ClassLinker* class_linker_; 452b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom 453e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes SignalCatcher* signal_catcher_; 45494ce37a3919a0bdb8855a3d3264a50df1dbc41beElliott Hughes std::string stack_trace_file_; 455e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes 456c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes JavaVMExt* java_vm_; 457f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes 4582dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers mirror::Throwable* pre_allocated_OutOfMemoryError_; 459225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes 460ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* callee_save_methods_[kLastCalleeSaveType]; 461ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers 462ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* resolution_method_; 4631984651929744dd603fd082e23eacd877b9bc177Ian Rogers 46488474b416eb257078e590bf9bc7957cee604a186Jeff Hao mirror::ArtMethod* imt_conflict_method_; 46588474b416eb257078e590bf9bc7957cee604a186Jeff Hao 46688474b416eb257078e590bf9bc7957cee604a186Jeff Hao mirror::ObjectArray<mirror::ArtMethod>* default_imt_; 46788474b416eb257078e590bf9bc7957cee604a186Jeff Hao 46815d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier // Fault message, printed when we get a SIGSEGV. 46915d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier Mutex fault_message_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; 47015d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier std::string fault_message_ GUARDED_BY(fault_message_lock_); 47115d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier 472c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier // Method verifier set, used so that we can update their GC roots. 473719d1a33f6569864f529e5a3fff59e7bca97aad0Ian Rogers Mutex method_verifier_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; 474c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier std::set<verifier::MethodVerifier*> method_verifiers_; 475c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier 476120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // A non-zero value indicates that a thread has been created but not yet initialized. Guarded by 477120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // the shutdown lock so that threads aren't born while we're shutting down. 478120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers size_t threads_being_born_ GUARDED_BY(Locks::runtime_shutdown_lock_); 479120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 480120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // Waited upon until no threads are being born. 481120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers UniquePtr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_); 482120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 483120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // Set when runtime shutdown is past the point that new threads may attach. 484120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers bool shutting_down_ GUARDED_BY(Locks::runtime_shutdown_lock_); 485120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 486120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // The runtime is starting to shutdown but is blocked waiting on shutdown_cond_. 487120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_); 488120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 489dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes bool started_; 490dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes 4917664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier // New flag added which tells us if the runtime has finished starting. If 4927664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier // this flag is set then the Daemon threads are created and the class loader 4937664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier // is created. This flag is needed for knowing if its safe to request CMS. 4947664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier bool finished_starting_; 4957664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier 4966ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom // Hooks supported by JNI_CreateJavaVM 4976ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom jint (*vfprintf_)(FILE* stream, const char* format, va_list ap); 4986ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom void (*exit_)(jint status); 4996ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom void (*abort_)(); 5006ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom 5019d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes bool stats_enabled_; 5029d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes RuntimeStats stats_; 5039d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 5040aded089f565008ba5908e395e5914ca4f91f2deDave Allison // Runtime profile support. 5050aded089f565008ba5908e395e5914ca4f91f2deDave Allison bool profile_; 5060aded089f565008ba5908e395e5914ca4f91f2deDave Allison std::string profile_output_filename_; 507491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom uint32_t profile_period_s_; // Generate profile every n seconds. 508491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom uint32_t profile_duration_s_; // Run profile for n seconds. 509491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom uint32_t profile_interval_us_; // Microseconds between samples. 5100aded089f565008ba5908e395e5914ca4f91f2deDave Allison double profile_backoff_coefficient_; // Coefficient to exponential backoff. 5110aded089f565008ba5908e395e5914ca4f91f2deDave Allison 512b5e81858a47dd7ed051135f6982fbc4e13d0f309jeffhao bool method_trace_; 513b5e81858a47dd7ed051135f6982fbc4e13d0f309jeffhao std::string method_trace_file_; 514b5e81858a47dd7ed051135f6982fbc4e13d0f309jeffhao size_t method_trace_file_size_; 51562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers instrumentation::Instrumentation instrumentation_; 5162692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhao 51700f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers typedef SafeMap<jobject, std::vector<const DexFile*>, JobjectComparator> CompileTimeClassPaths; 518b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes CompileTimeClassPaths compile_time_class_paths_; 519b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes bool use_compile_time_class_path_; 520131aef8c94292cc530da2fd91ee98d1432352959Elliott Hughes 521365c10235438607541fa2259a5fec48061b90bd8Ian Rogers jobject main_thread_group_; 522365c10235438607541fa2259a5fec48061b90bd8Ian Rogers jobject system_thread_group_; 523365c10235438607541fa2259a5fec48061b90bd8Ian Rogers 524ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom // As returned by ClassLoader.getSystemClassLoader(). 525ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom jobject system_class_loader_; 526ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom 5272e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi // If true, then we dump the GC cumulative timings on shutdown. 5282e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi bool dump_gc_performance_on_shutdown_; 5292e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi 530d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz // Transaction used for pre-initializing classes at compilation time. 531d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz Transaction* preinitialization_transaction; 532d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz 53361e019d291583029c01b61b93bea750f2b663c37Carl Shapiro DISALLOW_COPY_AND_ASSIGN(Runtime); 5347b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro}; 5357b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 5366b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro} // namespace art 5377b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 538fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_RUNTIME_H_ 539