Source code optimization
A computer implemented method optimizes source code. A processor set receives a source code in a first version. The processor set compiles the source code in the first version to generate an intermediate representation for the source codes in the first version. The processor set compares the intermediate representation for the source code in the first version to a number of optimization paths. The processor set identifies a number of matches based on the comparisons. The processor set updates at least a portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version.
1 . A computer implemented method for optimizing source code, the computer implemented method comprising:
receiving, by a processor set, a source code in a first version;
compiling, by the processor set, the source code in the first version to generate an intermediate representation for the source code in the first version;
comparing, by the processor set, the intermediate representation for the source code in the first version to a number of optimization paths, wherein the number of optimization paths are data structures that comprise information for converting the source code in the first version to the source code in a second version, and wherein the number of optimization paths are stored as mappings between fragments of the intermediate representation and corresponding portions of the source code in the second version of the source code in an optimization path library;
identifying, by the processor set, a number of matches based on the comparisons, wherein each match from the number of matches comprises a fragment of the intermediate representation and corresponding portion of the source code in the second version for the fragment of the intermediate representation based on an optimization path from the number of optimization paths stored in the optimization path library; and
updating, by the processor set, at least a portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version.
2 . The computer implemented method of claim 1 further comprising:
tagging, by the processor set, the portion of the source code in the first version based on the number of matches for review.
3 . The computer implemented method of claim 1 , wherein the updating, by the processor set, the at least the portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version comprises:
presenting, by the processor set, the number of matches in a graphical user interface;
selecting, by the processor set based on a user input, a subset of matches from the number of matches; and
updating, by the processor set, the at least the portion of the source code in the first version to the second version based on the selected subset of matches to generate the source code in the second version.
4 . The computer implemented method of claim 1 , wherein the identifying, by the processor set, the number of matches based on the comparisons comprises:
organizing, by the processor set, the number of optimization paths in a hierarchical manner such that the identification for the number of matches is proceeded from first optimization paths from the number of optimization paths to a last optimization from the number of optimization paths; and
terminating, by the processor set, the identification for the number of matches upon identifying a first match.
5 . The computer implemented method of claim 1 , wherein the comparing, by the processor set, the intermediate representation for the source code in the first version to the number of optimization paths comprises:
comparing, by the processor set, each section of the intermediate representation to each optimization path from the number of optimization paths.
6 . The computer implemented method of claim 1 , wherein the intermediate representation and the number of optimization paths are in the same syntax specified by a complier vendor.
7 . The computer implemented method of claim 1 , wherein the intermediate representation excludes information related to variable names in the source code in the first version.
8 . A computer system comprising:
a processor set;
a set of one or more computer-readable storage media; and
program instructions, collectively stored in the set of one or more computer-readable storage media, for causing the processor set to:
receive a source code in a first version;
compile the source code in the first version to generate an intermediate representation for the source code in the first version;
compare the intermediate representation for the source code in the first version to a number of optimization paths, wherein the number of optimization paths are data structures that comprise information for converting the source code in the first version to the source code in a second version, and wherein the number of optimization paths are stored as mappings between fragments of the intermediate representation and corresponding portions of the source code in the second version of the source code in an optimization path library;
identify a number of matches based on the comparisons, wherein each match from the number of matches comprises a fragment of the intermediate representation and corresponding portion of the source code in the second version for the fragment of the intermediate representation based on an optimization path from the number of optimization paths stored in the optimization path library; and
update at least a portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version.
9 . The computer system of claim 8 , wherein the program instructions, collectively stored in the set of one or more storage media, cause the processor set to:
tag the portion of the source code in the first version based on the number of matches for review.
10 . The computer system of claim 8 , wherein as part of the updating the at least the portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version, the program instructions, collectively stored in the set of one or more storage media, cause the processor set to:
present the number of matches in a graphical user interface;
select a subset of matches from the number of matches based on a user input; and
update the at least the portion of the source code in the first version to the second version based on the selected subset of matches to generate the source code in the second version.
11 . The computer system of claim 8 , wherein as part of the identifying the number of matches based on the comparisons, the program instructions, collectively stored in the set of one or more storage media, cause the processor set to:
organize the number of optimization paths in a hierarchical manner such that the identification for the number of matches is proceeded from first optimization paths from the number of optimization paths to a last optimization from the number of optimization paths;
and terminate the identification for the number of matches upon identifying a first match.
12 . The computer system of claim 8 , wherein the comparing the intermediate representation for the source code in the first version to the number of optimization paths, the program instructions, collectively stored in the set of one or more storage media, cause the processor set to:
compare each section of the intermediate representation to each optimization path from the number of optimization paths.
13 . The computer system of claim 8 , wherein the intermediate representation and the number of optimization paths are in the same syntax specified by a complier vendor.
14 . The computer system of claim 8 , wherein the intermediate representation excludes information related to variable names in the source code in the first version.
15 . A computer program product for optimizing source code, the computer program product comprising:
a set of one or more computer-readable storage media; and
program instructions, collectively stored in the set of one or more computer-readable storage media, for causing a processor set to:
receive source code in a first version;
compile the source code in the first version to generate an intermediate representation for the source code in the first version;
compare the intermediate representation for the source code in the first version to a number of optimization paths, wherein the number of optimization paths are data structures that comprise information for converting the source code in the first version to the source code in a second version, and wherein the number of optimization paths are stored as mappings between fragments of the intermediate representation and corresponding portions of the source code in the second version of the source code in an optimization path library;
identify a number of matches based on the comparisons, wherein each match from the number of matches comprises a fragment of the intermediate representation and corresponding portion of the source code in the second version for the fragment of the intermediate representation based on an optimization path from the number of optimization paths stored in the optimization path library; and
update at least a portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version.
16 . The computer program product of claim 15 , wherein program instructions, collectively stored in the set of one or more storage media further cause the processor set to:
tag the portion of the source code in the first version based on the number of matches for review.
17 . The computer program product of claim 15 , wherein as part of the updating the at least the portion of the source code in the first version to the second version based on the number of matches to generate the source code in the second version, the program instructions cause the processors set to:
present the number of matches in a graphical user interface;
select a subset of matches from the number of matches based on a user input; and
update the at least the portion of the source code in the first version to the second version based on the selected subset of matches to generate the source code in the second version.
18 . The computer program product of claim 15 , wherein as part of the identifying the number of matches based on the comparisons, the program instructions cause the processors set to:
organize the number of optimization paths in a hierarchical manner such that the identification for the number of matches is proceeded from first optimization paths from the number of optimization paths to a last optimization from the number of optimization paths; and
terminate the identification for the number of matches upon identifying a first match.
19 . The computer program product of claim 15 , wherein the comparing the intermediate representation for the source code in the first version to the number of optimization paths, the program instructions cause the processors set to:
compare each section of the intermediate representation to each optimization path from the number of optimization paths.
20 . The computer program product of claim 15 , wherein the intermediate representation and the number of optimization paths are in the same syntax specified by a complier vendor.