gpt4 book ai didi

java - AOT 检测是什么意思?

转载 作者:行者123 更新时间:2023-11-29 08:44:44 24 4
gpt4 key购买 nike

我知道什么是字节码检测。它只是在运行时更改 .class 文件字节码,这似乎从 JDK 1.5 开始可用。但是,据说是在类加载期间而不是运行时。

现在我的问题是,什么是 AOT 或提前检测?相反的程序是什么?随着时间的推移仪器?

Instrumenting Your Code
Quasar fibers rely on bytecode instrumentation. This can be done at classloading time via a Java Agent, or at compilation time with an Ant task.

Running the Instrumentation
Java Agent Quasar’s lightweight thread implementation relies on bytecode instrumentation. Instrumentation can be performed at compilation time (detailed below) or at runtime using a Java agent. To run the Java agent, the following must be added to the java command line (or use your favorite build tool to add this as a JVM argument):

-javaagent:path-to-quasar-jar.jar

Ahead-of-Time (AOT) Instrumentation
The easy and preferable way to instrument programs using Quasar is with the Java agent, which instruments code at runtime. Sometimes, however, running a Java agent is not an option.

Quasar supports AOT instrumentation with an Ant task. The task is co.paralleluniverse.fibers.instrument.InstrumentationTask found in quasar-core.jar, and it accepts a fileset of classes to instrument. Not all classes will actually be instrumented – only those with suspendable methods (see below) – so simply give the task all of the class files in your program. In fact, Quasar itself is instrumented ahead-of-time.

Source

最佳答案

提前 (AOT) 编译/检测就是这样,它发生在运行程序之前。

AOT 的对立面是准时制,即 JIT。它发生在运行时。在 Java 中,类加载是在运行时完成的,并且有一些机制可以解决它。

在您的示例中,AOT 检测是在运行程序之前通过 Ant 任务完成的,并将更改写入 .class 文件。

另一种可能的方法是使用 Java 代理进行 JIT。在这种情况下,检测发生在类加载时的运行时,结果不会写入文件,而是每次类加载时都必须重新执行。

参见 Wikipedia/Ahead-of-time-compilationWikipedia/Just-in-time-compilation了解更多信息。

关于java - AOT 检测是什么意思?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37179477/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com