<div dir="auto"><div><div class="gmail_quote"><div dir="ltr" class="gmail_attr">Benito van der Zander via fpc-pascal <<a href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>> schrieb am Di., 16. Feb. 2021, 23:35:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div>
<div id="m_1619508560580165443smartTemplate4-template"><blockquote type="cite">Interfaces are not slow because they are
are interfaces! When you call a interface method it has the
same costs as a virtual method call! And the cost for
reference counting that interfaces have right now would be
there for ARC as well. <br>
</blockquote>
<p></p>
<p><br>
</p>
<p>But it is not calling the method, it is calling the wrapper
function<br>
</p>
<p>That is a additional second method call/jump for every
interface method call.</p>
<p><br>
</p>
<p>E.g. _AddRef on TInterfacedObject as an interface, does not
call TInterfacedObject._AddRef, it calls this:<br>
</p>
</div>
<div>WRPR_$SYSTEM_$$_TINTERFACEDOBJECT_$_IUNKNOWN_$_1_$_SYSTEM$_$TINTERFACEDOBJECT_$__$$__ADDREF$$LONGINT
<br>
0000000000424600 4883ef10 sub $0x10,%rdi<br>
0000000000424604 e997f8feff jmpq 0x413ea0
<SYSTEM$_$TINTERFACEDOBJECT_$__$$__ADDREF$$LONGINT><br></div></div></blockquote></div></div><div dir="auto"><br></div><div dir="auto">It's an *unconditional* jump. The branch prediction of the CPU should handle this without much penalty. </div><div dir="auto"><br></div><div dir="auto">Regards, </div><div dir="auto">Sven </div><div dir="auto"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div><div></div></div>
</blockquote></div></div></div>