Switching to use foo struct on Windows VM

bryce at kampjes.demon.co.uk bryce at kampjes.demon.co.uk
Sun Jul 15 21:18:46 UTC 2007


sig writes:
 > On 15/07/07, Bert Freudenberg <bert at freudenbergs.de> wrote:
 > Everywhere when some method uses foo struct, generator places
 > following line in function:
 > register struct foo * foo = &fum;
 > 
 > and then uses everywhere  foo->bar.
 > So, the difference in compiled code when using foo struct or not is minimal:
 > 
 >    mov reg, [bar]   <- using globals
 >    mov reg, [foo + bar_offset]  <- with foo
 > 
 > Of course, this depends how well GCC optimizes code, but in optimal
 > case - difference between loading value using direct pointer or using
 > base+offset is a just few cycles. And i don't think that this may
 > cause a major speed degradation.

The cost is to be efficient you need to use a register to
hold foo. The x86 is register starved with only 6 or 7 registers
available.

It's so bad that people will commonly compile with a compiler flag to
free up the frame pointer which makes debugging much harder as the
debugger can no longer reliably find the stack. This frees up 1
register which can provide a 20% performance improvement.

Bryce



More information about the Squeak-dev mailing list