Partial evaluation of single execution methods
Systems and methods implement partial evaluation of single execution methods. A native image is built from a build image compiled from source code. At image build time, a single execution method of the build image is executed to update an image heap of the native image. The single execution method is executed with a single execution for a native instance. The image heap is stored to the native image built from the build image.
1 . A method comprising:
building a native image from a build image compiled from source code;
executing, at image build time, a single execution method of the build image to update an image heap of the native image, wherein the single execution method is executed with a single execution for a native instance;
identifying, in the native image, the single execution method as partially evaluated at the image build time, wherein execution of the single execution method is halted to save a current state of an instantiation of the build image during image build time and the native instance resumes execution of the single execution method at runtime using the current state; and
storing the image heap to the native image built from the build image.
2 . The method of claim 1 , further comprising:
initializing, at runtime, a runtime heap from the image heap for the native image.
3 . The method of claim 1 , further comprising:
wherein the single execution of the single execution method is performed during one or more of the image build time and runtime.
4 . The method of claim 1 , further comprising:
executing the single execution method as part of a class, of a set of classes, wherein initialization of the class at the image build time is conditioned upon initialization of a different class at the image build time of the set of classes.
5 . The method of claim 1 , further comprising:
executing the single execution method, wherein the single execution method is a class initializer of a class.
6 . The method of claim 1 , further comprising:
executing, for the single execution, the single execution method once without a subsequent execution.
7 . The method of claim 1 , further comprising:
identifying a class, comprising the single execution method, as partially initialized at image build time after the execution of the single execution method encounters an unresolvable dependency.
8 . The method of claim 1 , further comprising:
identifying a class, comprising the single execution method, as initialized at image build time after allocating one or more objects to the image heap.
9 . The method of claim 1 , further comprising:
executing a remaining portion of the single execution method at runtime using the image heap.
10 . The method of claim 1 , further comprising:
unrolling a loop as part of executing the single execution method.
11 . The method of claim 1 , further comprising:
receiving the build image compiled from the source code, wherein the source code comprises a class definition; and
processing the build image, comprising the single execution method, to generate the native image, comprising the image heap.
12 . The method of claim 1 , further comprising:
executing the native image using the image heap, wherein the native image corresponds to an operating system and a hardware architecture.
13 . A system comprising:
at least one processor;
at least one memory coupled to the processor; and
an application executing on the processor and configured for:
building a native image from a build image compiled from source code;
executing, at image build time, a single execution method of the build image to update an image heap of the native image, wherein the single execution method is executed with a single execution for a native instance;
identifying, in the native image, the single execution method as partially evaluated at the image build time, wherein execution of the single execution method is halted to save a current state of an instantiation of the build image during image build time and the native instance resumes execution of the single execution method at runtime using the current state; and
storing the image heap to the native image built from the build image.
14 . The system of claim 13 , wherein the application is further configured for:
initializing, at runtime, a runtime heap from the image heap for the native image.
15 . The system of claim 13 , wherein the application is further configured for:
wherein the single execution of the single execution method is performed during one or more of the image build time and runtime.
16 . The system of claim 13 , wherein the application is further configured for:
executing the single execution method as part of a class, of a set of classes, wherein initialization of the class at the image build time is conditioned upon initialization of a different class at the image build time of the set of classes.
17 . The system of claim 13 , wherein the application is further configured for:
executing the single execution method, wherein the single execution method is a class initializer of a class.
18 . The system of claim 13 , wherein the application is further configured for:
executing, for the single execution, the single execution method once without a subsequent execution.
19 . The system of claim 13 , wherein the application is further configured for:
identifying a class, comprising the single execution method, as partially initialized at image build time after the execution of the single execution method encounters an unresolvable dependency.
20 . A method comprising:
receiving a native image, wherein the native image is generated by:
building the native image from a build image compiled from source code;
executing, at image build time, a single execution method of the build image to update an image heap of the native image, wherein the single execution method is executed with a single execution for a native instance;
identifying, in the native image, the single execution method as partially evaluated at the image build time, wherein execution of the single execution method is halted to save a current state of an instantiation of the build image during image build time and the native instance resumes execution of the single execution method at runtime using the current state; and
storing the image heap to the native image built from the build image;
initializing, at runtime, a runtime heap from the image heap for the native image; and
executing the native image as the native instance.