diff options
Diffstat (limited to 'runtime/stack.cc')
| -rw-r--r-- | runtime/stack.cc | 60 |
1 files changed, 18 insertions, 42 deletions
diff --git a/runtime/stack.cc b/runtime/stack.cc index bd0d5d680e..053c28fce9 100644 --- a/runtime/stack.cc +++ b/runtime/stack.cc @@ -68,7 +68,6 @@ StackVisitor::StackVisitor(Thread* thread, cur_oat_quick_method_header_(nullptr), num_frames_(num_frames), cur_depth_(0), - current_inlining_depth_(0), context_(context), check_suspended_(check_suspended) { if (check_suspended_) { @@ -76,32 +75,15 @@ StackVisitor::StackVisitor(Thread* thread, } } -static StackMap GetCurrentStackMap(CodeInfo& code_info, - const OatQuickMethodHeader* method_header, - uintptr_t cur_quick_frame_pc) - REQUIRES_SHARED(Locks::mutator_lock_) { - uint32_t native_pc_offset = method_header->NativeQuickPcOffset(cur_quick_frame_pc); - StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset); - DCHECK(stack_map.IsValid()); - return stack_map; -} - ArtMethod* StackVisitor::GetMethod() const { if (cur_shadow_frame_ != nullptr) { return cur_shadow_frame_->GetMethod(); } else if (cur_quick_frame_ != nullptr) { if (IsInInlinedFrame()) { - size_t depth_in_stack_map = current_inlining_depth_ - 1; const OatQuickMethodHeader* method_header = GetCurrentOatQuickMethodHeader(); - CodeInfo code_info(method_header); - StackMap stack_map = GetCurrentStackMap(code_info, method_header, cur_quick_frame_pc_); MethodInfo method_info = method_header->GetOptimizedMethodInfo(); DCHECK(walk_kind_ != StackWalkKind::kSkipInlinedFrames); - return GetResolvedMethod(*GetCurrentQuickFrame(), - method_info, - code_info, - stack_map, - depth_in_stack_map); + return GetResolvedMethod(*GetCurrentQuickFrame(), method_info, current_inline_frames_); } else { return *cur_quick_frame_; } @@ -114,11 +96,7 @@ uint32_t StackVisitor::GetDexPc(bool abort_on_failure) const { return cur_shadow_frame_->GetDexPC(); } else if (cur_quick_frame_ != nullptr) { if (IsInInlinedFrame()) { - const OatQuickMethodHeader* method_header = GetCurrentOatQuickMethodHeader(); - CodeInfo code_info(method_header); - size_t depth_in_stack_map = current_inlining_depth_ - 1; - StackMap stack_map = GetCurrentStackMap(code_info, method_header, cur_quick_frame_pc_); - return code_info.GetInlineInfoAtDepth(stack_map, depth_in_stack_map).GetDexPc(); + return current_inline_frames_.back().GetDexPc(); } else if (cur_oat_quick_method_header_ == nullptr) { return dex::kDexNoIndex; } else { @@ -233,19 +211,18 @@ bool StackVisitor::GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKin uint32_t native_pc_offset = method_header->NativeQuickPcOffset(cur_quick_frame_pc_); StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset); DCHECK(stack_map.IsValid()); - size_t depth_in_stack_map = current_inlining_depth_ - 1; DexRegisterMap dex_register_map = IsInInlinedFrame() - ? code_info.GetDexRegisterMapAtDepth(depth_in_stack_map, stack_map, number_of_dex_registers) - : code_info.GetDexRegisterMapOf(stack_map, number_of_dex_registers); - - if (!dex_register_map.IsValid()) { + ? code_info.GetInlineDexRegisterMapOf(stack_map, current_inline_frames_.back()) + : code_info.GetDexRegisterMapOf(stack_map); + if (dex_register_map.empty()) { return false; } - DexRegisterLocation::Kind location_kind = dex_register_map.GetLocationKind(vreg); + DCHECK_EQ(dex_register_map.size(), number_of_dex_registers); + DexRegisterLocation::Kind location_kind = dex_register_map[vreg].GetKind(); switch (location_kind) { case DexRegisterLocation::Kind::kInStack: { - const int32_t offset = dex_register_map.GetStackOffsetInBytes(vreg); + const int32_t offset = dex_register_map[vreg].GetStackOffsetInBytes(); const uint8_t* addr = reinterpret_cast<const uint8_t*>(cur_quick_frame_) + offset; *val = *reinterpret_cast<const uint32_t*>(addr); return true; @@ -254,18 +231,16 @@ bool StackVisitor::GetVRegFromOptimizedCode(ArtMethod* m, uint16_t vreg, VRegKin case DexRegisterLocation::Kind::kInRegisterHigh: case DexRegisterLocation::Kind::kInFpuRegister: case DexRegisterLocation::Kind::kInFpuRegisterHigh: { - uint32_t reg = dex_register_map.GetMachineRegister(vreg); + uint32_t reg = dex_register_map[vreg].GetMachineRegister(); return GetRegisterIfAccessible(reg, kind, val); } case DexRegisterLocation::Kind::kConstant: - *val = dex_register_map.GetConstant(vreg); + *val = dex_register_map[vreg].GetConstant(); return true; case DexRegisterLocation::Kind::kNone: return false; default: - LOG(FATAL) - << "Unexpected location kind " - << dex_register_map.GetLocationInternalKind(vreg); + LOG(FATAL) << "Unexpected location kind " << dex_register_map[vreg].GetKind(); UNREACHABLE(); } } @@ -822,10 +797,10 @@ void StackVisitor::WalkStack(bool include_transitions) { cur_oat_quick_method_header_->NativeQuickPcOffset(cur_quick_frame_pc_); StackMap stack_map = code_info.GetStackMapForNativePcOffset(native_pc_offset); if (stack_map.IsValid() && stack_map.HasInlineInfo()) { - DCHECK_EQ(current_inlining_depth_, 0u); - for (current_inlining_depth_ = code_info.GetInlineDepthOf(stack_map); - current_inlining_depth_ != 0; - --current_inlining_depth_) { + DCHECK_EQ(current_inline_frames_.size(), 0u); + for (current_inline_frames_ = code_info.GetInlineInfosOf(stack_map); + !current_inline_frames_.empty(); + current_inline_frames_.pop_back()) { bool should_continue = VisitFrame(); if (UNLIKELY(!should_continue)) { return; @@ -851,13 +826,14 @@ void StackVisitor::WalkStack(bool include_transitions) { uint8_t* return_pc_addr = reinterpret_cast<uint8_t*>(cur_quick_frame_) + return_pc_offset; uintptr_t return_pc = *reinterpret_cast<uintptr_t*>(return_pc_addr); - if (UNLIKELY(exit_stubs_installed)) { + if (UNLIKELY(exit_stubs_installed || + reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()) == return_pc)) { // While profiling, the return pc is restored from the side stack, except when walking // the stack for an exception where the side stack will be unwound in VisitFrame. if (reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()) == return_pc) { CHECK_LT(instrumentation_stack_depth, thread_->GetInstrumentationStack()->size()); const instrumentation::InstrumentationStackFrame& instrumentation_frame = - thread_->GetInstrumentationStack()->at(instrumentation_stack_depth); + (*thread_->GetInstrumentationStack())[instrumentation_stack_depth]; instrumentation_stack_depth++; if (GetMethod() == Runtime::Current()->GetCalleeSaveMethod(CalleeSaveType::kSaveAllCalleeSaves)) { |