alephnull said:
If you don't think the compiler is involved what do you think happens when you add the keyword inline before a function definition? Would you agree with me that the compiler does not put an inline function's parameters on the call stack? Try doing a backtrace on a piece of code compiled with -O3 in gcc. I think you will find that it inlines quite a bit. Particularly with the CBE and Xenon you have over a hundred registers per core, and if you don't think copious inlining is going on then... well, I dunno.
|
inline functions replace their function call with the actual code for the function, so you are right there, there is no pushing and popping off the stack. There may be, however, memory read/writes since you may have more params than available registers.
However, inline functions have to be used carefully. They can increase code size dramatically. You could eliminate all stack push/pops by making your code all one function, but that is horrible design, and would basically be what inlineing all your functions does.
inline eliminates the benefits of functions by not reusing code. If you have:
inline int functiona(int a, int b, int c)
{
//Code Here
}
and this function is called 100 different times, the "Code Here" section is compiled in to assembly 100 times. Ouch.
I am a Gauntlet Adventurer. I strive to improve my living conditions by hoarding gold, food, and sometimes keys and potions. I love adventure, fighting, and particularly winning - especially when there's a prize at stake. I occasionally get lost inside buildings and can't find the exit. I need food badly. What Video Game Character Are You? |
Mega Man 9 Challenges: 74%
Waltz | Tango | Jitterbug | Bust a move | Headbanging |
Bunny Hop | Mr. Trigger Happy | Double Trouble | Mr. Perfect | Invincible |
Almost Invincible | No Coffee Break | Air Shoes | Mega Diet | Encore |
Peacekeeper | Conservationist | Farewell To Arms | Gamer's Day | Daily Dose |
Whomp Wiley! | Truly Addicted! | Truly Hardcore! | Conqueror | Vanquisher |
Destroyer | World Warrior | Trusty Sidearm | Pack Rat | Valued Customer |
Shop A Holic | Last Man Standing | Survivor | Hard Rock | Heavy Metal |
Speed Metal | Fantastic 9 | Fully Unloaded | Blue Bomber | Eco Fighter |
Marathon Fight | Quick Draw G | Quick Draw C | Quick Draw S | Quick Draw H |
Quick Draw J | Quick Draw P | Quick Draw T | Quick Draw M | Quick Draw X |