Skip to content

Commit

Permalink
- Moving the fake nullHeader to all memoryManagers
Browse files Browse the repository at this point in the history
- When checking if a perm object points to a new or old object, I have to discard the machine code objects
- Writing a better test
  • Loading branch information
tesonep committed Sep 8, 2023
1 parent 520f38d commit 46aa062
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 23 deletions.
9 changes: 0 additions & 9 deletions smalltalksrc/VMMaker/Spur32BitCoMemoryManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -199,15 +199,6 @@ Spur32BitCoMemoryManager >> needGCFlagAddress [
inSmalltalk: [cogit simulatedReadWriteVariableAddress: #needGCFlag in: self]
]

{ #category : #'garbage collection' }
Spur32BitCoMemoryManager >> nullHeaderForMachineCodeMethod [
<api>
<returnTypeC: #sqLong>
^(self firstLongFormat << self formatShift)
+ (1 << self markedBitFullShift)
+ ClassBitmapCompactIndex
]

{ #category : #'object enumeration' }
Spur32BitCoMemoryManager >> objectBytesForSlots: numSlots [
"Answer the total number of bytes in an object with the given
Expand Down
9 changes: 0 additions & 9 deletions smalltalksrc/VMMaker/Spur64BitCoMemoryManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -206,15 +206,6 @@ Spur64BitCoMemoryManager >> needGCFlagAddress [
inSmalltalk: [cogit simulatedReadWriteVariableAddress: #needGCFlag in: self]
]

{ #category : #'garbage collection' }
Spur64BitCoMemoryManager >> nullHeaderForMachineCodeMethod [
<api>
<returnTypeC: #sqLong>
^(self firstLongFormat << self formatShift)
+ (1 << self markedBitFullShift)
+ ClassBitmapCompactIndex
]

{ #category : #'object enumeration' }
Spur64BitCoMemoryManager >> objectBytesForSlots: numSlots [
"Answer the total number of bytes in an object with the given
Expand Down
14 changes: 12 additions & 2 deletions smalltalksrc/VMMaker/SpurMemoryManager.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -9538,6 +9538,15 @@ SpurMemoryManager >> nonIndexablePointerFormat [
^1
]

{ #category : #'garbage collection' }
SpurMemoryManager >> nullHeaderForMachineCodeMethod [
<api>
<returnTypeC: #sqLong>
^(self firstLongFormat << self formatShift)
+ (1 << self markedBitFullShift)
+ ClassBitmapCompactIndex
]

{ #category : #'object access' }
SpurMemoryManager >> num16BitUnitsOf: objOop [
"Answer the number of 16-bit units in the given non-immediate object.
Expand Down Expand Up @@ -10285,12 +10294,13 @@ SpurMemoryManager >> possiblePermObjectStoreInto: destObj value: valueObj [
ifFalse: [ ^ self ].

(self getMemoryMap isPermanentObject: valueObj)
ifFalse: [ ^ self ].
ifTrue: [ ^ self ].

(self isFixedKnownObject: valueObj)
ifTrue: [ ^ self ].

self assert: (self isInObjectMemory: valueObj).
(self isInObjectMemory: valueObj)
ifFalse: [ ^ self ].

self getFromPermToNewSpaceRememberedSet remember: destObj.
]
Expand Down
15 changes: 12 additions & 3 deletions smalltalksrc/VMMakerTests/VMPermanentSpaceMemoryTest.class.st
Original file line number Diff line number Diff line change
Expand Up @@ -653,7 +653,7 @@ VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToTrueIsNotRemembered [
VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToYoungObjectIsRemovedWhenPointingToMachineCodeMethod [


| oldObject permanentObject youngObject |
| oldObject permanentObject youngObject fakeMachineCodeMethod |
oldObject := self newOldSpaceObjectWithSlots: 1.
youngObject := self newZeroSizedObject.
memory storePointer: 0 ofObject: oldObject withValue: youngObject.
Expand All @@ -662,13 +662,22 @@ VMPermanentSpaceMemoryTest >> testPermanentObjectPointingToYoungObjectIsRemovedW
self assert: (memory isRemembered: permanentObject).
self assert: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject ).

memory storePointer: 0 ofObject: permanentObject withValue: 16.
"We allocate some memory in the codeZone.
Also we set the null header for the machineCodeMethods, this is used to threat references to it as other objects.
For example, check the header to see if it is a forwarder, a machine code method is never a forwarder."

fakeMachineCodeMethod := (VMMemoryMapConfiguration forWordsize: wordSize) new codeZoneInitialAddress.
memory memoryManager allocate: 32 desiredPosition: fakeMachineCodeMethod.
memory unsignedLong64At: fakeMachineCodeMethod put: memory nullHeaderForMachineCodeMethod.

"We update the permanent object with the value as if it was a CompiledMethod with a corresponding MachineCodeMethod"
memory storePointer: 0 ofObject: permanentObject withValue: fakeMachineCodeMethod.

memory doScavenge: 1.

self deny: (memory isRemembered: permanentObject).
self deny: (memory getFromPermToNewSpaceRememberedSet isInRememberedSet: permanentObject ).

self assert: (memory fetchPointer: 0 ofObject: permanentObject ) equals: fakeMachineCodeMethod.
]

{ #category : #'test - moving' }
Expand Down

0 comments on commit 46aa062

Please sign in to comment.