Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

become primitive does not support objects in PermSpace #815

Open
PalumboN opened this issue Jun 15, 2024 · 0 comments
Open

become primitive does not support objects in PermSpace #815

PalumboN opened this issue Jun 15, 2024 · 0 comments
Labels
bug Something isn't working perm-space

Comments

@PalumboN
Copy link
Collaborator

I'm running some benchmarks using the PermSpace and I get an error running the tests in Kernel.* packages.

I moved all classes using following these instructions.

Then you can run

ObjectsAsMethodsTest suite debug

And you get a primitive error for elementsForwardIdentityTo:.

➜  latest10 git:(server) ✗ ./Pharo.app/Contents/MacOS/Pharo ../../images/p11-classes-permi/p11-classes-permi.image eval "ObjectsAsMethodsTest suite debug"
PrimitiveFailed: primitive #elementsForwardIdentityTo: in Array failed
Array(ProtoObject)>>primitiveFailed:
Array(ProtoObject)>>primitiveFailed
Array>>elementsForwardIdentityTo:
MethodDictionary(ProtoObject)>>becomeForward:
MethodDictionary>>grow
MethodDictionary(HashedCollection)>>fullCheck
MethodDictionary>>at:put:
ObjectsAsMethodsTest class(Behavior)>>addSelectorSilently:withMethod:
ObjectsAsMethodsTest class(ClassDescription)>>addSelectorSilently:withMethod:
ObjectsAsMethodsTest class(ClassDescription)>>addSelector:withMethod:

Checking the GC code about becoming objects, there is a check for the case that an object is in the old space and the other in the new space using the OldBecameNewFlag.
Probably (I didn't debug it) a check for the permanent space is missing there.

Here

{ #category : #'become implementation' }
SpurMemoryManager >> doBecome: obj1 to: obj2 copyHash: copyHashFlag [
"one-way become with or without copying obj1's hash into obj2.
Straight-forward, even for classes. With classes we end up with two entries
for obj2. Which is current depends on copyHashFlag. If copyHashFlag is true
then the entry at obj1's hash is valid, otherwise the the existing one at obj2's
hash. When all the instances with the old hash have been collected, the GC will
discover this and expunge obj2 at the unused index (see markAndTraceClassOf:)."
self forward: obj1 to: obj2.
copyHashFlag ifTrue: [self setHashBitsOf: obj2 to: (self rawHashBitsOf: obj1)].
((memoryMap isOldObject: obj1)
and: [self isYoung: obj2]) ifTrue:
[becomeEffectsFlags := becomeEffectsFlags bitOr: OldBecameNewFlag].
self deny: (self isOopForwarded: obj2)
]

And here

{ #category : #'become implementation' }
SpurMemoryManager >> outOfPlaceBecome: obj1 and: obj2 copyHashFlag: copyHashFlag [
<inline: #never> "in an effort to fix a compiler bug with two-way become post r3427"
"Allocate two new objects, n1 & n2. Copy the contents appropriately. Convert
obj1 and obj2 into forwarding objects pointing to n2 and n1 respectively"
| clone1 clone2 |
clone1 := (self isContextNonImm: obj1)
ifTrue: [coInterpreter cloneContext: obj1]
ifFalse: [self clone: obj1].
clone1 ifNil: [ self error: 'Not enough space to copy the objects in two-way become. This should have been detected before'. ^ self].
clone2 := (self isContextNonImm: obj2)
ifTrue: [coInterpreter cloneContext: obj2]
ifFalse: [self clone: obj2].
clone2 ifNil: [ self error: 'Not enough space to copy the objects in two-way become. This should have been detected before'.^ self ].
(self isObjImmutable: obj1) ifTrue:
[self setIsImmutableOf: clone1 to: true].
(self isObjImmutable: obj2) ifTrue:
[self setIsImmutableOf: clone2 to: true].
copyHashFlag
ifTrue:
[self setHashBitsOf: clone1 to: (self rawHashBitsOf: obj1).
self setHashBitsOf: clone2 to: (self rawHashBitsOf: obj2)]
ifFalse:
[self setHashBitsOf: clone1 to: (self rawHashBitsOf: obj2).
self setHashBitsOf: clone2 to: (self rawHashBitsOf: obj1)].
self
forward: obj1 to: clone2;
forward: obj2 to: clone1.
((memoryMap isYoungObject: obj1) ~= (memoryMap isYoungObject: clone2)
or: [(memoryMap isYoungObject: obj2) ~= (memoryMap isYoungObject: clone1)]) ifTrue:
[becomeEffectsFlags := becomeEffectsFlags bitOr: OldBecameNewFlag]
]

@PalumboN PalumboN added bug Something isn't working perm-space labels Jun 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working perm-space
Projects
None yet
Development

No branches or pull requests

1 participant