Testing for CompiledMethod properties

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

Testing for CompiledMethod properties

Andres Fortier-2
Hi list,
         I need to check if the code of a compiled method matches some
criteria; in particular I would like to see if:

a. sends a message to its receiver (i.e. "self doSomething").
b. sends a message where the receiver is passed as an argument (i.e.
"anObject doSomething: self").
c. sends a message to its receiver by means of the super pseudovariable.

So far I've been able to detect this by using the ParseTreeSearcher, but
I'm looking for something that speeds things up a little, so I was
thinking in looking directly at the bytecodes. In the bytecodes doc (an
by inspecting a few compiled methods) it seems that:

1. OpLoadReceiver, OpPopLoadReceiver and OpSendSelf0 are the ones that I
should be looking for a) or b).

2. OpXSuper and OpXXSuper are the ones for c).

I've made some tests and it seems to work, but since I've never played
much with bytecodes I was wondering if someone with more experience in
this field could tell me if I am missing something.

Thanks in advance,
                  Andrés

Reply | Threaded
Open this post in threaded view
|

Re: Testing for CompiledMethod properties

Steve Aldred-3
Andres Fortier wrote:
> Hi list,
>         I need to check if the code of a compiled method matches some
> criteria; in particular I would like to see if:
>
> a. sends a message to its receiver (i.e. "self doSomething").
> b. sends a message where the receiver is passed as an argument (i.e.
> "anObject doSomething: self").
> c. sends a message to its receiver by means of the super pseudovariable.
> ...

Wouldn't the rewrite tools have code that does just that?

Reply | Threaded
Open this post in threaded view
|

Re: Testing for CompiledMethod properties

Andres Fortier-2
Hi Steve,
          I may be wrong, but AFAIK the rewrite tool uses
ParseTreeRewriter, which is what I'm trying to avoid.


Steve Aldred escribió:

> Andres Fortier wrote:
>> Hi list,
>>         I need to check if the code of a compiled method matches some
>> criteria; in particular I would like to see if:
>>
>> a. sends a message to its receiver (i.e. "self doSomething").
>> b. sends a message where the receiver is passed as an argument (i.e.
>> "anObject doSomething: self").
>> c. sends a message to its receiver by means of the super pseudovariable.
>> ...
>
> Wouldn't the rewrite tools have code that does just that?
>
>

Reply | Threaded
Open this post in threaded view
|

RE: Testing for CompiledMethod properties

Steven Kelly
In reply to this post by Andres Fortier-2
There are special bytecodes for a number of common messages, so be aware that you may miss some cases of a) - maybe even if the method is redefined in your class. This might also apply to c), I'm not sure.

I've not looked how MethodCollector works, but that might also contain useful stuff. See the examples in Help | System Workspace.

Steve

> -----Original Message-----
> From: Andres Fortier [mailto:[hidden email]]
> Sent: 11. helmikuuta 2008 21:43
> To: VWNC List
> Subject: Testing for CompiledMethod properties
>
>
> Hi list,
>          I need to check if the code of a compiled method
> matches some
> criteria; in particular I would like to see if:
>
> a. sends a message to its receiver (i.e. "self doSomething").
> b. sends a message where the receiver is passed as an argument (i.e.
> "anObject doSomething: self").
> c. sends a message to its receiver by means of the super
> pseudovariable.
>
> So far I've been able to detect this by using the
> ParseTreeSearcher, but
> I'm looking for something that speeds things up a little, so I was
> thinking in looking directly at the bytecodes. In the
> bytecodes doc (an
> by inspecting a few compiled methods) it seems that:
>
> 1. OpLoadReceiver, OpPopLoadReceiver and OpSendSelf0 are the
> ones that I
> should be looking for a) or b).
>
> 2. OpXSuper and OpXXSuper are the ones for c).
>
> I've made some tests and it seems to work, but since I've
> never played
> much with bytecodes I was wondering if someone with more
> experience in
> this field could tell me if I am missing something.
>
> Thanks in advance,
>          Andrés
>
>

Reply | Threaded
Open this post in threaded view
|

Re: Testing for CompiledMethod properties

Andres Fortier-2
Thanks Steven, I'll take a look to MethodCollector internals.

Cheers,
         Andrés

Steven Kelly escribió:

> There are special bytecodes for a number of common messages, so be aware that you may miss some cases of a) - maybe even if the method is redefined in your class. This might also apply to c), I'm not sure.
>
> I've not looked how MethodCollector works, but that might also contain useful stuff. See the examples in Help | System Workspace.
>
> Steve
>
>> -----Original Message-----
>> From: Andres Fortier [mailto:[hidden email]]
>> Sent: 11. helmikuuta 2008 21:43
>> To: VWNC List
>> Subject: Testing for CompiledMethod properties
>>
>>
>> Hi list,
>>          I need to check if the code of a compiled method
>> matches some
>> criteria; in particular I would like to see if:
>>
>> a. sends a message to its receiver (i.e. "self doSomething").
>> b. sends a message where the receiver is passed as an argument (i.e.
>> "anObject doSomething: self").
>> c. sends a message to its receiver by means of the super
>> pseudovariable.
>>
>> So far I've been able to detect this by using the
>> ParseTreeSearcher, but
>> I'm looking for something that speeds things up a little, so I was
>> thinking in looking directly at the bytecodes. In the
>> bytecodes doc (an
>> by inspecting a few compiled methods) it seems that:
>>
>> 1. OpLoadReceiver, OpPopLoadReceiver and OpSendSelf0 are the
>> ones that I
>> should be looking for a) or b).
>>
>> 2. OpXSuper and OpXXSuper are the ones for c).
>>
>> I've made some tests and it seems to work, but since I've
>> never played
>> much with bytecodes I was wondering if someone with more
>> experience in
>> this field could tell me if I am missing something.
>>
>> Thanks in advance,
>>          Andrés
>>
>>
>
>