instrumentation.h revision 6ea1a0e2168c8d9b6d97c075c73a72d84080f45b
1725a957985171d712d5c048cc3d00ff14968784bjeffhao/* 2725a957985171d712d5c048cc3d00ff14968784bjeffhao * Copyright (C) 2011 The Android Open Source Project 3725a957985171d712d5c048cc3d00ff14968784bjeffhao * 4725a957985171d712d5c048cc3d00ff14968784bjeffhao * Licensed under the Apache License, Version 2.0 (the "License"); 5725a957985171d712d5c048cc3d00ff14968784bjeffhao * you may not use this file except in compliance with the License. 6725a957985171d712d5c048cc3d00ff14968784bjeffhao * You may obtain a copy of the License at 7725a957985171d712d5c048cc3d00ff14968784bjeffhao * 8725a957985171d712d5c048cc3d00ff14968784bjeffhao * http://www.apache.org/licenses/LICENSE-2.0 9725a957985171d712d5c048cc3d00ff14968784bjeffhao * 10725a957985171d712d5c048cc3d00ff14968784bjeffhao * Unless required by applicable law or agreed to in writing, software 11725a957985171d712d5c048cc3d00ff14968784bjeffhao * distributed under the License is distributed on an "AS IS" BASIS, 12725a957985171d712d5c048cc3d00ff14968784bjeffhao * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13725a957985171d712d5c048cc3d00ff14968784bjeffhao * See the License for the specific language governing permissions and 14725a957985171d712d5c048cc3d00ff14968784bjeffhao * limitations under the License. 15725a957985171d712d5c048cc3d00ff14968784bjeffhao */ 16725a957985171d712d5c048cc3d00ff14968784bjeffhao 17fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#ifndef ART_RUNTIME_INSTRUMENTATION_H_ 18fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#define ART_RUNTIME_INSTRUMENTATION_H_ 19725a957985171d712d5c048cc3d00ff14968784bjeffhao 20576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include <stdint.h> 21576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers#include <list> 22e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier#include <unordered_set> 23576ca0cd692c0b6ae70e776de91015b8ff000a08Ian Rogers 24d582fa4ea62083a7598dded5b82dc2198b3daac7Ian Rogers#include "arch/instruction_set.h" 25761600567d73b23324ae0251e871c15d6849ffd8Elliott Hughes#include "base/macros.h" 26719d1a33f6569864f529e5a3fff59e7bca97aad0Ian Rogers#include "base/mutex.h" 2794f7b49578b6aaa80de8ffed230648d601393905Hiroshi Yamauchi#include "gc_root.h" 280462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz#include "safe_map.h" 292dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers 30725a957985171d712d5c048cc3d00ff14968784bjeffhaonamespace art { 312dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogersnamespace mirror { 32ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom class Class; 33ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom class Object; 34ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom class Throwable; 3562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers} // namespace mirror 36c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartierclass ArtField; 37e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartierclass ArtMethod; 3862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersunion JValue; 39725a957985171d712d5c048cc3d00ff14968784bjeffhaoclass Thread; 40725a957985171d712d5c048cc3d00ff14968784bjeffhao 4162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersnamespace instrumentation { 42725a957985171d712d5c048cc3d00ff14968784bjeffhao 43ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz// Interpreter handler tables. 44ee1997a3b83334985e757f369c09e111b121661bSebastien Hertzenum InterpreterHandlerTable { 45ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz kMainHandlerTable = 0, // Main handler table: no suspend check, no instrumentation. 46ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz kAlternativeHandlerTable = 1, // Alternative handler table: suspend check and/or instrumentation 47ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz // enabled. 48ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz kNumHandlerTables 49ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz}; 50ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz 5140da286d3207d88ed8ff3f5caac4873874603428Andreas Gampe// Do we want to deoptimize for method entry and exit listeners or just try to intercept 5240da286d3207d88ed8ff3f5caac4873874603428Andreas Gampe// invocations? Deoptimization forces all code to run in the interpreter and considerably hurts the 5340da286d3207d88ed8ff3f5caac4873874603428Andreas Gampe// application's performance. 5440da286d3207d88ed8ff3f5caac4873874603428Andreas Gampestatic constexpr bool kDeoptimizeForAccurateMethodEntryExitListeners = true; 5540da286d3207d88ed8ff3f5caac4873874603428Andreas Gampe 5662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// Instrumentation event listener API. Registered listeners will get the appropriate call back for 5762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// the events they are listening for. The call backs supply the thread, method and dex_pc the event 5862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// occurred upon. The thread may or may not be Thread::Current(). 5962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersstruct InstrumentationListener { 6062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers InstrumentationListener() {} 6162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers virtual ~InstrumentationListener() {} 6262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 6362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Call-back for when a method is entered. 6462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers virtual void MethodEntered(Thread* thread, mirror::Object* this_object, 65e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, 6690443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier uint32_t dex_pc) SHARED_REQUIRES(Locks::mutator_lock_) = 0; 6762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 6862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Call-back for when a method is exited. 6962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers virtual void MethodExited(Thread* thread, mirror::Object* this_object, 70e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc, 7162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers const JValue& return_value) 7290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) = 0; 7362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 7462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Call-back for when a method is popped due to an exception throw. A method will either cause a 7562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // MethodExited call-back or a MethodUnwind call-back when its activation is removed. 7651db44a194bafc3810a41164a8b39614f10e79dfSebastien Hertz virtual void MethodUnwind(Thread* thread, mirror::Object* this_object, 77e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc) 7890443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) = 0; 7962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 8062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Call-back for when the dex pc moves in a method. 8162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers virtual void DexPcMoved(Thread* thread, mirror::Object* this_object, 82e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t new_dex_pc) 8390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) = 0; 8462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 853f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // Call-back for when we read from a field. 86e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier virtual void FieldRead(Thread* thread, mirror::Object* this_object, ArtMethod* method, 87c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier uint32_t dex_pc, ArtField* field) = 0; 883f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 893f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // Call-back for when we write into a field. 90e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier virtual void FieldWritten(Thread* thread, mirror::Object* this_object, ArtMethod* method, 91c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier uint32_t dex_pc, ArtField* field, const JValue& field_value) = 0; 923f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 9362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Call-back when an exception is caught. 9414691c5e786e8c2c5734f687e4c96217340771beNicolas Geoffray virtual void ExceptionCaught(Thread* thread, mirror::Throwable* exception_object) 9590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) = 0; 96e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 9781f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray // Call-back for when we execute a branch. 9881f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray virtual void Branch(Thread* thread, 9981f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray ArtMethod* method, 10081f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray uint32_t dex_pc, 10181f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray int32_t dex_pc_offset) 10290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) = 0; 1035550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray 1045550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray // Call-back for when we get an invokevirtual or an invokeinterface. 1055550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray virtual void InvokeVirtualOrInterface(Thread* thread, 1065550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray mirror::Object* this_object, 1075550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray ArtMethod* caller, 1085550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray uint32_t dex_pc, 1095550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray ArtMethod* callee) 1103fdb3fec5c36127d8568b2f89698906ba4b68576Mathieu Chartier REQUIRES(Roles::uninterruptible_) 1115550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray SHARED_REQUIRES(Locks::mutator_lock_) = 0; 112725a957985171d712d5c048cc3d00ff14968784bjeffhao}; 113725a957985171d712d5c048cc3d00ff14968784bjeffhao 11462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// Instrumentation is a catch-all for when extra information is required from the runtime. The 11562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// typical use for instrumentation is for profiling and debugging. Instrumentation may add stubs 11662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// to method entry and exit, it may also force execution to be switched to the interpreter and 11762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// trigger deoptimization. 118725a957985171d712d5c048cc3d00ff14968784bjeffhaoclass Instrumentation { 119725a957985171d712d5c048cc3d00ff14968784bjeffhao public: 12062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers enum InstrumentationEvent { 121e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kMethodEntered = 0x1, 122e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kMethodExited = 0x2, 123e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kMethodUnwind = 0x4, 124e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kDexPcMoved = 0x8, 125e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kFieldRead = 0x10, 126e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kFieldWritten = 0x20, 127e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier kExceptionCaught = 0x40, 12881f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray kBranch = 0x80, 1295550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray kInvokeVirtualOrInterface = 0x100, 13062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers }; 13162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 1320462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz enum class InstrumentationLevel { 1330462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz kInstrumentNothing, // execute without instrumentation 1340462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz kInstrumentWithInstrumentationStubs, // execute with instrumentation entry/exit stubs 1350462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz kInstrumentWithInterpreter // execute with interpreter 1360462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz }; 1370462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz 1383b05e9ba874449dbff65b01b8781001f7d93eea6Mathieu Chartier Instrumentation(); 13962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 14062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Add a listener to be notified of the masked together sent of instrumentation events. This 14162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // suspend the runtime to install stubs. You are expected to hold the mutator lock as a proxy 14262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // for saying you should have suspended all threads (installing stubs while threads are running 14362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // will break). 14462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void AddListener(InstrumentationListener* listener, uint32_t events) 14590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !Locks::classlinker_classes_lock_); 14662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 14762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Removes a listener possibly removing instrumentation stubs. 14862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void RemoveListener(InstrumentationListener* listener, uint32_t events) 14990443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !Locks::classlinker_classes_lock_); 15062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 151138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // Deoptimization. 152a76a6d4cb3dedec909bd927f20bc0ab23198a337Sebastien Hertz void EnableDeoptimization() 153aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_) 154aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!deoptimized_methods_lock_); 155aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier // Calls UndeoptimizeEverything which may visit class linker classes through ConfigureStubs. 1560462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz void DisableDeoptimization(const char* key) 157aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) 158aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!deoptimized_methods_lock_); 159aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier 160a76a6d4cb3dedec909bd927f20bc0ab23198a337Sebastien Hertz bool AreAllMethodsDeoptimized() const { 161a76a6d4cb3dedec909bd927f20bc0ab23198a337Sebastien Hertz return interpreter_stubs_installed_; 162a76a6d4cb3dedec909bd927f20bc0ab23198a337Sebastien Hertz } 16390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool ShouldNotifyMethodEnterExitEvents() const SHARED_REQUIRES(Locks::mutator_lock_); 164138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 165138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // Executes everything with interpreter. 1660462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz void DeoptimizeEverything(const char* key) 167aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) 168aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!Locks::thread_list_lock_, 169aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier !Locks::classlinker_classes_lock_, 17090443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !deoptimized_methods_lock_); 171138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 172aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier // Executes everything with compiled code (or interpreter if there is no code). May visit class 173aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier // linker classes through ConfigureStubs. 1740462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz void UndeoptimizeEverything(const char* key) 175aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) 176aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!Locks::thread_list_lock_, 177aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier !Locks::classlinker_classes_lock_, 17890443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !deoptimized_methods_lock_); 179138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 180138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // Deoptimize a method by forcing its execution with the interpreter. Nevertheless, a static 181138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // method (except a class initializer) set to the resolution trampoline will be deoptimized only 182138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // once its declaring class is initialized. 183e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void Deoptimize(ArtMethod* method) 18490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !deoptimized_methods_lock_); 185138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 186138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // Undeoptimze the method by restoring its entrypoints. Nevertheless, a static method 187138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // (except a class initializer) set to the resolution trampoline will be updated only once its 188138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // declaring class is initialized. 189e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void Undeoptimize(ArtMethod* method) 19090443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !deoptimized_methods_lock_); 191138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 1920462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // Indicates whether the method has been deoptimized so it is executed with the interpreter. 193e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier bool IsDeoptimized(ArtMethod* method) 19490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(!deoptimized_methods_lock_) SHARED_REQUIRES(Locks::mutator_lock_); 195138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 1960462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // Enable method tracing by installing instrumentation entry/exit stubs or interpreter. 1970462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz void EnableMethodTracing(const char* key, 1980462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz bool needs_interpreter = kDeoptimizeForAccurateMethodEntryExitListeners) 199aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) 200aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!Locks::thread_list_lock_, 201aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier !Locks::classlinker_classes_lock_, 20290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !deoptimized_methods_lock_); 203138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 2040462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // Disable method tracing by uninstalling instrumentation entry/exit stubs or interpreter. 2050462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz void DisableMethodTracing(const char* key) 206aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) 207aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!Locks::thread_list_lock_, 208aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier !Locks::classlinker_classes_lock_, 20990443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !deoptimized_methods_lock_); 210138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 211ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz InterpreterHandlerTable GetInterpreterHandlerTable() const 21290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 213ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz return interpreter_handler_table_; 214ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz } 215ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz 21690443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier void InstrumentQuickAllocEntryPoints() REQUIRES(!Locks::instrument_entrypoints_lock_); 21790443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier void UninstrumentQuickAllocEntryPoints() REQUIRES(!Locks::instrument_entrypoints_lock_); 2189ef78b59da51080882e47505896b420977fd79aeMathieu Chartier void InstrumentQuickAllocEntryPointsLocked() 21990443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(Locks::instrument_entrypoints_lock_, !Locks::thread_list_lock_, 22090443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !Locks::runtime_shutdown_lock_); 2219ef78b59da51080882e47505896b420977fd79aeMathieu Chartier void UninstrumentQuickAllocEntryPointsLocked() 22290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(Locks::instrument_entrypoints_lock_, !Locks::thread_list_lock_, 22390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !Locks::runtime_shutdown_lock_); 22490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier void ResetQuickAllocEntryPoints() REQUIRES(Locks::runtime_shutdown_lock_); 225fa82427c68b09f4aedbee319dc71579afbfc66f5Ian Rogers 22662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Update the code of a method respecting any installed stubs. 227e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void UpdateMethodsCode(ArtMethod* method, const void* quick_code) 22890443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!deoptimized_methods_lock_); 22962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 23062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Get the quick code for the given method. More efficient than asking the class linker as it 23162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // will short-cut to GetCode if instrumentation and static method resolution stubs aren't 23262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // installed. 233e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier const void* GetQuickCodeFor(ArtMethod* method, size_t pointer_size) const 23490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 23562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 23662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void ForceInterpretOnly() { 23762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers interpret_only_ = true; 23862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers forced_interpret_only_ = true; 23962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 24062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 241ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom // Called by ArtMethod::Invoke to determine dispatch mechanism. 24262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool InterpretOnly() const { 24362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return interpret_only_; 24462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 24562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 246563b47cc142e477da244539b1d63070425e7fd78Hiroshi Yamauchi bool IsForcedInterpretOnly() const { 247563b47cc142e477da244539b1d63070425e7fd78Hiroshi Yamauchi return forced_interpret_only_; 248563b47cc142e477da244539b1d63070425e7fd78Hiroshi Yamauchi } 249563b47cc142e477da244539b1d63070425e7fd78Hiroshi Yamauchi 2506ea1a0e2168c8d9b6d97c075c73a72d84080f45bMingyao Yang // Code is in boot image oat file which isn't compiled as debuggable. 2516ea1a0e2168c8d9b6d97c075c73a72d84080f45bMingyao Yang // Need debug version (interpreter or jitted) if that's the case. 2526ea1a0e2168c8d9b6d97c075c73a72d84080f45bMingyao Yang bool NeedDebugVersionForBootImageCode(ArtMethod* method, const void* code) const 2536ea1a0e2168c8d9b6d97c075c73a72d84080f45bMingyao Yang SHARED_REQUIRES(Locks::mutator_lock_); 2546ea1a0e2168c8d9b6d97c075c73a72d84080f45bMingyao Yang 25562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool AreExitStubsInstalled() const { 25662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return instrumentation_stubs_installed_; 25762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 25862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 25990443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasMethodEntryListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 26074109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz return have_method_entry_listeners_; 26174109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz } 26274109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz 26390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasMethodExitListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 26474109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz return have_method_exit_listeners_; 26574109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz } 26674109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz 26790443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasMethodUnwindListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 2680462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz return have_method_unwind_listeners_; 2690462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz } 2700462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz 27190443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasDexPcListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 27274109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz return have_dex_pc_listeners_; 27374109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz } 27474109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz 27590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasFieldReadListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 2763f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz return have_field_read_listeners_; 2773f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz } 2783f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 27990443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasFieldWriteListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 2803f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz return have_field_write_listeners_; 2813f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz } 2823f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 28390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool HasExceptionCaughtListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 2849f1020305292a21fd14a402b189c765a125226abSebastien Hertz return have_exception_caught_listeners_; 2859f1020305292a21fd14a402b189c765a125226abSebastien Hertz } 2869f1020305292a21fd14a402b189c765a125226abSebastien Hertz 28781f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray bool HasBranchListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 28881f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray return have_branch_listeners_; 289e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier } 290e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 2915550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray bool HasInvokeVirtualOrInterfaceListeners() const SHARED_REQUIRES(Locks::mutator_lock_) { 2925550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray return have_invoke_virtual_or_interface_listeners_; 2935550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray } 2945550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray 29590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier bool IsActive() const SHARED_REQUIRES(Locks::mutator_lock_) { 296ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz return have_dex_pc_listeners_ || have_method_entry_listeners_ || have_method_exit_listeners_ || 29742cd43fa593e8f0427eb0ec158bef08814a6180bSebastien Hertz have_field_read_listeners_ || have_field_write_listeners_ || 298fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee have_exception_caught_listeners_ || have_method_unwind_listeners_ || 299fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee have_branch_listeners_ || have_invoke_virtual_or_interface_listeners_; 300fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee } 301fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee 302fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee // Any instrumentation *other* than what is needed for Jit profiling active? 303fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee bool NonJitProfilingActive() const SHARED_REQUIRES(Locks::mutator_lock_) { 304fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee return have_dex_pc_listeners_ || have_method_exit_listeners_ || 305fd522f9039befff986701ff05054ffdd1be1dd33Bill Buzbee have_field_read_listeners_ || have_field_write_listeners_ || 306ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz have_exception_caught_listeners_ || have_method_unwind_listeners_; 307ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz } 308ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz 30962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Inform listeners that a method has been entered. A dex PC is provided as we may install 31062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // listeners into executing code and get method enter events for methods already on the stack. 31162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void MethodEnterEvent(Thread* thread, mirror::Object* this_object, 312e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc) const 31390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 31474109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz if (UNLIKELY(HasMethodEntryListeners())) { 31562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers MethodEnterEventImpl(thread, this_object, method, dex_pc); 31662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 31762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 31862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 31962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Inform listeners that a method has been exited. 32062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void MethodExitEvent(Thread* thread, mirror::Object* this_object, 321e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc, 32262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers const JValue& return_value) const 32390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 32474109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz if (UNLIKELY(HasMethodExitListeners())) { 32562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers MethodExitEventImpl(thread, this_object, method, dex_pc, return_value); 32662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 32762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 32862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 32962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Inform listeners that a method has been exited due to an exception. 33062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void MethodUnwindEvent(Thread* thread, mirror::Object* this_object, 331e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc) const 33290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 33362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 33462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Inform listeners that the dex pc has moved (only supported by the interpreter). 33562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void DexPcMovedEvent(Thread* thread, mirror::Object* this_object, 336e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc) const 33790443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 33874109f6683096de494b1457fa6d5b0ac33b4c98cSebastien Hertz if (UNLIKELY(HasDexPcListeners())) { 33962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers DexPcMovedEventImpl(thread, this_object, method, dex_pc); 34062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 34162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 342725a957985171d712d5c048cc3d00ff14968784bjeffhao 34381f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray // Inform listeners that a branch has been taken (only supported by the interpreter). 34481f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray void Branch(Thread* thread, ArtMethod* method, uint32_t dex_pc, int32_t offset) const 34590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 34681f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray if (UNLIKELY(HasBranchListeners())) { 34781f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray BranchImpl(thread, method, dex_pc, offset); 348e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier } 349e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier } 350e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 3513f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // Inform listeners that we read a field (only supported by the interpreter). 3523f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz void FieldReadEvent(Thread* thread, mirror::Object* this_object, 353e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc, 354c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier ArtField* field) const 35590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 3563f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz if (UNLIKELY(HasFieldReadListeners())) { 3573f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz FieldReadEventImpl(thread, this_object, method, dex_pc, field); 3583f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz } 3593f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz } 3603f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 3613f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // Inform listeners that we write a field (only supported by the interpreter). 3623f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz void FieldWriteEvent(Thread* thread, mirror::Object* this_object, 363e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc, 364c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier ArtField* field, const JValue& field_value) const 36590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) { 3663f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz if (UNLIKELY(HasFieldWriteListeners())) { 3673f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz FieldWriteEventImpl(thread, this_object, method, dex_pc, field, field_value); 3683f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz } 3693f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz } 3703f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 3715550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray void InvokeVirtualOrInterface(Thread* thread, 3725550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray mirror::Object* this_object, 3735550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray ArtMethod* caller, 3745550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray uint32_t dex_pc, 3755550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray ArtMethod* callee) const 3765550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray SHARED_REQUIRES(Locks::mutator_lock_) { 3775550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray if (UNLIKELY(HasInvokeVirtualOrInterfaceListeners())) { 3785550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray InvokeVirtualOrInterfaceImpl(thread, this_object, caller, dex_pc, callee); 3795550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray } 3805550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray } 3815550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray 38262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Inform listeners that an exception was caught. 38314691c5e786e8c2c5734f687e4c96217340771beNicolas Geoffray void ExceptionCaughtEvent(Thread* thread, mirror::Throwable* exception_object) const 38490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 385725a957985171d712d5c048cc3d00ff14968784bjeffhao 38662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Called when an instrumented method is entered. The intended link register (lr) is saved so 38762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // that returning causes a branch to the method exit stub. Generates method enter events. 38862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object, 389e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uintptr_t lr, 3909a916d3c0d0574d106c764e737c67b52988d6139Jeff Hao bool interpreter_entry) 39190443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 392725a957985171d712d5c048cc3d00ff14968784bjeffhao 39362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Called when an instrumented method is exited. Removes the pushed instrumentation frame 39462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // returning the intended link register. Generates method exit events. 395d58342caa97108ba413bad467c285c0377f138f5Andreas Gampe TwoWordReturn PopInstrumentationStackFrame(Thread* self, uintptr_t* return_pc, 396d58342caa97108ba413bad467c285c0377f138f5Andreas Gampe uint64_t gpr_result, uint64_t fpr_result) 39790443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!deoptimized_methods_lock_); 398725a957985171d712d5c048cc3d00ff14968784bjeffhao 39962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Pops an instrumentation frame from the current thread and generate an unwind event. 40062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void PopMethodForUnwind(Thread* self, bool is_deoptimization) const 40190443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 40262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 40362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Call back for configure stubs. 40490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier void InstallStubsForClass(mirror::Class* klass) SHARED_REQUIRES(Locks::mutator_lock_) 40590443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier REQUIRES(!deoptimized_methods_lock_); 406725a957985171d712d5c048cc3d00ff14968784bjeffhao 407e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier void InstallStubsForMethod(ArtMethod* method) 40890443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!deoptimized_methods_lock_); 409138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 41099170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang // Install instrumentation exit stub on every method of the stack of the given thread. 41199170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang // This is used by the debugger to cause a deoptimization of the thread's stack after updating 41299170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang // local variable(s). 41399170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang void InstrumentThreadStack(Thread* thread) 41499170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang SHARED_REQUIRES(Locks::mutator_lock_) 41599170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang REQUIRES(!Locks::thread_list_lock_); 41699170c636dfae4908b102347cfe9f92bad1881ccMingyao Yang 417b2feaafd89813af69c65da95e0b51b1a4cecaf0bSebastien Hertz static size_t ComputeFrameId(Thread* self, 418b2feaafd89813af69c65da95e0b51b1a4cecaf0bSebastien Hertz size_t frame_depth, 419b2feaafd89813af69c65da95e0b51b1a4cecaf0bSebastien Hertz size_t inlined_frames_before_frame) 420b2feaafd89813af69c65da95e0b51b1a4cecaf0bSebastien Hertz SHARED_REQUIRES(Locks::mutator_lock_); 421b2feaafd89813af69c65da95e0b51b1a4cecaf0bSebastien Hertz 422725a957985171d712d5c048cc3d00ff14968784bjeffhao private: 4230462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz InstrumentationLevel GetCurrentInstrumentationLevel() const; 4240462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz 42562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Does the job of installing or removing instrumentation code within methods. 4260462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // In order to support multiple clients using instrumentation at the same time, 4270462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // the caller must pass a unique key (a string) identifying it so we remind which 4280462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // instrumentation level it needs. Therefore the current instrumentation level 4290462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // becomes the highest instrumentation level required by a client. 4300462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz void ConfigureStubs(const char* key, InstrumentationLevel desired_instrumentation_level) 431aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_) 432aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier REQUIRES(!deoptimized_methods_lock_, 433aa5168291c46f9b418d989bccf2d8e09338a83e6Mathieu Chartier !Locks::thread_list_lock_, 43490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier !Locks::classlinker_classes_lock_); 43562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 43690443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier void UpdateInterpreterHandlerTable() REQUIRES(Locks::mutator_lock_) { 4371452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee /* 4381452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee * TUNING: Dalvik's mterp stashes the actual current handler table base in a 4391452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee * tls field. For Arm, this enables all suspend, debug & tracing checks to be 4401452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee * collapsed into a single conditionally-executed ldw instruction. 4411452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee * Move to Dalvik-style handler-table management for both the goto interpreter and 4421452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee * mterp. 4431452bee8f06b9f76a333ddf4760e4beaa82f8099buzbee */ 444ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz interpreter_handler_table_ = IsActive() ? kAlternativeHandlerTable : kMainHandlerTable; 445ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz } 446ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz 447661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier // No thread safety analysis to get around SetQuickAllocEntryPointsInstrumented requiring 448661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier // exclusive access to mutator lock which you can't get if the runtime isn't started. 4499ef78b59da51080882e47505896b420977fd79aeMathieu Chartier void SetEntrypointsInstrumented(bool instrumented) NO_THREAD_SAFETY_ANALYSIS; 450661974a5561e5ccdfbac8cb5d8df8b7e6f3483b8Mathieu Chartier 45162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void MethodEnterEventImpl(Thread* thread, mirror::Object* this_object, 452e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc) const 45390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 45462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void MethodExitEventImpl(Thread* thread, mirror::Object* this_object, 455e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, 45662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers uint32_t dex_pc, const JValue& return_value) const 45790443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 45862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers void DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object, 459e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc) const 46090443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 46181f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray void BranchImpl(Thread* thread, ArtMethod* method, uint32_t dex_pc, int32_t offset) const 46290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 4635550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray void InvokeVirtualOrInterfaceImpl(Thread* thread, 4645550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray mirror::Object* this_object, 4655550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray ArtMethod* caller, 4665550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray uint32_t dex_pc, 4675550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray ArtMethod* callee) const 4685550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray SHARED_REQUIRES(Locks::mutator_lock_); 4693f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz void FieldReadEventImpl(Thread* thread, mirror::Object* this_object, 470e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc, 471c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier ArtField* field) const 47290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 4733f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz void FieldWriteEventImpl(Thread* thread, mirror::Object* this_object, 474e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method, uint32_t dex_pc, 475c785344b87221f5e4e6473e5b762e4e61fe65dcfMathieu Chartier ArtField* field, const JValue& field_value) const 47690443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_); 47762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 478799eb3a5555254427db269921042419bc30d4d86Hiroshi Yamauchi // Read barrier-aware utility functions for accessing deoptimized_methods_ 479e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier bool AddDeoptimizedMethod(ArtMethod* method) 48090443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(deoptimized_methods_lock_); 481e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier bool IsDeoptimizedMethod(ArtMethod* method) 48290443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_, deoptimized_methods_lock_); 483e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier bool RemoveDeoptimizedMethod(ArtMethod* method) 48490443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(deoptimized_methods_lock_); 485e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* BeginDeoptimizedMethod() 48690443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_, deoptimized_methods_lock_); 487799eb3a5555254427db269921042419bc30d4d86Hiroshi Yamauchi bool IsDeoptimizedMethodsEmpty() const 48890443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier SHARED_REQUIRES(Locks::mutator_lock_, deoptimized_methods_lock_); 489799eb3a5555254427db269921042419bc30d4d86Hiroshi Yamauchi 490ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom // Have we hijacked ArtMethod::code_ so that it calls instrumentation/interpreter code? 49162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool instrumentation_stubs_installed_; 49262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 493ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom // Have we hijacked ArtMethod::code_ to reference the enter/exit stubs? 49462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool entry_exit_stubs_installed_; 49562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 496ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom // Have we hijacked ArtMethod::code_ to reference the enter interpreter stub? 49762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool interpreter_stubs_installed_; 49862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 49962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Do we need the fidelity of events that we only get from running within the interpreter? 50062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool interpret_only_; 501725a957985171d712d5c048cc3d00ff14968784bjeffhao 50262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Did the runtime request we only run in the interpreter? ie -Xint mode. 50362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool forced_interpret_only_; 504725a957985171d712d5c048cc3d00ff14968784bjeffhao 50562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Do we have any listeners for method entry events? Short-cut to avoid taking the 50662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // instrumentation_lock_. 507ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_method_entry_listeners_ GUARDED_BY(Locks::mutator_lock_); 50862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 50962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Do we have any listeners for method exit events? Short-cut to avoid taking the 51062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // instrumentation_lock_. 511ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_method_exit_listeners_ GUARDED_BY(Locks::mutator_lock_); 51262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 51362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Do we have any listeners for method unwind events? Short-cut to avoid taking the 51462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // instrumentation_lock_. 515ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_method_unwind_listeners_ GUARDED_BY(Locks::mutator_lock_); 51662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 51762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Do we have any listeners for dex move events? Short-cut to avoid taking the 51862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // instrumentation_lock_. 519ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_dex_pc_listeners_ GUARDED_BY(Locks::mutator_lock_); 52062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 5213f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // Do we have any listeners for field read events? Short-cut to avoid taking the 5223f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // instrumentation_lock_. 523ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_field_read_listeners_ GUARDED_BY(Locks::mutator_lock_); 5243f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 5253f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // Do we have any listeners for field write events? Short-cut to avoid taking the 5263f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz // instrumentation_lock_. 527ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_field_write_listeners_ GUARDED_BY(Locks::mutator_lock_); 5283f52eafe5577b8489f90dc8ed5981b3455206147Sebastien Hertz 52962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Do we have any exception caught listeners? Short-cut to avoid taking the instrumentation_lock_. 530ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz bool have_exception_caught_listeners_ GUARDED_BY(Locks::mutator_lock_); 53162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 53281f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray // Do we have any branch listeners? Short-cut to avoid taking the instrumentation_lock_. 53381f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray bool have_branch_listeners_ GUARDED_BY(Locks::mutator_lock_); 534e5f13e57ff8fa36342beb33830b3ec5942a61ccaMathieu Chartier 5355550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray // Do we have any invoke listeners? Short-cut to avoid taking the instrumentation_lock_. 5365550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray bool have_invoke_virtual_or_interface_listeners_ GUARDED_BY(Locks::mutator_lock_); 5375550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray 5380462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // Contains the instrumentation level required by each client of the instrumentation identified 5390462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz // by a string key. 5400462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz typedef SafeMap<const char*, InstrumentationLevel> InstrumentationLevelTable; 5410462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz InstrumentationLevelTable requested_instrumentation_levels_ GUARDED_BY(Locks::mutator_lock_); 5420462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz 54362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // The event listeners, written to with the mutator_lock_ exclusively held. 544514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // Mutators must be able to iterate over these lists concurrently, that is, with listeners being 545514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // added or removed while iterating. The modifying thread holds exclusive lock, 546514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // so other threads cannot iterate (i.e. read the data of the list) at the same time but they 547514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // do keep iterators that need to remain valid. This is the reason these listeners are std::list 548514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // and not for example std::vector: the existing storage for a std::list does not move. 549514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // Note that mutators cannot make a copy of these lists before iterating, as the instrumentation 550514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // listeners can also be deleted concurrently. 551514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // As a result, these lists are never trimmed. That's acceptable given the low number of 552514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray // listeners we have. 55362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers std::list<InstrumentationListener*> method_entry_listeners_ GUARDED_BY(Locks::mutator_lock_); 55462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers std::list<InstrumentationListener*> method_exit_listeners_ GUARDED_BY(Locks::mutator_lock_); 55562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers std::list<InstrumentationListener*> method_unwind_listeners_ GUARDED_BY(Locks::mutator_lock_); 55681f0f953c4bb159997046c962d44cb1898b1778dNicolas Geoffray std::list<InstrumentationListener*> branch_listeners_ GUARDED_BY(Locks::mutator_lock_); 5575550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray std::list<InstrumentationListener*> invoke_virtual_or_interface_listeners_ 5585550ca8bcc742b109d77e62f3a0877c667d894d3Nicolas Geoffray GUARDED_BY(Locks::mutator_lock_); 559514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray std::list<InstrumentationListener*> dex_pc_listeners_ GUARDED_BY(Locks::mutator_lock_); 560514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray std::list<InstrumentationListener*> field_read_listeners_ GUARDED_BY(Locks::mutator_lock_); 561514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray std::list<InstrumentationListener*> field_write_listeners_ GUARDED_BY(Locks::mutator_lock_); 562514a616fd434212815bdd49cc1e2786817395969Nicolas Geoffray std::list<InstrumentationListener*> exception_caught_listeners_ GUARDED_BY(Locks::mutator_lock_); 563725a957985171d712d5c048cc3d00ff14968784bjeffhao 564138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // The set of methods being deoptimized (by the debugger) which must be executed with interpreter 565138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz // only. 5663b05e9ba874449dbff65b01b8781001f7d93eea6Mathieu Chartier mutable ReaderWriterMutex deoptimized_methods_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER; 567e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier std::unordered_set<ArtMethod*> deoptimized_methods_ GUARDED_BY(deoptimized_methods_lock_); 56811d40c250ec86c784cf76b8c31e1cf9285d555dcSebastien Hertz bool deoptimization_enabled_; 569138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz 570fa82427c68b09f4aedbee319dc71579afbfc66f5Ian Rogers // Current interpreter handler table. This is updated each time the thread state flags are 571fa82427c68b09f4aedbee319dc71579afbfc66f5Ian Rogers // modified. 572ed2be1725fb79075892b1a9103487c9d9a95b350Sebastien Hertz InterpreterHandlerTable interpreter_handler_table_ GUARDED_BY(Locks::mutator_lock_); 573ee1997a3b83334985e757f369c09e111b121661bSebastien Hertz 574fa82427c68b09f4aedbee319dc71579afbfc66f5Ian Rogers // Greater than 0 if quick alloc entry points instrumented. 5759ef78b59da51080882e47505896b420977fd79aeMathieu Chartier size_t quick_alloc_entry_points_instrumentation_counter_ 5769ef78b59da51080882e47505896b420977fd79aeMathieu Chartier GUARDED_BY(Locks::instrument_entrypoints_lock_); 577fa82427c68b09f4aedbee319dc71579afbfc66f5Ian Rogers 5780462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz friend class InstrumentationTest; // For GetCurrentInstrumentationLevel and ConfigureStubs. 5790462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertz 580725a957985171d712d5c048cc3d00ff14968784bjeffhao DISALLOW_COPY_AND_ASSIGN(Instrumentation); 581725a957985171d712d5c048cc3d00ff14968784bjeffhao}; 5826a3c1fcb4ba42ad4d5d142c17a3712a6ddd3866fIan Rogersstd::ostream& operator<<(std::ostream& os, const Instrumentation::InstrumentationEvent& rhs); 5830462c4c87c39db6cfcd338f323844738109ac3c9Sebastien Hertzstd::ostream& operator<<(std::ostream& os, const Instrumentation::InstrumentationLevel& rhs); 584725a957985171d712d5c048cc3d00ff14968784bjeffhao 58562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers// An element in the instrumentation side stack maintained in art::Thread. 58662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersstruct InstrumentationStackFrame { 587e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier InstrumentationStackFrame(mirror::Object* this_object, ArtMethod* method, 5889a916d3c0d0574d106c764e737c67b52988d6139Jeff Hao uintptr_t return_pc, size_t frame_id, bool interpreter_entry) 5899a916d3c0d0574d106c764e737c67b52988d6139Jeff Hao : this_object_(this_object), method_(method), return_pc_(return_pc), frame_id_(frame_id), 5909a916d3c0d0574d106c764e737c67b52988d6139Jeff Hao interpreter_entry_(interpreter_entry) { 59162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 59262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 59390443477f9a0061581c420775ce3b7eeae7468bcMathieu Chartier std::string Dump() const SHARED_REQUIRES(Locks::mutator_lock_); 59462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 59562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers mirror::Object* this_object_; 596e401d146407d61eeb99f8d6176b2ac13c4df1e33Mathieu Chartier ArtMethod* method_; 597138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz uintptr_t return_pc_; 598138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz size_t frame_id_; 599138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz bool interpreter_entry_; 60062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers}; 60162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 60262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers} // namespace instrumentation 603725a957985171d712d5c048cc3d00ff14968784bjeffhao} // namespace art 604725a957985171d712d5c048cc3d00ff14968784bjeffhao 605fc0e3219edc9a5bf81b166e82fd5db2796eb6a0dBrian Carlstrom#endif // ART_RUNTIME_INSTRUMENTATION_H_ 606