IP Library Granted Patent US 9,134,977
Granted Patent B2
US 9,134,977 · App. 12/714,236 · Granted Sep 15, 2015

Compiler operation for handling conditional statements

Inventors: Jason I. H. Baron (Bedford, MA); Richard Henderson (Campbell, CA); Roland McGrath (Berkeley, CA)
Assignee: Red Hat, Inc.
G06F8/443
View Patent ↗
Loading inventors, assignments & file history…
Monitor This Case
Get email alerts when status or documents change.
Order Certified Copies
Most orders are placed with the USPTO same day — all within 24 business hours.
Order via The Patent Place →
Pre-filled with this patent's details
Quick Facts
Patent No.
US 9,134,977
App. No.
12/714,236
Granted
Sep 15, 2015
Kind
B2
Abstract

A computer-implemented method and apparatus for optimizing conditional code by identifying conditional code in a source code, adding a no-operation instruction to an executable code corresponding to the source code in place of the conditional code, adding an entry to a table to pair the no-operation instruction to the conditional code, compiling the conditional code, and storing the compiled conditional code separate from the executable code. A computer-implemented method and apparatus to optimize conditional code by loading an executable code to be executed, checking whether conditional code associated with the executable code is enabled for execution, looking up a location of a no-operation instruction in a table and a location of a compiled conditional code in the table, and replacing the no-operation instruction in the executable code with the compiled conditional code.

Claims (40)

1. A method comprising:

identifying a conditional code in a source code, wherein the source code comprises a code segment that is not part of the conditional code;

adding to a table an entry that associates a no-operation instruction with the conditional code to enable execution of the conditional code;

compiling the code segment of the source code that is not part of the conditional code to generate an executable code;

upon enabling of execution of the conditional code, inserting, by a processing device, the no-operation instruction into the executable code in place of the conditional code; and

compiling the conditional code and storing the compiled conditional code separately from the executable code.

2. The method of claim 1 , wherein the conditional code is a trace.

3. The method of claim 1 , wherein the entry to the table comprises an address of the no-operation instruction in the executable code and an address at which the compiled conditional code is stored.

4. The method of claim 3 , wherein the entry to the table comprises a label for a condition or variable to be checked to enable the conditional code.

5. The method of claim 1 , wherein the conditional code in the source code comprises a branch out of assembly code into compiled code.

6. A method comprising:

compiling a code segment of a source code that is not part of a conditional code of the source code to generate an executable code, wherein the conditional code is compiled separately from the executable code, the compiled conditional code is generated during compilation of the source code and stored in a second file, wherein the second file is separate from a first file that stores the executable code;

identifying a no-operation instruction in the executable code; and

upon enabling of execution of the compiled conditional code, replacing, by the processing device, the compiled conditional code in the source code with the no-operation instruction.

7. The method of claim 6 , wherein the compiled conditional code is a trace.

8. The method of claim 6 , further comprising:

matching a global-variable with a label in a table to identify each corresponding no-operation instruction in the executable code.

9. The method of claim 8 , wherein the table comprises an entry with an address of the no-operation instruction in the executable code and an address of the compiled conditional code.

10. The method of claim 9 , further comprising:

replacing the no-operation instruction with a jump instruction to the compiled conditional code in the executable code.

11. A non-transitory computer-readable storage medium having instructions stored therein, which when executed cause a processing device to:

identify a conditional code in a source code, wherein the source code comprises a code segment that is not part of the conditional code;

add to a table an entry that associates a no-operation instruction with the conditional code to enable execution of the conditional code;

compile the code segment of the source code that is not part of the conditional code to generate an executable code;

upon enabling of execution of the conditional code, insert, by the processing device, the no-operation instruction into the executable code in place of the conditional code; and

compile the conditional code and storing the compiled conditional code separately from the executable code.

12. The non-transitory computer-readable storage medium of claim 11 , wherein the conditional code is a trace.

13. The non-transitory computer-readable storage medium of claim 11 , wherein the entry to the table comprises an address of the no-operation instruction in the executable code and an address at which the compiled conditional code is stored.

14. The non-transitory computer-readable storage medium of claim 11 , wherein the entry to the table comprises a label for a condition or variable to be checked to enable the conditional code.

15. The non-transitory computer-readable storage medium of claim 11 , wherein the conditional code in the source code comprises a branch out of assembly code into compiled code.

16. A non-transitory computer-readable storage medium having instructions stored therein, which when executed cause a processing device to:

compile a code segment of a source code that is not part of a conditional code of the source code to generate an executable code, wherein the conditional code is compiled separately from the executable code, the compiled conditional code is generated during compilation of the source code and stored in a second file, wherein the second file is separate from a first file that stores the executable code;

identify a no-operation instruction in the executable code; and

upon enabling of execution of the compiled conditional code, replace, by the processing device, the compiled conditional code in the source code with the no-operation instruction.

17. The non-transitory computer-readable storage medium of claim 16 , wherein the conditional code is a trace.

18. The non-transitory computer-readable storage medium of claim 16 , wherein the set of operations further comprises:

matching a global-variable with a label in a table to identify each corresponding no-operation instruction in the executable code.

19. The non-transitory computer-readable storage medium of claim 18 , wherein the table comprises an entry with an address of the no-operation instruction in the executable code and an address of the compiled conditional code.

20. The non-transitory computer-readable storage medium of claim 19 , wherein the set of operations further comprises:

replacing the no-operation instruction with a jump instruction to the compiled conditional code in the executable code.

Assignments (1)
ASSIGNMENT OF ASSIGNOR'S INTEREST Recorded Apr 6, 2010
From: BARON, JASON I.H.; HENDERSON, RICHARD; MCGRATH, ROLAND
To: RED HAT, INC.
Reel/Frame 024194/0119 →
Continuity (1)
Related Publication 20110214110A1 · Sep 1, 2011