我有源代码:
RenderPart* Frame::ownerRenderer() const
{
HTMLFrameOwnerElement* ownerElement = m_ownerElement;
if (!ownerElement)
return 0;
RenderObject* object = ownerElement->renderer();
if (!object)
return 0;
// FIXME: If <object> is ever fixed to disassociate itself from frames
// that it has started but canceled, then this can turn into an ASSERT
// since m_ownerElement would be 0 when the load is canceled.
// https://bugs.webkit.org/show_bug.cgi?id=18585
if (!object->isRenderPart())
return 0;
return toRenderPart(object);
}
和objdump:
00143408 <_ZNK7WebCore5Frame13ownerRendererEv>:
143408: b510 push {r4, lr}
14340a: f8d0 32f0 ldr.w r3, [r0, #752]
14340e: b14b cbz r3, 143424 <_ZNK7WebCore5Frame13ownerRendererEv+0x1c>
143410: 6a1c ldr r4, [r3, #32]
143412: b13c cbz r4, 143424 <_ZNK7WebCore5Frame13ownerRendererEv+0x1c>
143414: 6820 ldr r0, [r4, #0]
143416: f8d0 30b0 ldr.w r3, [r0, #176]
14341a: 4620 mov r0, r4
14341c: 4798 blx r3
14341e: b108 cbz r0, 143424 <_ZNK7WebCore5Frame13ownerRendererEv+0x1c>
143420: 4620 mov r0, r4
143422: e000 b.n 143426 <_ZNK7WebCore5Frame13ownerRendererEv+0x1e>
143424: 2000 movs r0, #0
143426: bd10 pop {r4, pc}
现在我想知道哪个源代码行可以编译成143416行?
答案 0 :(得分:2)
我认为它基本上是ownerElement->renderer
。
142312是最后一个if(!object)
(return 0
低于143424-143426),然后143414-14341a正在为函数调用ownerElement->renderer()
做准备:
143414将ownerElement变为r0
143416将renderer()的偏移量转换为r3
14341a实际上是设置此ptr以在renderer()(即ownerElement)中使用
14341c实际上跳转到渲染器()