theseion / Fuel

Fuel, the Smalltalk object serializer
https://theseion.github.io/Fuel
MIT License
26 stars 12 forks source link

[Pharo11] We now have Ephemerons in Pharo11 #272

Closed MarcusDenker closed 8 months ago

MarcusDenker commented 1 year ago

Pharo11 now implemens Ephemerons and uses it to implement Weak datastructures.

Fuel seems to not support serializing them.

I would implement this by forwarding to the Class Layout, but of course Fuel can no do that because it wants to be source level backward compatible to systems that do not have the class layout hierarchy...

fuelAccept: aGeneralMapper

    "Be careful because the order is important. For example, weak are also variable, but we need that weak objects send #visitWeakObject: and not #visitVariableObject: "
    self class isFixed
        ifTrue: [ ^ aGeneralMapper visitFixedObject: self ].
    self class isWeak
        ifTrue: [ ^ aGeneralMapper visitWeakObject: self ].
    self class isPointers
        ifTrue: [ ^ aGeneralMapper visitVariableObject: self ].
    self class isBytes
        ifTrue: [ ^ aGeneralMapper visitBytesObject: self ].
    self class isWords
        ifTrue: [   ^ aGeneralMapper visitWordsObject: self ].
    self error: 'Something is wrong!'
stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will remain open but will probably not come into focus. If you still think this should receive some attention, leave a comment. Thank you for your contributions.

stale[bot] commented 11 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will remain open but will probably not come into focus. If you still think this should receive some attention, leave a comment. Thank you for your contributions.

tinchodias commented 11 months ago

There is FLPlatform current that returns e.g. an instance of FLPharo11Platform, or the corresponding one. What should be moved there to support ephemerons?

theseion commented 10 months ago

@tinchodias, same here, Fuel-Platform is no longer in Pharo 12+. We can implement this however we want.

stale[bot] commented 8 months ago

This issue has been automatically marked as stale because it has not had recent activity. It will remain open but will probably not come into focus. If you still think this should receive some attention, leave a comment. Thank you for your contributions.

tinchodias commented 8 months ago

I'm still not familiar with the ephemerons. I see in my Pharo 12 image:

Smalltalk allClasses select: [ :each | each isEphemeronClass ]
">>> an OrderedCollection(FinalizationRegistryEntry IllEphemeron WeakKeyAssociation)"

I'm not sure what should fuel serializer do when it finds an instance of those classes.

For example:

Association << #FinalizationRegistryEntry
    layout: EphemeronLayout;
    slots: { #container . #link };
    tag: 'Registry';
    package: 'System-Finalization'

Probably it should serialize ignore what is referenced in container and link slots.

The implementation for the variable weak objects was ignoring the objects pointed from the variable slots, but not serializing the fixed slots as if it was a regular object.

theseion commented 8 months ago

I think we can handle Ephemerons the same way we do weak classes: attempt to serialize the references (might be nil during serialization if the GC has kicked in), making sure not to collect the references into a collection that references the key strongly.

theseion commented 8 months ago

I've updated the Pharo12 branch to delegate cluster determination to the class layout. Now we can implement support for ephemerons.

theseion commented 8 months ago

@tinchodias @MarcusDenker https://github.com/pharo-project/pharo/pull/15563