Source Code Redundancy Reduction via Generalized Functions
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Compilers face inefficiencies in translating source code into target form due to the generation of large volumes of program code in intermediate formats, requiring significant time and computing resources.
Innovation Solution
The method involves identifying function groups with matching functions, generating a generalized function that implements the common algorithm, and creating wrapper functions to call the generalized function, thereby reducing the amount of code to be translated and processed.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Productivity
If an early translation stage generates a large volume of program code in intermediate format with many specialized functions, then the source code can be translated into the target form, but the subsequent translation stages require significant time and computing resources
Solution Approach 1:
The patent creates a generalized function that serves multiple original functions by implementing their common algorithm. This single generalized function replaces multiple specialized functions, reducing the overall volume of code that subsequent compilation stages must process, thereby decreasing computational resources and time required while maintaining the ability to serve multiple original functions
Solution Approach 2:
The patent merges multiple matching functions into a single generalized function that implements their shared algorithm. By combining these functions and creating wrapper functions that call the generalized function, the total code volume is reduced, which directly addresses the problem of excessive computational resources required in subsequent translation stages
2Productivity
If an early translation stage generates a large volume of program code in intermediate format, then the source code can be translated into the target form, but the amount of code to be processed in subsequent stages increases
Solution Approach 1:
The generalized function implements the common algorithm shared by multiple original functions, allowing a single function to serve multiple purposes. This reduces the total volume of program code in the intermediate format that needs to be processed in subsequent compilation stages, directly addressing the issue of excessive code volume
Solution Approach 2:
Instead of duplicating the common algorithm in multiple specialized functions, the patent creates one generalized function that contains the algorithm once, and uses wrapper functions to call it. This eliminates redundant code copies while preserving the functionality of all original functions
Data Source
AI summary
Processing program code can include comparing functions specified in program code to identify a function group including a plurality of matching functions. A generalized function can be generated, using a processor, for the function group that implements an algorithm common to each of the plurality of matching functions. For each function of the function group, a wrapper function associated with the function can be generated, wherein each wrapper function calls the generalized function. A version of the program code including the generalized function and the wrapper function in place of each function of the function group can be created.


