[fpc-devel] Proof of Concept ARC implementation

Sven Barth pascaldragon at googlemail.com
Thu Oct 30 10:35:02 CET 2014


On 30.10.2014 04:14, Hans-Peter Diettrich wrote:
> Sven Barth schrieb:
>> On 28.10.2014 10:15, Michael Schnell wrote:
>>> On 10/27/2014 05:17 PM, Hans-Peter Diettrich wrote:
>>>>
>>>> Something like ShortString and AnsiString?
>>>>
>>> Only that ShortStrings can easily be avoided (AFAIK, no great
>>> performance advantage to use them) and hence are seldom used right now.
>>
>> ShortStrings don't have implicit initialization/finalization, thus no
>> implicit try/finally blocks, which at least with FPC's platform
>> independant exception handling mechanism or SEH on i386-win32 have
>> quite some performance impact even in case no error occured (SEH on
>> x86_64-win64 (and in theory arm-wince) only has an impact in case of
>> an error (and an impact in binary size for the exception tables)).
>> Also there is no reference counting for ShortString.
>>
>> So: basically the performance of reference counted objects compared to
>> normal objects is more or less similar to the performance of
>> AnsiStrings compared to ShortStrings (it's not completely equal,
>> because AnsiStrings are allocated on the heap while ShortStrings are
>> on the stack, but it's good enough...). And did anyone yet complain
>> about the performance of AnsiStrings? ;)
>
> Right, this entire discussion is somewhat fruitless without benchmarks.
>
> I wonder how difficult it would be to implement the existing Interface
> refcounting model for TObject, so that this runtime variation could be
> tested and benchmarked as well, in addition to the current compiletime
> approach. According to the problems of the compiletime approach,
> revealed in this thread, it looks not viable to me at all.

The code would mostly be the same as the one I already implemented. Add 
"virtual" to the ARCDecRef, ARCIncRef and ARCRefCount methods of 
TObject, adjust the RTL helper functions to not expect a refcount field 
at a specific offset, remove the restrictions that reference counting is 
only done for classes marked as "refcounted" and you're done...

Regards,
Sven



More information about the fpc-devel mailing list