Just in time compilation using link time optimization
A first intermediate representation of a first portion of a source code implementing an application and a second intermediate representation of a second portion of the source code is received by a processing device. The first intermediate representation and the second intermediate representation is merged, at run-time, into a merged intermediate representation, wherein the first intermediate representation includes a reference to a function in the second intermediate representation. An execution flow transfer instruction within the merged intermediate representation is identified based on a run-time value of a parameter of the application. The execution flow transfer instruction references the function. A set of executable instructions implementing the function is identified within the merged intermediate representation. The execution flow transfer instruction is replaced with a copy of the set of executable instructions implementing the function.
1 . A method comprising:
generating, using a processing device, a merged intermediate representation of at least a portion of source code implementing an application, wherein the merged intermediate representation includes intermediate representations comprising parameterized functions, wherein parameterized functions are generated using a compiler before run-time or at run-time prior to the merging;
identifying one or more function calls within the merged intermediate representation that are to be performed conditionally based on application parameters at run-time;
determining, at run-time and based on evaluating values of application parameters, one or more functions to be called by the one or more function calls;
replacing the one or more function calls with one or more sets of executable instructions implementing the one or more functions, wherein to replace, at the run-time and based on the run-time values of application parameters, the one or more function calls, the one or more CPUs are to:
identify, within the merged intermediate representation, the one or more sets of executable instructions implementing the one or more functions; and
replace the one or more function calls with a copy of the one or more sets of executable instructions implementing the one or more functions.
2 . The method of claim 1 , wherein generating the merged intermediate representation of a source code implementing the application comprises receiving the intermediate representations comprising parameterized functions.
3 . The method of claim 1 , wherein an intermediate representation of the intermediate representations comprising parameterized functions references the one or more functions.
4 . The method of claim 1 , further comprising: executing the merged intermediate representation using the processing device.
5 . The method of claim 1 , wherein at least one of the generating or replacing is performed using an application programming interface (API) accessible by the processing device.
6 . A system comprising:
one or more central processing units (CPUs), executing instructions, to:
generate a merged intermediate representation of at least a portion of source code implementing an application, wherein the merged intermediate representation includes intermediate representations comprising parameterized functions, wherein parameterized functions are generated using a compiler before run-time or at run-time prior to the merging;
identify one or more function calls within the merged intermediate representation that are to be performed conditionally based on application parameters at runtime;
determine, at run-time and based on evaluating values of application parameters, one or more functions to be called by the one or more function calls;
replace the one or more function calls with one or more sets of executable instructions implementing the one or more functions, wherein to replace, at the run-time and based on the run-time values of application parameters, the one or more function calls, the one or more CPUs are to:
identify, within the merged intermediate representation, the one or more sets of executable instructions implementing the one or more functions; and
replace the one or more function calls with a copy of the one or more sets of executable instructions implementing the one or more functions.
7 . The system of claim 6 , wherein to generate the merged intermediate representation of a source code implementing the application, the one or more CPUs are to receive the intermediate representations comprising parameterized functions.
8 . The system of claim 6 , wherein an intermediate representation of the intermediate representations comprising parameterized functions references the one or more functions.
9 . The system of claim 6 , wherein the one or more CPUs are further to:
execute the merged intermediate representation.
10 . The system of claim 6 , wherein at least one of the generating or replacing is performed using an application programming interface (API) accessible by the one or more CPUs.
11 . A processing device comprising:
computer executable instruction stored in a memory which are executed by one or more processing units to:
generate a merged intermediate representation that includes intermediate representations comprising parameterized functions, wherein parameterized functions are generated using a compiler before run-time or at run-time prior to the merging and corresponds to at least a portion of source code implementing an application, to identify one or more function calls within the merged intermediate representation that are to be performed conditionally based on application parameters at run-time, to determine, at run-time and based on evaluating values of application parameters, one or more functions to be called by the one or more function calls, and to replace the one or more function calls with one or more sets of executable instructions implementing the one or more functions, wherein to replace the one or more function calls with the one or more sets of executable instructions, the one or more processing units are to:
identify, within the merged intermediate representation, the one or more sets of executable instructions implementing the one or more functions; and
replace the one or more function calls with a copy of the one or more sets of executable instructions implementing the one or more functions.
12 . The processing device of claim 11 , wherein to generate the merged intermediate representation, the one or more processing units are to receive the intermediate representations comprising parameterized functions.
13 . The processing device of claim 11 , wherein an intermediate representation of the intermediate representations comprising parameterized functions references the one or more functions.
14 . The processing device of claim 11 , wherein the one or more processing units are further to execute the merged intermediate representation.