WO2017092409A1 - 语言虚拟机中热点中间代码的识别方法以及装置 - Google Patents
语言虚拟机中热点中间代码的识别方法以及装置 Download PDFInfo
- Publication number
- WO2017092409A1 WO2017092409A1 PCT/CN2016/096068 CN2016096068W WO2017092409A1 WO 2017092409 A1 WO2017092409 A1 WO 2017092409A1 CN 2016096068 W CN2016096068 W CN 2016096068W WO 2017092409 A1 WO2017092409 A1 WO 2017092409A1
- Authority
- WO
- WIPO (PCT)
- Prior art keywords
- function
- recognized
- instruction
- local
- address
- Prior art date
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45508—Runtime interpretation or emulation, e g. emulator loops, bytecode interpretation
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45504—Abstract machines for programme code execution, e.g. Java virtual machine [JVM], interpreters, emulators
- G06F9/45516—Runtime code conversion or optimisation
- G06F9/4552—Involving translation to a different instruction set architecture, e.g. just-in-time translation in a JVM
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F9/00—Arrangements for program control, e.g. control units
- G06F9/06—Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
- G06F9/44—Arrangements for executing specific programs
- G06F9/455—Emulation; Interpretation; Software simulation, e.g. virtualisation or emulation of application or operating system execution engines
- G06F9/45533—Hypervisors; Virtual machine monitors
Definitions
- the present invention relates to a compilation technique, and in particular, to a method and apparatus for identifying a hotspot intermediate code.
- the language virtual machine is a virtual machine running intermediate code, such as intermediate code for executing JAVA.
- the language virtual machine is a virtual machine running intermediate code, such as intermediate code for executing JAVA.
- (Bytecode) JAVA Java Virtual Machine
- JIT Just In Time
- the just-in-time compiler is used to compile the intermediate code into local code for the executed execution, the local code. The execution efficiency is relatively high.
- Some just-in-time compilers can be subdivided into lightweight compilers and heavyweight compilers. The heavyweight compiler is more versatile than the lightweight compiler, and the compilation is better, but the compilation time is more expensive.
- the real-time compiler compiles the local code with low execution frequency, and the local code with low execution frequency occupies a large amount of storage space, which will affect the connection.
- the compilation process of the intermediate code with high execution frequency causes a waste of storage space and seriously affects the overall running performance of the language virtual machine.
- an apparatus for identifying a hotspot intermediate code comprising:
- Obtaining a circuit configured to acquire an instruction address in an instruction counter when the function to be recognized is executed by the language virtual machine;
- a first determining circuit configured to determine, according to an instruction address in the instruction counter acquired by the acquiring circuit, whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized;
- a updating circuit configured to: when the first determining circuit determines that the local instruction corresponding to the instruction address in the instruction counter is the local instruction of the function to be recognized, increase a current heat value of the function to be recognized by a preset a value to update the heat value of the function to be identified;
- a second determining circuit configured to determine whether the updated heat value of the to-be-recognized function obtained by the updating circuit is greater than or equal to a heat threshold of the to-be-recognized function, and an updated heat value of the to-be-recognized function
- the intermediate code of the function to be recognized is used as a hot spot intermediate code.
- updating the heat value of the function to be identified refers to replacing the current heat value with a new heat value, and the current heat value changes before and after the update, the current heat value after the update, or the updated The heat value becomes the new heat value before the update.
- the device determines whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized by acquiring an instruction address in the instruction counter, so that the instruction can be implemented in the interpreter or in the process of compiling the execution code in real time. Identify the hotspot intermediate code.
- the first determining circuit is configured to:
- the implementation can effectively distinguish whether the instruction currently being executed is a local instruction for implementing the function of the language virtual machine itself, or a local instruction of a function executed by the language virtual machine, thereby simply and effectively determining the instruction address in the instruction counter. Whether the corresponding local instruction is a local instruction of the function to be recognized.
- the function may also be referred to as a method, and the local instruction for implementing the function of the language virtual machine may also be referred to as an instruction in the host-side code, and the local instruction of the function executed by the language virtual machine may also be referred to as an instruction in the client code.
- the second possible implementation of the apparatus includes an interpreter, and the local instruction in the local instruction space of the function to be recognized includes a local instruction for the local instruction including the intermediate instruction corresponding to the interpreter translation, the The local instruction corresponding to the intermediate instruction of the interpreter translation includes the local instruction of the function to be recognized.
- the function to be recognized may be executed: the intermediate code of the function to be recognized is executed.
- the local instructions corresponding to all the intermediate instructions are stored in a continuous storage space, that is, a storage space of local instructions obtainable by the interpreter translation, the storage
- the space may be a memory space
- the local code may be an assembly code
- the intermediate code may also be a byte code, by determining whether the instruction address of the currently executed local instruction is in a local instruction obtainable by the interpreter translation Within the address range of the storage space, it may be implemented in the interpreter translation stage to determine whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized.
- the language virtual machine includes a timely compiler, and a local instruction space of the function to be recognized is used to store the to-be-identified
- the local code of the function, the local instruction of the function to be recognized is an instruction in the local code of the function to be recognized, and the local code of the function to be recognized is obtained by compiling the timely compiler.
- the function to be recognized may be executed: the local code of the function to be recognized is executed.
- the local code of the to-be-recognized function obtained by the just-time compiler compiles, and the local code of the function to be recognized is stored in a storage for storing the local code of the function to be recognized.
- Space wherein the storage space may be memory, for example, the storage space may be a code cache, wherein the local code of the function to be recognized may be obtained by a lightweight compiler in a timely compiler.
- the lightweight native code of the function to be recognized may also be a heavyweight native code of the function to be recognized obtained by a heavyweight compiler in a timely compiler.
- the local code of the function to be recognized is a lightweight local code
- determining whether the instruction address of the currently executed local instruction is within an address range of a storage space for storing the local code of the function to be recognized In a stage in which the lightweight local code is executed, determining whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized; when the local code of the function to be recognized is a heavyweight local code
- judging Whether the instruction address of the previously executed local instruction is within the address range of the storage space for storing the local code of the function to be recognized, and it is possible to determine the instruction address in the instruction counter during the execution stage of the heavyweight native code Whether the corresponding local instruction is a local instruction of the function to be recognized, thereby implementing statistics on the execution frequency of the heavyweight local code.
- the update circuit includes a heat value counter, and the heat value counter is configured to:
- the heat value of the function to be recognized in the heat value counter is incremented by one.
- the heat value counter is a counter that can trigger the counting by the input level (for example, by the rising edge of the level change), thereby replacing the software counting implementation, thereby reducing the burden of software implementation. And because it is directly implemented by the circuit, the execution efficiency is higher.
- the second determining circuit includes a subtractor and a threshold register for storing a heat threshold of the function to be identified.
- a subtractor coupled to the threshold register, the subtractor being coupled to the heat value counter, the subtractor configured to obtain a heat value of the to-be-recognized function in the heat value counter minus the threshold register
- a difference of the heat threshold of the to-be-identified function wherein the difference greater than 0 indicates that the updated heat value of the to-be-identified function is greater than or equal to a heat threshold of the function to be recognized.
- the function of determining whether the updated heat value of the function to be recognized is greater than or equal to the heat threshold of the function to be recognized is implemented by the circuit, thereby further reducing the operation of the code.
- the amount further makes the execution more efficient.
- the second determining circuit includes a first comparator and a threshold register for storing a heat threshold of the to-be-identified function
- the first comparator is connected to the threshold register, the first comparator is connected to the heat value counter, and the first comparator is configured to determine an update of the to-be-identified function in the heat value counter Whether the subsequent heat value is greater than or equal to the heat threshold of the function to be recognized in the threshold register.
- the function of determining whether the updated heat value of the to-be-identified function is greater than or equal to the heat threshold of the function to be recognized is implemented by the circuit, thereby reducing software implementation.
- the burden further makes the execution more efficient.
- the device further includes a processor and a memory; Storing code; the processor reads the code stored in the memory for:
- the value in the heat value counter is a heat value of the function to be recognized, so that the heat value counter can be used for other functions during the time when the function to be recognized is not executed. Optimized use of storage resources.
- the processor may be further configured to: when the to-be-identified function is called by the language virtual machine Loading the heat threshold of the function to be identified into the threshold register to apply to different functions having different heat thresholds.
- the threshold register may be used after the function to be recognized is returned by the language virtual machine. Other uses than storing the heat threshold of the function to be identified.
- the processor may be further configured to: when the to-be-identified function is returned by the language virtual machine And storing a heat threshold of the to-be-recognized function in the threshold register to the memory to apply to a case where a heat threshold in the threshold register is changed during execution of the function to be recognized.
- the processor is further configured to: when the to-be-identified function is called by the language virtual machine, save the An updated heat value of a key function in the heat value counter to the memory, the function to be recognized being a sub-function of the key function;
- the heat value of the main function and the function to be recognized can be differentiated.
- the processor may be further configured to load a heat threshold of the calling function to the threshold register when the function to be recognized is returned by the language virtual machine.
- the processor may be further configured to save the heat of the key function in the threshold register when the function to be recognized is called, when the heat threshold in the threshold register is changed during execution of the key function Threshold to the memory.
- the acquiring circuit includes an instruction address register connected to an instruction counter, the instruction address register The action of acquiring an instruction address in the instruction counter is triggered by receiving a trigger level, and the instruction address register is further configured to store an instruction address in the instruction counter.
- the function of acquiring the instruction address in the instruction counter is realized by the circuit, thereby reducing the burden of software implementation and further making the execution efficiency higher.
- the local instruction space of the function to be recognized is a storage space with consecutive addresses
- the local instruction space of the function to be recognized The address range is represented by a start address of the local instruction space of the function to be recognized and a termination address of the local instruction space of the function to be recognized, wherein a termination address of the local instruction space of the function to be recognized is greater than or equal to Describe the starting address of the local instruction space of the recognition function;
- the first determining circuit includes a start address register for storing a start address of a local instruction space of the function to be recognized, and a termination address register for storing a termination address of a local instruction space of the function to be recognized. a third comparator and a second comparator, the third comparator being coupled to the instruction address register, the third comparator being coupled to the start address register, the third comparator for: comparing the Whether the instruction address in the instruction counter in the instruction address register is greater than or equal to a start address of a local instruction space of the to-be-recognized function in the start address register;
- the second comparator is coupled to the instruction address register, the second comparator is coupled to the termination address register, and the second comparator is configured to: compare the instruction counter in the instruction address register Whether the instruction address is less than or equal to a termination address of the local instruction space of the function to be recognized in the termination address register, wherein an instruction address in the instruction counter is greater than or equal to a local instruction space of the function to be recognized When the start address is less than or equal to the termination address of the local instruction space of the function to be recognized, it indicates that the instruction address in the instruction counter is within the address range of the local instruction space of the function to be recognized.
- the address refers to a logical address or a physical address, and the address consecutively refers to a storage space corresponding to a minimum address value with a minimum value of an address in a local instruction space of the function to be recognized, and a maximum address value having a maximum value. All are storage spaces for the local instruction space.
- the start address register and the final The stop address register can serve as a register that can simultaneously store the start address of the local instruction space of the function to be recognized and the end address of the local instruction space of the function to be recognized.
- Determining, by the circuit, whether the local instruction corresponding to the instruction address in the instruction counter is the function to be recognized by connecting the second comparator, the third comparator, the instruction address register, the start address register, and the termination address register The function of local instructions, thereby reducing the burden of software implementation, further making the execution more efficient.
- the second comparator and the third comparator are directly or indirectly connected to the heat value counter through the logic gate, and pass through the second comparator.
- the level of the local instruction outputted by the third comparator for indicating the instruction address in the instruction counter is the level of the local instruction of the function to be recognized, and the triggering of the heat value counter is incremented by one, and the hot spot can be completely implemented.
- the identification of the intermediate code that is to say the identification of the hotspot intermediate code is completely completed by the hardware circuit independent of the execution process of the code in the language virtual machine, thereby reducing the burden of the software implementation and further making the execution more efficient.
- the device includes a processor and a memory; the memory is configured to store a code; By reading the code stored in the memory for:
- the value in the start address register is the start address of the local instruction space of the function to be recognized, so that the value in the termination address register is the The termination address of the local instruction space of the function is identified such that the start address register and the termination address register can be used for other functions while the function to be recognized is not being executed, optimizing the use of the storage resource.
- the implementation can accommodate situations where different functions have different starting addresses or ending addresses.
- the processor may be further configured to: when the to-be-identified function is virtualized by the language When the machine returns, save the start address of the local instruction space of the to-be-recognized function in the start address register to the memory, and save the termination of the local instruction space of the to-be-recognized function in the termination address register Addressing the memory to adapt to a start address of the local instruction space of the function to be recognized and a termination address of a local instruction space of the function to be recognized, In the case where the recognition function is changed during execution, it should be understood that after the function to be recognized is returned by the language virtual machine, the start address register and the termination address register may be used to store the start address and the center address of the function to be recognized. Other uses than others.
- the processor is configured to:
- the function to be recognized When the function to be recognized is returned by the language virtual machine, loading a start address of a local instruction space of the main function to the start address register, and loading a termination address of the local instruction space of the main function to the The termination address register is described, and the function to be recognized is a sub-function of the main function. In order to adapt to the case where the calling key function and the start address and the end address of the function to be recognized are different.
- the processor may be further configured to save a start address of a local instruction space of a key function in the start address register to the memory when the function to be recognized is called, and save the termination The termination address of the local instruction space of the calling function in the address register is to the memory.
- the acquiring circuit is configured to: periodically receive a periodic trigger level, periodically The action of acquiring the instruction address in the instruction counter is triggered.
- Periodically obtaining the instruction address in the instruction counter may be implemented by software timing, or may be triggered by a periodic clock signal.
- the acquisition circuit is an instruction address register
- the input of the instruction address register is respectively from the instruction counter and the cycle.
- the trigger level of the polarity which can be a periodic clock signal.
- the trigger instruction address register is synchronized with the instruction counter.
- the instruction counter generates a stable and large amount of data for processing by periodically acquiring the instruction address in the instruction counter, thereby reducing the influence of random factors, so that the reliability of the obtained heat value is higher.
- the device in the fourteenth possible implementation manner of the device, includes a processor and a memory; the memory is configured to store a code; The processor reads the code stored in the memory for:
- the function to be recognized is executed once the function to be recognized is executed, the above-mentioned judging action is performed during the execution of the function to be recognized, and when returning the function to be recognized, or at the returning place After the recognition function is described, the timing of obtaining the judgment result does not affect the current execution of the function to be recognized, but the instruction address in the instruction counter is periodically acquired.
- the former cannot accurately determine the next execution of the function, whether the intermediate code of the function to be recognized is a hot intermediate code, because even if the judgment result in the execution of the function is that the intermediate code of the function to be recognized is not the hot spot intermediate code
- the heat value of the function to be recognized may still increase.
- the former cannot accurately determine the next execution of the function, and the intermediate code of the function to be recognized is the hot intermediate code, but the latter can .
- the device in a possible implementation manner of the fifteenth implementation manner of the device, includes a processor and a memory; Storing a code; the processor reads the code stored in the memory for:
- the second determining circuit determines that the updated heat value of the to-be-recognized function is greater than or equal to the heat threshold of the to-be-recognized function, storing the updated heat value of the to-be-identified function in the memory;
- Calculating an updated heat value of the to-be-identified function in the memory minus the heat value before the preset time period of the to-be-identified function is greater than or equal to a heat value threshold of the function to be recognized a difference obtained by the heat value of the function to be recognized before the preset time period, the heat value of the function to be recognized before the preset time period is stored in the memory;
- the local code of the function to be recognized is deleted from the memory.
- hotspot intermediate code recognition is that since the execution efficiency of the native code is more efficient than the execution of the intermediate code, the prior art will compile the hotspot intermediate code into the local code by the timely compiler and store it in the local code for storing the local code.
- the storage space is used for being called, and the device can clear the local code whose frequency of recent execution is not high, so that more storage space can store the newly generated local code, improve the utilization of the storage space, and further improve the code. Execution efficiency.
- the device further includes a function letter for storing the to-be-identified function a function information register for indicating the function to be identified, the device comprising a processor and a memory; the memory for storing code; the processor reading the stored in the memory Code for:
- a method for identifying a hotspot intermediate code comprising: when an function to be recognized is executed by a language virtual machine, acquiring an instruction address in an instruction counter, and determining a local address corresponding to an instruction address in the instruction counter Whether the instruction is a local instruction of the function to be recognized; when the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized, adding a current heat value of the function to be recognized to a preset a value to update the heat value of the function to be recognized; determining whether the updated heat value of the function to be identified is greater than or equal to a heat threshold of the function to be recognized, and an updated heat value of the function to be recognized When the heat threshold is greater than or equal to the function to be recognized, the intermediate code of the function to be recognized is used as a hot spot intermediate code.
- the method may be implemented by software programming, or may be implemented by a circuit that can implement the method, or part of the method may be implemented by software, and another part may be implemented by a circuit.
- the local instruction refers to the instruction in the local code
- the instruction in the intermediate code is the intermediate instruction.
- the method determines whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized by acquiring an instruction address in the instruction counter, so that the hot spot intermediate code can be identified.
- the determining whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the to-be-identified function comprises: determining the Whether the instruction address in the instruction counter is within the address range of the local instruction space of the function to be recognized, the local instruction in the local instruction space of the function to be recognized includes the local instruction of the function to be recognized, and the to-be-identified Local instructions in the function's local instruction space do not include local instructions for implementing the language virtual machine functions.
- the second possible implementation manner of the method may be obtained by referring to the second possible implementation manner of the first aspect, where a third possible implementation manner of the method may refer to On the one hand, the third possible implementation is obtained.
- the local instruction space of the function to be recognized is a storage space with consecutive addresses
- An address range of a local instruction space of the function to be recognized is represented by a start address of a local instruction space of the function to be recognized and a termination address of a local instruction space of the function to be recognized, wherein the local instruction of the function to be recognized
- the termination address of the space is greater than or equal to the start address of the local instruction space of the function to be recognized
- determining whether the instruction address in the instruction counter is within the address range of the local instruction space of the function to be recognized includes:
- the acquiring an instruction address in the instruction counter includes: periodically acquiring the instruction counter Instruction address
- the determining whether the updated heat value of the to-be-recognized function is greater than or equal to the heat threshold of the function to be recognized includes:
- Periodically obtaining the instruction address in the instruction counter may be implemented by software timing, or may be triggered by a periodic clock signal, for example, by periodically triggering a specified register by a periodic clock signal to periodically acquire an instruction address in the instruction counter.
- a periodic clock signal for example, by periodically triggering a specified register by a periodic clock signal to periodically acquire an instruction address in the instruction counter.
- the method further includes:
- the heat value before the preset time period of the function to be recognized is greater than or equal to the said Calculating a difference value obtained by subtracting a heat value of the to-be-recognized function before a preset time period from an updated heat value threshold of the function;
- the local code of the function to be recognized is deleted from the storage space of the local code of the function to be recognized.
- the local code of the to-be-identified function is deleted from a storage space of a local code for storing the to-be-identified function After that, the heat value of the function to be recognized can also be cleared.
- an apparatus for identifying a hotspot intermediate code comprising:
- An obtaining unit configured to acquire an instruction address in the instruction counter when the function to be recognized is executed by the language virtual machine
- a first determining unit configured to determine, according to an instruction address in the instruction counter acquired by the acquiring unit, whether a local instruction corresponding to an instruction address in the instruction counter is a local instruction of the function to be recognized;
- an updating unit configured to: when the first determining unit determines that the local instruction corresponding to the instruction address in the instruction counter is the local instruction of the to-be-identified function, increase a current heat value of the to-be-identified function by a preset a value to update the heat value of the function to be identified;
- a second determining unit configured to determine whether the updated heat value of the to-be-recognized function obtained by the updating unit is greater than or equal to a heat threshold of the to-be-recognized function, and an updated heat value of the to-be-recognized function
- the intermediate code of the function to be recognized is used as a hot spot intermediate code.
- the first determining unit is configured to:
- the second possible implementation manner of the device may be obtained by referring to the second possible implementation manner of the first aspect, and the third possible implementation manner of the device may refer to On the one hand, the third possible implementation is obtained.
- the fourth device In a possible implementation manner, the local instruction space of the function to be recognized is a storage space with consecutive addresses, and the address range of the local instruction space of the function to be recognized uses the starting address of the local instruction space of the function to be recognized and The termination address of the local instruction space of the function to be recognized is represented by the termination address of the local instruction space of the function to be recognized, which is greater than or equal to the start address of the local instruction space of the function to be recognized, the first The judgment unit is used to:
- the acquiring unit is configured to: periodically acquire an instruction address in the instruction counter; corresponding,
- the second determining unit is configured to: when the language virtual machine returns the to-be-identified function, or after the language virtual machine returns the to-be-recognized function, determine an updated heat value of the to-be-identified function Whether it is greater than or equal to the heat threshold of the function to be identified.
- the device further includes: a calculating unit and a deleting unit;
- the calculating unit is configured to calculate the to-be-recognized function after the second determining unit determines that the updated heat value of the to-be-identified function obtained by the updating unit is greater than or equal to a heat threshold of the to-be-identified function
- the updated heat value minus the difference obtained by the heat value of the function to be recognized before the preset time period, the heat value of the function to be recognized before the preset time period is greater than or equal to the waiting value Identifying the heat value threshold of the function;
- the deleting unit is configured to: when the difference obtained by the calculating unit is less than a preset deletion threshold, use a local code of the function to be recognized from a storage space for storing a local code of the function to be recognized delete.
- a fourth aspect provides an apparatus for identifying a hotspot intermediate code, the apparatus comprising a processor and a memory; the memory for storing a code; the processor reading the code stored in the memory for use in Perform the method provided in the second aspect.
- a computer storage medium for storing computer software instructions for execution by a processor of the third aspect for performing the method provided by the second aspect.
- FIG. 1 is a schematic block diagram of a language virtual machine according to an embodiment of the present invention
- FIG. 2 is a schematic diagram of a logical structure of an apparatus for identifying a hotspot intermediate code according to an embodiment of the present invention
- FIG. 3 is a schematic diagram of a logical structure of a hardware circuit according to an embodiment of the present invention.
- FIG. 4 is a schematic flowchart of a method for identifying a hotspot intermediate code according to an embodiment of the present invention
- FIG. 5 is a schematic structural diagram of hardware of a computer device according to an embodiment of the present invention.
- FIG. 1 is a schematic block diagram of a language virtual machine 100, which is a fictitious computer implemented by simulating various computer functions on an actual computer.
- the language virtual machine 100 can be located at a computer device.
- the code of the language virtual machine 100 is obtained by the processor of the computer device (the code is also referred to as a host-side host method, or a non-client method), and the language virtual machine is executed by the processor.
- the language virtual machine 100 includes an execution engine 110 and a runtime data area 120.
- the execution engine 110 is configured to execute intermediate code, including an interpreter 112, a Just In Time compiler 114.
- the runtime data area 120 is used to store data needed during the operation of the language virtual machine 100 and is created when the language virtual machine 100 is started, and is eliminated when the language virtual machine 100 is launched.
- the runtime data area 120 includes a Program Counter Register 122, a virtual machine stack (Stack) 124, a Native Method Stack 126, and a Method Area 128. And Heap 130.
- the method may also be referred to as a function, and it should be understood that the method or function should be understood as a client guest method unless otherwise specified.
- the program counter 122 is a memory area for storing the next bytecode instruction instruction counter to be executed.
- the virtual machine stack 124 represents a memory model executed by the method. Each time a method is called, a stack frame is generated.
- the stack frame is divided into three parts: a local variable area (Local Variables), an operand stack (Operand Stack), and Frame Data Area.
- the local variable area is used to store local variables and parameters in the method, and the operand stack is used to store the intermediate results generated during the execution of the method.
- the frame data area is used for data parsing in the constant pool (constant_pool), returning the method after the method is executed, restoring the calling method scene, etc., wherein the constant pool is determined at compile time and saved in the compiled .class file.
- Constant pools contain constants about classes, methods, or interfaces, as well as string constants and symbolic references, each of which has its own constant pool.
- the local method stack 126 is used when executing the native method.
- the language virtual machine is a JVM
- the local method is a method implemented by a non-JAVA language.
- the method area 128 is configured to store information such as type information, constants, static variables, and immediately compiled code that have been loaded by the virtual machine.
- Part of the method area 128 is the Runtime Constant Pool, which is mainly used to store arguments and symbol references generated at compile time. Constants can also be generated at runtime, such as String's intern method.
- the Java heap only needs to be logically contiguous and not discontinuous in physical space.
- the hotspot intermediate code identifying apparatus 200 includes an obtaining unit 202, a first determining unit 204, and an updating unit. 206 and a second determining unit 208.
- the identification device 200 of the hotspot intermediate code may be a computer device.
- the units in the identification device 200 of the hotspot intermediate code can be implemented by software programming or by hardware circuits.
- the hardware circuit or software includes units in the identification device 200 of one or more hotspot intermediate codes.
- the identification device 200 of the hotspot intermediate code may be a computer device including the language virtual machine 100, and the identification device 200 of the hotspot intermediate code may also be a computer device not including the language virtual machine 100, but The computer device of the language virtual machine 100 establishes the interaction of information to implement the functions of the units of the hotspot intermediate code identification device 200.
- the unit in the identification device 200 of the hotspot intermediate code can be used as an execution unit of the language virtual machine 100. It can also be used directly by the processor of the computer device.
- the acquisition unit 202 is referred to as an acquisition circuit
- the first determination unit 204 is referred to as a first determination circuit
- the update unit 206 is referred to as an update circuit
- the second determination unit 208 is referred to as a second determination circuit, a hotspot intermediate code.
- the identification device 200 can realize the function of each circuit of the identification device 200 of the hotspot intermediate code by means of the interaction of establishing information with the computer device including the language virtual machine 100, the way of establishing the interaction of the information, or the communication through the wireless network;
- the intermediate code identification device 200 may also be a computer device including the respective circuits of the language virtual machine 100 and the hotspot intermediate code identification device 200.
- the obtaining unit 202 is configured to acquire an instruction address in the instruction counter when the function to be recognized is executed by the language virtual machine 100.
- the function to be identified may also be referred to as a method to be identified.
- the instruction counter may also be referred to as a program counter, but unlike the program counter 122 in the language virtual machine 100, the program counter 122 is a memory area for storing the next byte code (intermediate instruction), and the instruction counter For the registers in the processor, the instruction counter stores the address of the next local instruction that the processor will execute.
- the instruction counter is also located in a computer device that includes the language virtual machine 100.
- the acquiring unit 202 when used as the acquiring circuit, it may be an instruction address register 302 connected to the instruction counter, and the instruction address register 302 triggers an action of acquiring an instruction address in the instruction counter by receiving a trigger level, and the instruction address register 302 Also used to store the acquired instruction address.
- the connection here includes physical connection and establishment of information interaction.
- the trigger level may be periodic.
- the trigger level may be the clock signal of the identification device 200 itself of the hotspot intermediate code or the clock signal.
- the frequency-divided signal acquisition circuit (specifically, the instruction address register 302) can periodically trigger the action of acquiring the instruction address in the instruction counter by receiving a periodic trigger level.
- the first determining unit 204 is configured to determine, according to the instruction address in the instruction counter acquired by the obtaining unit 202, whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized.
- the first determining unit 204 may be configured to obtain an instruction corresponding to the instruction address by using the instruction address, and further determine whether the instruction corresponding to the instruction address is a local instruction of the function to be recognized.
- the first determining unit 204 can be configured to determine whether the instruction address in the instruction counter is Within the address range of the local instruction space of the function to be recognized, the local instruction of the function to be recognized is stored in the local instruction space of the function to be recognized, and the local instruction in the local instruction space does not include the local function for implementing the function of the language virtual machine 100. instruction. It should be understood that when the interpreter 112 of the language virtual machine 100 executes the intermediate code of the function to be recognized, the local instructions corresponding to all the intermediate instructions are stored in a continuous storage space in the memory of the memory, specifically, may be stored in the method area. 128.
- the interpreter 112 translates the intermediate instructions in the intermediate code of the function to be recognized into corresponding local instructions one by one by querying local instructions corresponding to the intermediate instructions in the continuous storage space in the memory.
- the local instruction space is a storage space for storing local instructions obtainable by the interpreter 112 translation, or may also be referred to as interpreter 112 for interrogating the middle.
- the storage space of the local instruction corresponding to the instruction, the local instruction in the local instruction in the local instruction space includes a local instruction corresponding to the intermediate instruction translated by the interpreter 112, and the local instruction corresponding to the intermediate instruction translated by the interpreter 112
- the instruction includes a local instruction of the function to be identified.
- the real-time compiler 114 of the language virtual machine 100 stores the local code in the memory space of the memory after the intermediate code is compiled into the local code, such as a code cache.
- the buffer may be located in the method area 128, so that when the timely compiler 114 of the language virtual machine 100 executes the native code of the function to be recognized, the local instruction space is a storage space for storing the local code of the function to be recognized, wherein The local instruction identifying the function is the instruction in the native code of the function to be recognized.
- the local instruction space may be a contiguous storage space, and the address range of the local instruction space may be represented by a start address of the local instruction space and a termination address of the local instruction space, where the local The termination address of the instruction space is greater than or equal to the start address of the local instruction space.
- the first determining unit 204 may be configured to: determine whether the instruction address is greater than or equal to a starting address of a local instruction space of the function to be identified, and whether the instruction address is less than or equal to a termination address of a local instruction space of the function to be identified; When the instruction address is greater than or equal to the start address of the local instruction space of the function to be recognized, and is less than or equal to the termination address of the local instruction space of the function to be recognized, then the instruction address in the instruction counter is in the local instruction space of the function to be recognized. Within the address range.
- the first determining unit 204 may further include a start address register 304 for storing a start address of a local instruction space of the function to be recognized, and for storing A termination address register 306 that identifies the termination address of the local instruction space of the function.
- the first determining circuit may include a third comparator and a second comparator, the third comparator is connected to the instruction address register 302, the third comparator is connected to the start address register 304, and the third comparator is used for: comparing Whether the instruction address in the instruction address register 302 is greater than or equal to the start address of the local instruction space of the function to be recognized in the start address register 304; the second comparator is coupled to the instruction address register 302, the second comparator and the termination address register The second comparator is configured to: compare whether the instruction address in the instruction address register 302 is less than or equal to the termination address of the local instruction space of the function to be recognized in the termination address register 306.
- the instruction address is greater than or equal to the start address of the local instruction space of the function to be identified and is less than or equal to the termination address of the local instruction space of the function to be identified, indicating that the instruction address in the instruction counter is in the address of the local instruction space of the function to be recognized.
- the first determining circuit may further include a third subtractor and a second subtractor, the third subtractor is connected to the instruction address register 302, the third subtractor is connected to the start address register 304, and the third subtractor is configured to: By comparing the difference between the instruction address in the instruction address register 302 and the start address of the local instruction space of the function to be recognized in the start address register 304, to compare whether the instruction address in the instruction address register 302 is greater than or equal to the start address.
- the instruction address in the instruction counter is in the local instruction space of the function to be recognized. Within the address range.
- the updating unit 206 is configured to: when the first determining unit 204 determines that the local instruction corresponding to the instruction address in the instruction counter is the local instruction of the function to be recognized, increase a current heat value of the function to be recognized to a preset value, To update the heat value of the function to be identified.
- the update unit 206 may be a heat value counter 310 when the update circuit is used, and the heat counter is a counter for storing a heat value counter, and the heat value counter 310 is used to heat the to-be-recognized function in the heat value counter 310. Add 1 to the value.
- the second determining unit 208 is configured to determine, after the update of the function to be recognized obtained by the updating unit 206, Whether the heat value is greater than or equal to the heat threshold of the function to be identified, and when the updated heat value of the function to be identified is greater than the heat threshold of the function to be identified, the intermediate code of the function to be identified is used as the hot spot intermediate code.
- the obtaining unit 202 may periodically acquire the instruction address in the instruction counter; correspondingly, the second determining unit 208 may be configured to: when returning the function to be recognized, or after returning the function to be recognized, determine the function to be recognized Whether the updated heat value is greater than or equal to the heat threshold of the function to be identified.
- the second determining unit 208 as a second determining circuit may include a threshold register 312 for storing a heat threshold of the function to be identified.
- the second determining circuit may further include a subtractor 314, the subtractor 314 is connected to the threshold register 312, the subtractor 314 is connected to the heat value counter 310, and the subtractor 314 is configured to acquire the to-be-identified in the heat value counter 310.
- the heat value of the function is subtracted from the difference of the heat threshold of the function to be recognized in the threshold register 312, wherein when the difference is greater than 0, the updated heat value of the function to be recognized is greater than or equal to the function to be recognized Heat threshold.
- the second determining circuit may further include a first comparator, the first comparator is connected to the threshold register 312, the first comparator is connected to the heat value counter 310, and the first comparator is configured to determine the waiting in the heat value counter 310. Whether the updated heat value of the recognition function is greater than or equal to the heat threshold of the function to be identified in the threshold register 312.
- the processor may directly or indirectly obtain the output result of the subtractor 314 or the first comparator to confirm whether the updated heat value of the function to be identified is greater than or equal to the heat threshold of the function to be identified.
- the heat value counter 310 may be directly connected to the third subtractor, the second subtractor, or the third subtractor and the second The subtractor is first indirectly connected to the heat value counter 310 through the logic gate circuit, and the heat is generated when the output of the third subtractor and the second subtractor indicates whether the updated heat value of the function to be recognized is greater than or equal to the heat threshold of the function to be recognized.
- the value counter 310 triggers a count of one.
- the heat value counter 310 may be directly connected to the third comparator, the second comparator, or the third comparator and the second The comparator is first indirectly connected to the heat value counter 310 through the logic gate circuit, and the heat is generated when the output of the third comparator and the second comparator indicates whether the updated heat value of the function to be identified is greater than or equal to the heat threshold of the function to be recognized.
- the value counter 310 triggers a count of one.
- the just-in-time compiler 114 compiles the intermediate code of the function to be recognized into the native code of the function to be recognized.
- a corresponding data structure body may be established for each function, the data structure body is named metadata, and the data structure body may be, for example, a class or a struct, to identify a function.
- the data that can be recorded in the metadata of the function to be recognized includes: an identifier of the function to be identified, a starting address of the function to be recognized, a termination address of the function to be recognized, a heat value of the function to be recognized, and a heat threshold of the function to be recognized.
- the metadata of the function to be recognized may have no heat threshold of the function to be recognized, but a heat threshold as a function common value; for the embodiment, it is only applied to the explanation.
- the metadata of the function to be recognized may have no start address of the function to be recognized, a termination address of the function to be recognized, but a common address of the start address and the end address. Value.
- the identifier of the function to be identified is used to obtain the intermediate code of the function to be recognized by the identifier of the function to be recognized after the intermediate code of the function to be recognized is used as the hot spot intermediate code, thereby obtaining the intermediate code of the function to be recognized.
- Compile as a native code for the function to be recognized. Since the identifier of the function to be identified is not used for hotspot identification, for the hotspot identification of the intermediate code, there may be no identifier of the function to be identified in the metadata of the function to be recognized.
- the identification device 200 of the hotspot intermediate code may include a processor for storing code, and the processor may be configured to: when the function to be recognized is called by the language virtual machine 100, by reading the code stored in the memory. The current heat value of the function to be recognized is loaded to the heat value counter 310, and when the function to be recognized is returned by the language virtual machine 100, the updated heat value of the function to be recognized in the heat value counter 310 is saved to the memory.
- the processor may be further configured to: when the function to be recognized is invoked by the language virtual machine 100, save the updated heat value of the key function in the heat value counter 310 to the memory, and the function to be recognized is a main function. a sub-function, or a call instruction containing a function to be recognized in a function body of the main function, when the function to be recognized is returned by the language virtual machine 100, loading the current heat value of the main function to a heat value counter 310.
- the processor is further configured to: when the function to be recognized is called by the language virtual machine 100, load a start address of the local instruction space of the function to be recognized to the start address register 304, and load the local instruction space of the function to be recognized.
- the termination address is to the termination address register 306.
- the processor is further configured to: when the function to be recognized is returned by the language virtual machine 100, save the start address of the local instruction space of the function to be recognized in the start address register 304 to the memory, and save the termination address register 306. The termination address of the local instruction space of the function to be recognized Memory.
- the processor is further configured to: when the function to be recognized is called, save the start address of the local instruction space of the calling function in the start address register 304 to the memory, and save the keynote in the termination address register 306.
- the termination address of the function's local instruction space is to memory.
- the processor is further configured to: when the function to be recognized is returned by the language virtual machine 100, load a starting address of the local instruction space of the calling function to the start address register 304, and load the local instruction space of the calling function.
- the termination address is to the termination address register 306.
- the instruction of the function call can be modified, and the instruction returned by the function can be modified.
- the function call instruction can be added by one operand, and the added
- the operand may be the address of the metadata of the function to be recognized, such as a pointer to the metadata of the function.
- a storage space may be set in the memory for storing the pointer space of the metadata of the currently executing function, which may be, for example, It is not limited to registers, and a pointer stack for storing metadata pointers is set in the memory.
- the function to be recognized is called by a function call instruction with an increased operand
- the value of the added operand is a preset value (such as 0)
- the function call instruction with the added operand is used as a prior art.
- the function call instruction if the added operand is not the preset value, the added operand is used as the pointer of the metadata of the function to be recognized, and the following operations are performed: wherein the optional operations are: 1) according to the pointer space A pointer of the metadata of the main key function, storing the value in the heat value counter 310 to the storage space of the heat value storing the function to be recognized in the metadata of the main function; 2) pressing the pointer of the metadata of the main function in the pointer space
- the pointer stack can be established in the virtual machine stack 124, only for storing pointers to the metadata; 3) loading the pointer of the metadata of the function to be recognized into the pointer space; 4) according to the function to be recognized a pointer
- the function return instruction can be added with an operand, and the added operand can be an identifier for indicating that the function return instruction with the added operand performs the following operations: There are: 1) according to the pointer of the metadata of the function to be recognized in the pointer space, the heat value in the heat value counter 310 is saved to the metadata in the function to be recognized.
- the processor may be further configured to: when returning the function to be recognized, or after returning the function to be recognized, triggering the second determining unit 208 to determine whether the updated heat value of the function to be recognized obtained by the updating unit 206 is greater than Or an action equal to the heat threshold of the function to be identified.
- the lightweight compiler or the heavyweight compiler of the just-in-time compiler 114 can be compiled into the local code of the recognition function.
- the processor may be further configured to: after the output result of the second determining unit 208 indicates that the updated heat value of the function to be recognized is greater than or equal to the heat threshold of the function to be identified, the updated heat of the function to be identified
- the value is stored in the memory; when the heat value of the function to be recognized before the preset time period is greater than or equal to the heat value threshold of the function to be recognized, the updated heat value of the function to be recognized in the memory is calculated minus the to-be-identified a difference obtained by the heat value of the function before the preset time period, the heat value of the function to be recognized before the preset time period is stored in the memory; when the difference is less than the preset deletion threshold,
- the native code that describes the recognition function is removed from memory, such as a code buffer in memory.
- the purpose of the selective deletion of the local code of the function to be recognized from the memory is to monitor the execution frequency of the local code obtained by the compilation in real time, and in a specific implementation process, it may pass at a certain time. Traversing the pointers in the pointer stack, and obtaining the heat value of the metadata stored in each function of each function, can be judged by the second determining unit 208 (which can also have the same function as the second determining unit), thereby obtaining the heat.
- a function whose value is greater than the heat threshold, and then a function with a heat value greater than the heat threshold can be written to the linked list 1 in the form of [method, count1] (the heat value can also be stored in the memory in other ways), where method is function information , count1 is the heat value of the metadata stored in the function of each function.
- count1 is the heat value of the metadata stored in the function of each function.
- the pointer is obtained, the obtained heat value is greater than the current heat value of the function of the heat threshold.
- the function to be recognized is traversed to the previous traversal.
- the frequency of execution during the time period is not high, and the local code of the function to be recognized can be deleted from the memory, and the space is reserved for the recently executed high frequency to improve the storage space utilization rate.
- the hotspot intermediate code identifying apparatus 200 may further include a calculating unit and a deleting unit;
- the calculating unit is configured to calculate, after the updated heat value of the function to be recognized obtained by the updating unit 206 is greater than or equal to the heat threshold of the function to be recognized, the updated heat value of the function to be recognized minus the preset function to be recognized The difference obtained by the heat value before the time period, the heat value of the function to be recognized before the preset time period is greater than or equal to the heat value threshold of the function to be recognized.
- the connection may be performed with the update unit 206 to determine whether the updated heat value of the function to be recognized is greater than or equal to the heat threshold of the function to be recognized, or may be connected to the second determination unit 208. critical result.
- the deleting unit is configured to delete the local code of the function to be recognized from a storage space (for example, a code buffer) of the local code of the function to be recognized when the difference obtained by the computing unit is less than a preset deletion threshold.
- the unit (the obtaining unit 202, the first determining unit 204, the updating unit 206 or the second determining unit 208) in the identification device 200 of the hotspot intermediate code may be different from the memory and the processor in different implementation manners.
- the relationship, the unit implemented by the software in the identification device 200 of the hotspot intermediate code may be located in a memory, which is read by the processor from the memory to implement the functions of the unit.
- the unit implemented by the hardware circuit in the identification device 200 of the hotspot intermediate code may be integrated on the processor or connected to the processor.
- each of the subtractors in the embodiment of the present invention can be replaced by an adder to implement the subtraction operation.
- FIG. 3 is a hardware circuit implementation manner of the identification device 200 of the hotspot intermediate code. It should be understood that the implementation manner of the hardware circuit of the hotspot intermediate code identification device 200 of the embodiment of the present invention is not limited thereto, and the figure is not limited thereto. The connection manner of each unit in 3 is not limited to this.
- the comparator 308 includes a second comparator and a third comparator, or the comparator 308 includes a second subtractor and a third subtractor, with respect to the second subtractor, the third subtractor, the second comparator, and the third Comparator, termination address register 306, instruction address register 302, start address register 304, heat value counter
- the contents of 310, threshold register 312, and subtractor 314 have been described in detail above and will not be described again here.
- FIG. 4 is a schematic flowchart of a method for identifying a hotspot intermediate code applied to the language virtual machine 100.
- the method may be performed by the hotspot intermediate code identifying apparatus 200.
- the method steps are as follows:
- S402. Determine whether the local instruction corresponding to the instruction address in the instruction counter is a local instruction of the function to be recognized.
- the local instruction in the local instruction space of the function to be recognized includes a local instruction of the function to be recognized, and the local instruction in the local instruction space of the function to be recognized does not include the function for implementing the language virtual machine.
- the local instruction, the local instruction space of the function to be recognized stores the local instruction.
- the language virtual machine 100 when executed as an intermediate code of the function to be recognized, includes an interpreter 112, which may be a storage space for storing local instructions obtainable by the interpreter 112 translation, or
- the local instructions in the local instruction space of the recognition function include local instructions for the intermediate instructions translated by the interpreter 112, and the local instructions corresponding to the intermediate instructions for the interpreter translation include local instructions for the function to be recognized.
- the language virtual machine 100 when executed as the local code of the function to be recognized, the language virtual machine 100 includes a timely compiler 114, the local instruction space may be used to store the local code of the function to be recognized, and the local instruction of the function to be recognized is the function to be recognized.
- the instructions in the native code, the native code of the function to be recognized is compiled by the timely compiler 114.
- the local instruction space is a contiguous storage space of the address
- the address range of the local instruction space is represented by a start address of the local instruction space and a termination address of the local instruction space, where the termination address of the local instruction space of the function to be identified is
- the instruction address in the instruction counter is greater than or equal to the start address of the local instruction space of the function to be recognized
- whether the instruction address in the instruction counter is within the address range of the local instruction space of the function to be recognized may be: determining whether the instruction address in the instruction counter is greater than or equal to Identifying the starting address of the local instruction space of the function, and whether the instruction address is less than or equal to the termination address of the local instruction space of the function to be identified; the instruction address is greater than or equal to the starting address of the local instruction space of the function to be identified, and is less than or Termination of the local instruction space equal to the function to be identified At the address, it indicates that the instruction address in the instruction counter is within the address range of the local instruction space of the function to be recognized.
- the instruction address in the instruction counter may be periodically acquired, thereby updating the heat value of the function to be identified.
- the current heat value of the function to be recognized is added to a preset value to update the heat value of the function to be identified.
- the preset value is a positive number, such as a positive integer.
- the added preset value can be 1.
- the intermediate code of the function to be recognized may be used as the hotspot intermediate code, and the hot spot intermediate code is compiled into the local code of the function to be recognized by the timely compiler 114.
- whether the updated heat value of the function to be recognized is greater than or equal to the heat threshold of the function to be recognized may be determined when the language virtual machine 100 returns the function to be recognized, or after the language virtual machine 100 returns the function to be recognized.
- the heat value before the preset time period of the function to be recognized is greater than or equal to the heat value threshold of the function to be recognized, calculating the updated heat value of the function to be recognized minus the preset value of the function to be recognized The difference obtained from the heat value before the time period; when the difference is less than the preset deletion threshold, the local code of the function to be recognized is deleted from the storage space of the local code of the function to be recognized.
- the heat value of the function to be recognized before the preset time period can be understood as the heat value at the time A of the function to be recognized, wherein the current time is B, and the time A is earlier than the time B by a preset time period.
- the heat value of the function to be recognized may also be cleared.
- FIG. 5 is a schematic diagram showing the hardware structure of a computer device 500 according to an embodiment of the present invention.
- computer device 500 can be implemented as an implementation of identification device 200 for hotspot intermediate code, which includes processor 502, memory 504, input/output interface 506, communication interface 508, and bus 510.
- the processor 502, the memory 504, the input/output interface 506, and the communication interface 508 implement communication connections with each other through the bus 510.
- the processor 502 can adopt a general-purpose central processing unit (CPU).
- CPU central processing unit
- a microprocessor an application specific integrated circuit (ASIC), or one or more integrated circuits, for performing related procedures to implement the technical solutions provided by the embodiments of the present invention.
- ASIC application specific integrated circuit
- the memory 504 may be a read only memory (ROM), a static storage device, a dynamic storage device, or a random access memory (RAM).
- Memory 504 can store an operating system, language virtual machine 100, and other applications.
- the present invention is used to implement the present invention by implementing the functions and functions required to be performed in the identification device 200 of the hotspot intermediate code provided by the embodiment of the present invention, or performing the above-described methods provided by the embodiments of the method of the present invention.
- the program code of the technical solution provided by the embodiment is stored in the memory 504, and the unit included in the identification device 200 of the hotspot intermediate code and the operation required to be performed by the component are executed by the processor 502, or the method provided by the embodiment of the present invention is executed. The above method.
- the input/output interface 506 is for receiving input data and information, and outputting data such as operation results.
- Communication interface 508 implements communication between computer device 500 and other devices or communication networks using transceivers such as, but not limited to, transceivers.
- Bus 510 can include a path for communicating information between various components of computer device 500, such as processor 602, memory 504, input/output interface 506, and communication interface 508.
- Computer device 500 shown in FIG. 5 only shows the processor 502, the memory 504, the input/output interface 506, the communication interface 508, and the bus 510, those skilled in the art will understand in the specific implementation process.
- Computer device 500 also includes other devices necessary to achieve normal operation, such as a display screen.
- computer device 500 may also include hardware devices that implement other additional functions, depending on the particular needs.
- computer device 500 may also only include the components necessary to implement embodiments of the present invention, and does not necessarily include all of the devices shown in FIG.
- the storage medium may be a magnetic disk, an optical disk, a read-only memory (ROM), or a random access memory (RAM).
Landscapes
- Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Engineering & Computer Science (AREA)
- General Physics & Mathematics (AREA)
- Devices For Executing Special Programs (AREA)
Abstract
一种热点中间代码的识别方法以及装置。其中热点中间代码的识别方法包括:在待识别函数被语言虚拟机执行时,获取指令计数器中的指令地址,判断指令地址对应的本地指令是否为待识别函数的本地指令;在指令地址对应的本地指令为待识别函数的本地指令时,将待识别函数的当前的热度值增加预设值,以更新待识别函数的热度值;判断待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值,在待识别函数的更新后的热度值大于或等于待识别函数的热度阈值时,将待识别函数的中间代码作为热点中间代码。使用上述方法,可以识别出热点中间代码。
Description
本申请要求于2015年12月02日提交中国专利局、申请号为201510872247.7、发明名称为“语言虚拟机中热点中间代码的识别方法以及装置”的中国专利申请的优先权,其全部内容通过引用结合在本申请中。
本发明涉及编译技术,具体涉及一种热点中间代码的识别方法以及装置。
在代码的执行过程中,为了屏蔽平台的差异性,首先要把源代码转换为中间代码,然后运行在各自的语言虚拟机,语言虚拟机为运行中间代码的虚拟机,例如执行JAVA的中间代码(字节码)的JAVA虚拟机(JVM,Java Virtual Machine)一般包括解释器(Interpreter)、即时(JIT,Just In Time)编译器。在中间代码的执行过程中,解释器用于在程序启动时,对中间代码进行逐个翻译并执行,执行效率比较低,即时编译器用于将中间代码编译为用于被调用执行的本地代码,本地代码的执行效率比较高。一些即时编译器又可以细分为轻量级编译器、重量级编译器。重量级编译器相比轻量级编译器优化手段更丰富,编译效果更好,但编译时开销更大。
然而,在不能有效地识别热点的中间代码(执行频率高的中间代码)时,使得即时编译器编译出执行频率低的本地代码,这些执行频率低的本地代码占据了大量存储空间,会影响接下来的执行频率高的中间代码的编译过程,造成了存储空间浪费且严重影响语言虚拟机整体运行性能。
发明内容
本发明的目的在于提供一种热点中间代码的识别方法以及装置,用于识别热点的中间代码。
上述目标和其它目标将通过独立权利要求中的特征来达成。进一步的实现方式在从属权利要求、说明书和附图中体现。
第一方面,提供一种热点中间代码的识别装置,所述装置包括:
获取电路,用于在待识别函数被语言虚拟机执行时,获取指令计数器中的指令地址;
第一判断电路,用于根据所述获取电路获取的所述指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令;
更新电路,用于在所述第一判断电路确定所述指令计数器中的指令地址对应的本地指令为所述待识别函数的本地指令时,将所述待识别函数的当前的热度值增加预设值,以更新所述待识别函数的热度值;
第二判断电路,用于判断所述更新电路得到的所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值,在所述待识别函数的更新后的热度值大于所述待识别函数的热度阈值时,将所述待识别函数的中间代码作为热点中间代码。
其中,更新所述待识别函数的热度值指的是用新的热度值来替换当前的热度值,当前的热度值在更新前后会发生改变,更新之后的当前的热度值,或者说更新后的热度值就变成了更新前的那个新的热度值。
该装置通过获取指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令,使得可以实现在解释器或是即时编译执行代码的过程中识别出热点中间代码。
根据第一方面,在所述装置第一种可能的实现方式中,所述第一判断电路用于:
判断所述指令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内,所述待识别函数的本地指令空间中的本地指令包括所述待识别函数的本地指令,并且所述待识别函数的本地指令空间中的本地指令不包括用于实现所述语言虚拟机功能的本地指令。该实现方式可以有效区分当前正在执行的指令是用于实现语言虚拟机自身功能的本地指令,还是语言虚拟机执行的函数的本地指令,从而简单且有效的实现判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令。其中函数也可以称为方法,用于实现语言虚拟机自身功能的本地指令也可以称为主机端代码中的指令,语言虚拟机执行的函数的本地指令也可以称为客户端代码中的指令。
根据第一方面的第一种实现方式,在所述装置第二种可能的实现方式
中,所述语言虚拟机包括解释器,所述待识别函数的本地指令空间中的本地指令包括用于中的本地指令包括所述解释器翻译的中间指令对应的本地指令,所述用于所述解释器翻译的中间指令对应的本地指令包括所述待识别函数的本地指令。
相应的,所述待识别函数被执行可以包括:所述待识别函数的中间代码被执行。
在语言虚拟机中的解释器翻译中间代码的过程中,所有中间指令对应的本地指令被存储在连续的存储空间,也就是可通过所述解释器翻译获得的本地指令的存储空间,所述存储空间可以是内存空间,所述本地代码可以是汇编代码,所述中间代码也可以是字节码,通过判断当前执行的本地指令的指令地址是否在可通过所述解释器翻译获得的本地指令的存储空间的地址范围内,可实现解释器翻译阶段中判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令。
根据第一方面的第一种实现方式,在所述装置第三种可能的实现方式中,所述语言虚拟机包括及时编译器,所述待识别函数的本地指令空间用于存储所述待识别函数的本地代码,所述待识别函数的本地指令为所述待识别函数的本地代码中的指令,所述待识别函数的本地代码通过所述及时编译器编译获得。
相应的,所述待识别函数被执行可以包括:所述待识别函数的本地代码被执行。
即时编译器编译获得的所述待识别函数的本地代码,会以所述待识别函数为一个整体,将所述待识别函数的本地代码存储在用于存储所述待识别函数的本地代码的存储空间,其中,该存储空间可以是内存,例如,该存储空间可以是代码缓冲区(code cache),其中所述待识别函数的本地代码可以是通过及时编译器中的轻量级编译器获得的所述待识别函数的轻量级本地代码,也可以是通过及时编译器中的重量级编译器获得的所述待识别函数的重量级本地代码。在所述待识别函数的本地代码为轻量级本地代码时,通过判断当前执行的本地指令的指令地址是否在用于存储所述待识别函数的本地代码的存储空间的地址范围内,可实现在轻量级本地代码被执行阶段中,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令;在所述待识别函数的本地代码为重量级本地代码时,通过判断当
前执行的本地指令的指令地址是否在用于存储所述待识别函数的本地代码的存储空间的地址范围内,可实现在重量级本地代码被执行阶段中,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令,从而实现对重量级本地代码的执行频率的统计。
根据第一方面,或以上第一方面的任意一种实现方式,在所述装置第四种可能的实现方式中,所述更新电路包括热度值计数器,所述热度值计数器用于:将所述热度值计数器中的所述待识别函数的热度值加1。该热度值计数器为计数器,可以通过输入的电平(例如,通过电平变化的上升沿)来触发计数,从而替代软件计数的实现方式,从而减轻软件实现的负担。并且由于是电路直接实现,使得执行效率更高。
根据第一方面的第四种实现方式,在所述装置第五种可能的实现方式中,所述第二判断电路包括减法器和用于存储所述待识别函数的热度阈值的阈值寄存器,所述减法器与所述阈值寄存器相连,所述减法器与所述热度值计数器相连,所述减法器用于获取所述热度值计数器中的所述待识别函数的热度值减去所述阈值寄存器中的所述待识别函数的热度阈值的差值,其中,所述差值大于0指示所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值。
通过将减法器、阈值寄存器以及热度值计数器相连,通过电路实现判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值的功能,从而进一步降低了代码的运算量,进一步使得执行效率更高。
根据第一方面的第四种实现方式,在所述装置第六种可能的实现方式中,所述第二判断电路包括第一比较器和用于存储所述待识别函数的热度阈值的阈值寄存器,所述第一比较器与所述阈值寄存器相连,所述第一比较器与所述热度值计数器相连,所述第一比较器用于判断所述热度值计数器中的所述待识别函数的更新后的热度值是否大于或等于所述阈值寄存器中的所述待识别函数的热度阈值。
通过将第一比较器、阈值寄存器以及热度值计数器相连,通过电路实现判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值的功能,从而减轻软件实现的负担,进一步使得执行效率更高。
根据第一方面的第五种或第六种实现方式,在所述装置第七种实现方式的一种可能的实现方式中,所述装置还包括处理器和存储器;所述存储器用
于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:
在所述待识别函数被所述语言虚拟机调用时,加载所述待识别函数的当前的热度值到所述热度值计数器;
在所述待识别函数被所述语言虚拟机返回时,保存所述热度值计数器中的所述待识别函数的更新后的热度值到所述存储器。
仅在所述待识别函数被执行期间,令热度值计数器中的值为所述待识别函数的热度值,使得在所述待识别函数不被执行期间,热度值计数器可以被用于其它功能,优化了存储资源的使用。
根据上述第一方面第七种可能的实现方式,作为第一方面第七种实现方式的另一种实现方式,所述处理器还可以用于在所述待识别函数被所述语言虚拟机调用时,加载所述待识别函数的热度阈值到所述阈值寄存器,以适用于不同函数具有不同的热度阈值的情况,应理解,在待识别函数被所述语言虚拟机返回之后,阈值寄存器可以用于除存储待识别函数的热度阈值之外的其它用途。
根据上述第一方面第七种可能的实现方式,作为第一方面第七种实现方式的另一种实现方式,所述处理器还可以用于在所述待识别函数被所述语言虚拟机返回时,保存所述阈值寄存器中的所述待识别函数的热度阈值到所述存储器,以适用于待识别函数在执行期间阈值寄存器中的热度阈值发生改变的情况。
根据第一方面的第七种实现方式,在所述装置第八种可能的实现方式中,所述处理器还用于:在所述待识别函数被所述语言虚拟机调用时,保存所述热度值计数器中的主调函数的更新后的热度值到所述存储器,所述待识别函数为所述主调函数的子函数;
在所述待识别函数被所述语言虚拟机返回时,加载所述主调函数的当前的热度值到所述热度值计数器。使得主调函数以及待识别函数的热度值可以区分处理。
在不同函数具有不同的热度阈值时,所述处理器还可以用于在所述待识别函数被所述语言虚拟机返回时,加载所述主调函数的热度阈值到所述阈值寄存器,在所述主调函数执行期间,阈值寄存器中的热度阈值会发生改变时,所述处理器还可以用于在所述待识别函数被调用时,保存所述阈值寄存器中的所述主调函数的热度阈值到所述存储器。
根据第一方面,或以上第一方面的任意一种实现方式,在所述装置第九种可能的实现方式中,所述获取电路包括与指令计数器相连接的指令地址寄存器,所述指令地址寄存器通过接收触发电平,触发所述获取指令计数器中的指令地址的动作,所述指令地址寄存器还用于存储所述指令计数器中的指令地址。
通过电路实现获取指令计数器中的指令地址的功能,从而减轻软件实现的负担,进一步使得执行效率更高。
根据第一方面的第九种实现方式,在所述装置第十种可能的实现方式中,所述待识别函数的本地指令空间为地址连续的存储空间,所述待识别函数的本地指令空间的地址范围用所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址来表示,其中,所述待识别函数的本地指令空间的终止地址大于或等于所述待识别函数的本地指令空间的起始地址;
所述第一判断电路包括用于存储所述待识别函数的本地指令空间的起始地址的起始地址寄存器,和用于存储所述待识别函数的本地指令空间的终止地址的终止地址寄存器,第三比较器和第二比较器,所述第三比较器与所述指令地址寄存器连接,所述第三比较器与所述起始地址寄存器连接,所述第三比较器用于:比较所述指令地址寄存器中的所述指令计数器中的指令地址是否大于或等于所述起始地址寄存器中的所述待识别函数的本地指令空间的起始地址;
所述第二比较器与所述指令地址寄存器连接,所述第二比较器与所述终止地址寄存器连接,所述第二比较器用于:比较所述指令地址寄存器中的所述指令计数器中的指令地址是否小于或等于所述终止地址寄存器中的所述待识别函数的本地指令空间的终止地址,其中,在所述指令计数器中的指令地址大于或等于所述待识别函数的本地指令空间的起始地址且小于或等于所述待识别函数的本地指令空间的终止地址时,则指示所述指令计数器中的指令地址在所述待识别函数的本地指令空间的地址范围内。
其中地址指的是逻辑地址或物理地址,地址连续指的是在所述待识别函数的本地指令空间中的地址的值中值最小的最小地址值到值最大的最大地址值对应的存储空间,均为本地指令空间的存储空间。
作为第一方面第十种实现方式的另一种实现方式,起始地址寄存器和终
止地址寄存器可以作为一个寄存器,该寄存器可同时存储所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址。
通过将第二比较器、第三比较器、指令地址寄存器、起始地址寄存器以及终止地址寄存器相连,通过电路实现判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令的功能,从而减轻软件实现的负担,进一步使得执行效率更高。
当所述装置第十种实现方式与所述装置第六种实现方式结合时,即将第二比较器以及第三比较器,直接或者间接的通过逻辑门与热度值计数器连接,通过第二比较器与第三比较器输出的用于指示所述指令计数器中的指令地址对应的本地指令为所述待识别函数的本地指令的电平,触发热度值计数器进行加1的计数,可以完整的实现热点中间代码的识别,也就是说热点中间代码的识别完全由硬件电路独立于语言虚拟机中代码的执行过程来完成,从而减轻软件实现的负担,进一步使得执行效率更高。
根据第一方面的第十种实现方式,在所述装置第十一种实现方式的一种可能的实现方式中,所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:
在所述待识别函数被所述语言虚拟机调用时,加载所述待识别函数的本地指令空间的起始地址到所述起始地址寄存器,加载所述待识别函数的本地指令空间的终止地址到所述终止地址寄存器。
仅在所述待识别函数被所述语言虚拟机执行期间,令起始地址寄存器中的值为所述待识别函数的本地指令空间的起始地址,令终止地址寄存器中的值为所述待识别函数的本地指令空间的终止地址,使得在所述待识别函数不被执行期间,起始地址寄存器以及终止地址寄存器可以被用于其它功能,优化了存储资源的使用。并且,该实现方式可以适应不同的函数具有不同的起始地址或是终止地址的情况。
根据上述第一方面第十一种可能的实现方式,作为第一方面第十一种实现方式的另一种实现方式,所述处理器还可以用于在所述待识别函数被所述语言虚拟机返回时,保存所述起始地址寄存器中的所述待识别函数的本地指令空间的起始地址到所述存储器,保存所述终止地址寄存器中的所述待识别函数的本地指令空间的终止地址到所述存储器,以适应所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址,在待
识别函数被执行期间发生改变的情况,应理解,在待识别函数被所述语言虚拟机返回之后,起始地址寄存器以及终止地址寄存器可以用于除存储待识别函数的起始地址以及中置地址之外的其它用途。
根据第一方面的第十一种实现方式,在所述装置第十二种可能的实现方式中,所述处理器用于:
在所述待识别函数被所述语言虚拟机返回时,加载主调函数的本地指令空间的起始地址到所述起始地址寄存器,加载所述主调函数的本地指令空间的终止地址到所述终止地址寄存器,所述待识别函数为所述主调函数的子函数。以适应主调函数与待识别函数的起始地址与终止地址不同的情况。
应理解,所述处理器还可以用于在所述待识别函数被调用时,保存所述起始地址寄存器中的主调函数的本地指令空间的起始地址到所述存储器,保存所述终止地址寄存器中的所述主调函数的本地指令空间的终止地址到所述存储器。
根据第一方面,或以上第一方面的任意一种实现方式,在所述装置第十三种可能的实现方式中,所述获取电路用于:通过接收周期性的触发电平,周期性地触发所述获取所述指令计数器中的指令地址的动作。周期性地获取所述指令计数器中的指令地址可以通过软件计时实现,也可以通过周期性的时钟信号触发获取动作,在获取电路为指令地址寄存器时,指令地址寄存器的输入分别来自指令计数器和周期性的触发电平,该电平可以是周期性的时钟信号,在时钟信号的上升沿或是下降沿时,触发指令地址寄存器进行与指令计数器的同步。
指令计数器通过周期性地获取所述指令计数器中的指令地址,形成稳定、大量的数据用于处理,降低了随机因素带来的影响,使得获得的热度值的可靠性更高。
根据第一方面,或以上第一方面的任意一种实现方式,在所述装置第十四种可能的实现方式中,所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:
在所述语言虚拟机返回所述待识别函数时,或在所述语言虚拟机返回所述待识别函数之后,触发所述第二判断电路进行所述判断所述更新电路得到的所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值的动作。
对于待识别函数一旦被执行就会执行到待识别函数被返回的情况来说,在所述待识别函数执行过程中就执行上述判断动作,与在返回所述待识别函数时,或在返回所述待识别函数之后,才执行上述判断的动作相比,两者判断结果获得的时机并不会影响待识别函数的此次的执行情况,然而在周期性地获取所述指令计数器中的指令地址的情况下,前者不能准确判断函数的下次执行时,待识别函数的中间代码是否是热点中间代码,因为即使在函数执行过程中进行判断的判断结果为待识别函数的中间代码不是热点中间代码,但是在判断之后到函数返回的时段中,待识别函数的热度值仍然可能会增加,前者不能准确判断函数的下次执行时,待识别函数的中间代码是否是热点中间代码,但是后者可以。
根据第一方面,或以上第一方面的任意一种实现方式,在所述装置第十五种实现方式的一种可能的实现方式中,所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:
在所述第二判断电路判断所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值之后,将所述待识别函数的更新后的热度值存储在所述存储器;
在所述待识别函数的在预设的时段之前的热度值大于或等于所述待识别函数的热度值阈值时,计算所述存储器中所述待识别函数的更新后的热度值减去所述待识别函数的在预设的时段之前的热度值而获得的差值,所述待识别函数的在预设的时段之前的热度值存储在所述存储器中;
在所述差值小于预设的删除阈值时,将所述待识别函数的本地代码从所述存储器中删除。
热点中间代码识别的其中一个目的在于,由于本地代码的执行效率比中间代码的执行效率高,故现有技术会将热点中间代码通过及时编译器编译成本地代码并存储于用于存储本地代码的存储空间以用于被调用,所述装置可以及时清除近期执行频率不高的本地代码,从而使得更多的存储空间可以存储新生成的本地代码,提高了存储空间的利用率,进一步提高了代码的执行效率。
根据第一方面,或以上第一方面的任意一种实现方式,在所述装置第十六种可能的实现方式中,所述装置还包括用于存储所述待识别函数的函数信
息的函数信息寄存器,所述函数信息用于指示所述待识别函数,所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:
加载所述待识别函数的函数信息到所述函数信息寄存器,以使得所述处理器根据所述函数信息寄存器中的所述待识别函数的函数信息,将所述待识别函数的中间代码作为所述热点中间代码编译为所述待识别函数的本地代码。
第二方面,提供一种热点中间代码的识别方法,所述方法包括:在待识别函数被语言虚拟机执行时,获取指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令;在所述指令计数器中的指令地址对应的本地指令为所述待识别函数的本地指令时,将所述待识别函数的当前的热度值增加预设值,以更新所述待识别函数的热度值;判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值,在所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值时,将所述待识别函数的中间代码作为热点中间代码。
该方法可以由软件编程实现,也可以由可以实现该方法的电路实现,也可以将该方法中的一部分由软件编程实现,另一部分由电路实现。其中,本地指令指的是本地代码中的指令,同理,中间代码中的指令为中间指令。
该方法通过获取指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令,使得可以识别出热点中间代码。
根据第二方面,在所述方法的第一种可能的实现方式中,所述判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令,包括:判断所述指令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内,所述待识别函数的本地指令空间中的本地指令包括所述待识别函数的本地指令,并且所述待识别函数的本地指令空间中的本地指令不包括用于实现所述语言虚拟机功能的本地指令。
根据第二方面的第一种实现方式,所述方法的第二种可能的实现方式可以参考第一方面第二种可能的实现方式得到,所述方法的第三种可能的实现方式可以参考第一方面第三种可能的实现方式得到。
根据第二方面的第一种至第三种的任意一种实现方式,在所述方法第四中可能的实现方式中,所述待识别函数的本地指令空间为地址连续的存储空间,所述待识别函数的本地指令空间的地址范围用所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址来表示,其中,所述待识别函数的本地指令空间的终止地址大于或等于所述待识别函数的本地指令空间的起始地址,所述判断所述指令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内包括:
判断所述指令计数器中的指令地址是否大于或等于所述待识别函数的本地指令空间的起始地址,并且所述指令计数器中的指令地址是否小于或等于所述待识别函数的本地指令空间的终止地址;
在所述指令计数器中的指令地址大于或等于所述待识别函数的本地指令空间的起始地址,并且小于或等于所述待识别函数的本地指令空间的终止地址时,则指示所述指令计数器中的指令地址在所述待识别函数的本地指令空间的地址范围内。
根据第二方面,或以上第二方面的任意一种实现方式,在所述方法第五种可能的实现方式中,所述获取指令计数器中的指令地址包括:周期性地获取所述指令计数器中的指令地址;
所述判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值包括:
在所述语言虚拟机返回所述待识别函数时,或在所述语言虚拟机返回所述待识别函数之后,判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值。
周期性地获取所述指令计数器中的指令地址可以通过软件计时实现,也可以通过周期性的时钟信号触发获取动作,例如通过周期性的时钟信号触发指定的寄存器周期性获取指令计数器中的指令地址,通过周期性地获取所述指令计数器中的指令地址,形成稳定、大量的数据用于处理,降低了随机因素带来的影响,使得获得的热度值的可靠性更高。
根据第二方面,或以上第二方面的任意一种实现方式,在所述方法第六种可能的实现方式中,在判断所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值之后,所述方法还包括:
在所述待识别函数的在预设的时段之前的热度值大于或等于所述待识
别函数的热度值阈值时,计算所述待识别函数的更新后的热度值减去所述待识别函数的在预设的时段之前的热度值而获得的差值;
在所述差值小于预设的删除阈值时,将所述待识别函数的本地代码从所述待识别函数的本地代码的存储空间中删除。
根据第二方面第一种实现方式,在所述方法第七种可能的实现方式中,在将所述待识别函数的本地代码从用于存储所述待识别函数的本地代码的存储空间中删除之后,还可以将待识别函数的热度值清零。
第三方面,提供一种热点中间代码的识别装置,所述装置包括:
获取单元,用于在待识别函数被语言虚拟机执行时,获取指令计数器中的指令地址;
第一判断单元,用于根据所述获取单元获取的所述指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令;
更新单元,用于在所述第一判断单元确定所述指令计数器中的指令地址对应的本地指令为所述待识别函数的本地指令时,将所述待识别函数的当前的热度值增加预设值,以更新所述待识别函数的热度值;
第二判断单元,用于判断所述更新单元得到的所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值,在所述待识别函数的更新后的热度值大于所述待识别函数的热度阈值时,将所述待识别函数的中间代码作为热点中间代码。
根据第三方面,在所述装置第一种可能的实现方式中,所述第一判断单元用于:
判断所述指令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内,所述待识别函数的本地指令空间中的本地指令包括所述待识别函数的本地指令所述待识别函数的本地指令空间,并且所述待识别函数的本地指令空间中的本地指令不包括用于实现所述语言虚拟机功能的本地指令。
根据第三方面的第一种实现方式,所述装置的第二种可能的实现方式可以参考第一方面第二种可能的实现方式得到,所述装置的第三种可能的实现方式可以参考第一方面第三种可能的实现方式得到。
根据第三方面的第一种至第三种的任意一种实现方式,在所述装置第四
种可能的实现方式中,所述待识别函数的本地指令空间为地址连续的存储空间,所述待识别函数的本地指令空间的地址范围用所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址来表示,其中,所述待识别函数的本地指令空间的终止地址大于或等于所述待识别函数的本地指令空间的起始地址,所述第一判断单元用于:
判断所述指令计数器中的指令地址是否大于或等于所述待识别函数的本地指令空间的起始地址,并且所述指令计数器中的指令地址是否小于或等于所述待识别函数的本地指令空间的终止地址;
在所述指令计数器中的指令地址大于或等于所述待识别函数的本地指令空间的起始地址,并且小于或等于所述待识别函数的本地指令空间的终止地址时,则指示所述指令计数器中的指令地址在所述待识别函数的本地指令空间的地址范围内。
根据第三方面,或以上第三方面的任意一种实现方式,在所述装置第五种可能的实现方式中,所述获取单元用于:周期性地获取所述指令计数器中的指令地址;相应的,
所述第二判断单元用于:在所述语言虚拟机返回所述待识别函数时,或在所述语言虚拟机返回所述待识别函数之后,判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值。
根据第三方面,或以上第三方面的任意一种实现方式,在所述装置第六种可能的实现方式中,所述装置还包括:计算单元和删除单元;
所述计算单元用于在所述第二判断单元判断所述更新单元得到的所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值之后,计算所述待识别函数的更新后的热度值减去所述待识别函数的在预设的时段之前的热度值而获得的差值,所述待识别函数的在预设的时段之前的热度值大于或等于所述待识别函数的热度值阈值;
所述删除单元用于在所述计算单元得到的所述差值小于预设的删除阈值时,将所述待识别函数的本地代码从用于存储所述待识别函数的本地代码的存储空间中删除。
第四方面,提供一种热点中间代码的识别装置,该装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于执行第二方面提供的方法。
第五方面,提供一种计算机存储介质,用于储存用于第三方面的处理器执行的计算机软件指令,以用于执行第二方面提供的方法。
从本发明实施例提供的以上实现方式可以看出,通过获取指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令,使得可以识别出热点中间代码。
为了更清楚地说明本发明实施例中的技术方案,下面将对实施例描述中所需要使用的附图作简单地介绍,显而易见地,下面描述中的附图仅仅是本发明的一些实施例,对于本领域普通技术人员来讲,在不付出创造性劳动性的前提下,还可以根据这些附图获得其他的附图。
图1为本发明实施例提供的一种语言虚拟机的示意性框图;
图2为本发明实施例提供的一种热点中间代码的识别装置的逻辑结构示意图;
图3为本发明实施例提供的一种硬件电路的逻辑结构示意图;
图4为本发明实施例提供的一种热点中间代码的识别方法流程示意图;
图5为本发明实施例提供的一种计算机设备的硬件结构示意图。
下面结合附图,对本发明的实施例进行描述。
图1为一种语言虚拟机100的示意性框图,语言虚拟机100是一个虚构出来的计算机,是通过在实际的计算机上仿真模拟各种计算机功能来实现的,语言虚拟机100可位于计算机设备的存储器中,通过计算机设备的处理器获取语言虚拟机100的代码(该代码为也称为主机端host方法,或者称为非客户端(guest)方法),并由处理器来执行语言虚拟机100的功能。语言虚拟机100包括执行引擎(execution engine)110和运行时数据区(runtime data area)120。
执行引擎110用于执行中间代码,包括解释器(Interpreter)112、即时(JIT,Just In Time)编译器114。
运行时数据区120用于存储语言虚拟机100运行过程中需要的数据,并在语言虚拟机100启动时创建,在语言虚拟机100推出时消除。运行时数据区120包括指令计数器(Program Counter Register)122,虚拟机栈(Stack)124,本地方法栈(Native Method Stack)126,方法区(Method Area)128
以及堆(Heap)130。其中,方法也可以称为函数,应理解,下文中如无特别说明,方法或是函数都应理解为客户端guest方法。
程序计数器122,是一块内存区域,用于存放下一条要执行的字节码指令指令计数器。
虚拟机栈124表示方法执行的内存模型,每调用一个方法,就会生成一个栈帧(Stack Frame),栈帧分为三部分:局部变量区(Local Variables)、操作数栈(Operand Stack)和帧数据区(Frame Data)。局部变量区用于存放方法中的局部变量和参数,操作数栈中用于存放方法执行过程中产生的中间结果。帧数据区用于常量池(constant_pool)中数据解析、方法执行后处理方法返回,恢复调用方法现场等,其中,常量池是在编译期被确定,并被保存在已编译的.class文件中。常量池中包括了关于类、方法或接口中的常量,也包括字符串常量和符号引用,每个类型都有自己的常量池。
本地方法栈126,与虚拟机栈类似,是执行本地方法时使用的,在语言虚拟机为JVM时,本地方法为由非JAVA语言实现的方法。
方法区128,用于存储已被虚拟机加载的类型信息、常量、静态变量、即时编译后的代码等信息。方法区128中有一部分是运行时常量池(Runtime Constant Pool),主要用来存储编译时生成的自变量和符号引用,常量也可以在运行时产生,如String的intern方法。
堆130,虚拟机中用于存放对象与数组实例的地方,Java堆只要求逻辑上是连续的,在物理空间上可以不连续。
图2为一种应用于语言虚拟机100的热点中间代码的识别装置200的逻辑结构示意图,如图2所示,热点中间代码的识别装置200包括获取单元202、第一判断单元204、更新单元206以及第二判断单元208。应理解,热点中间代码的识别装置200可以是计算机设备。热点中间代码的识别装置200中的单元可以通过软件编程实现,也可以通过硬件电路实现。该硬件电路或软件包括一个或多个热点中间代码的识别装置200中的单元。
在通过软件编程实现时,热点中间代码的识别装置200可以是包括语言虚拟机100的计算机设备,热点中间代码的识别装置200也可以是不包括语言虚拟机100的计算机设备,而是通过与包括语言虚拟机100的计算机设备建立信息的交互,以实现热点中间代码的识别装置200的各单元的功能。热点中间代码的识别装置200中的单元可以作为语言虚拟机100的执行单元,
也可以直接用于被计算机设备的处理器执行。
在通过硬件电路实现时,获取单元202称为获取电路,第一判断单元204称为第一判断电路,更新单元206称为更新电路,第二判断单元208称为第二判断电路,热点中间代码的识别装置200可以通过与包括语言虚拟机100的计算机设备建立信息的交互,建立信息的交互的方式有线连接或通过无线网络通信,以实现热点中间代码的识别装置200的各电路的功能;热点中间代码的识别装置200也可以是包括语言虚拟机100以及热点中间代码的识别装置200的各电路的计算机设备。
获取单元202,用于在待识别函数被语言虚拟机100执行时,获取指令计数器中的指令地址。其中,待识别函数也可称为待识别的方法。
需要说明的是,该指令计数器也可以称为程序计数器,但与语言虚拟机100中的程序计数器122不同,程序计数器122为一块存储下一条字节码(中间指令)的内存区域,而指令计数器为处理器中的寄存器,指令计数器中存放的是处理器将要执行的下一条本地指令的地址。指令计数器同样位于包括语言虚拟机100的计算机设备中。
具体地,获取单元202作为获取电路时,可以是与指令计数器相连接的指令地址寄存器302,该指令地址寄存器302通过接收触发电平,触发获取指令计数器中的指令地址的动作,指令地址寄存器302还用于存储获取到的指令地址。其中,这里的相连接包括物理上的连接,以及建立信息交互。
在具体实现过程中,触发电平可以是周期性的,例如在热点中间代码的识别装置200为计算机设备时,触发电平可以是热点中间代码的识别装置200自身的时钟信号或是将时钟信号分频得到的信号,获取电路(具体来说,可以是指令地址寄存器302)通过接收周期性的触发电平,可以周期性地触发所述获取所述指令计数器中的指令地址的动作。
第一判断单元204,用于根据获取单元202获取的指令计数器中的指令地址,判断指令计数器中的指令地址对应的本地指令是否为待识别函数的本地指令。
具体地,第一判断单元204可以用于通过该指令地址获得该指令地址对应的指令,并进一步判断该指令地址对应的指令是否为待识别函数的本地指令。
具体地,第一判断单元204可以用于判断指令计数器中的指令地址是否
在待识别函数的本地指令空间的地址范围内,待识别函数的本地指令存储于待识别函数的本地指令空间,并且该本地指令空间中的本地指令不包括用于实现语言虚拟机100功能的本地指令。应明白,在语言虚拟机100的解释器112执行待识别函数的中间代码时,所有中间指令对应的本地指令存储在存储器的内存中连续的存储空间内,具体来说,可以是存储在方法区128,解释器112通过查询该内存中连续的存储空间中的中间指令对应的本地指令,从而实现将待识别函数的中间代码中的中间指令逐个翻译成对应的本地指令。因此,在待识别函数的中间代码被解释器112执行时,该本地指令空间为用于存储可通过解释器112翻译获得的本地指令的存储空间,或者也可称为用于解释器112查询中间指令对应的本地指令的存储空间,该本地指令空间中的本地指令中的本地指令包括用于被解释器112翻译的中间指令对应的本地指令,用于被解释器112翻译的中间指令对应的本地指令包括待识别函数的本地指令。
同时也应明白,语言虚拟机100的即时编译器114在中间代码编译为本地代码后,会将本地代码存储在存储器的内存空间中,例如代码缓冲区(code cache),具体实现过程中,代码缓冲区可以位于方法区128中,因此在语言虚拟机100的及时编译器114执行待识别函数的本地代码时,该本地指令空间为用于存储待识别函数的本地代码的存储空间,其中,待识别函数的本地指令为待识别函数的本地代码中的指令。
在具体实现过程中,该本地指令空间可以为地址连续的存储空间,该本地指令空间的地址范围可以用该本地指令空间的起始地址和该本地指令空间的终止地址来表示,其中,该本地指令空间的终止地址大于或等于该本地指令空间的起始地址。
可选地,第一判断单元204可以用于:判断指令地址是否大于或等于待识别函数的本地指令空间的起始地址,并且指令地址是否小于或等于待识别函数的本地指令空间的终止地址;在指令地址大于或等于待识别函数的本地指令空间的起始地址,并且小于或等于待识别函数的本地指令空间的终止地址时,则指令计数器中的指令地址在待识别函数的本地指令空间的地址范围内。
可选地,第一判断单元204作为第一判断电路时还可以包括用于存储待识别函数的本地指令空间的起始地址的起始地址寄存器304,和用于存储待
识别函数的本地指令空间的终止地址的终止地址寄存器306。
可选的,第一判断电路可以包括第三比较器和第二比较器,第三比较器与指令地址寄存器302连接,第三比较器与起始地址寄存器304连接,第三比较器用于:比较指令地址寄存器302中的指令地址是否大于或等于起始地址寄存器304中的待识别函数的本地指令空间的起始地址;第二比较器与指令地址寄存器302连接,第二比较器与终止地址寄存器306连接,第二比较器用于:比较指令地址寄存器302中的指令地址是否小于或等于终止地址寄存器306中的待识别函数的本地指令空间的终止地址。其中,指令地址大于或等于待识别函数的本地指令空间的起始地址且小于或等于待识别函数的本地指令空间的终止地址,指示指令计数器中的指令地址在待识别函数的本地指令空间的地址范围内。
可选的,第一判断电路也可以包括第三减法器和第二减法器,第三减法器与指令地址寄存器302连接,第三减法器与起始地址寄存器304连接,第三减法器用于:通过获得指令地址寄存器302中的指令地址与起始地址寄存器304中的待识别函数的本地指令空间的起始地址的差值,以比较指令地址寄存器302中的指令地址是否大于或等于起始地址寄存器304中的待识别函数的本地指令空间的起始地址;第二减法器与指令地址寄存器302连接,第二减法器与终止地址寄存器306连接,第二减法器用于:通过获得指令地址寄存器302中的指令地址与终止地址寄存器306中的待识别函数的本地指令空间的终止地址的差值,以比较指令地址寄存器302中的指令地址是否小于或等于终止地址寄存器306中的待识别函数的本地指令空间的终止地址。其中,在指令地址大于或等于待识别函数的本地指令空间的起始地址且小于或等于待识别函数的本地指令空间的终止地址时,则指令计数器中的指令地址在待识别函数的本地指令空间的地址范围内。
更新单元206,用于在第一判断单元204确定指令计数器中的指令地址对应的本地指令为所述待识别函数的本地指令时,将所述待识别函数的当前的热度值增加预设值,以更新所述待识别函数的热度值。
具体地,更新单元206作为更新电路时可以是热度值计数器310,热度计数器为存储热度值的计数器,所述热度值计数器310用于将所述热度值计数器310中的所述待识别函数的热度值加1。
第二判断单元208,用于判断更新单元206得到的待识别函数的更新后
的热度值是否大于或等于待识别函数的热度阈值,在待识别函数的更新后的热度值大于所述待识别函数的热度阈值时,将待识别函数的中间代码作为热点中间代码。
可选地,获取单元202可以周期性获取指令计数器中的指令地址;相应的,第二判断单元208可以用于:在返回待识别函数时,或在返回待识别函数之后,判断待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值。
可选地,第二判断单元208作为第二判断电路可以包括用于存储待识别函数的热度阈值的阈值寄存器312。
可选地,第二判断电路还可以包括减法器314,减法器314与阈值寄存器312相连接,减法器314与热度值计数器310相连接,减法器314用于获取热度值计数器310中的待识别函数的热度值减去阈值寄存器312中的待识别函数的热度阈值的差值,其中,在所述差值大于0时,待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值。
可选地,第二判断电路也可以包括第一比较器,第一比较器与阈值寄存器312相连,第一比较器与热度值计数器310相连,第一比较器用于判断热度值计数器310中的待识别函数的更新后的热度值是否大于或等于阈值寄存器312中的待识别函数的热度阈值。其中,处理器可以直接或是间接获取减法器314或是第一比较器的输出结果,以确认待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值。
在具体实现过程中,在第一判断电路包括第三减法器、第二减法器时,可以将热度值计数器310直接第三减法器、第二减法器,也可以将第三减法器与第二减法器先通过逻辑门电路间接连接至热度值计数器310,在第三减法器、第二减法器的输出指示待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值时,热度值计数器310触发加1的计数。
在具体实现过程中,在第一判断电路包括第三比较器、第二比较器时,可以将热度值计数器310直接第三比较器、第二比较器,也可以将第三比较器与第二比较器先通过逻辑门电路间接连接至热度值计数器310,在第三比较器、第二比较器的输出指示待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值时,热度值计数器310触发加1的计数。
具体地,在将待识别函数的中间代码作为热点中间代码之后,可以通过
即时编译器114将待识别函数的中间代码编译为待识别函数的本地代码。
在具体实现的过程中,可以为每个函数建立一个对应的数据结构体,将该数据结构体命名为metadata,数据结构体可以是例如类(class)或是结构(struct),以待识别函数为例,可以在待识别函数的metadata中记录的数据包括:待识别函数的标识、待识别函数的起始地址、待识别函数的终止地址、待识别函数的热度值和待识别函数的热度阈值,对于不同的函数都是用相同的热度阈值的情况,待识别函数的metadata中可以没有待识别函数的热度阈值,而是将热度阈值作为函数公共的值;对于本实施例仅应用于在解释器112执行中间代码的过程中进行热点识别的情况,待识别函数的metadata中可以没有待识别函数的起始地址、待识别函数的终止地址,而是将起始地址和终止地址作为函数的公共的值。其中,待识别函数的标识,用于在将待识别函数的中间代码作为热点中间代码之后,使即时编译器通过待识别函数的标识获得待识别函数的中间代码,从而将待识别函数的中间代码编译为待识别函数的本地代码。由于待识别函数的标识并不用于热点识别,因此,对于中间代码的热点识别来说待识别函数的metadata中可以没有待识别函数的标识。
具体地,热点中间代码的识别装置200可以包括处理器和存储器,存储器用于存储代码,处理器可以通过读取存储器中存储的代码,可以用于:在待识别函数被语言虚拟机100调用时,加载待识别函数的当前的热度值到热度值计数器310,在待识别函数被语言虚拟机100返回时,保存热度值计数器310中的待识别函数的更新后的热度值到存储器。
可选地,处理器还可以用于:在待识别函数被语言虚拟机100调用时,保存热度值计数器310中的主调函数的更新后的热度值到存储器,待识别函数为主调函数的子函数,或者说在主调函数的函数体中包含对待识别函数的调用指令,在所述待识别函数被语言虚拟机100返回时,加载所述主调函数的当前的热度值到热度值计数器310。
可选地,处理器还可以用于:在待识别函数被语言虚拟机100调用时,加载待识别函数的本地指令空间的起始地址到起始地址寄存器304,加载待识别函数的本地指令空间的终止地址到终止地址寄存器306。
可选地,处理器还可以用于:在待识别函数被语言虚拟机100返回时,保存起始地址寄存器304中的待识别函数的本地指令空间的起始地址到存储器,保存终止地址寄存器306中的待识别函数的本地指令空间的终止地址到
存储器。
可选地,处理器还可以用于:在待识别函数被调用时,保存起始地址寄存器304中的主调函数的本地指令空间的起始地址到存储器,保存终止地址寄存器306中的主调函数的本地指令空间的终止地址到存储器。
可选地,处理器还可以用于:在待识别函数被语言虚拟机100返回时,加载主调函数的本地指令空间的起始地址到起始地址寄存器304,加载主调函数的本地指令空间的终止地址到终止地址寄存器306。
在具体实现过程中,为了实现上述的加载以及保存的操作,可以通过修改函数调用的指令,以及修改函数返回的指令实现,以汇编指令为例,可以将函数调用指令增加一个操作数,增加的操作数可以是待识别函数的metadata的地址,如函数的metadata的指针,应理解,可以在存储器中设置一段存储空间用于存储当前正在执行的函数的metadata的指针空间,该存储空间可以例如但不限于寄存器,以及在存储器中设置用于存放metadata指针的指针栈。
以用增加了操作数的函数调用指令调用待识别函数为例,如果增加的操作数的值为预设的值(比如0),则将该增加了操作数的函数调用指令作为现有技术中的函数调用指令,如果增加的操作数不为预设的值,则将增加的操作数作为待识别函数的metadata的指针,执行如下操作:其中可选的操作有:1)根据指针空间中的主调函数的metadata的指针,保存热度值计数器310中的值到主调函数的metadata中的存储待识别函数的热度值的存储空间;2)将指针空间中的主调函数的metadata的指针压入指针栈,在具体实现过程中,指针栈可以建立在虚拟机栈124中,只用于存储metadata的指针;3)加载待识别函数的metadata的指针到指针空间;4)根据待识别函数的metadata的指针,加载待识别函数的热度值到热度值计数器310;5)根据待识别函数的metadata的指针,加载待识别函数的起始地址到起始地址寄存器304,加载待识别函数的终止地址到终止地址寄存器306。其中必选的操作有:1)将主调函数的返回地址压栈;2)跳转到待识别函数的执行入口。
在具体实现过程中,以汇编指令为例,可以将函数返回指令增加一个操作数,增加的操作数可以是一个标识,用于指示增加了操作数的函数返回指令执行以下操作:其中可选的有:1)根据指针空间中待识别函数的metadata的指针,保存热度值计数器310中的热度值到待识别函数的metadata中的存
储待识别函数的热度值的存储空间;2)从指针栈中弹出主调函数的metadata的指针,将主调函数的metadata的指针加载到指针空间;3)根据指针空间中的主调函数的metadata的指针,加载主调函数的热度值到热度值计数器310;4)根据指针空间中的主调函数的metadata的指针,加载主调函数的起始地址到起始地址寄存器304,加载主调函数的终止地址到终止地址寄存器306。其中必选的有:1)从栈中弹出主调函数的返回地址,返回到主调函数执行。
可选的,处理器还可以用于:在返回待识别函数时,或在返回待识别函数之后,触发第二判断单元208进行判断更新单元206得到的待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值的动作。
可选地,在第二判断单元208的输出结果指示待识别函数的更新后的热度值大于或等于待识别函数的热度阈值之后,即时编译器114的轻量级编译器或是重量级编译器,可以将待识别函数的中间代码编译成识别函数的本地代码。
可选地,处理器还可以用于:在第二判断单元208的输出结果指示待识别函数的更新后的热度值大于或等于待识别函数的热度阈值之后,将待识别函数的更新后的热度值存储在存储器中;在待识别函数的在预设的时段之前的热度值大于或等于待识别函数的热度值阈值时,计算存储器中待识别函数的更新后的热度值减去所述待识别函数的在预设的时段之前的热度值而获得的差值,待识别函数的在预设的时段之前的热度值存储在所述存储器中;在差值小于预设的删除阈值时,将所述待识别函数的本地代码从存储器(例如存储器中的代码缓冲区)中删除。
该选择性的将所述待识别函数的本地代码从所述存储器中删除的方案的目的在于实时的监控编译获得的本地代码的执行频率,在具体实现过程中,可以每隔一定的时间,通过遍历指针栈中的指针,获取每个函数存储在每个函数的metadata的热度值,可以通过第二判断单元208(也可以通过与第二判断单元有相同功能的单元)进行判断,从而得到热度值大于热度阈值的函数,然后可以将热度值大于热度阈值的函数以[method,count1]的形式写入链表1(也可以采用其它的方式将热度值存储在存储器中),其中method为函数信息,count1为函数存储在每个函数的metadata的热度值。同时,存在另一个链表2存储了[method,count2],其中count2为上一次遍历指针栈中
的指针时,获得的热度值大于热度阈值的函数的当时的热度值。以待识别函数为例,在存在待识别函数的count2时,可以将待识别函数的count1与count2相减,如果相减的值小于删除阈值,说明待识别函数在上一次遍历到这次遍历的时段内被执行的频率不高,可以将待识别函数的本地代码从存储器中删除,预留空间给近期被执行频率高的方法,提升存储空间使用率。
可选地,作为另一种删除操作的实现方式,热点中间代码的识别装置200还可以包括计算单元和删除单元;
计算单元用于在更新单元206得到的待识别函数的更新后的热度值大于或等于待识别函数的热度阈值之后,计算待识别函数的更新后的热度值减去待识别函数的在预设的时段之前的热度值而获得的差值,待识别函数的在预设的时段之前的热度值大于或等于待识别函数的热度值阈值。
其中计算单元作为计算电路时,可以与更新单元206连接完成判断待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值的操作,也可以通过与第二判断单元208连接以获得判断结果。
所述删除单元用于在计算单元得到的差值小于预设的删除阈值时,将待识别函数的本地代码从待识别函数的本地代码的存储空间(例如代码缓冲区)中删除。
应理解,热点中间代码的识别装置200中的单元(获取单元202、第一判断单元204、更新单元206或第二判断单元208)在不同的实现方式下,会与存储器、处理器有不同的关系,热点中间代码的识别装置200中由软件实现的单元可以位于存储器中,由处理器从存储器中读取来实现单元的功能。热点中间代码的识别装置200中由硬件电路实现的单元可以集成在处理器上,或是与处理器连接。
应理解,由于减法操作在硬件电路实现时也可以用加法器实现,因此本发明实施例中的各个减法器可由加法器代替,以实现减法操作。
举例来说,图3为热点中间代码的识别装置200的一种硬件电路实现方式,应理解,本发明实施例的热点中间代码的识别装置200的硬件电路的实现方式并不限于此,并且图3中各单元的连接方式不限于此。其中,比较器308包括第二比较器和第三比较器,或者,比较器308包括第二减法器和第三减法器,关于第二减法器、第三减法器、第二比较器、第三比较器、终止地址寄存器306、指令地址寄存器302、起始地址寄存器304、热度值计数器
310、阈值寄存器312以及减法器314的内容,在上文中已经做了详细介绍,这里不再赘述。
图4为一种应用于语言虚拟机100的热点中间代码的识别方法的流程示意图,该方法可以由热点中间代码的识别装置200执行,该方法步骤如下:
S401,在待识别函数被语言虚拟机100执行时,获取指令计数器中的指令地址。
S402,判断指令计数器中的指令地址对应的本地指令是否为待识别函数的本地指令。
具体来说,作为判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令的可选的实现方式,可以判断指令计数器中的指令地址是否在待识别函数的本地指令空间的地址范围内,待识别函数的本地指令空间中的本地指令包括待识别函数的本地指令,并且待识别函数的本地指令空间中的本地指令不包括用于实现所述语言虚拟机功能的本地指令,待识别函数的本地指令空间存储本地指令。
可选的,在被执行是待识别函数的中间代码时,语言虚拟机100包括解释器112,本地指令空间可以为用于存储可通过解释器112翻译获得的本地指令的存储空间,或者,待识别函数的本地指令空间中的本地指令包括用于被解释器112翻译的中间指令对应的本地指令,用于所述解释器翻译的中间指令对应的本地指令包括待识别函数的本地指令。
可选的,在被执行是待识别函数的本地代码时,语言虚拟机100包括及时编译器114,本地指令空间可以用于存储待识别函数的本地代码,待识别函数的本地指令为待识别函数的本地代码中的指令,待识别函数的本地代码通过及时编译器114编译获得。
可选的,本地指令空间为地址连续的存储空间,本地指令空间的地址范围用本地指令空间的起始地址和本地指令空间的终止地址来表示,其中,待识别函数的本地指令空间的终止地址大于或等于待识别函数的本地指令空间的起始地址,判断指令计数器中的指令地址是否在待识别函数的本地指令空间的地址范围内可以为:判断指令计数器中的指令地址是否大于或等于待识别函数的本地指令空间的起始地址,并且指令地址是否小于或等于待识别函数的本地指令空间的终止地址;在指令地址大于或等于待识别函数的本地指令空间的起始地址,并且小于或等于待识别函数的本地指令空间的终止地
址时,则指示指令计数器中的指令地址在待识别函数的本地指令空间的地址范围内。
可选的,可以周期性地获取指令计数器中的指令地址,从而用于更新待识别函数的热度值。
S403,在指令计数器中的指令地址对应的本地指令为待识别函数的本地指令时,将待识别函数的当前的热度值增加预设值,以更新待识别函数的热度值。预设值为正数,例如正整数,可选的,增加的预设值可以是1。
S404,判断待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值,在待识别函数的更新后的热度值大于或等于待识别函数的热度阈值时,将待识别函数的中间代码作为热点中间代码。
可选地,可以将待识别函数的中间代码作为热点中间代码,将热点中间代码通过及时编译器114编译为待识别函数的本地代码。
可选地,可以在语言虚拟机100返回待识别函数时,或在语言虚拟机100返回待识别函数之后,才判断待识别函数的更新后的热度值是否大于或等于待识别函数的热度阈值。
可选地,在待识别函数的在预设的时段之前的热度值大于或等于待识别函数的热度值阈值时,计算待识别函数的更新后的热度值减去待识别函数的在预设的时段之前的热度值而获得的差值;在差值小于预设的删除阈值时,将待识别函数的本地代码从待识别函数的本地代码的存储空间中删除。应理解,待识别函数的在预设的时段之前的热度值可以理解为待识别函数的在时刻A当时的热度值,其中,当前时刻为B,时刻A比时刻B提前预设的时段。在将待识别函数的本地代码从用于存储所述待识别函数的本地代码的存储空间中删除之后,还可以将待识别函数的热度值清零。
由于与本发明方法实施例与装置实施例基于同一构思,具体内容可参见本发明装置实施例中相应的部件所进行的操作的叙述,此处不再赘述。
图5是本发明实施例提供的计算机设备500的硬件结构示意图。如图5所示,计算机设备500可以作为热点中间代码的识别装置200的一种实现方式,计算机设备500包括处理器502、存储器504、输入/输出接口506、通信接口508和总线510。其中,处理器502、存储器504、输入/输出接口506和通信接口508通过总线510实现彼此之间的通信连接。
处理器502可以采用通用的中央处理器(Central Processing Unit,CPU),
微处理器,应用专用集成电路(Application Specific Integrated Circuit,ASIC),或者一个或多个集成电路,用于执行相关程序,以实现本发明实施例所提供的技术方案。
存储器504可以是只读存储器(Read Only Memory,ROM),静态存储设备,动态存储设备或者随机存取存储器(Random Access Memory,RAM)。存储器504可以存储操作系统、语言虚拟机100以及其他应用程序。在通过软件或者固件来实现本发明实施例提供的热点中间代码的识别装置200中包括的单元以及部件所需执行的功能,或者执行本发明方法实施例提供的上述方法时,用于实现本发明实施例提供的技术方案的程序代码保存在存储器504中,并由处理器502来执行热点中间代码的识别装置200中包括的单元以及部件所需执行的操作,或者执行本发明方法实施例提供的上述方法。
输入/输出接口506用于接收输入的数据和信息,输出操作结果等数据。
通信接口508使用例如但不限于收发器一类的收发装置,来实现计算机设备500与其他设备或通信网络之间的通信。
总线510可包括在计算机设备500各个部件(例如处理器602、存储器504、输入/输出接口506和通信接口508)之间传送信息的通路。
应注意,尽管图5所示的计算机设备500仅仅示出了处理器502、存储器504、输入/输出接口506、通信接口508以及总线510,但是在具体实现过程中,本领域的技术人员应当明白,计算机设备500还包含实现正常运行所必须的其他器件,例如显示屏幕。同时,根据具体需要,本领域的技术人员应当明白,计算机设备500还可包含实现其他附加功能的硬件器件。此外,本领域的技术人员应当明白,计算机设备500也可仅仅包含实现本发明实施例所必须的器件,而不必包含图5中所示的全部器件。
需要说明的是,对于前述的各方法实施例,为了简单描述,故将其都表述为一系列的动作组合,但是本领域技术人员应该知悉,本发明并不受所描述的动作顺序的限制,因为依据本发明,某些步骤可以采用其他顺序或者同时进行。其次,本领域技术人员也应该知悉,说明书中所涉及的动作和单元并不一定是本发明所必须的。
本领域普通技术人员可以理解实现上述实施例方法中的全部或部分流程,是可以通过计算机程序来指令相关的硬件来完成,上述的程序可存储于一种计算机可读取存储介质中,该程序在执行时,可包括如上述各方法的实
施例的流程。其中,上述的存储介质可为磁碟、光盘、只读存储记忆体(ROM:Read-Only Memory)或随机存储记忆体(RAM:Random Access Memory)等。
尽管在此结合各实施例对本发明进行了描述,然而,在实施所要保护的本发明的过程中,本领域技术人员通过查看所述附图、公开内容、以及所附权利要求书,可理解并实现所述公开实施例的其它变化。在权利要求中,“包括”(comprising)一词不排除其它组成部分或步骤,“一”或“一个”不排除多个的可能性。单个处理器或其它单元可以实现权利要求中列举的若干项功能。互相不同的从属权利要求中记载了某些措施,但这并不代表这些措施不能组合起来产生良好的效果。计算机程序可以存储/分布在合适的介质中,例如:光存储介质或固态介质,与其它硬件一起提供或作为硬件的一部分,也可以采用其它分布形式,如通过Internet或其它有线或无线电信系统。
本文中应用了具体个例对本发明的原理及实施方式进行了阐述,以上实施例的说明只是用于帮助理解本发明的方法及其思想;同时,对于本领域的一般技术人员,依据本发明的思想,在具体实施方式及应用范围上均会有改变之处,综上所述,本说明书内容不应理解为对本发明的限制。
Claims (22)
- 一种热点中间代码的识别方法,其特征在于,所述方法包括:在待识别函数被语言虚拟机执行时,获取指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令;在所述指令计数器中的指令地址对应的本地指令为所述待识别函数的本地指令时,将所述待识别函数的当前的热度值增加预设值,以更新所述待识别函数的热度值;判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值,在所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值时,将所述待识别函数的中间代码作为热点中间代码。
- 根据权利要求1所述的方法,其特征在于,所述判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令,包括:判断所述指令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内,所述待识别函数的本地指令空间中的本地指令包括所述待识别函数的本地指令所述待识别函数的本地指令空间,并且所述待识别函数的本地指令空间中的本地指令不包括用于实现所述语言虚拟机功能的本地指令。
- 根据权利要求2所述的方法,其特征在于,所述语言虚拟机包括解释器,所述待识别函数的本地指令空间中的本地指令包括用于被所述解释器翻译的中间指令对应的本地指令,所述用于所述解释器翻译的中间指令对应的本地指令包括所述待识别函数的本地指令。
- 根据权利要求2所述的方法,其特征在于,所述语言虚拟机包括及时编译器,所述待识别函数的本地指令空间用于存储所述待识别函数的本地代码,所述待识别函数的本地指令为所述待识别函数的本地代码中的指令,所述待识别函数的本地代码通过所述及时编译器编译获得。
- 根据权利要求2至4任一项所述的方法,所述待识别函数的本地指令空间为地址连续的存储空间,所述待识别函数的本地指令空间的地址范围用所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址来表示,其中,所述待识别函数的本地指令空间的终止地址大于或等于所述待识别函数的本地指令空间的起始地址,所述判断所述指 令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内包括:判断所述指令计数器中的指令地址是否大于或等于所述待识别函数的本地指令空间的起始地址,并且所述指令计数器中的指令地址是否小于或等于所述待识别函数的本地指令空间的终止地址;在所述指令计数器中的指令地址大于或等于所述待识别函数的本地指令空间的起始地址,并且小于或等于所述待识别函数的本地指令空间的终止地址时,则指示所述指令计数器中的指令地址在所述待识别函数的本地指令空间的地址范围内。
- 根据权利要求1至5任一项所述的方法,其特征在于,所述获取指令计数器中的指令地址包括:周期性地获取所述指令计数器中的指令地址;所述判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值包括:在所述语言虚拟机返回所述待识别函数时,或在所述语言虚拟机返回所述待识别函数之后,判断所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值。
- 根据权利要求1至6任一项所述的方法,其特征在于,在判断所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值之后,所述方法还包括:在所述待识别函数的在预设的时段之前的热度值大于或等于所述待识别函数的热度值阈值时,计算所述待识别函数的更新后的热度值减去所述待识别函数的在预设的时段之前的热度值而获得的差值;在所述差值小于预设的删除阈值时,将所述待识别函数的本地代码从所述待识别函数的本地代码的存储空间中删除。
- 一种热点中间代码的识别装置,其特征在于,所述装置包括:获取电路,用于在待识别函数被语言虚拟机执行时,获取指令计数器中的指令地址;第一判断电路,用于根据所述获取单元获取的所述指令计数器中的指令地址,判断所述指令计数器中的指令地址对应的本地指令是否为所述待识别函数的本地指令;更新电路,用于在所述第一判断单元确定所述指令计数器中的指令地址 对应的本地指令为所述待识别函数的本地指令时,将所述待识别函数的当前的热度值增加预设值,以更新所述待识别函数的热度值;第二判断电路,用于判断所述更新单元得到的所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值,在所述待识别函数的更新后的热度值大于所述待识别函数的热度阈值时,将所述待识别函数的中间代码作为热点中间代码。
- 根据权利要求8所述的装置,其特征在于,所述第一判断电路用于:判断所述指令计数器中的指令地址是否在所述待识别函数的本地指令空间的地址范围内,所述待识别函数的本地指令空间中的本地指令包括所述待识别函数的本地指令,并且所述待识别函数的本地指令空间中的本地指令不包括用于实现所述语言虚拟机功能的本地指令。
- 根据权利要求9所述的装置,其特征在于,所述语言虚拟机包括解释器,所述待识别函数的本地指令空间中的本地指令包括用于被所述解释器翻译的中间指令对应的本地指令,所述用于所述解释器翻译的中间指令对应的本地指令包括所述待识别函数的本地指令。
- 根据权利要求9所述的装置,其特征在于,所述语言虚拟机包括及时编译器,所述待识别函数的本地指令空间用于存储所述待识别函数的本地代码,所述待识别函数的本地指令为所述待识别函数的本地代码中的指令,所述待识别函数的本地代码通过所述及时编译器编译获得。
- 根据权利要求8至11任一项所述的装置,所述更新电路包括热度值计数器,所述热度值计数器用于:将所述热度值计数器中的所述待识别函数的热度值加1。
- 根据权利要求12所述的装置,其特征在于,所述第二判断电路包括减法器和用于存储所述待识别函数的热度阈值的阈值寄存器,所述减法器与所述阈值寄存器相连,所述减法器与所述热度值计数器相连,所述减法器用于获取所述热度值计数器中的所述待识别函数的热度值减去所述阈值寄存器中的所述待识别函数的热度阈值的差值,其中,所述差值大于0指示所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值。
- 根据权利要求12所述的装置,其特征在于,所述第二判断电路包括第一比较器和用于存储所述待识别函数的热度阈值的阈值寄存器,所述第一比较器与所述阈值寄存器相连,所述第一比较器与所述热度值计数器相 连,所述第一比较器用于判断所述热度值计数器中的所述待识别函数的更新后的热度值是否大于或等于所述阈值寄存器中的所述待识别函数的热度阈值。
- 根据权利要求13或14所述的装置,其特征在于,所述装置还包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:在所述待识别函数被所述语言虚拟机调用时,加载所述待识别函数的当前的热度值到所述热度值计数器;在所述待识别函数被所述语言虚拟机返回时,保存所述热度值计数器中的所述待识别函数的更新后的热度值到所述存储器。
- 根据权利要求15所述的装置,其特征在于,所述处理器还用于:在所述待识别函数被所述语言虚拟机调用时,保存所述热度值计数器中的主调函数的更新后的热度值到所述存储器,所述待识别函数为所述主调函数的子函数;在所述待识别函数被所述语言虚拟机返回时,加载所述主调函数的当前的热度值到所述热度值计数器。
- 根据权利要求9至16任一项所述的装置,其特征在于,所述获取电路包括与指令计数器相连接的指令地址寄存器,所述指令地址寄存器通过接收触发电平,触发所述获取指令计数器中的指令地址的动作,所述指令地址寄存器还用于存储所述指令计数器中的指令地址。
- 根据权利要求17所述的装置,其特征在于,所述待识别函数的本地指令空间为地址连续的存储空间,所述待识别函数的本地指令空间的地址范围用所述待识别函数的本地指令空间的起始地址和所述待识别函数的本地指令空间的终止地址来表示,其中,所述待识别函数的本地指令空间的终止地址大于或等于所述待识别函数的本地指令空间的起始地址;所述第一判断电路包括用于存储所述待识别函数的本地指令空间的起始地址的起始地址寄存器,和用于存储所述待识别函数的本地指令空间的终止地址的终止地址寄存器,第三比较器和第二比较器,所述第三比较器与所述指令地址寄存器连接,所述第三比较器与所述起始地址寄存器连接,所述第三比较器用于:比较所述指令地址寄存器中的所述指令计数器中的指令地址是否大于或等于所述起始地址寄存器中的所述待识别函数的本地指令空 间的起始地址;所述第二比较器与所述指令地址寄存器连接,所述第二比较器与所述终止地址寄存器连接,所述第二比较器用于:比较所述指令地址寄存器中的所述指令计数器中的指令地址是否小于或等于所述终止地址寄存器中的所述待识别函数的本地指令空间的终止地址,其中,在所述指令计数器中的指令地址大于或等于所述待识别函数的本地指令空间的起始地址且小于或等于所述待识别函数的本地指令空间的终止地址时,则指示所述指令计数器中的指令地址在所述待识别函数的本地指令空间的地址范围内。
- 根据权利要求18所述的装置,其特征在于,所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:在所述待识别函数被所述语言虚拟机调用时,加载所述待识别函数的本地指令空间的起始地址到所述起始地址寄存器,加载所述待识别函数的本地指令空间的终止地址到所述终止地址寄存器。
- 根据权利要求19所述的语言虚拟机,其特征在于,所述处理器用于:在所述待识别函数被所述语言虚拟机返回时,加载主调函数的本地指令空间的起始地址到所述起始地址寄存器,加载所述主调函数的本地指令空间的终止地址到所述终止地址寄存器,所述待识别函数为所述主调函数的子函数。
- 根据权利要求8至20任一项所述的语言虚拟机,其特征在于,所述获取电路用于:通过接收周期性的触发电平,周期性地触发所述获取所述指令计数器中的指令地址的动作;所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述存储器中存储的所述代码,以用于:在所述语言虚拟机返回所述待识别函数时,或在所述语言虚拟机返回所述待识别函数之后,触发所述第二判断电路进行所述判断所述更新电路得到的所述待识别函数的更新后的热度值是否大于或等于所述待识别函数的热度阈值的动作。
- 根据权利要求8至21任一项所述的装置,其特征在于,所述装置包括处理器和存储器;所述存储器用于存储代码;所述处理器通过读取所述 存储器中存储的所述代码,以用于:在所述第二判断电路判断所述待识别函数的更新后的热度值大于或等于所述待识别函数的热度阈值之后,将所述待识别函数的更新后的热度值存储在所述存储器;在所述待识别函数的在预设的时段之前的热度值大于或等于所述待识别函数的热度值阈值时,计算所述存储器中所述待识别函数的更新后的热度值减去所述待识别函数的在预设的时段之前的热度值而获得的差值,所述待识别函数的在预设的时段之前的热度值为存储在所述存储器中;在所述差值小于预设的删除阈值时,将所述待识别函数的本地代码从所述存储器中删除。
Priority Applications (3)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
KR1020187018366A KR102112081B1 (ko) | 2015-12-02 | 2016-08-19 | 언어 가상 머신에서 고-사용 중간 코드를 식별하는 방법 및 디바이스 |
EP16869720.9A EP3379412A4 (en) | 2015-12-02 | 2016-08-19 | METHOD AND DEVICE FOR IDENTIFYING A HIGH-PARTICULAR CODE IN A VIRTUAL LANGUAGE MACHINE |
US15/995,555 US10871976B2 (en) | 2015-12-02 | 2018-06-01 | Method and apparatus for identifying hotspot intermediate code in language virtual machine |
Applications Claiming Priority (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201510872247.7A CN105511942B (zh) | 2015-12-02 | 2015-12-02 | 语言虚拟机中热点中间代码的识别方法以及装置 |
CN201510872247.7 | 2015-12-02 |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US15/995,555 Continuation US10871976B2 (en) | 2015-12-02 | 2018-06-01 | Method and apparatus for identifying hotspot intermediate code in language virtual machine |
Publications (1)
Publication Number | Publication Date |
---|---|
WO2017092409A1 true WO2017092409A1 (zh) | 2017-06-08 |
Family
ID=55719948
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
PCT/CN2016/096068 WO2017092409A1 (zh) | 2015-12-02 | 2016-08-19 | 语言虚拟机中热点中间代码的识别方法以及装置 |
Country Status (5)
Country | Link |
---|---|
US (1) | US10871976B2 (zh) |
EP (1) | EP3379412A4 (zh) |
KR (1) | KR102112081B1 (zh) |
CN (1) | CN105511942B (zh) |
WO (1) | WO2017092409A1 (zh) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112068926A (zh) * | 2020-07-31 | 2020-12-11 | 中国科学院信息工程研究所 | 一种局域网内虚拟机的识别方法 |
CN116342541A (zh) * | 2023-03-29 | 2023-06-27 | 中国矿业大学 | 一种基于相邻图像孔隙融合重构的岩土体渗透率计算方法 |
Families Citing this family (13)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN105511942B (zh) * | 2015-12-02 | 2019-02-19 | 华为技术有限公司 | 语言虚拟机中热点中间代码的识别方法以及装置 |
CN109426503B (zh) * | 2017-07-21 | 2022-05-31 | 华为技术有限公司 | 提供仿真激励的方法及装置 |
CN109710396B (zh) * | 2017-10-26 | 2023-08-22 | 华为技术有限公司 | 一种信息采集及内存释放的方法及装置 |
CN108415719B (zh) * | 2018-03-29 | 2019-03-19 | 网易(杭州)网络有限公司 | 代码热更新方法和装置、存储介质、处理器及终端 |
CN108470072B (zh) * | 2018-03-30 | 2019-07-09 | 迅讯科技(北京)有限公司 | 一种查询编译方法和装置 |
US10802854B2 (en) * | 2019-08-30 | 2020-10-13 | Alibaba Group Holding Limited | Method and apparatus for interpreting bytecode instruction stream |
CN111258557B (zh) * | 2020-01-16 | 2023-08-18 | Oppo(重庆)智能科技有限公司 | 代码处理方法、装置、电子设备及计算机可读介质 |
US11115494B1 (en) * | 2020-02-26 | 2021-09-07 | International Business Machines Corporation | Profile clustering for homogenous instance analysis |
CN111880800B (zh) * | 2020-06-19 | 2023-10-31 | 无锡融卡科技有限公司 | 应用下载方法与应用下载系统 |
CN113872948A (zh) * | 2020-08-31 | 2021-12-31 | 支付宝(杭州)信息技术有限公司 | 一种执行智能合约的方法、区块链节点和节点设备 |
CN112199116B (zh) * | 2020-10-16 | 2023-08-11 | 常熟理工学院 | 操作数栈寄存器识别方法、装置、设备及存储介质 |
US12073218B2 (en) * | 2021-03-08 | 2024-08-27 | Unisys Corporation | System and method for the detection of processing hot-spots |
CN115563015B (zh) * | 2022-11-09 | 2023-07-07 | 科东(广州)软件科技有限公司 | 一种代码热度统计方法、装置、设备和存储介质 |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030084432A1 (en) * | 2001-10-31 | 2003-05-01 | Tetsuyuki Kobayashi | Intermediate code preprocessing apparatus, intermediate code execution apparatus, intermediate code execution system, and computer program product for preprocessing or executing intermediate code |
CN1790267A (zh) * | 2005-12-14 | 2006-06-21 | 浙江大学 | 应用于Java操作系统中虚拟机的编译体系实现方法 |
CN103399780A (zh) * | 2013-07-03 | 2013-11-20 | 清华大学 | 一种基于虚拟机技术和动态符号执行的整数溢出检测方法 |
CN105511942A (zh) * | 2015-12-02 | 2016-04-20 | 华为技术有限公司 | 语言虚拟机中热点中间代码的识别方法以及装置 |
Family Cites Families (31)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5394537A (en) * | 1989-12-13 | 1995-02-28 | Texas Instruments Incorporated | Adaptive page placement memory management system |
US6530075B1 (en) * | 1998-12-03 | 2003-03-04 | International Business Machines Corporation | JIT/compiler Java language extensions to enable field performance and serviceability |
GB2358261B (en) * | 2000-01-17 | 2004-06-09 | Advanced Risc Mach Ltd | Data processing with native and interpreted program instruction words |
SE0002440D0 (sv) * | 2000-06-28 | 2000-06-28 | Virtutech Ab | Interpreter |
US7873814B1 (en) * | 2000-12-22 | 2011-01-18 | Lsi Corporation | Microcode based hardware translator to support a multitude of processors |
US7350200B2 (en) * | 2001-03-29 | 2008-03-25 | Intel Corporation | Method and system of controlling dynamically compiled native code size |
JP3786644B2 (ja) * | 2001-04-23 | 2006-06-14 | アトメル・コーポレイション | バイトコンパイルされたJava(R)コードを実行するためのマイクロプロセッサ |
US20040088690A1 (en) * | 2002-08-27 | 2004-05-06 | Hayim Shaul | Method for accelerating a computer application by recompilation and hardware customization |
US7150012B2 (en) * | 2002-10-15 | 2006-12-12 | Nokia Corporation | Method and apparatus for accelerating program execution in platform-independent virtual machines |
US7197573B1 (en) * | 2002-11-18 | 2007-03-27 | Packet Design, Inc. | System and method for identifying addresses to modify and the effects thereof |
US7412693B2 (en) * | 2004-03-05 | 2008-08-12 | Sun Microsystems, Inc. | Method and apparatus for determining frequency of execution for compiled methods within a virtual machine |
US7765527B2 (en) * | 2005-09-29 | 2010-07-27 | International Business Machines Corporation | Per thread buffering for storing profiling data |
US9009688B2 (en) * | 2005-12-30 | 2015-04-14 | Intel Corporation | Type checking for object-oriented programming languages |
US8225291B2 (en) * | 2008-01-04 | 2012-07-17 | International Business Machines Corporation | Automated detection of application performance bottlenecks |
KR100943887B1 (ko) | 2008-02-05 | 2010-02-24 | 재단법인서울대학교산학협력재단 | 핫스팟 메소드의 동적 컴파일을 위해 수행 시간을 추정하는방법 |
US8281296B2 (en) * | 2008-08-12 | 2012-10-02 | Oracle America, Inc. | Cross-ISA inlining in a system virtual machine |
US8307353B2 (en) * | 2008-08-12 | 2012-11-06 | Oracle America, Inc. | Cross-domain inlining in a system virtual machine |
CN102231130B (zh) * | 2010-01-11 | 2015-06-17 | 国际商业机器公司 | 计算机系统性能分析方法和装置 |
CN101963907A (zh) | 2010-10-14 | 2011-02-02 | 中国科学技术大学苏州研究院 | 一种计算机程序热点的动态剖析机制 |
US8756581B2 (en) * | 2011-02-03 | 2014-06-17 | International Business Machines Corporation | Adaptive next-executing-cycle trace selection for trace-driven code optimizers |
CN103294517B (zh) * | 2012-02-22 | 2018-05-11 | 国际商业机器公司 | 堆栈溢出保护装置、堆栈保护方法、相关编译器和计算装置 |
KR102023351B1 (ko) * | 2013-03-19 | 2019-11-04 | 삼성전자 주식회사 | 저장 장치 내 할당 촉진을 위한 데이터 분석 방법 및 장치 |
US10114728B2 (en) | 2013-04-11 | 2018-10-30 | Nec Corporation | Dynamic function-level hardware performance profiling for application performance analysis |
US9372773B2 (en) | 2013-06-12 | 2016-06-21 | Advanced Micro Devices, Inc. | User-level hardware branch records |
EP3014423B1 (en) * | 2013-06-28 | 2018-03-07 | Intel Corporation | Binary translation for multi-processor and multi-core platforms |
CN103473168B (zh) | 2013-09-12 | 2016-05-04 | 中国科学院声学研究所 | 一种热点程序的统计方法 |
US9519466B2 (en) * | 2013-12-20 | 2016-12-13 | Oracle International Corporation | Executable code for constrained computing environments |
CN103729235A (zh) | 2013-12-24 | 2014-04-16 | 华为技术有限公司 | Java虚拟机的编译方法和Java虚拟机 |
CN106462360B (zh) * | 2014-12-23 | 2019-10-25 | 华为技术有限公司 | 一种资源调度方法以及相关装置 |
CN104657496B (zh) * | 2015-03-09 | 2018-08-14 | 杭州朗和科技有限公司 | 一种计算信息热度值的方法和设备 |
CN105589729A (zh) | 2015-12-28 | 2016-05-18 | 北京锐安科技有限公司 | 一种基于嵌入式虚拟机的动态编译的方法及装置 |
-
2015
- 2015-12-02 CN CN201510872247.7A patent/CN105511942B/zh active Active
-
2016
- 2016-08-19 KR KR1020187018366A patent/KR102112081B1/ko active IP Right Grant
- 2016-08-19 WO PCT/CN2016/096068 patent/WO2017092409A1/zh active Application Filing
- 2016-08-19 EP EP16869720.9A patent/EP3379412A4/en not_active Ceased
-
2018
- 2018-06-01 US US15/995,555 patent/US10871976B2/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20030084432A1 (en) * | 2001-10-31 | 2003-05-01 | Tetsuyuki Kobayashi | Intermediate code preprocessing apparatus, intermediate code execution apparatus, intermediate code execution system, and computer program product for preprocessing or executing intermediate code |
CN1790267A (zh) * | 2005-12-14 | 2006-06-21 | 浙江大学 | 应用于Java操作系统中虚拟机的编译体系实现方法 |
CN103399780A (zh) * | 2013-07-03 | 2013-11-20 | 清华大学 | 一种基于虚拟机技术和动态符号执行的整数溢出检测方法 |
CN105511942A (zh) * | 2015-12-02 | 2016-04-20 | 华为技术有限公司 | 语言虚拟机中热点中间代码的识别方法以及装置 |
Non-Patent Citations (1)
Title |
---|
See also references of EP3379412A4 * |
Cited By (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN112068926A (zh) * | 2020-07-31 | 2020-12-11 | 中国科学院信息工程研究所 | 一种局域网内虚拟机的识别方法 |
CN116342541A (zh) * | 2023-03-29 | 2023-06-27 | 中国矿业大学 | 一种基于相邻图像孔隙融合重构的岩土体渗透率计算方法 |
CN116342541B (zh) * | 2023-03-29 | 2024-03-22 | 中国矿业大学 | 一种基于相邻图像孔隙融合重构的岩土体渗透率计算方法 |
Also Published As
Publication number | Publication date |
---|---|
KR102112081B1 (ko) | 2020-05-18 |
CN105511942A (zh) | 2016-04-20 |
EP3379412A4 (en) | 2019-01-16 |
KR20180088706A (ko) | 2018-08-06 |
US20180276015A1 (en) | 2018-09-27 |
EP3379412A1 (en) | 2018-09-26 |
US10871976B2 (en) | 2020-12-22 |
CN105511942B (zh) | 2019-02-19 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
WO2017092409A1 (zh) | 语言虚拟机中热点中间代码的识别方法以及装置 | |
US10324741B2 (en) | Speeding up dynamic language execution on a virtual machine with type speculation | |
US11249758B2 (en) | Conditional branch frame barrier | |
US8245202B2 (en) | Processor emulation using speculative forward translation | |
JP6138142B2 (ja) | 被管理ランタイムのためのハードウェア・ベース・ランタイム計装機構 | |
KR101879113B1 (ko) | 프로세서를 위한 공동 설계 동적 언어 가속기 | |
US7823140B2 (en) | Java bytecode translation method and Java interpreter performing the same | |
JPH10111818A (ja) | バーストプロファイリング方法およびシステム | |
WO2021169127A1 (zh) | 虚拟机升级方法、装置、设备及存储介质 | |
US11755341B2 (en) | Class loading method and apparatus | |
US11029876B2 (en) | Determining an age category for an object stored in a heap | |
WO2023274135A1 (zh) | 一种数据的处理系统、方法以及装置 | |
JP2020500368A (ja) | データプリフェッチング方法、装置、およびシステム | |
US11204767B2 (en) | Context switching locations for compiler-assisted context switching | |
US8903776B2 (en) | Caching socket connections while ensuring that there are file descriptors available for the applications | |
US11474832B2 (en) | Intelligently determining a virtual machine configuration during runtime based on garbage collection characteristics | |
US10802854B2 (en) | Method and apparatus for interpreting bytecode instruction stream | |
Reijers et al. | Improved ahead-of-time compilation of stack-based JVM bytecode on resource-constrained devices | |
KR101088516B1 (ko) | 수행 중 선행 컴파일링을 이용한 내장형 시스템을 위한 자바 컴파일링 방법 | |
Tasneem et al. | Android memory optimization | |
US11720468B1 (en) | Unwinding program call stacks for performance profiling | |
CN118860842A (zh) | 数据处理方法、装置、设备及可读存储介质 | |
CN117608579A (zh) | 一种c++语言高效的指针实现和应用方法及装置 | |
Ramanan | JIT through the ages Evolution of just-in-time compilation from theoretical performance improvements to smartphone runtime and browser optimizations |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
121 | Ep: the epo has been informed by wipo that ep was designated in this application |
Ref document number: 16869720 Country of ref document: EP Kind code of ref document: A1 |
|
NENP | Non-entry into the national phase |
Ref country code: DE |
|
ENP | Entry into the national phase |
Ref document number: 20187018366 Country of ref document: KR Kind code of ref document: A |
|
WWE | Wipo information: entry into national phase |
Ref document number: 2016869720 Country of ref document: EP |