[fpc-devel] Suggestion: reference counted objects

Boian Mitov mitov at mitov.com
Sun Sep 21 22:03:43 CEST 2014


This is not true. Ref pointer is exactly the same size as non ref pointer. 
the counter is in the instance not in the pointer to the instance ;-) .
You can study the interface implementations or the String implementations 
they are done the same way.

With best regards,
Boian Mitov

-------------------------------------------------------
Mitov Software
www.mitov.com
-------------------------------------------------------
-----Original Message----- 
From: Peter Popov
Sent: Sunday, September 21, 2014 12:29 PM
To: fpc-devel at lists.freepascal.org ; Sven Barth
Subject: Re: [fpc-devel] Suggestion: reference counted objects

Sven,
based on your comments a bizarre thought came to me. Currently, class
instances are pointers. What you propose will somehow create a special
pointer type (referenced class).

Should this be done, I have a request: create a 4 byte "compressed" class
reference which expands into an 8 byte pointer type prior to usage:
1. Most architectures align data.
2. 64 bit comps align pointers on 8 byte boundaries, meaning that the 3
leftmost bits are 0.
3. You could store a class pointer as a 4 byte integer and, prior to
usage, expand it to 8 bytes a leftshift 3.

In this way you will have 64GB of data available to your program and your
pointers will occupy twice less. If, for example one uses large amount of
pointers, this could be ... aesthetically pleasing ...





More information about the fpc-devel mailing list