Saturday, April 13, 2013

C/C++ interview question --- question 2



What are the disadvantages of inlining all functions in C?

 

 few reasons why it would be a bad idea:
  • Code size increases greatly especially when inlining large functions
  • Instruction caches become much less effective because you are always fetching new instructions from higher up in the memory hierarchy and never re-using instructions.
  • Register spilling would increase the stack usage but then, if you just had normal functions, you would have to pop/push activation records onto the stack instead of spilling. So, this last tradeoff is highly dependent on the code and the compiler.

No comments:

Post a Comment