Reputation: 23
I've been wondering where interpreted byte-code of methods are stored internally in the JVM (specifically HotSpot x64). I know that methods that are JIT-ed are stored and can be accessed in the Method structure but I'm trying to understand where the JVM stores the byte-code converted to assembly instructions (I assume it stores them, otherwise there would be a lot of memory usage to interpret every invocation) as I wasn't able to find it in the internals source code.
Upvotes: 2
Views: 348
Reputation: 30807
Interpreting bytecode is not as expensive as you would think. Why would the JVM spend time generating machine code for code that runs once? Best to wait until a certain method or block reaches the JIT threshold and only then spend time enabling the tracing JIT.
The src/share/vm/interpreter
subdirectory seems to be what you're after:
bytecodeInterpreter.cpp
implements the actual stack machine;bytecodes.cpp
defines the shape and attributes of each opcode.bytecodes.h
declares all bytecodes.templateTable.cpp
contains machinery to map JVM opcodes to assembly.cpu/*/vm/templateTable*.cpp
contains the actual code to generate assembly snippets for the given CPU.Upvotes: 3