Erlang 编译:“HiPE 目标代码”的混合和“操作码”?
是否有可能有一个 VM 实例同时执行 HiPE 代码和通常的基于“操作码”的对象?
Is it possible to have a VM instance that executes both HiPE code and the usual "opcode" based objects at the same time?
This question is related to : Erlang OTP release compiles with HiPE?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,这就是本机编译器的集成方式。只有那些使用 +native 选项编译的模块才会以本机机器代码执行,其余的模块照常由 BEAM 模拟器解释。当您在以不同方式编译的模块之间进行调用时,就会发生“模式切换”。这样,您就可以无缝地混合本机模块和模拟模块。不过,您应该尝试选择本机编译的模块,以便避免在紧密的、性能关键的循环中进行模式切换,因为每次都会产生很小的开销。
Yes, that is how the native compiler is integrated. Only those modules that are compiled with the +native option are executing in native machine code, and the rest are interpreted by the BEAM emulator as usual. When you make calls between modules compiled in different ways, a "mode switch" happens. This way, you can mix native and emulated modules seamlessly. Still, you should try to select which modules you native compile so that you avoid mode switches in tight, performance critical loops, because there is a small overhead each time.