Method for eliminating common subexpressions from java byte codes
Saved in:
| Title: | Method for eliminating common subexpressions from java byte codes |
|---|---|
| Patent Number: | 6,158,048 |
| Publication Date: | December 05, 2000 |
| Appl. No: | 09/087,349 |
| Application Filed: | May 29, 1998 |
| Abstract: | Compilers are tools that generate efficient mappings from programs to machines. A Java "Just-In-Time" runs as part of an application, and as such, it must be fast and efficient in its use of memory. To achieve good performance and further optimize code generation, the present invention introduces a method for eliminating common subexpressions from Java bytecodes. The method of the present invention first loads a code stream containing sequences of computer code into computer memory. The expression value for a first expression of a first code sequence is computed and stored in a memory location. A tag is assigned to the memory location holding this expression value for tracking which expression sequences' values are held in memory locations. As code compilation continues, the code selector looks ahead in the code stream to see if any upcoming expression sequences already have expression values stored in a memory location. The code selector compares the expression of a second code sequence with the code sequences annotated by the tags of expression values currently stored in memory. If the second code sequence matches a sequence already associated with a memory location, then the value of the matched sequence is pushed from the memory location onto a stack, and the computations of the expression of the second code sequence is skipped. If the second expression does not match any of the expressions represented by the tags, the expression value of the second expression is calculated and stored in a memory location. This memory location is then annotated with its own expression tag for future comparisons with upcoming expressions in the code stream. |
| Inventors: | Lueh, Guei-Yuan (Santa Clara, CA); Adl-Tabatabai, Ali-Reza (Santa Clara, CA) |
| Assignees: | Intel Corporation (Santa Clara, CA) |
| Claim: | What is claimed is |
| Claim: | 1. A computer implemented method of optimizing code comprising |
| Claim: | loading a code stream into computer memory, said code stream comprising of a set of sequences of code; |
| Claim: | storing a first expression value for a first expression in a first memory location, said first expression comprising of a first sequence of code; |
| Claim: | tracking said first expression value by annotating said first memory location with a tag of said first expression; |
| Claim: | performing a string compare of a second sequence of code with said first sequence of source; and |
| Claim: | replacing a second expression with said first expression value, said second expression comprising a second sequence of code, if said second sequence of code matches said first sequence of code, and omitting execution of said second sequence of code in code stream. |
| Claim: | 2. The method of claim 1 further comprising storing a second expression value for said second sequence in a second memory location if said second sequence of code does not match said first sequence of code, and annotating said second memory location with a tag of said second expression. |
| Claim: | 3. The method of claim 1 wherein said replacing comprises pushing said first expression value onto a stack. |
| Claim: | 4. The method of claim 1 wherein said code comprises of Java byte codes. |
| Claim: | 5. The method of claim 1 wherein said memory location comprises of a processor register. |
| Claim: | 6. The method of claim 1 wherein said memory location comprises of a stack. |
| Claim: | 7. The method of claim 1 wherein said comparing comprises a string compare of code sub-sequences. |
| Claim: | 8. A method of eliminating common subexpressions during computer code generation comprising |
| Claim: | performing a string compare of a second expression with said first expression, said second expression comprising of a second sequence of code; and |
| Claim: | using said first expression value for said second expression if said second expression matches said first expression, and skipping over said second sequence of code in said code stream. |
| Claim: | 9. The method of claim 8 further comprising tracking said first expression value by annotating said first memory location with a tag of said first expression. |
| Claim: | 10. The method as claimed in claim 8 further comprising storing a second expression value for said second sequence in a second memory location if said second expression does not match said first expression, and annotating said second memory location with a tag of said second expression. |
| Claim: | 11. The method of claim 8 wherein said using said first expression value comprises pushing said first expression value onto a stack if said second expression matches said first expression, and skipping over said second sequence of source code in code stream. |
| Claim: | 12. The method of claim 9 further comprising storing a second expression comprising of said second sequence in a second memory location if said second sequence of code does not match said tag of first expression, and annotating said second memory location with a tag of said second expression. |
| Claim: | 13. The method as claimed in claim 9 wherein said using said first expression value comprises pushing said first expression value onto a stack if said second sequence of code matches code sequence annotated by said tag of said first expression, and skipping over said second sequence of code in code stream. |
| Claim: | 14. The method of claim 8 wherein said code comprises of Java byte codes. |
| Claim: | 15. The method of claim 8 wherein said memory location comprises of a processor register. |
| Claim: | 16. The method of claim 8 wherein said memory location comprises of a stack. |
| Claim: | 17. A computer readable medium having embodied thereon a computer program, the computer program being executable by a machine to perform a method comprising |
| Claim: | tracking said first expression value by annotating said first memory location with a tag of said first expression; and |
| Claim: | performing a string compare of a second expression with said first expression, said second expression comprising of a second sequence of code. |
| Claim: | 18. The computer readable medium having embodied thereon a computer program of claim 17, the computer program being executable by a machine to further perform |
| Claim: | replacing an expression value for said second expression with said first expression value if said second expression matches said first expression, and skipping over said second sequence of code in said code stream; and |
| Claim: | storing a second expression value for said second expression in a second memory location if said second expression does not match said first expression, and annotating said second memory location with a tag of said second expression. |
| Claim: | 19. The computer readable medium having embodied thereon a computer program of claim 17, the computer program being executable by a machine to further perform |
| Claim: | replacing an expression value for said second sequence with said first expression value if said second sequence of code matches said first sequence of source code, and skipping over said second sequence of code in said code stream; and |
| Claim: | storing a second expression value for said second sequence in a second memory location if said second sequence of code does not match said first sequence of code, and annotating said second memory location with a tag of said second expression. |
| Claim: | 20. The computer program of claim 17 wherein said code comprises of Java byte codes. |
| Claim: | 21. A digital processing system having a processor operable to perform the steps of |
| Claim: | performing a string compare a second expression with said first expression, said second expression comprising of a second sequence of code. |
| Claim: | 22. The digital processing system of claim 21 operable to further perform the steps |
| Claim: | pushing said first expression value onto a stack if said second expression matches said first expression, and skipping over said second sequence of code in said code stream; and |
| Claim: | 23. The digital processing system of claim 21 operable to further perform the steps |
| Claim: | pushing said first expression value onto a stack if said second sequence code matches said first sequence of code, and skipping over said second sequence of code in said code stream; and |
| Claim: | 24. The digital processing system of claim 21 wherein said code comprises of Java byte codes. |
| Claim: | 25. A method of eliminating common subexpressions comprising |
| Claim: | loading a set of bytecode sequences into computer memory; |
| Claim: | generating a first expression value for a first bytecode sequence; |
| Claim: | storing said first expression value in a first memory location; |
| Claim: | tracking said first expression value by annotating said first memory location with a tag of said first bytecode sequence; |
| Claim: | performing a string compare of a second bytecode sequence with said first bytecode sequence; and |
| Claim: | replacing said second bytecode sequence with said first expression value if said second bytecode sequence matches said first bytecode sequence. |
| Claim: | 26. The method of claim 25 further comprising |
| Claim: | generating a second expression value for said second bytecode sequence if said second bytecode sequence does not match said first bytecode sequence; |
| Claim: | storing said second expression value in a second memory location; and |
| Claim: | annotating said second memory location with a tag of said second bytecode sequence. |
| Claim: | 27. The method of claim 25 wherein said replacing comprises pushing said first expression value onto a stack and marking said first expression value as equivalent to a result of said second bytecode sequence. |
| Claim: | 28. The method of claim 25 wherein said memory location comprises of a register. |
| Claim: | 29. The method of claim 25 wherein said memory location comprises of a stack. |
| Current U.S. Class: | 717/9 |
| Current International Class: | G06F 945 |
| Patent References Cited: | 4642764 February 1987 Auslander et al. 4656583 April 1987 Auslander et al. 5367685 November 1994 Gosling 5396631 March 1995 Hayashi et al. 5481708 January 1996 Kukol 5535391 July 1996 Hejlsberg et al. 5644709 July 1997 Austin 5668999 September 1997 Gosling 5713010 January 1998 Buzbee et al. 5790867 August 1998 Schmidt et al. 6002879 December 1999 Radigan et al. |
| Other References: | Deodhar, R.; "Optimizing Compiler Technology Streamlines Complex Systems", Electronic Design, vol. 45, Iss 9, pp. 153, May 1997. Cramer et al.; "Compiling Just In Time", IEEE Micro, vol. 17, Iss 3, pp. 36-43, May 1997. Pollock et al.; "Incremental Global Reoptimization of Programs". ACM Transactions on Programming Languages and Systems, vol. 14, No. 2, pp. 173-200, Apr. 1992. Lambright, H.D.; "Java Bytecode Optimizations". Proceedings of the 1997 COMPCON, pp. 206-210, Feb. 1997. Gupta et al.; "Magic-sets Transformation in Nonrecursive Systems". Proceedings of the eleventh ACM SIGACT-SIGMOD-SIGART symposium on Principles of database systems, pp. 354, Jun. 1992. Bacon et al.; "Compiler Transformations for High-Performance Computing", ACM Digital Library[online]. ACM Computing Surveys, vol. 26, No. 4, Dec. 1994. Tyma, P.; "Tuning Java Performance". Dr. Dobb's Journal, vol. 21, No. 4, pp. 52-58, Apr. 1996. Cierniak et al.; "Briki: an optimizing Java compiler", IEEE/IEE Electronic Library [online]. Proceedings of IEEE Compcon '97, pp. 179-184, Feb. 1997. Bell, D.; "Make Java fast: Optimize!", JavaWorld[online]. Acessed from internet on Jun. 22, 1999. Retrieved from: Apr. 1997. Hsieh et al.; "Compilers for improved Java Performance", IEEE/IEE Electronic Library [online]. Computer, vol. 30, Iss. 6, pp. 67-75, Jun. 1997. Armstrong, E.; "HotSpot: A new breed of virtual machine", Javaworld [online]. Accessed on Jun. 22, 1999. Retrieved from:Mar. 1998. Jensen et al.; "Security and Dynamic Class Loading in Java: a Formalisation". IEEE/IEE Electronic Library [online], May 1998. Aho et al.; Compilers, Principles, Techniques, and Tools. Addison-Wesley Publishing Company, Reading, MA. Chapters 9 and 10, Dec. 1985. Lindholm et al.; The Java Virtual Machine Specification. Addison-Wesley Publishing Company, Reading, MA. Chapters 2-4, Sep. 1996. James Gosling, et al., The Java Language Specification, Published by Addison-Wesley, 1996, pp. 29-49, Sep. 1996. Tim Lindholm, et al., The Java Virtual Machine Specification, Published by Addison-Wesley, 1997, pp. 57-82, Sep. 1996. Alfred V. Aho, et al., Compilers-Principles, Techniques, and Tools, Published by Addison-Wesley, 1988, pp. 1-24, Sep. 1985. Steven S. Muchnick, Advanced Compiler Design & Implementation, Published by Morgan Kaufmann, 1997, pp. 1-18, 319-328 and pp. 377-396, Aug. 1997. Douglas Kramer, The Java Platform-A White Paper, Published by Javasoft, 1996, pp. 6-24, May 1996. |
| Primary Examiner: | Hafiz, Tariq R. |
| Assistant Examiner: | Booker, Kelvin E. |
| Attorney, Agent or Firm: | Blakely, Sokoloff, Taylor & Zafman LLP |
| Accession Number: | edspgr.06158048 |
| Database: | USPTO Patent Grants |
| Abstract: | Compilers are tools that generate efficient mappings from programs to machines. A Java "Just-In-Time" runs as part of an application, and as such, it must be fast and efficient in its use of memory. To achieve good performance and further optimize code generation, the present invention introduces a method for eliminating common subexpressions from Java bytecodes. The method of the present invention first loads a code stream containing sequences of computer code into computer memory. The expression value for a first expression of a first code sequence is computed and stored in a memory location. A tag is assigned to the memory location holding this expression value for tracking which expression sequences' values are held in memory locations. As code compilation continues, the code selector looks ahead in the code stream to see if any upcoming expression sequences already have expression values stored in a memory location. The code selector compares the expression of a second code sequence with the code sequences annotated by the tags of expression values currently stored in memory. If the second code sequence matches a sequence already associated with a memory location, then the value of the matched sequence is pushed from the memory location onto a stack, and the computations of the expression of the second code sequence is skipped. If the second expression does not match any of the expressions represented by the tags, the expression value of the second expression is calculated and stored in a memory location. This memory location is then annotated with its own expression tag for future comparisons with upcoming expressions in the code stream. |
|---|