How to generate identically image file after snapshots
John M McIntosh
johnmci at smalltalkconsulting.com
Tue Jul 31 02:02:48 UTC 2007
Well writing the image out, means doing a full GC, some cleanup, then
we write out some header bytes and do
bytesWritten = sqImageFileWrite(pointerForOop(memory), sizeof
(unsigned char), imageBytes, f);
which depending on the platform is
#define sqImageFileWrite(ptr, sz, count, f) fwrite(ptr, sz, count, f)
or
sqInt sqImageFileWrite(void *ptr, size_t elementSize, size_t count,
sqImageFile f) {
if (f != 0)
return fwrite(ptr,elementSize,count,f);
return 0;
}
or
size_t sqImageFileWrite(void *ptr, size_t sz, size_t count,
sqImageFile h)
{
DWORD dwReallyWritten;
WriteFile((HANDLE)(h-1), (LPVOID) ptr, count*sz, &dwReallyWritten,
NULL);
return (size_t) (dwReallyWritten / sz);
}
So after we've shoved the entire oops memory space out to what ever
the file handle points to we
start running the VM which instantly changes the bytes in memory
because objects are created/destroyed as
as result of executing byte codes.
If you have some desire to make duplicate images look at
primitiveSnapshot
and consider cloning that to perform the writeImageFile() twice using
different image names.
--
========================================================================
===
John M. McIntosh <johnmci at smalltalkconsulting.com>
Corporate Smalltalk Consulting Ltd. http://www.smalltalkconsulting.com
========================================================================
===
More information about the Squeak-dev
mailing list
|