US20110320786A1 - Dynamically Rewriting Branch Instructions in Response to Cache Line Eviction - Google Patents
Dynamically Rewriting Branch Instructions in Response to Cache Line Eviction Download PDFInfo
- Publication number
- US20110320786A1 US20110320786A1 US12/823,226 US82322610A US2011320786A1 US 20110320786 A1 US20110320786 A1 US 20110320786A1 US 82322610 A US82322610 A US 82322610A US 2011320786 A1 US2011320786 A1 US 2011320786A1
- Authority
- US
- United States
- Prior art keywords
- branch
- instruction
- target
- cache line
- call
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Abandoned
Links
- 230000004044 response Effects 0.000 title claims description 8
- 238000012545 processing Methods 0.000 claims abstract description 74
- 238000000034 method Methods 0.000 claims description 46
- 238000004590 computer program Methods 0.000 claims description 21
- 238000003860 storage Methods 0.000 claims description 21
- 230000008569 process Effects 0.000 claims description 20
- 230000008685 targeting Effects 0.000 claims description 5
- 230000007246 mechanism Effects 0.000 abstract description 46
- 230000006870 function Effects 0.000 description 59
- 230000015654 memory Effects 0.000 description 29
- 238000010586 diagram Methods 0.000 description 24
- 238000005192 partition Methods 0.000 description 8
- 230000003287 optical effect Effects 0.000 description 6
- 238000005457 optimization Methods 0.000 description 6
- 238000000638 solvent extraction Methods 0.000 description 6
- 230000002195 synergetic effect Effects 0.000 description 4
- 230000009191 jumping Effects 0.000 description 3
- 238000004891 communication Methods 0.000 description 2
- 230000000873 masking effect Effects 0.000 description 2
- 238000012986 modification Methods 0.000 description 2
- 230000004048 modification Effects 0.000 description 2
- 239000013307 optical fiber Substances 0.000 description 2
- 230000000644 propagated effect Effects 0.000 description 2
- 230000003068 static effect Effects 0.000 description 2
- 230000003466 anti-cipated effect Effects 0.000 description 1
- XMQFTWRPUQYINF-UHFFFAOYSA-N bensulfuron-methyl Chemical compound COC(=O)C1=CC=CC=C1CS(=O)(=O)NC(=O)NC1=NC(OC)=CC(OC)=N1 XMQFTWRPUQYINF-UHFFFAOYSA-N 0.000 description 1
- 238000012217 deletion Methods 0.000 description 1
- 230000037430 deletion Effects 0.000 description 1
- 230000000694 effects Effects 0.000 description 1
- 238000004519 manufacturing process Methods 0.000 description 1
- 230000002093 peripheral effect Effects 0.000 description 1
- 239000004065 semiconductor Substances 0.000 description 1
- 230000007704 transition Effects 0.000 description 1
- 238000013519 translation Methods 0.000 description 1
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F8/00—Arrangements for software engineering
- G06F8/40—Transformation of program code
- G06F8/41—Compilation
- G06F8/44—Encoding
- G06F8/443—Optimisation
- G06F8/4441—Reducing the execution time required by the program code
- G06F8/4442—Reducing the number of cache misses; Data prefetching
-
- 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/30—Arrangements for executing machine instructions, e.g. instruction decode
- G06F9/38—Concurrent instruction execution, e.g. pipeline or look ahead
- G06F9/3802—Instruction prefetching
- G06F9/3804—Instruction prefetching for branches, e.g. hedging, branch folding
- G06F9/3806—Instruction prefetching for branches, e.g. hedging, branch folding using address prediction, e.g. return stack, branch history buffer
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/0802—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches
- G06F12/0875—Addressing of a memory level in which the access to the desired data or data block requires associative addressing means, e.g. caches with dedicated cache, e.g. instruction or stack
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F12/00—Accessing, addressing or allocating within memory systems or architectures
- G06F12/02—Addressing or allocation; Relocation
- G06F12/08—Addressing or allocation; Relocation in hierarchically structured memory systems, e.g. virtual memory systems
- G06F12/12—Replacement control
Definitions
- the present application relates generally to an improved data processing apparatus and method and more specifically to mechanisms for dynamically rewriting branch instructions in response to cache line eviction.
- CBE Cell Broadband Engine
- PPE primary control processor
- SPEs synergistic processing elements
- Each SPE has a local memory, or local store, into which instructions and data are copied so that the SPE may execute instructions in the local store on data brought into the location store from main memory.
- the local store serves as both an instruction and data cache for the SPE.
- Other multiprocessor architectures utilize similar configurations in which the processors may have a local instruction cache and data cache into which data and instructions are brought before executing on the processor or having the processor operate on the data.
- the local store, or cache, of a modern day multiprocessor architecture is designed to be much smaller in storage size than the main memory.
- executing code larger than the processor's local store or cache size requires a strategy for swapping pieces of code, or code segments, into the local store or cache before use.
- a code segment may include branch instructions whose target instruction is located in a different code segment that may not be currently present in the local store or cache. This would require a strategy for bringing in the code segment corresponding to the target instruction from main memory.
- a method for evicting cache lines from an instruction cache of the data processing system.
- the method comprises storing, by a processor of the data processing system, for a portion of code in a current cache line, a linked list of call sites that directly or indirectly target the portion of code in the current cache line.
- the method further comprises determining, by the processor, that the current cache line is to be evicted from the instruction cache.
- the method comprises processing, by the processor, the linked list of call sites to identify one or more rewritten branch instructions having associated branch stubs, that either directly or indirectly target the portion of code in the current cache line.
- the method comprises rewriting, by the processor, the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state based on information in the associated branch stubs.
- a computer program product comprising a computer useable or readable medium having a computer readable program.
- the computer readable program when executed on a computing device, causes the computing device to perform various ones, and combinations of, the operations outlined above with regard to the method illustrative embodiment.
- a system/apparatus may comprise one or more processors and a memory coupled to the one or more processors.
- the memory may comprise instructions which, when executed by the one or more processors, cause the one or more processors to perform various ones, and combinations of, the operations outlined above with regard to the method illustrative embodiment.
- FIG. 1 is an example embodiment of an information handling system capable of implementing aspects of the illustrative embodiments set forth herein;
- FIG. 2 is a diagram showing embodiments of a software controlled instruction cache (icache) manager translating a target instruction space address to other types of instruction addresses;
- icache software controlled instruction cache
- FIG. 3 is a diagram showing a cache line that includes direct branch instructions and corresponding branch descriptors in accordance with one illustrative embodiment
- FIG. 4 is a flowchart showing steps taken in compiling various branch instruction types in accordance with one illustrative embodiment
- FIG. 5 is a flowchart showing steps taken in executing a direct branch instruction in a runtime environment in accordance with one illustrative embodiment
- FIG. 6 is a flowchart showing steps taken in executing an indirect branch instruction in a runtime environment in accordance with one illustrative embodiment
- FIG. 7 is a flowchart showing steps taken in executing a function return instruction in a runtime environment in accordance with one illustrative embodiment
- FIG. 8A shows a target instruction space address translated into a target local store address in accordance with one illustrative embodiment
- FIG. 8B is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target instruction tag (ITAG) in accordance with one illustrative embodiment
- FIG. 8C is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target backing store address in accordance with one illustrative embodiment
- FIG. 9 illustrates information handling system, which is another embodiment of a simplified example of a computer system capable of performing the computing operations described herein;
- FIG. 10 is an example diagram of a branch stub in accordance with one illustrative embodiment
- FIG. 11 is an example diagram illustrating a rewriting of a link register in accordance with one illustrative embodiment
- FIG. 12 is an example diagram illustrating an overall operation of one illustrative embodiment for rewriting branch instructions using branch stubs
- FIG. 13 is a flowchart outlining an example operation of a compiler for rewriting branch instructions in accordance with one illustrative embodiment
- FIG. 14 is a flowchart outlining an example operation or an instruction cache runtime system for performing dynamic rewriting of branch instructions in accordance with one illustrative embodiment
- FIG. 15 is an example diagram illustrating a call stub in accordance with one illustrative embodiment
- FIG. 16 is a flowchart outlining an example operation of an instruction cache manager when handling the eviction of a cache line in accordance with one illustrative embodiment
- FIG. 17 is an example diagram illustrating one illustrative embodiment of a source code block listing quad word
- FIG. 18 is a flowchart outlining an example operation of a compiler when analyzing original code and inserting a list of possible source code blocks targeting a current code block in accordance with one illustrative embodiment
- FIG. 19 is a flowchart outlining an example operation of the instruction cache runtime system in accordance with one illustrative embodiment, with regard to handling eviction of a cache line;
- FIG. 20 is a flowchart outlining an example operation for performing code optimization using a partitioned call graph in accordance with one illustrative embodiment.
- the illustrative embodiments provide a mechanism for statically and dynamically rewriting branch instructions so that they may be more optimally executed in view of the limited size of local stores or caches of a processor.
- the mechanisms of the illustrative embodiments provide functionality for rewriting code, both statically by a compiler and dynamically by an instruction cache runtime system, to thereby generate and utilize branch stubs in the code for branch instructions.
- the branch stubs may be used as a basis for holding information about the branch instruction for use in determining whether a jump directly to a target of the branch instruction in the instruction cache may be possible or not.
- Examples of branch instructions include function calls, conditional branch instructions, unconditional branch instructions, function returns, and the like, as is generally known in the art.
- the mechanisms of the illustrative embodiments provide functionality for performing dynamic rewriting of branches based on whether or not the possible targets of the branches are known or not.
- the rewriting of the branch instructions allows the code to directly jump to target code in the instruction cache when possible rather than having to go through an instruction cache manager to determine if the target code is present in the instruction cache or not.
- the branch instruction is rewritten as a jump to the location of the target code in the instruction cache.
- the branch instruction is restored since it cannot jump to the target code directly but must trigger a software instruction cache mechanism to handle the jump to the target code.
- aspects of the present invention may be embodied as a system, method, or computer program product. Accordingly, aspects of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a “circuit,” “module” or “system.” Furthermore, aspects of the present invention may take the form of a computer program product embodied in any one or more computer readable medium(s) having computer usable program code embodied thereon.
- the computer readable medium may be a computer readable signal medium or a computer readable storage medium.
- a computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, device, or any suitable combination of the foregoing.
- a computer readable storage medium may be any tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.
- a computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in a baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof.
- a computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
- Computer code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, radio frequency (RF), etc., or any suitable combination thereof.
- any appropriate medium including but not limited to wireless, wireline, optical fiber cable, radio frequency (RF), etc., or any suitable combination thereof.
- Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as JavaTM, SmalltalkTM, C++, or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages.
- the program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server.
- the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
- LAN local area network
- WAN wide area network
- Internet Service Provider for example, AT&T, MCI, Sprint, EarthLinkTM, MSN, GTE, etc.
- These computer program instructions may also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions that implement the function/act specified in the flowchart and/or block diagram block or blocks.
- the computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus, or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
- each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s).
- the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved.
- FIG. 1 is an example embodiment of an information handling system capable of implementing aspects of the illustrative embodiments set forth herein.
- the example information handling system shown in FIG. 1 is an example of a Cell Broadband Engine (CBE) architecture available from International Business Machines Corporation of Armonk, N.Y. It should be appreciated, however, that the present invention is not limited to use with the CBE and other information handling system architectures, configurations, and the like, may be used without departing from the spirit and scope of the illustrative embodiments.
- CBE Cell Broadband Engine
- Processor element architecture ( 100 ) includes multiple heterogeneous processors that share a common memory and a common bus.
- Processor element architecture (PEA) 100 sends and receives information to/from external devices through input output 190 , and distributes the information to control plane 110 and data plane 140 using processor element bus 180 .
- Control plane 110 manages PEA 100 and distributes work to data plane 140 .
- Control plane 110 includes processing unit 120 , which runs operating system (OS) 125 .
- processing unit 120 may be a Power PC core that is embedded in PEA 100 and OS 125 may be a Linux operating system.
- Processing unit 120 manages a common memory map table for PEA 100 .
- the memory map table corresponds to memory locations included in PEA 100 , such as L2 memory 130 as well as non-private memory included in data plane 140 .
- Data plane 140 includes Synergistic Processing Elements (SPE) 150 , 160 , and 170 .
- SPE Synergistic Processing Elements
- Each SPE processes data information and each SPE may have different instruction sets.
- PEA 100 may be used in a wireless communications system and each SPE may be responsible for separate processing tasks, such as modulation, chip rate processing, encoding, and network interfacing.
- each SPE may have identical instruction sets and may be used in parallel to perform operations benefiting from parallel processes.
- Each SPE includes a synergistic processing unit (SPUs 155 , 165 , 175 ), which is a processing core, such as a digital signal processor, a microcontroller, a microprocessor, or a combination of these cores.
- Each SPU includes a local storage area (local stores 158 , 168 , and 178 ), which may be segmented into private and non-private memory.
- Each of local stores 158 , 168 , and 178 store a cache directory and tag directory (instruction and/or data), along with a cache manager (see FIG. 2 and corresponding text for further details).
- each cache manager within each SPU manages their corresponding cache and retrieves data from backing store 135 accordingly.
- an information handling system may take many forms.
- an information handling system may take the form of a desktop, server, portable, laptop, notebook, or other form factor computer or data processing system.
- an information handling system may take other form factors such as a personal digital assistant (PDA), a gaming device, ATM machine, a portable telephone device, a communication device or other devices that include a processor and memory (see FIG. 9 and corresponding text for another embodiment of an information handling system for performing compilation functions as described herein).
- PDA personal digital assistant
- FIG. 2 is a diagram showing embodiments of an instruction cache (icache) manager translating a target instruction space address to other types of instruction addresses.
- Local store 200 resides within a synergistic processing unit (e.g., SPU's 155 , 165 , or 175 ) and includes instruction cache (icache) manager 220 , instruction tag (ITAG) directory 225 , and instruction cache 230 .
- a synergistic processing unit e.g., SPU's 155 , 165 , or 175
- instruction cache (icache) manager 220 e.g., instruction cache (ITAG) directory 225 , and instruction cache 230 .
- ITAG instruction tag
- icache manager 220 In order to effectively move instructions from backing store 135 to icache 230 , icache manager 220 requires an effective address within backing store 135 that corresponds to the location of the target instruction (target backing store address 280 ), as well as a local storage address within icache 230 to store the instruction (target local store address 260 ). In addition, icache manager 220 requires an instruction tag that corresponds to the target instruction in order to utilize ITAG directory 225 and determine a cache hit or a cache miss (target ITAG 270 ). As discussed herein, icache manager 220 uses an instruction's “instruction space address” (target instruction space address 255 ) to compute an instruction's target backing store address, target local store address, and target ITAG. The instruction space address is an address given to an instruction at link/load time based upon the location of the instruction in a program (program 250 ).
- icache manager 220 determines whether the target instruction already resides in icache 230 by checking whether the target instruction's corresponding instruction tag (ITAG) is located in ITAG directory 225 (target ITAG 270 ). In order to generate target ITAG 270 , icache manager 220 uses target ITAG subroutine 265 , which generates target ITAG 270 using target instruction space address 255 and a tag array mask (see FIG. 8B and corresponding text for further details).
- ITAG instruction tag
- icache manager 220 When icache manager 200 needs to load the target instruction from backing store 135 into icache 230 , icache manager 220 computes the location of the target instruction in backing store 135 (target backing store address 280 ) as well as the location to store the target instruction in icache 230 (target local store address 260 ). Icache manager 220 utilizes target instruction space address 255 to generate these addresses as discussed below.
- target instruction space address 255 is 32 bits.
- Target instruction space address 255 's 18 least significant bits is target local store address 260 because local store 200 is 256 KB in size and only requires 18 bits for addressing into icache 230 .
- icache manager 220 masks off target instruction space address 255 's 14 most significant bits in order to generate target local store address 260 (see FIG. 8A and corresponding text for further details).
- more or less bits may be required for target local store address 260 based upon the size of local store 200 .
- icache manager 220 uses backing store subroutine 275 , which generates an offset using target instruction space address 255 and an icache base address, and uses the offset and a mask to generate target backing store address 280 (see FIG. 8C and corresponding text for further details). In turn, icache manager 220 retrieves the target instruction from target backing store address 280 ; stores the target instruction in target local store address 260 ; and updates ITAG directory 225 accordingly.
- FIG. 3 is a diagram showing a cache line that includes direct branch instructions and corresponding branch descriptors in accordance with one illustrative embodiment.
- a “direct” branch instruction is an instruction in which the address of a next instruction to execute, i.e. the target of the branch instruction, is explicitly specified.
- An “indirect” branch instruction is one in which the address of the next instruction to execute is not explicitly specified but instead the argument of the branch instruction specifies where the address is located.
- an example of an indirect branch instruction could be of the type “jump indirect on the r 1 register,” which means that the next instruction to be executed would be at the address whose value is stored in register r 1 .
- indirect branch instructions can also depend on the value of a memory location, rather than a specified register.
- the address of the next instruction to execute is not known at compile time, but is only known once the branch instruction is executed, i.e. at runtime.
- the target of the branch instruction is known at compile time.
- FIG. 3 shows instruction cache 230 , which includes cache line 300 .
- Cache line 300 includes multiple instructions, some of which are direct branch instructions 310 and 320 .
- Cache line 300 also includes branch descriptors 330 and 350 , which correspond to direct branch instructions 310 and 320 , respectively.
- Branch descriptor 330 includes trampoline branch instruction 335 and target instruction space address 345 .
- a trampoline branch is an instruction that, when executed, branches to, or “bounces” to icache manager 220 , thus causing a trampoline effect.
- trampoline branch instruction 335 is invoked, which branches to icache manager 220 and loads pointer 340 into a link register via a branch and set link instruction, which points back to branch descriptor 330 .
- icache manager 220 uses pointer 340 to locate branch descriptor 330 and retrieve target instruction space address 345 .
- Icache manager 220 uses target instruction space address 345 to generate various addresses and locate a target instruction corresponding to direct branch instruction 310 (see FIG. 5 and corresponding text for further details).
- Branch descriptor 350 includes trampoline branch instruction 355 and target instruction space address 365 .
- Target instruction space address 365 corresponds to a location of the target instruction for branch instruction 320 .
- trampoline branch instruction 355 is invoked, which branches to icache manager 220 and loads pointer 360 into the link register via a branch and set link instruction, which points back to branch descriptor 350 .
- icache manager 220 uses pointer 360 to locate branch descriptor 350 and retrieve target instruction space address 365 .
- FIG. 4 is a flowchart showing steps taken in compiling various branch instruction types in accordance with one illustrative embodiment.
- the illustrative embodiments described herein includes embodiments discussing code compilation/linking, and embodiments discussing code execution (e.g., runtime environment).
- FIG. 4 shows steps taken by a compiler (and/or linker) when the compiler encounters a branch instruction while compiling source code.
- Processing commences at 400 , whereupon processing retrieves an instruction from source code 410 at step 405 .
- decision 420 branches to “Yes” branch 428 , whereupon a determination is made as to the type of branch instruction (decision 430 ). If the instruction is a direct branch instruction, decision 430 branches to “Direct” branch 432 whereupon processing generates a branch descriptor that includes a trampoline branch instruction and a target instruction space address at step 440 .
- the direct branch instruction branches to the trampoline branch instruction, which sends a pointer to the icache manager and, in turn, the icache manager retrieves the target instruction space address from the branch descriptor (see FIGS. 3 , 5 , and corresponding text for further details).
- processing compiles the branch instruction and branch descriptor.
- decision 430 branches to “Indirect” branch 438 , whereupon processing generates a number of instructions (step 460 ) to handle the indirect branch during runtime execution.
- the instructions include an instruction to translate the indirect branch's target instruction space address to an instruction tag (ITAG) along with an instruction to look up the ITAG in an icache directory (icache directory 225 shown in FIG. 2 ). Processing also generates instructions in order to handle hit or miss outcomes of the lookup.
- ITAG instruction tag
- processing generates an instruction that translates the target instruction space address to a target local store address in order to branch to the instruction in icache if the lookup results in a cache hit, and also generates an instruction that calls the icache manager if the lookup results in a cache miss.
- processing compiles the instructions.
- FIG. 5 is a flowchart showing steps taken in executing a direct branch instruction in a runtime environment in accordance with one illustrative embodiment.
- a branch descriptor is inserted into a cache line for each direct branch instruction (see FIG. 4 and corresponding text for further details).
- the branch descriptor includes information to pass onto an icache manager to process the direct branch instruction.
- Processing commences at 500 , whereupon processing (e.g., application thread) loads a direct branch instruction at step 505 .
- the direct branch instruction was arranged at load time to branch to a trampoline branch instruction included in the direct branch's corresponding branch descriptor (see FIG. 3 and corresponding text for further details).
- processing branches to the trampoline branch instruction included in the corresponding branch descriptor.
- the trampoline branch instruction branches to the icache manager and sends a branch descriptor pointer to the icache manager (e.g., stores the branch descriptor pointer in an icache link register).
- Icache manager processing commences at 530 , whereupon the icache manager retrieves the branch descriptor pointer from the link register at step 535 .
- the icache manager uses the branch descriptor pointer to locate and extract the target instruction space address from the branch descriptor.
- the target instruction space address is an address that corresponds to the direct branch's target instruction.
- the icache manager computes a target ITAG from the target instruction space using a tag array mask (see FIG. 8B and corresponding text for further details).
- the icache manager looks up the target ITAG in ITAG directory 225 in order to determine whether the target instruction is located in icache 230 (step 550 ).
- ITAG directory 225 fails to include the target ITAG (cache miss)
- decision 560 branches to “No” branch 568 whereupon processing computes a target backing store address from the target instruction space address using an offset and mask at step 570 (see FIG. 8C and corresponding text for further details).
- the target backing store address corresponds to the location of the target instruction stored in backing store 135 .
- the icache manager translates the target instruction space address to a target local store address at step 575 by masking off a portion of the target instruction space address (see FIG. 8A and corresponding text for further details).
- the target local store address is the location in icache 230 that the target instruction is stored.
- the icache manager loads the target instruction from backing store 135 into icache 230 .
- the icache manager branches to the target instruction located at the target local store address within icache 230 and passes control back to the application thread (step 565 ), which continues program execution at step 520 .
- Icache manager processing ends at 570 and application thread processing ends at 525 .
- FIG. 6 is a flowchart showing steps taken in executing an indirect branch instruction in a runtime environment in accordance with one illustrative embodiment.
- Indirect branch processing commences at 600 , whereupon processing (e.g., application thread) computes a target instruction tag (ITAG) using a target instruction space address located in register store 615 that corresponds to the indirect branch instruction's target instruction (step 610 ).
- the target instruction space address was stored in register store 615 from a previous instruction (hence an indirect branch instruction).
- Processing looks up the target ITAG in ITAG directory 225 at step 620 , and a determination is made as to whether the lookup results in a cache hit or a cache miss (decision 630 ). If a cache miss occurs, decision 630 branches to “No” branch 632 , whereupon processing calls icache manager 220 to move the target instruction from backing store 135 into icache 230 (step 640 ). Icache manager 220 , in turn, translates the target instruction space address to a target backing store address and a target local store address in order to move the target instruction from backing store 135 into icache 230 (see FIGS. 5 , 8 A, 8 C, and corresponding text for further details). On the other hand, if a cache hit occurs, decision 630 branches to “Yes” branch 638 , bypassing icache manager steps.
- processing translates the target instruction space address to the target local store address and, at step 660 , processing retrieves the target instruction from icache 230 at the target local store address. Processing continues program execution at step 670 , and ends at 680 .
- FIG. 7 is a flowchart showing steps taken in executing a function return instruction in a runtime environment in accordance with one illustrative embodiment. Processing commences at 700 , whereupon processing executes a function return instruction and, in doing so, creates a target local store address (icache address) as the return value, which is stored in a link register included in register store 720 (step 705 ).
- icache address target local store address
- the target instruction space address is stored in the link register such that when the function return completes, processing realizes that the target instruction is no longer in icache 230 and should call the icache manager to move the target instruction from backing store 135 into icache 230 (discussed below).
- decision 710 branches to “No” branch 718 bypassing translation steps.
- decision 730 A determination is made as to whether the function return has completed (decision 730 ). If the function return has not yet completed, decision 730 branches to “No” branch 732 , which loops back to monitor function return completion and target instruction eviction. This looping continues until the function return completes, at which point decision 730 branches to “Yes” branch 738 whereupon processing retrieves the link register value from register store 720 (step 740 ).
- step 765 converts the target instruction space address to the target local store address.
- the link register value is a target local store address (e.g., target instruction was not evicted)
- decision 750 branches to “TLSA” branch 758 bypassing icache manager calling steps.
- processing branches to the target address at the target local store address and continues program execution at step 780 . Processing ends at 790 .
- FIG. 8A shows a target instruction space address translated into a target local store address in accordance with one illustrative embodiment.
- the target instruction space address discussed herein includes 32 bits and the target local store address discussed herein includes 18 bits. As those skilled in the art can appreciate, more or less bits may be used for the target instruction space address and/or the target local store address.
- the target instruction space address includes the target local store address in its 18 least significant bits (see FIG. 2 and corresponding text for further details).
- the icache manager masks off target instruction space address 800 's 14 most significant bits using mask 810 , which leaves 18 least significant bits as target local store address 820 .
- FIG. 8B is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target instruction tag (ITAG) in accordance with one illustrative embodiment.
- Icache manager processing commences at 830 , whereupon the icache manager generates an instruction tag index using the target instruction space effective address and a tag array mask (step 840 ).
- a tag array is an array of structures with one element per cache line. Each element includes an instruction space address of a corresponding line that is currently resident. As such, in this embodiment:
- tag array mask Number of cache lines ⁇ 1
- ITAG index (TISA/linesize)&tag mask
- the icache manager generates the target instruction tag at step 850 from the generated ITAG index, such as by using the instruction:
- the icache manager may then use the target ITAG to look in the ITAG directory and determine whether a corresponding target instruction is located in the icache or whether the icache manager should retrieve the target instruction from backing store and load it into the icache. Processing ends at 860
- FIG. 8C is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target backing store address.
- Icache manager processing commences at 870 , whereupon the icache manager generates an offset using the target instruction space address (TISA) and icache base address (step 880 ), such as with the instruction:
- TISA target instruction space address
- icache base address step 880
- the icache manager generates the target backing store address (TBSA) using the generated offset and mask that preserves an index into a cache array, such as with the instruction:
- TBSA (offset&mask that preserves idx into cache array)
- the icache manager may then use the target backing store address to retrieve the target instruction from backing store at the target backing store address, and load the target instruction into the icache (see FIGS. 5-7 and corresponding text for further details). Processing ends at 895 .
- FIG. 9 illustrates information handling system 900 , which is another embodiment of a simplified example of a computer system capable of performing the computing operations described herein.
- Information handling system 900 includes one or more processors 910 coupled to processor interface bus 912 .
- Processor interface bus 912 connects processors 910 to Northbridge 915 , which is also known as the Memory Controller Hub (MCH).
- Northbridge 915 connects to system memory 920 and provides a means for processor(s) 910 to access the system memory.
- Graphics controller 925 also connects to Northbridge 915 .
- PCI Express bus 918 connects Northbridge 915 to graphics controller 925 .
- Graphics controller 925 connects to display device 930 , such as a computer monitor.
- Northbridge 915 and Southbridge 935 connect to each other using bus 919 .
- the bus is a Direct Media Interface (DMI) bus that transfers data at high speeds in each direction between Northbridge 915 and Southbridge 935 .
- a Peripheral Component Interconnect (PCI) bus connects the Northbridge and the Southbridge.
- Southbridge 935 also known as the I/O Controller Hub (ICH) is a chip that generally implements capabilities that operate at slower speeds than the capabilities provided by the Northbridge.
- Southbridge 935 typically provides various busses used to connect various components. These busses include, for example, PCI and PCI Express busses, an ISA bus, a System Management Bus (SMBus or SMB), and/or a Low Pin Count (LPC) bus.
- PCI and PCI Express busses an ISA bus
- SMB System Management Bus
- LPC Low Pin Count
- the LPC bus often connects low-bandwidth devices, such as boot ROM 996 and “legacy” I/O devices (using a “super I/O” chip).
- the “legacy” I/O devices ( 998 ) can include, for example, serial and parallel ports, keyboard, mouse, and/or a floppy disk controller.
- the LPC bus also connects Southbridge 935 to Trusted Platform Module (TPM) 995 .
- TPM Trusted Platform Module
- Other components often included in Southbridge 935 include a Direct Memory Access (DMA) controller, a Programmable Interrupt Controller (PIC), and a storage device controller, which connects Southbridge 935 to nonvolatile storage device 985 , such as a hard disk drive, using bus 984 .
- DMA Direct Memory Access
- PIC Programmable Interrupt Controller
- storage device controller which connects Southbridge 935 to nonvolatile storage device 985 , such as a hard disk drive, using bus 984 .
- ExpressCard 955 is a slot that connects hot-pluggable devices to the information handling system.
- ExpressCard 955 supports both PCI Express and USB connectivity as it connects to Southbridge 935 using both the Universal Serial Bus (USB) the PCI Express bus.
- Southbridge 935 includes USB Controller 940 that provides USB connectivity to devices that connect to the USB. These devices include webcam (camera) 950 , infrared (IR) receiver 948 , keyboard and trackpad 944 , and Bluetooth device 946 , which provides for wireless personal area networks (PANs).
- webcam camera
- IR infrared
- keyboard and trackpad 944 keyboard and trackpad 944
- Bluetooth device 946 which provides for wireless personal area networks (PANs).
- USB Controller 940 also provides USB connectivity to other miscellaneous USB connected devices 942 , such as a mouse, removable nonvolatile storage device 945 , modems, network cards, ISDN connectors, fax, printers, USB hubs, and many other types of USB connected devices. While removable nonvolatile storage device 945 is shown as a USB-connected device, removable nonvolatile storage device 945 could be connected using a different interface, such as a Firewire interface, etcetera.
- Wireless Local Area Network (LAN) device 975 connects to Southbridge 935 via the PCI or PCI Express bus 972 .
- LAN device 975 typically implements one of the IEEE 802.11 standards of over-the-air modulation techniques that all use the same protocol to wireless communicate between information handling system 900 and another computer system or device.
- Optical storage device 990 connects to Southbridge 935 using Serial ATA (SATA) bus 988 .
- Serial ATA adapters and devices communicate over a high-speed serial link.
- the Serial ATA bus also connects Southbridge 935 to other forms of storage devices, such as hard disk drives.
- Audio circuitry 960 such as a sound card, connects to Southbridge 935 via bus 958 .
- Audio circuitry 960 also provides functionality such as audio line-in and optical digital audio in port 962 , optical digital output and headphone jack 964 , internal speakers 966 , and internal microphone 968 .
- Ethernet controller 970 connects to Southbridge 935 using a bus, such as the PCI or PCI Express bus. Ethernet controller 970 connects information handling system 900 to a computer network, such as a Local Area Network (LAN), the Internet, and other public and private computer networks.
- LAN Local Area Network
- the Internet and other public and private computer networks.
- the above mechanisms provide the ability for code to jump, through the use of a trampoline instruction, to the instruction cache manager of the instruction cache to check whether the target code for a branch instruction is in the instruction cache or not. If not, the instruction cache manager will bring the target code into the cache. The instruction cache manager will then cause the execution to jump to where the target code is present in the instruction cache.
- This allows code segments to be brought from a backing store, or main memory, of the system into a local store or instruction cache associated with a processor.
- This mechanism may be replicated with each processor of a multi-processor system such that each processor may manage the moving of instructions into and out of the local stores or instruction caches associated with the individual processors.
- the mechanisms of the illustrative embodiments provide further functionality to dynamically rewrite branch instructions utilizing branch stubs, i.e. small portions of code that stand in for, or replace, another programming function.
- the branch stubs maintain information about branch instructions and serve as a mechanism for jumping directly to target code in the instruction cache when possible.
- the branch stub code serves a similar purpose as the trampoline code with the exception that the overhead of the instruction cache manager is avoided when the target code exists within the instruction cache.
- the execution of the code may be redirected to the instruction cache manager as previously described above.
- These mechanisms may be implemented in an information handling system, such as described above with reference to FIG. 9 , or other type of information/data processing system.
- the branch stubs are introduced into the code, such as at the end of a code block (a section of code grouped together, typically having a size that is able to fit into one or more cache lines of an instruction cache), by a compiler at compile time and may be dynamically updated at runtime by an instruction cache runtime system.
- the instruction cache runtime system is the collection of software designed to support the execution of computer programs, which may include subroutines and libraries for common operations, implementation of programming language commands, type checking, debugging, code generation and optimization, and the like.
- the instruction cache runtime system includes an instruction cache manager, such as that previously described above, which has been modified to make use of the additional mechanisms described in the further illustrative embodiments hereafter.
- branch instructions may be function calls, conditional branch instructions, unconditional branch instructions, or the like, and may be direct branch instructions or indirect branch instructions.
- the branch stubs can be used to store a branch offset, i.e. an offset from the address of the branch instruction, that is used to locate the original target address of the next instruction to execute and thus, the target is explicitly identified.
- the direct branch instruction can be rewritten so that it targets the address of the actual target inside the instruction cache, rather than the address of the branch stub. In this way, further executions of the direct branch instruction will proceed directly to the target address of the next instruction directly without incurring instruction cache runtime system overhead, i.e. the overhead associated with jumping to the instruction cache manager of the instruction cache runtime system.
- Indirect branch instructions cannot be rewritten in the same manner as direct branch instructions using the branch stubs since the targets of indirect branch instructions are only known at runtime and may be different each time the indirect branch instructions are executed. Thus, the overhead associated with having to go to the instruction cache runtime system can only be avoided if it can be determined that the current target of the indirect branch instruction is already in the instruction cache.
- the illustrative embodiments provide mechanisms for determining whether the target of an indirect branch instruction is in the instruction cache or not so that a direct jump can be made using the branch stub.
- the instruction cache runtime system may monitor the execution of code to identify these indirect branch instructions and may determine the target of the indirect branch instruction and whether the target of the indirect branch instruction is the same target as in a previous execution of the indirect branch instruction.
- the branch stubs for indirect branch instructions along with a compiler inserted check instruction, can be used to make such a determination, as will be described in greater detail hereafter. If the indirect branch instruction is targeting the same target address as for a previous execution of the indirect branch instruction, then the execution may jump directly to this target in the instruction cache without having to go through the instruction cache runtime system, e.g., the instruction cache manager.
- the execution may jump to the instruction cache runtime system, such as the instruction cache manager as described above, to bring the target of the indirect branch instruction into the instruction cache.
- one aspect of these illustrative embodiments is the introduction of branch stubs for branch instructions in code provided to a compiler.
- the compiler may analyze the received code, identify branch instructions in the code as well as whether the branch instruction is a direct branch instruction or an indirect branch instruction. For example, the compiler may identify a branch instruction as a direct branch instruction when the target of the branch instruction is a discernable address at compile time. A branch instruction whose target is a register or some other location whose contents are dynamically determined at runtime, will be identified by the compiler as an indirect branch instruction.
- the compiler For direct and indirect branch instructions, the compiler generates a branch stub, inserts a link to the instruction cache manager into a first portion of the branch stub, and a copy of the target address from the original branch instruction in a second portion of the branch stub. The original branch instruction is then rewritten to reference the branch stub, i.e. the target of the original branch instruction is changed to an address or offset to the branch stub for that branch instruction to thereby generate a modified branch instruction.
- the compiler further inserts a check instruction, such as prior to the branch instruction, to check whether a target of the branch instruction matches a previous target of the same branch instruction and to jump to one of the target instruction or the instruction cache runtime system based on an outcome of the check. This will be described in greater detail hereafter.
- FIG. 10 is an example diagram of a branch stub in accordance with one illustrative embodiment.
- the branch stub 1000 comprises a plurality of portions of data 1010 - 1040 with each portion of data 1010 - 1040 storing different information based on the type of branch instruction that is replaced by the branch stub 1000 .
- the branch stub 1000 is comprised of four words 1010 - 1040 , with each word being a fixed size number of bits of data.
- the first portion 1010 of the branch stub 1000 e.g., the first word
- the first portion 1010 is used for storing an address to link register and a cache miss handler in the first portion 1010 , which may be the instruction cache manager, may be part of the instruction cache manager, or may otherwise be provided by the instruction cache runtime system, for example, in case the target of the branch is not present in the instruction cache when the branch stub is processed.
- the second portion 1020 may store a copy of the target effective address from the original branch instruction.
- the last two portions 1030 and 1040 are free to be used by the instruction cache runtime system to store information about runtime status of the branch instructions that are rewritten using the branch stub 1000 based on the type of branch instruction being replaced or rewritten.
- the third portion 1030 of the branch stub 1000 may be used by the instruction cache runtime system, for direct branch instructions, to store an offset into a cache line or cache line for locating the original branch instruction.
- the fourth portion 1040 of the branch stub 1000 may be used to store a copy of the original branch instruction before rewriting.
- the mechanisms of the illustrative embodiments make use of the observation that indirect branch instructions tend to target the same target address at runtime.
- the instruction cache runtime system uses a sub-portion of the third portion 1030 of the branch stub 1000 , which is unused for direct branch instructions, to store the target address for the last target called by the indirect branch instruction.
- This target address for the last target called by the indirect branch instruction, stored in sub-portion of the third portion 1030 of the branch stub 1000 may be used by the check instruction inserted by the compiler to check to see if the previous execution of the indirect branch instruction targeted the same target address or not as the current execution of the indirect branch instruction.
- the indirect branch instruction can jump directly to the target instruction in the instruction cache without having to go through the instruction cache manager. If the target address for the last target called by the indirect branch instruction does not match the target of the current execution of the indirect branch instruction, then the execution jumps to the instruction cache manager to perform the necessary operations for bringing the target into the instruction cache, as previously described above.
- the saved target address in the sub-portion of the third portion 1030 of the branch stub 1000 of the calling indirect branch instruction needs to be cleared when the target instruction is evicted from the instruction cache.
- the target address information stored in the branch stub 1000 must be cleared when the target instruction is evicted from the instruction cache. More about eviction will be provided hereafter.
- each SPE may support 128 bit registers, each of which may store a quadword.
- Register r 0 may be used as a link register, i.e. a register that stores the address to return to when a function completes execution, with only word 0 of the link register typically being used.
- a return handler which may be part of the instruction cache manager, or otherwise provided in the instruction cache runtime system, is called with the link register address as input.
- the return handler would then check whether the code block to return to is still in the instruction cache or not, and if not, it will fetch the code block from the backing store or main memory and put it into the instruction cache.
- FIG. 11 is an example diagram illustrating a rewriting of a link register in accordance with one illustrative embodiment.
- the mechanisms of the illustrative embodiments rewrite the link register 1100 so that additional information is stored in the link register 1100 . That is, typically the link register 1100 only stores the return address, referred to as the load/store return address, in word 0 1110 of the link register 1100 .
- the instruction cache runtime system rewrites the link register 1100 to store a target address in word 0 1110 , which is to be used as a basis for an indirect branch instruction to the target address, and an effective address (EA) for the return address in word 1 1120 .
- EA effective address
- the instruction cache runtime system can perform a load of the link register from the stack and perform an indirect branch to the link register.
- the target of the indirect branch instruction to the link register will be word 0 of the link register.
- This indirect branch instruction can then be handled using the mechanisms noted above with regard to indirect branches.
- the target address stored in word 0 of the link register corresponds to the same target address as a previous execution of the indirect branch, as determined from a branch stub associated with the indirect branch instruction, then the execution of the code can bypass the return handler of the instruction cache runtime system and jump directly to the target instruction in the instruction cache. If the target addresses do not match, then the instruction cache manager may be invoked as discussed above.
- the return handler of the instruction cache runtime system e.g., in the instruction cache manager, stores the instruction cache address of the code block to return to in the first slot or word, e.g., word 0 1110 , of the link register 1100 .
- the return handler also stores the corresponding effective address of the instruction cache address of the code block to return to in a second slot or word, e.g., word 1 1120 , of the link register 1100 .
- the instruction cache manager may traverse all call stack frames through a back chain. For each call stack frame, the instruction cache manager may examine the second slot or word, e.g., word 1 1120 , of the link register 1100 . If the effective address in the second slot or word matches the cache line evicted, then the instruction cache manager may modify the first slot or word, e.g., word 0 1110 , of the link register 1100 to point to the address of the return handler of the instruction cache runtime system. Thus, later, when the branch instruction returns, the return handler will be invoked instead, and the return handler knows which cache line to fetch based on the second slot or word, e.g., word 1 1120 , of the link register 1100 .
- FIG. 12 is an example diagram illustrating an overall operation of one illustrative embodiment for rewriting branch instructions using branch stubs.
- original code 1210 is provided and may include one or more direct branch instructions 1212 and/or one or more indirect branch instructions 1214 .
- the compiler 1220 may receive the original code 1210 and, as part of its optimizations, may rewrite the branches in the original code 1210 using branch stubs with the branch instructions referencing the branch stubs.
- the compiler 1220 may be provided with branch rewriting logic 1222 that performs the static analysis of the original code 1210 as described previously to identify branches in the original code 1210 and rewrite these branches accordingly.
- the branch rewriting logic 1222 may identify the branches in the original code 1210 , generate a branch stub, e.g., branch stubs 1238 and 1239 , for each of the branches in the original code 1210 , and populate the branch stubs with an address for the instruction cache manager (for use in the case of a target block not being present in the instruction cache), as well as an original target address from the original branch instruction.
- the original branch instructions are then rewritten to replace the reference to the target instruction with a reference to the branch stub corresponding to the branch instruction. This is done regardless of whether the branch instruction is a direct branch instruction or an indirect branch instruction.
- the rewritten code 1230 includes rewritten branch instructions 1232 and 1236 as well as branch stubs 1238 and 1239 with a linking between the rewritten branch instructions and their corresponding branch stubs (represented by the arrows in FIG. 12 ).
- the branch rewriting logic 1222 further determines which branch instructions in the original code 1210 are direct branch instructions 1212 or indirect branch instructions 1214 .
- the branch rewriting logic 1222 inserts check target instructions, such as check target instruction 1234 .
- these check target instructions 1234 at runtime, cause a check to be performed of the target address of the current execution of an indirect branch instruction with a target address of a last previous execution of the indirect branch instruction to see if there is a match between the two. If there is a match, then the execution jumps to the target address directly without having to go to the instruction cache (icache) runtime system 1240 . If there is not a match, then the execution goes to the icache runtime system 1240 so that an instruction cache manager 1242 may perform the necessary operations to ensure that the block of code targeted by the indirect branch instruction is brought into the instruction cache (icache) 1250 .
- the rewritten code 1230 may be provided to a linker (not shown) which then links the code with library functions and the like, and generates executable code that is provided to processor 1280 .
- the processor 1280 may execute the rewritten code 1230 and, in the process execute the rewritten branch instructions 1232 and 1236 using the corresponding branch stubs 1238 and 1239 .
- the icache runtime system 1240 may monitor the execution to determine when the branch instructions need to be dynamically rewritten.
- the dynamic branch rewriting logic 1244 of the icache runtime system 1240 rewrites the direct branch instruction 1232 dynamically to directly target the location 1254 within the instruction cache 1250 where the target of the original branch instruction is currently located, rather than pointing to the branch stub 1238 .
- This dynamic rewriting is performed to the direct branch instruction in the direct branch cache line 1252 in the icache 1250 .
- indirect branch instructions such as indirect branch instruction 1236
- the dynamic branch rewriting logic 1244 monitors whether the corresponding check target instruction 1234 results in the target addresses matching or not. If the target addresses match, then the processor may access the indirect branch target cache line 1258 directly without having to go through the instruction cache manager 1242 of the icache runtime system 1240 . If the target addresses do not match, then the execution branches to the instruction cache manager 1242 of the instruction cache runtime system 1240 , as specified by the first portion of the branch stub.
- the dynamic branch rewriting logic 1244 rewrites the indirect branch stub 1239 , in the indirect branch cache line 1256 , with the current target address of the current execution of the indirect branch instruction 1236 , such as in a sub-portion of the third word 1030 in FIG. 10 .
- the target address stored in the indirect branch stub in the indirect branch cache line 1256 is updated to store the last previous target address of the indirect branch instruction.
- the branch return rewriting logic 1246 of the icache runtime system 1240 operates to rewrite the link register 1260 so that it stores the target address and effective address of the target address in the link register as discussed above with regard to FIG. 11 .
- a branch instruction returns, it returns to the target address in the link register using an indirect branch instruction that is handled in the same manner as other indirect branch instructions discussed above.
- the instruction cache manager 1242 may perform the operations noted above using the call stack 1270 to traverse call stack frames to determine if there is a match to the effective address of the link register 1260 and if so, cause the branch return rewriting logic to rewrite the target address in the link register 1260 to point to the instruction cache manager 1242 .
- FIG. 13 is a flowchart outlining an example operation of a compiler for rewriting branch instructions in accordance with one illustrative embodiment.
- the operation starts with the compiler analyzing the received code (step 1305 ) and determining if a branch instruction is encountered (step 1310 ). If a branch instruction is not encountered, the operation determines if an end of the code is encountered (step 1315 ). If not, the operation returns to step 1305 . Otherwise the optimized code is output to the linker for generation of executable code (step 1320 ) and the operation terminates.
- the compiler If the compiler encounters a branch instruction (step 1310 ), the compiler generates a branch stub for the branch instruction including storing the address to the instruction cache manager and the original target address of the branch instruction as described above (step 1325 ). The compiler rewrites the branch instruction to target the branch stub (step 1330 ) and determines if the branch instruction is an indirect branch instruction (step 1335 ). If the branch is an indirect branch instruction, the compiler inserts a check target instruction prior to the branch instruction that checks the target of the indirect branch instruction against a last previous target address stored in the branch stub and jumps directly to the target if there is a match or jumps to the instruction cache manager if there is not a match (step 1340 ). Thereafter, or if the branch instruction is not an indirect branch instruction, the operation continues to step 1315 .
- FIG. 14 is a flowchart outlining an example operation or an instruction cache runtime system for performing dynamic rewriting of branch instructions in accordance with one illustrative embodiment.
- the operation starts by receiving a cache line request requesting an access to a particular portion of code in a cache line of the instruction cache (step 1405 ).
- a determination is made as to whether there is a cache hit or not, i.e. the cache line corresponding to the cache line request is already present in the instruction cache (step 1410 ). If there is a cache hit, then the cache line is accessed from the instruction cache (step 1415 ) and the operation terminates. If there is not a cache hit, i.e.
- step 1420 a determination is made as to whether the instruction cache has available unused space to store a cache line corresponding to the cache line request (step 1420 ). If there is available space, then the requested cache line is fetched from the backing store and loaded into the instruction cache (step 1425 ), with the operation returning to step 1405 where the cache line request is again executed.
- an existing cache line is evicted (step 1430 ) and a determination is made as to whether dynamic branch rewriting is to be performed (step 1435 ). If dynamic branch rewriting is not to be performed, the operation continues to step 1425 .
- the determination as to whether to perform dynamic branch rewriting may include, for example, determining if a branch instruction loaded with the cache line targeted by the cache line request is a direct branch or an indirect branch. If the branch is a direct branch, then the branch instruction can be dynamically rewritten to directly reference the location of the original target instruction in the instruction cache rather than referencing the branch stub of the direct branch.
- a check instruction may be executed to determine if the target of the indirect branch is the same as a last previous target as stored in the branch stub. If there is a match, then the branch instruction can jump directly to the target in the instruction cache. If there is not a match, then the execution may branch to the instruction branch manager and the current target may be stored in the branch stub in replacement of the last previous target address.
- step 1440 the dynamic branch rewriting is performed as discussed above (step 1440 ).
- a return rewrite operation may then be performed for the evicted cache line based on the effective address of the target stored in the link register, as previously described above (step 1445 ).
- the link register may then be dynamically rewritten (step 1450 ). As noted above, the link register may be rewritten to include the target address and the effective address of the target.
- An indirect branch instruction to the target address stored in the link register may be inserted at the branch return (step 1455 ). The operation then terminates.
- the illustrative embodiments provide a mechanism for using a branch stub and runtime logic to bypass the instruction cache manager in instances where it can be determined that the target of the branch instruction is already present in the instruction cache.
- the mechanisms of the illustrative embodiments provide a functionality for rewriting a link register so that upon a return from executing a branch instruction, an indirect branch to a target specified in the link register, or the instruction cache manager is made possible.
- the unchaining process i.e. retracing the jump instructions from one cache line to another in the instruction cache to identify source cache lines, i.e. the cache line from which a branch or call to a cache line of interest, or target cache line
- source cache lines i.e. the cache line from which a branch or call to a cache line of interest, or target cache line
- One mechanism for handling this situation is to flush the entire instruction cache or utilize expensive bookkeeping and table lookup algorithms which result in significant overhead and lose the opportunity for reuse of the cache line, i.e. if the instruction cache is flushed and all cache lines are evicted, then the cache lines that were brought into the instruction cache cannot be used again.
- the illustrative embodiments provide additional mechanisms for handling cache eviction in which branch instructions have been rewritten to directly target cache lines that are to be evicted.
- the possible source cache lines of a cache line of interest hereafter referred to as the target cache line
- the linked list is scanned to restore the chained jump branch instructions.
- the mechanisms of the illustrative embodiments support efficient eviction via a doubly linked list of cross inter-cache line branches who's branch targets are in a particular cache line, and a singly linked list of inter-cache line branches within a particular cache line that have been put into the doubly linked lists of the other cache lines.
- the mechanisms of the illustrative embodiments support a partial stack scan with the stack back trace scan being stopped at a first match to a “victim” cache line, as described hereafter.
- the rewriting of direct function calls is very similar to rewriting branches inside a function.
- the compiler generally does not have a complete view of all functions inside a program and thus, the compiler does not know the exact set of possible callers to a callee function. As a result, the compiler cannot pre-allocate space to record all call sites, i.e. the branch instruction that makes the function call which is also part of the source cache line, as in the case of branches inside a function.
- the mechanisms of the illustrative embodiments address these problems by using a linked list based solution that is able to handle an arbitrary number of call sites, i.e. branch instructions that branch to, or “call,” a portion of code corresponding to a target cache line, i.e. a callee function.
- a linked list is dynamically constructed that records rewritten call sites that call the callee function.
- the linked list node is constructed as part of an extended branch stub, which is referred to herein as a “call stub,” which extends the branch stub described above with an additional quadword for tracking call sites.
- a call stub which extends the branch stub described above with an additional quadword for tracking call sites.
- information corresponding to the branch stub previously described above is stored.
- a linked list previous entry pointer and a linked list next entry pointer for pointing to entries in a linked list of call sites are stored.
- the linked list previous entry pointer points to a previous entry in the linked list and the linked list next entry pointer points to a next entry in the linked list. This provides a doubly linked list of call sites that facilitates a more simplified deletion process for deleting call sites from the linked list.
- FIG. 15 is an example diagram illustrating a call stub in accordance with one illustrative embodiment.
- the call stub 1500 includes a first portion 1510 , which may be a first quad word, that stores data similar to that of the branch stub previously described above. That is, the first portion 1510 stores, in a first word 1512 , a link to the instruction cache manager in the case of a instruction cache miss.
- a second word 1514 the target address for the original branch instruction or function call is stored.
- an offset to the original branch or call instruction is stored.
- a copy of the original branch or call instruction is stored.
- the call stub includes a second portion 1520 , which may be a second quadword, for storing linked list pointers for purposes of handling instruction cache eviction.
- a first word 1522 of the second portion 1520 may store a linked list previous pointer that points to, i.e. stores an address for, a previous call stub in the linked list.
- a second word 1524 of the second portion 1520 may store a linked list next pointer that points to, i.e. stores an address for, a next call stub in the linked list.
- the third and fourth words 1526 and 1528 may be kept free and unused.
- the instruction cache manager determines whether the evicted cache line is the entry of a function. This determination may be done based on a tag placed on the cache directory when the cache line is loaded due to a function call or a separate table of function entry cache lines may be maintained, for example. Other ways of determining whether a cache line is an entry to a function may be used without departing from the spirit and scope of the illustrative embodiments.
- the cache line has additional information, before or after the actual code, that records the start of the doubly linked list of call sites.
- This additional information may be generated by the compiler and may be maintained by the instruction cache runtime system.
- the instruction cache manager may process the doubly linked list and each call site is “fixed” by restoring the target of the original call or branch instruction to point to the original target address rather than the call stub. This can be achieved by replacing the branch or call instruction with the copy of the original branch or call instruction stored in the fourth word 1518 of the first quadword 1510 in the call stub 1500 or the fourth word 1040 in the branch stub 1000 in FIG. 10 . Since the information for performing this fix is stored in the call stub 1500 or branch stub 1000 this fix is made simple to implement by changing the binary code in the instruction cache to replace the branch instruction or call instruction.
- the instruction cache manager may perform additional functionality for maintaining the doubly linked call site list. Whenever a cache line is evicted, the instruction cache manager processes the doubly linked call site list for the evicted cache line and checks whether any of the call sites is in the doubly linked call site list. If so, the call site has to be removed from the linked list otherwise, after eviction of the cache line, the doubly linked call site list may become corrupted. For example, the next pointer in the previous call stub maybe changed to point to the next pointer in the current call stub and the previous pointer in the next call stub may be changed to point to the previous call stub of the current call stub, thereby eliminating the current call stub from the linked list.
- this doubly linked call site list mechanism an arbitrary number of call sites calling a callee function can be handled with undoing rewriting of call or branch instructions when the callee function is evicted.
- FIG. 16 is a flowchart outlining an example operation of an instruction cache manager when handling the eviction of a cache line in accordance with one illustrative embodiment.
- the operation starts with the eviction of a cache line (step 1610 ).
- a determination is made as to whether the cache line is an entry to a function (step 1620 ). If so, then a doubly linked call site list associated with the function is processed using the call stub of the function and any other call stubs linked to directly or indirectly by the call stub (step 1630 ). Call sites in the doubly linked call site list are fixed by restoring the target address from the call stubs corresponding to the call sites (step 1640 ).
- each call site inside the evicted block is checked (step 1650 ) to determine if the call site is present in the doubly linked call site list as the doubly linked call site list is processed (step 1660 ). If the call site is in the doubly linked call site list, then the call site is removed from the doubly linked call site list (step 1670 ). The operation then terminates.
- the mechanisms of the illustrative embodiments may extend these branch stubs to call stubs that include pointers for a doubly linked list. These pointers may be used to maintain a doubly linked call site list that can be used during cache line eviction to determine which call sites need to be “fixed” by restoring the target addresses originally referenced in the call site branch or call instructions.
- Mechanisms for maintaining the doubly linked call site list are also provided. These mechanisms make eviction of cache lines with rewritten call site branch instructions or call instructions possible without corrupting the rewritten code.
- the illustrative embodiments may, for direct branches or calls to a target code block, where each code block is stored in its own cache line, further record a list of source code blocks that branch to or call the code in the target code block. Since the compiler has a complete view of the functions/procedures in the code, for each code block, the compiler knows the exact list of source code blocks that could directly branch to this target code block at runtime. The compiler just needs to record this information in the target code block so that it can be used by the instruction cache runtime system. With the mechanisms of the illustrative embodiments, the information regarding the list of source code blocks is recorded at the end of the target code block after all of the created branch stubs and call stubs.
- FIG. 17 is an example diagram illustrating one illustrative embodiment of a source code block listing quad word.
- a first word 1710 of this quad word 1700 contains the number of source code blocks that could branch to the current code block at runtime.
- a second word 1720 of the quad word contains the number of branch stubs this current code block has.
- a third word 1730 of the quad word contains a number of call stubs this current code block has.
- a fourth word 1740 of the quad word contains the start address of the branch stubs and call stubs in the current code block.
- the locations, i.e. addresses, of the source code blocks 1750 are laid out just before the last quad word so that the instruction cache runtime system knows where to find them at runtime.
- the instruction cache manager needs to fix all the rewritten source code blocks with a target code block that is in the evicted cache line.
- the instruction cache manager in the instruction cache runtime system first fetches the last quad word of the evicted cache line, which will also be the last quadword of the code block since each code block is loaded into its own cache line. From the first word 1710 of the quad word 1700 , the instruction cache manager knows how many source code block address have been encoded in the evicted cache line and where the list of addresses start. The instruction cache manager processes the potential source code blocks one by one. For each source code block, the instruction cache manager locates the source code block based on the source code block address encoded in the evicted cache line.
- the instruction cache manager fetches the last quad word of that source block and examines the second word 1720 and fourth word 1740 of the quad word 1700 .
- the second word 1720 records the number of branch stubs in the source code block.
- the fourth word 1740 records the start address of the branch stubs.
- the instruction cache manager may examine each branch stub and check whether the branch stub is the one branching to the evicted cache line. Eventually, the instruction cache manager will find the branch stub that branches to the evicted cache line.
- the instruction cache manager copies the fourth word of the branch stub, i.e. word 1040 in FIG. 10 , and replaces the rewritten branch instruction with the copy of the original branch instruction (prior to rewriting) stored in the fourth word 1040 .
- the branch instruction is restored and does not directly branch to the evicted cache line, thereby eliminating the possibility of a direct branch to a wrong target block.
- the restored branch instruction will operate in the same manner as discussed above with regard to branching to the instruction cache manager to determine if the target block is in the instruction cache or not and bringing the required block of code into the instruction cache if it is not already present in the instruction cache.
- FIG. 18 is a flowchart outlining an example operation of a compiler when analyzing original code and inserting a list of possible source code blocks targeting a current code block in accordance with one illustrative embodiment.
- the compiler identifies possible source blocks that may target the next block of code (step 1810 ).
- the addresses of the possible source code blocks are stored in a portion of the current code block after any branch stubs and/or call stubs created by the compiler (step 1820 ).
- the compiler stores a number of the source code blocks in a last portion of the current code block, e.g., the last quad word of the current code block (step 1830 ).
- the compiler further stores a number of call stubs in the last portion of the current code block (step 1840 ).
- the compiler further stores the start address of branch and call stubs in the current code block in this last portion of the current code block (step 1850 ).
- a determination is made as to whether this is the last code block to process or not (step 1860 ). If not, the operation returns to step 1810 . Otherwise, the operation terminates.
- FIG. 19 is a flowchart outlining an example operation of the instruction cache manager in accordance with one illustrative embodiment, with regard to handling eviction of a cache line with direct branches to the evicted cache line.
- the operation starts with determining that a cache line needs to be evicted (step 1910 ).
- the instruction cache manager fetches the last quad word of the evicted cache line (step 1920 ). From the first word of the quad word, the instruction cache manager determines how many source code block address have been encoded in the evicted cache line and where the list of addresses start (step 1930 ).
- the instruction cache manager processes a next potential source code block (step 1940 ). For the next source code block, the instruction cache manager locates the source code block based on the source code block address encoded in the evicted cache line (step 1950 ).
- the instruction cache manager fetches the last quad word of that source block and examines the number of branch stubs and start address of the branch stubs in the last quad word (step 1960 ).
- the instruction cache manager examines each branch stub and checks whether the branch stub branches to the evicted cache line (step 1970 ).
- the instruction cache manager then fixes the rewritten branch instruction corresponding to a branch stub that branches to the evicted cache line, by copying the copy of the original branch instruction from the branch stub and replacing the rewritten branch instruction with the copy of the original branch instruction (step 1980 ). The operation then terminates.
- conflict misses sometimes are a problem to the performance of the system.
- a conflict miss is a cache miss due to the replacement policy used by the software cache.
- a code block can be only put, or “mapped,” into one predefined cache line. Obviously, some code blocks may be mapped into the same cache line. If they are used repeated, only one of them can be kept in the cache even if there are many other unused cache lines. As a result, the cache manager has to load and evict these cache blocks repeatedly. Such cache misses are referred to as conflict misses.
- the illustrative embodiments may further provide a compiler mechanism that is able to collect and process all the objects, e.g., object files, or .o files, that together make up the executable code of a program, compiled by the compiler that utilize direct target jump optimizations such as those described above.
- the compiler builds a whole program call graph that lays out the objects and which objects call which other objects, as is generally known in the art.
- the compiler then partitions the call graph to minimize inter-partition transitions based on the instruction cache size, the size of each function, and the affinity among functions.
- the illustrative embodiments weights the call graph by weighting the nodes in the call graph according to code size, and weights the edges of the call graph according to a number of calls between the particular objects at the ends of the edge.
- a maximally weighted edge in unprocessed edges of the call graph is selected and a determination is made as to whether the weights of the nodes associated with the selected edge are less than a cache line size. If so, then the nodes are merged into a new node with the weights being updated appropriately. If an edge having a maximum weight among unprocessed edges cannot be found, any remaining procedures are places in one node together in one cache line. In this way, the compiler tries to put high affinity functions into the same partition to reduce conflict misses.
- call graph partitioning one “compilation unit” is created for each call graph partition. That is, after the call graph is partitioned into several sub-graphs, each of the sub-graphs, along with its procedures, is associated with a compilation unit for the compiler to operate on.
- the compiler takes one compilation unit, or partition, as input and lays out the code in it starting at the beginning of the instruction cache address space.
- the functions inside one call graph partition normally will not evict each other, as long as the code size for this call graph partition is smaller than the total instruction cache size.
- the link-time optimizer first builds a global call graph in a mariner generally known in the art.
- Each node in the global call graph is weighted according to the corresponding size of the code represented by the node in the global call graph.
- Each call graph edge is weighted according to a number of calls between the nodes associated with the edge. This information may all be determined statically by the compiler at compile time by analyzing the original code and determining the size of the portions of code in the compiled code that correspond to the nodes in the global call graph and determining an estimate of the number of calls anticipated between nodes, such as based on iterations in loops referencing portions of code, or the like.
- the weights may be determined through static program analysis or by profiling, for example, and the result may be a weighted call graph that may be the basis for the partitioning mechanisms.
- weights may be used without departing from the spirit and scope of the illustrative embodiments.
- FIG. 20 is a flowchart outlining an example operation for performing code optimization using a partitioned call graph in accordance with one illustrative embodiment.
- the operation starts by building a weighted call graph (step 2010 ).
- the building of the weighted call graph starts by building a global call graph and then applying weights to the nodes and edges of the global call graph.
- the weights of nodes may be determined according to the code size, such as in bytes, associated with the nodes.
- the weights of edges may be determined based on an estimate of the number of calls between nodes of the particular edge. These weights are applied to the nodes and edges of the global call graph to thereby generate a weighted call graph.
- a maximally weighted edge, in unprocessed edges of the call graph, is selected (step 2020 ). Assume for purposes of description that the selected edge is e and the nodes of the selected edge are v 1 and v 2 . A determination is made as to whether such a maximally weighted edge can be found or not (step 2030 ). If not, any remaining procedures/functions are placed in the same node together in one cache line (step 2040 ) and the operation ends.
- the selected edge e i.e. edge (v 1 , v 2 )
- the operation returns to step 2020 to select a next maximally weighted edge from the remaining unprocessed edges. If the sum of the weights of the nodes of the selected edge is greater than a cache line size, then the edge is marked as having been processed (step 2080 ) and the operation returns to step 2020 .
- the result is a partitioned call graph in which nodes are merged into sizes corresponding to the cache line size of the instruction cache based on their affinity.
- the resulting code is configured according to this partitioned call graph such that when the code is brought into the instruction cache the code fits within the cache lines of the instruction cache will minimal cross-cache line references. This greatly reduces conflict misses because of a cache line not being present in the instruction cache.
- the illustrative embodiments provide mechanisms for directly jumping to branch targets in an instruction cache when possible through compiler implemented and runtime implemented rewriting of branch instructions and function calls.
- the illustrative embodiments further provide mechanisms for handling eviction of cache lines that correspond to rewritten branch instructions and function calls so as to avoid any jumps to incorrect targets in the instruction cache.
- the illustrative embodiments provide mechanisms for reducing instruction cache conflict misses by partitioning the code based on instruction cache size, function size, and affinity amongst the functions. All of these mechanisms work together to improve the performance of a system's execution of the code by reducing latency encountered by the overhead of having to redirect execution to an instruction cache manager for every branch or function call.
- the illustrative embodiments may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment containing both hardware and software elements.
- the mechanisms of the illustrative embodiments are implemented in software or program code, which includes but is not limited to firmware, resident software, microcode, etc.
- a data processing system suitable for storing and/or executing program code will include at least one processor coupled directly or indirectly to memory elements through a system bus.
- the memory elements can include local memory employed during actual execution of the program code, bulk storage, and cache memories which provide temporary storage of at least some program code in order to reduce the number of times code must be retrieved from bulk storage during execution.
- I/O devices can be coupled to the system either directly or through intervening I/O controllers.
- Network adapters may also be coupled to the system to enable the data processing system to become coupled to other data processing systems or remote printers or storage devices through intervening private or public networks. Modems, cable modems and Ethernet cards are just a few of the currently available types of network adapters.
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Software Systems (AREA)
- General Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Memory System Of A Hierarchy Structure (AREA)
Abstract
Mechanisms are provided for evicting cache lines from an instruction cache of the data processing system. The mechanisms store, for a portion of code in a current cache line, a linked list of call sites that directly or indirectly target the portion of code in the current cache line. A determination is made as to whether the current cache line is to be evicted from the instruction cache. The linked list of call sites is processed to identify one or more rewritten branch instructions having associated branch stubs, that either directly or indirectly target the portion of code in the current cache line. In addition, the one or more rewritten branch instructions are rewritten to restore the one or more rewritten branch instructions to an original state based on information in the associated branch stubs.
Description
- The present application relates generally to an improved data processing apparatus and method and more specifically to mechanisms for dynamically rewriting branch instructions in response to cache line eviction.
- Many modern computing devices utilize a multiprocessor architecture in which multiple processors are provided to increase the computation power of the computing device. One example of a modern multiprocessor architecture is the Cell Broadband Engine (CBE) available from International Business Machines Corporation or Armonk, N.Y. With the CBE, a primary control processor, referred to as the PPE, is provided along with a plurality of controlled processors, referred to as synergistic processing elements (SPEs). Each SPE has a local memory, or local store, into which instructions and data are copied so that the SPE may execute instructions in the local store on data brought into the location store from main memory. Thus, the local store serves as both an instruction and data cache for the SPE. Other multiprocessor architectures utilize similar configurations in which the processors may have a local instruction cache and data cache into which data and instructions are brought before executing on the processor or having the processor operate on the data.
- Typically, the local store, or cache, of a modern day multiprocessor architecture is designed to be much smaller in storage size than the main memory. Thus, executing code larger than the processor's local store or cache size requires a strategy for swapping pieces of code, or code segments, into the local store or cache before use. In some cases, a code segment may include branch instructions whose target instruction is located in a different code segment that may not be currently present in the local store or cache. This would require a strategy for bringing in the code segment corresponding to the target instruction from main memory.
- In one illustrative embodiment, a method, in a data processing system, is provided for evicting cache lines from an instruction cache of the data processing system. The method comprises storing, by a processor of the data processing system, for a portion of code in a current cache line, a linked list of call sites that directly or indirectly target the portion of code in the current cache line. The method further comprises determining, by the processor, that the current cache line is to be evicted from the instruction cache. Moreover, the method comprises processing, by the processor, the linked list of call sites to identify one or more rewritten branch instructions having associated branch stubs, that either directly or indirectly target the portion of code in the current cache line. In addition, the method comprises rewriting, by the processor, the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state based on information in the associated branch stubs.
- In other illustrative embodiments, a computer program product comprising a computer useable or readable medium having a computer readable program is provided. The computer readable program, when executed on a computing device, causes the computing device to perform various ones, and combinations of, the operations outlined above with regard to the method illustrative embodiment.
- In yet another illustrative embodiment, a system/apparatus is provided. The system/apparatus may comprise one or more processors and a memory coupled to the one or more processors. The memory may comprise instructions which, when executed by the one or more processors, cause the one or more processors to perform various ones, and combinations of, the operations outlined above with regard to the method illustrative embodiment.
- These and other features and advantages of the present invention will be described in, or will become apparent to those of ordinary skill in the art in view of, the following detailed description of the example embodiments of the present invention.
- The invention, as well as a preferred mode of use and further objectives and advantages thereof, will best be understood by reference to the following detailed description of illustrative embodiments when read in conjunction with the accompanying drawings, wherein:
-
FIG. 1 is an example embodiment of an information handling system capable of implementing aspects of the illustrative embodiments set forth herein; -
FIG. 2 is a diagram showing embodiments of a software controlled instruction cache (icache) manager translating a target instruction space address to other types of instruction addresses; -
FIG. 3 is a diagram showing a cache line that includes direct branch instructions and corresponding branch descriptors in accordance with one illustrative embodiment; -
FIG. 4 is a flowchart showing steps taken in compiling various branch instruction types in accordance with one illustrative embodiment; -
FIG. 5 is a flowchart showing steps taken in executing a direct branch instruction in a runtime environment in accordance with one illustrative embodiment; -
FIG. 6 is a flowchart showing steps taken in executing an indirect branch instruction in a runtime environment in accordance with one illustrative embodiment; -
FIG. 7 is a flowchart showing steps taken in executing a function return instruction in a runtime environment in accordance with one illustrative embodiment; -
FIG. 8A shows a target instruction space address translated into a target local store address in accordance with one illustrative embodiment; -
FIG. 8B is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target instruction tag (ITAG) in accordance with one illustrative embodiment; -
FIG. 8C is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target backing store address in accordance with one illustrative embodiment; -
FIG. 9 illustrates information handling system, which is another embodiment of a simplified example of a computer system capable of performing the computing operations described herein; -
FIG. 10 is an example diagram of a branch stub in accordance with one illustrative embodiment; -
FIG. 11 is an example diagram illustrating a rewriting of a link register in accordance with one illustrative embodiment; -
FIG. 12 is an example diagram illustrating an overall operation of one illustrative embodiment for rewriting branch instructions using branch stubs; -
FIG. 13 is a flowchart outlining an example operation of a compiler for rewriting branch instructions in accordance with one illustrative embodiment; -
FIG. 14 is a flowchart outlining an example operation or an instruction cache runtime system for performing dynamic rewriting of branch instructions in accordance with one illustrative embodiment; -
FIG. 15 is an example diagram illustrating a call stub in accordance with one illustrative embodiment; -
FIG. 16 is a flowchart outlining an example operation of an instruction cache manager when handling the eviction of a cache line in accordance with one illustrative embodiment; -
FIG. 17 is an example diagram illustrating one illustrative embodiment of a source code block listing quad word; -
FIG. 18 is a flowchart outlining an example operation of a compiler when analyzing original code and inserting a list of possible source code blocks targeting a current code block in accordance with one illustrative embodiment; -
FIG. 19 is a flowchart outlining an example operation of the instruction cache runtime system in accordance with one illustrative embodiment, with regard to handling eviction of a cache line; and -
FIG. 20 is a flowchart outlining an example operation for performing code optimization using a partitioned call graph in accordance with one illustrative embodiment. - The illustrative embodiments provide a mechanism for statically and dynamically rewriting branch instructions so that they may be more optimally executed in view of the limited size of local stores or caches of a processor. In particular, the mechanisms of the illustrative embodiments provide functionality for rewriting code, both statically by a compiler and dynamically by an instruction cache runtime system, to thereby generate and utilize branch stubs in the code for branch instructions. The branch stubs may be used as a basis for holding information about the branch instruction for use in determining whether a jump directly to a target of the branch instruction in the instruction cache may be possible or not. Examples of branch instructions include function calls, conditional branch instructions, unconditional branch instructions, function returns, and the like, as is generally known in the art.
- In addition, the mechanisms of the illustrative embodiments provide functionality for performing dynamic rewriting of branches based on whether or not the possible targets of the branches are known or not. The rewriting of the branch instructions allows the code to directly jump to target code in the instruction cache when possible rather than having to go through an instruction cache manager to determine if the target code is present in the instruction cache or not. In general, when the target code is loaded into the instruction cache, the branch instruction is rewritten as a jump to the location of the target code in the instruction cache. When the target code is evicted from the instruction cache, the branch instruction is restored since it cannot jump to the target code directly but must trigger a software instruction cache mechanism to handle the jump to the target code.
- As will be appreciated by one skilled in the art, the present invention may be embodied as a system, method, or computer program product. Accordingly, aspects of the present invention may take the form of an entirely hardware embodiment, an entirely software embodiment (including firmware, resident software, micro-code, etc.) or an embodiment combining software and hardware aspects that may all generally be referred to herein as a “circuit,” “module” or “system.” Furthermore, aspects of the present invention may take the form of a computer program product embodied in any one or more computer readable medium(s) having computer usable program code embodied thereon.
- Any combination of one or more computer readable medium(s) may be utilized. The computer readable medium may be a computer readable signal medium or a computer readable storage medium. A computer readable storage medium may be, for example, but not limited to, an electronic, magnetic, optical, electromagnetic, infrared, or semiconductor system, apparatus, device, or any suitable combination of the foregoing. More specific examples (a non-exhaustive list) of the computer readable medium would include the following: an electrical connection having one or more wires, a portable computer diskette, a hard disk, a random access memory (RAM), a read-only memory (ROM), an erasable programmable read-only memory (EPROM or Flash memory), an optical fiber, a portable compact disc read-only memory (CDROM), an optical storage device, a magnetic storage device, or any suitable combination of the foregoing. In the context of this document, a computer readable storage medium may be any tangible medium that can contain or store a program for use by or in connection with an instruction execution system, apparatus, or device.
- A computer readable signal medium may include a propagated data signal with computer readable program code embodied therein, for example, in a baseband or as part of a carrier wave. Such a propagated signal may take any of a variety of forms, including, but not limited to, electro-magnetic, optical, or any suitable combination thereof. A computer readable signal medium may be any computer readable medium that is not a computer readable storage medium and that can communicate, propagate, or transport a program for use by or in connection with an instruction execution system, apparatus, or device.
- Computer code embodied on a computer readable medium may be transmitted using any appropriate medium, including but not limited to wireless, wireline, optical fiber cable, radio frequency (RF), etc., or any suitable combination thereof.
- Computer program code for carrying out operations for aspects of the present invention may be written in any combination of one or more programming languages, including an object oriented programming language such as Java™, Smalltalk™, C++, or the like, and conventional procedural programming languages, such as the “C” programming language or similar programming languages. The program code may execute entirely on the user's computer, partly on the user's computer, as a stand-alone software package, partly on the user's computer and partly on a remote computer, or entirely on the remote computer or server. In the latter scenario, the remote computer may be connected to the user's computer through any type of network, including a local area network (LAN) or a wide area network (WAN), or the connection may be made to an external computer (for example, through the Internet using an Internet Service Provider).
- Aspects of the present invention are described below with reference to flowchart illustrations and/or block diagrams of methods, apparatus (systems) and computer program products according to the illustrative embodiments of the invention. It will be understood that each block of the flowchart illustrations and/or block diagrams, and combinations of blocks in the flowchart illustrations and/or block diagrams, can be implemented by computer program instructions. These computer program instructions may be provided to a processor of a general purpose computer, special purpose computer, or other programmable data processing apparatus to produce a machine, such that the instructions, which execute via the processor of the computer or other programmable data processing apparatus, create means for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
- These computer program instructions may also be stored in a computer readable medium that can direct a computer, other programmable data processing apparatus, or other devices to function in a particular manner, such that the instructions stored in the computer readable medium produce an article of manufacture including instructions that implement the function/act specified in the flowchart and/or block diagram block or blocks.
- The computer program instructions may also be loaded onto a computer, other programmable data processing apparatus, or other devices to cause a series of operational steps to be performed on the computer, other programmable apparatus, or other devices to produce a computer implemented process such that the instructions which execute on the computer or other programmable apparatus provide processes for implementing the functions/acts specified in the flowchart and/or block diagram block or blocks.
- The flowchart and block diagrams in the figures illustrate the architecture, functionality, and operation of possible implementations of systems, methods and computer program products according to various embodiments of the present invention. In this regard, each block in the flowchart or block diagrams may represent a module, segment, or portion of code, which comprises one or more executable instructions for implementing the specified logical function(s). It should also be noted that, in some alternative implementations, the functions noted in the block may occur out of the order noted in the figures. For example, two blocks shown in succession may, in fact, be executed substantially concurrently, or the blocks may sometimes be executed in the reverse order, depending upon the functionality involved. It will also be noted that each block of the block diagrams and/or flowchart illustration, and combinations of blocks in the block diagrams and/or flowchart illustration, can be implemented by special purpose hardware-based systems that perform the specified functions or acts, or combinations of special purpose hardware and computer instructions.
-
FIG. 1 is an example embodiment of an information handling system capable of implementing aspects of the illustrative embodiments set forth herein. The example information handling system shown inFIG. 1 is an example of a Cell Broadband Engine (CBE) architecture available from International Business Machines Corporation of Armonk, N.Y. It should be appreciated, however, that the present invention is not limited to use with the CBE and other information handling system architectures, configurations, and the like, may be used without departing from the spirit and scope of the illustrative embodiments. - Processor element architecture (100) includes multiple heterogeneous processors that share a common memory and a common bus. Processor element architecture (PEA) 100 sends and receives information to/from external devices through
input output 190, and distributes the information to controlplane 110 anddata plane 140 usingprocessor element bus 180.Control plane 110 managesPEA 100 and distributes work todata plane 140. -
Control plane 110 includesprocessing unit 120, which runs operating system (OS) 125. For example, processingunit 120 may be a Power PC core that is embedded inPEA 100 andOS 125 may be a Linux operating system.Processing unit 120 manages a common memory map table forPEA 100. The memory map table corresponds to memory locations included inPEA 100, such asL2 memory 130 as well as non-private memory included indata plane 140. -
Data plane 140 includes Synergistic Processing Elements (SPE) 150, 160, and 170. Each SPE processes data information and each SPE may have different instruction sets. For example,PEA 100 may be used in a wireless communications system and each SPE may be responsible for separate processing tasks, such as modulation, chip rate processing, encoding, and network interfacing. In another example, each SPE may have identical instruction sets and may be used in parallel to perform operations benefiting from parallel processes. Each SPE includes a synergistic processing unit (SPUs local stores local stores FIG. 2 and corresponding text for further details). And, each cache manager within each SPU manages their corresponding cache and retrieves data frombacking store 135 accordingly. - While
FIG. 1 shows one information handling system, an information handling system may take many forms. For example, an information handling system may take the form of a desktop, server, portable, laptop, notebook, or other form factor computer or data processing system. In addition, an information handling system may take other form factors such as a personal digital assistant (PDA), a gaming device, ATM machine, a portable telephone device, a communication device or other devices that include a processor and memory (seeFIG. 9 and corresponding text for another embodiment of an information handling system for performing compilation functions as described herein). -
FIG. 2 is a diagram showing embodiments of an instruction cache (icache) manager translating a target instruction space address to other types of instruction addresses.Local store 200 resides within a synergistic processing unit (e.g., SPU's 155, 165, or 175) and includes instruction cache (icache)manager 220, instruction tag (ITAG)directory 225, andinstruction cache 230. - In order to effectively move instructions from
backing store 135 to icache 230,icache manager 220 requires an effective address withinbacking store 135 that corresponds to the location of the target instruction (target backing store address 280), as well as a local storage address withinicache 230 to store the instruction (target local store address 260). In addition,icache manager 220 requires an instruction tag that corresponds to the target instruction in order to utilizeITAG directory 225 and determine a cache hit or a cache miss (target ITAG 270). As discussed herein,icache manager 220 uses an instruction's “instruction space address” (target instruction space address 255) to compute an instruction's target backing store address, target local store address, and target ITAG. The instruction space address is an address given to an instruction at link/load time based upon the location of the instruction in a program (program 250). - When icache
manager 220 is requested (by an application thread) to branch to a particular target instruction,icache manager 220 determines whether the target instruction already resides inicache 230 by checking whether the target instruction's corresponding instruction tag (ITAG) is located in ITAG directory 225 (target ITAG 270). In order to generatetarget ITAG 270,icache manager 220 usestarget ITAG subroutine 265, which generatestarget ITAG 270 using targetinstruction space address 255 and a tag array mask (seeFIG. 8B and corresponding text for further details). - When icache
manager 200 needs to load the target instruction frombacking store 135 intoicache 230,icache manager 220 computes the location of the target instruction in backing store 135 (target backing store address 280) as well as the location to store the target instruction in icache 230 (target local store address 260).Icache manager 220 utilizes targetinstruction space address 255 to generate these addresses as discussed below. - In the example shown in
FIG. 2 , targetinstruction space address 255 is 32 bits. Targetinstruction space address 255's 18 least significant bits, however, is targetlocal store address 260 becauselocal store 200 is 256 KB in size and only requires 18 bits for addressing intoicache 230. As such,icache manager 220 masks off targetinstruction space address 255's 14 most significant bits in order to generate target local store address 260 (seeFIG. 8A and corresponding text for further details). As those skilled in the art can appreciate, more or less bits may be required for targetlocal store address 260 based upon the size oflocal store 200. - In order to identify the location in
backing store 135 to retrieve the instruction (target backing store address 280),icache manager 220 usesbacking store subroutine 275, which generates an offset using targetinstruction space address 255 and an icache base address, and uses the offset and a mask to generate target backing store address 280 (seeFIG. 8C and corresponding text for further details). In turn,icache manager 220 retrieves the target instruction from targetbacking store address 280; stores the target instruction in targetlocal store address 260; andupdates ITAG directory 225 accordingly. -
FIG. 3 is a diagram showing a cache line that includes direct branch instructions and corresponding branch descriptors in accordance with one illustrative embodiment. A “direct” branch instruction is an instruction in which the address of a next instruction to execute, i.e. the target of the branch instruction, is explicitly specified. An “indirect” branch instruction is one in which the address of the next instruction to execute is not explicitly specified but instead the argument of the branch instruction specifies where the address is located. Thus, an example of an indirect branch instruction could be of the type “jump indirect on the r1 register,” which means that the next instruction to be executed would be at the address whose value is stored in register r1. It should be noted that indirect branch instructions can also depend on the value of a memory location, rather than a specified register. Thus, with indirect branch instructions, the address of the next instruction to execute is not known at compile time, but is only known once the branch instruction is executed, i.e. at runtime. With direct branch instructions, the target of the branch instruction is known at compile time. - One aspect of the illustrative embodiment is that, during source compilation, a compiler adds a “branch descriptor” into a program for each direct branch instruction and, in turn, an icache manager loads the branch descriptors into the same instruction cache line during runtime execution.
FIG. 3 showsinstruction cache 230, which includescache line 300.Cache line 300 includes multiple instructions, some of which aredirect branch instructions Cache line 300 also includesbranch descriptors branch instructions - When an application thread executes
direct branch instruction 310,direct branch instruction 310 branches to branchdescriptor 330.Branch descriptor 330 includestrampoline branch instruction 335 and targetinstruction space address 345. A trampoline branch is an instruction that, when executed, branches to, or “bounces” toicache manager 220, thus causing a trampoline effect. Whenbranch instruction 310 branches to branchdescriptor 330,trampoline branch instruction 335 is invoked, which branches toicache manager 220 and loadspointer 340 into a link register via a branch and set link instruction, which points back tobranch descriptor 330. In turn,icache manager 220 usespointer 340 to locatebranch descriptor 330 and retrieve targetinstruction space address 345.Icache manager 220 uses targetinstruction space address 345 to generate various addresses and locate a target instruction corresponding to direct branch instruction 310 (seeFIG. 5 and corresponding text for further details). - Likewise, when the application thread executes
direct branch instruction 320, the branch instruction branches to branchdescriptor 350, which is different thanbranch descriptor 330.Branch descriptor 350 includestrampoline branch instruction 355 and targetinstruction space address 365. Targetinstruction space address 365 corresponds to a location of the target instruction forbranch instruction 320. Whenbranch instruction 320 branches to branchdescriptor 350,trampoline branch instruction 355 is invoked, which branches toicache manager 220 and loadspointer 360 into the link register via a branch and set link instruction, which points back tobranch descriptor 350. In turn,icache manager 220 usespointer 360 to locatebranch descriptor 350 and retrieve targetinstruction space address 365. -
FIG. 4 is a flowchart showing steps taken in compiling various branch instruction types in accordance with one illustrative embodiment. The illustrative embodiments described herein includes embodiments discussing code compilation/linking, and embodiments discussing code execution (e.g., runtime environment).FIG. 4 shows steps taken by a compiler (and/or linker) when the compiler encounters a branch instruction while compiling source code. - Processing commences at 400, whereupon processing retrieves an instruction from
source code 410 atstep 405. A determination is made as to whether the retrieved instruction is a branch instruction (decision 420). If the instruction is not a branch instruction,decision 420 branches to “No”branch 422 whereupon processing compiles the instruction (step 425) in a traditional manner known to those skilled in the art. - On the other hand, if the retrieved instruction is a branch instruction,
decision 420 branches to “Yes”branch 428, whereupon a determination is made as to the type of branch instruction (decision 430). If the instruction is a direct branch instruction,decision 430 branches to “Direct”branch 432 whereupon processing generates a branch descriptor that includes a trampoline branch instruction and a target instruction space address atstep 440. During runtime execution, the direct branch instruction branches to the trampoline branch instruction, which sends a pointer to the icache manager and, in turn, the icache manager retrieves the target instruction space address from the branch descriptor (seeFIGS. 3 , 5, and corresponding text for further details). Atstep 450, processing compiles the branch instruction and branch descriptor. - If the branch type is an indirect branch, however,
decision 430 branches to “Indirect”branch 438, whereupon processing generates a number of instructions (step 460) to handle the indirect branch during runtime execution. The instructions include an instruction to translate the indirect branch's target instruction space address to an instruction tag (ITAG) along with an instruction to look up the ITAG in an icache directory (icache directory 225 shown inFIG. 2 ). Processing also generates instructions in order to handle hit or miss outcomes of the lookup. For example, processing generates an instruction that translates the target instruction space address to a target local store address in order to branch to the instruction in icache if the lookup results in a cache hit, and also generates an instruction that calls the icache manager if the lookup results in a cache miss. Atstep 470, processing compiles the instructions. - A determination is made as to whether there are more instructions to process in source code 410 (decision 480). If there are more instructions to process, processing branches to “Yes”
branch 482, which loops back to retrieve and process the next instruction. This looping continues until there are no more source code instruction to process, at whichpoint decision 480 branches to “No”branch 488 whereupon processing ends at 490. -
FIG. 5 is a flowchart showing steps taken in executing a direct branch instruction in a runtime environment in accordance with one illustrative embodiment. In some of the illustrative embodiments described herein a branch descriptor is inserted into a cache line for each direct branch instruction (seeFIG. 4 and corresponding text for further details). In turn, the branch descriptor includes information to pass onto an icache manager to process the direct branch instruction. - Processing commences at 500, whereupon processing (e.g., application thread) loads a direct branch instruction at
step 505. The direct branch instruction was arranged at load time to branch to a trampoline branch instruction included in the direct branch's corresponding branch descriptor (seeFIG. 3 and corresponding text for further details). As such, atstep 510, processing branches to the trampoline branch instruction included in the corresponding branch descriptor. The trampoline branch instruction, atstep 515, branches to the icache manager and sends a branch descriptor pointer to the icache manager (e.g., stores the branch descriptor pointer in an icache link register). - Icache manager processing commences at 530, whereupon the icache manager retrieves the branch descriptor pointer from the link register at
step 535. Atstep 540, the icache manager uses the branch descriptor pointer to locate and extract the target instruction space address from the branch descriptor. The target instruction space address is an address that corresponds to the direct branch's target instruction. - At
step 545, the icache manager computes a target ITAG from the target instruction space using a tag array mask (seeFIG. 8B and corresponding text for further details). Next, the icache manager looks up the target ITAG inITAG directory 225 in order to determine whether the target instruction is located in icache 230 (step 550). - A determination is made as to whether
ITAG directory 225 includes the target ITAG (decision 560). IfITAG directory 225 includes the target ITAG (cache hit),decision 560 branches to “Yes”branch 562 whereupon the icache manager translates the target instruction space address to a target local store address atstep 564 by masking off a portion of the target instruction space address (seeFIG. 8A and corresponding text for further details). Then, atstep 565, the icache manager branches to the target instruction located at the target local store address withinicache 230; passes control back to the application thread; and ends at 570. The application thread continues program execution atstep 520, and ends at 525. - On the other hand, if
ITAG directory 225 fails to include the target ITAG (cache miss),decision 560 branches to “No”branch 568 whereupon processing computes a target backing store address from the target instruction space address using an offset and mask at step 570 (seeFIG. 8C and corresponding text for further details). The target backing store address corresponds to the location of the target instruction stored inbacking store 135. Next, the icache manager translates the target instruction space address to a target local store address atstep 575 by masking off a portion of the target instruction space address (seeFIG. 8A and corresponding text for further details). The target local store address is the location in icache 230 that the target instruction is stored. Atstep 580, the icache manager loads the target instruction frombacking store 135 intoicache 230. At this point, the icache manager branches to the target instruction located at the target local store address withinicache 230 and passes control back to the application thread (step 565), which continues program execution atstep 520. Icache manager processing ends at 570 and application thread processing ends at 525. -
FIG. 6 is a flowchart showing steps taken in executing an indirect branch instruction in a runtime environment in accordance with one illustrative embodiment. Indirect branch processing commences at 600, whereupon processing (e.g., application thread) computes a target instruction tag (ITAG) using a target instruction space address located inregister store 615 that corresponds to the indirect branch instruction's target instruction (step 610). The target instruction space address was stored inregister store 615 from a previous instruction (hence an indirect branch instruction). - Processing looks up the target ITAG in
ITAG directory 225 atstep 620, and a determination is made as to whether the lookup results in a cache hit or a cache miss (decision 630). If a cache miss occurs,decision 630 branches to “No”branch 632, whereupon processing callsicache manager 220 to move the target instruction frombacking store 135 into icache 230 (step 640).Icache manager 220, in turn, translates the target instruction space address to a target backing store address and a target local store address in order to move the target instruction frombacking store 135 into icache 230 (seeFIGS. 5 , 8A, 8C, and corresponding text for further details). On the other hand, if a cache hit occurs,decision 630 branches to “Yes”branch 638, bypassing icache manager steps. - At
step 650, processing translates the target instruction space address to the target local store address and, atstep 660, processing retrieves the target instruction fromicache 230 at the target local store address. Processing continues program execution atstep 670, and ends at 680. -
FIG. 7 is a flowchart showing steps taken in executing a function return instruction in a runtime environment in accordance with one illustrative embodiment. Processing commences at 700, whereupon processing executes a function return instruction and, in doing so, creates a target local store address (icache address) as the return value, which is stored in a link register included in register store 720 (step 705). - While waiting for the instruction to finish, a determination is made as to whether the target instruction is being evicted from the icache (decision 710). If the target instruction address is being evicted from the icache,
decision 710 branches to “Yes”branch 712, whereupon processing translates the target local store address to a target instruction space address and stores the target instruction space address in the link register atstep 715. The target instruction space address is stored in the link register such that when the function return completes, processing realizes that the target instruction is no longer inicache 230 and should call the icache manager to move the target instruction frombacking store 135 into icache 230 (discussed below). On the other hand, if the target instruction is not evicted from the icache,decision 710 branches to “No”branch 718 bypassing translation steps. - A determination is made as to whether the function return has completed (decision 730). If the function return has not yet completed,
decision 730 branches to “No”branch 732, which loops back to monitor function return completion and target instruction eviction. This looping continues until the function return completes, at whichpoint decision 730 branches to “Yes”branch 738 whereupon processing retrieves the link register value from register store 720 (step 740). - A determination is made as to whether the link register value is a target local store address (TLSA) or a target instruction space address (TISA) (decision 750). If the link register value is a target instruction space address,
decision 750 branches to “TISA”branch 752, whereupon processing callsicache manager 220 to move the target instruction frombacking store 135 into icache 230 (step 760).Icache manager 220, in turn, translates the target instruction space address to a target backing store address and a target local store address in order to move the target instruction frombacking store 135 into icache 230 (seeFIGS. 5 , 8A, 8C, and corresponding text for further details). Processing, atstep 765, converts the target instruction space address to the target local store address. On the other hand, if the link register value is a target local store address (e.g., target instruction was not evicted),decision 750 branches to “TLSA”branch 758 bypassing icache manager calling steps. - At
step 770, processing branches to the target address at the target local store address and continues program execution atstep 780. Processing ends at 790. -
FIG. 8A shows a target instruction space address translated into a target local store address in accordance with one illustrative embodiment. The target instruction space address discussed herein includes 32 bits and the target local store address discussed herein includes 18 bits. As those skilled in the art can appreciate, more or less bits may be used for the target instruction space address and/or the target local store address. The target instruction space address includes the target local store address in its 18 least significant bits (seeFIG. 2 and corresponding text for further details). As such, in order to translate the target instruction space address to the target local store address, the icache manager masks off targetinstruction space address 800's 14 most significantbits using mask 810, which leaves 18 least significant bits as targetlocal store address 820. -
FIG. 8B is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target instruction tag (ITAG) in accordance with one illustrative embodiment. Icache manager processing commences at 830, whereupon the icache manager generates an instruction tag index using the target instruction space effective address and a tag array mask (step 840). In one embodiment, a tag array is an array of structures with one element per cache line. Each element includes an instruction space address of a corresponding line that is currently resident. As such, in this embodiment: -
tag array mask=Number of cache lines−1 -
ITAG index=(TISA/linesize)&tag mask - Next, at
step 850, the icache manager generates the target instruction tag atstep 850 from the generated ITAG index, such as by using the instruction: -
Target ITAG=tag[ITAG index] - The icache manager may then use the target ITAG to look in the ITAG directory and determine whether a corresponding target instruction is located in the icache or whether the icache manager should retrieve the target instruction from backing store and load it into the icache. Processing ends at 860
-
FIG. 8C is a flowchart showing steps taken in an icache manager translating a target instruction space address to a target backing store address. Icache manager processing commences at 870, whereupon the icache manager generates an offset using the target instruction space address (TISA) and icache base address (step 880), such as with the instruction: -
offset=(TISA−icachebase) - Next, at
step 890, the icache manager generates the target backing store address (TBSA) using the generated offset and mask that preserves an index into a cache array, such as with the instruction: -
TBSA=(offset&mask that preserves idx into cache array)|(offset>>(18−log2 icachesize)) - where “&” is a bitwise AND operator; “|” is a bitwise OR operator; and “>>” is a bitwise right shift. The icache manager may then use the target backing store address to retrieve the target instruction from backing store at the target backing store address, and load the target instruction into the icache (see
FIGS. 5-7 and corresponding text for further details). Processing ends at 895. -
FIG. 9 illustratesinformation handling system 900, which is another embodiment of a simplified example of a computer system capable of performing the computing operations described herein.Information handling system 900 includes one ormore processors 910 coupled toprocessor interface bus 912.Processor interface bus 912 connectsprocessors 910 toNorthbridge 915, which is also known as the Memory Controller Hub (MCH).Northbridge 915 connects tosystem memory 920 and provides a means for processor(s) 910 to access the system memory.Graphics controller 925 also connects toNorthbridge 915. In one embodiment,PCI Express bus 918 connectsNorthbridge 915 tographics controller 925.Graphics controller 925 connects to displaydevice 930, such as a computer monitor. -
Northbridge 915 andSouthbridge 935 connect to each other usingbus 919. In one embodiment, the bus is a Direct Media Interface (DMI) bus that transfers data at high speeds in each direction betweenNorthbridge 915 andSouthbridge 935. In another embodiment, a Peripheral Component Interconnect (PCI) bus connects the Northbridge and the Southbridge.Southbridge 935, also known as the I/O Controller Hub (ICH) is a chip that generally implements capabilities that operate at slower speeds than the capabilities provided by the Northbridge.Southbridge 935 typically provides various busses used to connect various components. These busses include, for example, PCI and PCI Express busses, an ISA bus, a System Management Bus (SMBus or SMB), and/or a Low Pin Count (LPC) bus. The LPC bus often connects low-bandwidth devices, such asboot ROM 996 and “legacy” I/O devices (using a “super I/O” chip). The “legacy” I/O devices (998) can include, for example, serial and parallel ports, keyboard, mouse, and/or a floppy disk controller. The LPC bus also connectsSouthbridge 935 to Trusted Platform Module (TPM) 995. Other components often included inSouthbridge 935 include a Direct Memory Access (DMA) controller, a Programmable Interrupt Controller (PIC), and a storage device controller, which connectsSouthbridge 935 tononvolatile storage device 985, such as a hard disk drive, usingbus 984. -
ExpressCard 955 is a slot that connects hot-pluggable devices to the information handling system.ExpressCard 955 supports both PCI Express and USB connectivity as it connects toSouthbridge 935 using both the Universal Serial Bus (USB) the PCI Express bus.Southbridge 935 includesUSB Controller 940 that provides USB connectivity to devices that connect to the USB. These devices include webcam (camera) 950, infrared (IR)receiver 948, keyboard andtrackpad 944, andBluetooth device 946, which provides for wireless personal area networks (PANs).USB Controller 940 also provides USB connectivity to other miscellaneous USB connecteddevices 942, such as a mouse, removable nonvolatile storage device 945, modems, network cards, ISDN connectors, fax, printers, USB hubs, and many other types of USB connected devices. While removable nonvolatile storage device 945 is shown as a USB-connected device, removable nonvolatile storage device 945 could be connected using a different interface, such as a Firewire interface, etcetera. - Wireless Local Area Network (LAN)
device 975 connects to Southbridge 935 via the PCI orPCI Express bus 972.LAN device 975 typically implements one of the IEEE 802.11 standards of over-the-air modulation techniques that all use the same protocol to wireless communicate betweeninformation handling system 900 and another computer system or device.Optical storage device 990 connects toSouthbridge 935 using Serial ATA (SATA)bus 988. Serial ATA adapters and devices communicate over a high-speed serial link. The Serial ATA bus also connectsSouthbridge 935 to other forms of storage devices, such as hard disk drives.Audio circuitry 960, such as a sound card, connects toSouthbridge 935 viabus 958.Audio circuitry 960 also provides functionality such as audio line-in and optical digital audio inport 962, optical digital output andheadphone jack 964,internal speakers 966, andinternal microphone 968.Ethernet controller 970 connects toSouthbridge 935 using a bus, such as the PCI or PCI Express bus.Ethernet controller 970 connectsinformation handling system 900 to a computer network, such as a Local Area Network (LAN), the Internet, and other public and private computer networks. - The above mechanisms provide the ability for code to jump, through the use of a trampoline instruction, to the instruction cache manager of the instruction cache to check whether the target code for a branch instruction is in the instruction cache or not. If not, the instruction cache manager will bring the target code into the cache. The instruction cache manager will then cause the execution to jump to where the target code is present in the instruction cache. This allows code segments to be brought from a backing store, or main memory, of the system into a local store or instruction cache associated with a processor. This mechanism may be replicated with each processor of a multi-processor system such that each processor may manage the moving of instructions into and out of the local stores or instruction caches associated with the individual processors.
- While this mechanism generally works well, further performance enhancement and optimization may be achieved by providing mechanisms to avoid the overhead of redirecting execution to the instruction cache manager, having the instruction cache manager perform its checks and operations, and then returning to the original code. The mechanisms of the illustrative embodiments provide further functionality to dynamically rewrite branch instructions utilizing branch stubs, i.e. small portions of code that stand in for, or replace, another programming function. The branch stubs maintain information about branch instructions and serve as a mechanism for jumping directly to target code in the instruction cache when possible. The branch stub code serves a similar purpose as the trampoline code with the exception that the overhead of the instruction cache manager is avoided when the target code exists within the instruction cache. In the case that the target code is not in the instruction cache, the execution of the code may be redirected to the instruction cache manager as previously described above. These mechanisms may be implemented in an information handling system, such as described above with reference to
FIG. 9 , or other type of information/data processing system. - The branch stubs are introduced into the code, such as at the end of a code block (a section of code grouped together, typically having a size that is able to fit into one or more cache lines of an instruction cache), by a compiler at compile time and may be dynamically updated at runtime by an instruction cache runtime system. The instruction cache runtime system is the collection of software designed to support the execution of computer programs, which may include subroutines and libraries for common operations, implementation of programming language commands, type checking, debugging, code generation and optimization, and the like. In particular, the instruction cache runtime system includes an instruction cache manager, such as that previously described above, which has been modified to make use of the additional mechanisms described in the further illustrative embodiments hereafter. The original branch instruction is rewritten by the compiler to branch to an address corresponding to the branch stub for this branch instruction and the modified branch instruction and branch stub are included in the executable code so that it can be brought into the instruction cache along with the other instructions. Again, branch instructions may be function calls, conditional branch instructions, unconditional branch instructions, or the like, and may be direct branch instructions or indirect branch instructions.
- With direct branch instructions, i.e. branch instructions for which an address of a next instruction to execute is explicitly specified in the branch instruction, the branch stubs can be used to store a branch offset, i.e. an offset from the address of the branch instruction, that is used to locate the original target address of the next instruction to execute and thus, the target is explicitly identified. During runtime, after the instruction cache line corresponding to the branch instruction is fetched, the direct branch instruction can be rewritten so that it targets the address of the actual target inside the instruction cache, rather than the address of the branch stub. In this way, further executions of the direct branch instruction will proceed directly to the target address of the next instruction directly without incurring instruction cache runtime system overhead, i.e. the overhead associated with jumping to the instruction cache manager of the instruction cache runtime system.
- Indirect branch instructions cannot be rewritten in the same manner as direct branch instructions using the branch stubs since the targets of indirect branch instructions are only known at runtime and may be different each time the indirect branch instructions are executed. Thus, the overhead associated with having to go to the instruction cache runtime system can only be avoided if it can be determined that the current target of the indirect branch instruction is already in the instruction cache. The illustrative embodiments provide mechanisms for determining whether the target of an indirect branch instruction is in the instruction cache or not so that a direct jump can be made using the branch stub.
- With indirect branch instructions, the instruction cache runtime system may monitor the execution of code to identify these indirect branch instructions and may determine the target of the indirect branch instruction and whether the target of the indirect branch instruction is the same target as in a previous execution of the indirect branch instruction. The branch stubs for indirect branch instructions, along with a compiler inserted check instruction, can be used to make such a determination, as will be described in greater detail hereafter. If the indirect branch instruction is targeting the same target address as for a previous execution of the indirect branch instruction, then the execution may jump directly to this target in the instruction cache without having to go through the instruction cache runtime system, e.g., the instruction cache manager. However, if the target address of the indirect branch instruction does not match a previous target address for a previous execution of the branch instruction, then the execution may jump to the instruction cache runtime system, such as the instruction cache manager as described above, to bring the target of the indirect branch instruction into the instruction cache.
- As mentioned above, one aspect of these illustrative embodiments is the introduction of branch stubs for branch instructions in code provided to a compiler. The compiler may analyze the received code, identify branch instructions in the code as well as whether the branch instruction is a direct branch instruction or an indirect branch instruction. For example, the compiler may identify a branch instruction as a direct branch instruction when the target of the branch instruction is a discernable address at compile time. A branch instruction whose target is a register or some other location whose contents are dynamically determined at runtime, will be identified by the compiler as an indirect branch instruction.
- For direct and indirect branch instructions, the compiler generates a branch stub, inserts a link to the instruction cache manager into a first portion of the branch stub, and a copy of the target address from the original branch instruction in a second portion of the branch stub. The original branch instruction is then rewritten to reference the branch stub, i.e. the target of the original branch instruction is changed to an address or offset to the branch stub for that branch instruction to thereby generate a modified branch instruction. For indirect branch instructions, the compiler further inserts a check instruction, such as prior to the branch instruction, to check whether a target of the branch instruction matches a previous target of the same branch instruction and to jump to one of the target instruction or the instruction cache runtime system based on an outcome of the check. This will be described in greater detail hereafter.
-
FIG. 10 is an example diagram of a branch stub in accordance with one illustrative embodiment. As shown inFIG. 10 , in one illustrative embodiment, thebranch stub 1000 comprises a plurality of portions of data 1010-1040 with each portion of data 1010-1040 storing different information based on the type of branch instruction that is replaced by thebranch stub 1000. In the depicted example, thebranch stub 1000 is comprised of four words 1010-1040, with each word being a fixed size number of bits of data. In general thefirst portion 1010 of thebranch stub 1000, e.g., the first word, is used for storing an address to link register and a cache miss handler in thefirst portion 1010, which may be the instruction cache manager, may be part of the instruction cache manager, or may otherwise be provided by the instruction cache runtime system, for example, in case the target of the branch is not present in the instruction cache when the branch stub is processed. Thesecond portion 1020 may store a copy of the target effective address from the original branch instruction. The last twoportions branch stub 1000 based on the type of branch instruction being replaced or rewritten. - For example, the
third portion 1030 of thebranch stub 1000 may be used by the instruction cache runtime system, for direct branch instructions, to store an offset into a cache line or cache line for locating the original branch instruction. Thefourth portion 1040 of thebranch stub 1000 may be used to store a copy of the original branch instruction before rewriting. With this extra information in thebranch stub 1000, after the instruction cache manager fetches the instruction cache line corresponding to the branch instruction into the instruction cache, the instruction cache manager may cause the direct branch instruction to be rewritten to target the actual target address inside the instruction cache rather than thebranch stub 1000. Thereafter, when the direct branch instruction is again executed, the branch instruction will jump directly to the target in the instruction cache rather than having to go through the instruction cache manager to check to see if the target is in the instruction cache. - For indirect branch instructions, the mechanisms of the illustrative embodiments make use of the observation that indirect branch instructions tend to target the same target address at runtime. Thus, for indirect branch instructions, the instruction cache runtime system uses a sub-portion of the
third portion 1030 of thebranch stub 1000, which is unused for direct branch instructions, to store the target address for the last target called by the indirect branch instruction. This target address for the last target called by the indirect branch instruction, stored in sub-portion of thethird portion 1030 of thebranch stub 1000, may be used by the check instruction inserted by the compiler to check to see if the previous execution of the indirect branch instruction targeted the same target address or not as the current execution of the indirect branch instruction. If so, then the target instruction is already present in the instruction cache (since the previous execution used it) and thus, the indirect branch instruction can jump directly to the target instruction in the instruction cache without having to go through the instruction cache manager. If the target address for the last target called by the indirect branch instruction does not match the target of the current execution of the indirect branch instruction, then the execution jumps to the instruction cache manager to perform the necessary operations for bringing the target into the instruction cache, as previously described above. - It should be noted that in order to handle cache line eviction properly, such as when there is an instruction cache miss and a cache line needs to be evicted to bring in another cache line, the saved target address in the sub-portion of the
third portion 1030 of thebranch stub 1000 of the calling indirect branch instruction needs to be cleared when the target instruction is evicted from the instruction cache. The same is true for direct branches such that the target address information stored in thebranch stub 1000 must be cleared when the target instruction is evicted from the instruction cache. More about eviction will be provided hereafter. - In addition to the above, the illustrative embodiments further include mechanisms for rewriting branch instruction returns. Branch instruction return rewriting, in accordance with one illustrative embodiment, is achieved without using branch stubs but instead makes use of a rewriting of a link register. For example with a processor element architecture such as shown in
FIG. 1 , each SPE may support 128 bit registers, each of which may store a quadword. Register r0 may be used as a link register, i.e. a register that stores the address to return to when a function completes execution, with only word 0 of the link register typically being used. In general, when a function returns, the address stored in the link register is loaded from the call stack and then a return handler, which may be part of the instruction cache manager, or otherwise provided in the instruction cache runtime system, is called with the link register address as input. The return handler would then check whether the code block to return to is still in the instruction cache or not, and if not, it will fetch the code block from the backing store or main memory and put it into the instruction cache. -
FIG. 11 is an example diagram illustrating a rewriting of a link register in accordance with one illustrative embodiment. As shown inFIG. 11 , the mechanisms of the illustrative embodiments rewrite thelink register 1100 so that additional information is stored in thelink register 1100. That is, typically thelink register 1100 only stores the return address, referred to as the load/store return address, in word 0 1110 of thelink register 1100. However, with the mechanisms of the illustrative embodiments, the instruction cache runtime system rewrites thelink register 1100 to store a target address in word 0 1110, which is to be used as a basis for an indirect branch instruction to the target address, and an effective address (EA) for the return address inword 1 1120. - With this rewriting of the
link register 1100, when a branch returns, the instruction cache runtime system can perform a load of the link register from the stack and perform an indirect branch to the link register. The target of the indirect branch instruction to the link register will be word 0 of the link register. This indirect branch instruction can then be handled using the mechanisms noted above with regard to indirect branches. As a result, if the target address stored in word 0 of the link register corresponds to the same target address as a previous execution of the indirect branch, as determined from a branch stub associated with the indirect branch instruction, then the execution of the code can bypass the return handler of the instruction cache runtime system and jump directly to the target instruction in the instruction cache. If the target addresses do not match, then the instruction cache manager may be invoked as discussed above. - In particular, after instruction cache miss handling, which may occur as a result of a target of the branch instruction, e.g., a called function, not being present in the instruction cache, the return handler of the instruction cache runtime system, e.g., in the instruction cache manager, stores the instruction cache address of the code block to return to in the first slot or word, e.g., word 0 1110, of the
link register 1100. The return handler also stores the corresponding effective address of the instruction cache address of the code block to return to in a second slot or word, e.g.,word 1 1120, of thelink register 1100. Thus, after rewriting the link register, and assuming that the target block of code is not evicted, when the branch returns, it will branch to the first slot or word, e.g., word 0 1110, of thelink register 1100 directly without invoking the return handler of the instruction cache runtime system. - It should be noted that cache eviction needs to be handled carefully in this case. To correct return rewriting when the target block of code to be returned to has been evicted from the instruction cache, whenever a cache line is evicted, the instruction cache manager may traverse all call stack frames through a back chain. For each call stack frame, the instruction cache manager may examine the second slot or word, e.g.,
word 1 1120, of thelink register 1100. If the effective address in the second slot or word matches the cache line evicted, then the instruction cache manager may modify the first slot or word, e.g., word 0 1110, of thelink register 1100 to point to the address of the return handler of the instruction cache runtime system. Thus, later, when the branch instruction returns, the return handler will be invoked instead, and the return handler knows which cache line to fetch based on the second slot or word, e.g.,word 1 1120, of thelink register 1100. -
FIG. 12 is an example diagram illustrating an overall operation of one illustrative embodiment for rewriting branch instructions using branch stubs. As shown inFIG. 12 ,original code 1210 is provided and may include one or moredirect branch instructions 1212 and/or one or moreindirect branch instructions 1214. Thecompiler 1220 may receive theoriginal code 1210 and, as part of its optimizations, may rewrite the branches in theoriginal code 1210 using branch stubs with the branch instructions referencing the branch stubs. In order to achieve this rewriting, thecompiler 1220 may be provided withbranch rewriting logic 1222 that performs the static analysis of theoriginal code 1210 as described previously to identify branches in theoriginal code 1210 and rewrite these branches accordingly. - For example, the
branch rewriting logic 1222 may identify the branches in theoriginal code 1210, generate a branch stub, e.g.,branch stubs original code 1210, and populate the branch stubs with an address for the instruction cache manager (for use in the case of a target block not being present in the instruction cache), as well as an original target address from the original branch instruction. The original branch instructions are then rewritten to replace the reference to the target instruction with a reference to the branch stub corresponding to the branch instruction. This is done regardless of whether the branch instruction is a direct branch instruction or an indirect branch instruction. As a result, the rewrittencode 1230 includes rewrittenbranch instructions branch stubs FIG. 12 ). - The
branch rewriting logic 1222 further determines which branch instructions in theoriginal code 1210 aredirect branch instructions 1212 orindirect branch instructions 1214. Forindirect branch instructions 1214, thebranch rewriting logic 1222 inserts check target instructions, such ascheck target instruction 1234. As discussed above, thesecheck target instructions 1234, at runtime, cause a check to be performed of the target address of the current execution of an indirect branch instruction with a target address of a last previous execution of the indirect branch instruction to see if there is a match between the two. If there is a match, then the execution jumps to the target address directly without having to go to the instruction cache (icache)runtime system 1240. If there is not a match, then the execution goes to theicache runtime system 1240 so that aninstruction cache manager 1242 may perform the necessary operations to ensure that the block of code targeted by the indirect branch instruction is brought into the instruction cache (icache) 1250. - The rewritten
code 1230 may be provided to a linker (not shown) which then links the code with library functions and the like, and generates executable code that is provided toprocessor 1280. Theprocessor 1280 may execute the rewrittencode 1230 and, in the process execute the rewrittenbranch instructions corresponding branch stubs icache runtime system 1240 may monitor the execution to determine when the branch instructions need to be dynamically rewritten. For example, with direct branch instructions, such asdirect branch instruction 1232, the dynamicbranch rewriting logic 1244 of theicache runtime system 1240 rewrites thedirect branch instruction 1232 dynamically to directly target thelocation 1254 within theinstruction cache 1250 where the target of the original branch instruction is currently located, rather than pointing to thebranch stub 1238. This dynamic rewriting is performed to the direct branch instruction in the directbranch cache line 1252 in theicache 1250. - With indirect branch instructions, such as
indirect branch instruction 1236, the dynamicbranch rewriting logic 1244 monitors whether the correspondingcheck target instruction 1234 results in the target addresses matching or not. If the target addresses match, then the processor may access the indirect branchtarget cache line 1258 directly without having to go through theinstruction cache manager 1242 of theicache runtime system 1240. If the target addresses do not match, then the execution branches to theinstruction cache manager 1242 of the instructioncache runtime system 1240, as specified by the first portion of the branch stub. In addition, the dynamicbranch rewriting logic 1244 rewrites theindirect branch stub 1239, in the indirectbranch cache line 1256, with the current target address of the current execution of theindirect branch instruction 1236, such as in a sub-portion of thethird word 1030 inFIG. 10 . In this way, the target address stored in the indirect branch stub in the indirectbranch cache line 1256 is updated to store the last previous target address of the indirect branch instruction. - In addition to the above, the branch
return rewriting logic 1246 of theicache runtime system 1240 operates to rewrite thelink register 1260 so that it stores the target address and effective address of the target address in the link register as discussed above with regard toFIG. 11 . When a branch instruction returns, it returns to the target address in the link register using an indirect branch instruction that is handled in the same manner as other indirect branch instructions discussed above. In addition, theinstruction cache manager 1242 may perform the operations noted above using thecall stack 1270 to traverse call stack frames to determine if there is a match to the effective address of thelink register 1260 and if so, cause the branch return rewriting logic to rewrite the target address in thelink register 1260 to point to theinstruction cache manager 1242. -
FIG. 13 is a flowchart outlining an example operation of a compiler for rewriting branch instructions in accordance with one illustrative embodiment. As shown inFIG. 13 , the operation starts with the compiler analyzing the received code (step 1305) and determining if a branch instruction is encountered (step 1310). If a branch instruction is not encountered, the operation determines if an end of the code is encountered (step 1315). If not, the operation returns to step 1305. Otherwise the optimized code is output to the linker for generation of executable code (step 1320) and the operation terminates. - If the compiler encounters a branch instruction (step 1310), the compiler generates a branch stub for the branch instruction including storing the address to the instruction cache manager and the original target address of the branch instruction as described above (step 1325). The compiler rewrites the branch instruction to target the branch stub (step 1330) and determines if the branch instruction is an indirect branch instruction (step 1335). If the branch is an indirect branch instruction, the compiler inserts a check target instruction prior to the branch instruction that checks the target of the indirect branch instruction against a last previous target address stored in the branch stub and jumps directly to the target if there is a match or jumps to the instruction cache manager if there is not a match (step 1340). Thereafter, or if the branch instruction is not an indirect branch instruction, the operation continues to step 1315.
-
FIG. 14 is a flowchart outlining an example operation or an instruction cache runtime system for performing dynamic rewriting of branch instructions in accordance with one illustrative embodiment. As shown inFIG. 14 , the operation starts by receiving a cache line request requesting an access to a particular portion of code in a cache line of the instruction cache (step 1405). A determination is made as to whether there is a cache hit or not, i.e. the cache line corresponding to the cache line request is already present in the instruction cache (step 1410). If there is a cache hit, then the cache line is accessed from the instruction cache (step 1415) and the operation terminates. If there is not a cache hit, i.e. there is a cache miss, then a determination is made as to whether the instruction cache has available unused space to store a cache line corresponding to the cache line request (step 1420). If there is available space, then the requested cache line is fetched from the backing store and loaded into the instruction cache (step 1425), with the operation returning to step 1405 where the cache line request is again executed. - If there is not available space in the instruction cache, an existing cache line is evicted (step 1430) and a determination is made as to whether dynamic branch rewriting is to be performed (step 1435). If dynamic branch rewriting is not to be performed, the operation continues to step 1425. The determination as to whether to perform dynamic branch rewriting may include, for example, determining if a branch instruction loaded with the cache line targeted by the cache line request is a direct branch or an indirect branch. If the branch is a direct branch, then the branch instruction can be dynamically rewritten to directly reference the location of the original target instruction in the instruction cache rather than referencing the branch stub of the direct branch. If the branch is an indirect branch, then a check instruction may be executed to determine if the target of the indirect branch is the same as a last previous target as stored in the branch stub. If there is a match, then the branch instruction can jump directly to the target in the instruction cache. If there is not a match, then the execution may branch to the instruction branch manager and the current target may be stored in the branch stub in replacement of the last previous target address.
- If dynamic branch rewriting is to be performed, then the dynamic branch rewriting is performed as discussed above (step 1440). A return rewrite operation may then be performed for the evicted cache line based on the effective address of the target stored in the link register, as previously described above (step 1445). The link register may then be dynamically rewritten (step 1450). As noted above, the link register may be rewritten to include the target address and the effective address of the target. An indirect branch instruction to the target address stored in the link register may be inserted at the branch return (step 1455). The operation then terminates.
- Thus, the illustrative embodiments provide a mechanism for using a branch stub and runtime logic to bypass the instruction cache manager in instances where it can be determined that the target of the branch instruction is already present in the instruction cache. Moreover, the mechanisms of the illustrative embodiments provide a functionality for rewriting a link register so that upon a return from executing a branch instruction, an indirect branch to a target specified in the link register, or the instruction cache manager is made possible.
- These mechanisms improve the performance of a software managed instruction cache by rewriting a jump to the software instruction cache runtime system as a direct jump to the target location in the software cache. However, when a cache line or block is evicted from the instruction cache, all jumps directly going to this cache line or cache line need to be restored to their original targets so that, if necessary, the jumps can be made to the instruction cache runtime system in the event that the target is not in the instruction cache. This is because, if these jumps to the targets are not restored, the jumps may be made to a wrong target since the correct target is no longer in the instruction cache.
- The unchaining process, i.e. retracing the jump instructions from one cache line to another in the instruction cache to identify source cache lines, i.e. the cache line from which a branch or call to a cache line of interest, or target cache line, is especially challenging when the source cache lines are only known at runtime, such as with indirect branch instructions or function calls. One mechanism for handling this situation is to flush the entire instruction cache or utilize expensive bookkeeping and table lookup algorithms which result in significant overhead and lose the opportunity for reuse of the cache line, i.e. if the instruction cache is flushed and all cache lines are evicted, then the cache lines that were brought into the instruction cache cannot be used again.
- The illustrative embodiments provide additional mechanisms for handling cache eviction in which branch instructions have been rewritten to directly target cache lines that are to be evicted. With these mechanisms, the possible source cache lines of a cache line of interest, hereafter referred to as the target cache line, are dynamically maintained in a doubly linked list. When the target cache line is to be evicted, the linked list is scanned to restore the chained jump branch instructions. In this way, the mechanisms of the illustrative embodiments support efficient eviction via a doubly linked list of cross inter-cache line branches who's branch targets are in a particular cache line, and a singly linked list of inter-cache line branches within a particular cache line that have been put into the doubly linked lists of the other cache lines. Moreover, the mechanisms of the illustrative embodiments support a partial stack scan with the stack back trace scan being stopped at a first match to a “victim” cache line, as described hereafter.
- The rewriting of direct function calls is very similar to rewriting branches inside a function. However, unlike in the case of branches inside a function, the compiler generally does not have a complete view of all functions inside a program and thus, the compiler does not know the exact set of possible callers to a callee function. As a result, the compiler cannot pre-allocate space to record all call sites, i.e. the branch instruction that makes the function call which is also part of the source cache line, as in the case of branches inside a function.
- The mechanisms of the illustrative embodiments address these problems by using a linked list based solution that is able to handle an arbitrary number of call sites, i.e. branch instructions that branch to, or “call,” a portion of code corresponding to a target cache line, i.e. a callee function. For each callee function, i.e. each function called by a caller branch instruction, a linked list is dynamically constructed that records rewritten call sites that call the callee function.
- The linked list node is constructed as part of an extended branch stub, which is referred to herein as a “call stub,” which extends the branch stub described above with an additional quadword for tracking call sites. For example, in a first quadword, information corresponding to the branch stub previously described above is stored. In a second quadword, a linked list previous entry pointer and a linked list next entry pointer for pointing to entries in a linked list of call sites are stored. The linked list previous entry pointer points to a previous entry in the linked list and the linked list next entry pointer points to a next entry in the linked list. This provides a doubly linked list of call sites that facilitates a more simplified deletion process for deleting call sites from the linked list.
-
FIG. 15 is an example diagram illustrating a call stub in accordance with one illustrative embodiment. As shown inFIG. 15 , thecall stub 1500 includes afirst portion 1510, which may be a first quad word, that stores data similar to that of the branch stub previously described above. That is, thefirst portion 1510 stores, in afirst word 1512, a link to the instruction cache manager in the case of a instruction cache miss. In asecond word 1514, the target address for the original branch instruction or function call is stored. In athird word 1516, an offset to the original branch or call instruction is stored. In afourth word 1518, a copy of the original branch or call instruction is stored. - In addition, the call stub includes a
second portion 1520, which may be a second quadword, for storing linked list pointers for purposes of handling instruction cache eviction. As shown inFIG. 15 , afirst word 1522 of thesecond portion 1520 may store a linked list previous pointer that points to, i.e. stores an address for, a previous call stub in the linked list. Asecond word 1524 of thesecond portion 1520 may store a linked list next pointer that points to, i.e. stores an address for, a next call stub in the linked list. The third andfourth words - During runtime, if a cache line is evicted, the instruction cache manager determines whether the evicted cache line is the entry of a function. This determination may be done based on a tag placed on the cache directory when the cache line is loaded due to a function call or a separate table of function entry cache lines may be maintained, for example. Other ways of determining whether a cache line is an entry to a function may be used without departing from the spirit and scope of the illustrative embodiments.
- If the cache line is the entry of a function, the cache line has additional information, before or after the actual code, that records the start of the doubly linked list of call sites. This additional information may be generated by the compiler and may be maintained by the instruction cache runtime system. The instruction cache manager may process the doubly linked list and each call site is “fixed” by restoring the target of the original call or branch instruction to point to the original target address rather than the call stub. This can be achieved by replacing the branch or call instruction with the copy of the original branch or call instruction stored in the
fourth word 1518 of thefirst quadword 1510 in thecall stub 1500 or thefourth word 1040 in thebranch stub 1000 inFIG. 10 . Since the information for performing this fix is stored in thecall stub 1500 orbranch stub 1000 this fix is made simple to implement by changing the binary code in the instruction cache to replace the branch instruction or call instruction. - In addition, the instruction cache manager may perform additional functionality for maintaining the doubly linked call site list. Whenever a cache line is evicted, the instruction cache manager processes the doubly linked call site list for the evicted cache line and checks whether any of the call sites is in the doubly linked call site list. If so, the call site has to be removed from the linked list otherwise, after eviction of the cache line, the doubly linked call site list may become corrupted. For example, the next pointer in the previous call stub maybe changed to point to the next pointer in the current call stub and the previous pointer in the next call stub may be changed to point to the previous call stub of the current call stub, thereby eliminating the current call stub from the linked list. Using this doubly linked call site list mechanism, an arbitrary number of call sites calling a callee function can be handled with undoing rewriting of call or branch instructions when the callee function is evicted.
-
FIG. 16 is a flowchart outlining an example operation of an instruction cache manager when handling the eviction of a cache line in accordance with one illustrative embodiment. As shown inFIG. 16 , the operation starts with the eviction of a cache line (step 1610). A determination is made as to whether the cache line is an entry to a function (step 1620). If so, then a doubly linked call site list associated with the function is processed using the call stub of the function and any other call stubs linked to directly or indirectly by the call stub (step 1630). Call sites in the doubly linked call site list are fixed by restoring the target address from the call stubs corresponding to the call sites (step 1640). In addition, each call site inside the evicted block is checked (step 1650) to determine if the call site is present in the doubly linked call site list as the doubly linked call site list is processed (step 1660). If the call site is in the doubly linked call site list, then the call site is removed from the doubly linked call site list (step 1670). The operation then terminates. - Thus, in addition to providing mechanisms for rewriting branch instructions using branch stubs, the mechanisms of the illustrative embodiments may extend these branch stubs to call stubs that include pointers for a doubly linked list. These pointers may be used to maintain a doubly linked call site list that can be used during cache line eviction to determine which call sites need to be “fixed” by restoring the target addresses originally referenced in the call site branch or call instructions. Mechanisms for maintaining the doubly linked call site list are also provided. These mechanisms make eviction of cache lines with rewritten call site branch instructions or call instructions possible without corrupting the rewritten code.
- To assist in handling the eviction of a cache line from the instruction cache, in addition to the mechanisms noted above, the illustrative embodiments may, for direct branches or calls to a target code block, where each code block is stored in its own cache line, further record a list of source code blocks that branch to or call the code in the target code block. Since the compiler has a complete view of the functions/procedures in the code, for each code block, the compiler knows the exact list of source code blocks that could directly branch to this target code block at runtime. The compiler just needs to record this information in the target code block so that it can be used by the instruction cache runtime system. With the mechanisms of the illustrative embodiments, the information regarding the list of source code blocks is recorded at the end of the target code block after all of the created branch stubs and call stubs.
- To store this list of source code blocks information, the last quad word of the current code block is reserved.
FIG. 17 is an example diagram illustrating one illustrative embodiment of a source code block listing quad word. Afirst word 1710 of thisquad word 1700 contains the number of source code blocks that could branch to the current code block at runtime. Asecond word 1720 of the quad word contains the number of branch stubs this current code block has. Athird word 1730 of the quad word contains a number of call stubs this current code block has. Afourth word 1740 of the quad word contains the start address of the branch stubs and call stubs in the current code block. The locations, i.e. addresses, of the source code blocks 1750 are laid out just before the last quad word so that the instruction cache runtime system knows where to find them at runtime. - At runtime, when a cache line has to be evicted, the instruction cache manager needs to fix all the rewritten source code blocks with a target code block that is in the evicted cache line. To achieve this, the instruction cache manager in the instruction cache runtime system first fetches the last quad word of the evicted cache line, which will also be the last quadword of the code block since each code block is loaded into its own cache line. From the
first word 1710 of thequad word 1700, the instruction cache manager knows how many source code block address have been encoded in the evicted cache line and where the list of addresses start. The instruction cache manager processes the potential source code blocks one by one. For each source code block, the instruction cache manager locates the source code block based on the source code block address encoded in the evicted cache line. - The instruction cache manager fetches the last quad word of that source block and examines the
second word 1720 andfourth word 1740 of thequad word 1700. As previously mentioned above, thesecond word 1720 records the number of branch stubs in the source code block. Thefourth word 1740 records the start address of the branch stubs. With this information, the instruction cache manager may examine each branch stub and check whether the branch stub is the one branching to the evicted cache line. Eventually, the instruction cache manager will find the branch stub that branches to the evicted cache line. - To fix the rewritten branch instruction that branches to the evicted cache line, the instruction cache manager copies the fourth word of the branch stub, i.e.
word 1040 inFIG. 10 , and replaces the rewritten branch instruction with the copy of the original branch instruction (prior to rewriting) stored in thefourth word 1040. As a result, the branch instruction is restored and does not directly branch to the evicted cache line, thereby eliminating the possibility of a direct branch to a wrong target block. To the contrary, the restored branch instruction will operate in the same manner as discussed above with regard to branching to the instruction cache manager to determine if the target block is in the instruction cache or not and bringing the required block of code into the instruction cache if it is not already present in the instruction cache. -
FIG. 18 is a flowchart outlining an example operation of a compiler when analyzing original code and inserting a list of possible source code blocks targeting a current code block in accordance with one illustrative embodiment. As shown inFIG. 18 , for a next block of code in received original code, the compiler identifies possible source blocks that may target the next block of code (step 1810). The addresses of the possible source code blocks are stored in a portion of the current code block after any branch stubs and/or call stubs created by the compiler (step 1820). The compiler stores a number of the source code blocks in a last portion of the current code block, e.g., the last quad word of the current code block (step 1830). The compiler further stores a number of call stubs in the last portion of the current code block (step 1840). The compiler further stores the start address of branch and call stubs in the current code block in this last portion of the current code block (step 1850). A determination is made as to whether this is the last code block to process or not (step 1860). If not, the operation returns to step 1810. Otherwise, the operation terminates. -
FIG. 19 is a flowchart outlining an example operation of the instruction cache manager in accordance with one illustrative embodiment, with regard to handling eviction of a cache line with direct branches to the evicted cache line. As shown inFIG. 19 , the operation starts with determining that a cache line needs to be evicted (step 1910). The instruction cache manager fetches the last quad word of the evicted cache line (step 1920). From the first word of the quad word, the instruction cache manager determines how many source code block address have been encoded in the evicted cache line and where the list of addresses start (step 1930). The instruction cache manager processes a next potential source code block (step 1940). For the next source code block, the instruction cache manager locates the source code block based on the source code block address encoded in the evicted cache line (step 1950). - The instruction cache manager fetches the last quad word of that source block and examines the number of branch stubs and start address of the branch stubs in the last quad word (step 1960). The instruction cache manager examines each branch stub and checks whether the branch stub branches to the evicted cache line (step 1970). The instruction cache manager then fixes the rewritten branch instruction corresponding to a branch stub that branches to the evicted cache line, by copying the copy of the original branch instruction from the branch stub and replacing the rewritten branch instruction with the copy of the original branch instruction (step 1980). The operation then terminates.
- With the direct-mapped software instruction cache mechanisms described above, conflict misses sometimes are a problem to the performance of the system. A conflict miss is a cache miss due to the replacement policy used by the software cache. For example, in direct-mapped caches, a code block can be only put, or “mapped,” into one predefined cache line. Obviously, some code blocks may be mapped into the same cache line. If they are used repeated, only one of them can be kept in the cache even if there are many other unused cache lines. As a result, the cache manager has to load and evict these cache blocks repeatedly. Such cache misses are referred to as conflict misses.
- To reduce the possibility of conflict misses, the illustrative embodiments may further provide a compiler mechanism that is able to collect and process all the objects, e.g., object files, or .o files, that together make up the executable code of a program, compiled by the compiler that utilize direct target jump optimizations such as those described above. The compiler builds a whole program call graph that lays out the objects and which objects call which other objects, as is generally known in the art. The compiler then partitions the call graph to minimize inter-partition transitions based on the instruction cache size, the size of each function, and the affinity among functions.
- In order to achieve such partitioning, the illustrative embodiments weights the call graph by weighting the nodes in the call graph according to code size, and weights the edges of the call graph according to a number of calls between the particular objects at the ends of the edge. A maximally weighted edge in unprocessed edges of the call graph is selected and a determination is made as to whether the weights of the nodes associated with the selected edge are less than a cache line size. If so, then the nodes are merged into a new node with the weights being updated appropriately. If an edge having a maximum weight among unprocessed edges cannot be found, any remaining procedures are places in one node together in one cache line. In this way, the compiler tries to put high affinity functions into the same partition to reduce conflict misses.
- Using such call graph partitioning and attempting to put high affinity functions into the same partition helps to reduce cache conflict misses for the following reasons. Under call graph partitioning, one “compilation unit” is created for each call graph partition. That is, after the call graph is partitioned into several sub-graphs, each of the sub-graphs, along with its procedures, is associated with a compilation unit for the compiler to operate on. The compiler takes one compilation unit, or partition, as input and lays out the code in it starting at the beginning of the instruction cache address space. Thus, the functions inside one call graph partition normally will not evict each other, as long as the code size for this call graph partition is smaller than the total instruction cache size.
- With this call graph partitioning mechanism, the link-time optimizer first builds a global call graph in a mariner generally known in the art. Each node in the global call graph is weighted according to the corresponding size of the code represented by the node in the global call graph. Each call graph edge is weighted according to a number of calls between the nodes associated with the edge. This information may all be determined statically by the compiler at compile time by analyzing the original code and determining the size of the portions of code in the compiled code that correspond to the nodes in the global call graph and determining an estimate of the number of calls anticipated between nodes, such as based on iterations in loops referencing portions of code, or the like. Thus, the weights may be determined through static program analysis or by profiling, for example, and the result may be a weighted call graph that may be the basis for the partitioning mechanisms. Of course other weightings may be used without departing from the spirit and scope of the illustrative embodiments.
-
FIG. 20 is a flowchart outlining an example operation for performing code optimization using a partitioned call graph in accordance with one illustrative embodiment. As shown inFIG. 20 , the operation starts by building a weighted call graph (step 2010). As noted above, the building of the weighted call graph starts by building a global call graph and then applying weights to the nodes and edges of the global call graph. The weights of nodes may be determined according to the code size, such as in bytes, associated with the nodes. The weights of edges may be determined based on an estimate of the number of calls between nodes of the particular edge. These weights are applied to the nodes and edges of the global call graph to thereby generate a weighted call graph. - A maximally weighted edge, in unprocessed edges of the call graph, is selected (step 2020). Assume for purposes of description that the selected edge is e and the nodes of the selected edge are v1 and v2. A determination is made as to whether such a maximally weighted edge can be found or not (step 2030). If not, any remaining procedures/functions are placed in the same node together in one cache line (step 2040) and the operation ends.
- If a maximally weighted edge is found, a determination is made as to whether a sum of the weights of the nodes associated with the selected edge, e.g., weight(v1)+weight(v2), are less than or equal to a cache line size, e.g., a 1K cache line size or the like (step 2050). If so, then the nodes are merged into a new node with the weights being updated appropriately (step 2060). The merging of nodes into a new node places the binary code for the nodes together in the resulting binary code that is loaded into the instruction cache.
- The weights of the new node may be set, for example, by setting the weight of the new node to the sum of the weights of the merged nodes, e.g., weight(vnew)=weight(v1)+weight(v2). The weight of the edges between this new node and other nodes previously connected to the nodes of the selected edge are set, for example, equal to the sum of the weights of the edges between these other nodes and the nodes of the selected edges, e.g., weight (edge(edge(vnew,v))=weight(edge(v1, v))+weight(edge(v2, v)) for all v. Of course other weightings may be used without departing from the spirit and scope of the illustrative embodiments. The selected edge e, i.e. edge (v1, v2), is then eliminated from the weighted call graph (step 2070) and the operation returns to step 2020 to select a next maximally weighted edge from the remaining unprocessed edges. If the sum of the weights of the nodes of the selected edge is greater than a cache line size, then the edge is marked as having been processed (step 2080) and the operation returns to step 2020.
- The result is a partitioned call graph in which nodes are merged into sizes corresponding to the cache line size of the instruction cache based on their affinity. The resulting code is configured according to this partitioned call graph such that when the code is brought into the instruction cache the code fits within the cache lines of the instruction cache will minimal cross-cache line references. This greatly reduces conflict misses because of a cache line not being present in the instruction cache.
- Thus, the illustrative embodiments provide mechanisms for directly jumping to branch targets in an instruction cache when possible through compiler implemented and runtime implemented rewriting of branch instructions and function calls. The illustrative embodiments further provide mechanisms for handling eviction of cache lines that correspond to rewritten branch instructions and function calls so as to avoid any jumps to incorrect targets in the instruction cache. Further, the illustrative embodiments provide mechanisms for reducing instruction cache conflict misses by partitioning the code based on instruction cache size, function size, and affinity amongst the functions. All of these mechanisms work together to improve the performance of a system's execution of the code by reducing latency encountered by the overhead of having to redirect execution to an instruction cache manager for every branch or function call.
- As noted above, it should be appreciated that the illustrative embodiments may take the form of an entirely hardware embodiment, an entirely software embodiment or an embodiment containing both hardware and software elements. In one example embodiment, the mechanisms of the illustrative embodiments are implemented in software or program code, which includes but is not limited to firmware, resident software, microcode, etc.
- A data processing system suitable for storing and/or executing program code will include at least one processor coupled directly or indirectly to memory elements through a system bus. The memory elements can include local memory employed during actual execution of the program code, bulk storage, and cache memories which provide temporary storage of at least some program code in order to reduce the number of times code must be retrieved from bulk storage during execution.
- Input/output or I/O devices (including but not limited to keyboards, displays, pointing devices, etc.) can be coupled to the system either directly or through intervening I/O controllers. Network adapters may also be coupled to the system to enable the data processing system to become coupled to other data processing systems or remote printers or storage devices through intervening private or public networks. Modems, cable modems and Ethernet cards are just a few of the currently available types of network adapters.
- The description of the present invention has been presented for purposes of illustration and description, and is not intended to be exhaustive or limited to the invention in the form disclosed. Many modifications and variations will be apparent to those of ordinary skill in the art. The embodiment was chosen and described in order to best explain the principles of the invention, the practical application, and to enable others of ordinary skill in the art to understand the invention for various embodiments with various modifications as are suited to the particular use contemplated.
Claims (21)
1. A method, in a data processing system for evicting cache lines from an instruction cache of the data processing system, comprising:
storing, by a processor of the data processing system, for a portion of code in a current cache line, a linked list of call sites that directly or indirectly target the portion of code in the current cache line;
determining, by the processor, that the current cache line is to be evicted from the instruction cache; and
processing, by the processor, the linked list of call sites to identify one or more rewritten branch instructions having associated branch stubs, that either directly or indirectly target the portion of code in the current cache line; and
rewriting, by the processor, the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state based on information in the associated branch stubs.
2. The method of claim 1 , wherein the linked list is stored in an extended portion of the branch stubs of the one or more rewritten branch instructions.
3. The method of claim 2 , wherein the extended portion of the branch stubs includes a previous pointer pointing to a previous entry in the linked list and a next pointer pointing to a next entry in the linked list, wherein each entry in the linked list is a branch stub of a rewritten branch instruction in the one or more rewritten branch instructions.
4. The method of claim 1 , wherein the branch stubs of the one or more rewritten branch instructions comprises a copy of a corresponding original branch instruction prior to rewriting the branch instruction, and wherein rewriting the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state comprises replacing the one or more rewritten branch instructions with a copy of the corresponding original branch instruction from corresponding branch stubs.
5. The method of claim 1 , further comprising:
determining, for call sites in the current cache line, if the call sites are present in the linked list; and
removing the call sites from the linked list in response to eviction of the current cache line.
6. The method of claim 1 , further comprising:
determining if the current cache line is an entry to a function; and
retrieving a call stub associated with the function in response to the current cache line being an entry to the function, wherein the call stub comprises an entry in the linked list pointing to a call site that calls the function.
7. The method of claim 1 , wherein, for target code blocks in the portion of code that are directly targeted by source code blocks, a compiler stores a listing of source code blocks that can possibly directly branch to the target code block, and wherein the listing of source code blocks is processed in response to evicting the current cache line to identify a source code block that directly targets the target code block.
8. The method of claim 7 , wherein the listing of source code blocks includes a quadword of data comprising a number of source code blocks in the listing of source code blocks, a number of branch stubs in the target code block, a number of call stubs in the target code block, and a start address of the branch stubs and call stubs in the target code block.
9. The method of claim 8 , wherein processing the list of source code blocks comprises retrieving, for each source code block sequentially until a source code block targeting the target code block is found, a quadword associated with the source code block and checking each branch stub referenced in the quadword to determine if the source code block includes a branch instruction that branches to the target code word.
10. The method of claim 9 , further comprising rewriting the branch instruction in the source code block that targets the target code block to restore the branch instruction to an original state.
11. A computer program product comprising a computer readable storage medium having a computer readable program stored therein, wherein the computer readable program, when executed on a data processing system, causes the data processing system to:
store for a portion of code in a current cache line, a linked list of call sites that directly or indirectly target the portion of code in the current cache line;
determine that the current cache line is to be evicted from the instruction cache;
process the linked list of call sites to identify one or more rewritten branch instructions having associated branch stubs, that either directly or indirectly target the portion of code in the current cache line; and
rewrite the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state based on information in the associated branch stubs.
12. The computer program product of claim 11 , wherein the linked list is stored in an extended portion of the branch stubs of the one or more rewritten branch instructions.
13. The computer program product of claim 12 , wherein the extended portion of the branch stubs includes a previous pointer pointing to a previous entry in the linked list and a next pointer pointing to a next entry in the linked list, wherein each entry in the linked list is a branch stub of a rewritten branch instruction in the one or more rewritten branch instructions.
14. The computer program product of claim 11 , wherein the branch stubs of the one or more rewritten branch instructions comprises a copy of a corresponding original branch instruction prior to rewriting the branch instruction, and wherein rewriting the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state comprises replacing the one or more rewritten branch instructions with a copy of the corresponding original branch instruction from corresponding branch stubs.
15. The computer program product of claim 11 , wherein the computer readable program further causes the data processing system to:
determine, for call sites in the current cache line, if the call sites are present in the linked list; and
remove the call sites from the linked list in response to eviction of the current cache line.
16. The computer program product of claim 11 , wherein the computer readable program further causes the data processing system to:
determine if the current cache line is an entry to a function; and
retrieve a call stub associated with the function in response to the current cache line being an entry to the function, wherein the call stub comprises an entry in the linked list pointing to a call site that calls the function.
17. The computer program product of claim 11 , wherein, for target code blocks in the portion of code that are directly targeted by source code blocks, a compiler stores a listing of source code blocks that can possibly directly branch to the target code block, and wherein the listing of source code blocks is processed in response to evicting the current cache line to identify a source code block that directly targets the target code block.
18. The computer program product of claim 17 , wherein the listing of source code blocks includes a quadword of data comprising a number of source code blocks in the listing of source code blocks, a number of branch stubs in the target code block, a number of call stubs in the target code block, and a start address of the branch stubs and call stubs in the target code block.
19. The computer program product of claim 18 , wherein processing the list of source code blocks comprises retrieving, for each source code block sequentially until a source code block targeting the target code block is found, a quadword associated with the source code block and checking each branch stub referenced in the quadword to determine if the source code block includes a branch instruction that branches to the target code word.
20. The computer program product of claim 19 , further comprising rewriting the branch instruction in the source code block that targets the target code block to restore the branch instruction to an original state.
21. A data processing system, comprising:
a processor; and
an instruction cache coupled to the processor, wherein the instruction cache is configured to store for a portion of code in a current cache line, a linked list of call sites that directly or indirectly target the portion of code in the current cache line, and wherein the processor is configured to:
determine that the current cache line is to be evicted from the instruction cache;
process the linked list of call sites to identify one or more rewritten branch instructions having associated branch stubs, that either directly or indirectly target the portion of code in the current cache line; and
rewrite the one or more rewritten branch instructions to restore the one or more rewritten branch instructions to an original state based on information in the associated branch stubs.
Priority Applications (2)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US12/823,226 US20110320786A1 (en) | 2010-06-25 | 2010-06-25 | Dynamically Rewriting Branch Instructions in Response to Cache Line Eviction |
US13/444,890 US8782381B2 (en) | 2010-06-25 | 2012-04-12 | Dynamically rewriting branch instructions in response to cache line eviction |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
US12/823,226 US20110320786A1 (en) | 2010-06-25 | 2010-06-25 | Dynamically Rewriting Branch Instructions in Response to Cache Line Eviction |
Related Child Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US13/444,890 Continuation US8782381B2 (en) | 2010-06-25 | 2012-04-12 | Dynamically rewriting branch instructions in response to cache line eviction |
Publications (1)
Publication Number | Publication Date |
---|---|
US20110320786A1 true US20110320786A1 (en) | 2011-12-29 |
Family
ID=45353693
Family Applications (2)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US12/823,226 Abandoned US20110320786A1 (en) | 2010-06-25 | 2010-06-25 | Dynamically Rewriting Branch Instructions in Response to Cache Line Eviction |
US13/444,890 Active US8782381B2 (en) | 2010-06-25 | 2012-04-12 | Dynamically rewriting branch instructions in response to cache line eviction |
Family Applications After (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
US13/444,890 Active US8782381B2 (en) | 2010-06-25 | 2012-04-12 | Dynamically rewriting branch instructions in response to cache line eviction |
Country Status (1)
Country | Link |
---|---|
US (2) | US20110320786A1 (en) |
Cited By (11)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080235499A1 (en) * | 2007-03-22 | 2008-09-25 | Sony Computer Entertainment Inc. | Apparatus and method for information processing enabling fast access to program |
US20100201102A1 (en) * | 2009-01-30 | 2010-08-12 | Weaver Danny C | Pin-engaging drawbar and lock plate assembly |
US8516230B2 (en) | 2009-12-29 | 2013-08-20 | International Business Machines Corporation | SPE software instruction cache |
US8522225B2 (en) | 2010-06-25 | 2013-08-27 | International Business Machines Corporation | Rewriting branch instructions using branch stubs |
US8627051B2 (en) | 2010-06-25 | 2014-01-07 | International Business Machines Corporation | Dynamically rewriting branch instructions to directly target an instruction cache location |
US8782381B2 (en) | 2010-06-25 | 2014-07-15 | International Business Machines Corporation | Dynamically rewriting branch instructions in response to cache line eviction |
CN105009072A (en) * | 2013-01-31 | 2015-10-28 | 惠普发展公司,有限责任合伙企业 | Updating a commit list to indicate data to be written to a firmware interface variable repository |
US20160170769A1 (en) * | 2014-12-15 | 2016-06-16 | Michael LeMay | Technologies for indirect branch target security |
US9459851B2 (en) | 2010-06-25 | 2016-10-04 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
US20160335087A1 (en) * | 2015-05-14 | 2016-11-17 | International Business Machines Corporation | Optimizing branch re-wiring in a software instruction cache |
US11204797B2 (en) * | 2016-10-21 | 2021-12-21 | Samsung Electronics Co., Ltd. | Computing systems and methods of operating computing systems |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US9448788B1 (en) * | 2014-01-22 | 2016-09-20 | SecondWrite LLC | Binary rewriting system |
US10503626B2 (en) | 2018-01-29 | 2019-12-10 | Oracle International Corporation | Hybrid instrumentation framework for multicore low power processors |
US11086791B2 (en) * | 2019-08-29 | 2021-08-10 | Micron Technology, Inc. | Methods for supporting mismatched transaction granularities |
Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050108562A1 (en) * | 2003-06-18 | 2005-05-19 | Khazan Roger I. | Technique for detecting executable malicious code using a combination of static and dynamic analyses |
US20100306746A1 (en) * | 2009-05-29 | 2010-12-02 | University Of Maryland | Binary rewriting without relocation information |
Family Cites Families (45)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US5313616A (en) | 1990-09-18 | 1994-05-17 | 88Open Consortium, Ltd. | Method for analyzing calls of application program by inserting monitoring routines into the executable version and redirecting calls to the monitoring routines |
US5778228A (en) | 1994-08-16 | 1998-07-07 | International Business Machines Corporation | Method and system for transferring remote procedure calls and responses over a network |
US5926632A (en) | 1996-04-11 | 1999-07-20 | Matsushita Electric Industrial Co., Ltd. | Circuit partitioning method, circuit partitioning apparatus, and computer-readable recording medium having thereon circuit partitioning program |
US6865735B1 (en) | 1997-10-07 | 2005-03-08 | University Of Washington | Process for rewriting executable content on a network server or desktop machine in order to enforce site specific properties |
US6175957B1 (en) | 1997-12-09 | 2001-01-16 | International Business Machines Corporation | Method of, system for, and computer program product for providing efficient utilization of memory hierarchy through code restructuring |
US6112280A (en) | 1998-01-06 | 2000-08-29 | Hewlett-Packard Company | Method and apparatus for distinct instruction pointer storage in a partitioned cache memory |
US6205545B1 (en) | 1998-04-30 | 2001-03-20 | Hewlett-Packard Company | Method and apparatus for using static branch predictions hints with dynamically translated code traces to improve performance |
US6427234B1 (en) | 1998-06-11 | 2002-07-30 | University Of Washington | System and method for performing selective dynamic compilation using run-time information |
US20020147969A1 (en) | 1998-10-21 | 2002-10-10 | Richard A. Lethin | Dynamic optimizing object code translator for architecture emulation and dynamic optimizing object code translation method |
US6453411B1 (en) | 1999-02-18 | 2002-09-17 | Hewlett-Packard Company | System and method using a hardware embedded run-time optimizer |
US6317870B1 (en) | 1999-02-26 | 2001-11-13 | Hewlett-Packard Company | System and method for optimization of inter-module procedure calls |
US6330556B1 (en) | 1999-03-15 | 2001-12-11 | Trishul M. Chilimbi | Data structure partitioning to optimize cache utilization |
US6622300B1 (en) | 1999-04-21 | 2003-09-16 | Hewlett-Packard Development Company, L.P. | Dynamic optimization of computer programs using code-rewriting kernal module |
US6481008B1 (en) | 1999-06-30 | 2002-11-12 | Microsoft Corporation | Instrumentation and optimization tools for heterogeneous programs |
US6609248B1 (en) | 1999-06-30 | 2003-08-19 | Microsoft Corporation | Cross module representation of heterogeneous programs |
US6728788B1 (en) | 1999-12-16 | 2004-04-27 | International Business Machines Corporation | Method and system for converting a remote procedure call to a local procedure call when the service is on the same device as the calling client |
US6725335B2 (en) | 2000-02-09 | 2004-04-20 | Hewlett-Packard Development Company, L.P. | Method and system for fast unlinking of a linked branch in a caching dynamic translator |
US6721875B1 (en) | 2000-02-22 | 2004-04-13 | Hewlett-Packard Development Company, L.P. | Method and apparatus for implementing a single-syllable IP-relative branch instruction and a long IP-relative branch instruction in a processor which fetches instructions in bundle form |
US6598221B1 (en) | 2000-04-13 | 2003-07-22 | Koninklijke Philips Electronics N.V. | Assembly code performance evaluation apparatus and method |
WO2002027498A2 (en) | 2000-09-29 | 2002-04-04 | Sun Microsystems, Inc. | System and method for identifying and managing streaming-data |
US6966057B2 (en) | 2001-03-30 | 2005-11-15 | Intel Corporation | Static compilation of instrumentation code for debugging support |
US6968546B2 (en) | 2001-03-30 | 2005-11-22 | Intel Corporation | Debugging support using dynamic re-compilation |
US6817014B2 (en) | 2001-04-11 | 2004-11-09 | Hewlett-Packard Development Company, L.P. | Analysis of executable program code using compiler-generated function entry points and endpoints with other sources of function entry points and endpoints |
US6795964B2 (en) | 2001-06-18 | 2004-09-21 | Hewlett-Packard Development Company, L.P. | Edge profiling for executable program code having branches through stub code segments |
US20030009750A1 (en) | 2001-07-09 | 2003-01-09 | Robert Hundt | Optimizing an executable computer program having linkage functions |
US6934943B2 (en) | 2001-10-18 | 2005-08-23 | Hewlett-Packard Development Company | Optimization of control transfers to dynamically loaded modules |
US7039910B2 (en) | 2001-11-28 | 2006-05-02 | Sun Microsystems, Inc. | Technique for associating execution characteristics with instructions or operations of program code |
US7594111B2 (en) | 2002-12-19 | 2009-09-22 | Massachusetts Institute Of Technology | Secure execution of a computer program |
US7577965B2 (en) | 2003-01-15 | 2009-08-18 | Alcatel | Push-based object request broker |
US7165162B2 (en) | 2004-01-13 | 2007-01-16 | Hewlett-Packard Development Company, L.P. | Partitioning modules for cross-module optimization |
US7526760B1 (en) | 2004-03-17 | 2009-04-28 | Sun Microsystems, Inc. | Methods for implementing virtual method invocation with shared code |
US7765534B2 (en) | 2004-04-30 | 2010-07-27 | International Business Machines Corporation | Compiler with cache utilization optimizations |
GB2417579A (en) | 2004-08-26 | 2006-03-01 | Hewlett Packard Development Co | Method for dynamically inserting code into a process by enabling taken branch traps to intercept a branch during the execution of the process |
US7526502B2 (en) | 2004-09-10 | 2009-04-28 | Microsoft Corporation | Dynamic call site binding |
US20070027877A1 (en) | 2005-07-29 | 2007-02-01 | Droshev Mladen I | System and method for improving the efficiency of remote method invocations within a multi-tiered enterprise network |
US7856628B2 (en) | 2006-01-23 | 2010-12-21 | International Business Machines Corporation | Method for simplifying compiler-generated software code |
US7844113B2 (en) | 2006-04-05 | 2010-11-30 | Siemens Medical Solutions Usa, Inc. | Region based push-relabel algorithm for efficient computation of maximum flow |
US20080126771A1 (en) | 2006-07-25 | 2008-05-29 | Lei Chen | Branch Target Extension for an Instruction Cache |
US7765242B2 (en) | 2007-05-10 | 2010-07-27 | Hewlett-Packard Development Company, L.P. | Methods and apparatus for structure layout optimization for multi-threaded programs |
US8321850B2 (en) | 2008-06-06 | 2012-11-27 | Vmware, Inc. | Sharing and persisting code caches |
US8516230B2 (en) | 2009-12-29 | 2013-08-20 | International Business Machines Corporation | SPE software instruction cache |
US8631225B2 (en) | 2010-06-25 | 2014-01-14 | International Business Machines Corporation | Dynamically rewriting branch instructions to directly target an instruction cache location |
US20110320786A1 (en) | 2010-06-25 | 2011-12-29 | International Business Machines Corporation | Dynamically Rewriting Branch Instructions in Response to Cache Line Eviction |
US9459851B2 (en) | 2010-06-25 | 2016-10-04 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
US8522225B2 (en) | 2010-06-25 | 2013-08-27 | International Business Machines Corporation | Rewriting branch instructions using branch stubs |
-
2010
- 2010-06-25 US US12/823,226 patent/US20110320786A1/en not_active Abandoned
-
2012
- 2012-04-12 US US13/444,890 patent/US8782381B2/en active Active
Patent Citations (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20050108562A1 (en) * | 2003-06-18 | 2005-05-19 | Khazan Roger I. | Technique for detecting executable malicious code using a combination of static and dynamic analyses |
US20100306746A1 (en) * | 2009-05-29 | 2010-12-02 | University Of Maryland | Binary rewriting without relocation information |
Cited By (20)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20080235499A1 (en) * | 2007-03-22 | 2008-09-25 | Sony Computer Entertainment Inc. | Apparatus and method for information processing enabling fast access to program |
US8195925B2 (en) * | 2007-03-22 | 2012-06-05 | Sony Computer Entertainment Inc. | Apparatus and method for efficient caching via addition of branch into program block being processed |
US20100201102A1 (en) * | 2009-01-30 | 2010-08-12 | Weaver Danny C | Pin-engaging drawbar and lock plate assembly |
US8516230B2 (en) | 2009-12-29 | 2013-08-20 | International Business Machines Corporation | SPE software instruction cache |
US9916144B2 (en) | 2010-06-25 | 2018-03-13 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
US9459851B2 (en) | 2010-06-25 | 2016-10-04 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
US8631225B2 (en) | 2010-06-25 | 2014-01-14 | International Business Machines Corporation | Dynamically rewriting branch instructions to directly target an instruction cache location |
US8713548B2 (en) | 2010-06-25 | 2014-04-29 | International Business Machines Corporation | Rewriting branch instructions using branch stubs |
US8782381B2 (en) | 2010-06-25 | 2014-07-15 | International Business Machines Corporation | Dynamically rewriting branch instructions in response to cache line eviction |
US10324694B2 (en) | 2010-06-25 | 2019-06-18 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
US10169013B2 (en) | 2010-06-25 | 2019-01-01 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
US8627051B2 (en) | 2010-06-25 | 2014-01-07 | International Business Machines Corporation | Dynamically rewriting branch instructions to directly target an instruction cache location |
US8522225B2 (en) | 2010-06-25 | 2013-08-27 | International Business Machines Corporation | Rewriting branch instructions using branch stubs |
US9600253B2 (en) | 2010-06-25 | 2017-03-21 | International Business Machines Corporation | Arranging binary code based on call graph partitioning |
CN105009072A (en) * | 2013-01-31 | 2015-10-28 | 惠普发展公司,有限责任合伙企业 | Updating a commit list to indicate data to be written to a firmware interface variable repository |
US9830162B2 (en) * | 2014-12-15 | 2017-11-28 | Intel Corporation | Technologies for indirect branch target security |
US20160170769A1 (en) * | 2014-12-15 | 2016-06-16 | Michael LeMay | Technologies for indirect branch target security |
US20160335087A1 (en) * | 2015-05-14 | 2016-11-17 | International Business Machines Corporation | Optimizing branch re-wiring in a software instruction cache |
US10782973B2 (en) * | 2015-05-14 | 2020-09-22 | International Business Machines Corporation | Optimizing branch re-wiring in a software instruction cache |
US11204797B2 (en) * | 2016-10-21 | 2021-12-21 | Samsung Electronics Co., Ltd. | Computing systems and methods of operating computing systems |
Also Published As
Publication number | Publication date |
---|---|
US8782381B2 (en) | 2014-07-15 |
US20120198170A1 (en) | 2012-08-02 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
US10169013B2 (en) | Arranging binary code based on call graph partitioning | |
US8627051B2 (en) | Dynamically rewriting branch instructions to directly target an instruction cache location | |
US8713548B2 (en) | Rewriting branch instructions using branch stubs | |
US8782381B2 (en) | Dynamically rewriting branch instructions in response to cache line eviction | |
US8516230B2 (en) | SPE software instruction cache | |
US8990786B2 (en) | Program optimizing apparatus, program optimizing method, and program optimizing article of manufacture | |
US7730463B2 (en) | Efficient generation of SIMD code in presence of multi-threading and other false sharing conditions and in machines having memory protection support | |
US8402224B2 (en) | Thread-shared software code caches | |
US6993754B2 (en) | Annotations to executable images for improved dynamic optimization functions | |
US7784037B2 (en) | Compiler implemented software cache method in which non-aliased explicitly fetched data are excluded | |
US20090150890A1 (en) | Strand-based computing hardware and dynamically optimizing strandware for a high performance microprocessor system | |
US20110154289A1 (en) | Optimization of an application program | |
US8893100B2 (en) | Return address optimisation for a dynamic code translator | |
WO2008092883A2 (en) | Speculative throughput computing | |
US11681806B2 (en) | Protecting against out-of-bounds buffer references | |
US20060277371A1 (en) | System and method to instrument references to shared memory | |
US8726248B2 (en) | Method and apparatus for enregistering memory locations | |
US8359435B2 (en) | Optimization of software instruction cache by line re-ordering | |
US8839219B2 (en) | Data prefetching and coalescing for partitioned global address space languages | |
US20140325186A1 (en) | Supporting code execution in dual address spaces | |
US20050251795A1 (en) | Method, system, and program for optimizing code | |
Boshernitsan et al. | ROE: Runtime Optimization Environment |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
AS | Assignment |
Owner name: INTERNATIONAL BUSINESS MACHINES CORPORATION, NEW Y Free format text: ASSIGNMENT OF ASSIGNORS INTEREST;ASSIGNORS:CHEN, TONG;FLACHS, BRIAN;MICHAEL, BRAD W.;AND OTHERS;SIGNING DATES FROM 20100615 TO 20100621;REEL/FRAME:024676/0789 |
|
STCB | Information on status: application discontinuation |
Free format text: ABANDONED -- FAILURE TO PAY ISSUE FEE |