blob: 66c840d7c3915770ef526fdcd7fa489384386dc9 [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 Rogerse63db272014-07-15 15:36:11 -070023#include "dex_file.h"
24#include "instruction_set.h"
25#include "mirror/object_reference.h"
26#include "throw_location.h"
27#include "utils.h"
28#include "verify_object.h"
29
Elliott Hughes68e76522011-10-05 13:22:16 -070030namespace art {
31
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080032namespace mirror {
Brian Carlstromea46f952013-07-30 01:26:50 -070033 class ArtMethod;
34 class Object;
Ian Rogers2dd0e2c2013-01-24 12:42:14 -080035} // namespace mirror
36
37class Context;
Ian Rogers0399dde2012-06-06 17:09:28 -070038class ShadowFrame;
Mathieu Chartiereb8167a2014-05-07 15:43:14 -070039class HandleScope;
Ian Rogers00f7d0e2012-07-19 15:28:27 -070040class ScopedObjectAccess;
Elliott Hughes68e76522011-10-05 13:22:16 -070041class Thread;
42
Ian Rogers2bcb4a42012-11-08 10:39:18 -080043// The kind of vreg being accessed in calls to Set/GetVReg.
44enum VRegKind {
45 kReferenceVReg,
46 kIntVReg,
47 kFloatVReg,
48 kLongLoVReg,
49 kLongHiVReg,
50 kDoubleLoVReg,
51 kDoubleHiVReg,
52 kConstant,
53 kImpreciseConstant,
54 kUndefined,
55};
Ian Rogers6a3c1fc2014-10-31 00:33:20 -070056std::ostream& operator<<(std::ostream& os, const VRegKind& rhs);
Ian Rogers2bcb4a42012-11-08 10:39:18 -080057
Ian Rogersef7d42f2014-01-06 12:55:46 -080058// A reference from the shadow stack to a MirrorType object within the Java heap.
59template<class MirrorType>
60class MANAGED StackReference : public mirror::ObjectReference<false, MirrorType> {
61 public:
62 StackReference<MirrorType>() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
63 : mirror::ObjectReference<false, MirrorType>(nullptr) {}
64
65 static StackReference<MirrorType> FromMirrorPtr(MirrorType* p)
66 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
67 return StackReference<MirrorType>(p);
68 }
69
70 private:
71 StackReference<MirrorType>(MirrorType* p) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
72 : mirror::ObjectReference<false, MirrorType>(p) {}
73};
74
Mathieu Chartier67022432012-11-29 18:04:50 -080075// ShadowFrame has 3 possible layouts:
76// - portable - a unified array of VRegs and references. Precise references need GC maps.
77// - interpreter - separate VRegs and reference arrays. References are in the reference array.
78// - JNI - just VRegs, but where every VReg holds a reference.
Ian Rogers0399dde2012-06-06 17:09:28 -070079class ShadowFrame {
Elliott Hughes68e76522011-10-05 13:22:16 -070080 public:
Ian Rogersef7d42f2014-01-06 12:55:46 -080081 // Compute size of ShadowFrame in bytes assuming it has a reference array.
Jeff Hao66135192013-05-14 11:02:41 -070082 static size_t ComputeSize(uint32_t num_vregs) {
83 return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) +
Ian Rogersef7d42f2014-01-06 12:55:46 -080084 (sizeof(StackReference<mirror::Object>) * num_vregs);
Jeff Hao66135192013-05-14 11:02:41 -070085 }
86
87 // Create ShadowFrame in heap for deoptimization.
TDYa127ce4cc0d2012-11-18 16:59:53 -080088 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Brian Carlstromea46f952013-07-30 01:26:50 -070089 mirror::ArtMethod* method, uint32_t dex_pc) {
Jeff Hao66135192013-05-14 11:02:41 -070090 uint8_t* memory = new uint8_t[ComputeSize(num_vregs)];
Sebastien Hertzc61124b2013-09-10 11:44:19 +020091 return Create(num_vregs, link, method, dex_pc, memory);
Jeff Hao66135192013-05-14 11:02:41 -070092 }
93
94 // Create ShadowFrame for interpreter using provided memory.
95 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Brian Carlstromea46f952013-07-30 01:26:50 -070096 mirror::ArtMethod* method, uint32_t dex_pc, void* memory) {
TDYa127ce4cc0d2012-11-18 16:59:53 -080097 ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
98 return sf;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -070099 }
100 ~ShadowFrame() {}
101
TDYa127ce4cc0d2012-11-18 16:59:53 -0800102 bool HasReferenceArray() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700103#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800104 return (number_of_vregs_ & kHasReferenceArray) != 0;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700105#else
106 return true;
107#endif
Ian Rogers0399dde2012-06-06 17:09:28 -0700108 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700109
TDYa127ce4cc0d2012-11-18 16:59:53 -0800110 uint32_t NumberOfVRegs() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700111#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800112 return number_of_vregs_ & ~kHasReferenceArray;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700113#else
114 return number_of_vregs_;
115#endif
Ian Rogers0399dde2012-06-06 17:09:28 -0700116 }
117
TDYa127ce4cc0d2012-11-18 16:59:53 -0800118 void SetNumberOfVRegs(uint32_t number_of_vregs) {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700119#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800120 number_of_vregs_ = number_of_vregs | (number_of_vregs_ & kHasReferenceArray);
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700121#else
122 UNUSED(number_of_vregs);
123 UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled";
124#endif
Ian Rogers5438ad82012-10-15 17:22:44 -0700125 }
126
Ian Rogers0399dde2012-06-06 17:09:28 -0700127 uint32_t GetDexPC() const {
128 return dex_pc_;
129 }
130
131 void SetDexPC(uint32_t dex_pc) {
132 dex_pc_ = dex_pc;
133 }
134
Ian Rogers0399dde2012-06-06 17:09:28 -0700135 ShadowFrame* GetLink() const {
136 return link_;
137 }
138
139 void SetLink(ShadowFrame* frame) {
140 DCHECK_NE(this, frame);
141 link_ = frame;
142 }
143
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700144 int32_t GetVReg(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800145 DCHECK_LT(i, NumberOfVRegs());
146 const uint32_t* vreg = &vregs_[i];
147 return *reinterpret_cast<const int32_t*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700148 }
149
150 float GetVRegFloat(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800151 DCHECK_LT(i, NumberOfVRegs());
152 // NOTE: Strict-aliasing?
153 const uint32_t* vreg = &vregs_[i];
154 return *reinterpret_cast<const float*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700155 }
156
157 int64_t GetVRegLong(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200158 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800159 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700160 // Alignment attribute required for GCC 4.8
161 typedef const int64_t unaligned_int64 __attribute__ ((aligned (4)));
162 return *reinterpret_cast<unaligned_int64*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700163 }
164
165 double GetVRegDouble(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200166 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800167 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700168 // Alignment attribute required for GCC 4.8
169 typedef const double unaligned_double __attribute__ ((aligned (4)));
170 return *reinterpret_cast<unaligned_double*>(vreg);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800171 }
172
Mathieu Chartier4e305412014-02-19 10:54:44 -0800173 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800174 mirror::Object* GetVRegReference(size_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800175 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800176 mirror::Object* ref;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800177 if (HasReferenceArray()) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800178 ref = References()[i].AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800179 } else {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800180 const uint32_t* vreg_ptr = &vregs_[i];
Mathieu Chartier4e305412014-02-19 10:54:44 -0800181 ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800182 }
Mathieu Chartier4e305412014-02-19 10:54:44 -0800183 if (kVerifyFlags & kVerifyReads) {
184 VerifyObject(ref);
185 }
186 return ref;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700187 }
188
Jeff Hao16743632013-05-08 10:59:04 -0700189 // Get view of vregs as range of consecutive arguments starting at i.
190 uint32_t* GetVRegArgs(size_t i) {
191 return &vregs_[i];
192 }
193
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700194 void SetVReg(size_t i, int32_t val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800195 DCHECK_LT(i, NumberOfVRegs());
196 uint32_t* vreg = &vregs_[i];
197 *reinterpret_cast<int32_t*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700198 // This is needed for moving collectors since these can update the vreg references if they
199 // happen to agree with references in the reference array.
200 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800201 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700202 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700203 }
204
205 void SetVRegFloat(size_t i, float val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800206 DCHECK_LT(i, NumberOfVRegs());
207 uint32_t* vreg = &vregs_[i];
208 *reinterpret_cast<float*>(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();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700213 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700214 }
215
216 void SetVRegLong(size_t i, int64_t val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200217 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800218 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700219 // Alignment attribute required for GCC 4.8
220 typedef int64_t unaligned_int64 __attribute__ ((aligned (4)));
221 *reinterpret_cast<unaligned_int64*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700222 // This is needed for moving collectors since these can update the vreg references if they
223 // happen to agree with references in the reference array.
224 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800225 References()[i].Clear();
226 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700227 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700228 }
229
230 void SetVRegDouble(size_t i, double val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200231 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800232 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700233 // Alignment attribute required for GCC 4.8
234 typedef double unaligned_double __attribute__ ((aligned (4)));
235 *reinterpret_cast<unaligned_double*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700236 // This is needed for moving collectors since these can update the vreg references if they
237 // happen to agree with references in the reference array.
238 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800239 References()[i].Clear();
240 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700241 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700242 }
243
Mathieu Chartier4e305412014-02-19 10:54:44 -0800244 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800245 void SetVRegReference(size_t i, mirror::Object* val) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800246 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800247 if (kVerifyFlags & kVerifyWrites) {
248 VerifyObject(val);
249 }
TDYa127ce4cc0d2012-11-18 16:59:53 -0800250 uint32_t* vreg = &vregs_[i];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800251 reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800252 if (HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800253 References()[i].Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800254 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700255 }
256
Ian Rogersef7d42f2014-01-06 12:55:46 -0800257 mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
258 DCHECK(method_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700259 return method_;
Elliott Hughes68e76522011-10-05 13:22:16 -0700260 }
261
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700262 mirror::ArtMethod** GetMethodAddress() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
263 DCHECK(method_ != nullptr);
264 return &method_;
265 }
266
Ian Rogers62d6c772013-02-27 08:32:07 -0800267 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
268
Jeff Haoe701f482013-05-24 11:50:49 -0700269 mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
270
Ian Rogers62d6c772013-02-27 08:32:07 -0800271 ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
272
Brian Carlstromea46f952013-07-30 01:26:50 -0700273 void SetMethod(mirror::ArtMethod* method) {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700274#if defined(ART_USE_PORTABLE_COMPILER)
Ian Rogersef7d42f2014-01-06 12:55:46 -0800275 DCHECK(method != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700276 method_ = method;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700277#else
278 UNUSED(method);
279 UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled";
280#endif
Elliott Hughes68e76522011-10-05 13:22:16 -0700281 }
282
Ian Rogersef7d42f2014-01-06 12:55:46 -0800283 bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800284 if (HasReferenceArray()) {
285 return ((&References()[0] <= shadow_frame_entry_obj) &&
286 (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1])));
287 } else {
288 uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj);
289 return ((&vregs_[0] <= shadow_frame_entry) &&
290 (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1])));
Ian Rogers0399dde2012-06-06 17:09:28 -0700291 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700292 }
293
Ian Rogers0399dde2012-06-06 17:09:28 -0700294 static size_t LinkOffset() {
295 return OFFSETOF_MEMBER(ShadowFrame, link_);
296 }
297
Ian Rogers0399dde2012-06-06 17:09:28 -0700298 static size_t MethodOffset() {
299 return OFFSETOF_MEMBER(ShadowFrame, method_);
300 }
301
Ian Rogers0399dde2012-06-06 17:09:28 -0700302 static size_t DexPCOffset() {
303 return OFFSETOF_MEMBER(ShadowFrame, dex_pc_);
304 }
305
Ian Rogers5438ad82012-10-15 17:22:44 -0700306 static size_t NumberOfVRegsOffset() {
307 return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_);
308 }
309
TDYa127ce4cc0d2012-11-18 16:59:53 -0800310 static size_t VRegsOffset() {
311 return OFFSETOF_MEMBER(ShadowFrame, vregs_);
Ian Rogers5438ad82012-10-15 17:22:44 -0700312 }
313
Elliott Hughes68e76522011-10-05 13:22:16 -0700314 private:
Brian Carlstromea46f952013-07-30 01:26:50 -0700315 ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800316 uint32_t dex_pc, bool has_reference_array)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800317 : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) {
318 if (has_reference_array) {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700319#if defined(ART_USE_PORTABLE_COMPILER)
320 CHECK_LT(num_vregs, static_cast<uint32_t>(kHasReferenceArray));
TDYa127ce4cc0d2012-11-18 16:59:53 -0800321 number_of_vregs_ |= kHasReferenceArray;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700322#endif
Ian Rogersef7d42f2014-01-06 12:55:46 -0800323 memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(StackReference<mirror::Object>)));
Mathieu Chartier67022432012-11-29 18:04:50 -0800324 } else {
Jeff Haoe701f482013-05-24 11:50:49 -0700325 memset(vregs_, 0, num_vregs * sizeof(uint32_t));
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700326 }
327 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700328
Ian Rogersef7d42f2014-01-06 12:55:46 -0800329 const StackReference<mirror::Object>* References() const {
Mathieu Chartier67022432012-11-29 18:04:50 -0800330 DCHECK(HasReferenceArray());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800331 const uint32_t* vreg_end = &vregs_[NumberOfVRegs()];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800332 return reinterpret_cast<const StackReference<mirror::Object>*>(vreg_end);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800333 }
334
Ian Rogersef7d42f2014-01-06 12:55:46 -0800335 StackReference<mirror::Object>* References() {
336 return const_cast<StackReference<mirror::Object>*>(const_cast<const ShadowFrame*>(this)->References());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800337 }
338
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700339#if defined(ART_USE_PORTABLE_COMPILER)
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700340 constexpr uint32_t kHasReferenceArray = 1ul << 31;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700341 // TODO: make const in the portable case.
TDYa127ce4cc0d2012-11-18 16:59:53 -0800342 uint32_t number_of_vregs_;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700343#else
344 const uint32_t number_of_vregs_;
345#endif
Ian Rogers5438ad82012-10-15 17:22:44 -0700346 // Link to previous shadow frame or NULL.
Ian Rogers0399dde2012-06-06 17:09:28 -0700347 ShadowFrame* link_;
Brian Carlstromea46f952013-07-30 01:26:50 -0700348 mirror::ArtMethod* method_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700349 uint32_t dex_pc_;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800350 uint32_t vregs_[0];
Elliott Hughes68e76522011-10-05 13:22:16 -0700351
Ian Rogers0399dde2012-06-06 17:09:28 -0700352 DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame);
Elliott Hughes68e76522011-10-05 13:22:16 -0700353};
354
Ian Rogers0399dde2012-06-06 17:09:28 -0700355// The managed stack is used to record fragments of managed code stacks. Managed code stacks
356// may either be shadow frames or lists of frames using fixed frame sizes. Transition records are
357// necessary for transitions between code using different frame layouts and transitions into native
358// code.
Ian Rogersdf1ce912012-11-27 17:07:11 -0800359class PACKED(4) ManagedStack {
Ian Rogers0399dde2012-06-06 17:09:28 -0700360 public:
Ian Rogersca190662012-06-26 15:45:57 -0700361 ManagedStack()
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700362 : top_quick_frame_(nullptr), link_(nullptr), top_shadow_frame_(nullptr) {}
Ian Rogers81d425b2012-09-27 16:03:43 -0700363
364 void PushManagedStackFragment(ManagedStack* fragment) {
365 // Copy this top fragment into given fragment.
366 memcpy(fragment, this, sizeof(ManagedStack));
367 // Clear this fragment, which has become the top.
368 memset(this, 0, sizeof(ManagedStack));
369 // Link our top fragment onto the given fragment.
370 link_ = fragment;
371 }
372
373 void PopManagedStackFragment(const ManagedStack& fragment) {
374 DCHECK(&fragment == link_);
375 // Copy this given fragment back to the top.
376 memcpy(this, &fragment, sizeof(ManagedStack));
377 }
Ian Rogers0399dde2012-06-06 17:09:28 -0700378
379 ManagedStack* GetLink() const {
380 return link_;
381 }
382
Andreas Gampecf4035a2014-05-28 22:43:01 -0700383 StackReference<mirror::ArtMethod>* GetTopQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700384 return top_quick_frame_;
385 }
386
Andreas Gampecf4035a2014-05-28 22:43:01 -0700387 void SetTopQuickFrame(StackReference<mirror::ArtMethod>* top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700388 DCHECK(top_shadow_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700389 top_quick_frame_ = top;
390 }
391
Ian Rogers0399dde2012-06-06 17:09:28 -0700392 static size_t TopQuickFrameOffset() {
393 return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_);
394 }
395
Ian Rogers0399dde2012-06-06 17:09:28 -0700396 ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700397 DCHECK(top_quick_frame_ == nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700398 ShadowFrame* old_frame = top_shadow_frame_;
399 top_shadow_frame_ = new_top_frame;
400 new_top_frame->SetLink(old_frame);
401 return old_frame;
402 }
403
404 ShadowFrame* PopShadowFrame() {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700405 DCHECK(top_quick_frame_ == nullptr);
406 CHECK(top_shadow_frame_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700407 ShadowFrame* frame = top_shadow_frame_;
408 top_shadow_frame_ = frame->GetLink();
409 return frame;
410 }
411
412 ShadowFrame* GetTopShadowFrame() const {
413 return top_shadow_frame_;
414 }
415
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800416 void SetTopShadowFrame(ShadowFrame* top) {
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700417 DCHECK(top_quick_frame_ == nullptr);
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800418 top_shadow_frame_ = top;
419 }
420
Ian Rogers0399dde2012-06-06 17:09:28 -0700421 static size_t TopShadowFrameOffset() {
422 return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_);
423 }
424
Ian Rogersef7d42f2014-01-06 12:55:46 -0800425 size_t NumJniShadowFrameReferences() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700426
Ian Rogersef7d42f2014-01-06 12:55:46 -0800427 bool ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700428
429 private:
Ian Rogers1d8cdbc2014-09-22 22:51:09 -0700430 StackReference<mirror::ArtMethod>* top_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700431 ManagedStack* link_;
432 ShadowFrame* top_shadow_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700433};
434
435class StackVisitor {
436 protected:
Ian Rogers7a22fa62013-01-23 12:16:16 -0800437 StackVisitor(Thread* thread, Context* context) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700438
439 public:
440 virtual ~StackVisitor() {}
441
442 // Return 'true' if we should continue to visit more frames, 'false' to stop.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700443 virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
Ian Rogers0399dde2012-06-06 17:09:28 -0700444
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700445 void WalkStack(bool include_transitions = false)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700446 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700447
Ian Rogersef7d42f2014-01-06 12:55:46 -0800448 mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
449 if (cur_shadow_frame_ != nullptr) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700450 return cur_shadow_frame_->GetMethod();
Ian Rogersef7d42f2014-01-06 12:55:46 -0800451 } else if (cur_quick_frame_ != nullptr) {
Andreas Gampecf4035a2014-05-28 22:43:01 -0700452 return cur_quick_frame_->AsMirrorPtr();
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700453 } else {
454 return nullptr;
455 }
456 }
457
Ian Rogers0399dde2012-06-06 17:09:28 -0700458 bool IsShadowFrame() const {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800459 return cur_shadow_frame_ != nullptr;
Ian Rogers0399dde2012-06-06 17:09:28 -0700460 }
461
Dave Allisonb373e092014-02-20 16:06:36 -0800462 uint32_t GetDexPc(bool abort_on_failure = true) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0c7abda2012-09-19 13:33:42 -0700463
Ian Rogers62d6c772013-02-27 08:32:07 -0800464 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
465
Ian Rogers0c7abda2012-09-19 13:33:42 -0700466 size_t GetNativePcOffset() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
467
Ian Rogersef7d42f2014-01-06 12:55:46 -0800468 uintptr_t* CalleeSaveAddress(int num, size_t frame_size) const
469 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700470 // Callee saves are held at the top of the frame
Ian Rogersef7d42f2014-01-06 12:55:46 -0800471 DCHECK(GetMethod() != nullptr);
Ian Rogers13735952014-10-08 12:43:28 -0700472 uint8_t* save_addr =
473 reinterpret_cast<uint8_t*>(cur_quick_frame_) + frame_size - ((num + 1) * sizeof(void*));
Andreas Gampebf6b92a2014-03-05 16:11:04 -0800474#if defined(__i386__) || defined(__x86_64__)
Ian Rogers13735952014-10-08 12:43:28 -0700475 save_addr -= sizeof(void*); // account for return address
Ian Rogers0399dde2012-06-06 17:09:28 -0700476#endif
Mathieu Chartier67022432012-11-29 18:04:50 -0800477 return reinterpret_cast<uintptr_t*>(save_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700478 }
479
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700480 // Returns the height of the stack in the managed stack frames, including transitions.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700481 size_t GetFrameHeight() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800482 return GetNumFrames() - cur_depth_ - 1;
Ian Rogers0399dde2012-06-06 17:09:28 -0700483 }
484
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700485 // Returns a frame ID for JDWP use, starting from 1.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700486 size_t GetFrameId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700487 return GetFrameHeight() + 1;
488 }
489
Ian Rogersb726dcb2012-09-05 08:57:23 -0700490 size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700491 if (num_frames_ == 0) {
Ian Rogers7a22fa62013-01-23 12:16:16 -0800492 num_frames_ = ComputeNumFrames(thread_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700493 }
494 return num_frames_;
495 }
496
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700497 size_t GetFrameDepth() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
498 return cur_depth_;
499 }
500
Ian Rogers5cf98192014-05-29 21:31:50 -0700501 // Get the method and dex pc immediately after the one that's currently being visited.
502 bool GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32_t* next_dex_pc)
503 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
504
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200505 bool GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind, uint32_t* val) const
Ian Rogers2bcb4a42012-11-08 10:39:18 -0800506 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700507
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200508 uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const
509 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
510 uint32_t val;
511 bool success = GetVReg(m, vreg, kind, &val);
512 CHECK(success) << "Failed to read vreg " << vreg << " of kind " << kind;
513 return val;
514 }
515
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200516 bool GetVRegPair(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi,
517 uint64_t* val) const
518 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
519
520 uint64_t GetVRegPair(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind_lo,
521 VRegKind kind_hi) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
522 uint64_t val;
523 bool success = GetVRegPair(m, vreg, kind_lo, kind_hi, &val);
524 CHECK(success) << "Failed to read vreg pair " << vreg
525 << " of kind [" << kind_lo << "," << kind_hi << "]";
526 return val;
527 }
528
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200529 bool SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700530 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700531
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200532 bool SetVRegPair(mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value,
533 VRegKind kind_lo, VRegKind kind_hi)
534 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
535
Mathieu Chartier815873e2014-02-13 18:02:13 -0800536 uintptr_t* GetGPRAddress(uint32_t reg) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700537
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700538 // This is a fast-path for getting/setting values in a quick frame.
Andreas Gampecf4035a2014-05-28 22:43:01 -0700539 uint32_t* GetVRegAddr(StackReference<mirror::ArtMethod>* cur_quick_frame,
540 const DexFile::CodeItem* code_item,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800541 uint32_t core_spills, uint32_t fp_spills, size_t frame_size,
542 uint16_t vreg) const {
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000543 int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA);
Ian Rogers0ec569a2012-07-01 16:43:46 -0700544 DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame());
Ian Rogers13735952014-10-08 12:43:28 -0700545 uint8_t* vreg_addr = reinterpret_cast<uint8_t*>(cur_quick_frame) + offset;
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700546 return reinterpret_cast<uint32_t*>(vreg_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700547 }
548
Ian Rogersef7d42f2014-01-06 12:55:46 -0800549 uintptr_t GetReturnPc() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700550
Ian Rogersef7d42f2014-01-06 12:55:46 -0800551 void SetReturnPc(uintptr_t new_ret_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700552
553 /*
554 * Return sp-relative offset for a Dalvik virtual register, compiler
555 * spill or Method* in bytes using Method*.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700556 * Note that (reg == -1) denotes an invalid Dalvik register. For the
557 * positive values, the Dalvik registers come first, followed by the
558 * Method*, followed by other special temporaries if any, followed by
559 * regular compiler temporary. As of now we only have the Method* as
560 * as a special compiler temporary.
561 * A compiler temporary can be thought of as a virtual register that
562 * does not exist in the dex but holds intermediate values to help
563 * optimizations and code generation. A special compiler temporary is
564 * one whose location in frame is well known while non-special ones
565 * do not have a requirement on location in frame as long as code
566 * generator itself knows how to access them.
Ian Rogers0399dde2012-06-06 17:09:28 -0700567 *
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700568 * +-------------------------------+
569 * | IN[ins-1] | {Note: resides in caller's frame}
570 * | . |
571 * | IN[0] |
572 * | caller's ArtMethod | ... StackReference<ArtMethod>
573 * +===============================+ {Note: start of callee's frame}
574 * | core callee-save spill | {variable sized}
575 * +-------------------------------+
576 * | fp callee-save spill |
577 * +-------------------------------+
578 * | filler word | {For compatibility, if V[locals-1] used as wide
579 * +-------------------------------+
580 * | V[locals-1] |
581 * | V[locals-2] |
582 * | . |
583 * | . | ... (reg == 2)
584 * | V[1] | ... (reg == 1)
585 * | V[0] | ... (reg == 0) <---- "locals_start"
586 * +-------------------------------+
587 * | stack alignment padding | {0 to (kStackAlignWords-1) of padding}
588 * +-------------------------------+
589 * | Compiler temp region | ... (reg >= max_num_special_temps)
590 * | . |
591 * | . |
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700592 * | V[max_num_special_temps + 1] |
593 * | V[max_num_special_temps + 0] |
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700594 * +-------------------------------+
595 * | OUT[outs-1] |
596 * | OUT[outs-2] |
597 * | . |
598 * | OUT[0] |
599 * | StackReference<ArtMethod> | ... (reg == num_total_code_regs == special_temp_value) <<== sp, 16-byte aligned
600 * +===============================+
Ian Rogers0399dde2012-06-06 17:09:28 -0700601 */
602 static int GetVRegOffset(const DexFile::CodeItem* code_item,
Ian Rogersb23a7722012-10-09 16:54:26 -0700603 uint32_t core_spills, uint32_t fp_spills,
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000604 size_t frame_size, int reg, InstructionSet isa) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700605 DCHECK_EQ(frame_size & (kStackAlignment - 1), 0U);
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700606 DCHECK_NE(reg, -1);
Vladimir Marko81949632014-05-02 11:53:22 +0100607 int spill_size = POPCOUNT(core_spills) * GetBytesPerGprSpillLocation(isa)
608 + POPCOUNT(fp_spills) * GetBytesPerFprSpillLocation(isa)
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000609 + sizeof(uint32_t); // Filler.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700610 int num_regs = code_item->registers_size_ - code_item->ins_size_;
611 int temp_threshold = code_item->registers_size_;
612 const int max_num_special_temps = 1;
613 if (reg == temp_threshold) {
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800614 // The current method pointer corresponds to special location on stack.
615 return 0;
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700616 } else if (reg >= temp_threshold + max_num_special_temps) {
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800617 /*
618 * Special temporaries may have custom locations and the logic above deals with that.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700619 * However, non-special temporaries are placed relative to the outs.
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800620 */
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700621 int temps_start = sizeof(StackReference<mirror::ArtMethod>) + code_item->outs_size_ * sizeof(uint32_t);
622 int relative_offset = (reg - (temp_threshold + max_num_special_temps)) * sizeof(uint32_t);
623 return temps_start + relative_offset;
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800624 } else if (reg < num_regs) {
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700625 int locals_start = frame_size - spill_size - num_regs * sizeof(uint32_t);
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800626 return locals_start + (reg * sizeof(uint32_t));
Ian Rogers0399dde2012-06-06 17:09:28 -0700627 } else {
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800628 // Handle ins.
buzbee82818642014-06-04 15:35:41 -0700629 return frame_size + ((reg - num_regs) * sizeof(uint32_t)) +
630 sizeof(StackReference<mirror::ArtMethod>);
Ian Rogers0399dde2012-06-06 17:09:28 -0700631 }
632 }
633
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000634 static int GetOutVROffset(uint16_t out_num, InstructionSet isa) {
Ian Rogers6a3c1fc2014-10-31 00:33:20 -0700635 UNUSED(isa);
buzbee82818642014-06-04 15:35:41 -0700636 // According to stack model, the first out is above the Method referernce.
637 return sizeof(StackReference<mirror::ArtMethod>) + (out_num * sizeof(uint32_t));
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800638 }
639
Ian Rogers0399dde2012-06-06 17:09:28 -0700640 uintptr_t GetCurrentQuickFramePc() const {
641 return cur_quick_frame_pc_;
642 }
643
Andreas Gampecf4035a2014-05-28 22:43:01 -0700644 StackReference<mirror::ArtMethod>* GetCurrentQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700645 return cur_quick_frame_;
646 }
647
648 ShadowFrame* GetCurrentShadowFrame() const {
649 return cur_shadow_frame_;
650 }
651
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700652 HandleScope* GetCurrentHandleScope() const {
Andreas Gampecf4035a2014-05-28 22:43:01 -0700653 StackReference<mirror::ArtMethod>* sp = GetCurrentQuickFrame();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700654 ++sp; // Skip Method*; handle scope comes next;
655 return reinterpret_cast<HandleScope*>(sp);
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700656 }
657
Ian Rogers40e3bac2012-11-20 00:09:14 -0800658 std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
659
Ian Rogers7a22fa62013-01-23 12:16:16 -0800660 static size_t ComputeNumFrames(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800661
Ian Rogers7a22fa62013-01-23 12:16:16 -0800662 static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800663
Ian Rogers0399dde2012-06-06 17:09:28 -0700664 private:
Ian Rogers5cf98192014-05-29 21:31:50 -0700665 // Private constructor known in the case that num_frames_ has already been computed.
666 StackVisitor(Thread* thread, Context* context, size_t num_frames)
667 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
668
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200669 bool GetGPR(uint32_t reg, uintptr_t* val) const;
670 bool SetGPR(uint32_t reg, uintptr_t value);
671 bool GetFPR(uint32_t reg, uintptr_t* val) const;
672 bool SetFPR(uint32_t reg, uintptr_t value);
673
Ian Rogersb726dcb2012-09-05 08:57:23 -0700674 void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700675
Ian Rogers7a22fa62013-01-23 12:16:16 -0800676 Thread* const thread_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700677 ShadowFrame* cur_shadow_frame_;
Andreas Gampecf4035a2014-05-28 22:43:01 -0700678 StackReference<mirror::ArtMethod>* cur_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700679 uintptr_t cur_quick_frame_pc_;
680 // Lazily computed, number of frames in the stack.
681 size_t num_frames_;
682 // Depth of the frame we're currently at.
683 size_t cur_depth_;
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700684
Ian Rogers0399dde2012-06-06 17:09:28 -0700685 protected:
686 Context* const context_;
687};
688
Elliott Hughes68e76522011-10-05 13:22:16 -0700689} // namespace art
690
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700691#endif // ART_RUNTIME_STACK_H_