blob: 38dfe1b0b1384b7e35b940941a16ee5d59bb6d70 [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 Marko41b175a2015-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 Chartier3d21bdf2015-04-22 13:56:20 -070037class ArtMethod;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080038class Context;
Ian Rogers0399dde2012-06-06 17:09:28 -070039class ShadowFrame;
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070040class HandleScope;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070041class ScopedObjectAccess;
Nicolas Geoffray0aa50ce2015-03-10 11:03:29 +000042class StackVisitor;
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>
Mathieu Chartierbb87e0f2015-04-03 11:21:55 -070062class MANAGED StackReference : public mirror::CompressedReference<MirrorType> {
Ian Rogersef7d42f2014-01-06 12:55:46 -080063};
64
Elliott Hughes956af0f2014-12-11 14:34:28 -080065// ShadowFrame has 2 possible layouts:
Mathieu Chartier67022432012-11-29 18:04:50 -080066// - interpreter - separate VRegs and reference arrays. References are in the reference array.
67// - JNI - just VRegs, but where every VReg holds a reference.
Ian Rogers0399dde2012-06-06 17:09:28 -070068class ShadowFrame {
Elliott Hughes68e76522011-10-05 13:22:16 -070069 public:
Ian Rogersef7d42f2014-01-06 12:55:46 -080070 // Compute size of ShadowFrame in bytes assuming it has a reference array.
Jeff Hao66135192013-05-14 11:02:41 -070071 static size_t ComputeSize(uint32_t num_vregs) {
72 return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) +
Ian Rogersef7d42f2014-01-06 12:55:46 -080073 (sizeof(StackReference<mirror::Object>) * num_vregs);
Jeff Hao66135192013-05-14 11:02:41 -070074 }
75
76 // Create ShadowFrame in heap for deoptimization.
Christopher Ferris241a9582015-04-27 15:19:41 -070077 static ShadowFrame* CreateDeoptimizedFrame(uint32_t num_vregs, ShadowFrame* link,
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -070078 ArtMethod* method, uint32_t dex_pc) {
Jeff Hao66135192013-05-14 11:02:41 -070079 uint8_t* memory = new uint8_t[ComputeSize(num_vregs)];
Sebastien Hertzc61124b2013-09-10 11:44:19 +020080 return Create(num_vregs, link, method, dex_pc, memory);
Jeff Hao66135192013-05-14 11:02:41 -070081 }
82
Christopher Ferris241a9582015-04-27 15:19:41 -070083 // Delete a ShadowFrame allocated on the heap for deoptimization.
84 static void DeleteDeoptimizedFrame(ShadowFrame* sf) {
85 uint8_t* memory = reinterpret_cast<uint8_t*>(sf);
86 delete[] memory;
87 }
88
Jeff Hao66135192013-05-14 11:02:41 -070089 // Create ShadowFrame for interpreter using provided memory.
90 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -070091 ArtMethod* method, uint32_t dex_pc, void* memory) {
TDYa127ce4cc0d2012-11-18 16:59:53 -080092 ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
93 return sf;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -070094 }
95 ~ShadowFrame() {}
96
TDYa127ce4cc0d2012-11-18 16:59:53 -080097 bool HasReferenceArray() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -070098 return true;
Ian Rogers0399dde2012-06-06 17:09:28 -070099 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700100
TDYa127ce4cc0d2012-11-18 16:59:53 -0800101 uint32_t NumberOfVRegs() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700102 return number_of_vregs_;
Ian Rogers5438ad82012-10-15 17:22:44 -0700103 }
104
Ian Rogers0399dde2012-06-06 17:09:28 -0700105 uint32_t GetDexPC() const {
106 return dex_pc_;
107 }
108
109 void SetDexPC(uint32_t dex_pc) {
110 dex_pc_ = dex_pc;
111 }
112
Ian Rogers0399dde2012-06-06 17:09:28 -0700113 ShadowFrame* GetLink() const {
114 return link_;
115 }
116
117 void SetLink(ShadowFrame* frame) {
118 DCHECK_NE(this, frame);
119 link_ = frame;
120 }
121
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700122 int32_t GetVReg(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800123 DCHECK_LT(i, NumberOfVRegs());
124 const uint32_t* vreg = &vregs_[i];
125 return *reinterpret_cast<const int32_t*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700126 }
127
128 float GetVRegFloat(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800129 DCHECK_LT(i, NumberOfVRegs());
130 // NOTE: Strict-aliasing?
131 const uint32_t* vreg = &vregs_[i];
132 return *reinterpret_cast<const float*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700133 }
134
135 int64_t GetVRegLong(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200136 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800137 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700138 // Alignment attribute required for GCC 4.8
139 typedef const int64_t unaligned_int64 __attribute__ ((aligned (4)));
140 return *reinterpret_cast<unaligned_int64*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700141 }
142
143 double GetVRegDouble(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200144 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800145 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700146 // Alignment attribute required for GCC 4.8
147 typedef const double unaligned_double __attribute__ ((aligned (4)));
148 return *reinterpret_cast<unaligned_double*>(vreg);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800149 }
150
Mathieu Chartier4e305412014-02-19 10:54:44 -0800151 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800152 mirror::Object* GetVRegReference(size_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800153 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800154 mirror::Object* ref;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800155 if (HasReferenceArray()) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800156 ref = References()[i].AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800157 } else {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800158 const uint32_t* vreg_ptr = &vregs_[i];
Mathieu Chartier4e305412014-02-19 10:54:44 -0800159 ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800160 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800161 if (kUseReadBarrier) {
162 ReadBarrier::AssertToSpaceInvariant(ref);
163 }
Mathieu Chartier4e305412014-02-19 10:54:44 -0800164 if (kVerifyFlags & kVerifyReads) {
165 VerifyObject(ref);
166 }
167 return ref;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700168 }
169
Jeff Hao16743632013-05-08 10:59:04 -0700170 // Get view of vregs as range of consecutive arguments starting at i.
171 uint32_t* GetVRegArgs(size_t i) {
172 return &vregs_[i];
173 }
174
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700175 void SetVReg(size_t i, int32_t val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800176 DCHECK_LT(i, NumberOfVRegs());
177 uint32_t* vreg = &vregs_[i];
178 *reinterpret_cast<int32_t*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700179 // This is needed for moving collectors since these can update the vreg references if they
180 // happen to agree with references in the reference array.
181 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800182 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700183 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700184 }
185
186 void SetVRegFloat(size_t i, float val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800187 DCHECK_LT(i, NumberOfVRegs());
188 uint32_t* vreg = &vregs_[i];
189 *reinterpret_cast<float*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700190 // This is needed for moving collectors since these can update the vreg references if they
191 // happen to agree with references in the reference array.
192 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800193 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700194 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700195 }
196
197 void SetVRegLong(size_t i, int64_t val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200198 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800199 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700200 // Alignment attribute required for GCC 4.8
201 typedef int64_t unaligned_int64 __attribute__ ((aligned (4)));
202 *reinterpret_cast<unaligned_int64*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700203 // This is needed for moving collectors since these can update the vreg references if they
204 // happen to agree with references in the reference array.
205 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800206 References()[i].Clear();
207 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700208 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700209 }
210
211 void SetVRegDouble(size_t i, double val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200212 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800213 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700214 // Alignment attribute required for GCC 4.8
215 typedef double unaligned_double __attribute__ ((aligned (4)));
216 *reinterpret_cast<unaligned_double*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700217 // This is needed for moving collectors since these can update the vreg references if they
218 // happen to agree with references in the reference array.
219 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800220 References()[i].Clear();
221 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700222 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700223 }
224
Mathieu Chartier4e305412014-02-19 10:54:44 -0800225 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800226 void SetVRegReference(size_t i, mirror::Object* val) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800227 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800228 if (kVerifyFlags & kVerifyWrites) {
229 VerifyObject(val);
230 }
Hiroshi Yamauchi2cd334a2015-01-09 14:03:35 -0800231 if (kUseReadBarrier) {
232 ReadBarrier::AssertToSpaceInvariant(val);
233 }
TDYa127ce4cc0d2012-11-18 16:59:53 -0800234 uint32_t* vreg = &vregs_[i];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800235 reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800236 if (HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800237 References()[i].Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800238 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700239 }
240
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700241 ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800242 DCHECK(method_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700243 return method_;
Elliott Hughes68e76522011-10-05 13:22:16 -0700244 }
245
Ian Rogers62d6c772013-02-27 08:32:07 -0800246 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
247
Jeff Haoe701f482013-05-24 11:50:49 -0700248 mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
249
Ian Rogersef7d42f2014-01-06 12:55:46 -0800250 bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800251 if (HasReferenceArray()) {
252 return ((&References()[0] <= shadow_frame_entry_obj) &&
253 (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1])));
254 } else {
255 uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj);
256 return ((&vregs_[0] <= shadow_frame_entry) &&
257 (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1])));
Ian Rogers0399dde2012-06-06 17:09:28 -0700258 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700259 }
260
Ian Rogers0399dde2012-06-06 17:09:28 -0700261 static size_t LinkOffset() {
262 return OFFSETOF_MEMBER(ShadowFrame, link_);
263 }
264
Ian Rogers0399dde2012-06-06 17:09:28 -0700265 static size_t MethodOffset() {
266 return OFFSETOF_MEMBER(ShadowFrame, method_);
267 }
268
Ian Rogers0399dde2012-06-06 17:09:28 -0700269 static size_t DexPCOffset() {
270 return OFFSETOF_MEMBER(ShadowFrame, dex_pc_);
271 }
272
Ian Rogers5438ad82012-10-15 17:22:44 -0700273 static size_t NumberOfVRegsOffset() {
274 return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_);
275 }
276
TDYa127ce4cc0d2012-11-18 16:59:53 -0800277 static size_t VRegsOffset() {
278 return OFFSETOF_MEMBER(ShadowFrame, vregs_);
Ian Rogers5438ad82012-10-15 17:22:44 -0700279 }
280
Elliott Hughes68e76522011-10-05 13:22:16 -0700281 private:
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700282 ShadowFrame(uint32_t num_vregs, ShadowFrame* link, ArtMethod* method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800283 uint32_t dex_pc, bool has_reference_array)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800284 : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) {
285 if (has_reference_array) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800286 memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(StackReference<mirror::Object>)));
Mathieu Chartier67022432012-11-29 18:04:50 -0800287 } else {
Jeff Haoe701f482013-05-24 11:50:49 -0700288 memset(vregs_, 0, num_vregs * sizeof(uint32_t));
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700289 }
290 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700291
Ian Rogersef7d42f2014-01-06 12:55:46 -0800292 const StackReference<mirror::Object>* References() const {
Mathieu Chartier67022432012-11-29 18:04:50 -0800293 DCHECK(HasReferenceArray());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800294 const uint32_t* vreg_end = &vregs_[NumberOfVRegs()];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800295 return reinterpret_cast<const StackReference<mirror::Object>*>(vreg_end);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800296 }
297
Ian Rogersef7d42f2014-01-06 12:55:46 -0800298 StackReference<mirror::Object>* References() {
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700299 return const_cast<StackReference<mirror::Object>*>(
300 const_cast<const ShadowFrame*>(this)->References());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800301 }
302
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700303 const uint32_t number_of_vregs_;
Mathieu Chartier2cebb242015-04-21 16:50:40 -0700304 // Link to previous shadow frame or null.
Ian Rogers0399dde2012-06-06 17:09:28 -0700305 ShadowFrame* link_;
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700306 ArtMethod* method_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700307 uint32_t dex_pc_;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800308 uint32_t vregs_[0];
Elliott Hughes68e76522011-10-05 13:22:16 -0700309
Ian Rogers0399dde2012-06-06 17:09:28 -0700310 DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame);
Elliott Hughes68e76522011-10-05 13:22:16 -0700311};
312
Mathieu Chartiere34fa1d2015-01-14 14:55:47 -0800313class JavaFrameRootInfo : public RootInfo {
314 public:
315 JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg)
316 : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) {
317 }
318 virtual void Describe(std::ostream& os) const OVERRIDE
319 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
320
321 private:
322 const StackVisitor* const stack_visitor_;
323 const size_t vreg_;
324};
325
Ian Rogers0399dde2012-06-06 17:09:28 -0700326// The managed stack is used to record fragments of managed code stacks. Managed code stacks
327// may either be shadow frames or lists of frames using fixed frame sizes. Transition records are
328// necessary for transitions between code using different frame layouts and transitions into native
329// code.
Ian Rogersdf1ce912012-11-27 17:07:11 -0800330class PACKED(4) ManagedStack {
Ian Rogers0399dde2012-06-06 17:09:28 -0700331 public:
Ian Rogersca190662012-06-26 15:45:57 -0700332 ManagedStack()
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700333 : top_quick_frame_(nullptr), link_(nullptr), top_shadow_frame_(nullptr) {}
Ian Rogers81d425b2012-09-27 16:03:43 -0700334
335 void PushManagedStackFragment(ManagedStack* fragment) {
336 // Copy this top fragment into given fragment.
337 memcpy(fragment, this, sizeof(ManagedStack));
338 // Clear this fragment, which has become the top.
339 memset(this, 0, sizeof(ManagedStack));
340 // Link our top fragment onto the given fragment.
341 link_ = fragment;
342 }
343
344 void PopManagedStackFragment(const ManagedStack& fragment) {
345 DCHECK(&fragment == link_);
346 // Copy this given fragment back to the top.
347 memcpy(this, &fragment, sizeof(ManagedStack));
348 }
Ian Rogers0399dde2012-06-06 17:09:28 -0700349
350 ManagedStack* GetLink() const {
351 return link_;
352 }
353
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700354 ArtMethod** GetTopQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700355 return top_quick_frame_;
356 }
357
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700358 void SetTopQuickFrame(ArtMethod** top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700359 DCHECK(top_shadow_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700360 top_quick_frame_ = top;
361 }
362
Ian Rogers0399dde2012-06-06 17:09:28 -0700363 static size_t TopQuickFrameOffset() {
364 return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_);
365 }
366
Ian Rogers0399dde2012-06-06 17:09:28 -0700367 ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700368 DCHECK(top_quick_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700369 ShadowFrame* old_frame = top_shadow_frame_;
370 top_shadow_frame_ = new_top_frame;
371 new_top_frame->SetLink(old_frame);
372 return old_frame;
373 }
374
375 ShadowFrame* PopShadowFrame() {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700376 DCHECK(top_quick_frame_ == nullptr);
377 CHECK(top_shadow_frame_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700378 ShadowFrame* frame = top_shadow_frame_;
379 top_shadow_frame_ = frame->GetLink();
380 return frame;
381 }
382
383 ShadowFrame* GetTopShadowFrame() const {
384 return top_shadow_frame_;
385 }
386
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800387 void SetTopShadowFrame(ShadowFrame* top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700388 DCHECK(top_quick_frame_ == nullptr);
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800389 top_shadow_frame_ = top;
390 }
391
Ian Rogers0399dde2012-06-06 17:09:28 -0700392 static size_t TopShadowFrameOffset() {
393 return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_);
394 }
395
Ian Rogersef7d42f2014-01-06 12:55:46 -0800396 size_t NumJniShadowFrameReferences() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700397
Ian Rogersef7d42f2014-01-06 12:55:46 -0800398 bool ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700399
400 private:
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700401 ArtMethod** top_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700402 ManagedStack* link_;
403 ShadowFrame* top_shadow_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700404};
405
406class StackVisitor {
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100407 public:
408 // This enum defines a flag to control whether inlined frames are included
409 // when walking the stack.
410 enum class StackWalkKind {
411 kIncludeInlinedFrames,
412 kSkipInlinedFrames,
413 };
414
Ian Rogers0399dde2012-06-06 17:09:28 -0700415 protected:
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100416 StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind)
417 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700418
419 public:
420 virtual ~StackVisitor() {}
421
422 // Return 'true' if we should continue to visit more frames, 'false' to stop.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700423 virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
Ian Rogers0399dde2012-06-06 17:09:28 -0700424
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700425 void WalkStack(bool include_transitions = false)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700426 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700427
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700428 ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800429 if (cur_shadow_frame_ != nullptr) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700430 return cur_shadow_frame_->GetMethod();
Ian Rogersef7d42f2014-01-06 12:55:46 -0800431 } else if (cur_quick_frame_ != nullptr) {
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700432 return *cur_quick_frame_;
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700433 } else {
434 return nullptr;
435 }
436 }
437
Ian Rogers0399dde2012-06-06 17:09:28 -0700438 bool IsShadowFrame() const {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800439 return cur_shadow_frame_ != nullptr;
Ian Rogers0399dde2012-06-06 17:09:28 -0700440 }
441
Dave Allisonb373e092014-02-20 16:06:36 -0800442 uint32_t GetDexPc(bool abort_on_failure = true) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0c7abda2012-09-19 13:33:42 -0700443
Ian Rogers62d6c772013-02-27 08:32:07 -0800444 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
445
Ian Rogers0c7abda2012-09-19 13:33:42 -0700446 size_t GetNativePcOffset() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
447
Ian Rogersef7d42f2014-01-06 12:55:46 -0800448 uintptr_t* CalleeSaveAddress(int num, size_t frame_size) const
449 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700450 // Callee saves are held at the top of the frame
Ian Rogersef7d42f2014-01-06 12:55:46 -0800451 DCHECK(GetMethod() != nullptr);
Ian Rogers13735952014-10-08 12:43:28 -0700452 uint8_t* save_addr =
453 reinterpret_cast<uint8_t*>(cur_quick_frame_) + frame_size - ((num + 1) * sizeof(void*));
Andreas Gampebf6b92a2014-03-05 16:11:04 -0800454#if defined(__i386__) || defined(__x86_64__)
Ian Rogers13735952014-10-08 12:43:28 -0700455 save_addr -= sizeof(void*); // account for return address
Ian Rogers0399dde2012-06-06 17:09:28 -0700456#endif
Mathieu Chartier67022432012-11-29 18:04:50 -0800457 return reinterpret_cast<uintptr_t*>(save_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700458 }
459
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700460 // Returns the height of the stack in the managed stack frames, including transitions.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700461 size_t GetFrameHeight() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800462 return GetNumFrames() - cur_depth_ - 1;
Ian Rogers0399dde2012-06-06 17:09:28 -0700463 }
464
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700465 // Returns a frame ID for JDWP use, starting from 1.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700466 size_t GetFrameId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700467 return GetFrameHeight() + 1;
468 }
469
Ian Rogersb726dcb2012-09-05 08:57:23 -0700470 size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700471 if (num_frames_ == 0) {
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100472 num_frames_ = ComputeNumFrames(thread_, walk_kind_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700473 }
474 return num_frames_;
475 }
476
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700477 size_t GetFrameDepth() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
478 return cur_depth_;
479 }
480
Ian Rogers5cf98192014-05-29 21:31:50 -0700481 // Get the method and dex pc immediately after the one that's currently being visited.
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700482 bool GetNextMethodAndDexPc(ArtMethod** next_method, uint32_t* next_dex_pc)
Ian Rogers5cf98192014-05-29 21:31:50 -0700483 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
484
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700485 bool IsReferenceVReg(ArtMethod* m, uint16_t vreg)
Mathieu Chartier50030ef2015-05-08 14:19:26 -0700486 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
487
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700488 bool GetVReg(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
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700491 bool GetVRegPair(ArtMethod* m, uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi,
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200492 uint64_t* val) const
493 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
494
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700495 bool SetVReg(ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700496 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700497
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700498 bool SetVRegPair(ArtMethod* m, uint16_t vreg, uint64_t new_value,
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200499 VRegKind kind_lo, VRegKind kind_hi)
500 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
501
Mathieu Chartier815873e2014-02-13 18:02:13 -0800502 uintptr_t* GetGPRAddress(uint32_t reg) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700503
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700504 // This is a fast-path for getting/setting values in a quick frame.
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700505 uint32_t* GetVRegAddrFromQuickCode(ArtMethod** cur_quick_frame,
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000506 const DexFile::CodeItem* code_item,
507 uint32_t core_spills, uint32_t fp_spills, size_t frame_size,
508 uint16_t vreg) const {
509 int offset = GetVRegOffsetFromQuickCode(
510 code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA);
Ian Rogers0ec569a2012-07-01 16:43:46 -0700511 DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame());
Ian Rogers13735952014-10-08 12:43:28 -0700512 uint8_t* vreg_addr = reinterpret_cast<uint8_t*>(cur_quick_frame) + offset;
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700513 return reinterpret_cast<uint32_t*>(vreg_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700514 }
515
Ian Rogersef7d42f2014-01-06 12:55:46 -0800516 uintptr_t GetReturnPc() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700517
Ian Rogersef7d42f2014-01-06 12:55:46 -0800518 void SetReturnPc(uintptr_t new_ret_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700519
520 /*
521 * Return sp-relative offset for a Dalvik virtual register, compiler
522 * spill or Method* in bytes using Method*.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700523 * Note that (reg == -1) denotes an invalid Dalvik register. For the
524 * positive values, the Dalvik registers come first, followed by the
525 * Method*, followed by other special temporaries if any, followed by
526 * regular compiler temporary. As of now we only have the Method* as
527 * as a special compiler temporary.
528 * A compiler temporary can be thought of as a virtual register that
529 * does not exist in the dex but holds intermediate values to help
530 * optimizations and code generation. A special compiler temporary is
531 * one whose location in frame is well known while non-special ones
532 * do not have a requirement on location in frame as long as code
533 * generator itself knows how to access them.
Ian Rogers0399dde2012-06-06 17:09:28 -0700534 *
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700535 * +-------------------------------+
536 * | IN[ins-1] | {Note: resides in caller's frame}
537 * | . |
538 * | IN[0] |
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700539 * | caller's ArtMethod | ... ArtMethod*
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700540 * +===============================+ {Note: start of callee's frame}
541 * | core callee-save spill | {variable sized}
542 * +-------------------------------+
543 * | fp callee-save spill |
544 * +-------------------------------+
545 * | filler word | {For compatibility, if V[locals-1] used as wide
546 * +-------------------------------+
547 * | V[locals-1] |
548 * | V[locals-2] |
549 * | . |
550 * | . | ... (reg == 2)
551 * | V[1] | ... (reg == 1)
552 * | V[0] | ... (reg == 0) <---- "locals_start"
553 * +-------------------------------+
554 * | stack alignment padding | {0 to (kStackAlignWords-1) of padding}
555 * +-------------------------------+
556 * | Compiler temp region | ... (reg >= max_num_special_temps)
557 * | . |
558 * | . |
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700559 * | V[max_num_special_temps + 1] |
560 * | V[max_num_special_temps + 0] |
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700561 * +-------------------------------+
562 * | OUT[outs-1] |
563 * | OUT[outs-2] |
564 * | . |
565 * | OUT[0] |
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700566 * | ArtMethod* | ... (reg == num_total_code_regs == special_temp_value) <<== sp, 16-byte aligned
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700567 * +===============================+
Ian Rogers0399dde2012-06-06 17:09:28 -0700568 */
Nicolas Geoffray15b9d522015-03-12 15:05:13 +0000569 static int GetVRegOffsetFromQuickCode(const DexFile::CodeItem* code_item,
570 uint32_t core_spills, uint32_t fp_spills,
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700571 size_t frame_size, int reg, InstructionSet isa);
Ian Rogers0399dde2012-06-06 17:09:28 -0700572
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000573 static int GetOutVROffset(uint16_t out_num, InstructionSet isa) {
buzbee82818642014-06-04 15:35:41 -0700574 // According to stack model, the first out is above the Method referernce.
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700575 return InstructionSetPointerSize(isa) + out_num * sizeof(uint32_t);
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800576 }
577
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100578 bool IsInInlinedFrame() const {
579 return false;
580 }
581
Ian Rogers0399dde2012-06-06 17:09:28 -0700582 uintptr_t GetCurrentQuickFramePc() const {
583 return cur_quick_frame_pc_;
584 }
585
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700586 ArtMethod** GetCurrentQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700587 return cur_quick_frame_;
588 }
589
590 ShadowFrame* GetCurrentShadowFrame() const {
591 return cur_shadow_frame_;
592 }
593
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700594 HandleScope* GetCurrentHandleScope(size_t pointer_size) const {
595 ArtMethod** sp = GetCurrentQuickFrame();
596 // Skip ArtMethod*; handle scope comes next;
597 return reinterpret_cast<HandleScope*>(reinterpret_cast<uintptr_t>(sp) + pointer_size);
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700598 }
599
Ian Rogers40e3bac2012-11-20 00:09:14 -0800600 std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
601
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100602 static size_t ComputeNumFrames(Thread* thread, StackWalkKind walk_kind)
603 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800604
Ian Rogers7a22fa62013-01-23 12:16:16 -0800605 static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800606
Ian Rogers0399dde2012-06-06 17:09:28 -0700607 private:
Ian Rogers5cf98192014-05-29 21:31:50 -0700608 // Private constructor known in the case that num_frames_ has already been computed.
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100609 StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind, size_t num_frames)
Ian Rogers5cf98192014-05-29 21:31:50 -0700610 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
611
Sebastien Hertz96ba8dc2015-01-22 18:57:14 +0100612 bool IsAccessibleRegister(uint32_t reg, bool is_float) const {
613 return is_float ? IsAccessibleFPR(reg) : IsAccessibleGPR(reg);
614 }
615 uintptr_t GetRegister(uint32_t reg, bool is_float) const {
616 DCHECK(IsAccessibleRegister(reg, is_float));
617 return is_float ? GetFPR(reg) : GetGPR(reg);
618 }
619 void SetRegister(uint32_t reg, uintptr_t value, bool is_float) {
620 DCHECK(IsAccessibleRegister(reg, is_float));
621 if (is_float) {
622 SetFPR(reg, value);
623 } else {
624 SetGPR(reg, value);
625 }
626 }
627
628 bool IsAccessibleGPR(uint32_t reg) const;
629 uintptr_t GetGPR(uint32_t reg) const;
630 void SetGPR(uint32_t reg, uintptr_t value);
631
632 bool IsAccessibleFPR(uint32_t reg) const;
633 uintptr_t GetFPR(uint32_t reg) const;
634 void SetFPR(uint32_t reg, uintptr_t value);
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200635
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700636 bool GetVRegFromQuickCode(ArtMethod* m, uint16_t vreg, VRegKind kind,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100637 uint32_t* val) const
638 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700639 bool GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKind kind,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100640 uint32_t* val) const
641 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
642 bool GetRegisterIfAccessible(uint32_t reg, VRegKind kind, uint32_t* val) const
643 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
644
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700645 bool GetVRegPairFromQuickCode(ArtMethod* m, uint16_t vreg, VRegKind kind_lo,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100646 VRegKind kind_hi, uint64_t* val) const
647 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700648 bool GetVRegPairFromOptimizedCode(ArtMethod* m, uint16_t vreg,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100649 VRegKind kind_lo, VRegKind kind_hi,
650 uint64_t* val) const
651 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
652 bool GetRegisterPairIfAccessible(uint32_t reg_lo, uint32_t reg_hi, VRegKind kind_lo,
653 uint64_t* val) const
654 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
655
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700656 bool SetVRegFromQuickCode(ArtMethod* m, uint16_t vreg, uint32_t new_value,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100657 VRegKind kind)
658 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100659 bool SetRegisterIfAccessible(uint32_t reg, uint32_t new_value, VRegKind kind)
660 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
661
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700662 bool SetVRegPairFromQuickCode(ArtMethod* m, uint16_t vreg, uint64_t new_value,
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100663 VRegKind kind_lo, VRegKind kind_hi)
664 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Sebastien Hertz7cde48c2015-01-20 16:06:43 +0100665 bool SetRegisterPairIfAccessible(uint32_t reg_lo, uint32_t reg_hi, uint64_t new_value,
666 bool is_float)
667 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
668
Ian Rogersb726dcb2012-09-05 08:57:23 -0700669 void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700670
Ian Rogers7a22fa62013-01-23 12:16:16 -0800671 Thread* const thread_;
Nicolas Geoffray8e5bd182015-05-06 11:34:34 +0100672 const StackWalkKind walk_kind_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700673 ShadowFrame* cur_shadow_frame_;
Mathieu Chartier3d21bdf2015-04-22 13:56:20 -0700674 ArtMethod** cur_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700675 uintptr_t cur_quick_frame_pc_;
676 // Lazily computed, number of frames in the stack.
677 size_t num_frames_;
678 // Depth of the frame we're currently at.
679 size_t cur_depth_;
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700680
Ian Rogers0399dde2012-06-06 17:09:28 -0700681 protected:
682 Context* const context_;
683};
684
Elliott Hughes68e76522011-10-05 13:22:16 -0700685} // namespace art
686
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700687#endif // ART_RUNTIME_STACK_H_