diff options
author | Nicolas Geoffray <ngeoffray@google.com> | 2020-01-23 10:15:56 +0000 |
---|---|---|
committer | Nicolas Geoffray <ngeoffray@google.com> | 2020-01-31 08:20:57 +0000 |
commit | e91e795a77b96d58276f75b1b244a5509ef8c215 (patch) | |
tree | d34f8164bb7adb8ed46e3c989877012555e194c3 /runtime/quick_exception_handler.cc | |
parent | aa6f6f1c86705fe3cedf929bd30d1e6f51524594 (diff) |
Replace instrumention id with stack pointers.
Replace instrumentation ids for instrumentation frames, which are
inherently broken (see b/72608560), and use stack addresses instead
to properly identify which frames to pop / unwind.
Bug: 72608560
Bug: 148166031
Test: ./art/test/testrunner/testrunner.py --trace --debuggable --ndebuggable --optimizing --interpreter --jit --debug --ndebug -j32
Test: run-libjdwp-tests.sh
Test: 2011-stack-walk-concurrent-instrument
Test: ./art/test/run-test --host --dev --runtime-option -verbose:deopt,plugin --prebuild --compact-dex-level fast --jit --no-relocate --create-runner --runtime-option -Xcheck:jni 1965-get-set-local-primitive-no-tables
art/tools/parallel_run.py -j80 /tmp/path/to/runit.sh --out failure.txt
Change-Id: I71f6e55b9da608796cd3142b147f7b50bbd292ec
Diffstat (limited to 'runtime/quick_exception_handler.cc')
-rw-r--r-- | runtime/quick_exception_handler.cc | 46 |
1 files changed, 4 insertions, 42 deletions
diff --git a/runtime/quick_exception_handler.cc b/runtime/quick_exception_handler.cc index 910b389cf3..bd69aa49fb 100644 --- a/runtime/quick_exception_handler.cc +++ b/runtime/quick_exception_handler.cc @@ -156,37 +156,6 @@ class CatchBlockStackVisitor final : public StackVisitor { DISALLOW_COPY_AND_ASSIGN(CatchBlockStackVisitor); }; -static size_t GetInstrumentationFramesToPop(Thread* self, size_t frame_depth) - REQUIRES_SHARED(Locks::mutator_lock_) { - CHECK_NE(frame_depth, kInvalidFrameDepth); - size_t instrumentation_frames_to_pop = 0; - StackVisitor::WalkStack( - [&](art::StackVisitor* stack_visitor) REQUIRES_SHARED(Locks::mutator_lock_) { - size_t current_frame_depth = stack_visitor->GetFrameDepth(); - if (current_frame_depth < frame_depth) { - CHECK(stack_visitor->GetMethod() != nullptr); - if (UNLIKELY(reinterpret_cast<uintptr_t>(GetQuickInstrumentationExitPc()) == - stack_visitor->GetReturnPc())) { - if (!stack_visitor->IsInInlinedFrame()) { - // We do not count inlined frames, because we do not instrument them. The reason we - // include them in the stack walking is the check against `frame_depth_`, which is - // given to us by a visitor that visits inlined frames. - ++instrumentation_frames_to_pop; - } - } - return true; - } - // We reached the frame of the catch handler or the upcall. - return false; - }, - self, - /* context= */ nullptr, - art::StackVisitor::StackWalkKind::kIncludeInlinedFrames, - /* check_suspended */ true, - /* include_transitions */ true); - return instrumentation_frames_to_pop; -} - // Finds the appropriate exception catch after calling all method exit instrumentation functions. // Note that this might change the exception being thrown. void QuickExceptionHandler::FindCatch(ObjPtr<mirror::Throwable> exception) { @@ -219,11 +188,6 @@ void QuickExceptionHandler::FindCatch(ObjPtr<mirror::Throwable> exception) { DCHECK_GE(new_pop_count, already_popped); already_popped = new_pop_count; - // Figure out how many of those frames have instrumentation we need to remove (Should be the - // exact same as number of new_pop_count if there aren't inlined frames). - size_t instrumentation_frames_to_pop = - GetInstrumentationFramesToPop(self_, handler_frame_depth_); - if (kDebugExceptionDelivery) { if (*handler_quick_frame_ == nullptr) { LOG(INFO) << "Handler is upcall"; @@ -234,8 +198,6 @@ void QuickExceptionHandler::FindCatch(ObjPtr<mirror::Throwable> exception) { LOG(INFO) << "Handler: " << handler_method_->PrettyMethod() << " (line: " << line_number << ")"; } - LOG(INFO) << "Will attempt to pop " << instrumentation_frames_to_pop - << " off of the instrumentation stack"; } // Exception was cleared as part of delivery. DCHECK(!self_->IsExceptionPending()); @@ -245,7 +207,8 @@ void QuickExceptionHandler::FindCatch(ObjPtr<mirror::Throwable> exception) { handler_method_header_->IsOptimized()) { SetCatchEnvironmentForOptimizedHandler(&visitor); } - popped_to_top = popper.PopFramesTo(instrumentation_frames_to_pop, exception_ref); + popped_to_top = + popper.PopFramesTo(reinterpret_cast<uintptr_t>(handler_quick_frame_), exception_ref); } while (!popped_to_top); if (!clear_exception_) { // Put exception back in root set with clear throw location. @@ -679,10 +642,9 @@ uintptr_t QuickExceptionHandler::UpdateInstrumentationStack() { DCHECK(is_deoptimization_) << "Non-deoptimization handlers should use FindCatch"; uintptr_t return_pc = 0; if (method_tracing_active_) { - size_t instrumentation_frames_to_pop = - GetInstrumentationFramesToPop(self_, handler_frame_depth_); instrumentation::Instrumentation* instrumentation = Runtime::Current()->GetInstrumentation(); - return_pc = instrumentation->PopFramesForDeoptimization(self_, instrumentation_frames_to_pop); + return_pc = instrumentation->PopFramesForDeoptimization( + self_, reinterpret_cast<uintptr_t>(handler_quick_frame_)); } return return_pc; } |