Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 1 | /* |
| 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 Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 17 | #ifndef ART_RUNTIME_STACK_H_ |
| 18 | #define ART_RUNTIME_STACK_H_ |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 19 | |
Ian Rogers | 6d4d9fc | 2011-11-30 16:24:48 -0800 | [diff] [blame] | 20 | #include "dex_file.h" |
jeffhao | 725a957 | 2012-11-13 18:20:12 -0800 | [diff] [blame] | 21 | #include "instrumentation.h" |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 22 | #include "base/macros.h" |
Ian Rogers | 166db04 | 2013-07-26 12:05:57 -0700 | [diff] [blame] | 23 | #include "arch/context.h" |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 24 | |
| 25 | #include <stdint.h> |
Ian Rogers | 40e3bac | 2012-11-20 00:09:14 -0800 | [diff] [blame] | 26 | #include <string> |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 27 | |
| 28 | namespace art { |
| 29 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 30 | namespace mirror { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 31 | class ArtMethod; |
| 32 | class Object; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 33 | } // namespace mirror |
| 34 | |
| 35 | class Context; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 36 | class ShadowFrame; |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 37 | class StackIndirectReferenceTable; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 38 | class ScopedObjectAccess; |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 39 | class Thread; |
| 40 | |
Ian Rogers | 2bcb4a4 | 2012-11-08 10:39:18 -0800 | [diff] [blame] | 41 | // The kind of vreg being accessed in calls to Set/GetVReg. |
| 42 | enum VRegKind { |
| 43 | kReferenceVReg, |
| 44 | kIntVReg, |
| 45 | kFloatVReg, |
| 46 | kLongLoVReg, |
| 47 | kLongHiVReg, |
| 48 | kDoubleLoVReg, |
| 49 | kDoubleHiVReg, |
| 50 | kConstant, |
| 51 | kImpreciseConstant, |
| 52 | kUndefined, |
| 53 | }; |
| 54 | |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 55 | // ShadowFrame has 3 possible layouts: |
| 56 | // - portable - a unified array of VRegs and references. Precise references need GC maps. |
| 57 | // - interpreter - separate VRegs and reference arrays. References are in the reference array. |
| 58 | // - JNI - just VRegs, but where every VReg holds a reference. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 59 | class ShadowFrame { |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 60 | public: |
Jeff Hao | 6613519 | 2013-05-14 11:02:41 -0700 | [diff] [blame] | 61 | // Compute size of ShadowFrame in bytes. |
| 62 | static size_t ComputeSize(uint32_t num_vregs) { |
| 63 | return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) + |
| 64 | (sizeof(mirror::Object*) * num_vregs); |
| 65 | } |
| 66 | |
| 67 | // Create ShadowFrame in heap for deoptimization. |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 68 | static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 69 | mirror::ArtMethod* method, uint32_t dex_pc) { |
Jeff Hao | 6613519 | 2013-05-14 11:02:41 -0700 | [diff] [blame] | 70 | uint8_t* memory = new uint8_t[ComputeSize(num_vregs)]; |
| 71 | ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); |
| 72 | return sf; |
| 73 | } |
| 74 | |
| 75 | // Create ShadowFrame for interpreter using provided memory. |
| 76 | static ShadowFrame* Create(uint32_t num_vregs, ShadowFrame* link, |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 77 | mirror::ArtMethod* method, uint32_t dex_pc, void* memory) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 78 | ShadowFrame* sf = new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); |
| 79 | return sf; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 80 | } |
| 81 | ~ShadowFrame() {} |
| 82 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 83 | bool HasReferenceArray() const { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 84 | #if defined(ART_USE_PORTABLE_COMPILER) |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 85 | return (number_of_vregs_ & kHasReferenceArray) != 0; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 86 | #else |
| 87 | return true; |
| 88 | #endif |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 89 | } |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 90 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 91 | uint32_t NumberOfVRegs() const { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 92 | #if defined(ART_USE_PORTABLE_COMPILER) |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 93 | return number_of_vregs_ & ~kHasReferenceArray; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 94 | #else |
| 95 | return number_of_vregs_; |
| 96 | #endif |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 97 | } |
| 98 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 99 | void SetNumberOfVRegs(uint32_t number_of_vregs) { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 100 | #if defined(ART_USE_PORTABLE_COMPILER) |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 101 | number_of_vregs_ = number_of_vregs | (number_of_vregs_ & kHasReferenceArray); |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 102 | #else |
| 103 | UNUSED(number_of_vregs); |
| 104 | UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled"; |
| 105 | #endif |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 106 | } |
| 107 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 108 | uint32_t GetDexPC() const { |
| 109 | return dex_pc_; |
| 110 | } |
| 111 | |
| 112 | void SetDexPC(uint32_t dex_pc) { |
| 113 | dex_pc_ = dex_pc; |
| 114 | } |
| 115 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 116 | ShadowFrame* GetLink() const { |
| 117 | return link_; |
| 118 | } |
| 119 | |
| 120 | void SetLink(ShadowFrame* frame) { |
| 121 | DCHECK_NE(this, frame); |
| 122 | link_ = frame; |
| 123 | } |
| 124 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 125 | int32_t GetVReg(size_t i) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 126 | DCHECK_LT(i, NumberOfVRegs()); |
| 127 | const uint32_t* vreg = &vregs_[i]; |
| 128 | return *reinterpret_cast<const int32_t*>(vreg); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 129 | } |
| 130 | |
| 131 | float GetVRegFloat(size_t i) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 132 | DCHECK_LT(i, NumberOfVRegs()); |
| 133 | // NOTE: Strict-aliasing? |
| 134 | const uint32_t* vreg = &vregs_[i]; |
| 135 | return *reinterpret_cast<const float*>(vreg); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 136 | } |
| 137 | |
| 138 | int64_t GetVRegLong(size_t i) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 139 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 140 | const uint32_t* vreg = &vregs_[i]; |
| 141 | return *reinterpret_cast<const int64_t*>(vreg); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 142 | } |
| 143 | |
| 144 | double GetVRegDouble(size_t i) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 145 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 146 | const uint32_t* vreg = &vregs_[i]; |
| 147 | return *reinterpret_cast<const double*>(vreg); |
| 148 | } |
| 149 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 150 | mirror::Object* GetVRegReference(size_t i) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 151 | DCHECK_LT(i, NumberOfVRegs()); |
| 152 | if (HasReferenceArray()) { |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame^] | 153 | mirror::Object* ref = References()[i]; |
| 154 | // If the vreg reference is not equal to the vreg then the vreg reference is stale. |
| 155 | if (reinterpret_cast<uint32_t>(ref) != vregs_[i]) { |
| 156 | return nullptr; |
| 157 | } |
| 158 | return ref; |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 159 | } else { |
| 160 | const uint32_t* vreg = &vregs_[i]; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 161 | return *reinterpret_cast<mirror::Object* const*>(vreg); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 162 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 163 | } |
| 164 | |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 165 | // Get view of vregs as range of consecutive arguments starting at i. |
| 166 | uint32_t* GetVRegArgs(size_t i) { |
| 167 | return &vregs_[i]; |
| 168 | } |
| 169 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 170 | void SetVReg(size_t i, int32_t val) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 171 | DCHECK_LT(i, NumberOfVRegs()); |
| 172 | uint32_t* vreg = &vregs_[i]; |
| 173 | *reinterpret_cast<int32_t*>(vreg) = val; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 174 | } |
| 175 | |
| 176 | void SetVRegFloat(size_t i, float val) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 177 | DCHECK_LT(i, NumberOfVRegs()); |
| 178 | uint32_t* vreg = &vregs_[i]; |
| 179 | *reinterpret_cast<float*>(vreg) = val; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 180 | } |
| 181 | |
| 182 | void SetVRegLong(size_t i, int64_t val) { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 183 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 184 | uint32_t* vreg = &vregs_[i]; |
| 185 | *reinterpret_cast<int64_t*>(vreg) = val; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 186 | } |
| 187 | |
| 188 | void SetVRegDouble(size_t i, double val) { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 189 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 190 | uint32_t* vreg = &vregs_[i]; |
| 191 | *reinterpret_cast<double*>(vreg) = val; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 192 | } |
| 193 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 194 | void SetVRegReference(size_t i, mirror::Object* val) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 195 | DCHECK_LT(i, NumberOfVRegs()); |
| 196 | uint32_t* vreg = &vregs_[i]; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 197 | *reinterpret_cast<mirror::Object**>(vreg) = val; |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 198 | if (HasReferenceArray()) { |
| 199 | References()[i] = val; |
| 200 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 201 | } |
| 202 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 203 | mirror::ArtMethod* GetMethod() const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 204 | DCHECK_NE(method_, static_cast<void*>(NULL)); |
| 205 | return method_; |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 206 | } |
| 207 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 208 | mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 209 | |
Jeff Hao | e701f48 | 2013-05-24 11:50:49 -0700 | [diff] [blame] | 210 | mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 211 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 212 | ThrowLocation GetCurrentLocationForThrow() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 213 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 214 | void SetMethod(mirror::ArtMethod* method) { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 215 | #if defined(ART_USE_PORTABLE_COMPILER) |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 216 | DCHECK_NE(method, static_cast<void*>(NULL)); |
| 217 | method_ = method; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 218 | #else |
| 219 | UNUSED(method); |
| 220 | UNIMPLEMENTED(FATAL) << "Should only be called when portable is enabled"; |
| 221 | #endif |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 222 | } |
| 223 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 224 | bool Contains(mirror::Object** shadow_frame_entry_obj) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 225 | if (HasReferenceArray()) { |
| 226 | return ((&References()[0] <= shadow_frame_entry_obj) && |
| 227 | (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1]))); |
| 228 | } else { |
| 229 | uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj); |
| 230 | return ((&vregs_[0] <= shadow_frame_entry) && |
| 231 | (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1]))); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 232 | } |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 233 | } |
| 234 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 235 | static size_t LinkOffset() { |
| 236 | return OFFSETOF_MEMBER(ShadowFrame, link_); |
| 237 | } |
| 238 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 239 | static size_t MethodOffset() { |
| 240 | return OFFSETOF_MEMBER(ShadowFrame, method_); |
| 241 | } |
| 242 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 243 | static size_t DexPCOffset() { |
| 244 | return OFFSETOF_MEMBER(ShadowFrame, dex_pc_); |
| 245 | } |
| 246 | |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 247 | static size_t NumberOfVRegsOffset() { |
| 248 | return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_); |
| 249 | } |
| 250 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 251 | static size_t VRegsOffset() { |
| 252 | return OFFSETOF_MEMBER(ShadowFrame, vregs_); |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 253 | } |
| 254 | |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 255 | private: |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 256 | ShadowFrame(uint32_t num_vregs, ShadowFrame* link, mirror::ArtMethod* method, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 257 | uint32_t dex_pc, bool has_reference_array) |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 258 | : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) { |
| 259 | if (has_reference_array) { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 260 | #if defined(ART_USE_PORTABLE_COMPILER) |
| 261 | CHECK_LT(num_vregs, static_cast<uint32_t>(kHasReferenceArray)); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 262 | number_of_vregs_ |= kHasReferenceArray; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 263 | #endif |
Jeff Hao | e701f48 | 2013-05-24 11:50:49 -0700 | [diff] [blame] | 264 | memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(mirror::Object*))); |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 265 | } else { |
Jeff Hao | e701f48 | 2013-05-24 11:50:49 -0700 | [diff] [blame] | 266 | memset(vregs_, 0, num_vregs * sizeof(uint32_t)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 267 | } |
| 268 | } |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 269 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 270 | mirror::Object* const* References() const { |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 271 | DCHECK(HasReferenceArray()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 272 | const uint32_t* vreg_end = &vregs_[NumberOfVRegs()]; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 273 | return reinterpret_cast<mirror::Object* const*>(vreg_end); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 274 | } |
| 275 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 276 | mirror::Object** References() { |
| 277 | return const_cast<mirror::Object**>(const_cast<const ShadowFrame*>(this)->References()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 278 | } |
| 279 | |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 280 | #if defined(ART_USE_PORTABLE_COMPILER) |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 281 | enum ShadowFrameFlag { |
| 282 | kHasReferenceArray = 1ul << 31 |
| 283 | }; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 284 | // TODO: make const in the portable case. |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 285 | uint32_t number_of_vregs_; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 286 | #else |
| 287 | const uint32_t number_of_vregs_; |
| 288 | #endif |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 289 | // Link to previous shadow frame or NULL. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 290 | ShadowFrame* link_; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 291 | #if defined(ART_USE_PORTABLE_COMPILER) |
| 292 | // TODO: make const in the portable case. |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 293 | mirror::ArtMethod* method_; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 294 | #else |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 295 | mirror::ArtMethod* const method_; |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 296 | #endif |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 297 | uint32_t dex_pc_; |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 298 | uint32_t vregs_[0]; |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 299 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 300 | DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame); |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 301 | }; |
| 302 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 303 | // The managed stack is used to record fragments of managed code stacks. Managed code stacks |
| 304 | // may either be shadow frames or lists of frames using fixed frame sizes. Transition records are |
| 305 | // necessary for transitions between code using different frame layouts and transitions into native |
| 306 | // code. |
Ian Rogers | df1ce91 | 2012-11-27 17:07:11 -0800 | [diff] [blame] | 307 | class PACKED(4) ManagedStack { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 308 | public: |
Ian Rogers | ca19066 | 2012-06-26 15:45:57 -0700 | [diff] [blame] | 309 | ManagedStack() |
| 310 | : link_(NULL), top_shadow_frame_(NULL), top_quick_frame_(NULL), top_quick_frame_pc_(0) {} |
Ian Rogers | 81d425b | 2012-09-27 16:03:43 -0700 | [diff] [blame] | 311 | |
| 312 | void PushManagedStackFragment(ManagedStack* fragment) { |
| 313 | // Copy this top fragment into given fragment. |
| 314 | memcpy(fragment, this, sizeof(ManagedStack)); |
| 315 | // Clear this fragment, which has become the top. |
| 316 | memset(this, 0, sizeof(ManagedStack)); |
| 317 | // Link our top fragment onto the given fragment. |
| 318 | link_ = fragment; |
| 319 | } |
| 320 | |
| 321 | void PopManagedStackFragment(const ManagedStack& fragment) { |
| 322 | DCHECK(&fragment == link_); |
| 323 | // Copy this given fragment back to the top. |
| 324 | memcpy(this, &fragment, sizeof(ManagedStack)); |
| 325 | } |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 326 | |
| 327 | ManagedStack* GetLink() const { |
| 328 | return link_; |
| 329 | } |
| 330 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 331 | mirror::ArtMethod** GetTopQuickFrame() const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 332 | return top_quick_frame_; |
| 333 | } |
| 334 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 335 | void SetTopQuickFrame(mirror::ArtMethod** top) { |
Sebastien Hertz | a7b0c42 | 2013-04-05 16:19:39 +0200 | [diff] [blame] | 336 | DCHECK(top_shadow_frame_ == NULL); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 337 | top_quick_frame_ = top; |
| 338 | } |
| 339 | |
| 340 | uintptr_t GetTopQuickFramePc() const { |
| 341 | return top_quick_frame_pc_; |
| 342 | } |
| 343 | |
| 344 | void SetTopQuickFramePc(uintptr_t pc) { |
Sebastien Hertz | a7b0c42 | 2013-04-05 16:19:39 +0200 | [diff] [blame] | 345 | DCHECK(top_shadow_frame_ == NULL); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 346 | top_quick_frame_pc_ = pc; |
| 347 | } |
| 348 | |
| 349 | static size_t TopQuickFrameOffset() { |
| 350 | return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_); |
| 351 | } |
| 352 | |
| 353 | static size_t TopQuickFramePcOffset() { |
| 354 | return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_pc_); |
| 355 | } |
| 356 | |
| 357 | ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) { |
Sebastien Hertz | a7b0c42 | 2013-04-05 16:19:39 +0200 | [diff] [blame] | 358 | DCHECK(top_quick_frame_ == NULL); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 359 | ShadowFrame* old_frame = top_shadow_frame_; |
| 360 | top_shadow_frame_ = new_top_frame; |
| 361 | new_top_frame->SetLink(old_frame); |
| 362 | return old_frame; |
| 363 | } |
| 364 | |
| 365 | ShadowFrame* PopShadowFrame() { |
Sebastien Hertz | a7b0c42 | 2013-04-05 16:19:39 +0200 | [diff] [blame] | 366 | DCHECK(top_quick_frame_ == NULL); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 367 | CHECK(top_shadow_frame_ != NULL); |
| 368 | ShadowFrame* frame = top_shadow_frame_; |
| 369 | top_shadow_frame_ = frame->GetLink(); |
| 370 | return frame; |
| 371 | } |
| 372 | |
| 373 | ShadowFrame* GetTopShadowFrame() const { |
| 374 | return top_shadow_frame_; |
| 375 | } |
| 376 | |
Jeff Hao | 11ffc2d | 2013-02-01 11:52:17 -0800 | [diff] [blame] | 377 | void SetTopShadowFrame(ShadowFrame* top) { |
Sebastien Hertz | a7b0c42 | 2013-04-05 16:19:39 +0200 | [diff] [blame] | 378 | DCHECK(top_quick_frame_ == NULL); |
Jeff Hao | 11ffc2d | 2013-02-01 11:52:17 -0800 | [diff] [blame] | 379 | top_shadow_frame_ = top; |
| 380 | } |
| 381 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 382 | static size_t TopShadowFrameOffset() { |
| 383 | return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_); |
| 384 | } |
| 385 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 386 | size_t NumJniShadowFrameReferences() const; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 387 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 388 | bool ShadowFramesContain(mirror::Object** shadow_frame_entry) const; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 389 | |
| 390 | private: |
| 391 | ManagedStack* link_; |
| 392 | ShadowFrame* top_shadow_frame_; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 393 | mirror::ArtMethod** top_quick_frame_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 394 | uintptr_t top_quick_frame_pc_; |
| 395 | }; |
| 396 | |
| 397 | class StackVisitor { |
| 398 | protected: |
Ian Rogers | 7a22fa6 | 2013-01-23 12:16:16 -0800 | [diff] [blame] | 399 | StackVisitor(Thread* thread, Context* context) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 400 | |
| 401 | public: |
| 402 | virtual ~StackVisitor() {} |
| 403 | |
| 404 | // Return 'true' if we should continue to visit more frames, 'false' to stop. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 405 | virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) = 0; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 406 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 407 | void WalkStack(bool include_transitions = false) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 408 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 409 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 410 | mirror::ArtMethod* GetMethod() const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 411 | if (cur_shadow_frame_ != NULL) { |
| 412 | return cur_shadow_frame_->GetMethod(); |
| 413 | } else if (cur_quick_frame_ != NULL) { |
| 414 | return *cur_quick_frame_; |
| 415 | } else { |
| 416 | return NULL; |
| 417 | } |
| 418 | } |
| 419 | |
| 420 | bool IsShadowFrame() const { |
| 421 | return cur_shadow_frame_ != NULL; |
| 422 | } |
| 423 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 424 | uint32_t GetDexPc() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 425 | |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 426 | mirror::Object* GetThisObject() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 427 | |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 428 | size_t GetNativePcOffset() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 429 | |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 430 | uintptr_t* CalleeSaveAddress(int num, size_t frame_size) const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 431 | // Callee saves are held at the top of the frame |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 432 | DCHECK(GetMethod() != NULL); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 433 | byte* save_addr = |
| 434 | reinterpret_cast<byte*>(cur_quick_frame_) + frame_size - ((num + 1) * kPointerSize); |
| 435 | #if defined(__i386__) |
| 436 | save_addr -= kPointerSize; // account for return address |
| 437 | #endif |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 438 | return reinterpret_cast<uintptr_t*>(save_addr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 439 | } |
| 440 | |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 441 | // Returns the height of the stack in the managed stack frames, including transitions. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 442 | size_t GetFrameHeight() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 443 | return GetNumFrames() - cur_depth_ - 1; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 444 | } |
| 445 | |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 446 | // Returns a frame ID for JDWP use, starting from 1. |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 447 | size_t GetFrameId() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 448 | return GetFrameHeight() + 1; |
| 449 | } |
| 450 | |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 451 | size_t GetNumFrames() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 452 | if (num_frames_ == 0) { |
Ian Rogers | 7a22fa6 | 2013-01-23 12:16:16 -0800 | [diff] [blame] | 453 | num_frames_ = ComputeNumFrames(thread_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 454 | } |
| 455 | return num_frames_; |
| 456 | } |
| 457 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 458 | uint32_t GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const |
Ian Rogers | 2bcb4a4 | 2012-11-08 10:39:18 -0800 | [diff] [blame] | 459 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 460 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 461 | void SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 462 | SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 463 | |
| 464 | uintptr_t GetGPR(uint32_t reg) const; |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 465 | void SetGPR(uint32_t reg, uintptr_t value); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 466 | |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame^] | 467 | // This is a fast-path for getting/setting values in a quick frame. |
| 468 | uint32_t* GetVRegAddr(mirror::ArtMethod** cur_quick_frame, const DexFile::CodeItem* code_item, |
Ian Rogers | 2bcb4a4 | 2012-11-08 10:39:18 -0800 | [diff] [blame] | 469 | uint32_t core_spills, uint32_t fp_spills, size_t frame_size, |
| 470 | uint16_t vreg) const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 471 | int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg); |
Ian Rogers | 0ec569a | 2012-07-01 16:43:46 -0700 | [diff] [blame] | 472 | DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame()); |
| 473 | byte* vreg_addr = reinterpret_cast<byte*>(cur_quick_frame) + offset; |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame^] | 474 | return reinterpret_cast<uint32_t*>(vreg_addr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 475 | } |
| 476 | |
| 477 | uintptr_t GetReturnPc() const; |
| 478 | |
| 479 | void SetReturnPc(uintptr_t new_ret_pc); |
| 480 | |
| 481 | /* |
| 482 | * Return sp-relative offset for a Dalvik virtual register, compiler |
| 483 | * spill or Method* in bytes using Method*. |
| 484 | * Note that (reg >= 0) refers to a Dalvik register, (reg == -2) |
| 485 | * denotes Method* and (reg <= -3) denotes a compiler temp. |
| 486 | * |
| 487 | * +------------------------+ |
| 488 | * | IN[ins-1] | {Note: resides in caller's frame} |
| 489 | * | . | |
| 490 | * | IN[0] | |
| 491 | * | caller's Method* | |
| 492 | * +========================+ {Note: start of callee's frame} |
| 493 | * | core callee-save spill | {variable sized} |
| 494 | * +------------------------+ |
| 495 | * | fp callee-save spill | |
| 496 | * +------------------------+ |
| 497 | * | filler word | {For compatibility, if V[locals-1] used as wide |
| 498 | * +------------------------+ |
| 499 | * | V[locals-1] | |
| 500 | * | V[locals-2] | |
| 501 | * | . | |
| 502 | * | . | ... (reg == 2) |
| 503 | * | V[1] | ... (reg == 1) |
| 504 | * | V[0] | ... (reg == 0) <---- "locals_start" |
| 505 | * +------------------------+ |
| 506 | * | Compiler temps | ... (reg == -2) |
| 507 | * | | ... (reg == -3) |
| 508 | * | | ... (reg == -4) |
| 509 | * +------------------------+ |
| 510 | * | stack alignment padding| {0 to (kStackAlignWords-1) of padding} |
| 511 | * +------------------------+ |
| 512 | * | OUT[outs-1] | |
| 513 | * | OUT[outs-2] | |
| 514 | * | . | |
| 515 | * | OUT[0] | |
| 516 | * | curMethod* | ... (reg == -1) <<== sp, 16-byte aligned |
| 517 | * +========================+ |
| 518 | */ |
| 519 | static int GetVRegOffset(const DexFile::CodeItem* code_item, |
Ian Rogers | b23a772 | 2012-10-09 16:54:26 -0700 | [diff] [blame] | 520 | uint32_t core_spills, uint32_t fp_spills, |
| 521 | size_t frame_size, int reg) { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 522 | DCHECK_EQ(frame_size & (kStackAlignment - 1), 0U); |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 523 | int num_spills = __builtin_popcount(core_spills) + __builtin_popcount(fp_spills) + 1; // Filler. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 524 | int num_ins = code_item->ins_size_; |
| 525 | int num_regs = code_item->registers_size_ - num_ins; |
| 526 | int locals_start = frame_size - ((num_spills + num_regs) * sizeof(uint32_t)); |
| 527 | if (reg == -2) { |
| 528 | return 0; // Method* |
| 529 | } else if (reg <= -3) { |
| 530 | return locals_start - ((reg + 1) * sizeof(uint32_t)); // Compiler temp. |
| 531 | } else if (reg < num_regs) { |
| 532 | return locals_start + (reg * sizeof(uint32_t)); // Dalvik local reg. |
| 533 | } else { |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 534 | return frame_size + ((reg - num_regs) * sizeof(uint32_t)) + sizeof(uint32_t); // Dalvik in. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 535 | } |
| 536 | } |
| 537 | |
| 538 | uintptr_t GetCurrentQuickFramePc() const { |
| 539 | return cur_quick_frame_pc_; |
| 540 | } |
| 541 | |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 542 | mirror::ArtMethod** GetCurrentQuickFrame() const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 543 | return cur_quick_frame_; |
| 544 | } |
| 545 | |
| 546 | ShadowFrame* GetCurrentShadowFrame() const { |
| 547 | return cur_shadow_frame_; |
| 548 | } |
| 549 | |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 550 | StackIndirectReferenceTable* GetCurrentSirt() const { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 551 | mirror::ArtMethod** sp = GetCurrentQuickFrame(); |
Brian Carlstrom | 7934ac2 | 2013-07-26 10:54:15 -0700 | [diff] [blame] | 552 | ++sp; // Skip Method*; SIRT comes next; |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 553 | return reinterpret_cast<StackIndirectReferenceTable*>(sp); |
| 554 | } |
| 555 | |
Ian Rogers | 40e3bac | 2012-11-20 00:09:14 -0800 | [diff] [blame] | 556 | std::string DescribeLocation() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
| 557 | |
Ian Rogers | 7a22fa6 | 2013-01-23 12:16:16 -0800 | [diff] [blame] | 558 | static size_t ComputeNumFrames(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 559 | |
Ian Rogers | 7a22fa6 | 2013-01-23 12:16:16 -0800 | [diff] [blame] | 560 | static void DescribeStack(Thread* thread) SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 561 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 562 | private: |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 563 | instrumentation::InstrumentationStackFrame GetInstrumentationStackFrame(uint32_t depth) const; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 564 | |
Ian Rogers | b726dcb | 2012-09-05 08:57:23 -0700 | [diff] [blame] | 565 | void SanityCheckFrame() const SHARED_LOCKS_REQUIRED(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 566 | |
Ian Rogers | 7a22fa6 | 2013-01-23 12:16:16 -0800 | [diff] [blame] | 567 | Thread* const thread_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 568 | ShadowFrame* cur_shadow_frame_; |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 569 | mirror::ArtMethod** cur_quick_frame_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 570 | uintptr_t cur_quick_frame_pc_; |
| 571 | // Lazily computed, number of frames in the stack. |
| 572 | size_t num_frames_; |
| 573 | // Depth of the frame we're currently at. |
| 574 | size_t cur_depth_; |
Brian Carlstrom | 0cd7ec2 | 2013-07-17 23:40:20 -0700 | [diff] [blame] | 575 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 576 | protected: |
| 577 | Context* const context_; |
| 578 | }; |
| 579 | |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 580 | } // namespace art |
| 581 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 582 | #endif // ART_RUNTIME_STACK_H_ |