Problem with InstructionPrinter?

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

Problem with InstructionPrinter?

jamesl
Hi All,

InstructionPrinter printInstructionsOn: doesnt print anything for variable accessor methods.
Is this correct and expected?

I have a class with an instance variable called 'first' and I have a method called 'first'
which simply answers the instance variable.

first
^ first

When I dump the bytecode for this I get nothing.

However, when I add the following to the method the result is as expect, ie:
the instance variable is answered.

first
  |x|
  x := 1.
  ^ first

13 <76> pushConstant: 1
14 <68> popIntoTemp: 0
15 <00> pushRcvr: 0
16 <7C> returnTop

Why is there no bytecode for the simpler case?

Rgs, James.

_______________________________________________
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: Problem with InstructionPrinter?

Levente Uzonyi-2
On Tue, 3 Aug 2010, James Ladd wrote:

>
> Hi All,
>
> InstructionPrinter printInstructionsOn: doesnt print anything for variable accessor methods.
> Is this correct and expected?
>
> I have a class with an instance variable called 'first' and I have a method called 'first'
> which simply answers the instance variable.
>
> first
> ^ first
>
> When I dump the bytecode for this I get nothing.
>
> However, when I add the following to the method the result is as expect, ie:
> the instance variable is answered.
>
> first
>  |x|
>  x := 1.
>  ^ first
>
> 13 <76> pushConstant: 1
>
> 14 <68> popIntoTemp: 0
> 15 <00> pushRcvr: 0
>
> 16 <7C> returnTop
>
> Why is there no bytecode for the simpler case?

Because there are special primitives for that. Try this:

String streamContents: [ :stream |
  (YourClass >> #first) longPrintOn: stream indent: 0 ].


Levente


>
> Rgs, James.
>

_______________________________________________
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: Problem with InstructionPrinter?

jamesl
In reply to this post by jamesl
Is that example the recommended way to see a dump of the bytecodes for a method?
 
> Because there are special primitives for that. Try this:
>
> String streamContents: [ :stream |
> (YourClass >> #first) longPrintOn: stream indent: 0 ].
>
>
> Levente


_______________________________________________
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: Problem with InstructionPrinter?

Levente Uzonyi-2
On Tue, 3 Aug 2010, James Ladd wrote:

>
> Is that example the recommended way to see a dump of the bytecodes for a method?

Yes, but you can also explore the CompiledMethod to see it in a structured
form.


Levente

>
>
>
>> Because there are special primitives for that. Try this:
>>
>> String streamContents: [ :stream |
>> (YourClass >> #first) longPrintOn: stream indent: 0 ].
>>
>>
>> Levente
>
>

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