Templates, varargs and static foreach
%u
user at localhost.com
Sun Jan 14 04:42:43 PST 2007
> Dear Kirk, I tried this too, but disassembling to code reveals that the foreach generates extra
> instructions when compared to this (dmd 1.00 linux):
The optimizer eliminates the extra code - not a problem anymore. I just wondered, why doesn't it
do it all on compile time. Here's the dumbobj output:
static if's:
0: 55 push %ebp
1: 8b ec mov %esp,%ebp
3: e8 fc ff ff ff call 4 <_D2t216__T3abcTiTiTiTiZ3abcFiiiiZv+0x4>
8: e8 fc ff ff ff call 9 <_D2t216__T3abcTiTiTiTiZ3abcFiiiiZv+0x9>
d: e8 fc ff ff ff call e <_D2t216__T3abcTiTiTiTiZ3abcFiiiiZv+0xe>
12: e8 fc ff ff ff call 13 <_D2t216__T3abcTiTiTiTiZ3abcFiiiiZv+0x13>
17: 5d pop %ebp
18: c2 0c 00 ret $0xc
1b: 90 nop
foreach:
0: 55 push %ebp
1: 8b ec mov %esp,%ebp
3: 83 ec 04 sub $0x4,%esp
6: 53 push %ebx
7: 89 45 fc mov %eax,0xfffffffc(%ebp)
a: 8b 4d 10 mov 0x10(%ebp),%ecx
d: e8 fc ff ff ff call e <_D2t216__T3bcdTiTiTiTiZ3bcdFiiiiZv+0xe>
12: 8b 45 0c mov 0xc(%ebp),%eax
15: e8 fc ff ff ff call 16 <_D2t216__T3bcdTiTiTiTiZ3bcdFiiiiZv+0x16>
1a: 8b 55 08 mov 0x8(%ebp),%edx
1d: e8 fc ff ff ff call 1e <_D2t216__T3bcdTiTiTiTiZ3bcdFiiiiZv+0x1e>
22: 8b 5d fc mov 0xfffffffc(%ebp),%ebx
25: e8 fc ff ff ff call 26 <_D2t216__T3bcdTiTiTiTiZ3bcdFiiiiZv+0x26>
2a: 5b pop %ebx
2b: c9 leave
2c: c2 0c 00 ret $0xc
2f: 90 nop
More information about the Digitalmars-d-learn
mailing list