Method and apparatus for resolving data references in generated code

- Sun Microsystems, Inc.

A hybrid compiler-interpreter comprising a compiler for "compiing" source program code, and an interpreter for interpreting the "compiled" code, is provided to a computer system. The compiler comprises a code generator that generates code in intermediate form with data references made on a symbolic basis. The interpreter comprises a main interpretation routine, and two data reference handling routines, a dynamic field reference routine for handling symbolic references, and a static field reference routine for handling numeric references. The dynamic field reference routine, when invoked, resolves a symbolic reference and rewrites the symbolic reference into a numeric reference. After rewriting, the dynamic field reference routine returns to the main interpretation routine without advancing program execution to the next instruction thereby allowing the rewritten instruction with numeric reference to be reexecuted. The static field reference routine, when invoked, obtain data for the program from a data object based on the numeric reference. After obtaining data, the static field reference routine advances program execution to the next instruction before returning to the interpretation routine. The main interpretation routine selectively invokes the two data reference handling routines depending on whether the data reference in an inspection is a symbolic or a numeric reference.

Skip to:  ·  Claims  ·  References Cited  · Patent History  ·  Patent History

Claims

1. In a computer system comprising a program in source code form, a method for generating executable code for said program and resolving data references in said generated code, said method comprising the steps of:

a) generating executable code in intermediate form for said program in source code form with data references being made in said generated code on a symbolic basis, said generated code comprising a plurality of instructions of said computer system;
b) interpreting said instructions, one at a time, in accordance to a program execution control;
c) resolving said symbolic references to corresponding numeric references, replacing said symbolic references with their corresponding numeric references, and continuing interpretation without advancing program execution, as said symbolic references are encountered while said instructions are being interpreted; and
d) obtaining data in accordance to said numeric references, and continuing interpretation after advancing program execution, as said numeric references are encountered while said instruction are being interpreted;
said steps b) through d) being performed iteratively and interleavingly.

2. The method as set forth in claim 1, wherein, said program in source code form is implemented in source code form of an object oriented programming language.

3. The method as set forth in claim 2, wherein, said programming language is C.

4. The method as set forth in claim 2, wherein, said programming language is C++.

5. The method as set forth in claim 1, wherein,

said program execution control is a program counter;
said continuing interpretation in step c) is achieved by performing said step b) after said step c) without incrementing said program counter; and
said continuing interpretation in said step d) is achieved by performing said step b) after said d) after incrementing said program counter.

6. In a computer system comprising a program in source code form, an apparatus for generating executable code for said program and resolving data references in said generated code, said apparatus comprising:

a) compilation means for receiving said program in source code form and generating executable code in intermediate form for said program in source code form with data references being made in said generated code on a symbolic basis, said generated code comprising a plurality of instructions of said computer system;
b) interpretation means for receiving said generated code and interpreting said instructions, one at a time;
c) dynamic reference handling means coupled to said interpretation means for resolving said symbolic references to corresponding numeric references, replacing said symbolic references with their corresponding numeric references, and continuing interpretation by said interpretation means without advancing program execution, as said symbolic references are encountered while said instructions are being interpreted by said interpretation means; and
d) static reference handling means coupled to said interpretation means for obtaining data in accordance to said numeric references, and continuing interpretation by said interpretation means after advancing program execution, as said numeric references are encountered while said instruction are being interpreted by said interpretation means;
said interpretation means, said dynamic reference handling means, and said static reference handling means performing their corresponding functions iteratively and interleavingly.

7. The apparatus as set forth in claim 6, wherein, said program in source code form is implemented in source code form of an object oriented programming language.

8. The apparatus as set forth in claim 7, wherein, said programming language is C.

9. The apparatus as set forth in claim 7, wherein sad programming language is C++.

10. The apparatus as set forth in claim 6, wherein, said program execution control is a program counter..Iadd.

11. A method for interpreting software in intermediate form code, said intermediate form code comprising instructions, certain of said instructions containing one or more symbolic references, said method comprising the steps of:

