Currently executing bytecodes?

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

Currently executing bytecodes?

André Wendt-3
 
Hi all,

I'm stumped by the main interpreter loop: As I can't seem to get my
hands on the currently executing bytecodes using the context-step
simulator (same issue as desribed in
<http://bugs.squeak.org/view.php?id=5716>), I thought I'd log them along
the way directly in the VM.

However, modifying the interpreter loop to:

while (1) {
        printNumtoFile(currentBytecode, foo->vmLogFile);
        switch (currentBytecode) {
        ..
        }
}

didn't work: printNumtoFile() gets executed exactly once. I've debugged
this with GDB: currentBytecode gets modified from within the CASE
statements and the program never gets past the switch() statement.

I wouldn't want to maintain the same code in all bytecode CASEs but I
can't think of another solution at the moment.

Is there any other way to examine the currently executing bytecodes
apart from the buggy ContextPart?

Thanks,
André
Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

Michael Haupt-3

Hi,

On 11/9/07, André Wendt <[hidden email]> wrote:

> However, modifying the interpreter loop to:
>
> while (1) {
>         printNumtoFile(currentBytecode, foo->vmLogFile);
>         switch (currentBytecode) {
>         ..
>         }
> }
>
> didn't work: printNumtoFile() gets executed exactly once. I've debugged
> this with GDB: currentBytecode gets modified from within the CASE
> statements and the program never gets past the switch() statement.

that's most certainly because you are using a GNUified version of the
interpreter (right?). That one applies threading to the interpreter
implementation, so the loop body is not actually executed like a loop
body usually is. Instead, interpreter logic jumps directly to and fro
in the bytecode routines.

Best,

Michael
Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

Mathieu SUEN

On Nov 9, 2007, at 1:13 PM, Michael Haupt wrote:

>
> Hi,
>
> On 11/9/07, André Wendt <[hidden email]> wrote:
>> However, modifying the interpreter loop to:
>>
>> while (1) {
>>         printNumtoFile(currentBytecode, foo->vmLogFile);
>>         switch (currentBytecode) {
>>         ..
>>         }
>> }
>>
>> didn't work: printNumtoFile() gets executed exactly once. I've  
>> debugged
>> this with GDB: currentBytecode gets modified from within the CASE
>> statements and the program never gets past the switch() statement.
>
> that's most certainly because you are using a GNUified version of the
> interpreter (right?). That one applies threading to the interpreter
> implementation, so the loop body is not actually executed like a loop
> body usually is. Instead, interpreter logic jumps directly to and fro
> in the bytecode routines.

Intresting could you explain how?
Also how to solve the problem?

>
> Best,
>
> Michael

        Mth

Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

André Wendt-3
In reply to this post by André Wendt-3
 
Michael Haupt wrote:

>  
> Hi,
>
> On 11/9/07, André Wendt <[hidden email]> wrote:
>> However, modifying the interpreter loop to:
>>
>> while (1) {
>>         printNumtoFile(currentBytecode, foo->vmLogFile);
>>         switch (currentBytecode) {
>>         ..
>>         }
>> }
>>
>> didn't work: printNumtoFile() gets executed exactly once. I've debugged
>> this with GDB: currentBytecode gets modified from within the CASE
>> statements and the program never gets past the switch() statement.
>
> that's most certainly because you are using a GNUified version of the
> interpreter (right?). That one applies threading to the interpreter
> implementation, so the loop body is not actually executed like a loop
> body usually is. Instead, interpreter logic jumps directly to and fro
> in the bytecode routines.

I see. Is there any way I can prevent 'make' to gnuify the source?

Andre
Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

Bert Freudenberg
In reply to this post by Mathieu SUEN


On Nov 9, 2007, at 14:10 , Mathieu Suen wrote:

>
> On Nov 9, 2007, at 1:13 PM, Michael Haupt wrote:
>
>>
>> Hi,
>>
>> On 11/9/07, André Wendt <[hidden email]> wrote:
>>> However, modifying the interpreter loop to:
>>>
>>> while (1) {
>>>         printNumtoFile(currentBytecode, foo->vmLogFile);
>>>         switch (currentBytecode) {
>>>         ..
>>>         }
>>> }
>>>
>>> didn't work: printNumtoFile() gets executed exactly once. I've  
>>> debugged
>>> this with GDB: currentBytecode gets modified from within the CASE
>>> statements and the program never gets past the switch() statement.
>>
>> that's most certainly because you are using a GNUified version of the
>> interpreter (right?). That one applies threading to the interpreter
>> implementation, so the loop body is not actually executed like a loop
>> body usually is. Instead, interpreter logic jumps directly to and fro
>> in the bytecode routines.
>
> Intresting could you explain how?

It replace each "case 123:" with a label and each "break" with "goto  
*jumpTable[currentBytecode]", and initializes the jumpTable with the  
labels.

> Also how to solve the problem?

Modify the BREAK macro in sqGnu.h.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

Bert Freudenberg
In reply to this post by André Wendt-3


On Nov 9, 2007, at 14:22 , André Wendt wrote:

>
> Michael Haupt wrote:
>>
>> Hi,
>>
>> On 11/9/07, André Wendt <[hidden email]> wrote:
>>> However, modifying the interpreter loop to:
>>>
>>> while (1) {
>>>         printNumtoFile(currentBytecode, foo->vmLogFile);
>>>         switch (currentBytecode) {
>>>         ..
>>>         }
>>> }
>>>
>>> didn't work: printNumtoFile() gets executed exactly once. I've  
>>> debugged
>>> this with GDB: currentBytecode gets modified from within the CASE
>>> statements and the program never gets past the switch() statement.
>>
>> that's most certainly because you are using a GNUified version of the
>> interpreter (right?). That one applies threading to the interpreter
>> implementation, so the loop body is not actually executed like a loop
>> body usually is. Instead, interpreter logic jumps directly to and fro
>> in the bytecode routines.
>
> I see. Is there any way I can prevent 'make' to gnuify the source?

You could hack vm/Makefile in your build dir (replace gnu-interp  
withh interp). Or, comment out AC_GNU_INTERP in configure.ac and  
remake and rerun the configure script.

- Bert -


Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

Michael Haupt-3
In reply to this post by Mathieu SUEN
 
Hi Mathieu,

On 11/9/07, Mathieu Suen <[hidden email]> wrote:
> Intresting could you explain how?

there is a nice paper co-authored by Ian that does a better job in
explaining this (and much more) than I possibly could given the little
time I have right now...
http://www.daimi.au.dk/~ups/OOVM/papers/piumarta-riccardi:threaded.pdf

The paper describes several flavours of threaded interpretation.

> Also how to solve the problem?

Bert has answered this question, I think.

Best,

Michael
Reply | Threaded
Open this post in threaded view
|

Re: Currently executing bytecodes?

Mathieu SUEN
In reply to this post by Bert Freudenberg

On Nov 9, 2007, at 2:30 PM, Bert Freudenberg wrote:

>
>
> On Nov 9, 2007, at 14:10 , Mathieu Suen wrote:
>
>>
>> On Nov 9, 2007, at 1:13 PM, Michael Haupt wrote:
>>
>>>
>>> Hi,
>>>
>>> On 11/9/07, André Wendt <[hidden email]> wrote:
>>>> However, modifying the interpreter loop to:
>>>>
>>>> while (1) {
>>>>         printNumtoFile(currentBytecode, foo->vmLogFile);
>>>>         switch (currentBytecode) {
>>>>         ..
>>>>         }
>>>> }
>>>>
>>>> didn't work: printNumtoFile() gets executed exactly once. I've  
>>>> debugged
>>>> this with GDB: currentBytecode gets modified from within the CASE
>>>> statements and the program never gets past the switch() statement.
>>>
>>> that's most certainly because you are using a GNUified version of  
>>> the
>>> interpreter (right?). That one applies threading to the interpreter
>>> implementation, so the loop body is not actually executed like a  
>>> loop
>>> body usually is. Instead, interpreter logic jumps directly to and  
>>> fro
>>> in the bytecode routines.
>>
>> Intresting could you explain how?
>
> It replace each "case 123:" with a label and each "break" with  
> "goto *jumpTable[currentBytecode]", and initializes the jumpTable  
> with the labels.

Cool! I had never known what the gnuifier was doing. thanks

>
>> Also how to solve the problem?
>
> Modify the BREAK macro in sqGnu.h.
>
> - Bert -
>
>