US6041180AExpiredUtility

System and method for optimizing template object files

Assignee: IBMPriority: Apr 28, 1997Filed: Apr 28, 1997Granted: Mar 21, 2000
Est. expiryApr 28, 2017(expired)· nominal 20-yr term from priority
G06F 8/54G06F 8/4434G06F 8/40
70
PatentIndex Score
60
Cited by
3
References
27
Claims

Abstract

The present invention provides a system and method to reuse code, and thus save code space within a program. A compiler and a linker work together to decide which object code to reuse, for implementation of template classes, and other repetitive code segments. The compiler notes in the object file which functions are generated from template code, or other repetitive types of code. An intelligent linker then attempts to match code, and in the cases where the code matches, simply eliminates multiple versions of the same code by aliasing the function names. The compiler can reduce the amount of linker searching by storing a cyclic redundancy check (CRC) code with each method. By using the system and method of the present invention, code reuse is made possible without sacrificing program efficiency.

Claims

exact text as granted — not AI-modified
What is claimed is: 
     
       1. A method of generating an executable program, comprising the steps of: compiling one or more source files to generate an object file for each source file, wherein said compiling step includes the step of adding a comment record to each object file;   searching each object file to determine if there are one or more repeated sets of instructions; and   linking the object files together to create an executable module, wherein the executable module contains one copy of each repeated set of instructions.   
     
     
       2. A method according to claim 1, wherein said comment record contains a name and a location of one or more potentially repeated sets of instructions. 
     
     
       3. A method according to claim 1, wherein said comment record contains a file name, a line number, a cyclic redundancy check, and a function name. 
     
     
       4. A method according to claim 1, wherein said compiling step further comprises the step of calculating a cyclic redundancy check code for every potentially repeated set of instructions. 
     
     
       5. A method according to claim 4, wherein said searching step comprises the steps of: searching each object file to determine if there are one or more matching cyclic redundancy checks; and   if matching cyclic redundancy checks are found, comparing the sets of instructions associated with the matching cyclic redundancy checks to determine if the sets of instructions are identical.   
     
     
       6. A method according to claim 1, wherein said linking step further comprises the steps of: creating a duplicate set of entry points in the executable module for each repeated set of instructions found during said searching step; and   adjusting addresses of one or more function calls in the executable module to transfer control to the one copy of a repeated set of instructions.   
     
     
       7. An information handling system, comprising: one or more processors;   storage means;   input/output means;   display means;   one or more images of an operating system for controlling operation of said processors;   means for compiling one or more source files to generate an object file for each source file, wherein said means for compiling includes means for adding a comment record to each object file;   means for searching each object file to determine if there are one or more repeated sets of instructions; and   means for linking the object files together to create an executable module, wherein the executable module contains one copy of each repeated set of instructions.   
     
     
       8. An information handling system according to claim 7, wherein said comment record contains a name and a location of one or more potentially repeated sets of instructions. 
     
     
       9. An information handling system according to claim 7, wherein said comment record contains a file name, a line number, a cyclic redundancy check, and a function name. 
     
     
       10. An information handling system according to claim 7, wherein said means for compiling further comprises means for calculating a cyclic redundancy check for every potentially repeated set of instructions. 
     
     
       11. An information handling system according to claim 10, wherein said means for searching comprises: means for searching each object file to determine if there are one or more matching cyclic redundancy checks; and   if matching cyclic redundancy checks are found, means for comparing the sets of instructions associated with the matching cyclic redundancy checks to determine if the sets of instructions are identical.   
     
     
       12. An information handling system according to claim 7, wherein said means for linking further comprises: means for creating a duplicate set of entry points in the executable module for each repeated set of instructions found by said means for searching; and   means for adjusting addresses of one or more function calls in the executable module to transfer control to the one copy of a repeated set of instructions.   
     
     
       13. A computer-readable medium, comprising: means for compiling one or more source files to generate an object file for each source file, wherein said means for compiling further includes means for adding a comment record to each object file;   means for searching each object file to determine if there are one or more repeated sets of instructions; and   means for linking the object files together to create an executable module, wherein the executable module contains one copy of each repeated set of instructions.   
     
     
       14. A computer-readable medium according to claim 13, wherein said comment record contains a name and a location of one or more potentially repeated sets of instructions. 
     
     
       15. A computer-readable medium according to claim 13, wherein said comment record contains a file name, a line number, a cyclic redundancy check, and a function name. 
     
     
       16. A computer-readable medium according to claim 13, wherein said means for compiling further comprises means for calculating a cyclic redundancy check for every potentially repeated set of instructions. 
     
     
       17. A computer-readable medium according to claim 16, wherein said means for searching comprises: means for searching each object file to determine if there are one or more matching cyclic redundancy checks; and   if matching cyclic redundancy checks are found, means for comparing the sets of instructions associated with the matching cyclic redundancy checks to determine if the sets of instructions are identical.   
     
     
       18. A computer-readable medium according to claim 15, wherein said means for linking further comprises: means for creating a duplicate set of entry points in the executable module for each repeated set of instructions found by said means for searching; and   means for adjusting addresses of one or more function calls in the executable module to transfer control to the one copy of a repeated set of instructions.   
     
     
       19. A method of generating an executable program, comprising the steps of: compiling one or more source files to generate an object file for each source file;   searching each object file to determine if there are one or more repeated sets of instructions;   linking the object files together to create an executable module, wherein the executable module contains one copy of each repeated set of instructions, and wherein said linking step includes the steps of: creating a duplicate set of entry points in the executable module for each repeated set of instructions found during said searching step; and   adjusting addresses of one or more function calls in the executable module to transfer control to the one copy of a repeated set of instructions.     
     
     
       20. A method according to claim 19, wherein said compiling step further comprises the step of calculating a cyclic redundancy check code for every potentially repeated set of instructions. 
     
     
       21. A method according to claim 20, wherein said searching step comprises the steps of: searching each object file to determine if there are one or more matching cyclic redundancy checks; and   if matching cyclic redundancy checks are found, comparing the sets of instructions associated with the matching cyclic redundancy checks to determine if the sets or instructions are identical.   
     
     
       22. An information handling system, comprising: one or more processors;   storage means;   input/output means;   display means;   one or more images of an operating system for controlling operation of said processors;   means for compiling one or more source files to generate an object file for each source file;   means for searching each object file to determine if there are one or more repeated sets of instructions;   means for linking the object files together to create an executable module, wherein the executable module contains one copy of each repeated set of instructions, and wherein said means for linking further includes: means for creating a duplicate set of entry points in the executable module for each repeated set of instructions found by said means for searching; and   means for adjusting addresses of one or more function calls in the executable module to transfer control to the one copy of a repeated set of instructions.     
     
     
       23. An information handling system according to claim 22, wherein said means for compiling further comprises means for calculating a cyclic redundancy check for every potentially repeated set of instructions. 
     
     
       24. An information handling system according to claim 23, wherein said means for searching comprises: means for searching each object file to determine if there are one or more matching cyclic redundancy checks; and   if matching cyclic redundancy checks are found, means for comparing the sets of instructions associated with the matching cyclic redundancy checks to determine if the sets of instructions are identical.   
     
     
       25. A computer-readable medium, comprising: means for compiling one or more source files to generate an object file for each source file;   means for searching each object file to determine if there are one or more repeated sets of instructions; and   means for linking the object files together to create an executable module, wherein the executable module contains one copy of each repeated set of instructions, and wherein said means for linking includes: means for creating a duplicate set of entry points in the executable module for each repeated set of instructions found by said means for searching; and   means for adjusting addresses of one or more function calls in the executable module to transfer control to the one copy of a repeated set of instructions.     
     
     
       26. A computer-readable medium according to claim 25, wherein said means for compiling further comprises means for calculating a cyclic redundancy check for every potentially repeated set of instructions. 
     
     
       27. A computer-readable medium according to claim 26, wherein said means for searching comprises: means for searching each object file to determine if there are one or more matching cyclic redundancy checks; and   if matching cyclic redundancy checks are found, means for comparing the sets of instructions associated with the matching cyclic redundancy checks to determine if the sets of instructions are identical.

Join the waitlist — get patent alerts

Track US6041180A — get alerts on status changes and closely related new filings.

We store only your email — no account needed. See our privacy policy.