runtime compiled method optimizations

Robert Withers reefedjib at yahoo.com
Thu Oct 18 21:23:45 UTC 2007


Hi all,

I have a simple method containing an ifTrue: message.  I have  
compiled it normally, which uses macro transformations:

17 <10> pushTemp: 0
18 <9B> jumpFalse: 23
19 <10> pushTemp: 0
20 <20> pushConstant: 4
21 <B0> send: +
22 <7C> returnTop
23 <78> returnSelf

and I have compiled it using Klaus Witzel's nifty compiler changes to  
remove macro transformations and the result is an explicit message  
send of #ifTrue:

21 <10> pushTemp: 0
22 <89> pushThisContext:
23 <75> pushConstant: 0
24 <C8> send: blockCopy:
25 <A4 04> jumpTo: 31
27 <10> pushTemp: 0
28 <21> pushConstant: 4
29 <B0> send: +
30 <7C> returnTop
31 <E0> send: ifTrue:
32 <87> pop
33 <78> returnSelf

I would like to check the receiver of the ifTrue:, the 1st method arg  
in this case (Temp: 0), to see if a certain situation exists (is it a  
local reference to an object?).  If it is true, I would like to run  
the optimal code from the first example, instead of the longer second  
example.   How could we do that?  Something like this?  Could it be  
done entirely by the compiler, given the existence of the bytecode  
routine for #testLocalReference?

21 <10> pushTemp: 0
22 <??> testLocalReference
23 <??> jumpFalse: 30
24 <10> pushTemp: 0
25 <??> jumpFalse: 40
26 <10> pushTemp: 0
27 <20> pushConstant: 4
28 <B0> send: +
29 <7C> returnTop
30 <89> pushThisContext:
31 <75> pushConstant: 0
32 <C8> send: blockCopy:
33 <?? ??> jumpTo: 38
34 <10> pushTemp: 0
35 <21> pushConstant: 4
36 <B0> send: +
37 <7C> returnTop
38 <E0> send: ifTrue:
39 <87> pop
40 <78> returnSelf


Thanks!
Rob




More information about the Squeak-dev mailing list