blob: 79d2f40d73556d9bfe09e25c53fd9ecf6ea8f2d5 [file] [log] [blame]
Elliott Hughes68e76522011-10-05 13:22:16 -07001/*
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_STACK_H_
18#define ART_RUNTIME_STACK_H_
Elliott Hughes68e76522011-10-05 13:22:16 -070019
Elliott Hughes68e76522011-10-05 13:22:16 -070020#include <stdint.h>
Ian Rogers40e3bac2012-11-20 00:09:14 -080021#include <string>
Elliott Hughes68e76522011-10-05 13:22:16 -070022
Ian Rogersd582fa42014-11-05 23:46:43 -080023#include "arch/instruction_set.h"
Vladimir Marko80afd022015-05-19 18:08:00 +010024#include "base/bit_utils.h"
Ian Rogerse63db272014-07-15 15:36:11 -070025#include "dex_file.h"
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080026#include "gc_root.h"
Ian Rogerse63db272014-07-15 15:36:11 -070027#include "mirror/object_reference.h"
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080028#include "read_barrier.h"
Ian Rogerse63db272014-07-15 15:36:11 -070029#include "verify_object.h"
30
Elliott Hughes68e76522011-10-05 13:22:16 -070031namespace art {
32
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080033namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070034 class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080035} // namespace mirror
36
Mathieu Chartiere401d142015-04-22 13:56:20 -070037class ArtMethod;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080038class Context;
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070039class HandleScope;
Nicolas Geoffray57f61612015-05-15 13:20:41 +010040class InlineInfo;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070041class ScopedObjectAccess;
Nicolas Geoffray57f61612015-05-15 13:20:41 +010042class ShadowFrame;
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000043class StackVisitor;
Elliott Hughes68e76522011-10-05 13:22:16 -070044class Thread;
45
Ian Rogers2bcb4a42012-11-08 10:39:18 -080046// The kind of vreg being accessed in calls to Set/GetVReg.
47enum VRegKind {
48 kReferenceVReg,
49 kIntVReg,
50 kFloatVReg,
51 kLongLoVReg,
52 kLongHiVReg,
53 kDoubleLoVReg,
54 kDoubleHiVReg,
55 kConstant,
56 kImpreciseConstant,
57 kUndefined,
58};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070059std::ostream& operator<<(std::ostream& os, const VRegKind& rhs);
Ian Rogers2bcb4a42012-11-08 10:39:18 -080060
Ian Rogersef7d42f2014-01-06 12:55:46 -080061// A reference from the shadow stack to a MirrorType object within the Java heap.
62template<class MirrorType>
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -070063class MANAGED StackReference : public mirror::CompressedReference<MirrorType> {
Ian Rogersef7d42f2014-01-06 12:55:46 -080064};
65
Elliott Hughes956af0f2014-12-11 14:34:28 -080066// ShadowFrame has 2 possible layouts:
Mathieu Chartier67022432012-11-29 18:04:50 -080067// - interpreter - separate VRegs and reference arrays. References are in the reference array.
68// - JNI - just VRegs, but where every VReg holds a reference.
Ian Rogers0399dde2012-06-06 17:09:28 -070069class ShadowFrame {
Elliott Hughes68e76522011-10-05 13:22:16 -070070 public:
Ian Rogersef7d42f2014-01-06 12:55:46 -080071 // Compute size of ShadowFrame in bytes assuming it has a reference array.
Jeff Hao66135192013-05-14 11:02:41 -070072 static size_t ComputeSize(uint32_t num_vregs) {
73 return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) +
Ian Rogersef7d42f2014-01-06 12:55:46 -080074 (sizeof(StackReference<mirror::Object>) * num_vregs);
Jeff Hao66135192013-05-14 11:02:41 -070075 }
76
77 // Create ShadowFrame in heap for deoptimization.
Christopher Ferris241a9582015-04-27 15:19:41 -070078 static ShadowFrame* CreateDeoptimizedFrame(uint32_t num_vregs, ShadowFrame* link,
Mathieu Chartiere401d142015-04-22 13:56:20 -070079 ArtMethod* method, uint32_t dex_pc) {
Jeff Hao66135192013-05-14 11:02:41 -070080 uint8_t* memory = new uint8_t[ComputeSize(num_vregs)];
Sebastien Hertzc61124b2013-09-10 11:44:19 +020081 return Create(num_vregs, link, method, dex_pc, memory);
Jeff Hao66135192013-05-14 11:02:41 -070082 }
83
Christopher Ferris241a9582015-04-27 15:19:41 -070084 // Delete a ShadowFrame allocated on the heap for deoptimization.
85 static void DeleteDeoptimizedFrame(ShadowFrame* sf) {
86 uint8_t* memory = reinterpret_cast<uint8_t*>(sf);
87 delete[] memory;
88 }
89
Jeff Hao66135192013-05-14 11:02:41 -070090 // Create ShadowFrame for interpreter using provided memory.
91 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Mathieu Chartiere401d142015-04-22 13:56:20 -070092 ArtMethod* method, uint32_t dex_pc, void* memory) {
TDYa127ce4cc0d2012-11-18 16:59:53 -080093 ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
94 return sf;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -070095 }
96 ~ShadowFrame() {}
97
TDYa127ce4cc0d2012-11-18 16:59:53 -080098 bool HasReferenceArray() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -070099 return true;
Ian Rogers0399dde2012-06-06 17:09:28 -0700100 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700101
TDYa127ce4cc0d2012-11-18 16:59:53 -0800102 uint32_t NumberOfVRegs() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700103 return number_of_vregs_;
Ian Rogers5438ad82012-10-15 17:22:44 -0700104 }
105
Ian Rogers0399dde2012-06-06 17:09:28 -0700106 uint32_t GetDexPC() const {
107 return dex_pc_;
108 }
109
110 void SetDexPC(uint32_t dex_pc) {
111 dex_pc_ = dex_pc;
112 }
113
Ian Rogers0399dde2012-06-06 17:09:28 -0700114 ShadowFrame* GetLink() const {
115 return link_;
116 }
117
118 void SetLink(ShadowFrame* frame) {
119 DCHECK_NE(this, frame);
120 link_ = frame;
121 }
122
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700123 int32_t GetVReg(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800124 DCHECK_LT(i, NumberOfVRegs());
125 const uint32_t* vreg = &vregs_[i];
126 return *reinterpret_cast<const int32_t*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700127 }
128
129 float GetVRegFloat(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800130 DCHECK_LT(i, NumberOfVRegs());
131 // NOTE: Strict-aliasing?
132 const uint32_t* vreg = &vregs_[i];
133 return *reinterpret_cast<const float*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700134 }
135
136 int64_t GetVRegLong(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200137 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800138 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700139 // Alignment attribute required for GCC 4.8
140 typedef const int64_t unaligned_int64 __attribute__ ((aligned (4)));
141 return *reinterpret_cast<unaligned_int64*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700142 }
143
144 double GetVRegDouble(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200145 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800146 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700147 // Alignment attribute required for GCC 4.8
148 typedef const double unaligned_double __attribute__ ((aligned (4)));
149 return *reinterpret_cast<unaligned_double*>(vreg);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800150 }
151
Mathieu Chartier4e305412014-02-19 10:54:44 -0800152 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800153 mirror::Object* GetVRegReference(size_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800154 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800155 mirror::Object* ref;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800156 if (HasReferenceArray()) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800157 ref = References()[i].AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800158 } else {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800159 const uint32_t* vreg_ptr = &vregs_[i];
Mathieu Chartier4e305412014-02-19 10:54:44 -0800160 ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800161 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800162 if (kUseReadBarrier) {
163 ReadBarrier::AssertToSpaceInvariant(ref);
164 }
Mathieu Chartier4e305412014-02-19 10:54:44 -0800165 if (kVerifyFlags & kVerifyReads) {
166 VerifyObject(ref);
167 }
168 return ref;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700169 }
170
Jeff Hao16743632013-05-08 10:59:04 -0700171 // Get view of vregs as range of consecutive arguments starting at i.
172 uint32_t* GetVRegArgs(size_t i) {
173 return &vregs_[i];
174 }
175
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700176 void SetVReg(size_t i, int32_t val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800177 DCHECK_LT(i, NumberOfVRegs());
178 uint32_t* vreg = &vregs_[i];
179 *reinterpret_cast<int32_t*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700180 // This is needed for moving collectors since these can update the vreg references if they
181 // happen to agree with references in the reference array.
182 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800183 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700184 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700185 }
186
187 void SetVRegFloat(size_t i, float val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800188 DCHECK_LT(i, NumberOfVRegs());
189 uint32_t* vreg = &vregs_[i];
190 *reinterpret_cast<float*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700191 // This is needed for moving collectors since these can update the vreg references if they
192 // happen to agree with references in the reference array.
193 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800194 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700195 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700196 }
197
198 void SetVRegLong(size_t i, int64_t val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200199 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800200 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700201 // Alignment attribute required for GCC 4.8
202 typedef int64_t unaligned_int64 __attribute__ ((aligned (4)));
203 *reinterpret_cast<unaligned_int64*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700204 // This is needed for moving collectors since these can update the vreg references if they
205 // happen to agree with references in the reference array.
206 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800207 References()[i].Clear();
208 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700209 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700210 }
211
212 void SetVRegDouble(size_t i, double val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200213 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800214 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700215 // Alignment attribute required for GCC 4.8
216 typedef double unaligned_double __attribute__ ((aligned (4)));
217 *reinterpret_cast<unaligned_double*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700218 // This is needed for moving collectors since these can update the vreg references if they
219 // happen to agree with references in the reference array.
220 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800221 References()[i].Clear();
222 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700223 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700224 }
225
Mathieu Chartier4e305412014-02-19 10:54:44 -0800226 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800227 void SetVRegReference(size_t i, mirror::Object* val) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800228 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800229 if (kVerifyFlags & kVerifyWrites) {
230 VerifyObject(val);
231 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800232 if (kUseReadBarrier) {
233 ReadBarrier::AssertToSpaceInvariant(val);
234 }
TDYa127ce4cc0d2012-11-18 16:59:53 -0800235 uint32_t* vreg = &vregs_[i];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800236 reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800237 if (HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800238 References()[i].Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800239 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700240 }
241
Mathieu Chartiere401d142015-04-22 13:56:20 -0700242 ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800243 DCHECK(method_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700244 return method_;
Elliott Hughes68e76522011-10-05 13:22:16 -0700245 }
246
Ian Rogers62d6c772013-02-27 08:32:07 -0800247 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
248
Jeff Haoe701f482013-05-24 11:50:49 -0700249 mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
250
Ian Rogersef7d42f2014-01-06 12:55:46 -0800251 bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800252 if (HasReferenceArray()) {
253 return ((&References()[0] <= shadow_frame_entry_obj) &&
254 (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1])));
255 } else {
256 uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj);
257 return ((&vregs_[0] <= shadow_frame_entry) &&
258 (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1])));
Ian Rogers0399dde2012-06-06 17:09:28 -0700259 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700260 }
261
Ian Rogers0399dde2012-06-06 17:09:28 -0700262 static size_t LinkOffset() {
263 return OFFSETOF_MEMBER(ShadowFrame, link_);
264 }
265
Ian Rogers0399dde2012-06-06 17:09:28 -0700266 static size_t MethodOffset() {
267 return OFFSETOF_MEMBER(ShadowFrame, method_);
268 }
269
Ian Rogers0399dde2012-06-06 17:09:28 -0700270 static size_t DexPCOffset() {
271 return OFFSETOF_MEMBER(ShadowFrame, dex_pc_);
272 }
273
Ian Rogers5438ad82012-10-15 17:22:44 -0700274 static size_t NumberOfVRegsOffset() {
275 return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_);
276 }
277
TDYa127ce4cc0d2012-11-18 16:59:53 -0800278 static size_t VRegsOffset() {
279 return OFFSETOF_MEMBER(ShadowFrame, vregs_);
Ian Rogers5438ad82012-10-15 17:22:44 -0700280 }
281
Elliott Hughes68e76522011-10-05 13:22:16 -0700282 private:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700283 ShadowFrame(uint32_t num_vregs, ShadowFrame* link, ArtMethod* method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800284 uint32_t dex_pc, bool has_reference_array)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800285 : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) {
286 if (has_reference_array) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800287 memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(StackReference<mirror::Object>)));
Mathieu Chartier67022432012-11-29 18:04:50 -0800288 } else {
Jeff Haoe701f482013-05-24 11:50:49 -0700289 memset(vregs_, 0, num_vregs * sizeof(uint32_t));
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700290 }
291 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700292
Ian Rogersef7d42f2014-01-06 12:55:46 -0800293 const StackReference<mirror::Object>* References() const {
Mathieu Chartier67022432012-11-29 18:04:50 -0800294 DCHECK(HasReferenceArray());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800295 const uint32_t* vreg_end = &vregs_[NumberOfVRegs()];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800296 return reinterpret_cast<const StackReference<mirror::Object>*>(vreg_end);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800297 }
298
Ian Rogersef7d42f2014-01-06 12:55:46 -0800299 StackReference<mirror::Object>* References() {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700300 return const_cast<StackReference<mirror::Object>*>(
301 const_cast<const ShadowFrame*>(this)->References());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800302 }
303
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700304 const uint32_t number_of_vregs_;
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700305 // Link to previous shadow frame or null.
Ian Rogers0399dde2012-06-06 17:09:28 -0700306 ShadowFrame* link_;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700307 ArtMethod* method_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700308 uint32_t dex_pc_;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800309 uint32_t vregs_[0];
Elliott Hughes68e76522011-10-05 13:22:16 -0700310
Ian Rogers0399dde2012-06-06 17:09:28 -0700311 DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame);
Elliott Hughes68e76522011-10-05 13:22:16 -0700312};
313
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -0800314class JavaFrameRootInfo : public RootInfo {
315 public:
316 JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg)
317 : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) {
318 }
319 virtual void Describe(std::ostream& os) const OVERRIDE
320 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
321
322 private:
323 const StackVisitor* const stack_visitor_;
324 const size_t vreg_;
325};
326
Ian Rogers0399dde2012-06-06 17:09:28 -0700327// The managed stack is used to record fragments of managed code stacks. Managed code stacks
328// may either be shadow frames or lists of frames using fixed frame sizes. Transition records are
329// necessary for transitions between code using different frame layouts and transitions into native
330// code.
Ian Rogersdf1ce912012-11-27 17:07:11 -0800331class PACKED(4) ManagedStack {
Ian Rogers0399dde2012-06-06 17:09:28 -0700332 public:
Ian Rogersca190662012-06-26 15:45:57 -0700333 ManagedStack()
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700334 : top_quick_frame_(nullptr), link_(nullptr), top_shadow_frame_(nullptr) {}
Ian Rogers81d425b2012-09-27 16:03:43 -0700335
336 void PushManagedStackFragment(ManagedStack* fragment) {
337 // Copy this top fragment into given fragment.
338 memcpy(fragment, this, sizeof(ManagedStack));
339 // Clear this fragment, which has become the top.
340 memset(this, 0, sizeof(ManagedStack));
341 // Link our top fragment onto the given fragment.
342 link_ = fragment;
343 }
344
345 void PopManagedStackFragment(const ManagedStack& fragment) {
346 DCHECK(&fragment == link_);
347 // Copy this given fragment back to the top.
348 memcpy(this, &fragment, sizeof(ManagedStack));
349 }
Ian Rogers0399dde2012-06-06 17:09:28 -0700350
351 ManagedStack* GetLink() const {
352 return link_;
353 }
354
Mathieu Chartiere401d142015-04-22 13:56:20 -0700355 ArtMethod** GetTopQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700356 return top_quick_frame_;
357 }
358
Mathieu Chartiere401d142015-04-22 13:56:20 -0700359 void SetTopQuickFrame(ArtMethod** top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700360 DCHECK(top_shadow_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700361 top_quick_frame_ = top;
362 }
363
Ian Rogers0399dde2012-06-06 17:09:28 -0700364 static size_t TopQuickFrameOffset() {
365 return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_);
366 }
367
Ian Rogers0399dde2012-06-06 17:09:28 -0700368 ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700369 DCHECK(top_quick_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700370 ShadowFrame* old_frame = top_shadow_frame_;
371 top_shadow_frame_ = new_top_frame;
372 new_top_frame->SetLink(old_frame);
373 return old_frame;
374 }
375
376 ShadowFrame* PopShadowFrame() {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700377 DCHECK(top_quick_frame_ == nullptr);
378 CHECK(top_shadow_frame_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700379 ShadowFrame* frame = top_shadow_frame_;
380 top_shadow_frame_ = frame->GetLink();
381 return frame;
382 }
383
384 ShadowFrame* GetTopShadowFrame() const {
385 return top_shadow_frame_;
386 }
387
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800388 void SetTopShadowFrame(ShadowFrame* top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700389 DCHECK(top_quick_frame_ == nullptr);
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800390 top_shadow_frame_ = top;
391 }
392
Ian Rogers0399dde2012-06-06 17:09:28 -0700393 static size_t TopShadowFrameOffset() {
394 return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_);
395 }
396
Ian Rogersef7d42f2014-01-06 12:55:46 -0800397 size_t NumJniShadowFrameReferences() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700398
Ian Rogersef7d42f2014-01-06 12:55:46 -0800399 bool ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700400
401 private:
Mathieu Chartiere401d142015-04-22 13:56:20 -0700402 ArtMethod** top_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700403 ManagedStack* link_;
404 ShadowFrame* top_shadow_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700405};
406
407class StackVisitor {
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100408 public:
409 // This enum defines a flag to control whether inlined frames are included
410 // when walking the stack.
411 enum class StackWalkKind {
412 kIncludeInlinedFrames,
413 kSkipInlinedFrames,
414 };
415
Ian Rogers0399dde2012-06-06 17:09:28 -0700416 protected:
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100417 StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind)
418 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700419
420 public:
421 virtual ~StackVisitor() {}
422
423 // Return 'true' if we should continue to visit more frames, 'false' to stop.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700424 virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
Ian Rogers0399dde2012-06-06 17:09:28 -0700425
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700426 void WalkStack(bool include_transitions = false)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700427 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700428
Mathieu Chartiere401d142015-04-22 13:56:20 -0700429 ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700430
Ian Rogers0399dde2012-06-06 17:09:28 -0700431 bool IsShadowFrame() const {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800432 return cur_shadow_frame_ != nullptr;
Ian Rogers0399dde2012-06-06 17:09:28 -0700433 }
434
Dave Allisonb373e092014-02-20 16:06:36 -0800435 uint32_t GetDexPc(bool abort_on_failure = true) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0c7abda2012-09-19 13:33:42 -0700436
Ian Rogers62d6c772013-02-27 08:32:07 -0800437 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
438
Ian Rogers0c7abda2012-09-19 13:33:42 -0700439 size_t GetNativePcOffset() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
440
Ian Rogersef7d42f2014-01-06 12:55:46 -0800441 uintptr_t* CalleeSaveAddress(int num, size_t frame_size) const
442 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700443 // Callee saves are held at the top of the frame
Ian Rogersef7d42f2014-01-06 12:55:46 -0800444 DCHECK(GetMethod() != nullptr);
Ian Rogers13735952014-10-08 12:43:28 -0700445 uint8_t* save_addr =
446 reinterpret_cast<uint8_t*>(cur_quick_frame_) + frame_size - ((num + 1) * sizeof(void*));
Andreas Gampebf6b92a2014-03-05 16:11:04 -0800447#if defined(__i386__) || defined(__x86_64__)
Ian Rogers13735952014-10-08 12:43:28 -0700448 save_addr -= sizeof(void*); // account for return address
Ian Rogers0399dde2012-06-06 17:09:28 -0700449#endif
Mathieu Chartier67022432012-11-29 18:04:50 -0800450 return reinterpret_cast<uintptr_t*>(save_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700451 }
452
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700453 // Returns the height of the stack in the managed stack frames, including transitions.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700454 size_t GetFrameHeight() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800455 return GetNumFrames() - cur_depth_ - 1;
Ian Rogers0399dde2012-06-06 17:09:28 -0700456 }
457
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700458 // Returns a frame ID for JDWP use, starting from 1.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700459 size_t GetFrameId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700460 return GetFrameHeight() + 1;
461 }
462
Ian Rogersb726dcb2012-09-05 08:57:23 -0700463 size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700464 if (num_frames_ == 0) {
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100465 num_frames_ = ComputeNumFrames(thread_, walk_kind_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700466 }
467 return num_frames_;
468 }
469
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700470 size_t GetFrameDepth() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
471 return cur_depth_;
472 }
473
Ian Rogers5cf98192014-05-29 21:31:50 -0700474 // Get the method and dex pc immediately after the one that's currently being visited.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700475 bool GetNextMethodAndDexPc(ArtMethod** next_method, uint32_t* next_dex_pc)
Ian Rogers5cf98192014-05-29 21:31:50 -0700476 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
477
Mathieu Chartiere401d142015-04-22 13:56:20 -0700478 bool IsReferenceVReg(ArtMethod* m, uint16_t vreg)
Mathieu Chartier50030ef2015-05-08 14:19:26 -0700479 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
480
Mathieu Chartiere401d142015-04-22 13:56:20 -0700481 bool GetVReg(ArtMethod* m, uint16_t vreg, VRegKind kind, uint32_t* val) const
Ian Rogers2bcb4a42012-11-08 10:39:18 -0800482 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700483
Mathieu Chartiere401d142015-04-22 13:56:20 -0700484 bool GetVRegPair(ArtMethod* m, uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi,
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200485 uint64_t* val) const
486 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
487
Mathieu Chartiere401d142015-04-22 13:56:20 -0700488 bool SetVReg(ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700489 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700490
Mathieu Chartiere401d142015-04-22 13:56:20 -0700491 bool SetVRegPair(ArtMethod* m, uint16_t vreg, uint64_t new_value,
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200492 VRegKind kind_lo, VRegKind kind_hi)
493 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
494
Mathieu Chartier815873e2014-02-13 18:02:13 -0800495 uintptr_t* GetGPRAddress(uint32_t reg) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700496
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700497 // This is a fast-path for getting/setting values in a quick frame.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700498 uint32_t* GetVRegAddrFromQuickCode(ArtMethod** cur_quick_frame,
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000499 const DexFile::CodeItem* code_item,
500 uint32_t core_spills, uint32_t fp_spills, size_t frame_size,
501 uint16_t vreg) const {
502 int offset = GetVRegOffsetFromQuickCode(
503 code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA);
Ian Rogers0ec569a2012-07-01 16:43:46 -0700504 DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame());
Ian Rogers13735952014-10-08 12:43:28 -0700505 uint8_t* vreg_addr = reinterpret_cast<uint8_t*>(cur_quick_frame) + offset;
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700506 return reinterpret_cast<uint32_t*>(vreg_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700507 }
508
Ian Rogersef7d42f2014-01-06 12:55:46 -0800509 uintptr_t GetReturnPc() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700510
Ian Rogersef7d42f2014-01-06 12:55:46 -0800511 void SetReturnPc(uintptr_t new_ret_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700512
513 /*
514 * Return sp-relative offset for a Dalvik virtual register, compiler
515 * spill or Method* in bytes using Method*.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700516 * Note that (reg == -1) denotes an invalid Dalvik register. For the
517 * positive values, the Dalvik registers come first, followed by the
518 * Method*, followed by other special temporaries if any, followed by
519 * regular compiler temporary. As of now we only have the Method* as
520 * as a special compiler temporary.
521 * A compiler temporary can be thought of as a virtual register that
522 * does not exist in the dex but holds intermediate values to help
523 * optimizations and code generation. A special compiler temporary is
524 * one whose location in frame is well known while non-special ones
525 * do not have a requirement on location in frame as long as code
526 * generator itself knows how to access them.
Ian Rogers0399dde2012-06-06 17:09:28 -0700527 *
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700528 * +-------------------------------+
529 * | IN[ins-1] | {Note: resides in caller's frame}
530 * | . |
531 * | IN[0] |
Mathieu Chartiere401d142015-04-22 13:56:20 -0700532 * | caller's ArtMethod | ... ArtMethod*
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700533 * +===============================+ {Note: start of callee's frame}
534 * | core callee-save spill | {variable sized}
535 * +-------------------------------+
536 * | fp callee-save spill |
537 * +-------------------------------+
538 * | filler word | {For compatibility, if V[locals-1] used as wide
539 * +-------------------------------+
540 * | V[locals-1] |
541 * | V[locals-2] |
542 * | . |
543 * | . | ... (reg == 2)
544 * | V[1] | ... (reg == 1)
545 * | V[0] | ... (reg == 0) <---- "locals_start"
546 * +-------------------------------+
547 * | stack alignment padding | {0 to (kStackAlignWords-1) of padding}
548 * +-------------------------------+
549 * | Compiler temp region | ... (reg >= max_num_special_temps)
550 * | . |
551 * | . |
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700552 * | V[max_num_special_temps + 1] |
553 * | V[max_num_special_temps + 0] |
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700554 * +-------------------------------+
555 * | OUT[outs-1] |
556 * | OUT[outs-2] |
557 * | . |
558 * | OUT[0] |
Mathieu Chartiere401d142015-04-22 13:56:20 -0700559 * | ArtMethod* | ... (reg == num_total_code_regs == special_temp_value) <<== sp, 16-byte aligned
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700560 * +===============================+
Ian Rogers0399dde2012-06-06 17:09:28 -0700561 */
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000562 static int GetVRegOffsetFromQuickCode(const DexFile::CodeItem* code_item,
563 uint32_t core_spills, uint32_t fp_spills,
Mathieu Chartiere401d142015-04-22 13:56:20 -0700564 size_t frame_size, int reg, InstructionSet isa);
Ian Rogers0399dde2012-06-06 17:09:28 -0700565
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000566 static int GetOutVROffset(uint16_t out_num, InstructionSet isa) {
buzbee82818642014-06-04 15:35:41 -0700567 // According to stack model, the first out is above the Method referernce.
Mathieu Chartiere401d142015-04-22 13:56:20 -0700568 return InstructionSetPointerSize(isa) + out_num * sizeof(uint32_t);
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800569 }
570
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100571 bool IsInInlinedFrame() const {
Nicolas Geoffray57f61612015-05-15 13:20:41 +0100572 return current_inlining_depth_ != 0;
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100573 }
574
Ian Rogers0399dde2012-06-06 17:09:28 -0700575 uintptr_t GetCurrentQuickFramePc() const {
576 return cur_quick_frame_pc_;
577 }
578
Mathieu Chartiere401d142015-04-22 13:56:20 -0700579 ArtMethod** GetCurrentQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700580 return cur_quick_frame_;
581 }
582
583 ShadowFrame* GetCurrentShadowFrame() const {
584 return cur_shadow_frame_;
585 }
586
Mathieu Chartiere401d142015-04-22 13:56:20 -0700587 HandleScope* GetCurrentHandleScope(size_t pointer_size) const {
588 ArtMethod** sp = GetCurrentQuickFrame();
589 // Skip ArtMethod*; handle scope comes next;
590 return reinterpret_cast<HandleScope*>(reinterpret_cast<uintptr_t>(sp) + pointer_size);
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700591 }
592
Ian Rogers40e3bac2012-11-20 00:09:14 -0800593 std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
594
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100595 static size_t ComputeNumFrames(Thread* thread, StackWalkKind walk_kind)
596 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800597
Ian Rogers7a22fa62013-01-23 12:16:16 -0800598 static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800599
Ian Rogers0399dde2012-06-06 17:09:28 -0700600 private:
Ian Rogers5cf98192014-05-29 21:31:50 -0700601 // Private constructor known in the case that num_frames_ has already been computed.
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100602 StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind, size_t num_frames)
Ian Rogers5cf98192014-05-29 21:31:50 -0700603 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
604
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +0100605 bool IsAccessibleRegister(uint32_t reg, bool is_float) const {
606 return is_float ? IsAccessibleFPR(reg) : IsAccessibleGPR(reg);
607 }
608 uintptr_t GetRegister(uint32_t reg, bool is_float) const {
609 DCHECK(IsAccessibleRegister(reg, is_float));
610 return is_float ? GetFPR(reg) : GetGPR(reg);
611 }
612 void SetRegister(uint32_t reg, uintptr_t value, bool is_float) {
613 DCHECK(IsAccessibleRegister(reg, is_float));
614 if (is_float) {
615 SetFPR(reg, value);
616 } else {
617 SetGPR(reg, value);
618 }
619 }
620
621 bool IsAccessibleGPR(uint32_t reg) const;
622 uintptr_t GetGPR(uint32_t reg) const;
623 void SetGPR(uint32_t reg, uintptr_t value);
624
625 bool IsAccessibleFPR(uint32_t reg) const;
626 uintptr_t GetFPR(uint32_t reg) const;
627 void SetFPR(uint32_t reg, uintptr_t value);
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200628
Mathieu Chartiere401d142015-04-22 13:56:20 -0700629 bool GetVRegFromQuickCode(ArtMethod* m, uint16_t vreg, VRegKind kind,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100630 uint32_t* val) const
631 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700632 bool GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKind kind,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100633 uint32_t* val) const
634 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
635 bool GetRegisterIfAccessible(uint32_t reg, VRegKind kind, uint32_t* val) const
636 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
637
Mathieu Chartiere401d142015-04-22 13:56:20 -0700638 bool GetVRegPairFromQuickCode(ArtMethod* m, uint16_t vreg, VRegKind kind_lo,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100639 VRegKind kind_hi, uint64_t* val) const
640 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartiere401d142015-04-22 13:56:20 -0700641 bool GetVRegPairFromOptimizedCode(ArtMethod* m, uint16_t vreg,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100642 VRegKind kind_lo, VRegKind kind_hi,
643 uint64_t* val) const
644 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
645 bool GetRegisterPairIfAccessible(uint32_t reg_lo, uint32_t reg_hi, VRegKind kind_lo,
646 uint64_t* val) const
647 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
648
Mathieu Chartiere401d142015-04-22 13:56:20 -0700649 bool SetVRegFromQuickCode(ArtMethod* m, uint16_t vreg, uint32_t new_value,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100650 VRegKind kind)
651 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100652 bool SetRegisterIfAccessible(uint32_t reg, uint32_t new_value, VRegKind kind)
653 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
654
Mathieu Chartiere401d142015-04-22 13:56:20 -0700655 bool SetVRegPairFromQuickCode(ArtMethod* m, uint16_t vreg, uint64_t new_value,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100656 VRegKind kind_lo, VRegKind kind_hi)
657 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100658 bool SetRegisterPairIfAccessible(uint32_t reg_lo, uint32_t reg_hi, uint64_t new_value,
659 bool is_float)
660 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
661
Ian Rogersb726dcb2012-09-05 08:57:23 -0700662 void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700663
Nicolas Geoffray57f61612015-05-15 13:20:41 +0100664 InlineInfo GetCurrentInlineInfo() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
665
Ian Rogers7a22fa62013-01-23 12:16:16 -0800666 Thread* const thread_;
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100667 const StackWalkKind walk_kind_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700668 ShadowFrame* cur_shadow_frame_;
Mathieu Chartiere401d142015-04-22 13:56:20 -0700669 ArtMethod** cur_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700670 uintptr_t cur_quick_frame_pc_;
671 // Lazily computed, number of frames in the stack.
672 size_t num_frames_;
673 // Depth of the frame we're currently at.
674 size_t cur_depth_;
Nicolas Geoffray57f61612015-05-15 13:20:41 +0100675 // Current inlining depth of the method we are currently at.
676 // 0 if there is no inlined frame.
677 size_t current_inlining_depth_;
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700678
Ian Rogers0399dde2012-06-06 17:09:28 -0700679 protected:
680 Context* const context_;
681};
682
Elliott Hughes68e76522011-10-05 13:22:16 -0700683} // namespace art
684
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700685#endif // ART_RUNTIME_STACK_H_