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.
Ah, and the ifNil test is just a trick for the cascades, remember?
Isn't life easier with Smalltalk compared to a static world?
Nicolas
2009/1/12 nicolas cellier ncellier@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
(x=y) perform: #ifTrue: with: [ ... ]
:)
but if you don't want inlining at all in a system (like me) - the only way is to change the compiler.
Ah, and the ifNil test is just a trick for the cascades, remember?
Isn't life easier with Smalltalk compared to a static world?
Nicolas
Igor Stasenko wrote:
2009/1/12 nicolas cellier ncellier@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]
Thus, you still get inlined code somewhere. However, this can be changed to use BlockContext>>restart, I think...
Regards, Martin
On Tue, Jan 13, 2009 at 2:15 AM, Martin Beck <martin.beck@hpi.uni-potsdam.de
wrote:
Igor Stasenko wrote:
2009/1/12 nicolas cellier ncellier@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]
but this recursive definition works:
whileTrue: aBlock ^aBlock value ifTrue: [self whileTrue: aBlock]
Recursion does work if written correctly ;)
Thus, you still get inlined code somewhere. However, this can be changed to use BlockContext>>restart, I think...
Regards, Martin
On Tue, Jan 13, 2009 at 2:15 AM, Martin Beck <martin.beck@hpi.uni-potsdam.de
wrote:
Igor Stasenko wrote:
2009/1/12 nicolas cellier ncellier@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]
(Oops, too early in the morning)
this definition works correctly:
whileTrue: aBlock ^self value ifTrue: [self whileTrue: aBlock]
Thus, you still get inlined code somewhere. However, this can be changed to use BlockContext>>restart, I think...
Regards, Martin
On Tue, Jan 13, 2009 at 2:15 AM, Martin Beck <martin.beck@hpi.uni-potsdam.de
wrote:
Igor Stasenko wrote:
2009/1/12 nicolas cellier ncellier@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...
Regards, Martin
2009/1/13 Eliot Miranda eliot.miranda@gmail.com:
On Tue, Jan 13, 2009 at 2:15 AM, Martin Beck martin.beck@hpi.uni-potsdam.de wrote:
Igor Stasenko wrote:
2009/1/12 nicolas cellier ncellier@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
"Igor" == Igor Stasenko siguctua@gmail.com writes:
Igor> thisContext pc: (thisContext method initialPc).
All we have to do now is inline *this*.
:-)
On Sun, 18 Jan 2009 17:57:53 +0100, Randal L. Schwartz wrote:
"Igor" == Igor Stasenko writes:
Igor> thisContext pc: (thisContext method initialPc).
All we have to do now is inline *this*.
:-)
:) but is is "inlined" in the inlined version of #whileTrue: :)
Switching to bytecodes in the code pane shows it (the unconditional jump):
13 <70> self 14 <C9> send: value 15 <9C> jumpFalse: 21 16 <10> pushTemp: 0 17 <C9> send: value 18 <87> pop 19 <A3 F8> jumpTo: 13 21 <73> pushConstant: nil 22 <7C> returnTop
When compiling all methods in the .image with <nomacros> pragma (my own compiler ENH for controlling what is inlined), the ENH makes sure the existing code of #whileTrue: & friends is compiled with inlining, so that the method performs as if in tail recursive fashion.
This seems to be one of the fix points of the language (another one is expression [thisContext] relative to inlining).
Igor Stasenko a écrit :
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
(x=y) perform: #ifTrue: with: [ ... ]
:)
but if you don't want inlining at all in a system (like me) - the only way is to change the compiler.
Basically, if you want both to coexist, just create a subclass of MessageNode to redefine noteSpecialSelector:, then subclass all the chain Compiler/Parser to use that MessageNode... And change compilerClass where you desire.
If you just want to change the whole system, just change noteSpecialSelector:. Of course, you will have to find other ways to decently optimize the execution...
Nicolas
2009/1/13 nicolas cellier ncellier@ifrance.com:
Igor Stasenko a écrit :
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
(x=y) perform: #ifTrue: with: [ ... ]
:)
but if you don't want inlining at all in a system (like me) - the only way is to change the compiler.
Basically, if you want both to coexist, just create a subclass of MessageNode to redefine noteSpecialSelector:, then subclass all the chain Compiler/Parser to use that MessageNode... And change compilerClass where you desire.
If you just want to change the whole system, just change noteSpecialSelector:. Of course, you will have to find other ways to decently optimize the execution...
I made it easier: i wrote own parser :)
Nicolas
squeak-dev@lists.squeakfoundation.org