This is now in 3.0 (starting from 3.0 #133).

There is now even an example for the use of #optIlineNone

Do this:

        SmalltalkImage compilerClass: OpalCompiler.
        OpalCompiler allowNonBooleanReceivers: true.
        1 ifFalse: [ 'ups' ]


you get a DNU that SmallInteger does not understand #ifTrue:

Of course this does not turn of the inling in general, it just recompiled the
send (kind of like a doit) on-optimized and executes that in #mustBeBooleanIn:
in the right context with all variables correctly looked up in the context.

(it is only a proof of concept right now and not working for anything more 
complex.)

        Marcus


On May 14, 2013, at 4:02 PM, Marcus Denker <[email protected]> wrote:

> In 3.0, when using the new Compiler, there is now a new way to set options 
> that the compile
> chain can act on (Opal takes care to hand them through all the stages).
> 
> For now, the there are two cases where we use options: controlling inlining 
> and to generate 
> long ivar access bytecodes even when short ones would be enough:
> 
> defaultOptions
>       ^ #(
>       "by default we inline all optimized constructs"
>       + optInlineIf
>       + optInlineIfNil
>       + optInlineAndOr
>       + optInlineWhile
>       + optInlineToDo
>       + optInlineCase
>       
>       - optIlineNone "to turn off all. Overrides the others"  
>       - optLongIvarAccessBytecodes "special for Contexts"
>       )
> 
> 
> There are two ways to set compiler options. One is per Class Hierarchy. For 
> example, in
> InstructionStream class, there is this method:
> 
> 
> compiler
> 
>       ^super compiler options: #(+ optLongIvarAccessBytecodes)
>       
> The other way to use it is with a pragma:
> 
> test
>       <compilerOptions: #(-optInlineIf)>
>       
>       
>       ^1 < 2 ifTrue: [ 'Hello!' ]
>       
>       
> The options API idea is taken from NativeBoost:
> 
> #( + option1 option2 - option3 ... )
>       
> each time the #+ is seen, the options which follow it will be subject for 
> inclusion
> and, correspondingly, if #- seen, then they will be excluded.
> 
> By default, (if none of #+ or #- specified initially), all options are 
> subject for inclusion.
> 
> Like NativeBoost it uses #doesNotUnderstand, so e.g. if you want to have a 
> flag for your own
> Compiler Plugin, just set it and query the compilationContext by sending the 
> flag symbol as
> a message.
> 
> Next: AST Transformation Plugins… ready later this week.
> 
>       Marcus
> 
> 
> 


Reply via email to