blob: 25e50a1a1ffb6b6eaeb465ee8f78353e6af79f31 [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};
56
Ian Rogersef7d42f2014-01-06 12:55:46 -080057// A reference from the shadow stack to a MirrorType object within the Java heap.
58template<class MirrorType>
59class MANAGED StackReference : public mirror::ObjectReference<false, MirrorType> {
60 public:
61 StackReference<MirrorType>() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
62 : mirror::ObjectReference<false, MirrorType>(nullptr) {}
63
64 static StackReference<MirrorType> FromMirrorPtr(MirrorType* p)
65 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
66 return StackReference<MirrorType>(p);
67 }
68
69 private:
70 StackReference<MirrorType>(MirrorType* p) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_)
71 : mirror::ObjectReference<false, MirrorType>(p) {}
72};
73
Mathieu Chartier67022432012-11-29 18:04:50 -080074// ShadowFrame has 3 possible layouts:
75// - portable - a unified array of VRegs and references. Precise references need GC maps.
76// - interpreter - separate VRegs and reference arrays. References are in the reference array.
77// - JNI - just VRegs, but where every VReg holds a reference.
Ian Rogers0399dde2012-06-06 17:09:28 -070078class ShadowFrame {
Elliott Hughes68e76522011-10-05 13:22:16 -070079 public:
Ian Rogersef7d42f2014-01-06 12:55:46 -080080 // Compute size of ShadowFrame in bytes assuming it has a reference array.
Jeff Hao66135192013-05-14 11:02:41 -070081 static size_t ComputeSize(uint32_t num_vregs) {
82 return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) +
Ian Rogersef7d42f2014-01-06 12:55:46 -080083 (sizeof(StackReference<mirror::Object>) * num_vregs);
Jeff Hao66135192013-05-14 11:02:41 -070084 }
85
86 // Create ShadowFrame in heap for deoptimization.
TDYa127ce4cc0d2012-11-18 16:59:53 -080087 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Brian Carlstromea46f952013-07-30 01:26:50 -070088 mirror::ArtMethod* method, uint32_t dex_pc) {
Jeff Hao66135192013-05-14 11:02:41 -070089 uint8_t* memory = new uint8_t[ComputeSize(num_vregs)];
Sebastien Hertzc61124b2013-09-10 11:44:19 +020090 return Create(num_vregs, link, method, dex_pc, memory);
Jeff Hao66135192013-05-14 11:02:41 -070091 }
92
93 // Create ShadowFrame for interpreter using provided memory.
94 static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link,
Brian Carlstromea46f952013-07-30 01:26:50 -070095 mirror::ArtMethod* method, uint32_t dex_pc, void* memory) {
TDYa127ce4cc0d2012-11-18 16:59:53 -080096 ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true);
97 return sf;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -070098 }
99 ~ShadowFrame() {}
100
TDYa127ce4cc0d2012-11-18 16:59:53 -0800101 bool HasReferenceArray() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700102#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800103 return (number_of_vregs_ & kHasReferenceArray) != 0;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700104#else
105 return true;
106#endif
Ian Rogers0399dde2012-06-06 17:09:28 -0700107 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700108
TDYa127ce4cc0d2012-11-18 16:59:53 -0800109 uint32_t NumberOfVRegs() const {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700110#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800111 return number_of_vregs_ & ~kHasReferenceArray;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700112#else
113 return number_of_vregs_;
114#endif
Ian Rogers0399dde2012-06-06 17:09:28 -0700115 }
116
TDYa127ce4cc0d2012-11-18 16:59:53 -0800117 void SetNumberOfVRegs(uint32_t number_of_vregs) {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700118#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800119 number_of_vregs_ = number_of_vregs | (number_of_vregs_ & kHasReferenceArray);
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700120#else
121 UNUSED(number_of_vregs);
122 UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled";
123#endif
Ian Rogers5438ad82012-10-15 17:22:44 -0700124 }
125
Ian Rogers0399dde2012-06-06 17:09:28 -0700126 uint32_t GetDexPC() const {
127 return dex_pc_;
128 }
129
130 void SetDexPC(uint32_t dex_pc) {
131 dex_pc_ = dex_pc;
132 }
133
Ian Rogers0399dde2012-06-06 17:09:28 -0700134 ShadowFrame* GetLink() const {
135 return link_;
136 }
137
138 void SetLink(ShadowFrame* frame) {
139 DCHECK_NE(this, frame);
140 link_ = frame;
141 }
142
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700143 int32_t GetVReg(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800144 DCHECK_LT(i, NumberOfVRegs());
145 const uint32_t* vreg = &vregs_[i];
146 return *reinterpret_cast<const int32_t*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700147 }
148
149 float GetVRegFloat(size_t i) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800150 DCHECK_LT(i, NumberOfVRegs());
151 // NOTE: Strict-aliasing?
152 const uint32_t* vreg = &vregs_[i];
153 return *reinterpret_cast<const float*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700154 }
155
156 int64_t GetVRegLong(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200157 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800158 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700159 // Alignment attribute required for GCC 4.8
160 typedef const int64_t unaligned_int64 __attribute__ ((aligned (4)));
161 return *reinterpret_cast<unaligned_int64*>(vreg);
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700162 }
163
164 double GetVRegDouble(size_t i) const {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200165 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800166 const uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700167 // Alignment attribute required for GCC 4.8
168 typedef const double unaligned_double __attribute__ ((aligned (4)));
169 return *reinterpret_cast<unaligned_double*>(vreg);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800170 }
171
Mathieu Chartier4e305412014-02-19 10:54:44 -0800172 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800173 mirror::Object* GetVRegReference(size_t i) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800174 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800175 mirror::Object* ref;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800176 if (HasReferenceArray()) {
Mathieu Chartier4e305412014-02-19 10:54:44 -0800177 ref = References()[i].AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800178 } else {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800179 const uint32_t* vreg_ptr = &vregs_[i];
Mathieu Chartier4e305412014-02-19 10:54:44 -0800180 ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr();
TDYa127ce4cc0d2012-11-18 16:59:53 -0800181 }
Mathieu Chartier4e305412014-02-19 10:54:44 -0800182 if (kVerifyFlags & kVerifyReads) {
183 VerifyObject(ref);
184 }
185 return ref;
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700186 }
187
Jeff Hao16743632013-05-08 10:59:04 -0700188 // Get view of vregs as range of consecutive arguments starting at i.
189 uint32_t* GetVRegArgs(size_t i) {
190 return &vregs_[i];
191 }
192
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700193 void SetVReg(size_t i, int32_t val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800194 DCHECK_LT(i, NumberOfVRegs());
195 uint32_t* vreg = &vregs_[i];
196 *reinterpret_cast<int32_t*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700197 // This is needed for moving collectors since these can update the vreg references if they
198 // happen to agree with references in the reference array.
199 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800200 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700201 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700202 }
203
204 void SetVRegFloat(size_t i, float val) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800205 DCHECK_LT(i, NumberOfVRegs());
206 uint32_t* vreg = &vregs_[i];
207 *reinterpret_cast<float*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700208 // This is needed for moving collectors since these can update the vreg references if they
209 // happen to agree with references in the reference array.
210 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800211 References()[i].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700212 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700213 }
214
215 void SetVRegLong(size_t i, int64_t val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200216 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800217 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700218 // Alignment attribute required for GCC 4.8
219 typedef int64_t unaligned_int64 __attribute__ ((aligned (4)));
220 *reinterpret_cast<unaligned_int64*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700221 // This is needed for moving collectors since these can update the vreg references if they
222 // happen to agree with references in the reference array.
223 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800224 References()[i].Clear();
225 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700226 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700227 }
228
229 void SetVRegDouble(size_t i, double val) {
Sebastien Hertz807a2562013-04-15 09:33:39 +0200230 DCHECK_LT(i, NumberOfVRegs());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800231 uint32_t* vreg = &vregs_[i];
Jeff Haoe47637c2013-09-19 15:13:16 -0700232 // Alignment attribute required for GCC 4.8
233 typedef double unaligned_double __attribute__ ((aligned (4)));
234 *reinterpret_cast<unaligned_double*>(vreg) = val;
Mathieu Chartier590fee92013-09-13 13:46:47 -0700235 // This is needed for moving collectors since these can update the vreg references if they
236 // happen to agree with references in the reference array.
237 if (kMovingCollector && HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800238 References()[i].Clear();
239 References()[i + 1].Clear();
Mathieu Chartier590fee92013-09-13 13:46:47 -0700240 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700241 }
242
Mathieu Chartier4e305412014-02-19 10:54:44 -0800243 template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags>
Ian Rogersef7d42f2014-01-06 12:55:46 -0800244 void SetVRegReference(size_t i, mirror::Object* val) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800245 DCHECK_LT(i, NumberOfVRegs());
Mathieu Chartier4e305412014-02-19 10:54:44 -0800246 if (kVerifyFlags & kVerifyWrites) {
247 VerifyObject(val);
248 }
TDYa127ce4cc0d2012-11-18 16:59:53 -0800249 uint32_t* vreg = &vregs_[i];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800250 reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800251 if (HasReferenceArray()) {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800252 References()[i].Assign(val);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800253 }
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700254 }
255
Ian Rogersef7d42f2014-01-06 12:55:46 -0800256 mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
257 DCHECK(method_ != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700258 return method_;
Elliott Hughes68e76522011-10-05 13:22:16 -0700259 }
260
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700261 mirror::ArtMethod** GetMethodAddress() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
262 DCHECK(method_ != nullptr);
263 return &method_;
264 }
265
Ian Rogers62d6c772013-02-27 08:32:07 -0800266 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
267
Jeff Haoe701f482013-05-24 11:50:49 -0700268 mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
269
Ian Rogers62d6c772013-02-27 08:32:07 -0800270 ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
271
Brian Carlstromea46f952013-07-30 01:26:50 -0700272 void SetMethod(mirror::ArtMethod* method) {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700273#if defined(ART_USE_PORTABLE_COMPILER)
Ian Rogersef7d42f2014-01-06 12:55:46 -0800274 DCHECK(method != nullptr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700275 method_ = method;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700276#else
277 UNUSED(method);
278 UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled";
279#endif
Elliott Hughes68e76522011-10-05 13:22:16 -0700280 }
281
Ian Rogersef7d42f2014-01-06 12:55:46 -0800282 bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const {
TDYa127ce4cc0d2012-11-18 16:59:53 -0800283 if (HasReferenceArray()) {
284 return ((&References()[0] <= shadow_frame_entry_obj) &&
285 (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1])));
286 } else {
287 uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj);
288 return ((&vregs_[0] <= shadow_frame_entry) &&
289 (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1])));
Ian Rogers0399dde2012-06-06 17:09:28 -0700290 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700291 }
292
Ian Rogers0399dde2012-06-06 17:09:28 -0700293 static size_t LinkOffset() {
294 return OFFSETOF_MEMBER(ShadowFrame, link_);
295 }
296
Ian Rogers0399dde2012-06-06 17:09:28 -0700297 static size_t MethodOffset() {
298 return OFFSETOF_MEMBER(ShadowFrame, method_);
299 }
300
Ian Rogers0399dde2012-06-06 17:09:28 -0700301 static size_t DexPCOffset() {
302 return OFFSETOF_MEMBER(ShadowFrame, dex_pc_);
303 }
304
Ian Rogers5438ad82012-10-15 17:22:44 -0700305 static size_t NumberOfVRegsOffset() {
306 return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_);
307 }
308
TDYa127ce4cc0d2012-11-18 16:59:53 -0800309 static size_t VRegsOffset() {
310 return OFFSETOF_MEMBER(ShadowFrame, vregs_);
Ian Rogers5438ad82012-10-15 17:22:44 -0700311 }
312
Elliott Hughes68e76522011-10-05 13:22:16 -0700313 private:
Brian Carlstromea46f952013-07-30 01:26:50 -0700314 ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method,
Ian Rogers2dd0e2c2013-01-24 12:42:14 -0800315 uint32_t dex_pc, bool has_reference_array)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800316 : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) {
317 if (has_reference_array) {
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700318#if defined(ART_USE_PORTABLE_COMPILER)
319 CHECK_LT(num_vregs, static_cast<uint32_t>(kHasReferenceArray));
TDYa127ce4cc0d2012-11-18 16:59:53 -0800320 number_of_vregs_ |= kHasReferenceArray;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700321#endif
Ian Rogersef7d42f2014-01-06 12:55:46 -0800322 memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(StackReference<mirror::Object>)));
Mathieu Chartier67022432012-11-29 18:04:50 -0800323 } else {
Jeff Haoe701f482013-05-24 11:50:49 -0700324 memset(vregs_, 0, num_vregs * sizeof(uint32_t));
Ian Rogers2fa6b2e2012-10-17 00:10:17 -0700325 }
326 }
Elliott Hughes68e76522011-10-05 13:22:16 -0700327
Ian Rogersef7d42f2014-01-06 12:55:46 -0800328 const StackReference<mirror::Object>* References() const {
Mathieu Chartier67022432012-11-29 18:04:50 -0800329 DCHECK(HasReferenceArray());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800330 const uint32_t* vreg_end = &vregs_[NumberOfVRegs()];
Ian Rogersef7d42f2014-01-06 12:55:46 -0800331 return reinterpret_cast<const StackReference<mirror::Object>*>(vreg_end);
TDYa127ce4cc0d2012-11-18 16:59:53 -0800332 }
333
Ian Rogersef7d42f2014-01-06 12:55:46 -0800334 StackReference<mirror::Object>* References() {
335 return const_cast<StackReference<mirror::Object>*>(const_cast<const ShadowFrame*>(this)->References());
TDYa127ce4cc0d2012-11-18 16:59:53 -0800336 }
337
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700338#if defined(ART_USE_PORTABLE_COMPILER)
TDYa127ce4cc0d2012-11-18 16:59:53 -0800339 enum ShadowFrameFlag {
340 kHasReferenceArray = 1ul << 31
341 };
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700342 // TODO: make const in the portable case.
TDYa127ce4cc0d2012-11-18 16:59:53 -0800343 uint32_t number_of_vregs_;
Ian Rogers8a01a3a2013-05-06 13:25:44 -0700344#else
345 const uint32_t number_of_vregs_;
346#endif
Ian Rogers5438ad82012-10-15 17:22:44 -0700347 // Link to previous shadow frame or NULL.
Ian Rogers0399dde2012-06-06 17:09:28 -0700348 ShadowFrame* link_;
Brian Carlstromea46f952013-07-30 01:26:50 -0700349 mirror::ArtMethod* method_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700350 uint32_t dex_pc_;
TDYa127ce4cc0d2012-11-18 16:59:53 -0800351 uint32_t vregs_[0];
Elliott Hughes68e76522011-10-05 13:22:16 -0700352
Ian Rogers0399dde2012-06-06 17:09:28 -0700353 DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame);
Elliott Hughes68e76522011-10-05 13:22:16 -0700354};
355
Ian Rogers0399dde2012-06-06 17:09:28 -0700356// The managed stack is used to record fragments of managed code stacks. Managed code stacks
357// may either be shadow frames or lists of frames using fixed frame sizes. Transition records are
358// necessary for transitions between code using different frame layouts and transitions into native
359// code.
Ian Rogersdf1ce912012-11-27 17:07:11 -0800360class PACKED(4) ManagedStack {
Ian Rogers0399dde2012-06-06 17:09:28 -0700361 public:
Ian Rogersca190662012-06-26 15:45:57 -0700362 ManagedStack()
363 : link_(NULL), top_shadow_frame_(NULL), top_quick_frame_(NULL), top_quick_frame_pc_(0) {}
Ian Rogers81d425b2012-09-27 16:03:43 -0700364
365 void PushManagedStackFragment(ManagedStack* fragment) {
366 // Copy this top fragment into given fragment.
367 memcpy(fragment, this, sizeof(ManagedStack));
368 // Clear this fragment, which has become the top.
369 memset(this, 0, sizeof(ManagedStack));
370 // Link our top fragment onto the given fragment.
371 link_ = fragment;
372 }
373
374 void PopManagedStackFragment(const ManagedStack& fragment) {
375 DCHECK(&fragment == link_);
376 // Copy this given fragment back to the top.
377 memcpy(this, &fragment, sizeof(ManagedStack));
378 }
Ian Rogers0399dde2012-06-06 17:09:28 -0700379
380 ManagedStack* GetLink() const {
381 return link_;
382 }
383
Andreas Gampecf4035a2014-05-28 22:43:01 -0700384 StackReference<mirror::ArtMethod>* GetTopQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700385 return top_quick_frame_;
386 }
387
Andreas Gampecf4035a2014-05-28 22:43:01 -0700388 void SetTopQuickFrame(StackReference<mirror::ArtMethod>* top) {
Sebastien Hertza7b0c422013-04-05 16:19:39 +0200389 DCHECK(top_shadow_frame_ == NULL);
Ian Rogers0399dde2012-06-06 17:09:28 -0700390 top_quick_frame_ = top;
391 }
392
393 uintptr_t GetTopQuickFramePc() const {
394 return top_quick_frame_pc_;
395 }
396
397 void SetTopQuickFramePc(uintptr_t pc) {
Sebastien Hertza7b0c422013-04-05 16:19:39 +0200398 DCHECK(top_shadow_frame_ == NULL);
Ian Rogers0399dde2012-06-06 17:09:28 -0700399 top_quick_frame_pc_ = pc;
400 }
401
402 static size_t TopQuickFrameOffset() {
403 return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_);
404 }
405
406 static size_t TopQuickFramePcOffset() {
407 return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_pc_);
408 }
409
410 ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) {
Sebastien Hertza7b0c422013-04-05 16:19:39 +0200411 DCHECK(top_quick_frame_ == NULL);
Ian Rogers0399dde2012-06-06 17:09:28 -0700412 ShadowFrame* old_frame = top_shadow_frame_;
413 top_shadow_frame_ = new_top_frame;
414 new_top_frame->SetLink(old_frame);
415 return old_frame;
416 }
417
418 ShadowFrame* PopShadowFrame() {
Sebastien Hertza7b0c422013-04-05 16:19:39 +0200419 DCHECK(top_quick_frame_ == NULL);
Ian Rogers0399dde2012-06-06 17:09:28 -0700420 CHECK(top_shadow_frame_ != NULL);
421 ShadowFrame* frame = top_shadow_frame_;
422 top_shadow_frame_ = frame->GetLink();
423 return frame;
424 }
425
426 ShadowFrame* GetTopShadowFrame() const {
427 return top_shadow_frame_;
428 }
429
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800430 void SetTopShadowFrame(ShadowFrame* top) {
Sebastien Hertza7b0c422013-04-05 16:19:39 +0200431 DCHECK(top_quick_frame_ == NULL);
Jeff Hao11ffc2d2013-02-01 11:52:17 -0800432 top_shadow_frame_ = top;
433 }
434
Ian Rogers0399dde2012-06-06 17:09:28 -0700435 static size_t TopShadowFrameOffset() {
436 return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_);
437 }
438
Ian Rogersef7d42f2014-01-06 12:55:46 -0800439 size_t NumJniShadowFrameReferences() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700440
Ian Rogersef7d42f2014-01-06 12:55:46 -0800441 bool ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700442
443 private:
444 ManagedStack* link_;
445 ShadowFrame* top_shadow_frame_;
Andreas Gampecf4035a2014-05-28 22:43:01 -0700446 StackReference<mirror::ArtMethod>* top_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700447 uintptr_t top_quick_frame_pc_;
448};
449
450class StackVisitor {
451 protected:
Ian Rogers7a22fa62013-01-23 12:16:16 -0800452 StackVisitor(Thread* thread, Context* context) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700453
454 public:
455 virtual ~StackVisitor() {}
456
457 // Return 'true' if we should continue to visit more frames, 'false' to stop.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700458 virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0;
Ian Rogers0399dde2012-06-06 17:09:28 -0700459
Ian Rogers00f7d0e2012-07-19 15:28:27 -0700460 void WalkStack(bool include_transitions = false)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700461 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700462
Ian Rogersef7d42f2014-01-06 12:55:46 -0800463 mirror::ArtMethod* GetMethod() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
464 if (cur_shadow_frame_ != nullptr) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700465 return cur_shadow_frame_->GetMethod();
Ian Rogersef7d42f2014-01-06 12:55:46 -0800466 } else if (cur_quick_frame_ != nullptr) {
Andreas Gampecf4035a2014-05-28 22:43:01 -0700467 return cur_quick_frame_->AsMirrorPtr();
Hiroshi Yamauchi92d1a662014-05-15 21:43:59 -0700468 } else {
469 return nullptr;
470 }
471 }
472
Ian Rogers0399dde2012-06-06 17:09:28 -0700473 bool IsShadowFrame() const {
Ian Rogersef7d42f2014-01-06 12:55:46 -0800474 return cur_shadow_frame_ != nullptr;
Ian Rogers0399dde2012-06-06 17:09:28 -0700475 }
476
Dave Allisonb373e092014-02-20 16:06:36 -0800477 uint32_t GetDexPc(bool abort_on_failure = true) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0c7abda2012-09-19 13:33:42 -0700478
Ian Rogers62d6c772013-02-27 08:32:07 -0800479 mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
480
Ian Rogers0c7abda2012-09-19 13:33:42 -0700481 size_t GetNativePcOffset() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
482
Ian Rogersef7d42f2014-01-06 12:55:46 -0800483 uintptr_t* CalleeSaveAddress(int num, size_t frame_size) const
484 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700485 // Callee saves are held at the top of the frame
Ian Rogersef7d42f2014-01-06 12:55:46 -0800486 DCHECK(GetMethod() != nullptr);
Ian Rogers13735952014-10-08 12:43:28 -0700487 uint8_t* save_addr =
488 reinterpret_cast<uint8_t*>(cur_quick_frame_) + frame_size - ((num + 1) * sizeof(void*));
Andreas Gampebf6b92a2014-03-05 16:11:04 -0800489#if defined(__i386__) || defined(__x86_64__)
Ian Rogers13735952014-10-08 12:43:28 -0700490 save_addr -= sizeof(void*); // account for return address
Ian Rogers0399dde2012-06-06 17:09:28 -0700491#endif
Mathieu Chartier67022432012-11-29 18:04:50 -0800492 return reinterpret_cast<uintptr_t*>(save_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700493 }
494
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700495 // Returns the height of the stack in the managed stack frames, including transitions.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700496 size_t GetFrameHeight() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers62d6c772013-02-27 08:32:07 -0800497 return GetNumFrames() - cur_depth_ - 1;
Ian Rogers0399dde2012-06-06 17:09:28 -0700498 }
499
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700500 // Returns a frame ID for JDWP use, starting from 1.
Ian Rogersb726dcb2012-09-05 08:57:23 -0700501 size_t GetFrameId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700502 return GetFrameHeight() + 1;
503 }
504
Ian Rogersb726dcb2012-09-05 08:57:23 -0700505 size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700506 if (num_frames_ == 0) {
Ian Rogers7a22fa62013-01-23 12:16:16 -0800507 num_frames_ = ComputeNumFrames(thread_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700508 }
509 return num_frames_;
510 }
511
Hiroshi Yamauchi649278c2014-08-13 11:12:22 -0700512 size_t GetFrameDepth() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
513 return cur_depth_;
514 }
515
Ian Rogers5cf98192014-05-29 21:31:50 -0700516 // Get the method and dex pc immediately after the one that's currently being visited.
517 bool GetNextMethodAndDexPc(mirror::ArtMethod** next_method, uint32_t* next_dex_pc)
518 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
519
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200520 bool GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind, uint32_t* val) const
Ian Rogers2bcb4a42012-11-08 10:39:18 -0800521 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700522
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200523 uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const
524 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
525 uint32_t val;
526 bool success = GetVReg(m, vreg, kind, &val);
527 CHECK(success) << "Failed to read vreg " << vreg << " of kind " << kind;
528 return val;
529 }
530
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200531 bool GetVRegPair(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi,
532 uint64_t* val) const
533 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
534
535 uint64_t GetVRegPair(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind_lo,
536 VRegKind kind_hi) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
537 uint64_t val;
538 bool success = GetVRegPair(m, vreg, kind_lo, kind_hi, &val);
539 CHECK(success) << "Failed to read vreg pair " << vreg
540 << " of kind [" << kind_lo << "," << kind_hi << "]";
541 return val;
542 }
543
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200544 bool SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind)
Ian Rogersb726dcb2012-09-05 08:57:23 -0700545 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700546
Sebastien Hertzc901dd72014-07-16 11:56:07 +0200547 bool SetVRegPair(mirror::ArtMethod* m, uint16_t vreg, uint64_t new_value,
548 VRegKind kind_lo, VRegKind kind_hi)
549 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
550
Mathieu Chartier815873e2014-02-13 18:02:13 -0800551 uintptr_t* GetGPRAddress(uint32_t reg) const;
Ian Rogers0399dde2012-06-06 17:09:28 -0700552
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700553 // This is a fast-path for getting/setting values in a quick frame.
Andreas Gampecf4035a2014-05-28 22:43:01 -0700554 uint32_t* GetVRegAddr(StackReference<mirror::ArtMethod>* cur_quick_frame,
555 const DexFile::CodeItem* code_item,
Ian Rogersef7d42f2014-01-06 12:55:46 -0800556 uint32_t core_spills, uint32_t fp_spills, size_t frame_size,
557 uint16_t vreg) const {
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000558 int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA);
Ian Rogers0ec569a2012-07-01 16:43:46 -0700559 DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame());
Ian Rogers13735952014-10-08 12:43:28 -0700560 uint8_t* vreg_addr = reinterpret_cast<uint8_t*>(cur_quick_frame) + offset;
Mathieu Chartier423d2a32013-09-12 17:33:56 -0700561 return reinterpret_cast<uint32_t*>(vreg_addr);
Ian Rogers0399dde2012-06-06 17:09:28 -0700562 }
563
Ian Rogersef7d42f2014-01-06 12:55:46 -0800564 uintptr_t GetReturnPc() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700565
Ian Rogersef7d42f2014-01-06 12:55:46 -0800566 void SetReturnPc(uintptr_t new_ret_pc) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700567
568 /*
569 * Return sp-relative offset for a Dalvik virtual register, compiler
570 * spill or Method* in bytes using Method*.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700571 * Note that (reg == -1) denotes an invalid Dalvik register. For the
572 * positive values, the Dalvik registers come first, followed by the
573 * Method*, followed by other special temporaries if any, followed by
574 * regular compiler temporary. As of now we only have the Method* as
575 * as a special compiler temporary.
576 * A compiler temporary can be thought of as a virtual register that
577 * does not exist in the dex but holds intermediate values to help
578 * optimizations and code generation. A special compiler temporary is
579 * one whose location in frame is well known while non-special ones
580 * do not have a requirement on location in frame as long as code
581 * generator itself knows how to access them.
Ian Rogers0399dde2012-06-06 17:09:28 -0700582 *
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700583 * +-------------------------------+
584 * | IN[ins-1] | {Note: resides in caller's frame}
585 * | . |
586 * | IN[0] |
587 * | caller's ArtMethod | ... StackReference<ArtMethod>
588 * +===============================+ {Note: start of callee's frame}
589 * | core callee-save spill | {variable sized}
590 * +-------------------------------+
591 * | fp callee-save spill |
592 * +-------------------------------+
593 * | filler word | {For compatibility, if V[locals-1] used as wide
594 * +-------------------------------+
595 * | V[locals-1] |
596 * | V[locals-2] |
597 * | . |
598 * | . | ... (reg == 2)
599 * | V[1] | ... (reg == 1)
600 * | V[0] | ... (reg == 0) <---- "locals_start"
601 * +-------------------------------+
602 * | stack alignment padding | {0 to (kStackAlignWords-1) of padding}
603 * +-------------------------------+
604 * | Compiler temp region | ... (reg >= max_num_special_temps)
605 * | . |
606 * | . |
Brian Carlstrom2cbaccb2014-09-14 20:34:17 -0700607 * | V[max_num_special_temps + 1] |
608 * | V[max_num_special_temps + 0] |
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700609 * +-------------------------------+
610 * | OUT[outs-1] |
611 * | OUT[outs-2] |
612 * | . |
613 * | OUT[0] |
614 * | StackReference<ArtMethod> | ... (reg == num_total_code_regs == special_temp_value) <<== sp, 16-byte aligned
615 * +===============================+
Ian Rogers0399dde2012-06-06 17:09:28 -0700616 */
617 static int GetVRegOffset(const DexFile::CodeItem* code_item,
Ian Rogersb23a7722012-10-09 16:54:26 -0700618 uint32_t core_spills, uint32_t fp_spills,
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000619 size_t frame_size, int reg, InstructionSet isa) {
Ian Rogers0399dde2012-06-06 17:09:28 -0700620 DCHECK_EQ(frame_size & (kStackAlignment - 1), 0U);
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700621 DCHECK_NE(reg, -1);
Vladimir Marko81949632014-05-02 11:53:22 +0100622 int spill_size = POPCOUNT(core_spills) * GetBytesPerGprSpillLocation(isa)
623 + POPCOUNT(fp_spills) * GetBytesPerFprSpillLocation(isa)
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000624 + sizeof(uint32_t); // Filler.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700625 int num_regs = code_item->registers_size_ - code_item->ins_size_;
626 int temp_threshold = code_item->registers_size_;
627 const int max_num_special_temps = 1;
628 if (reg == temp_threshold) {
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800629 // The current method pointer corresponds to special location on stack.
630 return 0;
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700631 } else if (reg >= temp_threshold + max_num_special_temps) {
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800632 /*
633 * Special temporaries may have custom locations and the logic above deals with that.
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700634 * However, non-special temporaries are placed relative to the outs.
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800635 */
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700636 int temps_start = sizeof(StackReference<mirror::ArtMethod>) + code_item->outs_size_ * sizeof(uint32_t);
637 int relative_offset = (reg - (temp_threshold + max_num_special_temps)) * sizeof(uint32_t);
638 return temps_start + relative_offset;
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800639 } else if (reg < num_regs) {
Razvan A Lupusoru8d0d03e2014-06-06 17:04:52 -0700640 int locals_start = frame_size - spill_size - num_regs * sizeof(uint32_t);
Razvan A Lupusoruda7a69b2014-01-08 15:09:50 -0800641 return locals_start + (reg * sizeof(uint32_t));
Ian Rogers0399dde2012-06-06 17:09:28 -0700642 } else {
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800643 // Handle ins.
buzbee82818642014-06-04 15:35:41 -0700644 return frame_size + ((reg - num_regs) * sizeof(uint32_t)) +
645 sizeof(StackReference<mirror::ArtMethod>);
Ian Rogers0399dde2012-06-06 17:09:28 -0700646 }
647 }
648
Nicolas Geoffray42fcd982014-04-22 11:03:52 +0000649 static int GetOutVROffset(uint16_t out_num, InstructionSet isa) {
buzbee82818642014-06-04 15:35:41 -0700650 // According to stack model, the first out is above the Method referernce.
651 return sizeof(StackReference<mirror::ArtMethod>) + (out_num * sizeof(uint32_t));
Razvan A Lupusoru3bc01742014-02-06 13:18:43 -0800652 }
653
Ian Rogers0399dde2012-06-06 17:09:28 -0700654 uintptr_t GetCurrentQuickFramePc() const {
655 return cur_quick_frame_pc_;
656 }
657
Andreas Gampecf4035a2014-05-28 22:43:01 -0700658 StackReference<mirror::ArtMethod>* GetCurrentQuickFrame() const {
Ian Rogers0399dde2012-06-06 17:09:28 -0700659 return cur_quick_frame_;
660 }
661
662 ShadowFrame* GetCurrentShadowFrame() const {
663 return cur_shadow_frame_;
664 }
665
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700666 HandleScope* GetCurrentHandleScope() const {
Andreas Gampecf4035a2014-05-28 22:43:01 -0700667 StackReference<mirror::ArtMethod>* sp = GetCurrentQuickFrame();
Mathieu Chartiereb8167a2014-05-07 15:43:14 -0700668 ++sp; // Skip Method*; handle scope comes next;
669 return reinterpret_cast<HandleScope*>(sp);
Elliott Hughes08fc03a2012-06-26 17:34:00 -0700670 }
671
Ian Rogers40e3bac2012-11-20 00:09:14 -0800672 std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
673
Ian Rogers7a22fa62013-01-23 12:16:16 -0800674 static size_t ComputeNumFrames(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800675
Ian Rogers7a22fa62013-01-23 12:16:16 -0800676 static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers306057f2012-11-26 12:45:53 -0800677
Ian Rogers0399dde2012-06-06 17:09:28 -0700678 private:
Ian Rogers5cf98192014-05-29 21:31:50 -0700679 // Private constructor known in the case that num_frames_ has already been computed.
680 StackVisitor(Thread* thread, Context* context, size_t num_frames)
681 SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
682
Sebastien Hertz0bcb2902014-06-17 15:52:45 +0200683 bool GetGPR(uint32_t reg, uintptr_t* val) const;
684 bool SetGPR(uint32_t reg, uintptr_t value);
685 bool GetFPR(uint32_t reg, uintptr_t* val) const;
686 bool SetFPR(uint32_t reg, uintptr_t value);
687
Ian Rogersb726dcb2012-09-05 08:57:23 -0700688 void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_);
Ian Rogers0399dde2012-06-06 17:09:28 -0700689
Ian Rogers7a22fa62013-01-23 12:16:16 -0800690 Thread* const thread_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700691 ShadowFrame* cur_shadow_frame_;
Andreas Gampecf4035a2014-05-28 22:43:01 -0700692 StackReference<mirror::ArtMethod>* cur_quick_frame_;
Ian Rogers0399dde2012-06-06 17:09:28 -0700693 uintptr_t cur_quick_frame_pc_;
694 // Lazily computed, number of frames in the stack.
695 size_t num_frames_;
696 // Depth of the frame we're currently at.
697 size_t cur_depth_;
Brian Carlstrom0cd7ec22013-07-17 23:40:20 -0700698
Ian Rogers0399dde2012-06-06 17:09:28 -0700699 protected:
700 Context* const context_;
701};
702
Elliott Hughes68e76522011-10-05 13:22:16 -0700703} // namespace art
704
Brian Carlstromfc0e3212013-07-17 14:40:12 -0700705#endif // ART_RUNTIME_STACK_H_