Instruction execution method, device, computing device and storage medium
By capturing the processor's data access exception message in the computing device and generating an instruction substitution policy, replacing the non-bound access instruction as a boundary access instruction, the problem of data access in special storage situations is solved, and data access efficiency is improved And reduce the workload of data storage structure modification.
Patent Information
- Application Number
- CN202111117063.1
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-09-23
- Publication Date
- 2024-11-08
- Estimated Expiration
- 2041-09-23
AI Technical Summary
The prior art causes an error when the processor cannot directly process data access instructions in special storage situations. Due to the large number of applications, the workload of modifying the data storage structure is huge and cannot completely solve the problem.
By implementing the instruction execution method in the computing device, the data access exception message generated by the processor is captured, the instruction substitution policy is generated, and the non-bound access instruction is replaced as a bound access instruction, ensuring that the processor can perform data access operations normally.
It effectively solves the problem that the processor cannot handle the non-boundary data access instructions, improves the efficiency of data storage and access, and avoids a large amount of workload of modifying the data storage structure.
Smart Images

Figure CN113849345B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of operating systems, and in particular to an instruction execution method, device, computing equipment and storage medium. Background Art
[0002] With the continuous development of computer technology, more and more applications have been developed. Correspondingly, the application data is increasing, and the data structure is becoming more and more complex. Therefore, the system's access performance to complex data structures in memory is becoming more and more important, directly affecting the running speed of key applications. When storing data, special storage situations often occur. When applications access these stored data, the processor does not support special access instructions for the data, and an error will occur. The processor cannot directly process such access instructions to read data.
[0003] To this end, in the prior art, in order to enable applications to read data normally, a method of changing the data storage method is adopted, so that the instructions for applications to access the data become normal instructions, and the processor can execute to read the data. However, due to the large number of application programs, the data storage structure that needs to be modified is also very large, and some data storage structures may not be convenient to modify. Not only is the workload very huge, but it cannot solve all data storage problems.
[0004] Therefore, a new instruction execution method and device are needed. Summary of the invention
[0005] To this end, the present invention provides an instruction execution method to try to solve or at least alleviate the above problems.
[0006] According to one aspect of the present invention, there is provided an instruction execution method, which is suitable for execution in a computing device, the computing device comprising a processor and an internal memory, and running one or more applications, the storage area of the internal memory being mapped as a storage space, and the application accessing data in the internal memory with a storage address in the storage space, the method comprising the steps of: submitting a first operation instruction for the application to access data in the internal memory to the processor; when the processor generates a data access exception message due to the storage address of the data accessed by the first operation instruction, generating a first data block according to the data access exception message; determining an instruction replacement strategy for the data exception access message according to the first data block; generating a second operation instruction according to the instruction replacement strategy, the second operation instruction being suitable for accessing the data to be accessed by the first operation instruction, and the processor will not generate a data access exception message when executing the second operation instruction; and replacing the first operation instruction with the generated second operation instruction, and submitting the second operation instruction to the processor to access the data in the internal memory.
[0007] Optionally, in the method according to the present invention, the data access exception message includes the instruction address and exception type of the first operation instruction, and generating the first data block according to the data access exception message includes the steps of: generating the first data block according to the instruction address and exception type.
[0008] Optionally, in the method according to the present invention, an instruction replacement strategy table is stored in the computing device, and determining the instruction replacement strategy of the data exception access message based on the first data block includes the steps of: querying the instruction replacement strategy table according to the exception type in the first data block, and determining the instruction replacement strategy.
[0009] Optionally, the method according to the present invention further comprises the step of generating a second data block according to the first data block and the instruction replacement strategy.
[0010] Optionally, in the method according to the present invention, when the first operation instruction is an out-of-bounds access instruction, the exception type is an out-of-bounds access exception, and the instruction replacement strategy generates a second operation instruction including the steps of: replacing the first target address of the first operation instruction with a second target address according to the instruction replacement strategy in the second data block; and generating a second operation instruction according to the second target address.
[0011] Optionally, in the method according to the present invention, the instruction replacement strategy is to replace the non-boundary access instruction with the boundary access instruction, and the second operation instruction is the boundary access instruction.
[0012] Optionally, in the method according to the present invention, replacing the first target address of the first operation instruction with the second target address according to the instruction replacement strategy in the second data block includes the steps of: calculating the storage address and offset according to the first target address; and generating the second target address according to the storage address and the offset.
[0013] Optionally, in the method according to the present invention, replacing the first operation instruction with the generated second operation instruction includes the steps of: pulling the instruction stream where the first operation instruction is located; replacing the first operation instruction in the instruction stream with the second operation instruction according to the instruction address in the second data block.
[0014] According to another aspect of the present invention, there is provided an instruction execution apparatus, the apparatus resides in a computing device, the computing device includes a processor and an internal memory, and runs one or more applications, the storage area of the internal memory is mapped to a storage space, and the application accesses data in the internal memory with a storage address in the storage space, the apparatus includes: an exception capture module, adapted to generate a first data block according to the data access exception message when a first operation instruction for the application to access data in the internal memory is submitted to the processor, and the processor generates a data access exception message due to the storage address of the data accessed by the first operation instruction; a replacement strategy module, adapted to determine an instruction replacement strategy for the data exception access message according to the first data block; an instruction generation module, adapted to generate a second operation instruction according to the instruction replacement strategy, the second operation instruction is adapted to access the data to be accessed by the first operation instruction, and the processor will not generate a data access exception message when executing the second operation instruction; and an instruction replacement module, adapted to replace the first operation instruction with the generated second operation instruction, and submit the second operation instruction to the processor to access the data in the internal memory.
[0015] According to another aspect of the present invention, a computing device is provided, comprising: one or more processors; a memory; and one or more programs, wherein the one or more programs are stored in the memory and configured to be executed by the one or more processors, and the one or more programs include instructions for executing an instruction execution method according to the present invention.
[0016] According to another aspect of the present invention, a computer-readable storage medium storing one or more programs is provided. The one or more programs include instructions that, when executed by a computing device, cause the computing device to perform a method in an instruction execution method according to the present invention.
[0017] The instruction execution method of the present invention is suitable for execution in a computing device, the computing device includes a processor and an internal memory, and runs one or more applications, the storage area of the internal memory is mapped to a storage space, and the application accesses the data in the internal memory with the storage address in the storage space, and the method includes the steps of: submitting a first operation instruction for the application to access the data in the internal memory to the processor, when the processor generates a data access exception message due to the storage address of the data accessed by the first operation instruction, generating a first data block according to the data access exception message, thereby capturing the situation where the processor executes the operation instruction of the application abnormally, and processing the execution exception instruction in time. In addition, the instruction replacement strategy for abnormal data access is determined according to the first data block, and the second operation instruction is generated according to the instruction replacement strategy, so that the first operation instruction that the processor cannot execute normally is converted into a second operation instruction, the second operation instruction is suitable for accessing the data to be accessed by the first operation instruction, and the processor will not generate a data access exception message when executing the second operation instruction. Finally, the first operation instruction is replaced with the generated second operation instruction, so that the processor executes the second operation instruction and successfully accesses the data in the internal memory.
[0018] Furthermore, when the first operation instruction is an out-of-bounds access instruction, the exception type is an out-of-bounds access exception, and when generating the second operation instruction according to the instruction replacement strategy, the first target address of the first operation instruction is replaced with the second target address, and the second operation instruction is generated according to the second target address. The instruction replacement strategy is to replace the out-of-bounds access instruction with the in-bounds access instruction, and the second operation instruction is the in-bounds access instruction. According to the above steps, when the data storage is out-of-bounds and the processor cannot normally execute the out-of-bounds access instruction, the out-of-bounds access instruction can be converted into a docking access instruction, so that the processor can read the data normally. BRIEF DESCRIPTION OF THE DRAWINGS
[0019] In order to achieve the above and related purposes, certain illustrative aspects are described herein in conjunction with the following description and accompanying drawings, which indicate various ways in which the principles disclosed herein can be practiced, and all aspects and their equivalents are intended to fall within the scope of the claimed subject matter. By reading the following detailed description in conjunction with the accompanying drawings, the above and other purposes, features and advantages disclosed by the present invention will become more apparent. Throughout the present disclosure, the same reference numerals generally refer to the same parts or elements.
[0020] Figure 1 A schematic diagram of the structure of an instruction execution device according to an exemplary embodiment of the present invention is shown;
[0021] Figure 2 shows a block diagram of a computing device 200 according to an exemplary embodiment of the present invention; and
[0022] Figure 3 FIG. 3 is a flow chart of an instruction execution method 300 according to an exemplary embodiment of the present invention. DETAILED DESCRIPTION
[0023] Exemplary embodiments of the present disclosure will be described in more detail below with reference to the accompanying drawings. Although exemplary embodiments of the present disclosure are shown in the accompanying drawings, it should be understood that the present disclosure can be implemented in various forms and should not be limited by the embodiments set forth herein. On the contrary, these embodiments are provided in order to enable a more thorough understanding of the present disclosure and to enable the scope of the present disclosure to be fully conveyed to those skilled in the art. The same reference numerals generally refer to the same components or elements.
[0024] Figure 1 FIG. 2 shows a schematic diagram of the structure of an instruction execution device according to an exemplary embodiment of the present invention. Figure 1 As shown, the instruction execution device 140 resides in a computing device (not shown in the figure), which includes a processor 150, an internal memory 160, and an operating system 120. One or more applications can be installed on the operating system 120. Figure 1 The application 110 shown is only exemplary, and the present invention does not limit the type and number of applications installed by the operating system 120 .
[0025] like Figure 1 As shown, the processor 150 and the internal memory 160 are implemented as the hardware layer of the computing device. An operating system 120 is run on the hardware layer, and the operating system 120 is implemented as the system layer of the computing device, which runs in the kernel state (kernel space). The operating system 120 includes a kernel 130. The instruction execution device 140 resides in the kernel 130. All modules of the instruction execution device 140 run in the kernel state.
[0026] The application 110 running on the operating system 120 runs in user mode (user space). When the application 110 needs to read data in the internal memory 160, it needs to submit the first operation instruction of reading data to the processor 150 for execution via the kernel 130 of the operating system 120. The storage area of the internal memory is mapped into a storage space, and the application 110 accesses the data in the internal memory with the storage address in the storage space.
[0027] like Figure 1As shown, the processor 150 includes an instruction fetching unit 151, a decoding unit 152, an execution unit 153 and a memory access unit 154. The instruction fetching unit 151 is responsible for receiving a first operation instruction from the application 110 to access data in the internal memory 160. The decoding unit 152 compiles the first operation instruction to obtain the compiled first operation instruction, and the execution unit 153 executes the compiled first operation instruction. When the first operation instruction cannot be executed, the memory access unit 154 issues a data access exception message.
[0028] The instruction execution device 140 includes an exception capture module 141, a policy replacement module 142, an instruction generation module 143 and an instruction replacement module 144. The exception capture module 141 can capture the data access exception message generated by the processor 150 and generate a first data block according to the data access exception message.
[0029] The exception capture module 141 generates a first data block according to the instruction address and the exception type. The first data block includes the instruction address and the exception type, and the instruction address and the exception type are packaged to facilitate processing of data access exception messages.
[0030] The replacement strategy module 142 stores an instruction replacement strategy table, which is pre-written by the developer and stored in the replacement strategy module 142. The replacement strategy table includes exception types and replacement strategies. Each exception type corresponds to a replacement strategy. The replacement strategy module 142 queries the instruction replacement strategy table according to the exception type in the first data block to determine the instruction replacement strategy of the data exception access message. The replacement strategy includes whether to replace the instruction and what kind of replacement to perform. The exception type of the replacement strategy table includes the out-of-bounds access exception, and the corresponding replacement strategy is to replace the out-of-bounds access instruction with the bounds access instruction. Replacing the out-of-bounds access instruction with the bounds access instruction indicates that the instruction is to be replaced, and the out-of-bounds access instruction is replaced with the bounds access instruction.
[0031] The replacement strategy module 142 also generates a second data block according to the first data block and the instruction replacement strategy. The instruction generation module 143 generates a second operation instruction according to the instruction replacement strategy in the second data block. The second operation instruction is suitable for accessing the data to be accessed by the first operation instruction, and the processor does not generate a data access exception message when executing the second operation instruction.
[0032] When the instruction generation module 143 replaces the first target address of the first operation instruction with the second target address according to the instruction replacement strategy, the instruction replacement strategy replaces the non-boundary access instruction with the boundary access instruction, and the second operation instruction is the boundary access instruction. The second operation instruction is logically equivalent to the first operation instruction.
[0033] The instruction replacement module 140 replaces the first operation instruction with the generated second operation instruction, and submits it to the processor 150 according to the second operation instruction, so that the application 110 can access the internal memory data. When the instruction replacement module 140 replaces the first operation instruction with the generated second operation instruction, the first operation instruction in the instruction stream is replaced with the second operation instruction according to the instruction address in the second data block. The instruction address is the address of the first operation instruction in the instruction stream. After the first operation instruction is replaced with the second operation instruction in the form of a boundary instruction according to the instruction address, the processor 150 can read the data according to the second operation instruction.
[0034] Figure 1 The instruction execution device 140 resides in the computing device. Figure 2 FIG. 2 shows a block diagram of a computing device 200 according to an exemplary embodiment of the present invention. Figure 2 As shown, in a basic configuration 202, computing device 200 typically includes a system memory 206 and one or more processors 204. A memory bus 208 may be used for communication between processor 204 and system memory 206.
[0035] Depending on the desired configuration, the processor 204 can be any type of processor, including but not limited to: a microprocessor (μP), a microcontroller (μC), a digital information processor (DSP), or any combination thereof. The processor 204 can include one or more levels of cache such as a primary cache 210 and a secondary cache 212, a processor core 214, and registers 216. An example processor core 214 can include an arithmetic logic unit (ALU), a floating point unit (FPU), a digital signal processing core (DSP core), or any combination thereof. An example memory controller 218 can be used with the processor 204, or in some implementations, the memory controller 218 can be an internal part of the processor 204.
[0036] Depending on the desired configuration, the system memory 206 may be any type of memory, including but not limited to: volatile memory (such as RAM), non-volatile memory (such as ROM, flash memory, etc.), or any combination thereof. The system memory 206 may include an operating system 220, one or more programs 222, and program data 228. In some embodiments, the program 222 may be arranged to be executed by one or more processors 204 on the operating system using the program data 228 to execute the instructions 223 of the method 300 according to the present invention.
[0037] The computing device 200 may also include a storage interface bus 234. The storage interface bus 234 enables communication from storage devices 232 (e.g., removable storage 236 and non-removable storage 238) to the basic configuration 202 via the bus / interface controller 230. At least a portion of the operating system 220, the program 222, and the data 224 may be stored on the removable storage 236 and / or the non-removable storage 238, and when the computing device 200 is powered on or the program 222 is to be executed, it is loaded into the system memory 206 via the storage interface bus 234 and executed by the one or more processors 204.
[0038] The computing device 200 may also include an interface bus 240 that facilitates communication from various interface devices (e.g., output devices 242, peripheral interfaces 244, and communication devices 246) to the basic configuration 202 via the bus / interface controller 230. Example output devices 242 include a graphics processing unit 248 and an audio processing unit 250. They can be configured to facilitate communication with various external devices such as a display or speakers via one or more A / V ports 252. Example peripheral interfaces 244 may include a serial interface controller 254 and a parallel interface controller 256, which may be configured to facilitate communication with external devices such as input devices (e.g., keyboards, mice, pens, voice input devices, touch input devices) or other peripherals (e.g., printers, scanners, etc.) via one or more I / O ports 258. Example communication devices 246 may include a network controller 260, which may be arranged to communicate with one or more other computing devices 262 via a network communication link via one or more communication ports 264.
[0039] A network communication link can be an example of a communication medium. Communication media can generally be embodied as computer-readable instructions, data structures, program modules in a modulated data signal such as a carrier wave or other transmission mechanism, and can include any information delivery medium. A "modulated data signal" can be a signal in which one or more of its data sets or its changes can be carried out in a manner that encodes information in the signal. As non-limiting examples, communication media can include wired media such as a wired network or a dedicated line network, and various wireless media such as sound, radio frequency (RF), microwave, infrared (IR) or other wireless media. The term computer-readable medium used herein can include both storage media and communication media.
[0040] In the computing device 200 according to the present invention, the program 222 includes multiple program instructions of the instruction execution method 300, which can instruct the processor 204 to execute some steps of the instruction execution method 300 running in the computing device 200 of the present invention, so that each part in the computing device 200 can process data by executing the instruction execution method 300 of the present invention.
[0041] The computing device 200 can be implemented as a server, such as a file server 240, a database 250, a server, an application server, etc. These electronic devices can be such as personal digital assistants (PDAs), wireless network browsing devices, application-specific devices, or hybrid devices that can include any of the above functions. It can be implemented as a personal computer including desktop computers and notebook computer configurations. In some embodiments, the computing device 200 is configured to execute the instruction execution method 300.
[0042] Figure 3 FIG. 3 is a flow chart of an instruction execution method 300 according to an exemplary embodiment of the present invention. The instruction execution method 300 of the present invention is suitable for execution in a computing device, and is further suitable for execution in a computing device such as Figure 1 The kernel 130 shown in FIG. Figure 3 As shown, the instruction execution method 300 starts at step S310, submitting a first operation instruction for the application 110 to access data in the internal memory to the processor 150. When the application 110 needs to read data in the internal memory 160, it needs to submit the first operation instruction for reading data to the processor 150 for execution via the kernel 130 of the operating system 120. The storage area of the internal memory is mapped into a storage space, and the application 110 accesses the data in the internal memory with a storage address in the storage space.
[0043] When data is stored in the internal memory 160 in a special case, the processor 150 cannot execute the special operation instruction, and a data access exception message will be generated. According to one embodiment of the present invention, when the data to be read by the application 110 is stored out of bounds in the internal memory 160, the first operation instruction is an out-of-bounds memory access instruction, and the data access exception message is an out-of-bounds memory access exception. Out-of-bounds means that the starting position of the data stored in the memory is not aligned with the natural boundary of the data of this type stored sequentially in the memory. For example, a 32-bit register, when storing data normally, the register stores a complete 32-bit data, and the first address of the data storage is the first address of the register. But when the storage is out of bounds, the calculator only stores part of the 32-bit data, and the first address of the 32-bit data is offset from the first address of the register, and the first address of the data is at a certain address in the middle of the register. The other part of the 32-bit data is stored in the next register in turn. The out-of-bounds memory access exception means that on a processor 150 that does not support direct access to out-of-bounds data, direct access to out-of-bounds data will cause the processor 150 to throw an exception. The processor 150 cannot completely retrieve the 32-bit data stored in the divided manner according to one instruction, so the processor 150 throws an exception.
[0044] The processor 150 includes an instruction fetching unit 151, a decoding unit 152, an execution unit 153 and a memory access unit 154. The instruction fetching unit 151 is responsible for receiving a first operation instruction from the application 110 for accessing data in the internal memory 160. The decoding unit 152 compiles the first operation instruction to obtain the compiled first operation instruction, and the execution unit 153 executes the compiled first operation instruction. When the first operation instruction cannot be executed, the memory access unit 154 issues a data access exception message.
[0045] The data access exception message includes the instruction address and exception type of the first operation instruction. Application 110 generates a series of operation instructions during operation, and these operation instructions are collected to form an instruction stream. The first operation instruction is an operation instruction in the instruction stream of application 110, and the instruction address of the first operation instruction is the position of the first operation instruction in the instruction stream. When the exception type is that the processor 150 cannot execute the first operation instruction normally, what kind of exception does this situation belong to? According to one embodiment of the present invention, the exception type includes an out-of-bounds access exception. When the first operation instruction is an out-of-bounds access instruction, the corresponding exception type is an out-of-bounds access exception.
[0046] Subsequently, step S320 is executed, when the processor 150 generates a data access exception message due to the storage address of the data accessed by the first operation instruction, a first data block is generated according to the data access exception message. The first data block includes the instruction address and the exception type, and the data access exception message generated by the processor 150 is captured. When the first data block is generated according to the data access exception message, the instruction address and the exception type are packaged to facilitate the processing of the data access exception message.
[0047] Subsequently, step S330 is executed to determine the instruction replacement strategy of the data abnormal access message according to the first data block. The computing device also stores an instruction replacement strategy table, which is pre-written by the developer and stored in the computing device. The replacement strategy table includes an exception type and a replacement strategy. Each exception type corresponds to a replacement strategy. According to the exception type in the first data block, the instruction replacement strategy table is queried to determine the instruction replacement strategy of the data abnormal access message, and a second data block is generated according to the first data block and the instruction replacement strategy. The replacement strategy includes whether to replace the instruction and what kind of replacement to perform. The exception type of the replacement strategy table includes an out-of-bounds access exception, and the corresponding replacement strategy is to replace the out-of-bounds access instruction with a bounded access instruction. Replacing the out-of-bounds access instruction with a bounded access means that the instruction is to be replaced, and the out-of-bounds access instruction is replaced with a bounded access instruction.
[0048] Subsequently, step S340 is executed to generate a second operation instruction according to the instruction replacement strategy, the second operation instruction is suitable for accessing the data to be accessed by the first operation instruction, and the processor will not generate a data access exception message when executing the second operation instruction. When the second operation instruction is generated according to the instruction replacement strategy, the storage address and the offset are calculated according to the first target address, and the second target address is generated according to the storage address and the offset. According to one embodiment of the present invention, when the first operation instruction is an out-of-bounds access instruction and the exception type is an out-of-bounds access exception, when the second operation instruction is generated, the first target address of the first operation instruction is replaced with the second target address according to the instruction replacement strategy, and the second operation instruction is generated according to the second target address. The first target address and the second target address are both addresses of the data that the application 110 wants to read in the storage space. However, the address where the data is stored in the form of the first target address is not bounded, and the address where the data is stored in the form of the second target address is bounded.
[0049] When replacing the first target address of the first operation instruction with the second target address according to the instruction replacement strategy, the instruction replacement strategy replaces the non-boundary access instruction with the boundary access instruction, and the second operation instruction is the boundary access instruction. The second operation instruction is logically equivalent to the first operation instruction.
[0050] When the first target address of the first operation instruction is replaced with the second target address, the storage address and the offset are calculated according to the first target address, and the second target address is generated according to the storage address and the offset.
[0051] According to one embodiment of the present invention, the first operation instruction is load Ra.32, disp1(Rb1.32), which is an instruction for loading a 32-bit integer whose first target address is Rb1+disp1 into register Ra, wherein Rb1 represents the first address of register Rb, and disp1 is the offset of the 32-bit integer on the first address of register Rb.
[0052] In order to retrieve the 32-bit data separated in two consecutive registers, the number of bits of the first operation instruction needs to be doubled, that is, each two consecutive 32-bit registers in the internal memory 160 are regarded as a whole for operation. For example, the 0th 32-bit register and the 1st 32-bit register are regarded as a 64-bit register for operation, and the subsequent registers are operated in the same way.
[0053] When calculating the storage address of the second operation instruction, the address of the original register Rb is calculated according to the merging situation. The original register Rb is the i-th register. When i is an odd number, the original register Rb is merged with the next register as a whole to obtain the merged register Rb. The address Rb1 of the original register Rb is still the address Rb2 of the merged register Rb. When i is an even number, the original register Rb is merged with the previous register as a whole to obtain the merged register Rb. The address of the original register Rb plus the number of operation bits, that is, Rb1+32, is used as the address Rb2 of the merged register Rb.
[0054] When calculating the offset of the second operation instruction, use the following formula to calculate the offset:
[0055] disp2=(Rb1+disp1)-(Rb1+disp1)%64
[0056] A second target address Rb2+disp2 is generated according to the storage address and the offset.
[0057] Then, a second operation instruction is generated according to the second target address: load Ra.64, disp2 (Rb2.32). The second operation instruction indicates that the 32-bit integer whose second target address is Rb2+disp2 is read from the 64-bit aligned register into the register Ra.
[0058] Finally, step S350 is executed to replace the first operation instruction with the generated second operation instruction, and the second operation instruction is submitted to the processor 150 to access the data in the internal memory. When the first operation instruction is replaced with the generated second operation instruction, the first operation instruction in the instruction stream is replaced with the second operation instruction according to the instruction address in the second data block. The instruction address is the address of the first operation instruction in the instruction stream. After the first operation instruction is replaced with the second operation instruction in the form of a boundary instruction according to the instruction address, the processor 150 can read the data according to the second operation instruction.
[0059] Subsequently, the processor 150 reprocesses the instruction stream, the instruction fetch unit 151 receives the second operation instruction, the decoding unit 152 compiles the second operation instruction to obtain the compiled second operation instruction, the execution unit 153 executes the compiled second operation instruction, and the memory access unit 154 returns the read data to the application 110 via the kernel 130.
[0060] The instruction execution method of the present invention is suitable for execution in a computing device, the computing device includes a processor and an internal memory, and runs one or more applications, the storage area of the internal memory is mapped to a storage space, and the application accesses the data in the internal memory with the storage address in the storage space, and the method includes the steps of: submitting a first operation instruction for the application to access the data in the internal memory to the processor, when the processor generates a data access exception message due to the storage address of the data accessed by the first operation instruction, generating a first data block according to the data access exception message, thereby capturing the situation where the processor executes the operation instruction of the application abnormally, and processing the execution exception instruction in time. In addition, the instruction replacement strategy for abnormal data access is determined according to the first data block, and the second operation instruction is generated according to the instruction replacement strategy, so that the first operation instruction that the processor cannot execute normally is converted into a second operation instruction, the second operation instruction is suitable for accessing the data to be accessed by the first operation instruction, and the processor will not generate a data access exception message when executing the second operation instruction. Finally, the first operation instruction is replaced with the generated second operation instruction, so that the processor executes the second operation instruction and successfully accesses the data in the internal memory.
[0061] Furthermore, when the first operation instruction is an out-of-bounds access instruction, the exception type is an out-of-bounds access exception, and when generating the second operation instruction according to the instruction replacement strategy, the first target address of the first operation instruction is replaced with the second target address, and the second operation instruction is generated according to the second target address. The instruction replacement strategy is to replace the out-of-bounds access instruction with the in-bounds access instruction, and the second operation instruction is the in-bounds access instruction. According to the above steps, when the data storage is out-of-bounds and the processor cannot normally execute the out-of-bounds access instruction, the out-of-bounds access instruction can be converted into a docking access instruction, so that the processor can read the data normally.
[0062] A8. The method as described in A7, wherein replacing the first operation instruction with the generated second operation instruction comprises the steps of:
[0063] Pulling the instruction stream containing the first operation instruction;
[0064] The first operation instruction in the instruction stream is replaced with a second operation instruction according to the instruction address in the second data block.
[0065] In the description provided herein, a large number of specific details are described. However, it is understood that embodiments of the present invention can be practiced without these specific details. In some instances, well-known methods, structures and techniques are not shown in detail so as not to obscure the understanding of this description.
[0066] Similarly, it should be understood that in order to streamline the present disclosure and aid in understanding one or more of the various inventive aspects, in the above description of exemplary embodiments of the present invention, various features of the present invention are sometimes grouped together into a single embodiment, figure, or description thereof. However, this method of disclosure should not be interpreted as reflecting an intention that the claimed invention requires more features than are expressly recited in each claim.
[0067] Those skilled in the art will appreciate that the modules or units or groups of the devices in the examples disclosed herein may be arranged in the device as described in the embodiment, or alternatively may be located in one or more devices different from the devices in the example. The modules in the foregoing examples may be combined into one module or may be divided into multiple submodules.
[0068] Those skilled in the art will appreciate that the modules in the devices in the embodiments may be adaptively changed and arranged in one or more devices different from the embodiments. The modules or units or groups in the embodiments may be combined into one module or unit or group, and in addition they may be divided into a plurality of submodules or subunits or subgroups. All features disclosed in this specification (including the accompanying claims, abstracts and drawings) and all processes or units of any method or device so disclosed may be combined in any combination, except that at least some of such features and / or processes or units are mutually exclusive. Unless otherwise expressly stated, each feature disclosed in this specification (including the accompanying claims, abstracts and drawings) may be replaced by an alternative feature providing the same, equivalent or similar purpose.
[0069] Furthermore, those skilled in the art will appreciate that although some embodiments described herein include certain features included in other embodiments but not other features, the combination of features from different embodiments is meant to be within the scope of the present invention and to form different embodiments.
[0070] In addition, some of the embodiments are described herein as methods or combinations of method elements that can be implemented by a processor of a computer system or by other devices that perform the functions. Therefore, a processor with necessary instructions for implementing the method or method elements forms a device for implementing the method or method elements. In addition, the elements described herein of the device embodiments are examples of devices for implementing the functions performed by the elements for the purpose of implementing the invention.
[0071] The various techniques described herein may be implemented in combination with hardware or software, or a combination thereof. Thus, the method and apparatus of the present invention, or some aspects or portions of the method and apparatus of the present invention may be in the form of program codes (i.e., instructions) embedded in a tangible medium, such as a floppy disk, a CD-ROM, a hard disk drive, or any other machine-readable storage medium, wherein when the program is loaded into a machine such as a computer and executed by the machine, the machine becomes a device for practicing the present invention.
[0072] In the case where the program code is executed on a programmable computer, the computing device generally includes a processor, a storage medium readable by the processor (including volatile and non-volatile memory and / or storage elements), at least one input device, and at least one output device. The memory is configured to store the program code; the processor is configured to execute the method for determining the shutdown state of the device of the present invention according to the instructions in the program code stored in the memory.
[0073] By way of example and not limitation, computer readable media include computer storage media and communication media. Computer readable media include computer storage media and communication media. Computer storage media stores information such as computer readable instructions, data structures, program modules or other data. Communication media generally embodies computer readable instructions, data structures, program modules or other data in a modulated data signal such as a carrier wave or other transmission mechanism, and includes any information delivery medium. Any combination of the above is also included within the scope of computer readable media.
[0074] As used herein, unless otherwise specified, the use of ordinal numbers "first," "second," "third," etc. to describe common objects merely indicates that different instances of similar objects are involved, and is not intended to imply that the objects so described must have a given order in time, space, order, or in any other manner.
[0075] Although the present invention has been described according to a limited number of embodiments, it will be apparent to those skilled in the art, with the benefit of the above description, that other embodiments may be envisioned within the scope of the invention thus described. In addition, it should be noted that the language used in this specification is selected primarily for readability and teaching purposes, rather than for explaining or defining the subject matter of the present invention. Therefore, many modifications and variations will be apparent to those skilled in the art without departing from the scope and spirit of the appended claims. The disclosure of the present invention is illustrative, not restrictive, with respect to the scope of the present invention, which is defined by the appended claims.
Claims
1. An instruction execution method, suitable for execution in a computing device, the computing device comprising a processor and an internal memory, and running one or more applications, the storage area of the internal memory is mapped as a storage space, and the application accesses data in the internal memory with a storage address in the storage space, the method comprising the steps of: Submitting a first operation instruction for the application to access data in the internal memory to the processor; When the processor generates a data access exception message due to the storage address of the data accessed by the first operation instruction, generating a first data block according to the data access exception message; Determine an instruction replacement strategy for the data access exception message according to the first data block; generating a second operation instruction according to the instruction replacement strategy, wherein the second operation instruction is suitable for accessing data to be accessed by the first operation instruction, and the processor does not generate a data access exception message when executing the second operation instruction; as well as The first operation instruction is replaced by the generated second operation instruction, and the second operation instruction is submitted to the processor to access the data in the internal memory.
2. The method according to claim 1, in, The data access exception message includes the instruction address and exception type of the first operation instruction, and the generating of the first data block according to the data access exception message includes the steps of: The first data block is generated according to the instruction address and the exception type.
3. The method according to claim 2, in, The computing device stores an instruction replacement strategy table, and the instruction replacement strategy for determining the data access exception message according to the first data block comprises the following steps: According to the exception type in the first data block, the instruction replacement strategy table is queried to determine the instruction replacement strategy.
4. The method according to claim 2 or 3, further comprising the steps of: A second data block is generated according to the first data block and the instruction replacement strategy.
5. The method according to claim 4, in, When the first operation instruction is an out-of-bounds access instruction, the exception type is an out-of-bounds access exception, and generating the second operation instruction according to the instruction replacement strategy includes the steps of: replacing the first target address of the first operation instruction with the second target address according to the instruction replacement strategy in the second data block; A second operation instruction is generated according to the second target address.
6. The method according to claim 5, in, The instruction replacement strategy is to replace the non-boundary access instruction with the boundary access instruction, and the second operation instruction is the boundary access instruction.
7. The method according to claim 6, in, The replacing the first target address of the first operation instruction with the second target address according to the instruction replacement strategy in the second data block comprises the steps of: Calculate a storage address and an offset according to the first target address; A second target address is generated according to the storage address and the offset.
8. An instruction execution device, the device resides in a computing device, the computing device includes a processor and an internal memory, and runs one or more applications, the storage area of the internal memory is mapped to a storage space, and the application accesses data in the internal memory with a storage address in the storage space, the device include: an exception capture module, adapted to generate a first data block according to the data access exception message when a first operation instruction for the application to access data in the internal memory is submitted to the processor and the processor generates a data access exception message due to the storage address of the data accessed by the first operation instruction; a replacement strategy module, adapted to determine an instruction replacement strategy for the data access exception message according to the first data block; an instruction generation module, adapted to generate a second operation instruction according to the instruction replacement strategy, wherein the second operation instruction is adapted to access data to be accessed by the first operation instruction, and the processor does not generate a data access exception message when executing the second operation instruction; as well as The instruction replacement module is adapted to replace the first operation instruction with the generated second operation instruction, and submit the second operation instruction to the processor to access the data in the internal memory.
9. A computing device, include: one or more processors; Memory; as well as One or more devices comprising instructions for executing the method according to any one of claims 1-7.
10. A computer-readable storage medium storing one or more programs, the one or more programs comprising instructions which, when executed by a computing device, cause the computing device to perform the method according to any one of claims 1-7.
