DescriptionLink stack frames of JNI stubs to JNI callbacks.
Chrome's native heap profiler relies on stack frame pointers to unwind. That
is fast, but requires that all code in a call chain is built with frame pointer
support. Which is not the case for Java / JNI code on Android, so unwinding
stops prematurely once it crosses JNI boundary.
This CL exploits the fact that both JNI stubs (which call into Java) and JNI
callbacks (which are called by Java) are generated. It changes JNI generator
to save stack frame pointer in a JNI stub, and later link saved frame pointer
to a frame pointer of a JNI callback. That repairs broken stack frame chain
and allows unwinder to yield complete trace.
Changes in this CL are active only for profiling builds (ones that build with
enable_profiling=true). Otherwise JNI generator produces exactly the same code
as before (modulo removed empty lines).
Example of a complete trace made possible by this CL:
<.../base.odex>
Java_org_chromium_base_SystemMessageHandler_nativeDoRunLoopOnce
base::MessageLoop::DoWork
base::MessageLoop::DeferOrRunPendingTask
base::MessageLoop::RunTask
base::debug::TaskAnnotator::RunTask
cc::SingleThreadProxy::BeginMainFrame
cc::SingleThreadProxy::DoBeginMainFrame
content::CompositorImpl::UpdateLayerTreeHost..............................#4
<.../base.odex>
Java_org_chromium_chrome_..._ToolbarSceneLayer_nativeUpdateToolbarLayer...#3
android::ToolbarSceneLayer::UpdateToolbarLayer
android::ToolbarLayer::PushResource
ui::ResourceManagerImpl::GetResource......................................#2
<.../base.odex>
Java_org_chromium_ui_resources_ResourceManager_nativeOnResourceReady......#1
ui::ResourceManagerImpl::OnResourceReady
gfx::CreateSkBitmapFromJavaBitmap
...more frames from Chrome...
Previously unwinding would've stopped at #1. Code added by JNI generator links
frames #1->#2 and #3->#4.
BUG=624362
Committed: https://crrev.com/a8c951effbf899ae4951c67d606a634905f88ab4
Cr-Commit-Position: refs/heads/master@{#427534}
Patch Set 1 #Patch Set 2 : LinkStackFrames -> ScopedStackFrameLinker #Patch Set 3 : Rebase #Patch Set 4 : Simplify - remove FakeStackFrame, etc. #
Total comments: 18
Patch Set 5 : Rebase #Patch Set 6 : Address comments; fix tests #Patch Set 7 : Remove useless include #
Total comments: 1
Patch Set 8 : Rebase #Patch Set 9 : git cl format #Messages
Total messages: 24 (12 generated)
|