开发者

Is it possible to C++ compiler inline method calls across DLLs?

Is it possible to C++ c开发者_运维问答ompiler inline method calls across DLLs? Is it possible for .NET JIT ?


That's a definite Yes for a .NET jitter. It merely loads IL from a DLL, just-in-time code generation makes the fact that it came from a DLL disappear. All code from any DLL goes into the same loader heap. One consequence of this is that a DLL cannot be unloaded unless the entire AppDomain is unloaded.

A definite No for the C++ compiler, the exported functions are precompiled and located at a fixed address, an offset from the DLL base address. An indirect jump through the IAT is required, although optimizations are possible. But not inlining, that has to be done by the compiler.


If you hadn't included the ".net" tag, then the answer would be NO. However, with the ".net" tag, the jitter should be able to at least optimize, if not inline, unless the DLL is a native code DLL that you P/Invoke against.


A function defined completely in a C++ header file must be inlined by the compiler under normal circumstances, because there is no assigned compilation unit for the function. Of course, one could say the function does not even belong to the DLL, since you won't find an entry point there for the function, but IMHO that's only a nitpicker's point of view.


You should check out the /GL (Whole Program Optimization) flag for the compiler.

This flag tells the linker to optimize across module boundaries, including function inlining.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