stack.cc revision 42fcd9838a87abaf7a2ef86853a5287f86dbe391
168e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes/* 268e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * Copyright (C) 2011 The Android Open Source Project 368e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * 468e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * Licensed under the Apache License, Version 2.0 (the "License"); 568e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * you may not use this file except in compliance with the License. 668e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * You may obtain a copy of the License at 768e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * 868e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * http://www.apache.org/licenses/LICENSE-2.0 968e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * 1068e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * Unless required by applicable law or agreed to in writing, software 1168e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * distributed under the License is distributed on an "AS IS" BASIS, 1268e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 1368e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * See the License for the specific language governing permissions and 1468e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes * limitations under the License. 1568e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes */ 1668e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes 1768e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes#include "stack.h" 1868e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes 19f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison#include "base/hex_dump.h" 20ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom#include "mirror/art_method-inl.h" 214f6ad8ab428038129b2d0d6c40b7fd625cca15e1Ian Rogers#include "mirror/class-inl.h" 222dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "mirror/object.h" 232dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "mirror/object-inl.h" 242dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers#include "mirror/object_array-inl.h" 256d4d9fcb4f01e287ee29e81cd1c941ee5d11d379Ian Rogers#include "object_utils.h" 26590fee9e8972f872301c2d16a575d579ee564beeMathieu Chartier#include "runtime.h" 27f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison#include "thread.h" 28bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes#include "thread_list.h" 2962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers#include "throw_location.h" 304e30541a92381fb280cd0be9a1763b713ee4d64cMathieu Chartier#include "verify_object-inl.h" 311809a72a66d245ae598582d658b93a24ac3bf01eIan Rogers#include "vmap_table.h" 3268e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes 3311d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughesnamespace art { 3411d1b0c31ddd710d26068da8e0e4621002205b4bElliott Hughes 35f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison// Define a piece of memory, the address of which can be used as a marker 36f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison// for the gap in the stack added during stack overflow handling. 37f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allisonstatic uint32_t stack_overflow_object; 38f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 39f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison// The stack overflow gap marker is simply a valid unique address. 40f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allisonvoid* stack_overflow_gap_marker = &stack_overflow_object; 41f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 42f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 4362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersmirror::Object* ShadowFrame::GetThisObject() const { 44ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* m = GetMethod(); 4562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (m->IsStatic()) { 4662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return NULL; 4762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } else if (m->IsNative()) { 4862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return GetVRegReference(0); 4962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } else { 5062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers const DexFile::CodeItem* code_item = MethodHelper(m).GetCodeItem(); 5162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers CHECK(code_item != NULL) << PrettyMethod(m); 5262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers uint16_t reg = code_item->registers_size_ - code_item->ins_size_; 5362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return GetVRegReference(reg); 5462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 5562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers} 5662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 57e701f48eb06fa59871412a11286429111270b211Jeff Haomirror::Object* ShadowFrame::GetThisObject(uint16_t num_ins) const { 58ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* m = GetMethod(); 59e701f48eb06fa59871412a11286429111270b211Jeff Hao if (m->IsStatic()) { 60e701f48eb06fa59871412a11286429111270b211Jeff Hao return NULL; 61e701f48eb06fa59871412a11286429111270b211Jeff Hao } else { 628d44885106503f68e5b977c080df8ae6cc360497Jeff Hao return GetVRegReference(NumberOfVRegs() - num_ins); 63e701f48eb06fa59871412a11286429111270b211Jeff Hao } 64e701f48eb06fa59871412a11286429111270b211Jeff Hao} 65e701f48eb06fa59871412a11286429111270b211Jeff Hao 6662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian RogersThrowLocation ShadowFrame::GetCurrentLocationForThrow() const { 6762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return ThrowLocation(GetThisObject(), GetMethod(), GetDexPC()); 6862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers} 6962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 70ce4cc0d1818e872c1c7f3c3519a82259afd5c288TDYasize_t ManagedStack::NumJniShadowFrameReferences() const { 710399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers size_t count = 0; 720399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers for (const ManagedStack* current_fragment = this; current_fragment != NULL; 730399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers current_fragment = current_fragment->GetLink()) { 740399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; current_frame != NULL; 750399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers current_frame = current_frame->GetLink()) { 76ce4cc0d1818e872c1c7f3c3519a82259afd5c288TDYa if (current_frame->GetMethod()->IsNative()) { 77ce4cc0d1818e872c1c7f3c3519a82259afd5c288TDYa // The JNI ShadowFrame only contains references. (For indirect reference.) 78ce4cc0d1818e872c1c7f3c3519a82259afd5c288TDYa count += current_frame->NumberOfVRegs(); 79ce4cc0d1818e872c1c7f3c3519a82259afd5c288TDYa } 800399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 81efccc565091b3409ed1372615b4ea4e2f6c39323buzbee } 820399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return count; 83b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes} 84b3bd5f07884f5a1f2b84224363b1372d7c28d447Elliott Hughes 85ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogersbool ManagedStack::ShadowFramesContain(StackReference<mirror::Object>* shadow_frame_entry) const { 860399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers for (const ManagedStack* current_fragment = this; current_fragment != NULL; 870399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers current_fragment = current_fragment->GetLink()) { 880399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers for (ShadowFrame* current_frame = current_fragment->top_shadow_frame_; current_frame != NULL; 890399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers current_frame = current_frame->GetLink()) { 900399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (current_frame->Contains(shadow_frame_entry)) { 910399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return true; 920399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 930399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 940399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 950399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return false; 9668e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes} 9768e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes 987a22fa657b972e8323692368975bc5a7be1cc0f5Ian RogersStackVisitor::StackVisitor(Thread* thread, Context* context) 997a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers : thread_(thread), cur_shadow_frame_(NULL), 1007a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers cur_quick_frame_(NULL), cur_quick_frame_pc_(0), num_frames_(0), cur_depth_(0), 1017a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers context_(context) { 10262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers DCHECK(thread == Thread::Current() || thread->IsSuspended()) << *thread; 1037a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers} 1047a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers 105b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allisonuint32_t StackVisitor::GetDexPc(bool abort_on_failure) const { 1060399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (cur_shadow_frame_ != NULL) { 1070399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return cur_shadow_frame_->GetDexPC(); 1080399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } else if (cur_quick_frame_ != NULL) { 109b373e091eac39b1a79c11f2dcbd610af01e9e8a9Dave Allison return GetMethod()->ToDexPc(cur_quick_frame_pc_, abort_on_failure); 1100399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } else { 1110399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return 0; 1120399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 1130399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers} 1140399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers 11562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogersmirror::Object* StackVisitor::GetThisObject() const { 116ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* m = GetMethod(); 11762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (m->IsStatic()) { 11862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return NULL; 11962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } else if (m->IsNative()) { 12062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (cur_quick_frame_ != NULL) { 12136fea8dd490ab6439f391b8cd7f366c59f026fd2Andreas Gampe StackIndirectReferenceTable* sirt = 12236fea8dd490ab6439f391b8cd7f366c59f026fd2Andreas Gampe reinterpret_cast<StackIndirectReferenceTable*>( 12336fea8dd490ab6439f391b8cd7f366c59f026fd2Andreas Gampe reinterpret_cast<char*>(cur_quick_frame_) + 12436fea8dd490ab6439f391b8cd7f366c59f026fd2Andreas Gampe m->GetSirtOffsetInBytes()); 12536fea8dd490ab6439f391b8cd7f366c59f026fd2Andreas Gampe return sirt->GetReference(0); 12662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } else { 12762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return cur_shadow_frame_->GetVRegReference(0); 12862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 12962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } else { 13062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers const DexFile::CodeItem* code_item = MethodHelper(m).GetCodeItem(); 13162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (code_item == NULL) { 132e0dcd46314d07eeb332edea292f5110178e4e3d2Ian Rogers UNIMPLEMENTED(ERROR) << "Failed to determine this object of abstract or proxy method: " 13362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers << PrettyMethod(m); 134e0dcd46314d07eeb332edea292f5110178e4e3d2Ian Rogers return nullptr; 13562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } else { 13662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers uint16_t reg = code_item->registers_size_ - code_item->ins_size_; 13762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers return reinterpret_cast<mirror::Object*>(GetVReg(m, reg, kReferenceVReg)); 13862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 13962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 14062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers} 14162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers 1420c7abda482f53db3d153c073d1c7a145f84e0626Ian Rogerssize_t StackVisitor::GetNativePcOffset() const { 1430c7abda482f53db3d153c073d1c7a145f84e0626Ian Rogers DCHECK(!IsShadowFrame()); 1440c7abda482f53db3d153c073d1c7a145f84e0626Ian Rogers return GetMethod()->NativePcOffset(cur_quick_frame_pc_); 1450c7abda482f53db3d153c073d1c7a145f84e0626Ian Rogers} 1460c7abda482f53db3d153c073d1c7a145f84e0626Ian Rogers 147ea46f950e7a51585db293cd7f047de190a482414Brian Carlstromuint32_t StackVisitor::GetVReg(mirror::ArtMethod* m, uint16_t vreg, VRegKind kind) const { 1480ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers if (cur_quick_frame_ != NULL) { 1497934ac288acfb2552bb0b06ec1f61e5820d924a4Brian Carlstrom DCHECK(context_ != NULL); // You can't reliably read registers without a context. 1502bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers DCHECK(m == GetMethod()); 1511809a72a66d245ae598582d658b93a24ac3bf01eIan Rogers const VmapTable vmap_table(m->GetVmapTable()); 1520ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers uint32_t vmap_offset; 1530ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers // TODO: IsInContext stops before spotting floating point registers. 1541809a72a66d245ae598582d658b93a24ac3bf01eIan Rogers if (vmap_table.IsInContext(vreg, kind, &vmap_offset)) { 1552bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers bool is_float = (kind == kFloatVReg) || (kind == kDoubleLoVReg) || (kind == kDoubleHiVReg); 1562bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers uint32_t spill_mask = is_float ? m->GetFpSpillMask() 1572bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers : m->GetCoreSpillMask(); 1582bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers return GetGPR(vmap_table.ComputeRegister(spill_mask, vmap_offset, kind)); 1590ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers } else { 1600ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers const DexFile::CodeItem* code_item = MethodHelper(m).GetCodeItem(); 1617934ac288acfb2552bb0b06ec1f61e5820d924a4Brian Carlstrom DCHECK(code_item != NULL) << PrettyMethod(m); // Can't be NULL or how would we compile its instructions? 1620ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers size_t frame_size = m->GetFrameSizeInBytes(); 163423d2a3dcbb260b020efb5da59f784c9f02accbfMathieu Chartier return *GetVRegAddr(cur_quick_frame_, code_item, m->GetCoreSpillMask(), m->GetFpSpillMask(), 164423d2a3dcbb260b020efb5da59f784c9f02accbfMathieu Chartier frame_size, vreg); 1650399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 1660399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } else { 1678e950c117975d23f50ed7e32ca5db01a813c25d0TDYa return cur_shadow_frame_->GetVReg(vreg); 1680399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 1696d4d9fcb4f01e287ee29e81cd1c941ee5d11d379Ian Rogers} 1706d4d9fcb4f01e287ee29e81cd1c941ee5d11d379Ian Rogers 171ea46f950e7a51585db293cd7f047de190a482414Brian Carlstromvoid StackVisitor::SetVReg(mirror::ArtMethod* m, uint16_t vreg, uint32_t new_value, 1722dd0e2cea360bc9206eb88ecc40d259e796c239dIan Rogers VRegKind kind) { 1730ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers if (cur_quick_frame_ != NULL) { 1747934ac288acfb2552bb0b06ec1f61e5820d924a4Brian Carlstrom DCHECK(context_ != NULL); // You can't reliably write registers without a context. 1750ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers DCHECK(m == GetMethod()); 1761809a72a66d245ae598582d658b93a24ac3bf01eIan Rogers const VmapTable vmap_table(m->GetVmapTable()); 1770ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers uint32_t vmap_offset; 1780ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers // TODO: IsInContext stops before spotting floating point registers. 1791809a72a66d245ae598582d658b93a24ac3bf01eIan Rogers if (vmap_table.IsInContext(vreg, kind, &vmap_offset)) { 1806702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier bool is_float = (kind == kFloatVReg) || (kind == kDoubleLoVReg) || (kind == kDoubleHiVReg); 1816702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier uint32_t spill_mask = is_float ? m->GetFpSpillMask() : m->GetCoreSpillMask(); 1826702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier const uint32_t reg = vmap_table.ComputeRegister(spill_mask, vmap_offset, kReferenceVReg); 1836702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier SetGPR(reg, new_value); 1846702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier } else { 1856702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier const DexFile::CodeItem* code_item = MethodHelper(m).GetCodeItem(); 1867934ac288acfb2552bb0b06ec1f61e5820d924a4Brian Carlstrom DCHECK(code_item != NULL) << PrettyMethod(m); // Can't be NULL or how would we compile its instructions? 1876702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier uint32_t core_spills = m->GetCoreSpillMask(); 1886702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier uint32_t fp_spills = m->GetFpSpillMask(); 1896702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier size_t frame_size = m->GetFrameSizeInBytes(); 19042fcd9838a87abaf7a2ef86853a5287f86dbe391Nicolas Geoffray int offset = GetVRegOffset(code_item, core_spills, fp_spills, frame_size, vreg, kRuntimeISA); 1916702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier byte* vreg_addr = reinterpret_cast<byte*>(GetCurrentQuickFrame()) + offset; 1926702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier *reinterpret_cast<uint32_t*>(vreg_addr) = new_value; 1930ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers } 1940ec569a3e653e0358fcb59c89f2aad708843db53Ian Rogers } else { 1952bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers return cur_shadow_frame_->SetVReg(vreg, new_value); 1960399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 197cccd84f1f972f1a260c3be418c8388a5d30cf59eElliott Hughes} 198cccd84f1f972f1a260c3be418c8388a5d30cf59eElliott Hughes 199815873ecc312b1d231acce71e1a16f42cdaf09f2Mathieu Chartieruintptr_t* StackVisitor::GetGPRAddress(uint32_t reg) const { 200815873ecc312b1d231acce71e1a16f42cdaf09f2Mathieu Chartier DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; 201815873ecc312b1d231acce71e1a16f42cdaf09f2Mathieu Chartier return context_->GetGPRAddress(reg); 202815873ecc312b1d231acce71e1a16f42cdaf09f2Mathieu Chartier} 203815873ecc312b1d231acce71e1a16f42cdaf09f2Mathieu Chartier 2040399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogersuintptr_t StackVisitor::GetGPR(uint32_t reg) const { 205df62950e7a32031b82360c407d46a37b94188fbbBrian Carlstrom DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; 2060399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return context_->GetGPR(reg); 20768e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes} 20868e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes 2096702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartiervoid StackVisitor::SetGPR(uint32_t reg, uintptr_t value) { 210df62950e7a32031b82360c407d46a37b94188fbbBrian Carlstrom DCHECK(cur_quick_frame_ != NULL) << "This is a quick frame routine"; 2116702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier context_->SetGPR(reg, value); 2126702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier} 2136702243ea2332b566d8e8b871cc9db0906d835adMathieu Chartier 2140399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogersuintptr_t StackVisitor::GetReturnPc() const { 215ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod** sp = GetCurrentQuickFrame(); 2162bcb4a496b7aa00d996df3a070524f7568fb35a1Ian Rogers DCHECK(sp != NULL); 2170399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers byte* pc_addr = reinterpret_cast<byte*>(sp) + GetMethod()->GetReturnPcOffsetInBytes(); 2180399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return *reinterpret_cast<uintptr_t*>(pc_addr); 21968e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes} 22068e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes 2210399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogersvoid StackVisitor::SetReturnPc(uintptr_t new_ret_pc) { 222ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod** sp = GetCurrentQuickFrame(); 2230399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers CHECK(sp != NULL); 2240399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers byte* pc_addr = reinterpret_cast<byte*>(sp) + GetMethod()->GetReturnPcOffsetInBytes(); 2250399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers *reinterpret_cast<uintptr_t*>(pc_addr) = new_ret_pc; 2260399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers} 227bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes 2287a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogerssize_t StackVisitor::ComputeNumFrames(Thread* thread) { 2290399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers struct NumFramesVisitor : public StackVisitor { 2307a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers explicit NumFramesVisitor(Thread* thread) 2317a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers : StackVisitor(thread, NULL), frames(0) {} 232bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes 2330399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers virtual bool VisitFrame() { 2340399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers frames++; 2350399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return true; 2360399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 23708fc03ae5dded4adc9b45b7014a4b9dfedbe95a6Elliott Hughes 2380399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers size_t frames; 2390399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers }; 2407a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers NumFramesVisitor visitor(thread); 2410399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers visitor.WalkStack(true); 2420399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return visitor.frames; 2430399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers} 244bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes 2457a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogersvoid StackVisitor::DescribeStack(Thread* thread) { 246306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers struct DescribeStackVisitor : public StackVisitor { 2477a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers explicit DescribeStackVisitor(Thread* thread) 2487a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers : StackVisitor(thread, NULL) {} 249306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers 250306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers virtual bool VisitFrame() SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) { 251306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers LOG(INFO) << "Frame Id=" << GetFrameId() << " " << DescribeLocation(); 252306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers return true; 253306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers } 254306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers }; 2557a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers DescribeStackVisitor visitor(thread); 256306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers visitor.WalkStack(true); 257306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers} 258306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers 25940e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogersstd::string StackVisitor::DescribeLocation() const { 26040e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers std::string result("Visiting method '"); 261ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* m = GetMethod(); 262306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers if (m == NULL) { 263306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers return "upcall"; 264306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers } 265306057fd278d75bf3794bd5243a3b6652c487d18Ian Rogers result += PrettyMethod(m); 266ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers result += StringPrintf("' at dex PC 0x%04x", GetDexPc()); 26740e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers if (!IsShadowFrame()) { 26840e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers result += StringPrintf(" (native PC %p)", reinterpret_cast<void*>(GetCurrentQuickFramePc())); 26940e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers } 27040e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers return result; 27140e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers} 27240e3bacfd57bca2ca39c1caec64680bd0ed4a16dIan Rogers 27374e256b8e442417d4ba2054c771c1e4f41062768Sebastien Hertzinstrumentation::InstrumentationStackFrame& StackVisitor::GetInstrumentationStackFrame(uint32_t depth) const { 274123756a041baf8421ed933312605daa5ef082f6fSebastien Hertz CHECK_LT(depth, thread_->GetInstrumentationStack()->size()); 2757a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers return thread_->GetInstrumentationStack()->at(depth); 2767a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers} 2777a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers 27800f7d0eaa6bd93d33bf0c1429bf4ba0b3f28abacIan Rogersvoid StackVisitor::SanityCheckFrame() const { 279ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers if (kIsDebugBuild) { 280ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers mirror::ArtMethod* method = GetMethod(); 281ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers CHECK(method->GetClass() == mirror::ArtMethod::GetJavaLangReflectArtMethod()); 282ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers if (cur_quick_frame_ != nullptr) { 283ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers method->AssertPcIsWithinQuickCode(cur_quick_frame_pc_); 284ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers // Frame sanity. 285ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers size_t frame_size = method->GetFrameSizeInBytes(); 286ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers CHECK_NE(frame_size, 0u); 2875b417b97bd0e89ecd16d2215e0ff2eca5284e013Andreas Gampe // A rough guess at an upper size we expect to see for a frame. 2885b417b97bd0e89ecd16d2215e0ff2eca5284e013Andreas Gampe // 256 registers 2895b417b97bd0e89ecd16d2215e0ff2eca5284e013Andreas Gampe // 2 words Sirt overhead 2905b417b97bd0e89ecd16d2215e0ff2eca5284e013Andreas Gampe // 3+3 register spills 2915b417b97bd0e89ecd16d2215e0ff2eca5284e013Andreas Gampe // TODO: this seems architecture specific for the case of JNI frames. 292ed08bd41321b9347ce3b21e64a5084fb36234e9eBrian Carlstrom // TODO: 083-compiler-regressions ManyFloatArgs shows this estimate is wrong. 293ed08bd41321b9347ce3b21e64a5084fb36234e9eBrian Carlstrom // const size_t kMaxExpectedFrameSize = (256 + 2 + 3 + 3) * sizeof(word); 294ed08bd41321b9347ce3b21e64a5084fb36234e9eBrian Carlstrom const size_t kMaxExpectedFrameSize = 2 * KB; 295ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers CHECK_LE(frame_size, kMaxExpectedFrameSize); 296ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers size_t return_pc_offset = method->GetReturnPcOffsetInBytes(); 297ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers CHECK_LT(return_pc_offset, frame_size); 298ef7d42fca18c16fbaf103822ad16f23246e2905dIan Rogers } 2990399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 3000399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers} 301bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes 3020399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogersvoid StackVisitor::WalkStack(bool include_transitions) { 3037a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers DCHECK(thread_ == Thread::Current() || thread_->IsSuspended()); 30462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers CHECK_EQ(cur_depth_, 0U); 30562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers bool exit_stubs_installed = Runtime::Current()->GetInstrumentation()->AreExitStubsInstalled(); 306725a957985171d712d5c048cc3d00ff14968784bjeffhao uint32_t instrumentation_stack_depth = 0; 307f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 308f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison bool kDebugStackWalk = false; 309f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison bool kDebugStackWalkVeryVerbose = false; // The name says it all. 310f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 311f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (kDebugStackWalk) { 312f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "walking stack"; 313f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } 3147a22fa657b972e8323692368975bc5a7be1cc0f5Ian Rogers for (const ManagedStack* current_fragment = thread_->GetManagedStack(); current_fragment != NULL; 3150399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers current_fragment = current_fragment->GetLink()) { 3160399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_shadow_frame_ = current_fragment->GetTopShadowFrame(); 3170399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_quick_frame_ = current_fragment->GetTopQuickFrame(); 3180399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_quick_frame_pc_ = current_fragment->GetTopQuickFramePc(); 319f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (kDebugStackWalkVeryVerbose) { 320f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "cur_quick_frame: " << cur_quick_frame_; 321f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "cur_quick_frame_pc: " << std::hex << cur_quick_frame_pc_; 322f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } 323f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 3240399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (cur_quick_frame_ != NULL) { // Handle quick stack frames. 3250399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers // Can't be both a shadow and a quick fragment. 3260399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers DCHECK(current_fragment->GetTopShadowFrame() == NULL); 327ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* method = *cur_quick_frame_; 3286641ea12b98dda9ec45d29f20e43f85698b88a02jeffhao while (method != NULL) { 329f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // Check for a stack overflow gap marker. 330f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (method == reinterpret_cast<mirror::ArtMethod*>(stack_overflow_gap_marker)) { 331f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // Marker for a stack overflow. This is followed by the offset from the 332f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // current SP to the next frame. There is a gap in the stack here. Jump 333f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // the gap silently. 334f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // Caveat coder: the layout of the overflow marker depends on the architecture. 335f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // The first element is address sized (8 bytes on a 64 bit machine). The second 336f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // element is 32 bits. So be careful with those address calculations. 337f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison 338f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison // Get the address of the offset, just beyond the marker pointer. 339f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison byte* gapsizeaddr = reinterpret_cast<byte*>(cur_quick_frame_) + sizeof(uintptr_t); 340f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison uint32_t gap = *reinterpret_cast<uint32_t*>(gapsizeaddr); 341f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison CHECK_GT(gap, Thread::kStackOverflowProtectedSize); 342f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison mirror::ArtMethod** next_frame = reinterpret_cast<mirror::ArtMethod**>( 343f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison reinterpret_cast<byte*>(gapsizeaddr) + gap); 344f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (kDebugStackWalk) { 345f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "stack overflow marker hit, gap: " << gap << ", next_frame: " << 346f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison next_frame; 347f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } 348f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison cur_quick_frame_ = next_frame; 349f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison method = *next_frame; 350f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison CHECK(method != nullptr); 351f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } else { 352f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison SanityCheckFrame(); 353f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison bool should_continue = VisitFrame(); 354f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (UNLIKELY(!should_continue)) { 355f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison return; 356f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } 3570399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 3580399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (context_ != NULL) { 3590399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers context_->FillCalleeSaves(*this); 3600399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 3610399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers size_t frame_size = method->GetFrameSizeInBytes(); 3620399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers // Compute PC for next stack frame from return PC. 3630399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers size_t return_pc_offset = method->GetReturnPcOffsetInBytes(); 3640399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers byte* return_pc_addr = reinterpret_cast<byte*>(cur_quick_frame_) + return_pc_offset; 3650399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers uintptr_t return_pc = *reinterpret_cast<uintptr_t*>(return_pc_addr); 366f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (kDebugStackWalkVeryVerbose) { 367f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "frame size: " << frame_size << ", return_pc: " << std::hex << return_pc; 368f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } 36962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (UNLIKELY(exit_stubs_installed)) { 3700399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers // While profiling, the return pc is restored from the side stack, except when walking 3710399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers // the stack for an exception where the side stack will be unwound in VisitFrame. 372848871b4d8481229c32e0d048a9856e5a9a17ef9Ian Rogers if (GetQuickInstrumentationExitPc() == return_pc) { 37374e256b8e442417d4ba2054c771c1e4f41062768Sebastien Hertz const instrumentation::InstrumentationStackFrame& instrumentation_frame = 37462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers GetInstrumentationStackFrame(instrumentation_stack_depth); 375725a957985171d712d5c048cc3d00ff14968784bjeffhao instrumentation_stack_depth++; 376fb2802da02337309ac64970e06c90bb3b1b1de3fJeff Hao if (GetMethod() == Runtime::Current()->GetCalleeSaveMethod(Runtime::kSaveAll)) { 377fb2802da02337309ac64970e06c90bb3b1b1de3fJeff Hao // Skip runtime save all callee frames which are used to deliver exceptions. 378fb2802da02337309ac64970e06c90bb3b1b1de3fJeff Hao } else if (instrumentation_frame.interpreter_entry_) { 379ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom mirror::ArtMethod* callee = Runtime::Current()->GetCalleeSaveMethod(Runtime::kRefsAndArgs); 380fb2802da02337309ac64970e06c90bb3b1b1de3fJeff Hao CHECK_EQ(GetMethod(), callee) << "Expected: " << PrettyMethod(callee) << " Found: " 381138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz << PrettyMethod(GetMethod()); 3829a916d3c0d0574d106c764e737c67b52988d6139Jeff Hao } else if (instrumentation_frame.method_ != GetMethod()) { 38362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers LOG(FATAL) << "Expected: " << PrettyMethod(instrumentation_frame.method_) 384138dbfc3336e379d74d157086f69a0fbe830089bSebastien Hertz << " Found: " << PrettyMethod(GetMethod()); 38562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 38662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (num_frames_ != 0) { 38762d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // Check agreement of frame Ids only if num_frames_ is computed to avoid infinite 38862d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers // recursion. 38962d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers CHECK(instrumentation_frame.frame_id_ == GetFrameId()) 39062d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers << "Expected: " << instrumentation_frame.frame_id_ 39162d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers << " Found: " << GetFrameId(); 39262d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 393725a957985171d712d5c048cc3d00ff14968784bjeffhao return_pc = instrumentation_frame.return_pc_; 3940399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 3950399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 3960399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_quick_frame_pc_ = return_pc; 3970399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers byte* next_frame = reinterpret_cast<byte*>(cur_quick_frame_) + frame_size; 398ea46f950e7a51585db293cd7f047de190a482414Brian Carlstrom cur_quick_frame_ = reinterpret_cast<mirror::ArtMethod**>(next_frame); 3990399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_depth_++; 4000399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers method = *cur_quick_frame_; 401f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison if (kDebugStackWalkVeryVerbose) { 402f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "new cur_quick_frame_: " << cur_quick_frame_; 403f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison LOG(INFO) << "new cur_quick_frame_pc_: " << std::hex << cur_quick_frame_pc_; 404f943914730db8ad2ff03d49a2cacd31885d08fd7Dave Allison } 4056641ea12b98dda9ec45d29f20e43f85698b88a02jeffhao } 4060399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } else if (cur_shadow_frame_ != NULL) { 4070399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers do { 4080399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers SanityCheckFrame(); 4090399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers bool should_continue = VisitFrame(); 4100399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (UNLIKELY(!should_continue)) { 4110399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return; 4120399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 4130399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_depth_++; 4140399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers cur_shadow_frame_ = cur_shadow_frame_->GetLink(); 415df62950e7a32031b82360c407d46a37b94188fbbBrian Carlstrom } while (cur_shadow_frame_ != NULL); 4160399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 4170399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (include_transitions) { 4180399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers bool should_continue = VisitFrame(); 4190399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers if (!should_continue) { 4200399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers return; 4210399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 4220399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 42362d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers cur_depth_++; 42462d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers } 42562d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers if (num_frames_ != 0) { 42662d6c772205b8859f0ebf7ad105402ec4c3e2e01Ian Rogers CHECK_EQ(cur_depth_, num_frames_); 4270399dde18753aa9bd2bd0d7cf60beef154d164a4Ian Rogers } 428bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes} 429bfe487be25652c5456236661b9d9c3579d2296c1Elliott Hughes 43068e76526e98432625464022cb26f66b9ef6f5af4Elliott Hughes} // namespace art 431