On Sat, 2007-11-03 at 10:35 +0100, Sylvain Pion wrote: > skaller wrote : > > I can tell you I definitely considered using FS for the > > Felix thread frame pointer to save passing that pointer > > between every function.. > > But then, won't you end up with an implementation very similar > to __thread??
Yes, but there are several differences: 1. Instead of reserving a fixed register in the ABI, the compiler treats the pointer as an ordinary variable, and so can apply ordinary optimisation procedures to it. 2. Because the application controls the data pointed at, it need not be wasted on a resource which may not be needed, and may have the option of using a subsuming data structure. For example, if it pointed at the stack base which included not only a pointer to TLS data but also other application data, the cost of using the register would be relatively lower. Felix does precisely this: one pointer to the 'thread-frame' object includes not only a pointer to the garbage collector (a system resource) but also arbitrary user data. In a language with a display (Pascal, Ada, etc etc), the display pointer can always find the stack base frame, which can hold such data .. as well as locating the rest of the current functions static environment frames. Now it is true C doesn't have a need for a general display. However if C ABI/Compilers use a register for a specific, rarely needed purpose, particularly supporting broken legacy applications, that may interfere with more modern advanced technology using the register more effectively. My point really is: registers are a scarce resource, and TLS is a broken subconcept of the more general design error C commits, global store .. when a much more general mechanism exists (static display) which subsumes both. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net