On Wed, Mar 14, 2012 at 12:48 PM, Guillermo Polito
<guillermopolito@gmail.com> wrote:
Hi Eliot,
do you have a pointer of where can I see the differences between the old Squeak format and the cog image format, so I can make SystemTracer work on Cog vms?
So the image format differences are
- floats are in platform order, not necessarily in big-endian order
- the layout of the specialObjectsArray is slightly different (documented in recreateSpecialObjectsArray)
- there are more words in the header, see StackInterpreter>writeImageFileIO:, i.e.
in Cog:
self putLong: self imageFormatVersion toFile: f.
self putLong: headerSize toFile: f.
self putLong: imageBytes toFile: f.
self putLong: objectMemory startOfMemory toFile: f.
self putLong: objectMemory specialObjectsOop toFile: f.
self putLong: objectMemory newObjectHash toFile: f.
self putLong: self ioScreenSize toFile: f.
self putLong: self getImageHeaderFlags toFile: f.
self putLong: extraVMMemory toFile: f.
self putShort: desiredNumStackPages toFile: f.
self putShort: self unknownShortOrCodeSizeInKs toFile: f.
self putLong: desiredEdenBytes toFile: f.
self putShort: (maxExtSemTabSizeSet ifTrue: [self ioGetMaxExtSemTableSize] ifFalse: [0]) toFile: f.
self putShort: 0 toFile: f.
1 to: 4 do: [:i | self putLong: 0 toFile: f]. "fill remaining header words with zeros"
in Interpreter:
self putLong: (self imageFormatVersion) toFile: f.
self putLong: headerSize toFile: f.
self putLong: imageBytes toFile: f.
self putLong: (self startOfMemory) toFile: f.
self putLong: specialObjectsOop toFile: f.
self putLong: lastHash toFile: f.
self putLong: (self ioScreenSize) toFile: f.
self putLong: fullScreenFlag toFile: f.
self putLong: extraVMMemory toFile: f.
1 to: 7 do: [:i | self putLong: 0 toFile: f]. "fill remaining header words with zeros"
Then
getImageHeaderFlags
"Answer the flags that are contained in the 7th long of the image header."
^fullScreenFlag "0 or 1"
+ (VMBIGENDIAN ifTrue: [0] ifFalse: [2]) "this is the imageFloatsLittleEndian flag"
+ (processHasThreadId ifTrue: [4] ifFalse: [0])
+ (flagInterpretedMethods ifTrue: [8] ifFalse: [0])
+ (preemptionYields ifTrue: [0] ifFalse: [16])
+ (noThreadingOfGUIThread ifTrue: [32] ifFalse: [0])
+ (imageHeaderFlags bitAnd: 63 bitInvert32) "these are any flags we do not recognize"
Now most of the information in the flags is accessible from vmParameterAt: (or some convenience methods). e.g. vm parameter 49 is the max external semaphore table size, and vm parameter 48 is the following flags:
getCogVMFlags
"Answer an array of flags indicating various properties of the Cog VM.
Bit 0: implies the image's Process class has threadId as its 3rd inst var (zero relative)
Bit 1: if set, methods that are interpreted will have the flag bit set in their header
Bit 2: if set, implies preempting a process does not put it to the back of its run queue"
^objectMemory integerObjectOf: (processHasThreadId ifTrue: [1] ifFalse: [0])
+ (flagInterpretedMethods ifTrue: [2] ifFalse: [0])
+ (preemptionYields ifTrue: [0] ifFalse: [4])
+ (noThreadingOfGUIThread ifTrue: [8] ifFalse: [0])