1. An apparatus for generating code for a virtual machine, the apparatus comprising: an information collecting unit configured to collect tracking information that indicates a logical flow by which bytecode is to be executed; and a code determining unit configured to determine a bytecode trace which is to be compiled into machine code based on the collected tracking information, while the bytecode is not being compiled.