是否有可能 C++跨 DLL 的编译器内联方法调用?

发布于 2024-10-07 03:27:18 字数 46 浏览 5 评论 0原文

C++ 编译器是否可以跨 DLL 内联方法调用? .NET JIT 可能吗?

Is it possible to C++ compiler inline method calls across DLLs?
Is it possible for .NET JIT ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

空城仅有旧梦在 2024-10-14 03:27:18

对于 .NET 抖动来说,这是肯定的。它只是从 DLL 加载 IL,即时代码生成使得它来自 DLL 的事实消失了。任何 DLL 中的所有代码都进入同一个加载器堆。这样做的后果之一是除非卸载整个 AppDomain,否则无法卸载 DLL。

对于 C++ 编译器来说,绝对不行,导出的函数经过预编译并位于固定地址(相对于 DLL 基地址的偏移量)。尽管可以进行优化,但仍需要通过 IAT 进行间接跳转。但不是内联,这必须由编译器完成。

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.

梦回梦里 2024-10-14 03:27:18

如果您没有包含“.net”标记,那么答案将为。但是,使用“.net”标记,抖动至少应该能够优化(如果不是内联),除非 DLL 是您 P/ 的本机代码 DLL援引反对。

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.

暗恋未遂 2024-10-14 03:27:18

完全在C++头文件中定义的函数,一般情况下必须由编译器内联,因为该函数没有分配编译单元。当然,有人可能会说该函数甚至不属于 DLL,因为您在那里找不到该函数的入口点,但恕我直言,这只是挑剔者的观点。

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.

甜是你 2024-10-14 03:27:18

您应该查看 /GL(整体程序优化) 编译器的标志。

该标志告诉链接器跨模块边界进行优化,包括函数内联。

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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文