Getting all senders of a CompiledMethod, best solution ?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
5 messages Options
Reply | Threaded
Open this post in threaded view
|

Getting all senders of a CompiledMethod, best solution ?

laurent laffont
Hi,

I have this method in AutotestFinder, I don't like it, someone has better code ?

AutotestFinder>>allSendersOf: aCompiledMethod
     "Returns all senders as a collection of CompiledMethod"
| methodReferences senders |
methodReferences := (SystemNavigation default allSendersOf: aCompiledMethod selector).
senders := methodReferences collect: 
[:aMethodReference | 
aMethodReference actualClass
lookupSelector: aMethodReference selector].
^ senders select: [:sender| sender isNil not]. "Why senders contains nil sometimes ?"

What it does:

AutotestFinder new allSendersOf:  (ProfStef lookupSelector: #go) 

answers:

an OrderedCollection((ProfStef>>#go "a CompiledMethod(10485760)") (ProtoObject>>#initialize "a CompiledMethod(326631424)") (ProfStef class>>#go "a CompiledMethod(49807360)") (ProfStef class>>#initialize "a CompiledMethod(1060634624)") (ProfStefBrowser class>>#menuCommandOn: "a CompiledMethod(340262912)") (ProfStefTestGo>>#testGoOpenSmalltalkSyntaxTutorial "a CompiledMethod(249823232)"))

Cheers,

_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Getting all senders of a CompiledMethod, best solution ?

laurent laffont
Any hacker to start a code kata  here ? :)

Laurent 

On Fri, Jun 18, 2010 at 6:33 PM, laurent laffont <[hidden email]> wrote:
Hi,

I have this method in AutotestFinder, I don't like it, someone has better code ?

AutotestFinder>>allSendersOf: aCompiledMethod
     "Returns all senders as a collection of CompiledMethod"
| methodReferences senders |
methodReferences := (SystemNavigation default allSendersOf: aCompiledMethod selector).
senders := methodReferences collect: 
[:aMethodReference | 
aMethodReference actualClass
lookupSelector: aMethodReference selector].
^ senders select: [:sender| sender isNil not]. "Why senders contains nil sometimes ?"

What it does:

AutotestFinder new allSendersOf:  (ProfStef lookupSelector: #go) 

answers:

an OrderedCollection((ProfStef>>#go "a CompiledMethod(10485760)") (ProtoObject>>#initialize "a CompiledMethod(326631424)") (ProfStef class>>#go "a CompiledMethod(49807360)") (ProfStef class>>#initialize "a CompiledMethod(1060634624)") (ProfStefBrowser class>>#menuCommandOn: "a CompiledMethod(340262912)") (ProfStefTestGo>>#testGoOpenSmalltalkSyntaxTutorial "a CompiledMethod(249823232)"))

Cheers,


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Getting all senders of a CompiledMethod, best solution ?

Stéphane Ducasse
may be defining a method
        aMethodReference actualClass lookupSelector: aMethodReference selector
on methodReference would laready help

Stef

On Jun 22, 2010, at 8:10 AM, laurent laffont wrote:

> Any hacker to start a code kata  here ? :)
>
> Laurent
>
> On Fri, Jun 18, 2010 at 6:33 PM, laurent laffont <[hidden email]> wrote:
> Hi,
>
> I have this method in AutotestFinder, I don't like it, someone has better code ?
>
> AutotestFinder>>allSendersOf: aCompiledMethod
>      "Returns all senders as a collection of CompiledMethod"
> | methodReferences senders |
> methodReferences := (SystemNavigation default allSendersOf: aCompiledMethod selector).
> senders := methodReferences collect:
> [:aMethodReference |
> aMethodReference actualClass
> lookupSelector: aMethodReference selector].
> ^ senders select: [:sender| sender isNil not]. "Why senders contains nil sometimes ?"
>
> What it does:
>
> AutotestFinder new allSendersOf:  (ProfStef lookupSelector: #go)
>
> answers:
>
> an OrderedCollection((ProfStef>>#go "a CompiledMethod(10485760)") (ProtoObject>>#initialize "a CompiledMethod(326631424)") (ProfStef class>>#go "a CompiledMethod(49807360)") (ProfStef class>>#initialize "a CompiledMethod(1060634624)") (ProfStefBrowser class>>#menuCommandOn: "a CompiledMethod(340262912)") (ProfStefTestGo>>#testGoOpenSmalltalkSyntaxTutorial "a CompiledMethod(249823232)"))
>
> Cheers,
>
> Laurent Laffont
>
> http://pharocasts.blogspot.com/
> http://magaloma.blogspot.com/
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Getting all senders of a CompiledMethod, best solution ?

laurent laffont


On Tue, Jun 22, 2010 at 8:35 AM, Stéphane Ducasse <[hidden email]> wrote:
may be defining a method
       aMethodReference actualClass lookupSelector: aMethodReference selector
on methodReference would laready help

Thanks. Adding

CompiledMethod>>allSenders
  ^ SystemNavigation default allSendersOf: self selector

is OK too ?

Laurent
 

Stef

On Jun 22, 2010, at 8:10 AM, laurent laffont wrote:

> Any hacker to start a code kata  here ? :)
>
> Laurent
>
> On Fri, Jun 18, 2010 at 6:33 PM, laurent laffont <[hidden email]> wrote:
> Hi,
>
> I have this method in AutotestFinder, I don't like it, someone has better code ?
>
> AutotestFinder>>allSendersOf: aCompiledMethod
>      "Returns all senders as a collection of CompiledMethod"
>       | methodReferences senders |
>       methodReferences := (SystemNavigation default allSendersOf: aCompiledMethod selector).
>       senders := methodReferences collect:
>                                       [:aMethodReference |
>                                        aMethodReference actualClass
>                                                       lookupSelector: aMethodReference selector].
>       ^ senders select: [:sender| sender isNil not]. "Why senders contains nil sometimes ?"
>
> What it does:
>
> AutotestFinder new allSendersOf:  (ProfStef lookupSelector: #go)
>
> answers:
>
> an OrderedCollection((ProfStef>>#go "a CompiledMethod(10485760)") (ProtoObject>>#initialize "a CompiledMethod(326631424)") (ProfStef class>>#go "a CompiledMethod(49807360)") (ProfStef class>>#initialize "a CompiledMethod(1060634624)") (ProfStefBrowser class>>#menuCommandOn: "a CompiledMethod(340262912)") (ProfStefTestGo>>#testGoOpenSmalltalkSyntaxTutorial "a CompiledMethod(249823232)"))
>
> Cheers,
>
> Laurent Laffont
>
> http://pharocasts.blogspot.com/
> http://magaloma.blogspot.com/
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
Reply | Threaded
Open this post in threaded view
|

Re: Getting all senders of a CompiledMethod, best solution ?

Stéphane Ducasse
> Thanks. Adding
>
> CompiledMethod>>allSenders
>   ^ SystemNavigation default allSendersOf: self selector


not in compiled method but methodreference
 or in method method extensions with the package that contains SystemNavigation (probably better solution)

Stef

>
> is OK too ?
>
> Laurent
>  
>
> Stef
>
> On Jun 22, 2010, at 8:10 AM, laurent laffont wrote:
>
> > Any hacker to start a code kata  here ? :)
> >
> > Laurent
> >
> > On Fri, Jun 18, 2010 at 6:33 PM, laurent laffont <[hidden email]> wrote:
> > Hi,
> >
> > I have this method in AutotestFinder, I don't like it, someone has better code ?
> >
> > AutotestFinder>>allSendersOf: aCompiledMethod
> >      "Returns all senders as a collection of CompiledMethod"
> >       | methodReferences senders |
> >       methodReferences := (SystemNavigation default allSendersOf: aCompiledMethod selector).
> >       senders := methodReferences collect:
> >                                       [:aMethodReference |
> >                                        aMethodReference actualClass
> >                                                       lookupSelector: aMethodReference selector].
> >       ^ senders select: [:sender| sender isNil not]. "Why senders contains nil sometimes ?"
> >
> > What it does:
> >
> > AutotestFinder new allSendersOf:  (ProfStef lookupSelector: #go)
> >
> > answers:
> >
> > an OrderedCollection((ProfStef>>#go "a CompiledMethod(10485760)") (ProtoObject>>#initialize "a CompiledMethod(326631424)") (ProfStef class>>#go "a CompiledMethod(49807360)") (ProfStef class>>#initialize "a CompiledMethod(1060634624)") (ProfStefBrowser class>>#menuCommandOn: "a CompiledMethod(340262912)") (ProfStefTestGo>>#testGoOpenSmalltalkSyntaxTutorial "a CompiledMethod(249823232)"))
> >
> > Cheers,
> >
> > Laurent Laffont
> >
> > http://pharocasts.blogspot.com/
> > http://magaloma.blogspot.com/
> >
> > _______________________________________________
> > Pharo-project mailing list
> > [hidden email]
> > http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project
>
> _______________________________________________
> Pharo-project mailing list
> [hidden email]
> http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project


_______________________________________________
Pharo-project mailing list
[hidden email]
http://lists.gforge.inria.fr/cgi-bin/mailman/listinfo/pharo-project