Machine-translated by Google. Questions are authored in English.
Top

Discussion

Assertion (A): Aggressive function inlining can make a program slower.
Reason (R): The enlarged code may no longer fit in the instruction cache, so execution stalls waiting for memory.

  • A.A is false but R is true
  • B.Both A and R are true, and R is the correct explanation of A
  • C.Both A and R are true, but R is not the correct explanation of A
  • D.A is true but R is false

Answer: B

Correct answer: Both A and R are true, and R is the correct explanation of A

Both are true and the reason gives the mechanism. Inlining removes call overhead and exposes context for further optimisation, but it duplicates the body at every site. Once the working set no longer fits the instruction cache, the misses cost far more than the calls saved - which is why inlining heuristics are based on size as much as on call frequency.

No comment is present. Be the first to comment.
Loading…

Post your comment

Please log in or register to post a comment.