Win32 port - the GC...
Anoq of the Sun
anoq@hardcoreprocessing.com
Thu, 31 Jan 2002 22:06:46 +0100
This is a multi-part message in MIME format.
--------------14E4402F98B4537F7DFE25DF
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Hello!
I'm working on completing the Win32-port of the 20010806
release of MLton now. I have now come to the point where
the compilation complains about compiling mllex - so I think
MLton itself compiles now (but that probably far from means
that it works of course - most of the code I messed with is
C-code after all ;)
Anyways - I have attached gc.c from the runtime. I would like
you guys to review / fix the code if you know of any potential
problems. And all changes should only apply if the _WIN32 flag
is defined - so I hope it's still equivalent to gc.c in
version 20010806 on Linux at least.
In particular I'm concerned about the following:
1) I commented out a lot of timing stuff - which doesn't exist
on Win32, but it seems mostly to be for debugging and feedback
so I hope it's not important (we only cross-compile applications
to Windows which already work on Linux - right? :)
2) It seems the garbage collector doesn't do memory shrinking of
the stack anymore (the ML call-stack i presume?) as it did
in the old version I ported. This should actually give one
problem _less_ on Win32 - but maybe the code has just changed
and maybe you still do stack shrinking, only in a different way?
3) There are no signals in Win32 - I'm not sure if it's safe to
just uncomment all that stuff (after all the GC seems to
only be concerned about disabling those signals... :)
and if I've done it right.
4) Win32 does not have the mprotect function - so I uncommented
that in ssmmap - but ssmmap is not even called anymore - after
the uncommenting of everything in the function initSignalStack
because of the signals (which I'm not sure will be safe either?)
So maybe ssmmap is not important at all...
Anyways - look for the following in the code:
_WIN32
FIXME:
DONT_SHRINK_MEM
DONT_USE_SIGNALS
I hope you can give some feedback :)
Cheers
--
http://www.HardcoreProcessing.com
--------------14E4402F98B4537F7DFE25DF
Content-Type: application/x-unknown-content-type-ProjectBuilder.c;
name="gc.c"
Content-Transfer-Encoding: base64
Content-Disposition: inline;
filename="gc.c"
LyogQ29weXJpZ2h0IChDKSAxOTk3LTE5OTkgTkVDIFJlc2VhcmNoIEluc3RpdHV0ZS4KICog
UGxlYXNlIHNlZSB0aGUgZmlsZSBMSUNFTlNFIGZvciBsaWNlbnNlIGluZm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