(EventSensor>>#eventTickler) decompile bug

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

(EventSensor>>#eventTickler) decompile bug

Nicolas Cellier
I think I narrowed a bit the offending code:

eventTickler2
        "For debugging Decompiler"
        [| delta |
        [delta := true] yourself.
        delta ] whileTrue.

(EventSensor>>#eventTickler2) decompile
 eventTickler2
        [[_r1 := true] yourself.
        _r1] whileTrue


17 <8A 01> push: (Array new: 1)
19 <68> popIntoTemp: 0
20 <10> pushTemp: 0
21 <8F 10 00 05> closureNumCopied: 1 numArgs: 0 bytes 25 to 29
25 <71> pushConstant: true
26 <8D 00 00> storeIntoTemp: 0 inVectorAt: 0
29 <7D> blockReturn
30 <D0> send: yourself
31 <87> pop
32 <8C 00 00> pushTemp: 0 inVectorAt: 0
35 <99> jumpFalse: 38
36 <A3 EB> jumpTo: 17
38 <78> returnSelf


All is well untill Decompiler tries to interpret instruction 35 <99>
jumpFalse: 38
We enter Decompiler>>#jump:if:
...snip...
        "if jump goes back, then it's a loop"
        thenJump < elseStart
                ifTrue:
                        ["Must be a while loop...
                          thenJump will jump to the beginning of the while expr.  In the
case of while's
                          with a block in the condition, the while expr should include more than just
                          the last expression: find all the statements needed by re-decompiling."
                        stack := saveStack.
                        pc := thenJump.
                        blockBody := self statementsTo: elsePc.
We go back and reinterpret what we already interpreted... But this
time we already get a RemoteTempVectorNode in the tempVars...
And we are gonna create a RemoteTempVectorNode  on a
RemoteTempVectorNode next time we interpret the closure byte code 17
<8A 01> push: (Array new: 1)...
So the second pass will decompile _r1 instead of t1...

I don't feel like correcting the monster  Decompiler>>#jump:if:
Maybe I will just set a tweak in RemoteTempVectorNode creation...

Nicolas

Reply | Threaded
Open this post in threaded view
|

Re: (EventSensor>>#eventTickler) decompile bug

Eliot Miranda-2
Hi Nicolas,

    this is fixed in my working image.  I'll try and move changes into trunk later this week.  There are also some compiler fixes for nilling block-local temps tat need to be included (i.e. in the below delta should have the value nil before the assignment, not the value it had from the previous iteration).  But I can't get to it right now.

best
Eliot

On Tue, Mar 2, 2010 at 2:17 PM, Nicolas Cellier <[hidden email]> wrote:
I think I narrowed a bit the offending code:

eventTickler2
       "For debugging Decompiler"
       [| delta |
       [delta := true] yourself.
       delta ] whileTrue.

(EventSensor>>#eventTickler2) decompile
 eventTickler2
       [[_r1 := true] yourself.
       _r1] whileTrue


17 <8A 01> push: (Array new: 1)
19 <68> popIntoTemp: 0
20 <10> pushTemp: 0
21 <8F 10 00 05> closureNumCopied: 1 numArgs: 0 bytes 25 to 29
25      <71> pushConstant: true
26      <8D 00 00> storeIntoTemp: 0 inVectorAt: 0
29      <7D> blockReturn
30 <D0> send: yourself
31 <87> pop
32 <8C 00 00> pushTemp: 0 inVectorAt: 0
35 <99> jumpFalse: 38
36 <A3 EB> jumpTo: 17
38 <78> returnSelf


All is well untill Decompiler tries to interpret instruction 35 <99>
jumpFalse: 38
We enter Decompiler>>#jump:if:
...snip...
       "if jump goes back, then it's a loop"
       thenJump < elseStart
               ifTrue:
                       ["Must be a while loop...
                         thenJump will jump to the beginning of the while expr.  In the
case of while's
                         with a block in the condition, the while expr should include more than just
                         the last expression: find all the statements needed by re-decompiling."
                       stack := saveStack.
                       pc := thenJump.
                       blockBody := self statementsTo: elsePc.
We go back and reinterpret what we already interpreted... But this
time we already get a RemoteTempVectorNode in the tempVars...
And we are gonna create a RemoteTempVectorNode  on a
RemoteTempVectorNode next time we interpret the closure byte code 17
<8A 01> push: (Array new: 1)...
So the second pass will decompile _r1 instead of t1...

I don't feel like correcting the monster  Decompiler>>#jump:if:
Maybe I will just set a tweak in RemoteTempVectorNode creation...

Nicolas




Reply | Threaded
Open this post in threaded view
|

Re: (EventSensor>>#eventTickler) decompile bug

Nicolas Cellier
Thanks!
I might have used big artillery : mapping statements to start pc.
But I prefer not to interfer too deeply.

Nicolas

2010/3/2 Eliot Miranda <[hidden email]>:

> Hi Nicolas,
>     this is fixed in my working image.  I'll try and move changes into trunk
> later this week.  There are also some compiler fixes for nilling block-local
> temps tat need to be included (i.e. in the below delta should have the value
> nil before the assignment, not the value it had from the previous
> iteration).  But I can't get to it right now.
> best
> Eliot
>
> On Tue, Mar 2, 2010 at 2:17 PM, Nicolas Cellier
> <[hidden email]> wrote:
>>
>> I think I narrowed a bit the offending code:
>>
>> eventTickler2
>>        "For debugging Decompiler"
>>        [| delta |
>>        [delta := true] yourself.
>>        delta ] whileTrue.
>>
>> (EventSensor>>#eventTickler2) decompile
>>  eventTickler2
>>        [[_r1 := true] yourself.
>>        _r1] whileTrue
>>
>>
>> 17 <8A 01> push: (Array new: 1)
>> 19 <68> popIntoTemp: 0
>> 20 <10> pushTemp: 0
>> 21 <8F 10 00 05> closureNumCopied: 1 numArgs: 0 bytes 25 to 29
>> 25      <71> pushConstant: true
>> 26      <8D 00 00> storeIntoTemp: 0 inVectorAt: 0
>> 29      <7D> blockReturn
>> 30 <D0> send: yourself
>> 31 <87> pop
>> 32 <8C 00 00> pushTemp: 0 inVectorAt: 0
>> 35 <99> jumpFalse: 38
>> 36 <A3 EB> jumpTo: 17
>> 38 <78> returnSelf
>>
>>
>> All is well untill Decompiler tries to interpret instruction 35 <99>
>> jumpFalse: 38
>> We enter Decompiler>>#jump:if:
>> ...snip...
>>        "if jump goes back, then it's a loop"
>>        thenJump < elseStart
>>                ifTrue:
>>                        ["Must be a while loop...
>>                          thenJump will jump to the beginning of the while
>> expr.  In the
>> case of while's
>>                          with a block in the condition, the while expr
>> should include more than just
>>                          the last expression: find all the statements
>> needed by re-decompiling."
>>                        stack := saveStack.
>>                        pc := thenJump.
>>                        blockBody := self statementsTo: elsePc.
>> We go back and reinterpret what we already interpreted... But this
>> time we already get a RemoteTempVectorNode in the tempVars...
>> And we are gonna create a RemoteTempVectorNode  on a
>> RemoteTempVectorNode next time we interpret the closure byte code 17
>> <8A 01> push: (Array new: 1)...
>> So the second pass will decompile _r1 instead of t1...
>>
>> I don't feel like correcting the monster  Decompiler>>#jump:if:
>> Maybe I will just set a tweak in RemoteTempVectorNode creation...
>>
>> Nicolas
>>
>
>
>
>
>