inlining methods in slang

John M McIntosh johnmci at smalltalkconsulting.com
Mon May 2 07:48:35 UTC 2005


You should look at
CCodeGenerator>>collectInlineList

to understand why your code does not get inlined.

A long time ago I wrote up a change set to force inline of methods I  
thought were safe, but violated the rules, see
http://www.smalltalkconsulting.com/papers/tipsAndThoughts/source/ 
ForceInline-JMM.cs
Since this example is 5 years old, I'd expect it might require some  
changes. A little bit of debugging should show you
why the inliner is not doing the inlining.

Lastly since you are fiddling with slang, you should be aware if that  
if you have a instance variable, and if that instance variable
is used in methods that fold via inlining into a single C routine the  
global variable will become a c routine scoped variable. This
optimization was used to improve the garbage collector since the mark  
logic is folded into a single routine but had used instance vars for
recording state across multiple methods in ObjectMemory. If you do not  
wish this behavior you code up an accessor, then it will resort back to  
a global var.


On May 1, 2005, at 9:15 AM, Martin Kuball wrote:

> Hi!
>
> I'm writing a xvid plugin and have the following problem. I to make
> the plugin code more readable I wrote a small method that should be
> inlined into the c-code whenever it is called:
>
> insert: color into: output at: offset
>  | intColor |
>  intColor _ self cCoerce: color to: 'int'.
>  output at: offset put: (0 max: (255 min: intColor))
>
> That works. But in addition the generator outputs code for the method
> itself. But that code does not compile because the generator
> generates code with output as an int var.
>
> Now declaring outpus as a pointer like:
>
> insert: color into: output at: offset
>
>  | intColor |
>  self var: #output type: 'unsigned char*'.
>  intColor _ self cCoerce: color to: 'int'.
>  output at: offset put: (0 max: (255 min: intColor))
>
> does help, but now the method is not inlined any more. Even forcing
> inlining using
>  self inline: true
>
> does not help.
>
> Martin
>
>
>
--
======================================================================== 
===
John M. McIntosh <johnmci at smalltalkconsulting.com> 1-800-477-2659
Corporate Smalltalk Consulting Ltd.  http://www.smalltalkconsulting.com
======================================================================== 
===




More information about the Squeak-dev mailing list