Where does the JIT compiled code reside?

前端 未结 3 1402
北荒
北荒 2020-12-16 03:58

So I have this method, written in Java:

public void myMethod(int y){
    int x = 5 + y;
    doSomething(x);
}

And assume my application cal

3条回答
  •  轮回少年
    2020-12-16 04:47

    As far as I know, the The Java® Virtual Machine Specification does not specify any of that.
    The only reference to JIT I can find is in Chapter 3:

    [...] One example of such a translator is a just-in-time (JIT) code generator, which generates platform-specific instructions only after Java Virtual Machine code has been loaded. This chapter does not address issues associated with code generation, only those associated with compiling source code written in the Java programming language to Java Virtual Machine instructions.

    So to my understanding, this can be done differently by different implementations.

    However, to me it seems very unlikely that the memory containing the java bytecode is overwritten with native CPU instructions, because CPU instructions are technically executable and bytecode is just data, as it has to be interpreted. It wouldn't be impossible though, just very odd.

提交回复
热议问题