interpreting said instructions in accordance with a program execution control;
operative when an instruction being interpreted contains an unresolved symbolic reference, resolving said unresolved symbolic reference, said step of resolving said unresolved symbolic reference including substeps of:
determining a numerical value corresponding to said unresolved symbolic reference, and
storing said numerical value in a memory; and
operative when an instruction being interpreted contains a resolved symbolic reference, interpreting said instruction by reading said stored numerical value..Iaddend..Iadd.12. The method of claim 11, where said substep of storing said numerical value comprises the substep of storing said numerical value in said instruction containing an unresolved symbolic reference..Iaddend..Iadd.13. The method of claim 12, where said substep of storing said numerical value in said instruction comprises the substep of replacing said unresolved symbolic reference with said numerical value.

.Iaddend..Iadd.14. The method of claim 12, where said step of resolving said unresolved symbolic reference further comprises the substep of interpreting said instruction containing an unresolved symbolic reference following said substep of storing said numerical value in said instruction containing a symbolic reference..Iaddend..Iadd.15. The method of claim 14, where said step of resolving said unresolved symbolic reference further comprises the substep of advancing said program execution control only after said substep of interpreting said instruction containing an unresolved symbolic reference..Iaddend..Iadd.16. The method of claim 11, where said unresolved symbolic reference is a data reference..Iaddend..Iadd.17. The method of claim 11, where said unresolved symbolic reference is a reference to a field in a data object..Iaddend..Iadd.18. The method of claim 11, where the source code of said software comprises code written in a non-object-oriented programming language..Iaddend..Iadd.19. The method of claim 11, where the source code of said software comprises code written in an object-oriented programming

language..Iaddend..Iadd.20. The method of claim 11, where said program execution control comprises a program counter..Iaddend..Iadd.21. The method of claim 11, where said instruction containing an unresolved symbolic reference comprises one or more machine instructions of said computer..Iaddend..Iadd.22. A method for compiling software into intermediate form code, said method comprising the steps of:

lexically analyzing source code of said software,
parsing output of said lexical analysis step,
building an intermediate representation from said parsed output, and
generating intermediate form code containing symbolic field references from said intermediate representation..Iaddend..Iadd.23. The method of claim 22, where said symbolic field references comprise data references..Iaddend..Iadd.24. The method of claim 23, where said data references comprise references to fields within data objects..Iaddend..Iadd.25. In a computer, an apparatus for interpreting software in intermediate form code, said intermediate form code comprising instructions, certain of said instructions containing one or more symbolic references, said apparatus comprising:
a first device configured to interpret said instructions in accordance with a program execution control;
a second device configured, operative when an instruction being interpreted contains an unresolved symbolic reference, to resolve said unresolved symbolic reference, said second device comprising:
a third device configured to determine a numerical value corresponding to said unresolved symbolic reference, and
a fourth device configured to store said numerical value in a memory; and
a fifth device configured, operative when an instruction being interpreted contains a resolved symbolic reference, to interpret said instruction by

reading said stored numerical value..Iaddend..Iadd.26. An apparatus for compiling software into intermediate form code, said apparatus comprising:

a first device configured to lexically analyze the source code of said software,
a second device configured to parse output of said first device,
a third device configured to build an intermediate representation from said parsed output, and
a fourth device configured to generate intermediate form code containing symbolic field references from said intermediate representation..Iaddend..Iadd.27. A computer system, comprising a plurality of one or more interconnected computers, at least one of said plurality of computers comprising an apparatus for interpreting software in an intermediate form code, said intermediate form code comprising instructions, certain of said instructions containing one or more symbolic references, said apparatus comprising:
a first device configured to interpret said instructions in accordance with a program execution control;
a second device configured, operative when an instruction being interpreted contains an unresolved symbolic reference, to resolve said unresolved symbolic reference, said second device comprising:
a third device configured to determine a numerical value corresponding to said unresolved symbolic reference, and
a fourth device configured to store said numerical value in a memory of said at least one of said plurality of computers; and
a fifth device configured, operative when an instruction being interpreted contains a resolved symbolic reference, to interpret said instruction by reading said stored numerical value..Iaddend..Iadd.28. A computer system, comprising a plurality of one or more interconnected computers, at least one of said plurality of computers comprising an apparatus for compiling software into intermediate form code, said apparatus comprising:
a first device configured to lexically analyze the source code of said software,
a second device configured to parse the output of said device configured to lexically analyze,
a third device configured to build an intermediate representation from said parsed output, and
a fourth device configured to generate intermediate form code containing symbolic field references from said intermediate representation.

