I. Field of the Disclosure
The technology of the disclosure relates generally to literal load instructions provided by a computer processor.
II. Background
Computer programs executed by modern computer processors may frequently employ literal values. As used herein, a “literal value” is a value that is expressed as itself (e.g., a numeral “25” or a string “Hello World”) in a computer program's source code. Literal values may provide a convenient means for a computer program to represent and utilize values that do not change, or that change only rarely during execution of the computer program. Multiple literal values to be accessed during execution of the computer program may be stored together in memory as a block of data known as a “constant table” or “constant pool.”
A load instruction may be employed by a computer program to access a literal value located at a specified address (i.e., a “literal load value”), and to place the literal load value in a register for use by one or more subsequent dependent instructions following the load instruction in a processing pipeline. Such load instructions are referred to herein as “literal load instructions,” while the subsequent instructions that make use of the literal load value as an input are referred to as “dependent instructions.” In some computer architectures, a literal load instruction may specify the location of the literal load value in a constant pool as an address relative to an address of the literal load instruction itself. For example, the following instructions illustrate a literal load instruction and a subsequent dependent instruction that may be used by an ARM® architecture:
LDR R0, [PC, #0x40]; retrieve a literal load value stored at program counter (PC)+0x40+8 into register R0.
ADD R1, R0, R0; use the literal load value by adding the value in register R0 to itself, and storing the result in register R1.
Due to data cache latency inherent in many conventional processors, a load instruction may incur a “load:use penalty” when loading a literal load value into a register. A load:use penalty refers to a minimum number of processor cycles that may elapse between dispatching of the load instruction and dispatching of a subsequent dependent instruction attributable to data cache latency. For instance, in the exemplary code above, the ADD instruction cannot be dispatched until the load:use penalty incurred by the LDR instruction has elapsed. Because the dependent instruction cannot be dispatched until the load instruction returns data, the load:use penalty may result in a “bubble” of underutilized processor cycles occurring within a processing pipeline.
The load:use penalty may be mitigated through the use of a literal load prediction mechanism, in which literal load values may be cached after a first execution of a literal load instruction and subsequently provided to dependent instructions pending the next execution of the literal load instruction. However, under such a literal load prediction mechanism, the dependent instructions cannot be retired until the literal load instruction has executed. Moreover, a literal load misprediction may require that all instructions following the literal load instruction be flushed and re-executed.
Aspects disclosed in the detailed description include removing invalid literal load values, and related circuits, methods, and computer-readable media. In some circumstances, all software operations that may result in a change to a literal value in a constant table may be known and detectable. By detecting such software operations, entries in a literal load table that are rendered invalid by the software operations may be identified and flushed, thus ensuring that the literal load table contents are always known to be valid. In this regard, in one aspect, an instruction processing circuit provides a literal load table for caching previously generated literal load values. The literal load table contains one or more entries, each comprising an address and a cached literal load value. Upon detecting a literal load instruction in an instruction stream that accesses a literal value in a constant table, the instruction processing circuit determines whether the literal load table contains an entry having an address corresponding to the literal load instruction. If so, it may be assumed that the literal load instruction has already executed at least once, and the resulting literal load value has been cached in the literal load table and is valid. Accordingly, the instruction processing circuit removes the literal load instruction from the instruction stream, and provides the cached literal load value stored in the entry to at least one dependent instruction of the literal load instruction. The instruction processing circuit further determines whether an invalidity indicator for the literal load table has been received. The invalidity indicator may be generated by, as a non-limiting example, a dynamic runtime capable of detecting all software operations that may result in modification of the literal value in the constant table corresponding to the entry in the literal load table. In response to determining that the invalidity indicator has been received, the instruction processing circuit may flush some or all of the entries in the literal load table. In this manner, processing performance may be improved by avoiding the additional overhead of literal load misprediction handling and unnecessary execution of literal load instructions, while enabling dependent instructions to access known valid literal load values without incurring a load:use penalty.
In another aspect, an instruction processing circuit is provided. The instruction processing circuit comprises a front-end circuit configured to fetch and decode instructions in an instruction stream, and a literal load table configured to provide one or more entries for caching literal load values. The instruction processing circuit is configured to detect, by the front-end circuit, a literal load instruction in the instruction stream that accesses a literal value of a constant table. The instruction processing circuit is further configured to determine whether an address of the literal load instruction is present in an entry of the literal load table. The instruction processing circuit is also configured to, responsive to determining that the address of the literal load instruction is present, remove the literal load instruction from the instruction stream. The instruction processing circuit is additionally configured to, responsive to determining that the address of the literal load instruction is present, provide a cached literal load value stored in the entry of the literal load table for execution of at least one dependent instruction of the literal load instruction. The instruction processing circuit is further configured to determine whether an invalidity indicator for the literal load table has been received. The instruction processing circuit is also configured to, responsive to receiving the invalidity indicator, flush the literal load table.
In another aspect, an instruction processing circuit is provided. The instruction processing circuit comprises a means for detecting, in an instruction stream, a literal load instruction that accesses a literal value of a constant table. The instruction processing circuit further comprises a means for determining whether an address of the literal load instruction is present in an entry of a literal load table. The instruction processing circuit also comprises a means for removing the literal load instruction from the instruction stream responsive to determining that the address of the literal load instruction is present. The instruction processing circuit additionally comprises a means for providing a cached literal load value stored in the entry of the literal load table for execution of at least one dependent instruction of the literal load instruction responsive to determining that the address of the literal load instruction is present. The instruction processing circuit further comprises a means for determining whether an invalidity indicator for the literal load table has been received. The instruction processing circuit also comprises a means for flushing the literal load table responsive to receiving the invalidity indicator.
In another aspect, a method for identifying invalid literal load values for removal from a literal load table is provided. The method comprises detecting, by a computer processor, an occurrence of a software operation. The method further comprises determining whether the software operation results in modification of a literal value in a constant table corresponding to an entry in a literal load table. The method also comprises, responsive to determining that the software operation results in the modification of the literal value, generating an invalidity indicator for the literal load table.
In another aspect, a non-transitory computer-readable medium is provided, having stored thereon computer-executable instructions which, when executed by a processor, cause the processor to detect an occurrence of a software operation. The computer-executable instructions further cause the processor to determine whether the software operation results in modification of a literal value in a constant table corresponding to an entry in a literal load table. The computer-executable instructions also cause the processor to, responsive to determining that the software operation results in the modification of the literal value, generate an invalidity indicator for the literal load table.
With reference now to the drawing figures, several exemplary aspects of the present disclosure are described. The word “exemplary” is used herein to mean “serving as an example, instance, or illustration.” Any aspect described herein as “exemplary” is not necessarily to be construed as preferred or advantageous over other aspects.
Aspects disclosed in the detailed description include removing invalid literal load values, and related circuits, methods, and computer-readable media. In some circumstances, all software operations that may result in a change to a literal value in a constant table may be known and detectable. By detecting such software operations, entries in a literal load table that are rendered invalid by the software operations may be identified and flushed, thus ensuring that the literal load table contents are always known to be valid. In this regard, in one aspect, an instruction processing circuit provides a literal load table for caching previously generated literal load values. The literal load table contains one or more entries, each comprising an address and a cached literal load value. Upon detecting a literal load instruction in an instruction stream that accesses a literal value in a constant table, the instruction processing circuit determines whether the literal load table contains an entry having an address corresponding to the literal load instruction. If so, it may be assumed that the literal load instruction has already executed at least once, and the resulting literal load value has been cached in the literal load table and is valid. Accordingly, the instruction processing circuit removes the literal load instruction from the instruction stream, and provides the cached literal load value stored in the entry to at least one dependent instruction of the literal load instruction. The instruction processing circuit further determines whether an invalidity indicator for the literal load table has been received. The invalidity indicator may be generated by, as a non-limiting example, a dynamic runtime capable of detecting all software operations that may result in modification of the literal value in the constant table corresponding to the entry in the literal load table. In response to determining that the invalidity indicator has been received, the instruction processing circuit may flush some or all of the entries in the literal load table. In this manner, processing performance may be improved by avoiding the additional overhead of literal load misprediction handling and unnecessary execution of literal load instructions, while enabling dependent instructions to access known valid literal load values without incurring a load:use penalty.
In this regard,
The computer processor 100 includes input/output circuits 106, an instruction cache 108, and a data cache 110. The computer processor 100 further comprises an execution pipeline 112, which includes a front-end circuit 114, an execution unit 116, and a completion unit 118. The computer processor 100 additionally includes registers 120, which comprise one or more general purpose registers (GPRs) 122, a program counter 124, and a link register 126. In some aspects, such as those employing the ARM® ARM7™ architecture, the link register 126 is one of the GPRs 122, as shown in
In exemplary operation, the front-end circuit 114 of the execution pipeline 112 fetches instructions (not shown) from the instruction cache 108, which in some aspects may be an on-chip Level 1 (L1) cache, as a non-limiting example. The fetched instructions are decoded by the front-end circuit 114 and issued to the execution unit 116. The execution unit 116 executes the issued instructions, and the completion unit 118 retires the executed instructions. In some aspects, the completion unit 118 may comprise a write-back mechanism (not shown) that stores the execution results in one or more of the registers 120. It is to be understood that the execution unit 116 and/or the completion unit 118 may each comprise one or more sequential pipeline stages. In the example of
The computer processor 100 of
While processing instructions in the execution pipeline 112, the instruction processing circuit 102 may fetch and execute a literal load instruction (not shown) for loading a literal load value into one of the registers 120. Processing the literal load instruction thus may include retrieving the literal load value from the data cache 110. However, in doing so, the literal load instruction may incur a load:use penalty resulting from an inherent latency in accessing the data cache 110. For example, in some computer architectures, accessing the data cache 110 may require two to three processor cycles to complete. Consequently, the instruction processing circuit 102 may be unable to dispatch a subsequent dependent instruction (not shown) until the load:use penalty incurred by the literal load instruction has elapsed. This may result in underutilization of the computer processor 100 within the execution pipeline 112.
In this regard, the instruction processing circuit 102 of
The front-end circuit 114 of the instruction processing circuit 102 is configured to detect literal load instructions (not shown) in an instruction stream (not shown) being processed within the execution pipeline 112. In some aspects, the instruction processing circuit 102 may be configured to detect literal load instructions based on an idiomatic form of a load instruction employed by the computer processor 100. As a non-limiting example, in a computer processor utilizing the ARM architecture, a literal load instruction may be detected by determining that the literal load instruction uses a program-counter-relative addressing mode, with the program counter offset specified by a constant.
As the literal load instruction is fetched by the front-end circuit 114 of the instruction processing circuit 102, the instruction processing circuit 102 may consult the literal load table 104. The literal load table 104 contains one or more entries (not shown), each of which may include an address of a previously detected literal load instruction, and a cached literal load value that was previously retrieved by the literal load instruction corresponding to the address. In some aspects, the address of the previously detected literal load instruction may comprise a program counter address and/or an individual or group cache tag, as non-limiting examples.
The instruction processing circuit 102 determines whether an address of the literal load instruction being fetched is present in an entry of the literal load table 104. If the address of the literal load instruction is found (i.e., a “hit”), the instruction processing circuit 102 removes the literal load instruction from the instruction stream. This is because, as noted above, the contents of the literal load table 104 contain only known valid literal values. Thus, there is no chance of misprediction of the results of executing the literal load instruction, and, consequently, no need to re-execute the literal load instruction. According to some aspects, the instruction processing circuit 102 may remove the literal load instruction from the instruction stream by preventing issuance of the literal load instruction.
The instruction processing circuit 102 may then provide the literal load value from the entry to at least one dependent instruction as a cached literal load value. In some aspects, the cached literal load value may be provided to the at least one dependent instruction via the constant cache 132. In this manner, the at least one dependent instruction may obtain the cached literal load value for the literal load instruction without incurring a corresponding load:use penalty.
As noted above, the instruction processing circuit 102 may identify and remove invalid entries in the literal load table 104 through the use of an invalidity indicator. In some aspects, the invalidity indicator may be generated by software such as a dynamic runtime, which may detect software operations that may result in modification of cached literal load values. The detected software operations may include, as non-limiting examples, a garbage collection operation and/or an inline cache address update operation. Based on the received invalidity indicator, the instruction processing circuit 102 may flush one or more of the entries of the literal load table 104 to ensure that no invalid literal values are provided to dependent instructions.
According to some aspects disclosed herein, if the instruction processing circuit 102 detects a literal load instruction but does not find the address of the literal load instruction in an entry of the literal load table 104, a “miss” occurs. In this case, the instruction processing circuit 102 may generate an entry in the literal load table 104 corresponding to the literal load instruction upon execution of the literal load instruction. The generated entry includes the address of the literal load instruction, and stores the actual literal load value loaded by the literal load instruction as the cached literal load value of the entry. Accordingly, if and when the literal load instruction is again detected by the instruction processing circuit 102, a “hit” in the literal load table 104 may occur, and the cached literal load value may be provided to a dependent instruction.
Some aspects of the instruction processing circuit 102 disclosed herein may employ one of the control registers 127 to set an operational mode of the instruction processing circuit 102. For instance, the literal load caching operations of the instruction processing circuit 102 may be selectively enabled or disabled by software using one of the control registers 127. In some aspects, the one or more of the control registers 127 may be used to place the instruction processing circuit 102 in a literal load value caching mode or a literal load value prediction mode. In the event of an event such as an interrupt, a context switch, and/or a parallel synchronization event, the instruction processing circuit 102 may store its operational mode as part of the architectural state of the computer processor 100.
To better illustrate exemplary communications flows among the instruction processing circuit 102, the data cache 110, and the constant cache 132 of
In
The instruction stream 200 further includes a constant table 207 providing a literal value 208 for consumption by the literal load instruction 202.
The literal load instruction 202 in this example is an LDR instruction, which directs the computer processor 100 to load a literal value from an address specified by a current value of the program counter 124 (PC) plus the hexadecimal value 0x40. In the example of
The literal load table 104 illustrated in
As seen in
The constant cache 132 shown in
Referring now to
Upon execution of the literal load instruction 202, the entry 216(0) of the data cache 110 is populated with an actual literal load value 230 loaded by the literal load instruction 202 (here, the hexadecimal value 0x1234). As indicated by arrow 232, the instruction processing circuit 102 accesses the entry 216(0) of the data cache 110, and obtains the actual literal load value 230. The instruction processing circuit 102 next generates the entry 210(X) in the literal load table 104 based on the actual literal load value 230, as indicated by arrow 234. The address 206 of the literal load instruction 202 will be stored in the program counter field 212 of the entry 210(X), while the actual literal load value 230 will be stored as a cached literal load value in the value field 214 of the entry 210(X). The actual literal load value 230 loaded into register R0 by the literal load instruction 202 is then forwarded to the dependent instruction 204 using conventional mechanisms, as indicated by arrow 236.
Because the contents of the literal load table 104 are known to be valid, there is no need to re-execute the literal load instruction 202 after the entry 210(X) is located. Accordingly, the instruction processing circuit 102 removes the literal load instruction 202 from the instruction stream 200, as indicated by strikethrough 241. In some aspects, the instruction processing circuit 102 may remove the literal load instruction 202 by preventing issuance of the literal load instruction 202. The instruction processing circuit 102 then assigns the cached literal load value 238 provided by the entry 210(X) to the entry 222(0) in the constant cache 132 corresponding to register R0, as indicated by arrow 242. The cached literal load value 238 is then provided to the dependent instruction 204 via the constant cache 132, as indicated by arrow 244. In this manner, the dependent instruction 204 is able to receive the cached literal load value 238 while incurring no load:use penalty.
To illustrate removal of invalid literal load values from the literal load table 104,
In response to receiving the invalidity indicator 252, as indicated by arrow 259, the instruction processing circuit 102 flushes the literal load table 104. In the example of
According to some aspects, the instruction processing circuit 102 may be configured to flush the literal load table 104 in response to other detected events besides receiving the invalidity indicator 252. In the example of
In
If, at decision block 302, the instruction processing circuit 102 determines that the address 206 of the literal load instruction 202 is not present in an entry 210(X) of the literal load table 104, the instruction processing circuit 102 generates the entry 210(X) in the literal load table 104 upon execution of the literal load instruction 202 (block 310). The entry 210(X) includes the address 206 of the literal load instruction 202, and contains an actual literal load value 230 stored as the cached literal load value 238. Processing then resumes at block 308 of
Referring now to
According to some aspects, the instruction processing circuit 102 may next determine whether an interrupt 262, a context switch 264, and/or a parallel synchronization event 266 has been detected (block 316). Any one of the aforementioned events may result in invalidation of the contents of the literal load table 104. If no such event has been detected, processing continues at block 320. However, if the instruction processing circuit 102 determines at decision block 316 that an interrupt 262, a context switch 264, and/or a parallel synchronization event 266 has been detected, the instruction processing circuit 102 flushes the literal load table 104 (block 322). In some aspects, in the event of an interrupt 262, a context switch 264, and/or a parallel synchronization event 266, the instruction processing circuit 102 may store an operational mode of the instruction processing circuit 102 as part of the architectural state of the computer processor 100.
To illustrate exemplary operations for receiving the invalidity indicator 252 of
As discussed above, the invalidity indicator 252 of
However, if it is determined at decision block 502 that the software operation 248 results in modification of the literal value 208, the invalidity indicator 252 is generated for the literal load table 104 (block 506). In some aspects, the invalidity indicator 252 may include an identification 260 of the entry 210(X) in the literal load table 104 to enable selective flushing of the entry 210(X). Depending on the implementation of the instruction processing circuit 102 of
Removing invalid literal load values according to aspects disclosed herein may be provided in or integrated into any processor-based device. Examples, without limitation, include a set top box, an entertainment unit, a navigation device, a communications device, a fixed location data unit, a mobile location data unit, a mobile phone, a cellular phone, a computer, a portable computer, a desktop computer, a personal digital assistant (PDA), a monitor, a computer monitor, a television, a tuner, a radio, a satellite radio, a music player, a digital music player, a portable music player, a digital video player, a video player, a digital video disc (DVD) player, and a portable digital video player.
In this regard,
Other master and slave devices can be connected to the system bus 608. As illustrated in
The CPU(s) 602 may also be configured to access the display controller(s) 620 over the system bus 608 to control information sent to one or more displays 626. The display controller(s) 620 sends information to the display(s) 626 to be displayed via one or more video processors 628, which process the information to be displayed into a format suitable for the display(s) 626. The display(s) 626 can include any type of display, including but not limited to a cathode ray tube (CRT), a liquid crystal display (LCD), a plasma display, etc.
Those of skill in the art will further appreciate that the various illustrative logical blocks, modules, circuits, and algorithms described in connection with the aspects disclosed herein may be implemented as electronic hardware, instructions stored in memory or in another computer-readable medium and executed by a processor or other processing device, or combinations of both. The master and slave devices described herein may be employed in any circuit, hardware component, integrated circuit (IC), or IC chip, as examples. Memory disclosed herein may be any type and size of memory and may be configured to store any type of information desired. To clearly illustrate this interchangeability, various illustrative components, blocks, modules, circuits, and steps have been described above generally in terms of their functionality. How such functionality is implemented depends upon the particular application, design choices, and/or design constraints imposed on the overall system. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present disclosure.
The various illustrative logical blocks, modules, and circuits described in connection with the aspects disclosed herein may be implemented or performed with a processor, a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field Programmable Gate Array (FPGA) or other programmable logic device, discrete gate or transistor logic, discrete hardware components, or any combination thereof designed to perform the functions described herein. A processor may be a microprocessor, but in the alternative, the processor may be any conventional processor, controller, microcontroller, or state machine. A processor may also be implemented as a combination of computing devices, e.g., a combination of a DSP and a microprocessor, a plurality of microprocessors, one or more microprocessors in conjunction with a DSP core, or any other such configuration.
The aspects disclosed herein may be embodied in hardware and in instructions that are stored in hardware, and may reside, for example, in Random Access Memory (RAM), flash memory, Read Only Memory (ROM), Electrically Programmable ROM (EPROM), Electrically Erasable Programmable ROM (EEPROM), registers, a hard disk, a removable disk, a CD-ROM, or any other form of computer readable medium known in the art. An exemplary storage medium is coupled to the processor such that the processor can read information from, and write information to, the storage medium. In the alternative, the storage medium may be integral to the processor. The processor and the storage medium may reside in an ASIC. The ASIC may reside in a remote station. In the alternative, the processor and the storage medium may reside as discrete components in a remote station, base station, or server.
It is also noted that the operational steps described in any of the exemplary aspects herein are described to provide examples and discussion. The operations described may be performed in numerous different sequences other than the illustrated sequences. Furthermore, operations described in a single operational step may actually be performed in a number of different steps. Additionally, one or more operational steps discussed in the exemplary aspects may be combined. It is to be understood that the operational steps illustrated in the flow chart diagrams may be subject to numerous different modifications as will be readily apparent to one of skill in the art. Those of skill in the art will also understand that information and signals may be represented using any of a variety of different technologies and techniques. For example, data, instructions, commands, information, signals, bits, symbols, and chips that may be referenced throughout the above description may be represented by voltages, currents, electromagnetic waves, magnetic fields or particles, optical fields or particles, or any combination thereof.
The previous description of the disclosure is provided to enable any person skilled in the art to make or use the disclosure. Various modifications to the disclosure will be readily apparent to those skilled in the art, and the generic principles defined herein may be applied to other variations without departing from the spirit or scope of the disclosure. Thus, the disclosure is not intended to be limited to the examples and designs described herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.