想问一个关于即时编译的问题

2022-06-15 11:11:56 +08:00
 7911364440

Java 字节码经过即时编译之后会变成机器码,这些机器码存在哪里的,内存吗?编译后的机器码会不会失效? 如果一段代码一开始调用频率非常高,被判定为热点代码并被即时编译,那如果这段代码之后不会再被访问,这段代码会不会降级为解释执行?

1420 次点击
所在节点    Java
3 条回复
crayygy
2022-06-15 11:34:24 +08:00
koebehshian
2022-06-15 11:41:55 +08:00
For example, translation to machine code was done on demand, and the result was cached for later use. When memory became scarce, the system would delete some of this code and regenerate it when it was needed again.
--- https://en.wikipedia.org/wiki/Just-in-time_compilation#Design

是在内存,内存不够是会被替换掉。
letianqiu
2022-06-15 11:42:48 +08:00
在 code cache 里。实际上就是 CHeap 里。hotspot 里有个东西叫 deoptimization ,就是你说的降级

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/859724

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX