Static Call Graph Generation for Dynamic Languages
Find Innovative SolutionsGenerate Solutions
Solution Overview
Problem
Generating a precise static call graph for computer programs, especially those written in dynamically typed languages like Python, is challenging due to dynamic polymorphism, which makes name-based call graphs insufficient, and existing methods struggle to represent all possible invocation relationships accurately.
Innovation Solution
A method that abstracts computer code by eliminating flow-related instructions, generating a constraint system to infer possible types for entities, and using techniques like abstract interpretation to create a call graph that includes all possible invocation relationships, ensuring a sound representation of the program's control flow.
Engineering Contradictions & Design Principles
Engineering Contradiction Analysis
1Ease of manufacture
If a name-based call graph is used for dynamically typed languages, then the call graph generation is simple, but the precision is insufficient due to dynamic polymorphism
Solution Approach 1:
The patent changes the parameters used to identify method invocations from simple names to structured type information. By analyzing variable types and method signatures, the system can precisely match dynamic method calls to their definitions, resolving the precision issue while maintaining automated analysis.
Solution Approach 2:
The patent introduces type information as an intermediary between method names and their definitions. By using type analysis to mediate the matching process, the system can handle dynamic polymorphism accurately without requiring complex runtime instrumentation.
2Measurement precision
If a precise static call graph is generated for dynamically typed languages, then the analysis precision is improved, but the computational complexity increases
Solution Approach 1:
The patent segments the analysis into distinct phases: type inference, constraint generation, and call graph construction. By dividing the complex task of precise call graph generation for dynamically typed languages into manageable segments, the system reduces overall computational complexity while maintaining precision.
Solution Approach 2:
The patent performs preliminary type inference and constraint generation before constructing the call graph. By pre-computing type information and possible method invocations, the system simplifies the subsequent call graph construction phase, reducing the overall computational burden.
3Ease of manufacture
If flow-related instructions are eliminated during abstraction, then the constraint system generation is simplified, but the control flow information is lost
Solution Approach 1:
The patent extracts control flow information into separate constraints rather than eliminating it entirely. By taking out the essential control flow relationships and representing them as constraints on variable types and method invocations, the system simplifies the abstraction process while preserving necessary control flow information for accurate call graph generation.
Data Source
AI summary
A computer-implemented method, system and computer program product, the method comprising: obtaining computer code; abstracting the computer code to obtain abstracted computer code comprising a plurality of instructions; generating a constraint system, comprising one or more constraints on one or more entities of the abstracted computer code; obtaining a solution to the constraint system, the solution comprising one or more possible types for each entity; and creating a call graph based on the types of the entities.