.Iaddend..Iadd.29. A computer program product comprising:

a computer readable medium having computer readable code embodied therein for interpreting software in an intermediate form code, said intermediate form code comprising instructions, certain of said instructions containing one or more symbolic references, said computer readable medium comprising:
a computer readable program code device configured to interpret said instructions in accordance with a program execution control;
a second computer readable program code device configured, operative when an instruction being interpreted contains an unresolved symbolic reference, to resolve said unresolved symbolic reference, said second computer readable program code device comprising:
a third computer readable program code device configured to determine a numerical value corresponding to said unresolved symbolic reference, and
fourth computer readable program code device configured to store said numerical value in a memory of said at least one of said plurality of computers; and
a fifth computer readable program code device configured, operative when an instruction being interpreted contains a resolved symbolic reference, to interpret said instruction by reading said stored numerical value.

.Iaddend..Iadd.30. A computer program product comprising:

a computer readable medium having computer readable code embodied therein for compiling software into intermediate form code, said computer readable medium comprising:
a first computer readable program code device configured to lexically analyze source code of said software,
a second computer readable program code device configured to parse the output of said first computer readable program code device,
a third computer readable program code device configured to build an intermediate representation of said parsed output, and
a fourth computer readable program code device configured to generate intermediate form code containing symbolic field references from said intermediate representation..Iaddend..Iadd.31. A system for distributing code stored on a computer readable medium, said code comprising computer readable code for interpreting software in an intermediate form code, said intermediate form code comprising instructions, certain of said instructions containing one or more symbolic references, said computer readable medium comprising:
a computer readable program code device configured to interpret said instructions in accordance with a program execution control;
a second computer readable program code device configured, operative when an instruction being interpreted contains an unresolved symbolic reference, to resolve said unresolved symbolic reference, said second computer readable program code device comprising:
a third computer readable program code device configured to determine a numerical value corresponding to said unresolved symbolic reference, and
a fourth computer readable program code device configured to store said numerical value in a memory of said at least one of said plurality of computers; and
a fifth computer readable program code device configured, operative when an instruction being interpreted contains a resolved symbolic reference, to interpret said instruction by reading said stored numerical value..Iaddend..Iadd.32. A system for distributing code stored on a computer readable medium, said code comprising computer readable code for compiling software into intermediate form code, said computer readable medium comprising:
a first computer readable program code device configured to lexically analyze source code of said software,
a second computer readable program code device configured to parse the output of said first computer readable program code device,
a third computer readable program code device configured to build an intermediate representation of said parsed output, and
a fourth computer readable program code device configured to generate intermediate form code containing symbolic field references from said

intermediate representation..Iaddend..Iadd.33. A method for distributing code stored on a computer readable medium, said code comprising computer readable code for interpreting software in an intermediate form code, said intermediate form code comprising instructions, certain of said instructions containing one or more symbolic references, said computer readable medium comprising:

a computer readable program code device configured to interpret said instructions in accordance with a program execution control;
a second computer readable program code device configured, operative when an instruction being interpreted contains an unresolved symbolic reference, to resolve said unresolved symbolic reference, said second computer readable program code device comprising:
a third computer readable program code device configured to determine a numerical value corresponding to said unresolved symbolic reference, and
a fourth computer readable program code device configured to store said numerical value in a memory of said at least one of said plurality of computers; and
a fifth computer readable program code device configured, operative when an instruction being interpreted contains a resolved symbolic reference, to interpret said instruction by reading said stored numerical value,

