blob: 5a86ca1b3bdf8ce0cbb8f434964ff847087d36b1 [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"
Ian Rogerse63db272014-07-15 15:36:11 -070024#include "dex_file.h"
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -080025#include "gc_root.h"
Ian Rogerse63db272014-07-15 15:36:11 -070026#include "mirror/object_reference.h"
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -080027#include "read_barrier.h"
Ian Rogerse63db272014-07-15 15:36:11 -070028#include "throw_location.h"
29#include "utils.h"
30#include "verify_object.h"
31
Elliott Hughes68e76522011-10-05 13:22:16 -070032namespace art {
33
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080034namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070035 class ArtMethod;
36 class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080037} // namespace mirror
38
39class Context;
Ian Rogers0399dde2012-06-06 17:09:28 -070040class ShadowFrame;
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070041class HandleScope;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070042class ScopedObjectAccess;
Elliott Hughes68e76522011-10-05 13:22:16 -070043class Thread;
44
Ian Rogers2bcb4a42012-11-08 10:39:18 -080045// The kind of vreg being accessed in calls to Set/GetVReg.
46enum VRegKind {
47 kReferenceVReg,
48 kIntVReg,
49 kFloatVReg,
50 kLongLoVReg,
51 kLongHiVReg,
52 kDoubleLoVReg,
53 kDoubleHiVReg,
54 kConstant,
55 kImpreciseConstant,
56 kUndefined,
57};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070058std::ostream& operator<<(std::ostream& os, const VRegKind& rhs);
Ian Rogers2bcb4a42012-11-08 10:39:18 -080059
Ian Rogersef7d42f2014-01-06 12:55:46 -080060// A reference from the shadow stack to a MirrorType object within the Java heap.
61template<class MirrorType>
62class MANAGED StackReference : public mirror::ObjectReference<false, MirrorType> {
63 public:
64 StackReference<MirrorType>() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
65 : mirror::ObjectReference<false, MirrorType>(nullptr) {}
66
67 static StackReference<MirrorType> FromMirrorPtr(MirrorType* p)
68 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
69 return StackReference<MirrorType>(p);
70 }
71
72 private:
73 StackReference<MirrorType>(MirrorType* p) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
74 : mirror::ObjectReference<false, MirrorType>(p) {}
75};
76
Elliott Hughes956af0f2014-12-11 14:34:28 -080077// ShadowFrame has 2 possible layouts:
Mathieu Chartier67022432012-11-29 18:04:50 -080078// - interpreter - separate VRegs and reference arrays. References are in the reference array.
79// - JNI - just VRegs, but where every VReg holds a reference.
Ian Rogers0399dde2012-06-06 17:09:28 -070080class ShadowFrame {
Elliott Hughes68e76522011-10-05 13:22:16 -070081 public:
Ian Rogersef7d42f2014-01-06 12:55:46 -080082 // Compute size of ShadowFrame in bytes assuming it has a reference array.
Jeff Hao66135192013-05-14 11:02:41 -070083 static size_t ComputeSize(uint32_t num_vregs) {
84 return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) +
Ian Rogersef7d42f2014-01-06 12:55:46 -080085 (sizeof(StackReference<mirror::Object>) * num_vregs);
Jeff Hao66135192013-05-14 11:02:41 -070086 }
87
88 // Create ShadowFrame in heap for deoptimization.
TDYa127ce4cc0d2012-11-18 16:59:53 -080089 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Brian Carlstromea46f952013-07-30 01:26:50 -070090 mirror::ArtMethod* method, uint32_t dex_pc) {
Jeff Hao66135192013-05-14 11:02:41 -070091 uint8_t* memory = new uint8_t[ComputeSize(num_vregs)];
Sebastien Hertzc61124b2013-09-10 11:44:19 +020092 return Create(num_vregs, link, method, dex_pc, memory);
Jeff Hao66135192013-05-14 11:02:41 -070093 }
94
95 // Create ShadowFrame for interpreter using provided memory.
96 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Brian Carlstromea46f952013-07-30 01:26:50 -070097 mirror::ArtMethod* method, uint32_t dex_pc, void* memory) {
TDYa127ce4cc0d2012-11-18 16:59:53 -080098 ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
99 return sf;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700100 }
101 ~ShadowFrame() {}
102
TDYa127ce4cc0d2012-11-18 16:59:53 -0800103 bool HasReferenceArray() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700104 return true;
Ian Rogers0399dde2012-06-06 17:09:28 -0700105 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700106
TDYa127ce4cc0d2012-11-18 16:59:53 -0800107 uint32_t NumberOfVRegs() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700108 return number_of_vregs_;
Ian Rogers5438ad82012-10-15 17:22:44 -0700109 }
110
Ian Rogers0399dde2012-06-06 17:09:28 -0700111 uint32_t GetDexPC() const {
112 return dex_pc_;
113 }
114
115 void SetDexPC(uint32_t dex_pc) {
116 dex_pc_ = dex_pc;
117 }
118
Ian Rogers0399dde2012-06-06 17:09:28 -0700119 ShadowFrame* GetLink() const {
120 return link_;
121 }
122
123 void SetLink(ShadowFrame* frame) {
124 DCHECK_NE(this, frame);
125 link_ = frame;
126 }
127
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700128 int32_t GetVReg(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800129 DCHECK_LT(i, NumberOfVRegs());
130 const uint32_t* vreg = &vregs_[i];
131 return *reinterpret_cast<const int32_t*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700132 }
133
134 float GetVRegFloat(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800135 DCHECK_LT(i, NumberOfVRegs());
136 // NOTE: Strict-aliasing?
137 const uint32_t* vreg = &vregs_[i];
138 return *reinterpret_cast<const float*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700139 }
140
141 int64_t GetVRegLong(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200142 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800143 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700144 // Alignment attribute required for GCC 4.8
145 typedef const int64_t unaligned_int64 __attribute__ ((aligned (4)));
146 return *reinterpret_cast<unaligned_int64*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700147 }
148
149 double GetVRegDouble(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200150 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800151 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700152 // Alignment attribute required for GCC 4.8
153 typedef const double unaligned_double __attribute__ ((aligned (4)));
154 return *reinterpret_cast<unaligned_double*>(vreg);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800155 }
156
Mathieu Chartier4e305412014-02-19 10:54:44 -0800157 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800158 mirror::Object* GetVRegReference(size_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800159 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800160 mirror::Object* ref;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800161 if (HasReferenceArray()) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800162 ref = References()[i].AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800163 } else {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800164 const uint32_t* vreg_ptr = &vregs_[i];
Mathieu Chartier4e305412014-02-19 10:54:44 -0800165 ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800166 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800167 if (kUseReadBarrier) {
168 ReadBarrier::AssertToSpaceInvariant(ref);
169 }
Mathieu Chartier4e305412014-02-19 10:54:44 -0800170 if (kVerifyFlags & kVerifyReads) {
171 VerifyObject(ref);
172 }
173 return ref;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700174 }
175
Jeff Hao16743632013-05-08 10:59:04 -0700176 // Get view of vregs as range of consecutive arguments starting at i.
177 uint32_t* GetVRegArgs(size_t i) {
178 return &vregs_[i];
179 }
180
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700181 void SetVReg(size_t i, int32_t val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800182 DCHECK_LT(i, NumberOfVRegs());
183 uint32_t* vreg = &vregs_[i];
184 *reinterpret_cast<int32_t*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700185 // This is needed for moving collectors since these can update the vreg references if they
186 // happen to agree with references in the reference array.
187 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800188 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700189 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700190 }
191
192 void SetVRegFloat(size_t i, float val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800193 DCHECK_LT(i, NumberOfVRegs());
194 uint32_t* vreg = &vregs_[i];
195 *reinterpret_cast<float*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700196 // This is needed for moving collectors since these can update the vreg references if they
197 // happen to agree with references in the reference array.
198 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800199 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700200 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700201 }
202
203 void SetVRegLong(size_t i, int64_t val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200204 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800205 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700206 // Alignment attribute required for GCC 4.8
207 typedef int64_t unaligned_int64 __attribute__ ((aligned (4)));
208 *reinterpret_cast<unaligned_int64*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700209 // This is needed for moving collectors since these can update the vreg references if they
210 // happen to agree with references in the reference array.
211 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800212 References()[i].Clear();
213 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700214 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700215 }
216
217 void SetVRegDouble(size_t i, double val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200218 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800219 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700220 // Alignment attribute required for GCC 4.8
221 typedef double unaligned_double __attribute__ ((aligned (4)));
222 *reinterpret_cast<unaligned_double*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700223 // This is needed for moving collectors since these can update the vreg references if they
224 // happen to agree with references in the reference array.
225 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800226 References()[i].Clear();
227 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700228 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700229 }
230
Mathieu Chartier4e305412014-02-19 10:54:44 -0800231 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800232 void SetVRegReference(size_t i, mirror::Object* val) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800233 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800234 if (kVerifyFlags & kVerifyWrites) {
235 VerifyObject(val);
236 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800237 if (kUseReadBarrier) {
238 ReadBarrier::AssertToSpaceInvariant(val);
239 }
TDYa127ce4cc0d2012-11-18 16:59:53 -0800240 uint32_t* vreg = &vregs_[i];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800241 reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800242 if (HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800243 References()[i].Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800244 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700245 }
246
Ian Rogersef7d42f2014-01-06 12:55:46 -0800247 mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
248 DCHECK(method_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700249 return method_;
Elliott Hughes68e76522011-10-05 13:22:16 -0700250 }
251
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700252 mirror::ArtMethod** GetMethodAddress() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
253 DCHECK(method_ != nullptr);
254 return &method_;
255 }
256
Ian Rogers62d6c772013-02-27 08:32:07 -0800257 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
258
Jeff Haoe701f482013-05-24 11:50:49 -0700259 mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
260
Ian Rogers62d6c772013-02-27 08:32:07 -0800261 ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
262
Ian Rogersef7d42f2014-01-06 12:55:46 -0800263 bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800264 if (HasReferenceArray()) {
265 return ((&References()[0] <= shadow_frame_entry_obj) &&
266 (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1])));
267 } else {
268 uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj);
269 return ((&vregs_[0] <= shadow_frame_entry) &&
270 (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1])));
Ian Rogers0399dde2012-06-06 17:09:28 -0700271 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700272 }
273
Ian Rogers0399dde2012-06-06 17:09:28 -0700274 static size_t LinkOffset() {
275 return OFFSETOF_MEMBER(ShadowFrame, link_);
276 }
277
Ian Rogers0399dde2012-06-06 17:09:28 -0700278 static size_t MethodOffset() {
279 return OFFSETOF_MEMBER(ShadowFrame, method_);
280 }
281
Ian Rogers0399dde2012-06-06 17:09:28 -0700282 static size_t DexPCOffset() {
283 return OFFSETOF_MEMBER(ShadowFrame, dex_pc_);
284 }
285
Ian Rogers5438ad82012-10-15 17:22:44 -0700286 static size_t NumberOfVRegsOffset() {
287 return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_);
288 }
289
TDYa127ce4cc0d2012-11-18 16:59:53 -0800290 static size_t VRegsOffset() {
291 return OFFSETOF_MEMBER(ShadowFrame, vregs_);
Ian Rogers5438ad82012-10-15 17:22:44 -0700292 }
293
Elliott Hughes68e76522011-10-05 13:22:16 -0700294 private:
Brian Carlstromea46f952013-07-30 01:26:50 -0700295 ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800296 uint32_t dex_pc, bool has_reference_array)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800297 : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) {
298 if (has_reference_array) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800299 memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(StackReference<mirror::Object>)));
Mathieu Chartier67022432012-11-29 18:04:50 -0800300 } else {
Jeff Haoe701f482013-05-24 11:50:49 -0700301 memset(vregs_, 0, num_vregs * sizeof(uint32_t));
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700302 }
303 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700304
Ian Rogersef7d42f2014-01-06 12:55:46 -0800305 const StackReference<mirror::Object>* References() const {
Mathieu Chartier67022432012-11-29 18:04:50 -0800306 DCHECK(HasReferenceArray());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800307 const uint32_t* vreg_end = &vregs_[NumberOfVRegs()];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800308 return reinterpret_cast<const StackReference<mirror::Object>*>(vreg_end);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800309 }
310
Ian Rogersef7d42f2014-01-06 12:55:46 -0800311 StackReference<mirror::Object>* References() {
312 return const_cast<StackReference<mirror::Object>*>(const_cast<const ShadowFrame*>(this)->References());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800313 }
314
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700315 const uint32_t number_of_vregs_;
Ian Rogers5438ad82012-10-15 17:22:44 -0700316 // Link to previous shadow frame or NULL.
Ian Rogers0399dde2012-06-06 17:09:28 -0700317 ShadowFrame* link_;
Brian Carlstromea46f952013-07-30 01:26:50 -0700318 mirror::ArtMethod* method_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700319 uint32_t dex_pc_;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800320 uint32_t vregs_[0];
Elliott Hughes68e76522011-10-05 13:22:16 -0700321
Ian Rogers0399dde2012-06-06 17:09:28 -0700322 DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame);
Elliott Hughes68e76522011-10-05 13:22:16 -0700323};
324
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -0800325class JavaFrameRootInfo : public RootInfo {
326 public:
327 JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg)
328 : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) {
329 }
330 virtual void Describe(std::ostream& os) const OVERRIDE
331 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
332
333 private:
334 const StackVisitor* const stack_visitor_;
335 const size_t vreg_;
336};
337
Ian Rogers0399dde2012-06-06 17:09:28 -0700338// The managed stack is used to record fragments of managed code stacks. Managed code stacks
339// may either be shadow frames or lists of frames using fixed frame sizes. Transition records are
340// necessary for transitions between code using different frame layouts and transitions into native
341// code.
Ian Rogersdf1ce912012-11-27 17:07:11 -0800342class PACKED(4) ManagedStack {
Ian Rogers0399dde2012-06-06 17:09:28 -0700343 public:
Ian Rogersca190662012-06-26 15:45:57 -0700344 ManagedStack()
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700345 : top_quick_frame_(nullptr), link_(nullptr), top_shadow_frame_(nullptr) {}
Ian Rogers81d425b2012-09-27 16:03:43 -0700346
347 void PushManagedStackFragment(ManagedStack* fragment) {
348 // Copy this top fragment into given fragment.
349 memcpy(fragment, this, sizeof(ManagedStack));
350 // Clear this fragment, which has become the top.
351 memset(this, 0, sizeof(ManagedStack));
352 // Link our top fragment onto the given fragment.
353 link_ = fragment;
354 }
355
356 void PopManagedStackFragment(const ManagedStack& fragment) {
357 DCHECK(&fragment == link_);
358 // Copy this given fragment back to the top.
359 memcpy(this, &fragment, sizeof(ManagedStack));
360 }
Ian Rogers0399dde2012-06-06 17:09:28 -0700361
362 ManagedStack* GetLink() const {
363 return link_;
364 }
365
Andreas Gampecf4035a2014-05-28 22:43:01 -0700366 StackReference<mirror::ArtMethod>* GetTopQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700367 return top_quick_frame_;
368 }
369
Andreas Gampecf4035a2014-05-28 22:43:01 -0700370 void SetTopQuickFrame(StackReference<mirror::ArtMethod>* top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700371 DCHECK(top_shadow_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700372 top_quick_frame_ = top;
373 }
374
Ian Rogers0399dde2012-06-06 17:09:28 -0700375 static size_t TopQuickFrameOffset() {
376 return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_);
377 }
378
Ian Rogers0399dde2012-06-06 17:09:28 -0700379 ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700380 DCHECK(top_quick_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700381 ShadowFrame* old_frame = top_shadow_frame_;
382 top_shadow_frame_ = new_top_frame;
383 new_top_frame->SetLink(old_frame);
384 return old_frame;
385 }
386
387 ShadowFrame* PopShadowFrame() {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700388 DCHECK(top_quick_frame_ == nullptr);
389 CHECK(top_shadow_frame_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700390 ShadowFrame* frame = top_shadow_frame_;
391 top_shadow_frame_ = frame->GetLink();
392 return frame;
393 }
394
395 ShadowFrame* GetTopShadowFrame() const {
396 return top_shadow_frame_;
397 }
398
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800399 void SetTopShadowFrame(ShadowFrame* top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700400 DCHECK(top_quick_frame_ == nullptr);
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800401 top_shadow_frame_ = top;
402 }
403
Ian Rogers0399dde2012-06-06 17:09:28 -0700404 static size_t TopShadowFrameOffset() {
405 return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_);
406 }
407
Ian Rogersef7d42f2014-01-06 12:55:46 -0800408 size_t NumJniShadowFrameReferences() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700409
Ian Rogersef7d42f2014-01-06 12:55:46 -0800410 bool ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700411
412 private:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700413 StackReference<mirror::ArtMethod>* top_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700414 ManagedStack* link_;
415 ShadowFrame* top_shadow_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700416};
417
418class StackVisitor {
419 protected:
Ian Rogers7a22fa62013-01-23 12:16:16 -0800420 StackVisitor(Thread* thread, Context* context) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700421
422 public:
423 virtual ~StackVisitor() {}
424
425 // Return 'true' if we should continue to visit more frames, 'false' to stop.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700426 virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
Ian Rogers0399dde2012-06-06 17:09:28 -0700427
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700428 void WalkStack(bool include_transitions = false)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700429 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700430
Ian Rogersef7d42f2014-01-06 12:55:46 -0800431 mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
432 if (cur_shadow_frame_ != nullptr) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700433 return cur_shadow_frame_->GetMethod();
Ian Rogersef7d42f2014-01-06 12:55:46 -0800434 } else if (cur_quick_frame_ != nullptr) {
Andreas Gampecf4035a2014-05-28 22:43:01 -0700435 return cur_quick_frame_->AsMirrorPtr();
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700436 } else {
437 return nullptr;
438 }
439 }
440
Ian Rogers0399dde2012-06-06 17:09:28 -0700441 bool IsShadowFrame() const {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800442 return cur_shadow_frame_ != nullptr;
Ian Rogers0399dde2012-06-06 17:09:28 -0700443 }
444
Dave Allisonb373e092014-02-20 16:06:36 -0800445 uint32_t GetDexPc(bool abort_on_failure = true) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0c7abda2012-09-19 13:33:42 -0700446
Ian Rogers62d6c772013-02-27 08:32:07 -0800447 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
448
Ian Rogers0c7abda2012-09-19 13:33:42 -0700449 size_t GetNativePcOffset() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
450
Ian Rogersef7d42f2014-01-06 12:55:46 -0800451 uintptr_t* CalleeSaveAddress(int num, size_t frame_size) const
452 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700453 // Callee saves are held at the top of the frame
Ian Rogersef7d42f2014-01-06 12:55:46 -0800454 DCHECK(GetMethod() != nullptr);
Ian Rogers13735952014-10-08 12:43:28 -0700455 uint8_t* save_addr =
456 reinterpret_cast<uint8_t*>(cur_quick_frame_) + frame_size - ((num + 1) * sizeof(void*));
Andreas Gampebf6b92a2014-03-05 16:11:04 -0800457#if defined(__i386__) || defined(__x86_64__)
Ian Rogers13735952014-10-08 12:43:28 -0700458 save_addr -= sizeof(void*); // account for return address
Ian Rogers0399dde2012-06-06 17:09:28 -0700459#endif
Mathieu Chartier67022432012-11-29 18:04:50 -0800460 return reinterpret_cast<uintptr_t*>(save_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700461 }
462
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700463 // Returns the height of the stack in the managed stack frames, including transitions.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700464 size_t GetFrameHeight() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800465 return GetNumFrames() - cur_depth_ - 1;
Ian Rogers0399dde2012-06-06 17:09:28 -0700466 }
467
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700468 // Returns a frame ID for JDWP use, starting from 1.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700469 size_t GetFrameId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700470 return GetFrameHeight() + 1;
471 }
472
Ian Rogersb726dcb2012-09-05 08:57:23 -0700473 size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700474 if (num_frames_ == 0) {
Ian Rogers7a22fa62013-01-23 12:16:16 -0800475 num_frames_ = ComputeNumFrames(thread_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700476 }
477 return num_frames_;
478 }
479
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700480 size_t GetFrameDepth() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
481 return cur_depth_;
482 }
483
Ian Rogers5cf98192014-05-29 21:31:50 -0700484 // Get the method and dex pc immediately after the one that's currently being visited.
485 bool GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32_t* next_dex_pc)
486 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
487
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200488 bool GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind, uint32_t* val) const
Ian Rogers2bcb4a42012-11-08 10:39:18 -0800489 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700490
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200491 uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const
492 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
493 uint32_t val;
494 bool success = GetVReg(m, vreg, kind, &val);
495 CHECK(success) << "Failed to read vreg " << vreg << " of kind " << kind;
496 return val;
497 }
498
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200499 bool GetVRegPair(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi,
500 uint64_t* val) const
501 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
502
503 uint64_t GetVRegPair(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind_lo,
504 VRegKind kind_hi) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
505 uint64_t val;
506 bool success = GetVRegPair(m, vreg, kind_lo, kind_hi, &val);
507 CHECK(success) << "Failed to read vreg pair " << vreg
508 << " of kind [" << kind_lo << "," << kind_hi << "]";
509 return val;
510 }
511
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200512 bool SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700513 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700514
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200515 bool SetVRegPair(mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value,
516 VRegKind kind_lo, VRegKind kind_hi)
517 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
518
Mathieu Chartier815873e2014-02-13 18:02:13 -0800519 uintptr_t* GetGPRAddress(uint32_t reg) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700520
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700521 // This is a fast-path for getting/setting values in a quick frame.
Andreas Gampecf4035a2014-05-28 22:43:01 -0700522 uint32_t* GetVRegAddr(StackReference<mirror::ArtMethod>* cur_quick_frame,
523 const DexFile::CodeItem* code_item,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800524 uint32_t core_spills, uint32_t fp_spills, size_t frame_size,
525 uint16_t vreg) const {
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000526 int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA);
Ian Rogers0ec569a2012-07-01 16:43:46 -0700527 DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame());
Ian Rogers13735952014-10-08 12:43:28 -0700528 uint8_t* vreg_addr = reinterpret_cast<uint8_t*>(cur_quick_frame) + offset;
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700529 return reinterpret_cast<uint32_t*>(vreg_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700530 }
531
Ian Rogersef7d42f2014-01-06 12:55:46 -0800532 uintptr_t GetReturnPc() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700533
Ian Rogersef7d42f2014-01-06 12:55:46 -0800534 void SetReturnPc(uintptr_t new_ret_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700535
536 /*
537 * Return sp-relative offset for a Dalvik virtual register, compiler
538 * spill or Method* in bytes using Method*.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700539 * Note that (reg == -1) denotes an invalid Dalvik register. For the
540 * positive values, the Dalvik registers come first, followed by the
541 * Method*, followed by other special temporaries if any, followed by
542 * regular compiler temporary. As of now we only have the Method* as
543 * as a special compiler temporary.
544 * A compiler temporary can be thought of as a virtual register that
545 * does not exist in the dex but holds intermediate values to help
546 * optimizations and code generation. A special compiler temporary is
547 * one whose location in frame is well known while non-special ones
548 * do not have a requirement on location in frame as long as code
549 * generator itself knows how to access them.
Ian Rogers0399dde2012-06-06 17:09:28 -0700550 *
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700551 * +-------------------------------+
552 * | IN[ins-1] | {Note: resides in caller's frame}
553 * | . |
554 * | IN[0] |
555 * | caller's ArtMethod | ... StackReference<ArtMethod>
556 * +===============================+ {Note: start of callee's frame}
557 * | core callee-save spill | {variable sized}
558 * +-------------------------------+
559 * | fp callee-save spill |
560 * +-------------------------------+
561 * | filler word | {For compatibility, if V[locals-1] used as wide
562 * +-------------------------------+
563 * | V[locals-1] |
564 * | V[locals-2] |
565 * | . |
566 * | . | ... (reg == 2)
567 * | V[1] | ... (reg == 1)
568 * | V[0] | ... (reg == 0) <---- "locals_start"
569 * +-------------------------------+
570 * | stack alignment padding | {0 to (kStackAlignWords-1) of padding}
571 * +-------------------------------+
572 * | Compiler temp region | ... (reg >= max_num_special_temps)
573 * | . |
574 * | . |
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700575 * | V[max_num_special_temps + 1] |
576 * | V[max_num_special_temps + 0] |
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700577 * +-------------------------------+
578 * | OUT[outs-1] |
579 * | OUT[outs-2] |
580 * | . |
581 * | OUT[0] |
582 * | StackReference<ArtMethod> | ... (reg == num_total_code_regs == special_temp_value) <<== sp, 16-byte aligned
583 * +===============================+
Ian Rogers0399dde2012-06-06 17:09:28 -0700584 */
585 static int GetVRegOffset(const DexFile::CodeItem* code_item,
Ian Rogersb23a7722012-10-09 16:54:26 -0700586 uint32_t core_spills, uint32_t fp_spills,
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000587 size_t frame_size, int reg, InstructionSet isa) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700588 DCHECK_EQ(frame_size & (kStackAlignment - 1), 0U);
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700589 DCHECK_NE(reg, -1);
Vladimir Marko81949632014-05-02 11:53:22 +0100590 int spill_size = POPCOUNT(core_spills) * GetBytesPerGprSpillLocation(isa)
591 + POPCOUNT(fp_spills) * GetBytesPerFprSpillLocation(isa)
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000592 + sizeof(uint32_t); // Filler.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700593 int num_regs = code_item->registers_size_ - code_item->ins_size_;
594 int temp_threshold = code_item->registers_size_;
595 const int max_num_special_temps = 1;
596 if (reg == temp_threshold) {
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800597 // The current method pointer corresponds to special location on stack.
598 return 0;
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700599 } else if (reg >= temp_threshold + max_num_special_temps) {
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800600 /*
601 * Special temporaries may have custom locations and the logic above deals with that.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700602 * However, non-special temporaries are placed relative to the outs.
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800603 */
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700604 int temps_start = sizeof(StackReference<mirror::ArtMethod>) + code_item->outs_size_ * sizeof(uint32_t);
605 int relative_offset = (reg - (temp_threshold + max_num_special_temps)) * sizeof(uint32_t);
606 return temps_start + relative_offset;
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800607 } else if (reg < num_regs) {
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700608 int locals_start = frame_size - spill_size - num_regs * sizeof(uint32_t);
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800609 return locals_start + (reg * sizeof(uint32_t));
Ian Rogers0399dde2012-06-06 17:09:28 -0700610 } else {
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800611 // Handle ins.
buzbee82818642014-06-04 15:35:41 -0700612 return frame_size + ((reg - num_regs) * sizeof(uint32_t)) +
613 sizeof(StackReference<mirror::ArtMethod>);
Ian Rogers0399dde2012-06-06 17:09:28 -0700614 }
615 }
616
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000617 static int GetOutVROffset(uint16_t out_num, InstructionSet isa) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700618 UNUSED(isa);
buzbee82818642014-06-04 15:35:41 -0700619 // According to stack model, the first out is above the Method referernce.
620 return sizeof(StackReference<mirror::ArtMethod>) + (out_num * sizeof(uint32_t));
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800621 }
622
Ian Rogers0399dde2012-06-06 17:09:28 -0700623 uintptr_t GetCurrentQuickFramePc() const {
624 return cur_quick_frame_pc_;
625 }
626
Andreas Gampecf4035a2014-05-28 22:43:01 -0700627 StackReference<mirror::ArtMethod>* GetCurrentQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700628 return cur_quick_frame_;
629 }
630
631 ShadowFrame* GetCurrentShadowFrame() const {
632 return cur_shadow_frame_;
633 }
634
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700635 HandleScope* GetCurrentHandleScope() const {
Andreas Gampecf4035a2014-05-28 22:43:01 -0700636 StackReference<mirror::ArtMethod>* sp = GetCurrentQuickFrame();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700637 ++sp; // Skip Method*; handle scope comes next;
638 return reinterpret_cast<HandleScope*>(sp);
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700639 }
640
Ian Rogers40e3bac2012-11-20 00:09:14 -0800641 std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
642
Ian Rogers7a22fa62013-01-23 12:16:16 -0800643 static size_t ComputeNumFrames(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800644
Ian Rogers7a22fa62013-01-23 12:16:16 -0800645 static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800646
Ian Rogers0399dde2012-06-06 17:09:28 -0700647 private:
Ian Rogers5cf98192014-05-29 21:31:50 -0700648 // Private constructor known in the case that num_frames_ has already been computed.
649 StackVisitor(Thread* thread, Context* context, size_t num_frames)
650 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
651
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +0100652 bool IsAccessibleRegister(uint32_t reg, bool is_float) const {
653 return is_float ? IsAccessibleFPR(reg) : IsAccessibleGPR(reg);
654 }
655 uintptr_t GetRegister(uint32_t reg, bool is_float) const {
656 DCHECK(IsAccessibleRegister(reg, is_float));
657 return is_float ? GetFPR(reg) : GetGPR(reg);
658 }
659 void SetRegister(uint32_t reg, uintptr_t value, bool is_float) {
660 DCHECK(IsAccessibleRegister(reg, is_float));
661 if (is_float) {
662 SetFPR(reg, value);
663 } else {
664 SetGPR(reg, value);
665 }
666 }
667
668 bool IsAccessibleGPR(uint32_t reg) const;
669 uintptr_t GetGPR(uint32_t reg) const;
670 void SetGPR(uint32_t reg, uintptr_t value);
671
672 bool IsAccessibleFPR(uint32_t reg) const;
673 uintptr_t GetFPR(uint32_t reg) const;
674 void SetFPR(uint32_t reg, uintptr_t value);
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200675
Ian Rogersb726dcb2012-09-05 08:57:23 -0700676 void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700677
Ian Rogers7a22fa62013-01-23 12:16:16 -0800678 Thread* const thread_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700679 ShadowFrame* cur_shadow_frame_;
Andreas Gampecf4035a2014-05-28 22:43:01 -0700680 StackReference<mirror::ArtMethod>* cur_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700681 uintptr_t cur_quick_frame_pc_;
682 // Lazily computed, number of frames in the stack.
683 size_t num_frames_;
684 // Depth of the frame we're currently at.
685 size_t cur_depth_;
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700686
Ian Rogers0399dde2012-06-06 17:09:28 -0700687 protected:
688 Context* const context_;
689};
690
Elliott Hughes68e76522011-10-05 13:22:16 -0700691} // namespace art
692
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700693#endif // ART_RUNTIME_STACK_H_