hasInstVarRef

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

hasInstVarRef

Bergel, Alexandre
Dear all,

Is this a bug?
(Point >> #x) hasInstVarRef ==> false

I haven't seen any related entry in http://bugs.squeak.org
Should I add it?

Cheers,
Alexandre

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: hasInstVarRef

Adrian Lienhard
Hi Alex,

In the image I have open right now, there is no #hasInstVarRef  
defined for CompiledMethod.
Maybe you are looking for (Point >> #x) readsField: 1 ==> true?

Cheers,
Adrian


On Sep 21, 2007, at 09:46 , Bergel, Alexandre wrote:

> Dear all,
>
> Is this a bug?
> (Point >> #x) hasInstVarRef ==> false
>
> I haven't seen any related entry in http://bugs.squeak.org
> Should I add it?
>
> Cheers,
> Alexandre
>
> --
> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
> Alexandre Bergel  http://www.bergel.eu
> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>
>
>
>


Reply | Threaded
Open this post in threaded view
|

Re: hasInstVarRef

Bergel, Alexandre
Hi Adrian,

I wish to know whether a compiled method references any variable.

Defined on CompiledMethod in Squeak-dev 7143:
-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=
md 4/27/2006 15:12 ¥ CompiledMethod ¥ scanning ¥ 3 implementors ¥ in  
no change set
hasInstVarRef
        "Answer whether the method references an instance variable."

        | scanner end printer |

        scanner _ InstructionStream on: self.
        printer _ InstVarRefLocator new.
        end _ self endPC.

        [scanner pc <= end] whileTrue: [
                (printer interpretNextInstructionUsing: scanner) ifTrue: [^true].
        ].
        ^false
-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=-=-=--=

Cheers,
Alexandre

On 21 Sep 2007, at 10:00, Adrian Lienhard wrote:

> Hi Alex,
>
> In the image I have open right now, there is no #hasInstVarRef  
> defined for CompiledMethod.
> Maybe you are looking for (Point >> #x) readsField: 1 ==> true?
>
> Cheers,
> Adrian
>
>
> On Sep 21, 2007, at 09:46 , Bergel, Alexandre wrote:
>
>> Dear all,
>>
>> Is this a bug?
>> (Point >> #x) hasInstVarRef ==> false
>>
>> I haven't seen any related entry in http://bugs.squeak.org
>> Should I add it?
>>
>> Cheers,
>> Alexandre
>>
>> --
>> _,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
>> Alexandre Bergel  http://www.bergel.eu
>> ^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.
>>
>>
>>
>>
>
>

--
_,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:
Alexandre Bergel  http://www.bergel.eu
^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;._,.;:~^~:;.




Reply | Threaded
Open this post in threaded view
|

Re: hasInstVarRef

Hans-Martin Mosner
Bergel, Alexandre wrote:
> Hi Adrian,
>
> I wish to know whether a compiled method references any variable.
The problem is that methods which just return the value of an instance
variable are compiled specially with a primitive index which corresponds
to the index of the instance variable plus some offset.
These methodes don't have ordinary bytecodes to read and return the
instance variable.
The implementation of #hasInstVarRef is incomplete, it should definitely
handle this case.

Cheers,
Hans-Martin

Reply | Threaded
Open this post in threaded view
|

Re: hasInstVarRef

Adrian Lienhard
ok, the image I was looking at didn't include the method in  
CompiledMethod.

On Sep 21, 2007, at 16:22 , Hans-Martin Mosner wrote:

> Bergel, Alexandre wrote:
>> Hi Adrian,
>>
>> I wish to know whether a compiled method references any variable.
> The problem is that methods which just return the value of an instance
> variable are compiled specially with a primitive index which  
> corresponds
> to the index of the instance variable plus some offset.
> These methodes don't have ordinary bytecodes to read and return the
> instance variable.
> The implementation of #hasInstVarRef is incomplete, it should  
> definitely
> handle this case.

Yep. Also, there's a duplication with CompiledMethod>>readsField:,  
which handles the quick return case correctly. In previous versions  
of Squeak, MethodContext implemented #hasInstVarRef but now it  
delegates to its method. While for a method context the  
implementation seems correct to me, it is not for a compiled method  
(as Alex has noted). I would revert the change and use #readsField:  
instead for CompiledMethods.

Cheers,
Adrian