.Iaddend..Iadd.34. A method for distributing code stored on a computer readable medium, said code comprising computer readable code for compiling software into intermediate form code, said computer readable medium comprising:

a first computer readable program code device configured to lexically analyze source code of said software,
a second computer readable program code device configured to parse the output of said first computer readable program code device,
a third computer readable program code device configured to build an intermediate representation of said parsed output, and
a fourth computer readable program code device configured to generate intermediate form code containing symbolic field references from said intermediate representation,

.Iaddend..Iadd.35. A computer implemented method for interpreting intermediate form code comprised of instructions, certain of said instructions containing one or more symbolic references, said method comprising the steps of:

interpreting said instructions in accordance with a program execution control; and
resolving a symbolic reference in an instruction being interpreted, said step of resolving said symbolic reference including the substeps of:
determining a numerical reference corresponding to said symbolic reference,

and storing said numerical reference in a memory..Iaddend..Iadd.36. The method of claim 35, wherein said substep of storing said numerical reference comprises the substep of replacing said symbolic reference with said numerical reference..Iaddend..Iadd.37. The method of claim 35, wherein said step of resolving said symbolic reference further comprises the substep of interpreting said instruction containing said symbolic reference using the stored numerical reference..Iaddend..Iadd.38. The method of claim 37, wherein said step of resolving said symbolic reference further comprises the substep of advancing said program execution control after said substep of interpreting said instruction containing said symbolic reference..Iaddend.

Referenced Cited
U.S. Patent Documents
4667290 May 19, 1987 Goss et al.
4729096 March 1, 1988 Larson
4773007 September 20, 1988 Kanada et al.
5201050 April 6, 1993 McKeeman et al.
5307492 April 26, 1994 Benson
5313614 May 17, 1994 Goettelmann et al.
Other references
  • Goldberg, Adele and Robson, David, "Smalltalk--80: The Language," ParcPlace Systems and Xerox PARC, Addison-Wesley Publishing Company, 1989, Chapter 21, pp. 417-442. Budd, Timothy, "A Little Smalltalk," Oregon State University, Addison-Wesley Publishing Company, 1987, Chapter 13, pp. 150-160, Chapter 14, pp. 161-175, Chapter 15, pp. 176-192. Chung, Kin-Man and Yuen, Herbert, "A `Tiny` Pascal Compiler: the P-Code Interpreter, " BYTE Publications, Inc., Sep. 1978. Chung, Kin-Man and Yuen, Herbert, "A `Tiny` Pascal Compiler: Part 2: The P-Compiler, " BYTE Publications, Inc. Oct. 1978. Thompson, Ken, "Regular Expression Search Algoritum," Communications of the ACM, vol. II, No. 6, p. 149 et seq., Jun. 1968. Mitchell, James G., Maybury, William, and Sweet, Richard, Mesa Language Manual, Xerox Corporation. McDaniel, Gene, "An Analysis of a Mesa Instruction Sets," Xerox Corporation, May 1982. Pier, Kenneth A., "A Retrospective on the Dorado, A High-Performance Personal Computer," Xerox Corporation, Aug. 1983. Pier, Kenneth A., "A Retrospective on the Dorado, A High-Performance Persopnal Computer," IEEE Conference Proceedings, The 10th Annual international Symposium on Computer Architecture, 1983.
Patent History
Patent number: RE36204
Type: Grant
Filed: Nov 21, 1996
Date of Patent: Apr 27, 1999
Assignee: Sun Microsystems, Inc. (Palo Alto, CA)
Inventor: James Gosling (Redwood City, CA)
Primary Examiner: Thomas M. Heckler
Law Firm: Finnegan, Henderson, Farabow, Garrett & Dunner, L.L.P.
Application Number: 8/755,764
Classifications
Current U.S. Class: 395/707
International Classification: G06F 945;