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

Clean method removal of RPackage #14360

Merged
merged 2 commits into from Jul 26, 2023

Conversation

jecisc
Copy link
Member

@jecisc jecisc commented Jul 24, 2023

This is a first step at the cleaning of the method removal of RPackage.

This is still quite bad but it is a first step a cleaning this. The change make the method removal work as the method addition and reduces the usage of the cache variables of RPackage a little. My mid term goal is to kill some of those caches.

This is a first step at the cleaning of the method removal of RPackage. 

This is still quite bad but it is a first step a cleaning this. The change make the method removal work as the method addition and reduces the usage of the cache variables of RPackage a little. My mid term goal is to kill some of those caches.
@jecisc jecisc added the Status: Need more work The issue is nearly ready. Waiting some last bits. label Jul 24, 2023
@jecisc jecisc added Status: Tests passed please review! and removed Status: Need more work The issue is nearly ready. Waiting some last bits. labels Jul 25, 2023
@Ducasse Ducasse merged commit b6fa1ab into pharo-project:Pharo12 Jul 26, 2023
1 of 2 checks passed
@jecisc jecisc deleted the clean-method-removal branch July 26, 2023 13:21
Copy link
Collaborator

@PalumboN PalumboN left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some comments during merging :P

Comment on lines +1197 to +1204
ifTrue: [
metaclassDefinedSelectors at: methodClass instanceSide originalName ifPresent: [ :methods |
methods remove: aCompiledMethod selector ifAbsent: [ ].
methods ifEmpty: [ metaclassDefinedSelectors removeKey: methodClass instanceSide originalName ] ] ]
ifFalse: [
classDefinedSelectors at: methodClass originalName ifPresent: [ :methods |
methods remove: aCompiledMethod selector ifAbsent: [ ].
methods ifEmpty: [ classDefinedSelectors removeKey: methodClass originalName ] ] ] ]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On add is used name as key, but here is using originalName. What's the difference?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The difference happens with ObsoleteClasses. #name will return the obsolete name while #originalName will return the name of the class when it was not obsolete.

In the end I would like to have real classes instead of class names in the caches so that we do not have to care about that (and so that we do not have to cast them each time we want a class)

Comment on lines +1206 to +1214
methodClass isMeta
ifTrue: [
metaclassExtensionSelectors at: methodClass instanceSide originalName ifPresent: [ :methods |
methods remove: aCompiledMethod selector ifAbsent: [ ].
methods ifEmpty: [ metaclassExtensionSelectors removeKey: methodClass instanceSide originalName ] ] ]
ifFalse: [
classExtensionSelectors at: methodClass originalName ifPresent: [ :methods |
methods remove: aCompiledMethod selector ifAbsent: [ ].
methods ifEmpty: [ classExtensionSelectors removeKey: methodClass originalName ] ] ] ].
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should be nice to hide and reuse the use of the cache in both methods.

Maybe delegating to methods

self cacheFor: methodClass ifPresent: [ .. ]
self cacheFor: methodClass ifAbsent: [ .. ]

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm planning to kill some of those caches. For now I'm trying to make the code simpler so that I can do my changes.

I also want to merge the class and metaclass caches because it's a bother to always check the #isMeta to call two different methods. Once this is done, I'll see if we can improve further the use of the extension selectors :)
This beast is pretty huge and I'm trying to simplify little by little because each change has a lot of impacts ahah

methods ifEmpty: [ classExtensionSelectors removeKey: methodClass originalName ] ] ] ].

((metaclassExtensionSelectors at: methodClass instanceSide originalName ifAbsent: [ #( ) ]) isEmpty and: [
(classExtensionSelectors at: methodClass instanceSide originalName ifAbsent: [ #( ) ]) isEmpty ]) ifTrue: [
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

classExtensionSelectors is using methodClass originalName (or name) as key.

Copy-paste issue?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no issue because here we are in the #ifFalse: of methodClass isMeta so we know we already have the instance side.

But as I said in another comment, I would like to remove the meta/non meta management to use one unified way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants