On Wed, 2007-10-10 at 12:20 +1000, skaller wrote: > *** Ouch. One oversight, which is rather nasty: the design isn't > thread safe.
It is now :) ****** Now, there is another issue. I assumed, incorrectly, that it would be possible to statically determine which allocations were safe for collection, and which not. It is certainly possible to do this conservatively .. if only by assuming (as at present) that all allocations are unsafe. Allocations in the top level code are always safe unless a pointer is saved in a machine stack temporary.. this can happen when Felix generates code like: { tmp = something; return new(..) proc2(this, tmp); } which I think it does. [Ouch .. ] However for a given routine, we need to tell it if the machine stack is non-empty on entry to the routine, provided the routine actually needs to know (i.e. if it is doing any allocations, or calling a routine that does). Clearly a routine might be called when the stack is empty in one place, and when it is non-empty in another .. so this information must be propagated dynamically. This is real mess! But it is worse, MUCH WORSE!! Even if I do all this it still won't work in multi-threaded environment. At the point the collector might be called we need to know if ANY thread is using the machine stack .. not just the current one! ALTERNATIVE ----------- A simple alternative to all this mess is to get the thread_control object to do more work. At present it only counts threads, it doesn't keep track of the actual threads. If the yield() function stored the current stack into the thread control object's slot for that thread, then at world stop time we'd have a set of frozen threads with their stacks known. The gc could then simply scan all the stacks conservatively. This is more or less what the Boehm gc does. The problem now is that we are so close to using a restricted subset of the Boehm functionality -- Boehm does more: incremental collection, and works with 'arbitrary C/C++' -- that it isn't clear we might not just use the Boehm collector and throw the Felix one out. Boehm ALSO allows precise collection, using a bitmap instead of the array of offsets Felix uses (but it comes to the same thing). Boehm isn't compatible with Judy, however I think it can be 'hooked' in somehow. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net ------------------------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Still grepping through log files to find problems? Stop. Now Search log events and configuration files using AJAX and a browser. Download your FREE copy of Splunk now >> http://get.splunk.com/ _______________________________________________ Felix-language mailing list Felix-language@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/felix-language