Code generator and method for generating extra code for a virtual machine
AssigneesSamsung Electronics Co., Ltd., Snu R&Db Foundation
InventorsHyeong-Seok Oh, Hyung-Kyu Choi, Dong-Heon Jung, Soo-Mook Moon, Kue-Hwan Sihn
Life of this patent
Estimating the term…
Abstract
In a virtual machine that uses a just-in-time complier (JITC) as a software execution environment, an idle time of a core to which the JITC is allocated is utilized to generate machine code in advance, thereby reducing a load on an interpreter. Accordingly, code execution performance of the interpreter is improved, and the utilization of a multi-core system that executes applications is increased.
Claims14
An apparatus for generating code for a virtual machine, the apparatus comprising:
- a processor;
- an interpreter implemented by the processor and configured to execute bytecode of a virtual machine;
- an information collecting unit implemented by the processor and configured to collect tracking information indicating a logical flow of execution of the bytecode by the interpreter, and to collect a number of executions of the bytecode by the interpreter;
- and
- a compiler implemented by the processor, the compiler configured to compile the bytecode into machine code, the compiler comprising:
- a work queue configured to store bytecode sections to be translated into machine code;
- and
- a code determining unit configured to receive the collected tracking information and to determine whether the compiler is idle, wherein
- in response to the compiler being idle,
- divide the bytecode into bytecode segments having a predefined length, based on the logical flow of execution of the bytecode;
- determine a bytecode trace among the bytecode segments, based on the number of executions of the bytecode, wherein the bytecode trace has the predefined length, and wherein the bytecode trace comprises a starting point that is a bytecode segment that has been executed by the interpreter more than a threshold number of executions;
- and
- compile the bytecode into machine code:
- and in response to the compiler not being idle,
- receive the collected tracking information, wherein the information collecting unit is implemented separately from both the interpreter and the compiler, and
- wherein the predefined length of the bytecode trace is defined based on a capacity of the work queue and a capacity of a code cache.
A method of generating code for a virtual machine, the method comprising:
- executing bytecode at an interpreter implemented by a processor;
- collecting tracking information at an information collecting unit, wherein the tracking information indicates a logical flow of execution of the bytecode by the interpreter, and a number of executions of the bytecode by the interpreter, and wherein the information collecting unit is implemented separately from both the interpreter and a compiler implemented by the processor;
- determining whether the compiler is idle,
- in response to the compiler being idle
- dividing the bytecode into bytecode segments having a predefined length, based on the logical flow of execution of the bytecode;
- and
- determining a bytecode trace among the bytecode segments, based on the number of executions of the bytecode, the bytecode trace having the predefined length, wherein the bytecode trace comprises a starting point that is a bytecode segment that has been executed by the interpreter more than a threshold number of executions;
- in response to the compiler not being idle,
- collecting tracking information at an information collecting unit;
- storing the bytecode trace in a work queue;
- and
- transmitting the stored bytecode trace to the compiler, in order to be compiled into machine code,
- and defining the predefined length of the bytecode trace based on a capacity of the work queue of the compiler and a capacity of a code cache configured to store machine code compiled from the bytecode executed by the interpreter.
A method of generating code for a virtual machine comprising bytecode, the method comprising:
- receiving tracking information at an information collecting unit implemented in a processor, that indicates a logical flow by which bytecode is executed by an interpreter wherein the information collecting unit is implemented separately from both the interpreter and a compiler implemented by the processor;
- determining whether the compiler is idle,
- in response to the compiler being idle dividing the bytecode into bytecode segments having a predefined length, based on the logical flow of execution of the bytecode;
- checking, at a code determining unit, whether the interpreter has determined a bytecode trace, and in response to the bytecode trace not being determined by the interpreter, determining, by the code determining unit, a new bytecode trace among the bytecode segments, based on the number of executions of the bytecode, and storing the new bytecode trace in a work queue;
- and
- in response to the compiler not being idle,
- receiving tracking information at an information collecting unit;
- compiling into machine code, at the compiler, when the compiler exits a standby state, the new bytecode trace determined by the code determining unit and stored in a work queue;
- and
- defining the predefined length of the new bytecode trace based on a capacity of the work queue of the compiler and a capacity of a code cache configured to store machine code compiled from the bytecode executed by the interpreter,
- wherein the new bytecode trace is a segment of code having the predefined length beginning at a starting point, and the starting point is a bytecode segment that has been executed by the interpreter more than a threshold number of executions.
A terminal, the terminal comprising:
- a processor;
- an interpreter implemented by the processor and configured to execute bytecode of a virtual machine, and determine a bytecode trace, to determine machine code to be generated;
- an information collecting unit implemented in the processor and configured to collect tracking information indicating a logical flow of the bytecode currently being executed by the interpreter, collect a number of executions of the bytecode by the interpreter;
- determining whether a compiler implemented by the processor is idle,
- wherein in response to the compiler being idle
- a code generator implemented by the processor, and configured to divide the bytecode into bytecode segments having a predefined length, based on the logical flow of execution of the bytecode;
- check whether the interpreter has determined the bytecode trace, and in response to the bytecode trace not being determined by the interpreter,
- determine a new bytecode trace among the bytecode segments, based on the number of executions of the bytecode, wherein the new bytecode trace is a segment of code having the predefined length beginning at a starting point, the starting point being a bytecode segment that has been executed by the interpreter more than a threshold number of executions;
- and
- in response to the compiler not being idle, collect tracking information;
- wherein the compiler is configured to compile the new bytecode trace into machine code, and the compiler includes a work queue configured to store bytecode sections to be translated into machine code,
- wherein the information collecting unit is implemented separately from both the interpreter and the compiler, and
- wherein the predefined length of the new bytecode trace is defined based on a capacity of the work queue and a capacity of a code cache configured to store machine code compiled from the bytecode executed by the interpreter.
Dependencies are inferred from the claim text.