blob: 2e4be6b689513a5aa4a4312bcad2dc313e2e9170 [file] [log] [blame]
jeffhao725a9572012-11-13 18:20:12 -08001/*
2 * Copyright (C) 2011 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
Brian Carlstromfc0e3212013-07-17 14:40:12 -070017#ifndef ART_RUNTIME_INSTRUMENTATION_H_
18#define ART_RUNTIME_INSTRUMENTATION_H_
jeffhao725a9572012-11-13 18:20:12 -080019
Ian Rogers576ca0c2014-06-06 15:58:22 -070020#include <stdint.h>
Ian Rogers576ca0c2014-06-06 15:58:22 -070021#include <list>
Mathieu Chartiere401d142015-04-22 13:56:20 -070022#include <unordered_set>
Ian Rogers576ca0c2014-06-06 15:58:22 -070023
Ian Rogersd582fa42014-11-05 23:46:43 -080024#include "arch/instruction_set.h"
Elliott Hughes76160052012-12-12 16:31:20 -080025#include "base/macros.h"
Ian Rogers719d1a32014-03-06 12:13:39 -080026#include "base/mutex.h"
Hiroshi Yamauchi94f7b492014-07-22 18:08:23 -070027#include "gc_root.h"
Sebastien Hertz0462c4c2015-04-01 16:34:17 +020028#include "safe_map.h"
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080029
jeffhao725a9572012-11-13 18:20:12 -080030namespace art {
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080031namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070032 class Class;
33 class Object;
34 class Throwable;
Ian Rogers62d6c772013-02-27 08:32:07 -080035} // namespace mirror
Mathieu Chartierc7853442015-03-27 14:35:38 -070036class ArtField;
Mathieu Chartiere401d142015-04-22 13:56:20 -070037class ArtMethod;
Ian Rogers62d6c772013-02-27 08:32:07 -080038union JValue;
jeffhao725a9572012-11-13 18:20:12 -080039class Thread;
40
Ian Rogers62d6c772013-02-27 08:32:07 -080041namespace instrumentation {
jeffhao725a9572012-11-13 18:20:12 -080042
Sebastien Hertzee1997a2013-09-19 14:47:09 +020043// Interpreter handler tables.
44enum InterpreterHandlerTable {
45 kMainHandlerTable = 0, // Main handler table: no suspend check, no instrumentation.
46 kAlternativeHandlerTable = 1, // Alternative handler table: suspend check and/or instrumentation
47 // enabled.
48 kNumHandlerTables
49};
50
Andreas Gampe40da2862015-02-27 12:49:04 -080051// Do we want to deoptimize for method entry and exit listeners or just try to intercept
52// invocations? Deoptimization forces all code to run in the interpreter and considerably hurts the
53// application's performance.
54static constexpr bool kDeoptimizeForAccurateMethodEntryExitListeners = true;
55
Ian Rogers62d6c772013-02-27 08:32:07 -080056// Instrumentation event listener API. Registered listeners will get the appropriate call back for
57// the events they are listening for. The call backs supply the thread, method and dex_pc the event
58// occurred upon. The thread may or may not be Thread::Current().
59struct InstrumentationListener {
60 InstrumentationListener() {}
61 virtual ~InstrumentationListener() {}
62
63 // Call-back for when a method is entered.
64 virtual void MethodEntered(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -070065 ArtMethod* method,
Mathieu Chartier90443472015-07-16 20:32:27 -070066 uint32_t dex_pc) SHARED_REQUIRES(Locks::mutator_lock_) = 0;
Ian Rogers62d6c772013-02-27 08:32:07 -080067
68 // Call-back for when a method is exited.
Ian Rogers62d6c772013-02-27 08:32:07 -080069 virtual void MethodExited(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -070070 ArtMethod* method, uint32_t dex_pc,
Ian Rogers62d6c772013-02-27 08:32:07 -080071 const JValue& return_value)
Mathieu Chartier90443472015-07-16 20:32:27 -070072 SHARED_REQUIRES(Locks::mutator_lock_) = 0;
Ian Rogers62d6c772013-02-27 08:32:07 -080073
74 // Call-back for when a method is popped due to an exception throw. A method will either cause a
75 // MethodExited call-back or a MethodUnwind call-back when its activation is removed.
Sebastien Hertz51db44a2013-11-19 10:00:29 +010076 virtual void MethodUnwind(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -070077 ArtMethod* method, uint32_t dex_pc)
Mathieu Chartier90443472015-07-16 20:32:27 -070078 SHARED_REQUIRES(Locks::mutator_lock_) = 0;
Ian Rogers62d6c772013-02-27 08:32:07 -080079
80 // Call-back for when the dex pc moves in a method.
81 virtual void DexPcMoved(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -070082 ArtMethod* method, uint32_t new_dex_pc)
Mathieu Chartier90443472015-07-16 20:32:27 -070083 SHARED_REQUIRES(Locks::mutator_lock_) = 0;
Ian Rogers62d6c772013-02-27 08:32:07 -080084
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +020085 // Call-back for when we read from a field.
Mathieu Chartiere401d142015-04-22 13:56:20 -070086 virtual void FieldRead(Thread* thread, mirror::Object* this_object, ArtMethod* method,
Mathieu Chartierc7853442015-03-27 14:35:38 -070087 uint32_t dex_pc, ArtField* field) = 0;
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +020088
89 // Call-back for when we write into a field.
Mathieu Chartiere401d142015-04-22 13:56:20 -070090 virtual void FieldWritten(Thread* thread, mirror::Object* this_object, ArtMethod* method,
Mathieu Chartierc7853442015-03-27 14:35:38 -070091 uint32_t dex_pc, ArtField* field, const JValue& field_value) = 0;
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +020092
Ian Rogers62d6c772013-02-27 08:32:07 -080093 // Call-back when an exception is caught.
Nicolas Geoffray14691c52015-03-05 10:40:17 +000094 virtual void ExceptionCaught(Thread* thread, mirror::Throwable* exception_object)
Mathieu Chartier90443472015-07-16 20:32:27 -070095 SHARED_REQUIRES(Locks::mutator_lock_) = 0;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -080096
Nicolas Geoffray81f0f952016-01-20 16:25:19 +000097 // Call-back for when we execute a branch.
98 virtual void Branch(Thread* thread,
99 ArtMethod* method,
100 uint32_t dex_pc,
101 int32_t dex_pc_offset)
Mathieu Chartier90443472015-07-16 20:32:27 -0700102 SHARED_REQUIRES(Locks::mutator_lock_) = 0;
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100103
104 // Call-back for when we get an invokevirtual or an invokeinterface.
105 virtual void InvokeVirtualOrInterface(Thread* thread,
106 mirror::Object* this_object,
107 ArtMethod* caller,
108 uint32_t dex_pc,
109 ArtMethod* callee)
Mathieu Chartier3fdb3fe2016-01-14 10:24:28 -0800110 REQUIRES(Roles::uninterruptible_)
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100111 SHARED_REQUIRES(Locks::mutator_lock_) = 0;
jeffhao725a9572012-11-13 18:20:12 -0800112};
113
Ian Rogers62d6c772013-02-27 08:32:07 -0800114// Instrumentation is a catch-all for when extra information is required from the runtime. The
115// typical use for instrumentation is for profiling and debugging. Instrumentation may add stubs
116// to method entry and exit, it may also force execution to be switched to the interpreter and
117// trigger deoptimization.
jeffhao725a9572012-11-13 18:20:12 -0800118class Instrumentation {
119 public:
Ian Rogers62d6c772013-02-27 08:32:07 -0800120 enum InstrumentationEvent {
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800121 kMethodEntered = 0x1,
122 kMethodExited = 0x2,
123 kMethodUnwind = 0x4,
124 kDexPcMoved = 0x8,
125 kFieldRead = 0x10,
126 kFieldWritten = 0x20,
127 kExceptionCaught = 0x40,
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000128 kBranch = 0x80,
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100129 kInvokeVirtualOrInterface = 0x100,
Ian Rogers62d6c772013-02-27 08:32:07 -0800130 };
jeffhao725a9572012-11-13 18:20:12 -0800131
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200132 enum class InstrumentationLevel {
133 kInstrumentNothing, // execute without instrumentation
134 kInstrumentWithInstrumentationStubs, // execute with instrumentation entry/exit stubs
135 kInstrumentWithInterpreter // execute with interpreter
136 };
137
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700138 Instrumentation();
jeffhao725a9572012-11-13 18:20:12 -0800139
Ian Rogers62d6c772013-02-27 08:32:07 -0800140 // Add a listener to be notified of the masked together sent of instrumentation events. This
141 // suspend the runtime to install stubs. You are expected to hold the mutator lock as a proxy
142 // for saying you should have suspended all threads (installing stubs while threads are running
143 // will break).
144 void AddListener(InstrumentationListener* listener, uint32_t events)
Mathieu Chartier90443472015-07-16 20:32:27 -0700145 REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !Locks::classlinker_classes_lock_);
jeffhao725a9572012-11-13 18:20:12 -0800146
Ian Rogers62d6c772013-02-27 08:32:07 -0800147 // Removes a listener possibly removing instrumentation stubs.
148 void RemoveListener(InstrumentationListener* listener, uint32_t events)
Mathieu Chartier90443472015-07-16 20:32:27 -0700149 REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !Locks::classlinker_classes_lock_);
jeffhao725a9572012-11-13 18:20:12 -0800150
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100151 // Deoptimization.
Sebastien Hertza76a6d42014-03-20 16:40:17 +0100152 void EnableDeoptimization()
Mathieu Chartieraa516822015-10-02 15:53:37 -0700153 REQUIRES(Locks::mutator_lock_)
154 REQUIRES(!deoptimized_methods_lock_);
155 // Calls UndeoptimizeEverything which may visit class linker classes through ConfigureStubs.
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200156 void DisableDeoptimization(const char* key)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700157 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
158 REQUIRES(!deoptimized_methods_lock_);
159
Sebastien Hertza76a6d42014-03-20 16:40:17 +0100160 bool AreAllMethodsDeoptimized() const {
161 return interpreter_stubs_installed_;
162 }
Mathieu Chartier90443472015-07-16 20:32:27 -0700163 bool ShouldNotifyMethodEnterExitEvents() const SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100164
165 // Executes everything with interpreter.
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200166 void DeoptimizeEverything(const char* key)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700167 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
168 REQUIRES(!Locks::thread_list_lock_,
169 !Locks::classlinker_classes_lock_,
Mathieu Chartier90443472015-07-16 20:32:27 -0700170 !deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100171
Mathieu Chartieraa516822015-10-02 15:53:37 -0700172 // Executes everything with compiled code (or interpreter if there is no code). May visit class
173 // linker classes through ConfigureStubs.
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200174 void UndeoptimizeEverything(const char* key)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700175 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
176 REQUIRES(!Locks::thread_list_lock_,
177 !Locks::classlinker_classes_lock_,
Mathieu Chartier90443472015-07-16 20:32:27 -0700178 !deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100179
180 // Deoptimize a method by forcing its execution with the interpreter. Nevertheless, a static
181 // method (except a class initializer) set to the resolution trampoline will be deoptimized only
182 // once its declaring class is initialized.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700183 void Deoptimize(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700184 REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100185
186 // Undeoptimze the method by restoring its entrypoints. Nevertheless, a static method
187 // (except a class initializer) set to the resolution trampoline will be updated only once its
188 // declaring class is initialized.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700189 void Undeoptimize(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700190 REQUIRES(Locks::mutator_lock_, !Locks::thread_list_lock_, !deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100191
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200192 // Indicates whether the method has been deoptimized so it is executed with the interpreter.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700193 bool IsDeoptimized(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700194 REQUIRES(!deoptimized_methods_lock_) SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100195
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200196 // Enable method tracing by installing instrumentation entry/exit stubs or interpreter.
197 void EnableMethodTracing(const char* key,
198 bool needs_interpreter = kDeoptimizeForAccurateMethodEntryExitListeners)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700199 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
200 REQUIRES(!Locks::thread_list_lock_,
201 !Locks::classlinker_classes_lock_,
Mathieu Chartier90443472015-07-16 20:32:27 -0700202 !deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100203
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200204 // Disable method tracing by uninstalling instrumentation entry/exit stubs or interpreter.
205 void DisableMethodTracing(const char* key)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700206 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
207 REQUIRES(!Locks::thread_list_lock_,
208 !Locks::classlinker_classes_lock_,
Mathieu Chartier90443472015-07-16 20:32:27 -0700209 !deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100210
Sebastien Hertzed2be172014-08-19 15:33:43 +0200211 InterpreterHandlerTable GetInterpreterHandlerTable() const
Mathieu Chartier90443472015-07-16 20:32:27 -0700212 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertzee1997a2013-09-19 14:47:09 +0200213 return interpreter_handler_table_;
214 }
215
Mathieu Chartier90443472015-07-16 20:32:27 -0700216 void InstrumentQuickAllocEntryPoints() REQUIRES(!Locks::instrument_entrypoints_lock_);
217 void UninstrumentQuickAllocEntryPoints() REQUIRES(!Locks::instrument_entrypoints_lock_);
Mathieu Chartier9ef78b52014-09-25 17:03:12 -0700218 void InstrumentQuickAllocEntryPointsLocked()
Mathieu Chartier90443472015-07-16 20:32:27 -0700219 REQUIRES(Locks::instrument_entrypoints_lock_, !Locks::thread_list_lock_,
220 !Locks::runtime_shutdown_lock_);
Mathieu Chartier9ef78b52014-09-25 17:03:12 -0700221 void UninstrumentQuickAllocEntryPointsLocked()
Mathieu Chartier90443472015-07-16 20:32:27 -0700222 REQUIRES(Locks::instrument_entrypoints_lock_, !Locks::thread_list_lock_,
223 !Locks::runtime_shutdown_lock_);
224 void ResetQuickAllocEntryPoints() REQUIRES(Locks::runtime_shutdown_lock_);
Ian Rogersfa824272013-11-05 16:12:57 -0800225
Ian Rogers62d6c772013-02-27 08:32:07 -0800226 // Update the code of a method respecting any installed stubs.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700227 void UpdateMethodsCode(ArtMethod* method, const void* quick_code)
Mathieu Chartier90443472015-07-16 20:32:27 -0700228 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!deoptimized_methods_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800229
230 // Get the quick code for the given method. More efficient than asking the class linker as it
231 // will short-cut to GetCode if instrumentation and static method resolution stubs aren't
232 // installed.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700233 const void* GetQuickCodeFor(ArtMethod* method, size_t pointer_size) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700234 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800235
236 void ForceInterpretOnly() {
237 interpret_only_ = true;
238 forced_interpret_only_ = true;
239 }
240
Brian Carlstromea46f952013-07-30 01:26:50 -0700241 // Called by ArtMethod::Invoke to determine dispatch mechanism.
Ian Rogers62d6c772013-02-27 08:32:07 -0800242 bool InterpretOnly() const {
243 return interpret_only_;
244 }
245
Hiroshi Yamauchi563b47c2014-02-28 17:18:37 -0800246 bool IsForcedInterpretOnly() const {
247 return forced_interpret_only_;
248 }
249
Mingyao Yang6ea1a0e2016-01-29 12:12:49 -0800250 // Code is in boot image oat file which isn't compiled as debuggable.
251 // Need debug version (interpreter or jitted) if that's the case.
252 bool NeedDebugVersionForBootImageCode(ArtMethod* method, const void* code) const
253 SHARED_REQUIRES(Locks::mutator_lock_);
254
Ian Rogers62d6c772013-02-27 08:32:07 -0800255 bool AreExitStubsInstalled() const {
256 return instrumentation_stubs_installed_;
257 }
258
Mathieu Chartier90443472015-07-16 20:32:27 -0700259 bool HasMethodEntryListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz74109f62013-06-07 17:40:09 +0200260 return have_method_entry_listeners_;
261 }
262
Mathieu Chartier90443472015-07-16 20:32:27 -0700263 bool HasMethodExitListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz74109f62013-06-07 17:40:09 +0200264 return have_method_exit_listeners_;
265 }
266
Mathieu Chartier90443472015-07-16 20:32:27 -0700267 bool HasMethodUnwindListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200268 return have_method_unwind_listeners_;
269 }
270
Mathieu Chartier90443472015-07-16 20:32:27 -0700271 bool HasDexPcListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz74109f62013-06-07 17:40:09 +0200272 return have_dex_pc_listeners_;
273 }
274
Mathieu Chartier90443472015-07-16 20:32:27 -0700275 bool HasFieldReadListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200276 return have_field_read_listeners_;
277 }
278
Mathieu Chartier90443472015-07-16 20:32:27 -0700279 bool HasFieldWriteListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200280 return have_field_write_listeners_;
281 }
282
Mathieu Chartier90443472015-07-16 20:32:27 -0700283 bool HasExceptionCaughtListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz9f102032014-05-23 08:59:42 +0200284 return have_exception_caught_listeners_;
285 }
286
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000287 bool HasBranchListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
288 return have_branch_listeners_;
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800289 }
290
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100291 bool HasInvokeVirtualOrInterfaceListeners() const SHARED_REQUIRES(Locks::mutator_lock_) {
292 return have_invoke_virtual_or_interface_listeners_;
293 }
294
Mathieu Chartier90443472015-07-16 20:32:27 -0700295 bool IsActive() const SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertzee1997a2013-09-19 14:47:09 +0200296 return have_dex_pc_listeners_ || have_method_entry_listeners_ || have_method_exit_listeners_ ||
Sebastien Hertz42cd43f2014-05-13 14:15:41 +0200297 have_field_read_listeners_ || have_field_write_listeners_ ||
Bill Buzbeefd522f92016-02-11 22:37:42 +0000298 have_exception_caught_listeners_ || have_method_unwind_listeners_ ||
299 have_branch_listeners_ || have_invoke_virtual_or_interface_listeners_;
300 }
301
302 // Any instrumentation *other* than what is needed for Jit profiling active?
303 bool NonJitProfilingActive() const SHARED_REQUIRES(Locks::mutator_lock_) {
304 return have_dex_pc_listeners_ || have_method_exit_listeners_ ||
305 have_field_read_listeners_ || have_field_write_listeners_ ||
Sebastien Hertzee1997a2013-09-19 14:47:09 +0200306 have_exception_caught_listeners_ || have_method_unwind_listeners_;
307 }
308
Ian Rogers62d6c772013-02-27 08:32:07 -0800309 // Inform listeners that a method has been entered. A dex PC is provided as we may install
310 // listeners into executing code and get method enter events for methods already on the stack.
311 void MethodEnterEvent(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700312 ArtMethod* method, uint32_t dex_pc) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700313 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz74109f62013-06-07 17:40:09 +0200314 if (UNLIKELY(HasMethodEntryListeners())) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800315 MethodEnterEventImpl(thread, this_object, method, dex_pc);
316 }
317 }
318
319 // Inform listeners that a method has been exited.
320 void MethodExitEvent(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700321 ArtMethod* method, uint32_t dex_pc,
Ian Rogers62d6c772013-02-27 08:32:07 -0800322 const JValue& return_value) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700323 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz74109f62013-06-07 17:40:09 +0200324 if (UNLIKELY(HasMethodExitListeners())) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800325 MethodExitEventImpl(thread, this_object, method, dex_pc, return_value);
326 }
327 }
328
329 // Inform listeners that a method has been exited due to an exception.
330 void MethodUnwindEvent(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700331 ArtMethod* method, uint32_t dex_pc) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700332 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800333
334 // Inform listeners that the dex pc has moved (only supported by the interpreter).
335 void DexPcMovedEvent(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700336 ArtMethod* method, uint32_t dex_pc) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700337 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz74109f62013-06-07 17:40:09 +0200338 if (UNLIKELY(HasDexPcListeners())) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800339 DexPcMovedEventImpl(thread, this_object, method, dex_pc);
340 }
341 }
342
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000343 // Inform listeners that a branch has been taken (only supported by the interpreter).
344 void Branch(Thread* thread, ArtMethod* method, uint32_t dex_pc, int32_t offset) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700345 SHARED_REQUIRES(Locks::mutator_lock_) {
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000346 if (UNLIKELY(HasBranchListeners())) {
347 BranchImpl(thread, method, dex_pc, offset);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800348 }
349 }
350
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200351 // Inform listeners that we read a field (only supported by the interpreter).
352 void FieldReadEvent(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700353 ArtMethod* method, uint32_t dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700354 ArtField* field) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700355 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200356 if (UNLIKELY(HasFieldReadListeners())) {
357 FieldReadEventImpl(thread, this_object, method, dex_pc, field);
358 }
359 }
360
361 // Inform listeners that we write a field (only supported by the interpreter).
362 void FieldWriteEvent(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700363 ArtMethod* method, uint32_t dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700364 ArtField* field, const JValue& field_value) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700365 SHARED_REQUIRES(Locks::mutator_lock_) {
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200366 if (UNLIKELY(HasFieldWriteListeners())) {
367 FieldWriteEventImpl(thread, this_object, method, dex_pc, field, field_value);
368 }
369 }
370
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100371 void InvokeVirtualOrInterface(Thread* thread,
372 mirror::Object* this_object,
373 ArtMethod* caller,
374 uint32_t dex_pc,
375 ArtMethod* callee) const
376 SHARED_REQUIRES(Locks::mutator_lock_) {
377 if (UNLIKELY(HasInvokeVirtualOrInterfaceListeners())) {
378 InvokeVirtualOrInterfaceImpl(thread, this_object, caller, dex_pc, callee);
379 }
380 }
381
Ian Rogers62d6c772013-02-27 08:32:07 -0800382 // Inform listeners that an exception was caught.
Nicolas Geoffray14691c52015-03-05 10:40:17 +0000383 void ExceptionCaughtEvent(Thread* thread, mirror::Throwable* exception_object) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700384 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800385
386 // Called when an instrumented method is entered. The intended link register (lr) is saved so
387 // that returning causes a branch to the method exit stub. Generates method enter events.
388 void PushInstrumentationStackFrame(Thread* self, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700389 ArtMethod* method, uintptr_t lr,
Jeff Hao9a916d32013-06-27 18:45:37 -0700390 bool interpreter_entry)
Mathieu Chartier90443472015-07-16 20:32:27 -0700391 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800392
393 // Called when an instrumented method is exited. Removes the pushed instrumentation frame
394 // returning the intended link register. Generates method exit events.
Andreas Gamped58342c2014-06-05 14:18:08 -0700395 TwoWordReturn PopInstrumentationStackFrame(Thread* self, uintptr_t* return_pc,
396 uint64_t gpr_result, uint64_t fpr_result)
Mathieu Chartier90443472015-07-16 20:32:27 -0700397 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!deoptimized_methods_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800398
399 // Pops an instrumentation frame from the current thread and generate an unwind event.
400 void PopMethodForUnwind(Thread* self, bool is_deoptimization) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700401 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800402
403 // Call back for configure stubs.
Mathieu Chartier90443472015-07-16 20:32:27 -0700404 void InstallStubsForClass(mirror::Class* klass) SHARED_REQUIRES(Locks::mutator_lock_)
405 REQUIRES(!deoptimized_methods_lock_);
jeffhao725a9572012-11-13 18:20:12 -0800406
Mathieu Chartiere401d142015-04-22 13:56:20 -0700407 void InstallStubsForMethod(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700408 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(!deoptimized_methods_lock_);
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100409
Mingyao Yang99170c62015-07-06 11:10:37 -0700410 // Install instrumentation exit stub on every method of the stack of the given thread.
411 // This is used by the debugger to cause a deoptimization of the thread's stack after updating
412 // local variable(s).
413 void InstrumentThreadStack(Thread* thread)
414 SHARED_REQUIRES(Locks::mutator_lock_)
415 REQUIRES(!Locks::thread_list_lock_);
416
Sebastien Hertzb2feaaf2015-10-12 13:40:10 +0000417 static size_t ComputeFrameId(Thread* self,
418 size_t frame_depth,
419 size_t inlined_frames_before_frame)
420 SHARED_REQUIRES(Locks::mutator_lock_);
421
jeffhao725a9572012-11-13 18:20:12 -0800422 private:
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200423 InstrumentationLevel GetCurrentInstrumentationLevel() const;
424
Ian Rogers62d6c772013-02-27 08:32:07 -0800425 // Does the job of installing or removing instrumentation code within methods.
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200426 // In order to support multiple clients using instrumentation at the same time,
427 // the caller must pass a unique key (a string) identifying it so we remind which
428 // instrumentation level it needs. Therefore the current instrumentation level
429 // becomes the highest instrumentation level required by a client.
430 void ConfigureStubs(const char* key, InstrumentationLevel desired_instrumentation_level)
Mathieu Chartieraa516822015-10-02 15:53:37 -0700431 REQUIRES(Locks::mutator_lock_, Roles::uninterruptible_)
432 REQUIRES(!deoptimized_methods_lock_,
433 !Locks::thread_list_lock_,
Mathieu Chartier90443472015-07-16 20:32:27 -0700434 !Locks::classlinker_classes_lock_);
jeffhao725a9572012-11-13 18:20:12 -0800435
Mathieu Chartier90443472015-07-16 20:32:27 -0700436 void UpdateInterpreterHandlerTable() REQUIRES(Locks::mutator_lock_) {
buzbee1452bee2015-03-06 14:43:04 -0800437 /*
438 * TUNING: Dalvik's mterp stashes the actual current handler table base in a
439 * tls field. For Arm, this enables all suspend, debug & tracing checks to be
440 * collapsed into a single conditionally-executed ldw instruction.
441 * Move to Dalvik-style handler-table management for both the goto interpreter and
442 * mterp.
443 */
Sebastien Hertzee1997a2013-09-19 14:47:09 +0200444 interpreter_handler_table_ = IsActive() ? kAlternativeHandlerTable : kMainHandlerTable;
445 }
446
Mathieu Chartier661974a2014-01-09 11:23:53 -0800447 // No thread safety analysis to get around SetQuickAllocEntryPointsInstrumented requiring
448 // exclusive access to mutator lock which you can't get if the runtime isn't started.
Mathieu Chartier9ef78b52014-09-25 17:03:12 -0700449 void SetEntrypointsInstrumented(bool instrumented) NO_THREAD_SAFETY_ANALYSIS;
Mathieu Chartier661974a2014-01-09 11:23:53 -0800450
Ian Rogers62d6c772013-02-27 08:32:07 -0800451 void MethodEnterEventImpl(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700452 ArtMethod* method, uint32_t dex_pc) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700453 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800454 void MethodExitEventImpl(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700455 ArtMethod* method,
Ian Rogers62d6c772013-02-27 08:32:07 -0800456 uint32_t dex_pc, const JValue& return_value) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700457 SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800458 void DexPcMovedEventImpl(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700459 ArtMethod* method, uint32_t dex_pc) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700460 SHARED_REQUIRES(Locks::mutator_lock_);
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000461 void BranchImpl(Thread* thread, ArtMethod* method, uint32_t dex_pc, int32_t offset) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700462 SHARED_REQUIRES(Locks::mutator_lock_);
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100463 void InvokeVirtualOrInterfaceImpl(Thread* thread,
464 mirror::Object* this_object,
465 ArtMethod* caller,
466 uint32_t dex_pc,
467 ArtMethod* callee) const
468 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200469 void FieldReadEventImpl(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700470 ArtMethod* method, uint32_t dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700471 ArtField* field) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700472 SHARED_REQUIRES(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200473 void FieldWriteEventImpl(Thread* thread, mirror::Object* this_object,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700474 ArtMethod* method, uint32_t dex_pc,
Mathieu Chartierc7853442015-03-27 14:35:38 -0700475 ArtField* field, const JValue& field_value) const
Mathieu Chartier90443472015-07-16 20:32:27 -0700476 SHARED_REQUIRES(Locks::mutator_lock_);
jeffhao725a9572012-11-13 18:20:12 -0800477
Hiroshi Yamauchi799eb3a2014-07-18 15:38:17 -0700478 // Read barrier-aware utility functions for accessing deoptimized_methods_
Mathieu Chartiere401d142015-04-22 13:56:20 -0700479 bool AddDeoptimizedMethod(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700480 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(deoptimized_methods_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700481 bool IsDeoptimizedMethod(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700482 SHARED_REQUIRES(Locks::mutator_lock_, deoptimized_methods_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700483 bool RemoveDeoptimizedMethod(ArtMethod* method)
Mathieu Chartier90443472015-07-16 20:32:27 -0700484 SHARED_REQUIRES(Locks::mutator_lock_) REQUIRES(deoptimized_methods_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700485 ArtMethod* BeginDeoptimizedMethod()
Mathieu Chartier90443472015-07-16 20:32:27 -0700486 SHARED_REQUIRES(Locks::mutator_lock_, deoptimized_methods_lock_);
Hiroshi Yamauchi799eb3a2014-07-18 15:38:17 -0700487 bool IsDeoptimizedMethodsEmpty() const
Mathieu Chartier90443472015-07-16 20:32:27 -0700488 SHARED_REQUIRES(Locks::mutator_lock_, deoptimized_methods_lock_);
Hiroshi Yamauchi799eb3a2014-07-18 15:38:17 -0700489
Brian Carlstromea46f952013-07-30 01:26:50 -0700490 // Have we hijacked ArtMethod::code_ so that it calls instrumentation/interpreter code?
Ian Rogers62d6c772013-02-27 08:32:07 -0800491 bool instrumentation_stubs_installed_;
492
Brian Carlstromea46f952013-07-30 01:26:50 -0700493 // Have we hijacked ArtMethod::code_ to reference the enter/exit stubs?
Ian Rogers62d6c772013-02-27 08:32:07 -0800494 bool entry_exit_stubs_installed_;
495
Brian Carlstromea46f952013-07-30 01:26:50 -0700496 // Have we hijacked ArtMethod::code_ to reference the enter interpreter stub?
Ian Rogers62d6c772013-02-27 08:32:07 -0800497 bool interpreter_stubs_installed_;
498
499 // Do we need the fidelity of events that we only get from running within the interpreter?
500 bool interpret_only_;
501
502 // Did the runtime request we only run in the interpreter? ie -Xint mode.
503 bool forced_interpret_only_;
504
505 // Do we have any listeners for method entry events? Short-cut to avoid taking the
506 // instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200507 bool have_method_entry_listeners_ GUARDED_BY(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800508
509 // Do we have any listeners for method exit events? Short-cut to avoid taking the
510 // instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200511 bool have_method_exit_listeners_ GUARDED_BY(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800512
513 // Do we have any listeners for method unwind events? Short-cut to avoid taking the
514 // instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200515 bool have_method_unwind_listeners_ GUARDED_BY(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800516
517 // Do we have any listeners for dex move events? Short-cut to avoid taking the
518 // instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200519 bool have_dex_pc_listeners_ GUARDED_BY(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800520
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200521 // Do we have any listeners for field read events? Short-cut to avoid taking the
522 // instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200523 bool have_field_read_listeners_ GUARDED_BY(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200524
525 // Do we have any listeners for field write events? Short-cut to avoid taking the
526 // instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200527 bool have_field_write_listeners_ GUARDED_BY(Locks::mutator_lock_);
Sebastien Hertz3f52eaf2014-04-04 17:50:18 +0200528
Ian Rogers62d6c772013-02-27 08:32:07 -0800529 // Do we have any exception caught listeners? Short-cut to avoid taking the instrumentation_lock_.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200530 bool have_exception_caught_listeners_ GUARDED_BY(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800531
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000532 // Do we have any branch listeners? Short-cut to avoid taking the instrumentation_lock_.
533 bool have_branch_listeners_ GUARDED_BY(Locks::mutator_lock_);
Mathieu Chartiere5f13e52015-02-24 09:37:21 -0800534
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100535 // Do we have any invoke listeners? Short-cut to avoid taking the instrumentation_lock_.
536 bool have_invoke_virtual_or_interface_listeners_ GUARDED_BY(Locks::mutator_lock_);
537
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200538 // Contains the instrumentation level required by each client of the instrumentation identified
539 // by a string key.
540 typedef SafeMap<const char*, InstrumentationLevel> InstrumentationLevelTable;
541 InstrumentationLevelTable requested_instrumentation_levels_ GUARDED_BY(Locks::mutator_lock_);
542
Ian Rogers62d6c772013-02-27 08:32:07 -0800543 // The event listeners, written to with the mutator_lock_ exclusively held.
Nicolas Geoffray514a6162015-11-03 11:44:24 +0000544 // Mutators must be able to iterate over these lists concurrently, that is, with listeners being
545 // added or removed while iterating. The modifying thread holds exclusive lock,
546 // so other threads cannot iterate (i.e. read the data of the list) at the same time but they
547 // do keep iterators that need to remain valid. This is the reason these listeners are std::list
548 // and not for example std::vector: the existing storage for a std::list does not move.
549 // Note that mutators cannot make a copy of these lists before iterating, as the instrumentation
550 // listeners can also be deleted concurrently.
551 // As a result, these lists are never trimmed. That's acceptable given the low number of
552 // listeners we have.
Ian Rogers62d6c772013-02-27 08:32:07 -0800553 std::list<InstrumentationListener*> method_entry_listeners_ GUARDED_BY(Locks::mutator_lock_);
554 std::list<InstrumentationListener*> method_exit_listeners_ GUARDED_BY(Locks::mutator_lock_);
555 std::list<InstrumentationListener*> method_unwind_listeners_ GUARDED_BY(Locks::mutator_lock_);
Nicolas Geoffray81f0f952016-01-20 16:25:19 +0000556 std::list<InstrumentationListener*> branch_listeners_ GUARDED_BY(Locks::mutator_lock_);
Nicolas Geoffray5550ca82015-08-21 18:38:30 +0100557 std::list<InstrumentationListener*> invoke_virtual_or_interface_listeners_
558 GUARDED_BY(Locks::mutator_lock_);
Nicolas Geoffray514a6162015-11-03 11:44:24 +0000559 std::list<InstrumentationListener*> dex_pc_listeners_ GUARDED_BY(Locks::mutator_lock_);
560 std::list<InstrumentationListener*> field_read_listeners_ GUARDED_BY(Locks::mutator_lock_);
561 std::list<InstrumentationListener*> field_write_listeners_ GUARDED_BY(Locks::mutator_lock_);
562 std::list<InstrumentationListener*> exception_caught_listeners_ GUARDED_BY(Locks::mutator_lock_);
jeffhao725a9572012-11-13 18:20:12 -0800563
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100564 // The set of methods being deoptimized (by the debugger) which must be executed with interpreter
565 // only.
Mathieu Chartier3b05e9b2014-03-25 09:29:43 -0700566 mutable ReaderWriterMutex deoptimized_methods_lock_ DEFAULT_MUTEX_ACQUIRED_AFTER;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700567 std::unordered_set<ArtMethod*> deoptimized_methods_ GUARDED_BY(deoptimized_methods_lock_);
Sebastien Hertz11d40c22014-02-19 18:00:17 +0100568 bool deoptimization_enabled_;
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100569
Ian Rogersfa824272013-11-05 16:12:57 -0800570 // Current interpreter handler table. This is updated each time the thread state flags are
571 // modified.
Sebastien Hertzed2be172014-08-19 15:33:43 +0200572 InterpreterHandlerTable interpreter_handler_table_ GUARDED_BY(Locks::mutator_lock_);
Sebastien Hertzee1997a2013-09-19 14:47:09 +0200573
Ian Rogersfa824272013-11-05 16:12:57 -0800574 // Greater than 0 if quick alloc entry points instrumented.
Mathieu Chartier9ef78b52014-09-25 17:03:12 -0700575 size_t quick_alloc_entry_points_instrumentation_counter_
576 GUARDED_BY(Locks::instrument_entrypoints_lock_);
Ian Rogersfa824272013-11-05 16:12:57 -0800577
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200578 friend class InstrumentationTest; // For GetCurrentInstrumentationLevel and ConfigureStubs.
579
jeffhao725a9572012-11-13 18:20:12 -0800580 DISALLOW_COPY_AND_ASSIGN(Instrumentation);
581};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700582std::ostream& operator<<(std::ostream& os, const Instrumentation::InstrumentationEvent& rhs);
Sebastien Hertz0462c4c2015-04-01 16:34:17 +0200583std::ostream& operator<<(std::ostream& os, const Instrumentation::InstrumentationLevel& rhs);
jeffhao725a9572012-11-13 18:20:12 -0800584
Ian Rogers62d6c772013-02-27 08:32:07 -0800585// An element in the instrumentation side stack maintained in art::Thread.
586struct InstrumentationStackFrame {
Mathieu Chartiere401d142015-04-22 13:56:20 -0700587 InstrumentationStackFrame(mirror::Object* this_object, ArtMethod* method,
Jeff Hao9a916d32013-06-27 18:45:37 -0700588 uintptr_t return_pc, size_t frame_id, bool interpreter_entry)
589 : this_object_(this_object), method_(method), return_pc_(return_pc), frame_id_(frame_id),
590 interpreter_entry_(interpreter_entry) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800591 }
592
Mathieu Chartier90443472015-07-16 20:32:27 -0700593 std::string Dump() const SHARED_REQUIRES(Locks::mutator_lock_);
Ian Rogers62d6c772013-02-27 08:32:07 -0800594
595 mirror::Object* this_object_;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700596 ArtMethod* method_;
Sebastien Hertz138dbfc2013-12-04 18:15:25 +0100597 uintptr_t return_pc_;
598 size_t frame_id_;
599 bool interpreter_entry_;
Ian Rogers62d6c772013-02-27 08:32:07 -0800600};
601
602} // namespace instrumentation
jeffhao725a9572012-11-13 18:20:12 -0800603} // namespace art
604
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700605#endif // ART_RUNTIME_INSTRUMENTATION_H_