[squeak-dev] Avoiding compiler inlining

Igor Stasenko siguctua at gmail.com
Sun Jan 18 10:54:45 UTC 2009


2009/1/13 Eliot Miranda <eliot.miranda at gmail.com>:
>
>
> On Tue, Jan 13, 2009 at 2:15 AM, Martin Beck
> <martin.beck at hpi.uni-potsdam.de> wrote:
>>
>> Igor Stasenko wrote:
>> > 2009/1/12 nicolas cellier <ncellier at ifrance.com>:
>> >> Following cascading of macros, I need turning some inline off. A
>> >> recurrent
>> >> topic in Squeak-dev.
>> >>
>> >> Well, once i thought about using a Compiler reflective annotation (i.e.
>> >> a
>> >> pragma) in order to turn optimization off.
>> >>
>> >> Stupid me.
>> >> Inlined messages are made of block receiver/arguments.
>> >> So one would simply turn inlining off by sending a yourself message to
>> >> a
>> >> block.
>> >>
>> >>
>> >>        [false] yourself whileTrue.
>> >>
>> >>        false ifTrue: [self inspect] yourself.
>> >>
>> >> Of course, yourself is not a very explicit message...
>> >> We could create another #turnOffInlining or something...
>> >>
>> >> Except that in Squeak as other Smalltalks, the Old Compiler is quite
>> >> pedantic about optimizing these messages.
>> >>
>> >> [false] yourself  <- receiver of whileTrue must be a block or variable
>> >> ->whileTrue.
>> >>
>> >> false ifTrue: [self inspect]  <- argument of ifTrue: must be a block or
>> >> variable ->yourself.
>> >>
>> >>
>> >> Common! You don't like the system? Change It!
>> >> This is just 1 method attached.
>> >
>> > Heh.. you seem stumbled upon same things as i was :)
>> >
>> > well, if you writing own code so you have a total control whether you
>> > want inlining or not, you can simply write:
>> > [ ... ] perform: #whileTrue
>> >
>> But keep in mind, that (at least in my Squeak 3.10 image)
>> BlockContext>>whileTrue: is defined recursively:
>>
>> whileTrue: aBlock
>>  ^ [self value] whileTrue: [aBlock value]
>
> Argh!  Never try to write an email when you're hurrying before taking the
> kids to school.  This one works:
> whileTrue: aBlock
>     ^self value ifTrue:
>         [aBlock value.
>          self whileTrue: aBlock]
>>
>>
>> Thus, you still get inlined code somewhere. However, this can be changed
>> to use BlockContext>>restart, I think...
>>

Aha, something like following:

 whileTrue: aBlock
    self value ifTrue:  [aBlock value ] ifFalse: [ ^ false ].
    thisContext pc: (thisContext method initialPc).

:)

>> Regards, Martin
>>


-- 
Best regards,
Igor Stasenko AKA sig.



More information about the Squeak-dev mailing list