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 | |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 20 | #include <stdint.h> |
Ian Rogers | 40e3bac | 2012-11-20 00:09:14 -0800 | [diff] [blame] | 21 | #include <string> |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 22 | |
Ian Rogers | d582fa4 | 2014-11-05 23:46:43 -0800 | [diff] [blame] | 23 | #include "arch/instruction_set.h" |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 24 | #include "base/macros.h" |
| 25 | #include "base/mutex.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 26 | #include "dex_file.h" |
Mathieu Chartier | e34fa1d | 2015-01-14 14:55:47 -0800 | [diff] [blame] | 27 | #include "gc_root.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 28 | #include "mirror/object_reference.h" |
Nicolas Geoffray | 524e7ea | 2015-10-16 17:13:34 +0100 | [diff] [blame] | 29 | #include "quick/quick_method_frame_info.h" |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 30 | #include "read_barrier.h" |
Ian Rogers | e63db27 | 2014-07-15 15:36:11 -0700 | [diff] [blame] | 31 | #include "verify_object.h" |
| 32 | |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 33 | namespace art { |
| 34 | |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 35 | namespace mirror { |
Brian Carlstrom | ea46f95 | 2013-07-30 01:26:50 -0700 | [diff] [blame] | 36 | class Object; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 37 | } // namespace mirror |
| 38 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 39 | class ArtMethod; |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 40 | class Context; |
Mathieu Chartier | eb8167a | 2014-05-07 15:43:14 -0700 | [diff] [blame] | 41 | class HandleScope; |
Nicolas Geoffray | 57f6161 | 2015-05-15 13:20:41 +0100 | [diff] [blame] | 42 | class InlineInfo; |
Nicolas Geoffray | 524e7ea | 2015-10-16 17:13:34 +0100 | [diff] [blame] | 43 | class OatQuickMethodHeader; |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 44 | class ScopedObjectAccess; |
Nicolas Geoffray | 57f6161 | 2015-05-15 13:20:41 +0100 | [diff] [blame] | 45 | class ShadowFrame; |
Nicolas Geoffray | 0aa50ce | 2015-03-10 11:03:29 +0000 | [diff] [blame] | 46 | class StackVisitor; |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 47 | class Thread; |
| 48 | |
Ian Rogers | 2bcb4a4 | 2012-11-08 10:39:18 -0800 | [diff] [blame] | 49 | // The kind of vreg being accessed in calls to Set/GetVReg. |
| 50 | enum VRegKind { |
| 51 | kReferenceVReg, |
| 52 | kIntVReg, |
| 53 | kFloatVReg, |
| 54 | kLongLoVReg, |
| 55 | kLongHiVReg, |
| 56 | kDoubleLoVReg, |
| 57 | kDoubleHiVReg, |
| 58 | kConstant, |
| 59 | kImpreciseConstant, |
| 60 | kUndefined, |
| 61 | }; |
Ian Rogers | 6a3c1fc | 2014-10-31 00:33:20 -0700 | [diff] [blame] | 62 | std::ostream& operator<<(std::ostream& os, const VRegKind& rhs); |
Ian Rogers | 2bcb4a4 | 2012-11-08 10:39:18 -0800 | [diff] [blame] | 63 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 64 | // A reference from the shadow stack to a MirrorType object within the Java heap. |
| 65 | template<class MirrorType> |
Mathieu Chartier | bb87e0f | 2015-04-03 11:21:55 -0700 | [diff] [blame] | 66 | class MANAGED StackReference : public mirror::CompressedReference<MirrorType> { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 67 | }; |
| 68 | |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 69 | // Forward declaration. Just calls the destructor. |
| 70 | struct ShadowFrameDeleter; |
| 71 | using ShadowFrameAllocaUniquePtr = std::unique_ptr<ShadowFrame, ShadowFrameDeleter>; |
| 72 | |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 73 | // Counting locks by storing object pointers into a vector. Duplicate entries mark recursive locks. |
| 74 | // The vector will be visited with the ShadowFrame during GC (so all the locked-on objects are |
| 75 | // thread roots). |
| 76 | // Note: implementation is split so that the call sites may be optimized to no-ops in case no |
| 77 | // lock counting is necessary. The actual implementation is in the cc file to avoid |
| 78 | // dependencies. |
| 79 | class LockCountData { |
| 80 | public: |
| 81 | // Add the given object to the list of monitors, that is, objects that have been locked. This |
| 82 | // will not throw (but be skipped if there is an exception pending on entry). |
| 83 | template <bool kLockCounting> |
| 84 | void AddMonitor(Thread* self, mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_) { |
| 85 | DCHECK(self != nullptr); |
| 86 | if (!kLockCounting) { |
| 87 | return; |
| 88 | } |
| 89 | AddMonitorInternal(self, obj); |
| 90 | } |
| 91 | |
| 92 | // Try to remove the given object from the monitor list, indicating an unlock operation. |
| 93 | // This will throw an IllegalMonitorStateException (clearing any already pending exception), in |
| 94 | // case that there wasn't a lock recorded for the object. |
| 95 | template <bool kLockCounting> |
| 96 | void RemoveMonitorOrThrow(Thread* self, |
| 97 | const mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_) { |
| 98 | DCHECK(self != nullptr); |
| 99 | if (!kLockCounting) { |
| 100 | return; |
| 101 | } |
| 102 | RemoveMonitorInternal(self, obj); |
| 103 | } |
| 104 | |
| 105 | // Check whether all acquired monitors have been released. This will potentially throw an |
| 106 | // IllegalMonitorStateException, clearing any already pending exception. Returns true if the |
| 107 | // check shows that everything is OK wrt/ lock counting, false otherwise. |
| 108 | template <bool kLockCounting> |
| 109 | bool CheckAllMonitorsReleasedOrThrow(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_) { |
| 110 | DCHECK(self != nullptr); |
| 111 | if (!kLockCounting) { |
| 112 | return true; |
| 113 | } |
| 114 | return CheckAllMonitorsReleasedInternal(self); |
| 115 | } |
| 116 | |
| 117 | template <typename T, typename... Args> |
| 118 | void VisitMonitors(T visitor, Args&&... args) SHARED_REQUIRES(Locks::mutator_lock_) { |
| 119 | if (monitors_ != nullptr) { |
| 120 | // Visitors may change the Object*. Be careful with the foreach loop. |
| 121 | for (mirror::Object*& obj : *monitors_) { |
| 122 | visitor(/* inout */ &obj, std::forward<Args>(args)...); |
| 123 | } |
| 124 | } |
| 125 | } |
| 126 | |
| 127 | private: |
| 128 | // Internal implementations. |
| 129 | void AddMonitorInternal(Thread* self, mirror::Object* obj) SHARED_REQUIRES(Locks::mutator_lock_); |
| 130 | void RemoveMonitorInternal(Thread* self, const mirror::Object* obj) |
| 131 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 132 | bool CheckAllMonitorsReleasedInternal(Thread* self) SHARED_REQUIRES(Locks::mutator_lock_); |
| 133 | |
| 134 | // Stores references to the locked-on objects. As noted, this should be visited during thread |
| 135 | // marking. |
| 136 | std::unique_ptr<std::vector<mirror::Object*>> monitors_; |
| 137 | }; |
| 138 | |
Elliott Hughes | 956af0f | 2014-12-11 14:34:28 -0800 | [diff] [blame] | 139 | // ShadowFrame has 2 possible layouts: |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 140 | // - interpreter - separate VRegs and reference arrays. References are in the reference array. |
| 141 | // - JNI - just VRegs, but where every VReg holds a reference. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 142 | class ShadowFrame { |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 143 | public: |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 144 | // Compute size of ShadowFrame in bytes assuming it has a reference array. |
Jeff Hao | 6613519 | 2013-05-14 11:02:41 -0700 | [diff] [blame] | 145 | static size_t ComputeSize(uint32_t num_vregs) { |
| 146 | return sizeof(ShadowFrame) + (sizeof(uint32_t) * num_vregs) + |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 147 | (sizeof(StackReference<mirror::Object>) * num_vregs); |
Jeff Hao | 6613519 | 2013-05-14 11:02:41 -0700 | [diff] [blame] | 148 | } |
| 149 | |
| 150 | // Create ShadowFrame in heap for deoptimization. |
Christopher Ferris | 241a958 | 2015-04-27 15:19:41 -0700 | [diff] [blame] | 151 | static ShadowFrame* CreateDeoptimizedFrame(uint32_t num_vregs, ShadowFrame* link, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 152 | ArtMethod* method, uint32_t dex_pc) { |
Jeff Hao | 6613519 | 2013-05-14 11:02:41 -0700 | [diff] [blame] | 153 | uint8_t* memory = new uint8_t[ComputeSize(num_vregs)]; |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 154 | return CreateShadowFrameImpl(num_vregs, link, method, dex_pc, memory); |
Jeff Hao | 6613519 | 2013-05-14 11:02:41 -0700 | [diff] [blame] | 155 | } |
| 156 | |
Christopher Ferris | 241a958 | 2015-04-27 15:19:41 -0700 | [diff] [blame] | 157 | // Delete a ShadowFrame allocated on the heap for deoptimization. |
| 158 | static void DeleteDeoptimizedFrame(ShadowFrame* sf) { |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 159 | sf->~ShadowFrame(); // Explicitly destruct. |
Christopher Ferris | 241a958 | 2015-04-27 15:19:41 -0700 | [diff] [blame] | 160 | uint8_t* memory = reinterpret_cast<uint8_t*>(sf); |
| 161 | delete[] memory; |
| 162 | } |
| 163 | |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 164 | // Create a shadow frame in a fresh alloca. This needs to be in the context of the caller. |
| 165 | // Inlining doesn't work, the compiler will still undo the alloca. So this needs to be a macro. |
| 166 | #define CREATE_SHADOW_FRAME(num_vregs, link, method, dex_pc) ({ \ |
| 167 | size_t frame_size = ShadowFrame::ComputeSize(num_vregs); \ |
| 168 | void* alloca_mem = alloca(frame_size); \ |
| 169 | ShadowFrameAllocaUniquePtr( \ |
| 170 | ShadowFrame::CreateShadowFrameImpl((num_vregs), (link), (method), (dex_pc), \ |
| 171 | (alloca_mem))); \ |
| 172 | }) |
| 173 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 174 | ~ShadowFrame() {} |
| 175 | |
Igor Murashkin | c449e8b | 2015-06-10 15:56:42 -0700 | [diff] [blame] | 176 | // TODO(iam): Clean references array up since they're always there, |
| 177 | // we don't need to do conditionals. |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 178 | bool HasReferenceArray() const { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 179 | return true; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 180 | } |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 181 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 182 | uint32_t NumberOfVRegs() const { |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 183 | return number_of_vregs_; |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 184 | } |
| 185 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 186 | uint32_t GetDexPC() const { |
| 187 | return dex_pc_; |
| 188 | } |
| 189 | |
| 190 | void SetDexPC(uint32_t dex_pc) { |
| 191 | dex_pc_ = dex_pc; |
| 192 | } |
| 193 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 194 | ShadowFrame* GetLink() const { |
| 195 | return link_; |
| 196 | } |
| 197 | |
| 198 | void SetLink(ShadowFrame* frame) { |
| 199 | DCHECK_NE(this, frame); |
| 200 | link_ = frame; |
| 201 | } |
| 202 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 203 | int32_t GetVReg(size_t i) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 204 | DCHECK_LT(i, NumberOfVRegs()); |
| 205 | const uint32_t* vreg = &vregs_[i]; |
| 206 | return *reinterpret_cast<const int32_t*>(vreg); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 207 | } |
| 208 | |
| 209 | float GetVRegFloat(size_t i) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 210 | DCHECK_LT(i, NumberOfVRegs()); |
| 211 | // NOTE: Strict-aliasing? |
| 212 | const uint32_t* vreg = &vregs_[i]; |
| 213 | return *reinterpret_cast<const float*>(vreg); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 214 | } |
| 215 | |
| 216 | int64_t GetVRegLong(size_t i) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 217 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 218 | const uint32_t* vreg = &vregs_[i]; |
Jeff Hao | e47637c | 2013-09-19 15:13:16 -0700 | [diff] [blame] | 219 | // Alignment attribute required for GCC 4.8 |
| 220 | typedef const int64_t unaligned_int64 __attribute__ ((aligned (4))); |
| 221 | return *reinterpret_cast<unaligned_int64*>(vreg); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 222 | } |
| 223 | |
| 224 | double GetVRegDouble(size_t i) const { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 225 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 226 | const uint32_t* vreg = &vregs_[i]; |
Jeff Hao | e47637c | 2013-09-19 15:13:16 -0700 | [diff] [blame] | 227 | // Alignment attribute required for GCC 4.8 |
| 228 | typedef const double unaligned_double __attribute__ ((aligned (4))); |
| 229 | return *reinterpret_cast<unaligned_double*>(vreg); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 230 | } |
| 231 | |
Igor Murashkin | c449e8b | 2015-06-10 15:56:42 -0700 | [diff] [blame] | 232 | // Look up the reference given its virtual register number. |
| 233 | // If this returns non-null then this does not mean the vreg is currently a reference |
| 234 | // on non-moving collectors. Check that the raw reg with GetVReg is equal to this if not certain. |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 235 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 236 | mirror::Object* GetVRegReference(size_t i) const SHARED_REQUIRES(Locks::mutator_lock_) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 237 | DCHECK_LT(i, NumberOfVRegs()); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 238 | mirror::Object* ref; |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 239 | if (HasReferenceArray()) { |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 240 | ref = References()[i].AsMirrorPtr(); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 241 | } else { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 242 | const uint32_t* vreg_ptr = &vregs_[i]; |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 243 | ref = reinterpret_cast<const StackReference<mirror::Object>*>(vreg_ptr)->AsMirrorPtr(); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 244 | } |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 245 | if (kUseReadBarrier) { |
| 246 | ReadBarrier::AssertToSpaceInvariant(ref); |
| 247 | } |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 248 | if (kVerifyFlags & kVerifyReads) { |
| 249 | VerifyObject(ref); |
| 250 | } |
| 251 | return ref; |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 252 | } |
| 253 | |
Jeff Hao | 1674363 | 2013-05-08 10:59:04 -0700 | [diff] [blame] | 254 | // Get view of vregs as range of consecutive arguments starting at i. |
| 255 | uint32_t* GetVRegArgs(size_t i) { |
| 256 | return &vregs_[i]; |
| 257 | } |
| 258 | |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 259 | void SetVReg(size_t i, int32_t val) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 260 | DCHECK_LT(i, NumberOfVRegs()); |
| 261 | uint32_t* vreg = &vregs_[i]; |
| 262 | *reinterpret_cast<int32_t*>(vreg) = val; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 263 | // This is needed for moving collectors since these can update the vreg references if they |
| 264 | // happen to agree with references in the reference array. |
| 265 | if (kMovingCollector && HasReferenceArray()) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 266 | References()[i].Clear(); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 267 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 268 | } |
| 269 | |
| 270 | void SetVRegFloat(size_t i, float val) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 271 | DCHECK_LT(i, NumberOfVRegs()); |
| 272 | uint32_t* vreg = &vregs_[i]; |
| 273 | *reinterpret_cast<float*>(vreg) = val; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 274 | // This is needed for moving collectors since these can update the vreg references if they |
| 275 | // happen to agree with references in the reference array. |
| 276 | if (kMovingCollector && HasReferenceArray()) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 277 | References()[i].Clear(); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 278 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | void SetVRegLong(size_t i, int64_t val) { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 282 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 283 | uint32_t* vreg = &vregs_[i]; |
Jeff Hao | e47637c | 2013-09-19 15:13:16 -0700 | [diff] [blame] | 284 | // Alignment attribute required for GCC 4.8 |
| 285 | typedef int64_t unaligned_int64 __attribute__ ((aligned (4))); |
| 286 | *reinterpret_cast<unaligned_int64*>(vreg) = val; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 287 | // This is needed for moving collectors since these can update the vreg references if they |
| 288 | // happen to agree with references in the reference array. |
| 289 | if (kMovingCollector && HasReferenceArray()) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 290 | References()[i].Clear(); |
| 291 | References()[i + 1].Clear(); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 292 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 293 | } |
| 294 | |
| 295 | void SetVRegDouble(size_t i, double val) { |
Sebastien Hertz | 807a256 | 2013-04-15 09:33:39 +0200 | [diff] [blame] | 296 | DCHECK_LT(i, NumberOfVRegs()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 297 | uint32_t* vreg = &vregs_[i]; |
Jeff Hao | e47637c | 2013-09-19 15:13:16 -0700 | [diff] [blame] | 298 | // Alignment attribute required for GCC 4.8 |
| 299 | typedef double unaligned_double __attribute__ ((aligned (4))); |
| 300 | *reinterpret_cast<unaligned_double*>(vreg) = val; |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 301 | // This is needed for moving collectors since these can update the vreg references if they |
| 302 | // happen to agree with references in the reference array. |
| 303 | if (kMovingCollector && HasReferenceArray()) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 304 | References()[i].Clear(); |
| 305 | References()[i + 1].Clear(); |
Mathieu Chartier | 590fee9 | 2013-09-13 13:46:47 -0700 | [diff] [blame] | 306 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 307 | } |
| 308 | |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 309 | template<VerifyObjectFlags kVerifyFlags = kDefaultVerifyFlags> |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 310 | void SetVRegReference(size_t i, mirror::Object* val) SHARED_REQUIRES(Locks::mutator_lock_) { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 311 | DCHECK_LT(i, NumberOfVRegs()); |
Mathieu Chartier | 4e30541 | 2014-02-19 10:54:44 -0800 | [diff] [blame] | 312 | if (kVerifyFlags & kVerifyWrites) { |
| 313 | VerifyObject(val); |
| 314 | } |
Hiroshi Yamauchi | 2cd334a | 2015-01-09 14:03:35 -0800 | [diff] [blame] | 315 | if (kUseReadBarrier) { |
| 316 | ReadBarrier::AssertToSpaceInvariant(val); |
| 317 | } |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 318 | uint32_t* vreg = &vregs_[i]; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 319 | reinterpret_cast<StackReference<mirror::Object>*>(vreg)->Assign(val); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 320 | if (HasReferenceArray()) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 321 | References()[i].Assign(val); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 322 | } |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 323 | } |
| 324 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 325 | ArtMethod* GetMethod() const SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 326 | DCHECK(method_ != nullptr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 327 | return method_; |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 328 | } |
| 329 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 330 | mirror::Object* GetThisObject() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 331 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 332 | mirror::Object* GetThisObject(uint16_t num_ins) const SHARED_REQUIRES(Locks::mutator_lock_); |
Jeff Hao | e701f48 | 2013-05-24 11:50:49 -0700 | [diff] [blame] | 333 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 334 | bool Contains(StackReference<mirror::Object>* shadow_frame_entry_obj) const { |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 335 | if (HasReferenceArray()) { |
| 336 | return ((&References()[0] <= shadow_frame_entry_obj) && |
| 337 | (shadow_frame_entry_obj <= (&References()[NumberOfVRegs() - 1]))); |
| 338 | } else { |
| 339 | uint32_t* shadow_frame_entry = reinterpret_cast<uint32_t*>(shadow_frame_entry_obj); |
| 340 | return ((&vregs_[0] <= shadow_frame_entry) && |
| 341 | (shadow_frame_entry <= (&vregs_[NumberOfVRegs() - 1]))); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 342 | } |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 343 | } |
| 344 | |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 345 | LockCountData& GetLockCountData() { |
| 346 | return lock_count_data_; |
| 347 | } |
| 348 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 349 | static size_t LinkOffset() { |
| 350 | return OFFSETOF_MEMBER(ShadowFrame, link_); |
| 351 | } |
| 352 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 353 | static size_t MethodOffset() { |
| 354 | return OFFSETOF_MEMBER(ShadowFrame, method_); |
| 355 | } |
| 356 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 357 | static size_t DexPCOffset() { |
| 358 | return OFFSETOF_MEMBER(ShadowFrame, dex_pc_); |
| 359 | } |
| 360 | |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 361 | static size_t NumberOfVRegsOffset() { |
| 362 | return OFFSETOF_MEMBER(ShadowFrame, number_of_vregs_); |
| 363 | } |
| 364 | |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 365 | static size_t VRegsOffset() { |
| 366 | return OFFSETOF_MEMBER(ShadowFrame, vregs_); |
Ian Rogers | 5438ad8 | 2012-10-15 17:22:44 -0700 | [diff] [blame] | 367 | } |
| 368 | |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 369 | // Create ShadowFrame for interpreter using provided memory. |
| 370 | static ShadowFrame* CreateShadowFrameImpl(uint32_t num_vregs, |
| 371 | ShadowFrame* link, |
| 372 | ArtMethod* method, |
| 373 | uint32_t dex_pc, |
| 374 | void* memory) { |
| 375 | return new (memory) ShadowFrame(num_vregs, link, method, dex_pc, true); |
| 376 | } |
| 377 | |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 378 | private: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 379 | ShadowFrame(uint32_t num_vregs, ShadowFrame* link, ArtMethod* method, |
Ian Rogers | 2dd0e2c | 2013-01-24 12:42:14 -0800 | [diff] [blame] | 380 | uint32_t dex_pc, bool has_reference_array) |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 381 | : number_of_vregs_(num_vregs), link_(link), method_(method), dex_pc_(dex_pc) { |
Igor Murashkin | c449e8b | 2015-06-10 15:56:42 -0700 | [diff] [blame] | 382 | // TODO(iam): Remove this parameter, it's an an artifact of portable removal |
| 383 | DCHECK(has_reference_array); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 384 | if (has_reference_array) { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 385 | memset(vregs_, 0, num_vregs * (sizeof(uint32_t) + sizeof(StackReference<mirror::Object>))); |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 386 | } else { |
Jeff Hao | e701f48 | 2013-05-24 11:50:49 -0700 | [diff] [blame] | 387 | memset(vregs_, 0, num_vregs * sizeof(uint32_t)); |
Ian Rogers | 2fa6b2e | 2012-10-17 00:10:17 -0700 | [diff] [blame] | 388 | } |
| 389 | } |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 390 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 391 | const StackReference<mirror::Object>* References() const { |
Mathieu Chartier | 6702243 | 2012-11-29 18:04:50 -0800 | [diff] [blame] | 392 | DCHECK(HasReferenceArray()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 393 | const uint32_t* vreg_end = &vregs_[NumberOfVRegs()]; |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 394 | return reinterpret_cast<const StackReference<mirror::Object>*>(vreg_end); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 395 | } |
| 396 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 397 | StackReference<mirror::Object>* References() { |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 398 | return const_cast<StackReference<mirror::Object>*>( |
| 399 | const_cast<const ShadowFrame*>(this)->References()); |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 400 | } |
| 401 | |
Ian Rogers | 8a01a3a | 2013-05-06 13:25:44 -0700 | [diff] [blame] | 402 | const uint32_t number_of_vregs_; |
Mathieu Chartier | 2cebb24 | 2015-04-21 16:50:40 -0700 | [diff] [blame] | 403 | // Link to previous shadow frame or null. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 404 | ShadowFrame* link_; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 405 | ArtMethod* method_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 406 | uint32_t dex_pc_; |
Andreas Gampe | 03ec930 | 2015-08-27 17:41:47 -0700 | [diff] [blame] | 407 | LockCountData lock_count_data_; // This may contain GC roots when lock counting is active. |
Igor Murashkin | c449e8b | 2015-06-10 15:56:42 -0700 | [diff] [blame] | 408 | |
| 409 | // This is a two-part array: |
| 410 | // - [0..number_of_vregs) holds the raw virtual registers, and each element here is always 4 |
| 411 | // bytes. |
| 412 | // - [number_of_vregs..number_of_vregs*2) holds only reference registers. Each element here is |
| 413 | // ptr-sized. |
| 414 | // In other words when a primitive is stored in vX, the second (reference) part of the array will |
| 415 | // be null. When a reference is stored in vX, the second (reference) part of the array will be a |
| 416 | // copy of vX. |
TDYa127 | ce4cc0d | 2012-11-18 16:59:53 -0800 | [diff] [blame] | 417 | uint32_t vregs_[0]; |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 418 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 419 | DISALLOW_IMPLICIT_CONSTRUCTORS(ShadowFrame); |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 420 | }; |
| 421 | |
Andreas Gampe | b302592 | 2015-09-01 14:45:00 -0700 | [diff] [blame] | 422 | struct ShadowFrameDeleter { |
| 423 | inline void operator()(ShadowFrame* frame) { |
| 424 | if (frame != nullptr) { |
| 425 | frame->~ShadowFrame(); |
| 426 | } |
| 427 | } |
| 428 | }; |
| 429 | |
Mathieu Chartier | e34fa1d | 2015-01-14 14:55:47 -0800 | [diff] [blame] | 430 | class JavaFrameRootInfo : public RootInfo { |
| 431 | public: |
| 432 | JavaFrameRootInfo(uint32_t thread_id, const StackVisitor* stack_visitor, size_t vreg) |
| 433 | : RootInfo(kRootJavaFrame, thread_id), stack_visitor_(stack_visitor), vreg_(vreg) { |
| 434 | } |
| 435 | virtual void Describe(std::ostream& os) const OVERRIDE |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 436 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e34fa1d | 2015-01-14 14:55:47 -0800 | [diff] [blame] | 437 | |
| 438 | private: |
| 439 | const StackVisitor* const stack_visitor_; |
| 440 | const size_t vreg_; |
| 441 | }; |
| 442 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 443 | // The managed stack is used to record fragments of managed code stacks. Managed code stacks |
| 444 | // may either be shadow frames or lists of frames using fixed frame sizes. Transition records are |
| 445 | // necessary for transitions between code using different frame layouts and transitions into native |
| 446 | // code. |
Ian Rogers | df1ce91 | 2012-11-27 17:07:11 -0800 | [diff] [blame] | 447 | class PACKED(4) ManagedStack { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 448 | public: |
Ian Rogers | ca19066 | 2012-06-26 15:45:57 -0700 | [diff] [blame] | 449 | ManagedStack() |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 450 | : top_quick_frame_(nullptr), link_(nullptr), top_shadow_frame_(nullptr) {} |
Ian Rogers | 81d425b | 2012-09-27 16:03:43 -0700 | [diff] [blame] | 451 | |
| 452 | void PushManagedStackFragment(ManagedStack* fragment) { |
| 453 | // Copy this top fragment into given fragment. |
| 454 | memcpy(fragment, this, sizeof(ManagedStack)); |
| 455 | // Clear this fragment, which has become the top. |
| 456 | memset(this, 0, sizeof(ManagedStack)); |
| 457 | // Link our top fragment onto the given fragment. |
| 458 | link_ = fragment; |
| 459 | } |
| 460 | |
| 461 | void PopManagedStackFragment(const ManagedStack& fragment) { |
| 462 | DCHECK(&fragment == link_); |
| 463 | // Copy this given fragment back to the top. |
| 464 | memcpy(this, &fragment, sizeof(ManagedStack)); |
| 465 | } |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 466 | |
| 467 | ManagedStack* GetLink() const { |
| 468 | return link_; |
| 469 | } |
| 470 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 471 | ArtMethod** GetTopQuickFrame() const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 472 | return top_quick_frame_; |
| 473 | } |
| 474 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 475 | void SetTopQuickFrame(ArtMethod** top) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 476 | DCHECK(top_shadow_frame_ == nullptr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 477 | top_quick_frame_ = top; |
| 478 | } |
| 479 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 480 | static size_t TopQuickFrameOffset() { |
| 481 | return OFFSETOF_MEMBER(ManagedStack, top_quick_frame_); |
| 482 | } |
| 483 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 484 | ShadowFrame* PushShadowFrame(ShadowFrame* new_top_frame) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 485 | DCHECK(top_quick_frame_ == nullptr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 486 | ShadowFrame* old_frame = top_shadow_frame_; |
| 487 | top_shadow_frame_ = new_top_frame; |
| 488 | new_top_frame->SetLink(old_frame); |
| 489 | return old_frame; |
| 490 | } |
| 491 | |
| 492 | ShadowFrame* PopShadowFrame() { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 493 | DCHECK(top_quick_frame_ == nullptr); |
| 494 | CHECK(top_shadow_frame_ != nullptr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 495 | ShadowFrame* frame = top_shadow_frame_; |
| 496 | top_shadow_frame_ = frame->GetLink(); |
| 497 | return frame; |
| 498 | } |
| 499 | |
| 500 | ShadowFrame* GetTopShadowFrame() const { |
| 501 | return top_shadow_frame_; |
| 502 | } |
| 503 | |
Jeff Hao | 11ffc2d | 2013-02-01 11:52:17 -0800 | [diff] [blame] | 504 | void SetTopShadowFrame(ShadowFrame* top) { |
Ian Rogers | 1d8cdbc | 2014-09-22 22:51:09 -0700 | [diff] [blame] | 505 | DCHECK(top_quick_frame_ == nullptr); |
Jeff Hao | 11ffc2d | 2013-02-01 11:52:17 -0800 | [diff] [blame] | 506 | top_shadow_frame_ = top; |
| 507 | } |
| 508 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 509 | static size_t TopShadowFrameOffset() { |
| 510 | return OFFSETOF_MEMBER(ManagedStack, top_shadow_frame_); |
| 511 | } |
| 512 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 513 | size_t NumJniShadowFrameReferences() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 514 | |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 515 | bool ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 516 | |
| 517 | private: |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 518 | ArtMethod** top_quick_frame_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 519 | ManagedStack* link_; |
| 520 | ShadowFrame* top_shadow_frame_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 521 | }; |
| 522 | |
| 523 | class StackVisitor { |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 524 | public: |
| 525 | // This enum defines a flag to control whether inlined frames are included |
| 526 | // when walking the stack. |
| 527 | enum class StackWalkKind { |
| 528 | kIncludeInlinedFrames, |
| 529 | kSkipInlinedFrames, |
| 530 | }; |
| 531 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 532 | protected: |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 533 | StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 534 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 535 | |
Nicolas Geoffray | 3385650 | 2015-10-20 15:52:58 +0100 | [diff] [blame^] | 536 | bool GetRegisterIfAccessible(uint32_t reg, VRegKind kind, uint32_t* val) const |
| 537 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 538 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 539 | public: |
| 540 | virtual ~StackVisitor() {} |
| 541 | |
| 542 | // Return 'true' if we should continue to visit more frames, 'false' to stop. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 543 | virtual bool VisitFrame() SHARED_REQUIRES(Locks::mutator_lock_) = 0; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 544 | |
Ian Rogers | 00f7d0e | 2012-07-19 15:28:27 -0700 | [diff] [blame] | 545 | void WalkStack(bool include_transitions = false) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 546 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 547 | |
Sebastien Hertz | 26f7286 | 2015-09-15 09:52:07 +0200 | [diff] [blame] | 548 | Thread* GetThread() const { |
| 549 | return thread_; |
| 550 | } |
| 551 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 552 | ArtMethod* GetMethod() const SHARED_REQUIRES(Locks::mutator_lock_); |
Hiroshi Yamauchi | 92d1a66 | 2014-05-15 21:43:59 -0700 | [diff] [blame] | 553 | |
Nicolas Geoffray | ccc6197 | 2015-10-01 14:34:20 +0100 | [diff] [blame] | 554 | ArtMethod* GetOuterMethod() const { |
| 555 | return *GetCurrentQuickFrame(); |
| 556 | } |
| 557 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 558 | bool IsShadowFrame() const { |
Ian Rogers | ef7d42f | 2014-01-06 12:55:46 -0800 | [diff] [blame] | 559 | return cur_shadow_frame_ != nullptr; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 560 | } |
| 561 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 562 | uint32_t GetDexPc(bool abort_on_failure = true) const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 563 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 564 | mirror::Object* GetThisObject() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 565 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 566 | size_t GetNativePcOffset() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0c7abda | 2012-09-19 13:33:42 -0700 | [diff] [blame] | 567 | |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 568 | // Returns the height of the stack in the managed stack frames, including transitions. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 569 | size_t GetFrameHeight() SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | 62d6c77 | 2013-02-27 08:32:07 -0800 | [diff] [blame] | 570 | return GetNumFrames() - cur_depth_ - 1; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 571 | } |
| 572 | |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 573 | // Returns a frame ID for JDWP use, starting from 1. |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 574 | size_t GetFrameId() SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 575 | return GetFrameHeight() + 1; |
| 576 | } |
| 577 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 578 | size_t GetNumFrames() SHARED_REQUIRES(Locks::mutator_lock_) { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 579 | if (num_frames_ == 0) { |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 580 | num_frames_ = ComputeNumFrames(thread_, walk_kind_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 581 | } |
| 582 | return num_frames_; |
| 583 | } |
| 584 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 585 | size_t GetFrameDepth() SHARED_REQUIRES(Locks::mutator_lock_) { |
Hiroshi Yamauchi | 649278c | 2014-08-13 11:12:22 -0700 | [diff] [blame] | 586 | return cur_depth_; |
| 587 | } |
| 588 | |
Ian Rogers | 5cf9819 | 2014-05-29 21:31:50 -0700 | [diff] [blame] | 589 | // Get the method and dex pc immediately after the one that's currently being visited. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 590 | bool GetNextMethodAndDexPc(ArtMethod** next_method, uint32_t* next_dex_pc) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 591 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 5cf9819 | 2014-05-29 21:31:50 -0700 | [diff] [blame] | 592 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 593 | bool IsReferenceVReg(ArtMethod* m, uint16_t vreg) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 594 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | 50030ef | 2015-05-08 14:19:26 -0700 | [diff] [blame] | 595 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 596 | bool GetVReg(ArtMethod* m, uint16_t vreg, VRegKind kind, uint32_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 597 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 598 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 599 | bool GetVRegPair(ArtMethod* m, uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi, |
Sebastien Hertz | c901dd7 | 2014-07-16 11:56:07 +0200 | [diff] [blame] | 600 | uint64_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 601 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | c901dd7 | 2014-07-16 11:56:07 +0200 | [diff] [blame] | 602 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 603 | bool SetVReg(ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 604 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 605 | |
Mingyao Yang | 99170c6 | 2015-07-06 11:10:37 -0700 | [diff] [blame] | 606 | // Values will be set in debugger shadow frames. Debugger will make sure deoptimization |
| 607 | // is triggered to make the values effective. |
| 608 | bool SetVRegFromDebugger(ArtMethod* m, uint16_t vreg, uint32_t new_value, VRegKind kind) |
| 609 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 610 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 611 | bool SetVRegPair(ArtMethod* m, uint16_t vreg, uint64_t new_value, |
Sebastien Hertz | c901dd7 | 2014-07-16 11:56:07 +0200 | [diff] [blame] | 612 | VRegKind kind_lo, VRegKind kind_hi) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 613 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | c901dd7 | 2014-07-16 11:56:07 +0200 | [diff] [blame] | 614 | |
Mingyao Yang | 99170c6 | 2015-07-06 11:10:37 -0700 | [diff] [blame] | 615 | // Values will be set in debugger shadow frames. Debugger will make sure deoptimization |
| 616 | // is triggered to make the values effective. |
| 617 | bool SetVRegPairFromDebugger(ArtMethod* m, uint16_t vreg, uint64_t new_value, |
| 618 | VRegKind kind_lo, VRegKind kind_hi) |
| 619 | SHARED_REQUIRES(Locks::mutator_lock_); |
| 620 | |
Mathieu Chartier | 815873e | 2014-02-13 18:02:13 -0800 | [diff] [blame] | 621 | uintptr_t* GetGPRAddress(uint32_t reg) const; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 622 | |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame] | 623 | // This is a fast-path for getting/setting values in a quick frame. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 624 | uint32_t* GetVRegAddrFromQuickCode(ArtMethod** cur_quick_frame, |
Nicolas Geoffray | 15b9d52 | 2015-03-12 15:05:13 +0000 | [diff] [blame] | 625 | const DexFile::CodeItem* code_item, |
| 626 | uint32_t core_spills, uint32_t fp_spills, size_t frame_size, |
| 627 | uint16_t vreg) const { |
| 628 | int offset = GetVRegOffsetFromQuickCode( |
| 629 | code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA); |
Ian Rogers | 0ec569a | 2012-07-01 16:43:46 -0700 | [diff] [blame] | 630 | DCHECK_EQ(cur_quick_frame, GetCurrentQuickFrame()); |
Ian Rogers | 1373595 | 2014-10-08 12:43:28 -0700 | [diff] [blame] | 631 | uint8_t* vreg_addr = reinterpret_cast<uint8_t*>(cur_quick_frame) + offset; |
Mathieu Chartier | 423d2a3 | 2013-09-12 17:33:56 -0700 | [diff] [blame] | 632 | return reinterpret_cast<uint32_t*>(vreg_addr); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 633 | } |
| 634 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 635 | uintptr_t GetReturnPc() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 636 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 637 | void SetReturnPc(uintptr_t new_ret_pc) SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 638 | |
| 639 | /* |
| 640 | * Return sp-relative offset for a Dalvik virtual register, compiler |
| 641 | * spill or Method* in bytes using Method*. |
Razvan A Lupusoru | 8d0d03e | 2014-06-06 17:04:52 -0700 | [diff] [blame] | 642 | * Note that (reg == -1) denotes an invalid Dalvik register. For the |
| 643 | * positive values, the Dalvik registers come first, followed by the |
| 644 | * Method*, followed by other special temporaries if any, followed by |
| 645 | * regular compiler temporary. As of now we only have the Method* as |
| 646 | * as a special compiler temporary. |
| 647 | * A compiler temporary can be thought of as a virtual register that |
| 648 | * does not exist in the dex but holds intermediate values to help |
| 649 | * optimizations and code generation. A special compiler temporary is |
| 650 | * one whose location in frame is well known while non-special ones |
| 651 | * do not have a requirement on location in frame as long as code |
| 652 | * generator itself knows how to access them. |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 653 | * |
Razvan A Lupusoru | 8d0d03e | 2014-06-06 17:04:52 -0700 | [diff] [blame] | 654 | * +-------------------------------+ |
| 655 | * | IN[ins-1] | {Note: resides in caller's frame} |
| 656 | * | . | |
| 657 | * | IN[0] | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 658 | * | caller's ArtMethod | ... ArtMethod* |
Razvan A Lupusoru | 8d0d03e | 2014-06-06 17:04:52 -0700 | [diff] [blame] | 659 | * +===============================+ {Note: start of callee's frame} |
| 660 | * | core callee-save spill | {variable sized} |
| 661 | * +-------------------------------+ |
| 662 | * | fp callee-save spill | |
| 663 | * +-------------------------------+ |
| 664 | * | filler word | {For compatibility, if V[locals-1] used as wide |
| 665 | * +-------------------------------+ |
| 666 | * | V[locals-1] | |
| 667 | * | V[locals-2] | |
| 668 | * | . | |
| 669 | * | . | ... (reg == 2) |
| 670 | * | V[1] | ... (reg == 1) |
| 671 | * | V[0] | ... (reg == 0) <---- "locals_start" |
| 672 | * +-------------------------------+ |
| 673 | * | stack alignment padding | {0 to (kStackAlignWords-1) of padding} |
| 674 | * +-------------------------------+ |
| 675 | * | Compiler temp region | ... (reg >= max_num_special_temps) |
| 676 | * | . | |
| 677 | * | . | |
Brian Carlstrom | 2cbaccb | 2014-09-14 20:34:17 -0700 | [diff] [blame] | 678 | * | V[max_num_special_temps + 1] | |
| 679 | * | V[max_num_special_temps + 0] | |
Razvan A Lupusoru | 8d0d03e | 2014-06-06 17:04:52 -0700 | [diff] [blame] | 680 | * +-------------------------------+ |
| 681 | * | OUT[outs-1] | |
| 682 | * | OUT[outs-2] | |
| 683 | * | . | |
| 684 | * | OUT[0] | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 685 | * | ArtMethod* | ... (reg == num_total_code_regs == special_temp_value) <<== sp, 16-byte aligned |
Razvan A Lupusoru | 8d0d03e | 2014-06-06 17:04:52 -0700 | [diff] [blame] | 686 | * +===============================+ |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 687 | */ |
Nicolas Geoffray | 15b9d52 | 2015-03-12 15:05:13 +0000 | [diff] [blame] | 688 | static int GetVRegOffsetFromQuickCode(const DexFile::CodeItem* code_item, |
| 689 | uint32_t core_spills, uint32_t fp_spills, |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 690 | size_t frame_size, int reg, InstructionSet isa); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 691 | |
Nicolas Geoffray | 42fcd98 | 2014-04-22 11:03:52 +0000 | [diff] [blame] | 692 | static int GetOutVROffset(uint16_t out_num, InstructionSet isa) { |
buzbee | 8281864 | 2014-06-04 15:35:41 -0700 | [diff] [blame] | 693 | // According to stack model, the first out is above the Method referernce. |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 694 | return InstructionSetPointerSize(isa) + out_num * sizeof(uint32_t); |
Razvan A Lupusoru | 3bc0174 | 2014-02-06 13:18:43 -0800 | [diff] [blame] | 695 | } |
| 696 | |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 697 | bool IsInInlinedFrame() const { |
Nicolas Geoffray | 57f6161 | 2015-05-15 13:20:41 +0100 | [diff] [blame] | 698 | return current_inlining_depth_ != 0; |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 699 | } |
| 700 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 701 | uintptr_t GetCurrentQuickFramePc() const { |
| 702 | return cur_quick_frame_pc_; |
| 703 | } |
| 704 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 705 | ArtMethod** GetCurrentQuickFrame() const { |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 706 | return cur_quick_frame_; |
| 707 | } |
| 708 | |
| 709 | ShadowFrame* GetCurrentShadowFrame() const { |
| 710 | return cur_shadow_frame_; |
| 711 | } |
| 712 | |
Nicolas Geoffray | 6bc4374 | 2015-10-12 18:11:10 +0100 | [diff] [blame] | 713 | bool IsCurrentFrameInInterpreter() const { |
| 714 | return cur_shadow_frame_ != nullptr; |
| 715 | } |
| 716 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 717 | HandleScope* GetCurrentHandleScope(size_t pointer_size) const { |
| 718 | ArtMethod** sp = GetCurrentQuickFrame(); |
| 719 | // Skip ArtMethod*; handle scope comes next; |
| 720 | return reinterpret_cast<HandleScope*>(reinterpret_cast<uintptr_t>(sp) + pointer_size); |
Elliott Hughes | 08fc03a | 2012-06-26 17:34:00 -0700 | [diff] [blame] | 721 | } |
| 722 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 723 | std::string DescribeLocation() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 40e3bac | 2012-11-20 00:09:14 -0800 | [diff] [blame] | 724 | |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 725 | static size_t ComputeNumFrames(Thread* thread, StackWalkKind walk_kind) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 726 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 727 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 728 | static void DescribeStack(Thread* thread) SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 306057f | 2012-11-26 12:45:53 -0800 | [diff] [blame] | 729 | |
Nicolas Geoffray | 524e7ea | 2015-10-16 17:13:34 +0100 | [diff] [blame] | 730 | const OatQuickMethodHeader* GetCurrentOatQuickMethodHeader() const { |
| 731 | return cur_oat_quick_method_header_; |
| 732 | } |
| 733 | |
| 734 | QuickMethodFrameInfo GetCurrentQuickFrameInfo() const SHARED_REQUIRES(Locks::mutator_lock_); |
Nicolas Geoffray | 6bc4374 | 2015-10-12 18:11:10 +0100 | [diff] [blame] | 735 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 736 | private: |
Ian Rogers | 5cf9819 | 2014-05-29 21:31:50 -0700 | [diff] [blame] | 737 | // Private constructor known in the case that num_frames_ has already been computed. |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 738 | StackVisitor(Thread* thread, Context* context, StackWalkKind walk_kind, size_t num_frames) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 739 | SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 5cf9819 | 2014-05-29 21:31:50 -0700 | [diff] [blame] | 740 | |
Sebastien Hertz | 96ba8dc | 2015-01-22 18:57:14 +0100 | [diff] [blame] | 741 | bool IsAccessibleRegister(uint32_t reg, bool is_float) const { |
| 742 | return is_float ? IsAccessibleFPR(reg) : IsAccessibleGPR(reg); |
| 743 | } |
| 744 | uintptr_t GetRegister(uint32_t reg, bool is_float) const { |
| 745 | DCHECK(IsAccessibleRegister(reg, is_float)); |
| 746 | return is_float ? GetFPR(reg) : GetGPR(reg); |
| 747 | } |
| 748 | void SetRegister(uint32_t reg, uintptr_t value, bool is_float) { |
| 749 | DCHECK(IsAccessibleRegister(reg, is_float)); |
| 750 | if (is_float) { |
| 751 | SetFPR(reg, value); |
| 752 | } else { |
| 753 | SetGPR(reg, value); |
| 754 | } |
| 755 | } |
| 756 | |
| 757 | bool IsAccessibleGPR(uint32_t reg) const; |
| 758 | uintptr_t GetGPR(uint32_t reg) const; |
| 759 | void SetGPR(uint32_t reg, uintptr_t value); |
| 760 | |
| 761 | bool IsAccessibleFPR(uint32_t reg) const; |
| 762 | uintptr_t GetFPR(uint32_t reg) const; |
| 763 | void SetFPR(uint32_t reg, uintptr_t value); |
Sebastien Hertz | 0bcb290 | 2014-06-17 15:52:45 +0200 | [diff] [blame] | 764 | |
Mingyao Yang | 99170c6 | 2015-07-06 11:10:37 -0700 | [diff] [blame] | 765 | bool GetVRegFromDebuggerShadowFrame(uint16_t vreg, VRegKind kind, uint32_t* val) const |
| 766 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 767 | bool GetVRegFromQuickCode(ArtMethod* m, uint16_t vreg, VRegKind kind, |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 768 | uint32_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 769 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 770 | bool GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKind kind, |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 771 | uint32_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 772 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 773 | |
Mingyao Yang | 99170c6 | 2015-07-06 11:10:37 -0700 | [diff] [blame] | 774 | bool GetVRegPairFromDebuggerShadowFrame(uint16_t vreg, VRegKind kind_lo, VRegKind kind_hi, |
| 775 | uint64_t* val) const |
| 776 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 777 | bool GetVRegPairFromQuickCode(ArtMethod* m, uint16_t vreg, VRegKind kind_lo, |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 778 | VRegKind kind_hi, uint64_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 779 | SHARED_REQUIRES(Locks::mutator_lock_); |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 780 | bool GetVRegPairFromOptimizedCode(ArtMethod* m, uint16_t vreg, |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 781 | VRegKind kind_lo, VRegKind kind_hi, |
| 782 | uint64_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 783 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 784 | bool GetRegisterPairIfAccessible(uint32_t reg_lo, uint32_t reg_hi, VRegKind kind_lo, |
| 785 | uint64_t* val) const |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 786 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 787 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 788 | bool SetVRegFromQuickCode(ArtMethod* m, uint16_t vreg, uint32_t new_value, |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 789 | VRegKind kind) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 790 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 791 | bool SetRegisterIfAccessible(uint32_t reg, uint32_t new_value, VRegKind kind) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 792 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 793 | |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 794 | bool SetVRegPairFromQuickCode(ArtMethod* m, uint16_t vreg, uint64_t new_value, |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 795 | VRegKind kind_lo, VRegKind kind_hi) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 796 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 797 | bool SetRegisterPairIfAccessible(uint32_t reg_lo, uint32_t reg_hi, uint64_t new_value, |
| 798 | bool is_float) |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 799 | SHARED_REQUIRES(Locks::mutator_lock_); |
Sebastien Hertz | 7cde48c | 2015-01-20 16:06:43 +0100 | [diff] [blame] | 800 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 801 | void SanityCheckFrame() const SHARED_REQUIRES(Locks::mutator_lock_); |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 802 | |
Mathieu Chartier | 9044347 | 2015-07-16 20:32:27 -0700 | [diff] [blame] | 803 | InlineInfo GetCurrentInlineInfo() const SHARED_REQUIRES(Locks::mutator_lock_); |
Nicolas Geoffray | 57f6161 | 2015-05-15 13:20:41 +0100 | [diff] [blame] | 804 | |
Ian Rogers | 7a22fa6 | 2013-01-23 12:16:16 -0800 | [diff] [blame] | 805 | Thread* const thread_; |
Nicolas Geoffray | 8e5bd18 | 2015-05-06 11:34:34 +0100 | [diff] [blame] | 806 | const StackWalkKind walk_kind_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 807 | ShadowFrame* cur_shadow_frame_; |
Mathieu Chartier | e401d14 | 2015-04-22 13:56:20 -0700 | [diff] [blame] | 808 | ArtMethod** cur_quick_frame_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 809 | uintptr_t cur_quick_frame_pc_; |
Nicolas Geoffray | 524e7ea | 2015-10-16 17:13:34 +0100 | [diff] [blame] | 810 | const OatQuickMethodHeader* cur_oat_quick_method_header_; |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 811 | // Lazily computed, number of frames in the stack. |
| 812 | size_t num_frames_; |
| 813 | // Depth of the frame we're currently at. |
| 814 | size_t cur_depth_; |
Nicolas Geoffray | 57f6161 | 2015-05-15 13:20:41 +0100 | [diff] [blame] | 815 | // Current inlining depth of the method we are currently at. |
| 816 | // 0 if there is no inlined frame. |
| 817 | size_t current_inlining_depth_; |
Brian Carlstrom | 0cd7ec2 | 2013-07-17 23:40:20 -0700 | [diff] [blame] | 818 | |
Ian Rogers | 0399dde | 2012-06-06 17:09:28 -0700 | [diff] [blame] | 819 | protected: |
| 820 | Context* const context_; |
| 821 | }; |
| 822 | |
Elliott Hughes | 68e7652 | 2011-10-05 13:22:16 -0700 | [diff] [blame] | 823 | } // namespace art |
| 824 | |
Brian Carlstrom | fc0e321 | 2013-07-17 14:40:12 -0700 | [diff] [blame] | 825 | #endif // ART_RUNTIME_STACK_H_ |