[Vm-dev] Checking
NewObjectMemory>>eeInstantiateClassIndex:format:numSlots:
(was: VM Maker: VMMaker.oscog-eem.363.mcz)
David T. Lewis
lewis at mail.msen.com
Sat Sep 14 14:37:54 UTC 2013
On Wed, Sep 11, 2013 at 07:55:14AM -0700, Eliot Miranda wrote:
>
> BTW, David, I implemented
> NewObjectMemory>>eeInstantiateClassIndex:format:numSlots: (in
> VMMaker.oscog-eem.369) which needs to set the Size4Bit. It contains a
> comment asking you to check the code :-). I wonder if, in your copious
> free time, you might do just that? No hurry, and indeed I hope to render
> ObjectMemory and NewObjectMemory obsolete asap :-).
>
Hi Eliot,
I took a look at this in a 64-bit image, and I think that the calculation
of Size4Bit setting is not right, but I am not sure that I understand the
usage of the numSlots parameter in eeInstantiateClassIndex:format:numSlots:.
If it is used in the same way as the size parameter in instantiateClass:indexableSize:
then no, it is not right.
I checked this by loading a 64-bit image into a simulator and scanning through
the objects to check the logic for setting Size4Bit versus the actual setting
of that bit in the object header. I am attaching a workspace so you can
take a look at the results yourself.
The key to it is this assumption that I made in the workspace:
numSlots := len. "is this right? assume param to eeInstantiateClass is this value"
If I have that wrong, then my results are bogus.
To run the workspace, start with a clean Squeak image, load a VMM trunk
into it (e.g. VMMaker-dtl.324), and evaluate the workspace.
You will need a 64-bit image file, grab a copy from
http://build.squeak.org/job/Squeak%2064-bit%20image/
One other note - I see that header format 7 is supposed to mean something
special in the 64 bit image, and this enters into the Size4Bit calculation.
But I found no instances of that object format in a (newly traced) 64-bit
image, so I don't know if this is important and I did not look into it
further.
HTH,
Dave
-------------- next part --------------
"First load VMM into a clean Squeak image (normal 32 bit image).
Then download a 64-bit image from
http://build.squeak.org/job/Squeak%2064-bit%20image/"
"Open the 64 bit image in a simulator"
om := ObjectMemorySimulatorLSB64 basicNew.
interp := InterpreterSimulatorLSB64 on: om.
interp openOn: 'TrunkImage-64.image'.
"Iterate through the object memory checking the size calculation"
"Note: format 7 is apparently a special case for the Piumarta-Ingalls 64 bit
object memory, see #formatOfHeader comments. However, I do not find any
instances of that format appearing in a newly traced 64 bit image, so I am not
sure if this is important."
problems := Dictionary new.
count := 0.
problemCount := 0.
oop := om firstAccessibleObject.
[oop < om endOfMemory] whileTrue: [ | len baseHeader header1 objFormat numSlots |
baseHeader := om baseHeader: oop.
objFormat := om formatOfHeader: baseHeader.
len := om lengthOf: oop.
"eeInstantiateClassIndex:format:numSlots: logic here"
header1 := 0. "ensure clear before calling eem logic"
numSlots := len. "is this right? assume param to eeInstantiateClass is this value"
(om bytesPerWord = 8 "David, please check this!!"
and: [objFormat >= 6 "self firstLongFormat" "32-bit longs and byte objects"
and: [(numSlots bitAnd: 1) ~= 0]]) ifTrue:
["extra low bit (4) for 64-bit VM goes in 4-bit (betw hdr bits and sizeBits)"
header1 := header1 bitOr: 4].
"end of snippet from eeInstantiateClassIndex:format:numSlots:"
(baseHeader bitAnd: 4) = header1
ifFalse: [ | result |
"expected header1 to have this bit set the same as in the actual object header"
result := Dictionary withAll: {
'oop' -> oop.
'objFormat' -> objFormat.
'len' -> len.
'baseHeader' -> baseHeader.
'baseHeader bitAnd: 4' -> (baseHeader bitAnd: 4).
'header1' -> header1 }.
problems at: objFormat ifAbsentPut: OrderedCollection new.
(problems at: objFormat) add: result.
problemCount := problemCount + 1.
"self halt"].
oop := om objectAfter: oop.
count := count + 1.
].
{ problems . count . problemCount } inspect.
"formatOfHeader: header
0 no fields
1 fixed fields only (all containing pointers)
2 indexable fields only (all containing pointers)
3 both fixed and indexable fields (all containing pointers)
4 both fixed and indexable weak fields (all containing pointers).
5 unused
6 indexable word fields only (no pointers)
7 indexable long (64-bit) fields (only in 64-bit images)
8-11 indexable byte fields only (no pointers) (low 2 bits are low 2 bits of size)
12-15 compiled methods:
# of literal oops specified in method header,
followed by indexable bytes (same interpretation of low 2 bits as above)
"
More information about the Vm-dev
mailing list