Static Call Graph Generation for Dynamic Languages

Resolve Bottlenecks,
Find Innovative Solutions
Generate 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

VSEngineering 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

Engineering Contradiction:
Improvecall graph generation simplicityVSAvoidcall graph precision
Core Design Contradiction:
Ease of manufactureVSMeasurement precision

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.

Inventive Principle:
Principle #35Parameter changes

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.

Inventive Principle:
Principle #24Intermediary (Mediator)

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

Engineering Contradiction:
Improvecall graph precisionVSAvoidanalysis complexity
Core Design Contradiction:
Measurement precisionVSDevice complexity

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.

Inventive Principle:
Principle #1Segmentation

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.

Inventive Principle:
Principle #10Preliminary action

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

Engineering Contradiction:
Improveconstraint system generation simplicityVSAvoidcontrol flow information
Core Design Contradiction:
Ease of manufactureVSLoss of information

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.

Inventive Principle:
Principle #2Taking out (Extraction)

Data Source

PatentUS11210087B2System and method for interprocedural analysis
Publication Date: 2021.12.28 WHITESOURCE LTD
  • US11210087B2 patent drawing
  • US11210087B2 patent drawing
  • US11210087B2 patent drawing

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.