[Pharo-project] About CompiledMethod category returning nil sometimes
Hi guys With cyrille we experience sometimes CompiledMethod with nil category and this can break hard some problem. We were thinking but not sure that it would be good to make sure that nil is not returned but 'as yet unclassified' What do you think? Do you have any idea of potential problem? Stef
Hi Stef. From what I can see, the category can be nil only when CompiledMethods are created for DoIts but not for regular CompiledMethods. Even those which are under 'as yet unclassified' answer that and not nil. (CompiledMethod allInstances select: [ :each | (each category isNil and: [(each selector beginsWith: #DoIt) not]) ]) size answers 0 in my image. (CompiledMethod allInstances select: [ :each | each category isNil ] thenCollect: [:each | each selector]) asSet -->> a Set(#DoIt #DoItIn:) So...only those guys answers nil. Is that important? If so, we already have the message: CompiledMethod >> isSelfEvaluating ^self methodClass notNil and: [(#(#DoIt #DoItIn: nil) includes: self selector) not] that answers false for those do its. Hence, we could patch to something like this: CompiledMethod >> category self isSelfEvaluating ifFalse: [^ 'evaluating']. ^self methodClass organization categoryOfElement:self selector There is another solution: the CM to answers its category delegates to "^self methodClass organization categoryOfElement:self selector" for do-its, the methodClass is always "UndefinedObject" So.....I can create a category called "evaluation" in UndefinedObject and put these two new methods: DoIt "When execution code from a workspace or similar places the Compiler creates a dummy CompiledMethod whose methodClass is UndefinedObject. When such CompiledMethods are ask its category, it answers nil, since the selector is search in the organization of the methodClass, which in this case is UndefinedObject. Hence, implementing this mehtod here will make such CompiledMethods to answer the category where this method is. " DoItIn: nonImportant "When execution code from a workspace or similar places the Compiler creates a dummy CompiledMethod whose methodClass is UndefinedObject. When such CompiledMethods are ask its category, it answers nil, since the selector is search in the organization of the methodClass, which in this case is UndefinedObject. Hence, implementing this mehtod here will make such CompiledMethods to answer the category where this method is. " So....now: (CompiledMethod allInstances select: [ :each | each isSelfEvaluating not ] thenCollect: [:each| each category ]) asSet --->a Set(#evaluation) I am not sure which of the both solution is the best nor the impact of them, Cheers Mariano On Mon, May 9, 2011 at 11:35 AM, Stéphane Ducasse <stephane.ducasse@inria.fr
wrote:
Hi guys
With cyrille we experience sometimes CompiledMethod with nil category and this can break hard some problem. We were thinking but not sure that it would be good to make sure that nil is not returned but 'as yet unclassified' What do you think? Do you have any idea of potential problem?
Stef
-- Mariano http://marianopeck.wordpress.com
2011/5/10 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi Stef. From what I can see, the category can be nil only when CompiledMethods are created for DoIts but not for regular CompiledMethods. Even those which are under 'as yet unclassified'Â answer that and not nil.
I think there are some .mcz-s flying around that cause a nil category on load - is that unrelated?
On Thu, May 12, 2011 at 3:53 PM, Markus Fritsche < fritsche.markus@googlemail.com> wrote:
2011/5/10 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi Stef. From what I can see, the category can be nil only when CompiledMethods are created for DoIts but not for regular CompiledMethods. Even those which are under 'as yet unclassified' answer that and not nil.
I think there are some .mcz-s flying around that cause a nil category on load - is that unrelated?
I have no idea. In my experiments, as I wrote, all CM with nil were with selector DoIt or DoItIn: Maybe in another image there are .mcz as you said which have those CM with nil also... -- Mariano http://marianopeck.wordpress.com
On May 12, 2011, at 3:53 PM, Markus Fritsche wrote:
2011/5/10 Mariano Martinez Peck <marianopeck@gmail.com>:
Hi Stef. From what I can see, the category can be nil only when CompiledMethods are created for DoIts but not for regular CompiledMethods. Even those which are under 'as yet unclassified' answer that and not nil.
I think there are some .mcz-s flying around that cause a nil category on load - is that unrelated?
yes this could be that.
participants (3)
-
Mariano Martinez Peck -
Markus Fritsche -
Stéphane Ducasse