[squeak-dev] VMMaker: Problem with C-code generation

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

[squeak-dev] VMMaker: Problem with C-code generation

Antoine Marot
Hi all,

I am trying to change the method lookup process in the VM but I have  
some troubles with the code generation.

I modified #lookupMethodInClass:  in the Interpreter class and I added  
some methods and some class variables as well.  For now, I do not need  
to build my extension as an internal or external plugin.

The generated C-code (in interp.c) includes my modified version of  
#lookupMethodInClass: (it calls my own methods) but those methods do  
not appear in the source at all (as well as my class variables).

However, I traced the code generation and my methods seems to treated.

Any idea of what I am doing wrong ?

Thanks for your help !


Antoine

Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] VMMaker: Problem with C-code generation

David T. Lewis
On Thu, May 21, 2009 at 01:28:48PM +0200, Antoine Marot wrote:

> Hi all,
>
> I am trying to change the method lookup process in the VM but I have  
> some troubles with the code generation.
>
> I modified #lookupMethodInClass:  in the Interpreter class and I added  
> some methods and some class variables as well.  For now, I do not need  
> to build my extension as an internal or external plugin.
>
> The generated C-code (in interp.c) includes my modified version of  
> #lookupMethodInClass: (it calls my own methods) but those methods do  
> not appear in the source at all (as well as my class variables).
>
> However, I traced the code generation and my methods seems to treated.
>
> Any idea of what I am doing wrong ?

There are a couple of possibilities.

If your new method is not referenced anywhere, the C code will not be
generated. You can force the code to be generated by adding it to
a list of required methods in Interpreter class>>requiredMethodNames.

If your method has been fully inlined, it will have been embedded in
the code for other methods and will not appear as a separate function
in the generated C code. If you want to disable this, add the line
"self inline: false" in your method.

You may find it easier to debug things like this if you add SlangBrowser
to your image (http://wiki.squeak.org/squeak/5916>. That will let you
see the code generation for each method in a class browser.

Dave


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] VMMaker: Problem with C-code generation

Antoine Marot
Thank you David for your answer.

Actually, it was another problem that removed my methods from the  
generated code. In one of my methods, I was calling a method which use  
a local variable out of the scope of my method in the generated code.  
I guess the code generation detects such kind of errors and removes  
the erroneous methods. It would be great to have a warning in such  
cases to help the debugging.

SlangBrowser is very helpful, thanks for the link !

Antoine

Le 21-mai-09 à 13:45, David T. Lewis a écrit :

> On Thu, May 21, 2009 at 01:28:48PM +0200, Antoine Marot wrote:
>> Hi all,
>>
>> I am trying to change the method lookup process in the VM but I have
>> some troubles with the code generation.
>>
>> I modified #lookupMethodInClass:  in the Interpreter class and I  
>> added
>> some methods and some class variables as well.  For now, I do not  
>> need
>> to build my extension as an internal or external plugin.
>>
>> The generated C-code (in interp.c) includes my modified version of
>> #lookupMethodInClass: (it calls my own methods) but those methods do
>> not appear in the source at all (as well as my class variables).
>>
>> However, I traced the code generation and my methods seems to  
>> treated.
>>
>> Any idea of what I am doing wrong ?
>
> There are a couple of possibilities.
>
> If your new method is not referenced anywhere, the C code will not be
> generated. You can force the code to be generated by adding it to
> a list of required methods in Interpreter class>>requiredMethodNames.
>
> If your method has been fully inlined, it will have been embedded in
> the code for other methods and will not appear as a separate function
> in the generated C code. If you want to disable this, add the line
> "self inline: false" in your method.
>
> You may find it easier to debug things like this if you add  
> SlangBrowser
> to your image (http://wiki.squeak.org/squeak/5916>. That will let you
> see the code generation for each method in a class browser.
>
> Dave
>
>