<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
</head>
<body smarttemplateinserted="true">
<div id="smartTemplate4-template">Hi,<br>
<br>
<p>
<blockquote type="cite">
<div dir="auto">If you need to create 1000 class instances
each frame then you have a flaw in your logic in my
opinion. </div>
<div dir="auto"><br>
</div>
</blockquote>
</p>
<p>I have more like a million class instances<br>
</p>
<p>For my XPath stuff, and every returned value is put in a
variant-like class. Selecting all nodes on an GB large XML,
could even create almost a billion class instances<br>
</p>
<p><br>
</p>
<p>I once did a benchmark. It is 10% faster to reuse the class
instances rather than recreating them, my commit log says. And I
only implemented one interface (actually, two interfaces, since
IUnknown always gets pulled in, too. )<br>
</p>
<p><br>
</p>
<p>
<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><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>
<br>
<br>
Bye,<br>
Benito </div>
<div class="moz-cite-prefix">On 16.02.21 19:48, Sven Barth via
fpc-pascal wrote:<br>
</div>
<blockquote type="cite"
cite="mid:CAFMUeB_WOijkLZX+i5rKehZtqeQSR1Rwru9hZN7kZgkEQkkTWQ@mail.gmail.com">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<div dir="auto">
<div>
<div class="gmail_quote">
<div dir="ltr" class="gmail_attr">Ryan Joseph via fpc-pascal
<<a href="mailto:fpc-pascal@lists.freepascal.org"
moz-do-not-send="true">fpc-pascal@lists.freepascal.org</a>>
schrieb am Di., 16. Feb. 2021, 19:21:</div>
<blockquote class="gmail_quote" style="margin:0 0 0
.8ex;border-left:1px #ccc solid;padding-left:1ex">
> <br>
> There we have:<br>
> <br>
> * slower creation of the class, because each
implemented interface adds another VMT reference to the
class which needs to be initialized.<br>
<br>
How bad is this? We need to make a test case we can
profile. For example if you have a game that creates 1000
classes 60 frames per second. If adding interfaces to the
classes hurts this process we may have a deal breaker.<br>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">If you need to create 1000 class instances each
frame then you have a flaw in your logic in my opinion. </div>
<div dir="auto"><br>
</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"> <br>
> * slow reference counting. Especially if it is thread
safe and exception safe with the implicit exception block<br>
<br>
It's a whole other topic but FPC needs opt-in ARC at the
language level for classes. Interfaces are not only slow
but then you need to pass around a reference to the
interface instead of the class you actually care about. It
makes no sense to me whatsoever.<br>
</blockquote>
</div>
</div>
<div dir="auto"><br>
</div>
<div dir="auto">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. </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">
</blockquote>
</div>
</div>
</div>
<br>
<fieldset class="mimeAttachmentHeader"></fieldset>
<pre class="moz-quote-pre" wrap="">_______________________________________________
fpc-pascal maillist - <a class="moz-txt-link-abbreviated" href="mailto:fpc-pascal@lists.freepascal.org">fpc-pascal@lists.freepascal.org</a>
<a class="moz-txt-link-freetext" href="https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal">https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal</a>
</pre>
</blockquote>
</body>
</html>