Tracing back objects

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

Tracing back objects

K. K. Subramaniam
Hi,

The following code:
 CompiledMethod allInstances inject: (CompiledMethod allInstances first) into:
[:m :i | i size > m size ifTrue: [i] ifFalse: [m]].

gives the largest method as an object. Is there an efficient way to trace back
the method selector and its class without doing a brute force lookup?

TIA .. Subbu
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Tracing back objects

Klaus D. Witzel
On Fri, 25 May 2007 12:18:38 +0200, subbukk wrote:

> Hi,
>
> The following code:
>  CompiledMethod allInstances inject: (CompiledMethod allInstances first)  
> into:
> [:m :i | i size > m size ifTrue: [i] ifFalse: [m]].
>
> gives the largest method as an object. Is there an efficient way to  
> trace back
> the method selector and its class without doing a brute force lookup?

On pre-traits images you'd need (aMethod who) but from 3.9 on #who is  
deprecated. If you're on 3.9 the comment in #who tells the fast way.

/Klaus

> TIA .. Subbu


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Tracing back objects

Bert Freudenberg
In reply to this post by K. K. Subramaniam

On May 25, 2007, at 12:18 , subbukk wrote:

> Hi,
>
> The following code:
>  CompiledMethod allInstances inject: (CompiledMethod allInstances  
> first) into:
> [:m :i | i size > m size ifTrue: [i] ifFalse: [m]].
>
> gives the largest method as an object.

Note that

        CompiledMethod someInstance

is much more efficient than

        CompiledMethod allInstances first

> Is there an efficient way to trace back
> the method selector and its class without doing a brute force lookup?

Not in 3.8, but I think later versions might cache the owner of CMs.  
Anyway, you might want to try this:

(CompiledMethod allInstances detectMax: [:m | m size]) who


- Bert -


_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners
Reply | Threaded
Open this post in threaded view
|

Re: Re: Tracing back objects

K. K. Subramaniam
In reply to this post by Klaus D. Witzel
On Friday 25 May 2007 5:02 pm, Klaus D. Witzel wrote:
> On pre-traits images you'd need (aMethod who) but from 3.9 on #who is
> deprecated. If you're on 3.9 the comment in #who tells the fast way.

Thanks. methodClass and selector worked. .. Subbu
_______________________________________________
Beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/beginners