Method for compiling program components in a mixed static and dynamic environment
First Claim
1. A method, in a mixed static and dynamic environment, for a virtual machine in which statically precompiled code may be securely executed by a virtual machine by means of a compiler or code generator, the method comprising the steps of:
- a) saving pre-compiled programs, including determining where to place said programs, annotating the programs with dependent information, annotating the programs with dependence information, and processing the programs to produce a further annotated executable code with annotations to help adapt the code to a new executable environment;
b) verifying that an intermediate code representation of the program is safe;
c) forming a secure hash describing the precompiled code;
d) forming a secure hash describing the intermediate code representation;
e) digitally signing the secure hashes of the precompiled code and the intermediate code representation;
the executing virtual machine reuses the precompiled code and the intermediate code representation byf) verifying that the secure hash of the intermediate code representation matches the digitally signed secure hash for the intermediate code representation;
g) verifying that the secure hash of the precompiled code matches the digitally signed secure hash for the precompiled code; and
h) loading and executing the precompiled code;
wherein the step of annotating the programs with dependence information includes the steps of annotating the programs with fine-grain dependencies, and processing said fine-grain dependencies by a dependence granularity adjuster to replace some fine-grain dependencies by coarser-grain dependencies to produce a final list of dependence annotations.
1 Assignment
0 Petitions
Accused Products
Abstract
This invention describes a method and several variants for compiling programs or components of programs in a mixed static and dynamic environment, so as to reduce the amount of time and memory spent in run-time compilation, or to exercise greater control over testing of the executable code for the program, or both. The invention involves generating persistent code images prior to program execution based on static compilation or dynamic compilation from a previous run, and then, adapting those images during program execution. We describe a method for generating auxiliary information in addition to the executable code that is recorded in the persistent code image. Further, we describe a method for checking the validity of those code images, adapting those images to the new execution context, and generating new executable code to respond to dynamic events, during program execution. Our method allows global interprocedural optimizations to be performed on the program, even if the programming language supports, or requires, dynamic binding. Variants of the method show how one or several of the features of the method may be performed. The invention is particularly useful in the context of implementing Java Virtual Machines, although it can also be used in implementing other programming languages.
118 Citations
8 Claims
-
1. A method, in a mixed static and dynamic environment, for a virtual machine in which statically precompiled code may be securely executed by a virtual machine by means of a compiler or code generator, the method comprising the steps of:
-
a) saving pre-compiled programs, including determining where to place said programs, annotating the programs with dependent information, annotating the programs with dependence information, and processing the programs to produce a further annotated executable code with annotations to help adapt the code to a new executable environment; b) verifying that an intermediate code representation of the program is safe; c) forming a secure hash describing the precompiled code; d) forming a secure hash describing the intermediate code representation; e) digitally signing the secure hashes of the precompiled code and the intermediate code representation;
the executing virtual machine reuses the precompiled code and the intermediate code representation byf) verifying that the secure hash of the intermediate code representation matches the digitally signed secure hash for the intermediate code representation; g) verifying that the secure hash of the precompiled code matches the digitally signed secure hash for the precompiled code; and h) loading and executing the precompiled code; wherein the step of annotating the programs with dependence information includes the steps of annotating the programs with fine-grain dependencies, and processing said fine-grain dependencies by a dependence granularity adjuster to replace some fine-grain dependencies by coarser-grain dependencies to produce a final list of dependence annotations. - View Dependent Claims (2, 3, 4, 5)
-
-
6. A method, in a mixed static and dynamic environment, for linking separately statically, precompiled code at run-time within a virtual machine by modifying the code, the method comprising the steps of
using a compiler to perform the steps of a) saving pre-compiled programs, including determining where to place said programs, annotating the programs with dependent information, annotating the programs with dependence information, and processing the programs to produce a further annotated executable code with annotations to help adapt the code to a new executable environment; -
b) maintaining symbolic entries for externally referenced symbols; and c) maintaining a mapping from locations in the precompiled code that reference external symbols to the symbolic entry for that symbol; and the virtual machine, before the code is executed, performs the steps of d) using the mapping and symbolic entries created by the compiler to generate direct references in the precompiled code to the externally referenced symbols that have been resolved by the virtual machine; and e) performing a given default action on those external symbols that have not been resolved, wherein the step of annotating the pro as with dependence information includes the steps of annotating the programs with fine-grain dependencies, and processing said fine-grain dependencies by a dependence granularity adjuster to replace some fine-grain dependencies by coarser-grain dependencies to produce a final list of dependence annotations.
-
-
7. A method, in a mixed static and dynamic environment, for updating statically generated precompiled code (C), at run-time, when separately compiled code (S), which contained symbols referenced by C changes, the method comprising the steps of:
-
saving pre-compiled programs, including determining where to place said programs, annotating the programs with dependent information, annotating the programs with dependence information, and processing the programs to produce a further annotated executable code with annotations to help adapt the code to a new executable environment; having a compiler generating the code for S to a) associate with method and data names, or signatures, in S a secure hash of the name of the method and data names or signatures in S with the compiler for C recording the secure hash for the byte code corresponding to any S that affects the code generated for C; and having the virtual machine executing C to b) check if any byte codes associated with any names in the S relied upon by C have changed by comparing the secure hash of the names associated with S with the secure hash stored for this byte code in C, and c) dynamically recompile the byte codes associated with C if any byte codes associated with S have changed; wherein the step of annotating the programs with dependence information includes the steps of annotating the programs with fine-grain dependencies, and processing said fine-grain dependencies by a dependence granularity adjuster to replace some fine-grain dependencies by coarser-grain dependencies to produce a final list of dependence annotations.
-
-
8. A method, in a mixed static and dynamic environment, for maintaining full compliance with a language requiring dynamic compilation without requiring the overhead of a just-in-time compiler to be present in the virtual machine, while enabling the use of statically generated precompiled code (C) for some byte code that depends on some byte code (S) that may be separately compiled,
saving pre-compiled programs, including determining where to place said programs, annotating the programs with dependent information, annotating the programs with dependence information, and processing the programs to produce a further annotated executable code with annotations to help adapt the code to a new executable environment; -
having a compiler generating code for S a) associate with S a secure hash of the byte code associated with S; having the compiler for C to b) record the secure hash for the byte code corresponding to any S that affects the code generated for C; and having the virtual machine executing C to c) check if any byte codes associated with any code S relied upon by C have changed by comparing the secure hash of the byte code associated with S with the secure hash stored for this byte code with C; and d) interpret the byte codes corresponding to C; wherein the step of annotating the programs with dependence information includes the steps of annotating the programs with fine-grain dependencies, and processing said fine-grain dependencies by a dependence granularity adjuster to replace some fine-grain dependencies by coarser-grain dependencies to produce a final list of dependence annotations.
-
Specification