Bug in EncoderForSistaV1

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

Bug in EncoderForSistaV1

marcel.taeumel
Hi, there.

The encoder for Sista cannot tell about references to instance variables that are behind compiled blocks.

Object subclass: #MyExampleClass
instanceVariableNames: 'field'
...
MyExampleClass >> #foobar
   ^ [field] value

This is the problem:

(MyExampleClass >> #foobar) readsField: 1.  "false"

Works fine if:

MyExampleClass >> #foobar
   ^ field

I don't feel able to fix that bug here:

EncoderForSistaV1 >> instVarReadScanBlockFor: varIndexCode using: scanner
"Answer a block argument for InstructionStream>>scanFor: that answers true
for reads of the inst var with zero-relative index varIndexCode.
N.B. Don't assume the compiler uses the most compact encoding available."

" 0-15 0000 i i i i Push Receiver Variable #iiii
* 224 11100000 aaaaaaaa Extend A (Ext A = Ext A prev * 256 + Ext A)
* 226 11100010 i i i i i i i i Push Receiver Variable #iiiiiiii (+ Extend A * 256)"
| extension |
extension := 0.
^[:b| | prevext |
  prevext := extension.
  extension := b = 224 ifTrue: [scanner followingByte bitShift: 8] ifFalse: [0].
  (b < 16 and: [b = varIndexCode])
   or: [b = 226
and: [scanner followingByte + prevext = varIndexCode]]]

Volunteers? :-)

Best,
Marcel


Reply | Threaded
Open this post in threaded view
|

Re: Bug in EncoderForSistaV1

marcel.taeumel
Maybe the bug is in CompiledMethod >> #readsField:? It might have to traverse
CompiledBlock in literals? Same for #writesField:? If so, I might be able to
fix that...

Best,
Marcel


marcel.taeumel wrote

> Hi, there.
>
> The encoder for Sista cannot tell about references to instance variables
> that are behind compiled blocks.
>
> Object subclass: #MyExampleClass
> instanceVariableNames: 'field'
> ...
> MyExampleClass >> #foobar
>    ^ [field] value
>
> This is the problem:
>
> (MyExampleClass >> #foobar) readsField: 1.  "false"
>
> Works fine if:
>
> MyExampleClass >> #foobar
>    ^ field
>
> I don't feel able to fix that bug here:
>
> EncoderForSistaV1 >> instVarReadScanBlockFor: varIndexCode using: scanner
> "Answer a block argument for InstructionStream>>scanFor: that answers true
> for reads of the inst var with zero-relative index varIndexCode.
> N.B. Don't assume the compiler uses the most compact encoding available."
>
> " 0-15 0000 i i i i Push Receiver Variable #iiii
> * 224 11100000 aaaaaaaa Extend A (Ext A = Ext A prev * 256 + Ext A)
> * 226 11100010 i i i i i i i i Push Receiver Variable #iiiiiiii (+ Extend
> A * 256)"
> | extension |
> extension := 0.
> ^[:b| | prevext |
>   prevext := extension.
>   extension := b = 224 ifTrue: [scanner followingByte bitShift: 8]
> ifFalse: [0].
>   (b < 16 and: [b = varIndexCode])
>    or: [b = 226
> and: [scanner followingByte + prevext = varIndexCode]]]
>
> Volunteers? :-)
>
> Best,
> Marcel





--
Sent from: http://forum.world.st/Squeak-Dev-f45488.html