为特定方法/类禁用 Java JIT?

2022-01-16 00:00:00 jvm jit java jvm-hotspot

我在我的 Java 应用程序中遇到了 JIT 破坏代码的问题.如果我禁用 JIT,一切正常,但运行速度会慢 10-20 倍.

I'm having an issue in my Java application where the JIT breaks the code. If I disable the JIT, everything works fine, but runs 10-20x slower.

有什么方法可以禁用特定方法或类的 JIT?

Is there any way to disable the JIT for a specific method or class?

我正在使用 Ubuntu 10.10,得到相同的结果:

I'm using Ubuntu 10.10, getting the same results both with:

OpenJDK Runtime Environment (IcedTea6 1.9) (6b20-1.9-0ubuntu1)
OpenJDK 64-Bit Server VM (build 17.0-b16, mixed mode)

和:

Java(TM) SE Runtime Environment (build 1.6.0_16-b01)
Java HotSpot(TM) 64-Bit Server VM (build 14.2-b01, mixed mode)

推荐答案

以下选项适用于我的 JVM,以排除特定方法:

The following option works on my JVMs, to exclude a specific method:

-X:CompileCommand=exclude,the/package/and/Class,methodName

相关文章