I'm currently learning about c++'s inline function by reading Bjarne Stroustrup Programming_ Principles and Practice Using C++.
The author mentioned
(for inline function) the compiler will try to generate code for the function at each point of call rather than using function-call instructions to use common code.
I'm not exactly sure what is the difference between "generate code for the function at each point of call" vs "using function-call instruction to use common code". What are the fundamental differences that distinguish the two concepts?
For a non-inlined function, a single copy of the function's code exists somewhere in memory, and the compiler generates a CALL
instruction at each call site to jump to that memory location. When the function exits, execution flow will jump back to the call site.
For an inlined function, the compiler will merge a copy of the function's code directly into the code at each call site. The function will not exist on its own in memory, and there will be no CALL
instructions generated to jump into the function and back.