runtime.h revision 4edd8476339fd93ba8ff384ad107f1fc662e64a3
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> 24799eb3a5555254427db269921042419bc30d4d86Hiroshi Yamauchi#include <set> 256ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <string> 26fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiro#include <utility> 276ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom#include <vector> 28578bbdc684db8ed68e9fedbc678669d27fa68b6eBrian Carlstrom 29d582fa4ea62083a7598dded5b82dc2198b3daac7Ian Rogers#include "arch/instruction_set.h" 30794ad76e8d5b5b9132819d5b08a0570e27615644Andreas Gampe#include "base/macros.h" 3194f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi#include "gc_root.h" 3262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers#include "instrumentation.h" 3300f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers#include "jobject_comparator.h" 34848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao#include "method_reference.h" 3583c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier#include "object_callbacks.h" 36576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include "offsets.h" 37c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle#include "profiler_options.h" 387624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko#include "quick/quick_method_frame_info.h" 399d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes#include "runtime_stats.h" 40a0e180632411f7fe0edf454e571c42209ee7b540Elliott Hughes#include "safe_map.h" 41b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro 426b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapironamespace art { 437b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 441d54e73444e017d3a65234e0f193846f3e27472bIan Rogersnamespace gc { 451d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class Heap; 462cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi namespace collector { 472cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi class GarbageCollector; 482cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi } // namespace collector 49576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers} // namespace gc 50e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 51e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartiernamespace jit { 52e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier class Jit; 53e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier class JitOptions; 54e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier} // namespace jit 55e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 562dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersnamespace mirror { 571d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class ClassLoader; 58d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz class Array; 5988474b416eb257078e590bf9bc7957cee604a186Jeff Hao template<class T> class ObjectArray; 601d54e73444e017d3a65234e0f193846f3e27472bIan Rogers template<class T> class PrimitiveArray; 611d54e73444e017d3a65234e0f193846f3e27472bIan Rogers typedef PrimitiveArray<int8_t> ByteArray; 621d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class String; 631d54e73444e017d3a65234e0f193846f3e27472bIan Rogers class Throwable; 642dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers} // namespace mirror 65c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartiernamespace verifier { 666a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866fIan Rogers class MethodVerifier; 676a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866fIan Rogers} // namespace verifier 68e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartierclass ArenaPool; 69e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartierclass ArtMethod; 7061e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ClassLinker; 712cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchiclass Closure; 72e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartierclass CompilerCallbacks; 73fc322c72d7a89a6f7a05c8bdc232d780aecd9232Carl Shapiroclass DexFile; 74cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughesclass InternTable; 75b48b9eb6d181a1f52e2e605cf26a21505f1d46edIan Rogersclass JavaVMExt; 76e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartierclass LinearAlloc; 77c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughesclass MonitorList; 78ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogersclass MonitorPool; 79576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersclass NullPointerHandler; 80e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughesclass SignalCatcher; 81576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersclass StackOverflowHandler; 82576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogersclass SuspensionHandler; 8361e019d291583029c01b61b93bea750f2b663c37Carl Shapiroclass ThreadList; 842692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhaoclass Trace; 85f6a780abeaed4bf745720e8f836a3064d3ffbec4Andreas Gampestruct TraceConfig; 86d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertzclass Transaction; 8761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 88e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogerstypedef std::vector<std::pair<std::string, const void*>> RuntimeOptions; 89848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Haotypedef SafeMap<MethodReference, SafeMap<uint32_t, std::set<uint32_t>>, 90848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao MethodReferenceComparator> MethodRefToStringInitRegMap; 91e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers 92661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// Not all combinations of flags are valid. You may not visit all roots as well as the new roots 93661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// (no logical reason to do this). You also may not start logging new roots and stop logging new 94661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier// roots (also no logical reason to do this). 95893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartierenum VisitRootFlags : uint8_t { 96893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagAllRoots = 0x1, 97893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagNewRoots = 0x2, 98893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagStartLoggingNewRoots = 0x4, 99893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagStopLoggingNewRoots = 0x8, 100893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier kVisitRootFlagClearRootLog = 0x10, 1014edd8476339fd93ba8ff384ad107f1fc662e64a3Mathieu Chartier // Non moving means we can have optimizations where we don't visit some roots if they are 1024edd8476339fd93ba8ff384ad107f1fc662e64a3Mathieu Chartier // definitely reachable from another location. E.g. ArtMethod and ArtField roots. 1034edd8476339fd93ba8ff384ad107f1fc662e64a3Mathieu Chartier kVisitRootFlagNonMoving = 0x20, 104893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier}; 105893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier 1061fb8620309a4e94d11879aabc33364acfa733904Carl Shapiroclass Runtime { 1077b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro public: 10861e019d291583029c01b61b93bea750f2b663c37Carl Shapiro // Creates and initializes a new runtime. 109e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers static bool Create(const RuntimeOptions& options, bool ignore_unrecognized) 110b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_); 11169b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom 112e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier // IsAotCompiler for compilers that don't have a running runtime. Only dex2oat currently. 113e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier bool IsAotCompiler() const { 114e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier return !UseJit() && IsCompiler(); 115e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier } 116e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 117e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier // IsCompiler is any runtime which has a running compiler, either dex2oat or JIT. 118d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes bool IsCompiler() const { 1192b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko return compiler_callbacks_ != nullptr; 1202b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko } 1212b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko 1224585f876eb5dfb936bd0d6cb6acd78a1f2182ba6Andreas Gampe // If a compiler, are we compiling a boot image? 1234585f876eb5dfb936bd0d6cb6acd78a1f2182ba6Andreas Gampe bool IsCompilingBootImage() const; 1244585f876eb5dfb936bd0d6cb6acd78a1f2182ba6Andreas Gampe 1254585f876eb5dfb936bd0d6cb6acd78a1f2182ba6Andreas Gampe bool CanRelocate() const; 126a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light 127a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light bool ShouldRelocate() const { 128a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light return must_relocate_ && CanRelocate(); 129a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light } 130a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light 131a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light bool MustRelocateIfPossible() const { 132a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light return must_relocate_; 133a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light } 134a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light 1354fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray bool IsDex2OatEnabled() const { 13664ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light return dex2oat_enabled_ && IsImageDex2OatEnabled(); 13764ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light } 13864ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light 13964ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light bool IsImageDex2OatEnabled() const { 14064ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light return image_dex2oat_enabled_; 1414fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray } 1424fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray 1432b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko CompilerCallbacks* GetCompilerCallbacks() { 1442b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko return compiler_callbacks_; 145d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes } 146d9c67be7c116875d96b31e640ad47d587b205605Elliott Hughes 147caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom bool IsZygote() const { 148caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom return is_zygote_; 149caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom } 150caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom 1518718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum bool IsExplicitGcDisabled() const { 1528718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum return is_explicit_gc_disabled_; 1538718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum } 1548718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum 15512e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang std::string GetCompilerExecutable() const; 156a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light std::string GetPatchoatExecutable() const; 15712e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang 1586449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom const std::vector<std::string>& GetCompilerOptions() const { 1596449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom return compiler_options_; 160a024a0686c3b0fea13f362bff70d65981e5febc5buzbee } 161a024a0686c3b0fea13f362bff70d65981e5febc5buzbee 162d2abbc9829ea0f657557c247a7c48c825dacfccdAndreas Gampe void AddCompilerOption(std::string option) { 163d2abbc9829ea0f657557c247a7c48c825dacfccdAndreas Gampe compiler_options_.push_back(option); 164d2abbc9829ea0f657557c247a7c48c825dacfccdAndreas Gampe } 165d2abbc9829ea0f657557c247a7c48c825dacfccdAndreas Gampe 1666449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom const std::vector<std::string>& GetImageCompilerOptions() const { 1676449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom return image_compiler_options_; 1688447d84d847d4562d7a7bce62768c27e7d20a9aaAnwar Ghuloum } 1698447d84d847d4562d7a7bce62768c27e7d20a9aaAnwar Ghuloum 17031d8f5295c24730a57cb36cbc41197f0b7e8397cBrian Carlstrom const std::string& GetImageLocation() const { 17131d8f5295c24730a57cb36cbc41197f0b7e8397cBrian Carlstrom return image_location_; 17231d8f5295c24730a57cb36cbc41197f0b7e8397cBrian Carlstrom } 17331d8f5295c24730a57cb36cbc41197f0b7e8397cBrian Carlstrom 174c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle const ProfilerOptions& GetProfilerOptions() const { 175c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle return profiler_options_; 176c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle } 177c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle 17869b15fb098162f19a4c20e6dccdcead04d9c77f0Brian Carlstrom // Starts a runtime, which may cause threads to be started and code to run. 179bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom bool Start() UNLOCK_FUNCTION(Locks::mutator_lock_); 1802ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro 181590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier bool IsShuttingDown(Thread* self); 182590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier bool IsShuttingDownLocked() const EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) { 1839af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return shutting_down_; 1849af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 1859af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 186120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers size_t NumberOfThreadsBeingBorn() const EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) { 187120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers return threads_being_born_; 188120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers } 189120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 190120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers void StartThreadBirth() EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_) { 191120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers threads_being_born_++; 192120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers } 193120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 194120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers void EndThreadBirth() EXCLUSIVE_LOCKS_REQUIRED(Locks::runtime_shutdown_lock_); 195120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 1969af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers bool IsStarted() const { 1979af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return started_; 1989af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 199dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes 2007664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier bool IsFinishedStarting() const { 2017664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier return finished_starting_; 2027664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier } 2037664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier 2042ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro static Runtime* Current() { 2052ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro return instance_; 2062ed144c2b49ae1da6c464d7a1be0062870530802Carl Shapiro } 20761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 208db978719dbcb73fc6acfd193561445c4462786b8Nicolas Geoffray // Aborts semi-cleanly. Used in the implementation of LOG(FATAL), which most 209db978719dbcb73fc6acfd193561445c4462786b8Nicolas Geoffray // callers should prefer. 210794ad76e8d5b5b9132819d5b08a0570e27615644Andreas Gampe NO_RETURN static void Abort() LOCKS_EXCLUDED(Locks::abort_lock_); 211ffe6736397d17457188727510f0a2953f69a383aElliott Hughes 212365c10235438607541fa2259a5fec48061b90bd8Ian Rogers // Returns the "main" ThreadGroup, used when attaching user threads. 213034f76b91225bea769d6185d7dad5e243af4ffa0Brian Carlstrom jobject GetMainThreadGroup() const; 214365c10235438607541fa2259a5fec48061b90bd8Ian Rogers 215365c10235438607541fa2259a5fec48061b90bd8Ian Rogers // Returns the "system" ThreadGroup, used when attaching our internal threads. 216034f76b91225bea769d6185d7dad5e243af4ffa0Brian Carlstrom jobject GetSystemThreadGroup() const; 217365c10235438607541fa2259a5fec48061b90bd8Ian Rogers 218ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom // Returns the system ClassLoader which represents the CLASSPATH. 219ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom jobject GetSystemClassLoader() const; 220ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom 221462c94449720e0dc6b93d7138d835d345ccf67aeElliott Hughes // Attaches the calling native thread to the runtime. 222664bebf92eb2151b9b570ccd42ac4b6056c3ea9cMathieu Chartier bool AttachCurrentThread(const char* thread_name, bool as_daemon, jobject thread_group, 223664bebf92eb2151b9b570ccd42ac4b6056c3ea9cMathieu Chartier bool create_peer); 224b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro 225bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes void CallExitHook(jint status); 226bf86d0438e9ef9c145ebcf16a2e74c4efaa2686aElliott Hughes 22761e019d291583029c01b61b93bea750f2b663c37Carl Shapiro // Detaches the current native thread from the runtime. 228b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers void DetachCurrentThread() LOCKS_EXCLUDED(Locks::mutator_lock_); 22961e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 2307b078e8c04f3e1451dbdd18543c8b9692b5b067eIan Rogers void DumpForSigQuit(std::ostream& os); 23121a5bf2dc8c9cb3fbe5a30a88d1149c328e3aacaElliott Hughes void DumpLockHolders(std::ostream& os); 232e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes 23361e019d291583029c01b61b93bea750f2b663c37Carl Shapiro ~Runtime(); 234b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro 235a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom const std::string& GetBootClassPathString() const { 236a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom return boot_class_path_string_; 237b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom } 238b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom 239a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom const std::string& GetClassPathString() const { 240a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom return class_path_string_; 2417a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro } 2427a90959d4ef7a69f3bcb7b8763f646e12d9267d3Carl Shapiro 243a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom ClassLinker* GetClassLinker() const { 244a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom return class_linker_; 2457ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes } 2467ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 2477ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes size_t GetDefaultStackSize() const { 2487ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes return default_stack_size_; 2497ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes } 2507ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 2511d54e73444e017d3a65234e0f193846f3e27472bIan Rogers gc::Heap* GetHeap() const { 252b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes return heap_; 253b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes } 254b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 255cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes InternTable* GetInternTable() const { 2562cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier DCHECK(intern_table_ != nullptr); 257cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes return intern_table_; 258cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes } 259cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes 2600af5543f8ea20c3e655b2d748a1b7dcf283792feElliott Hughes JavaVMExt* GetJavaVM() const { 261c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes return java_vm_; 262f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes } 263f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes 264d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers size_t GetMaxSpinsBeforeThinkLockInflation() const { 265d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers return max_spins_before_thin_lock_inflation_; 266d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers } 267d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers 268c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes MonitorList* GetMonitorList() const { 269c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes return monitor_list_; 270c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes } 271c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes 272ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers MonitorPool* GetMonitorPool() const { 273ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers return monitor_pool_; 274ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers } 275ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers 276c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers // Is the given object the special object used to mark a cleared JNI weak global? 277c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers bool IsClearedJniWeakGlobal(mirror::Object* obj) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 278c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers 279c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers // Get the special object used to mark a cleared JNI weak global. 280c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers mirror::Object* GetClearedJniWeakGlobal() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 281c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers 282ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi mirror::Throwable* GetPreAllocatedOutOfMemoryError() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 283225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes 28463557459a4098294a9ff44d035241de2966047c0Ian Rogers mirror::Throwable* GetPreAllocatedNoClassDefFoundError() 28563557459a4098294a9ff44d035241de2966047c0Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 28663557459a4098294a9ff44d035241de2966047c0Ian Rogers 287225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes const std::vector<std::string>& GetProperties() const { 288225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes return properties_; 289225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes } 290225f5a1df25241babd16cdba54056b9e2cd166a2Elliott Hughes 291d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes ThreadList* GetThreadList() const { 292d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes return thread_list_; 293d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes } 294d92bec457dc6c506c80e9da6b8e0c958266b5cdcElliott Hughes 295491ca9e75fad381468dd7f5fdbff56d1a9738dd7Brian Carlstrom static const char* GetVersion() { 2962153f93df36b59a61fed15bef8e7304010be04b5Andreas Gampe return "2.1.0"; 2977ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes } 2987ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 2992cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi void DisallowNewSystemWeaks() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 300c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier void AllowNewSystemWeaks() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3012cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi void EnsureNewSystemWeaksDisallowed() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 302c11d9b8870de5f860b13c84003ade7b3f3125a52Mathieu Chartier 3031d54e73444e017d3a65234e0f193846f3e27472bIan Rogers // Visit all the roots. If only_dirty is true then non-dirty roots won't be visited. If 3041d54e73444e017d3a65234e0f193846f3e27472bIan Rogers // clean_dirty is true then dirty roots will be marked as non-dirty after visiting. 305bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitRoots(RootVisitor* visitor, VisitRootFlags flags = kVisitRootFlagAllRoots) 3061d54e73444e017d3a65234e0f193846f3e27472bIan Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3071f87008b165d26541d832ff805250afdc89c253dBrian Carlstrom 308461687d898dfd91253f242072849a9fe43e5f523Mathieu Chartier // Visit image roots, only used for hprof since the GC uses the image space mod union table 309461687d898dfd91253f242072849a9fe43e5f523Mathieu Chartier // instead. 310bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitImageRoots(RootVisitor* visitor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 311461687d898dfd91253f242072849a9fe43e5f523Mathieu Chartier 3129ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier // Visit all of the roots we can do safely do concurrently. 313bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitConcurrentRoots(RootVisitor* visitor, 314893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier VisitRootFlags flags = kVisitRootFlagAllRoots) 315c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3169ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier 317858f1c5fd5e528d0b16040ced74d4636046a42d8Mathieu Chartier // Visit all of the non thread roots, we can do this with mutators unpaused. 318bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitNonThreadRoots(RootVisitor* visitor) 319c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 320858f1c5fd5e528d0b16040ced74d4636046a42d8Mathieu Chartier 321bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitTransactionRoots(RootVisitor* visitor) 3222cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3232cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi 3242cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi // Visit all of the thread roots. 325bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitThreadRoots(RootVisitor* visitor) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3262cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi 3272cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi // Flip thread roots from from-space refs to to-space refs. 3282cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi size_t FlipThreadRoots(Closure* thread_flip_visitor, Closure* flip_callback, 3292cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi gc::collector::GarbageCollector* collector) 3302cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi LOCKS_EXCLUDED(Locks::mutator_lock_); 3312cd334ae2d4287216523882f0d298cf3901b7ab1Hiroshi Yamauchi 3329ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier // Visit all other roots which must be done with mutators suspended. 333bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitNonConcurrentRoots(RootVisitor* visitor) 334c528dba35b5faece51ca658fc008b688f8b690adMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3359ebae1f30b84dfd8dab4144f80eebec4f8fc8851Mathieu Chartier 3362cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier // Sweep system weaks, the system weak is deleted if the visitor return null. Otherwise, the 3376aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier // system weak is updated to be the visitor's returned value. 33883c8ee000d525017ead8753fce6bc1020249b96aMathieu Chartier void SweepSystemWeaks(IsMarkedCallback* visitor, void* arg) 339ad2541a59c00c2c69e8973088891a2b5257c9780Mathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3406aa3df965395566ed6a4fec4af37c2b7577992e9Mathieu Chartier 341893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier // Constant roots are the roots which never change after the runtime is initialized, they only 342893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier // need to be visited once per GC cycle. 343bb87e0f1a52de656bc77cb01cb887e51a0e5198bMathieu Chartier void VisitConstantRoots(RootVisitor* visitor) 344893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 345893263b7d5bc2ca43a91ecb8071867f5134fc60aMathieu Chartier 3469af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers // Returns a special method that calls into a trampoline for runtime method resolution 347e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* GetResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3489af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 3499af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers bool HasResolutionMethod() const { 350e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier return resolution_method_ != nullptr; 3519af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 3529af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 353e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void SetResolutionMethod(ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3549af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 355e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* CreateResolutionMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3561984651929744dd603fd082e23eacd877b9bc177Ian Rogers 357e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers // Returns a special method that calls into a trampoline for runtime imt conflicts. 358e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* GetImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 359e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* GetImtUnimplementedMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 36088474b416eb257078e590bf9bc7957cee604a186Jeff Hao 36188474b416eb257078e590bf9bc7957cee604a186Jeff Hao bool HasImtConflictMethod() const { 362e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier return imt_conflict_method_ != nullptr; 36388474b416eb257078e590bf9bc7957cee604a186Jeff Hao } 36488474b416eb257078e590bf9bc7957cee604a186Jeff Hao 365e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void SetImtConflictMethod(ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 366e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void SetImtUnimplementedMethod(ArtMethod* method) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 36788474b416eb257078e590bf9bc7957cee604a186Jeff Hao 368e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* CreateImtConflictMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 36988474b416eb257078e590bf9bc7957cee604a186Jeff Hao 370ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers // Returns a special method that describes all callee saves being spilled to the stack. 3714f0d07c783afef89703dce32c94440fc8621a29bIan Rogers enum CalleeSaveType { 3724f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kSaveAll, 3734f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kRefsOnly, 3744f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kRefsAndArgs, 3754f0d07c783afef89703dce32c94440fc8621a29bIan Rogers kLastCalleeSaveType // Value used for iteration 3764f0d07c783afef89703dce32c94440fc8621a29bIan Rogers }; 3779af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 3789af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers bool HasCalleeSaveMethod(CalleeSaveType type) const { 379e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier return callee_save_methods_[type] != 0u; 3809af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 3819af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 382e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* GetCalleeSaveMethod(CalleeSaveType type) 383e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 384ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi 385e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* GetCalleeSaveMethodUnchecked(CalleeSaveType type) 386e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3879af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 3887624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko QuickMethodFrameInfo GetCalleeSaveMethodFrameInfo(CalleeSaveType type) const { 3897624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko return callee_save_method_frame_infos_[type]; 3907624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko } 3917624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko 392e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier QuickMethodFrameInfo GetRuntimeMethodFrameInfo(ArtMethod* method) 393ab088118d33caafb00815ab72ac0fd7374169f64Hiroshi Yamauchi SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 3947624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko 395936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers static size_t GetCalleeSaveMethodOffset(CalleeSaveType type) { 396936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers return OFFSETOF_MEMBER(Runtime, callee_save_methods_[type]); 397936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers } 398936b37f3a7f224d990a36b2ec66782a4462180d6Ian Rogers 3997624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko InstructionSet GetInstructionSet() const { 4007624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko return instruction_set_; 4017624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko } 4024f0d07c783afef89703dce32c94440fc8621a29bIan Rogers 4037624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko void SetInstructionSet(InstructionSet instruction_set); 4049af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers 405e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void SetCalleeSaveMethod(ArtMethod* method, CalleeSaveType type); 40600f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogers 407e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* CreateCalleeSaveMethod() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 408ff1ed4770bf7ff024a807b9f909b1a26abb78341Ian Rogers 4099d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes int32_t GetStat(int kind); 4109d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 4119af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers RuntimeStats* GetStats() { 4129af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers return &stats_; 4139af209c9dcc6763fae2976981570a90aa41fd86bIan Rogers } 4149d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 4159d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes bool HasStatsEnabled() const { 4169d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes return stats_enabled_; 4179d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes } 4189d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 4199d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes void ResetStats(int kinds); 4209d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 4219ef78b59da51080882e47505896b420977fd79aeMathieu Chartier void SetStatsEnabled(bool new_state) LOCKS_EXCLUDED(Locks::instrument_entrypoints_lock_, 4229ef78b59da51080882e47505896b420977fd79aeMathieu Chartier Locks::mutator_lock_); 4239d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 4246be67eeedbe60afce42300ae3e7f0e7180a96efaAndreas Gampe enum class NativeBridgeAction { // private 4256be67eeedbe60afce42300ae3e7f0e7180a96efaAndreas Gampe kUnload, 4266be67eeedbe60afce42300ae3e7f0e7180a96efaAndreas Gampe kInitialize 4276be67eeedbe60afce42300ae3e7f0e7180a96efaAndreas Gampe }; 428e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 429e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier jit::Jit* GetJit() { 430e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier return jit_.get(); 431e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier } 432e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier bool UseJit() const { 433e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier return jit_.get() != nullptr; 434e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier } 435e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 4363de95a7b0a2d30cde6dc92b72c35df3a61002124Narayan Kamath void PreZygoteFork(); 437bd86bccf1b47f1151842152ee52cf5d46d6b34abBrian Carlstrom bool InitZygote(); 438a6da74e941d7cee498ac3880018a1d8dc953c6ebjgu void DidForkFromZygote(JNIEnv* env, NativeBridgeAction action, const char* isa); 439caabb1b77b4a55eb1bb45ebcd3071c9ea01dd3cfBrian Carlstrom 4409bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers const instrumentation::Instrumentation* GetInstrumentation() const { 4419bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers return &instrumentation_; 4429bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers } 4439bc54406ba3377980cfce44901dc2be246178ba9Ian Rogers 44462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers instrumentation::Instrumentation* GetInstrumentation() { 44562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return &instrumentation_; 44662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 4472692b573a56cd63a3c8c8aa1636e3766b6d8c9c4jeffhao 448c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle void StartProfiler(const char* profile_output_filename); 44939c3bfbd03d85c63cfbe69f17ce5800ccc7d6c13Dave Allison void UpdateProfilerState(int state); 4500aded089f565008ba5908e395e5914ca4f91f2deDave Allison 451d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz // Transaction support. 452ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz bool IsActiveTransaction() const { 453ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz return preinitialization_transaction_ != nullptr; 454ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz } 455d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void EnterTransactionMode(Transaction* transaction); 456d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void ExitTransactionMode(); 4571c80becf5406cd6d95dc24bf47a0c5a3809ea281Sebastien Hertz bool IsTransactionAborted() const; 4581c80becf5406cd6d95dc24bf47a0c5a3809ea281Sebastien Hertz 4592fd7e69505195cda4caaa3161aaf37315552a698Sebastien Hertz void AbortTransactionAndThrowAbortError(Thread* self, const std::string& abort_message) 4601c80becf5406cd6d95dc24bf47a0c5a3809ea281Sebastien Hertz SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 4612fd7e69505195cda4caaa3161aaf37315552a698Sebastien Hertz void ThrowTransactionAbortError(Thread* self) 4621c80becf5406cd6d95dc24bf47a0c5a3809ea281Sebastien Hertz SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 4631c80becf5406cd6d95dc24bf47a0c5a3809ea281Sebastien Hertz 46437f05ef45e0393de812d51261dc293240c17294dFred Shih void RecordWriteFieldBoolean(mirror::Object* obj, MemberOffset field_offset, uint8_t value, 46537f05ef45e0393de812d51261dc293240c17294dFred Shih bool is_volatile) const; 46637f05ef45e0393de812d51261dc293240c17294dFred Shih void RecordWriteFieldByte(mirror::Object* obj, MemberOffset field_offset, int8_t value, 46737f05ef45e0393de812d51261dc293240c17294dFred Shih bool is_volatile) const; 46837f05ef45e0393de812d51261dc293240c17294dFred Shih void RecordWriteFieldChar(mirror::Object* obj, MemberOffset field_offset, uint16_t value, 46937f05ef45e0393de812d51261dc293240c17294dFred Shih bool is_volatile) const; 47037f05ef45e0393de812d51261dc293240c17294dFred Shih void RecordWriteFieldShort(mirror::Object* obj, MemberOffset field_offset, int16_t value, 47137f05ef45e0393de812d51261dc293240c17294dFred Shih bool is_volatile) const; 472d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteField32(mirror::Object* obj, MemberOffset field_offset, uint32_t value, 473d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz bool is_volatile) const; 474d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteField64(mirror::Object* obj, MemberOffset field_offset, uint64_t value, 475d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz bool is_volatile) const; 476d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteFieldReference(mirror::Object* obj, MemberOffset field_offset, 477d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz mirror::Object* value, bool is_volatile) const; 478d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz void RecordWriteArray(mirror::Array* array, size_t index, uint64_t value) const 479d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); 480cdfd39f579574a75b98e7ad48c69826b00361b27Mathieu Chartier void RecordStrongStringInsertion(mirror::String* s) const 481d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 482cdfd39f579574a75b98e7ad48c69826b00361b27Mathieu Chartier void RecordWeakStringInsertion(mirror::String* s) const 483d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 484cdfd39f579574a75b98e7ad48c69826b00361b27Mathieu Chartier void RecordStrongStringRemoval(mirror::String* s) const 485d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 486cdfd39f579574a75b98e7ad48c69826b00361b27Mathieu Chartier void RecordWeakStringRemoval(mirror::String* s) const 487d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz EXCLUSIVE_LOCKS_REQUIRED(Locks::intern_table_lock_); 488d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz 48915d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier void SetFaultMessage(const std::string& message); 49015d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier // Only read by the signal handler, NO_THREAD_SAFETY_ANALYSIS to prevent lock order violations 49115d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier // with the unexpected_signal_lock_. 49215d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier const std::string& GetFaultMessage() NO_THREAD_SAFETY_ANALYSIS { 49315d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier return fault_message_; 49415d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier } 49515d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier 4968afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers void AddCurrentRuntimeFeaturesAsDex2OatArguments(std::vector<std::string>* arg_vector) const; 4978afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers 498b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison bool ExplicitStackOverflowChecks() const { 499928f72bd75c385ba2708c58521171a77264d4486Andreas Gampe return !implicit_so_checks_; 500b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison } 501b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison 5024a200f56b7075309316b04d550c9cc50f8314eddJeff Hao bool IsVerificationEnabled() const { 5034a200f56b7075309316b04d550c9cc50f8314eddJeff Hao return verify_; 5044a200f56b7075309316b04d550c9cc50f8314eddJeff Hao } 5054a200f56b7075309316b04d550c9cc50f8314eddJeff Hao 50624e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler bool IsDexFileFallbackEnabled() const { 50724e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler return allow_dex_file_fallback_; 50824e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler } 50924e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler 510785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov const std::vector<std::string>& GetCpuAbilist() const { 511785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov return cpu_abilist_; 512785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov } 513785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov 514da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier bool RunningOnValgrind() const { 515da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier return running_on_valgrind_; 516da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier } 517da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier 518f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao void SetTargetSdkVersion(int32_t version) { 519f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao target_sdk_version_ = version; 520f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao } 521f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao 522f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao int32_t GetTargetSdkVersion() const { 523f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao return target_sdk_version_; 524f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao } 525f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao 5265a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath uint32_t GetZygoteMaxFailedBoots() const { 5275a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath return zygote_max_failed_boots_; 5285a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath } 5295a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath 530455f67c4cf0b4f04e117db3024fd189fa1c7dab9Mathieu Chartier // Create the JIT and instrumentation and code cache. 531e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier void CreateJit(); 532e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 5339b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier ArenaPool* GetArenaPool() { 5349b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier return arena_pool_.get(); 5359b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier } 5369b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier const ArenaPool* GetArenaPool() const { 5379b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier return arena_pool_.get(); 5389b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier } 539c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier LinearAlloc* GetLinearAlloc() { 540c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier return linear_alloc_.get(); 541c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier } 5429b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier 543455f67c4cf0b4f04e117db3024fd189fa1c7dab9Mathieu Chartier jit::JitOptions* GetJITOptions() { 544455f67c4cf0b4f04e117db3024fd189fa1c7dab9Mathieu Chartier return jit_options_.get(); 545455f67c4cf0b4f04e117db3024fd189fa1c7dab9Mathieu Chartier } 546455f67c4cf0b4f04e117db3024fd189fa1c7dab9Mathieu Chartier 547848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao MethodRefToStringInitRegMap& GetStringInitMap() { 548848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao return method_ref_string_init_reg_map_; 549848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao } 550848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao 551b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro private: 552457005c557b8762475db3220ce5a747d629f975bElliott Hughes static void InitPlatformSignalHandlers(); 553ffe6736397d17457188727510f0a2953f69a383aElliott Hughes 554dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes Runtime(); 55561e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 556c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes void BlockSignals(); 557c1674ed06662420213441ff2b818f2f71f9098dcElliott Hughes 558e63db27db913f1a88e2095a1ee8239b2bb9124e8Ian Rogers bool Init(const RuntimeOptions& options, bool ignore_unrecognized) 559b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers SHARED_TRYLOCK_FUNCTION(true, Locks::mutator_lock_); 560b726dcb581bf72da46527378ccb6889020f0e6e9Ian Rogers void InitNativeMethods() LOCKS_EXCLUDED(Locks::mutator_lock_); 561365c10235438607541fa2259a5fec48061b90bd8Ian Rogers void InitThreadGroups(Thread* self); 562ff17f1fd3ff32f93e45588eb2b158832d73f9afaElliott Hughes void RegisterRuntimeNativeMethods(JNIEnv* env); 563d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes 56485d1545e985ac689db4bad7849880e843707c862Elliott Hughes void StartDaemonThreads(); 565d1cc8363d4f4bbac7568b1d02a5ca481cd10830fElliott Hughes void StartSignalCatcher(); 56661e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 5672cebb24bfc3247d3e9be138a3350106737455918Mathieu Chartier // A pointer to the active runtime or null. 568b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes static Runtime* instance_; 569b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 5708afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers // NOTE: these must match the gc::ProcessState values as they come directly from the framework. 5718afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers static constexpr int kProfileForground = 0; 5728afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers static constexpr int kProfileBackgrouud = 1; 5738afeb85d3def12b559b7565fb6d3956f81b55132Ian Rogers 574e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier // 64 bit so that we can share the same asm offsets for both 32 and 64 bits. 575e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier uint64_t callee_save_methods_[kLastCalleeSaveType]; 57694f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi GcRoot<mirror::Throwable> pre_allocated_OutOfMemoryError_; 57763557459a4098294a9ff44d035241de2966047c0Ian Rogers GcRoot<mirror::Throwable> pre_allocated_NoClassDefFoundError_; 578e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* resolution_method_; 579e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* imt_conflict_method_; 5802d2621a1463d2f3f03fa73503fa42e43657cdcfcMathieu Chartier // Unresolved method has the same behavior as the conflict method, it is used by the class linker 5812d2621a1463d2f3f03fa73503fa42e43657cdcfcMathieu Chartier // for differentiating between unfilled imt slots vs conflict slots in superclasses. 582e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* imt_unimplemented_method_; 5836ed19fd1b08abbc438781ae3e6fea111c1f92315Ian Rogers 584c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers // Special sentinel object used to invalid conditions in JNI (cleared weak references) and 585c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers // JDWP (invalid references). 586c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers GcRoot<mirror::Object> sentinel_; 587c0542af3e2170143ba40d89136e284997e16bf64Ian Rogers 5887624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko InstructionSet instruction_set_; 5897624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko QuickMethodFrameInfo callee_save_method_frame_infos_[kLastCalleeSaveType]; 5907624d25dad2d1ba25969ae704fccf68649103ae5Vladimir Marko 5912b5eaa2b49f7489bafdadc4b4463ae27e4261817Vladimir Marko CompilerCallbacks* compiler_callbacks_; 5929ca7a1fdd0daa546b790adb6a24dbc13c22df76aElliott Hughes bool is_zygote_; 593a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light bool must_relocate_; 594069387a60cb2b72e116cc38b32e14403f092df8fMathieu Chartier bool is_concurrent_gc_enabled_; 5958718359763aa3dcd0033a2d2e67e0cb145fb9c53Anwar Ghuloum bool is_explicit_gc_disabled_; 5964fcdc94d22a4608e355aa8df36240181149d10e8Nicolas Geoffray bool dex2oat_enabled_; 59764ad14dbe2225441fb7734bf6d89358d96692eeaAlex Light bool image_dex2oat_enabled_; 5980a5b14de5115f51e0ed2dd6c3fcc5b84bbce690eBrian Carlstrom 59912e6d7446384a7a5fbec25fe116bbb271c62842eTsu Chiang Chuang std::string compiler_executable_; 600a59dd80f9f48cb750d329d4d4af2d99d72b484d1Alex Light std::string patchoat_executable_; 6016449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom std::vector<std::string> compiler_options_; 6026449c62e40ef3a9bb75f664f922555affb532ee4Brian Carlstrom std::vector<std::string> image_compiler_options_; 60331d8f5295c24730a57cb36cbc41197f0b7e8397cBrian Carlstrom std::string image_location_; 6047467ee05012e1fd9834df74663c1ebda46f5636bDragos Sbirlea 605a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom std::string boot_class_path_string_; 606a004aa933a58428489e42d77f707c2b063b73747Brian Carlstrom std::string class_path_string_; 6077ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes std::vector<std::string> properties_; 6087ede61eceed2f8da14a4fff05c57c748c160d57fElliott Hughes 609b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom // The default stack size for managed threads created by the runtime. 610be759c63c6bb58b76ac71cad2c5a736bd31f374dElliott Hughes size_t default_stack_size_; 611b765be0d656c3073402693aeaf64e95a0e49f218Brian Carlstrom 6121d54e73444e017d3a65234e0f193846f3e27472bIan Rogers gc::Heap* heap_; 613b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 6149b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier std::unique_ptr<ArenaPool> arena_pool_; 615c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier // Special low 4gb pool for compiler linear alloc. We need ArtFields to be in low 4gb if we are 616c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier // compiling using a 32 bit image on a 64 bit compiler in case we resolve things in the image 617c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier // since the field arrays are int arrays in this case. 618c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier std::unique_ptr<ArenaPool> low_4gb_arena_pool_; 619c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier 620c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier // Shared linear alloc for now. 621c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier std::unique_ptr<LinearAlloc> linear_alloc_; 6229b34b244ecddd8a35c922ed87bc3df0ca4db0282Mathieu Chartier 623d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers // The number of spins that are done before thread suspension is used to forcibly inflate. 624d9c4fc94fa618617f94e1de9af5f034549100753Ian Rogers size_t max_spins_before_thin_lock_inflation_; 625c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes MonitorList* monitor_list_; 626ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers MonitorPool* monitor_pool_; 627c33a32bccc4c66ed82ce3a580b16636399385cb4Elliott Hughes 628b557353b22c728eecbd1c68593b482622c7782a8Carl Shapiro ThreadList* thread_list_; 62961e019d291583029c01b61b93bea750f2b663c37Carl Shapiro 630cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes InternTable* intern_table_; 631cf4c6c41b0084dc4567ff709fb8ce9ebd72b26acElliott Hughes 632b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom ClassLinker* class_linker_; 633b0460eaa2cb131f1dbdd5a7217bd36b9a9f1b995Brian Carlstrom 634e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes SignalCatcher* signal_catcher_; 63594ce37a3919a0bdb8855a3d3264a50df1dbc41beElliott Hughes std::string stack_trace_file_; 636e27955ca3ca960928d4dbd6cb79711fce06950b3Elliott Hughes 637c5f7c91ab89055cffb573fff7e06dbdd860bccedElliott Hughes JavaVMExt* java_vm_; 638f2682d5a6ce0f7de58da8fd4ec8aec200c43b92eElliott Hughes 639e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier std::unique_ptr<jit::Jit> jit_; 640e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier std::unique_ptr<jit::JitOptions> jit_options_; 641e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 64215d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier // Fault message, printed when we get a SIGSEGV. 64315d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier Mutex fault_message_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; 64415d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier std::string fault_message_ GUARDED_BY(fault_message_lock_); 64515d3402bbf8265eb1165694da2e4117eb128f3bcMathieu Chartier 646120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // A non-zero value indicates that a thread has been created but not yet initialized. Guarded by 647120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // the shutdown lock so that threads aren't born while we're shutting down. 648120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers size_t threads_being_born_ GUARDED_BY(Locks::runtime_shutdown_lock_); 649120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 650120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // Waited upon until no threads are being born. 651700a402244a1a423da4f3ba8032459f4b65fa18fIan Rogers std::unique_ptr<ConditionVariable> shutdown_cond_ GUARDED_BY(Locks::runtime_shutdown_lock_); 652120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 653120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // Set when runtime shutdown is past the point that new threads may attach. 654120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers bool shutting_down_ GUARDED_BY(Locks::runtime_shutdown_lock_); 655120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 656120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers // The runtime is starting to shutdown but is blocked waiting on shutdown_cond_. 657120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers bool shutting_down_started_ GUARDED_BY(Locks::runtime_shutdown_lock_); 658120f1c74a9768e958377b6c97897511b27ae58c8Ian Rogers 659dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes bool started_; 660dcc247493fd8fb243e335c3ec08e5e625896a47cElliott Hughes 6617664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier // New flag added which tells us if the runtime has finished starting. If 6627664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier // this flag is set then the Daemon threads are created and the class loader 6637664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier // is created. This flag is needed for knowing if its safe to request CMS. 6647664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier bool finished_starting_; 6657664f5cd118b355a5fe0c7536cb48ac991ed2b62Mathieu Chartier 6666ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom // Hooks supported by JNI_CreateJavaVM 6676ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom jint (*vfprintf_)(FILE* stream, const char* format, va_list ap); 6686ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom void (*exit_)(jint status); 6696ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom void (*abort_)(); 6706ea095ad30bf13cc00b4fee7afbbe4731a349c83Brian Carlstrom 6719d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes bool stats_enabled_; 6729d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes RuntimeStats stats_; 6739d5ccec86d60c9ddd811836b9a2bc28d0b3d11feElliott Hughes 674da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier const bool running_on_valgrind_; 675da44d773dedf8aae6153e3423012f236cba3bfcdMathieu Chartier 6760aded089f565008ba5908e395e5914ca4f91f2deDave Allison std::string profile_output_filename_; 677c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle ProfilerOptions profiler_options_; 678c1b643cc6ac45dbd0eabdcd7425c7e86006c27d6Calin Juravle bool profiler_started_; 6790aded089f565008ba5908e395e5914ca4f91f2deDave Allison 680f6a780abeaed4bf745720e8f836a3064d3ffbec4Andreas Gampe std::unique_ptr<TraceConfig> trace_config_; 681f6a780abeaed4bf745720e8f836a3064d3ffbec4Andreas Gampe 68262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers instrumentation::Instrumentation instrumentation_; 683131aef8c94292cc530da2fd91ee98d1432352959Elliott Hughes 684365c10235438607541fa2259a5fec48061b90bd8Ian Rogers jobject main_thread_group_; 685365c10235438607541fa2259a5fec48061b90bd8Ian Rogers jobject system_thread_group_; 686365c10235438607541fa2259a5fec48061b90bd8Ian Rogers 687ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom // As returned by ClassLoader.getSystemClassLoader(). 688ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom jobject system_class_loader_; 689ce88853ab316c70ef7b598978a3609611db60552Brian Carlstrom 6902e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi // If true, then we dump the GC cumulative timings on shutdown. 6912e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi bool dump_gc_performance_on_shutdown_; 6922e899a92439dc6bdaaa67b8230933006284aa600Hiroshi Yamauchi 693d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz // Transaction used for pre-initializing classes at compilation time. 694ee1d79a603c77c0667b27c075a983579d5c51f7eSebastien Hertz Transaction* preinitialization_transaction_; 695d2fe10a3a34af171bf1631219cd2d6ff6b7778b5Sebastien Hertz 6964a200f56b7075309316b04d550c9cc50f8314eddJeff Hao // If false, verification is disabled. True by default. 6974a200f56b7075309316b04d550c9cc50f8314eddJeff Hao bool verify_; 6984a200f56b7075309316b04d550c9cc50f8314eddJeff Hao 69924e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler // If true, the runtime may use dex files directly with the interpreter if an oat file is not 70024e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler // available/usable. 70124e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler bool allow_dex_file_fallback_; 70224e04aa68c575d349eac0d9d09aab9bd3106ef94Jean Christophe Beyler 703785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov // List of supported cpu abis. 704785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov std::vector<std::string> cpu_abilist_; 705785049f8083e56e88dfeab5ff74fb3817f9854e3Dmitriy Ivanov 706f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao // Specifies target SDK version to allow workarounds for certain API levels. 707f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao int32_t target_sdk_version_; 708f00571c4e1ae202b3b4acb6b47cbe23a65178f7fJeff Hao 70969dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison // Implicit checks flags. 71069dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison bool implicit_null_checks_; // NullPointer checks are implicit. 71169dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison bool implicit_so_checks_; // StackOverflow checks are implicit. 71269dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison bool implicit_suspend_checks_; // Thread suspension checks are implicit. 71369dfe51b684dd9d510dbcb63295fe180f998efdeDave Allison 71407d83c7a25022064ac0a8dac4fe2a7a38681fa4bCalin Juravle // Whether or not a native bridge has been loaded. 715c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle // 716c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle // The native bridge allows running native code compiled for a foreign ISA. The way it works is, 717c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle // if standard dlopen fails to load native library associated with native activity, it calls to 718c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle // the native bridge to load it and then gets the trampoline for the entry to native activity. 71907d83c7a25022064ac0a8dac4fe2a7a38681fa4bCalin Juravle // 72007d83c7a25022064ac0a8dac4fe2a7a38681fa4bCalin Juravle // The option 'native_bridge_library_filename' specifies the name of the native bridge. 72107d83c7a25022064ac0a8dac4fe2a7a38681fa4bCalin Juravle // When non-empty the native bridge will be loaded from the given file. An empty value means 72207d83c7a25022064ac0a8dac4fe2a7a38681fa4bCalin Juravle // that there's no native bridge. 72307d83c7a25022064ac0a8dac4fe2a7a38681fa4bCalin Juravle bool is_native_bridge_loaded_; 724c8423521c1d1136c70b153479b7df3bf4fd7fc2aCalin Juravle 7255a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath // The maximum number of failed boots we allow before pruning the dalvik cache 7265a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath // and trying again. This option is only inspected when we're running as a 7275a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath // zygote. 7285a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath uint32_t zygote_max_failed_boots_; 7295a2be3f40125af8b25fbbd9d55dc968168c76ed7Narayan Kamath 730848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao MethodRefToStringInitRegMap method_ref_string_init_reg_map_; 731848f70a3d73833fc1bf3032a9ff6812e429661d9Jeff Hao 73261e019d291583029c01b61b93bea750f2b663c37Carl Shapiro DISALLOW_COPY_AND_ASSIGN(Runtime); 7337b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro}; 7346a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866fIan Rogersstd::ostream& operator<<(std::ostream& os, const Runtime::CalleeSaveType& rhs); 7357b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 7366b6b5f0e67ce03f38223a525612955663bc1799bCarl Shapiro} // namespace art 7377b21670581d13db32f1384a3b2692bcfc8f57320Carl Shapiro 738fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_RUNTIME_H_ 739