Require the class hierarchy information (inheritance structure) of the whole program
Resolve a virtual call based on the declared type of receiver variable of the call site
Assume the receiver variable a may point to objects of class A or all subclasses of A(Resolve target methods by looking up the class hierarchy of class A)
对一个 call site 执行 Resolve 方法得到所有可能的 target methods 算法如下
如图所示一共有三种数据流分析应用分别为reaching definitions、live variables、available expressions、available expressions,不同的数据流分析有不同的 data abstraction和不同的 flow safe-approximation strategies,如不同的 transfer functions 和 control-flow handlings
Overview of Data Flow Analysis
Data Flow Analysis可以概括为:How Data Flows on CFG,展开来的英文就是 How application-specific Data Flows through the Nodes(BBs/statements) and Edges(control flows) of CFG(a program)?
How application-specific Data :对数据的抽象(data abstraction) e.g:+, -, 0 等
假定 x 有定值 d (definition),如果存在一个路径,从紧随 d 的点到达某点 p,并且此路径上面没有 x 的其他定值点,则称 x 的定值 d 可达 (reaching) p。如果在这条路径上有对 x 新的定值,我们说变量 x 的这个定值 d 被杀死 (killed) ,其实就是说给变量v一个定义d,存在一条路径使得程序点p能够到达q,且在这个过程中不能改变v的赋值
Live variables analysis tells whether the value of variable v at program point p could be used along some path in CFG starting at p. If so, v is live at p; otherwise, v is dead at p.
An expression x op y is available at program point p if all paths from the entry to p must pass through the evaluation of x op y, and after the last evaluation of x op y, there is no redefinition of x or y
程序点p处的表达式x op y可用需满足2个条件,一是从 entry 到 p 点必须经过x op y,二是最后一次使用 x op y 之后,没有重定义操作数 x、y。(如果重定义了 x 或 y,如 x = a op2 b,则原来的表达式 x op y 中的x或y就会被替代)
Transfer Function:
OUT[B]=genB∪(IN[B]−killB) gen:基本块求值 x op y,且之后没有对 x 或 y 赋值、kill:基本块对 x 或 y 赋值,且没有重新计算 x op y(如果重新计算,即使值不一样,也属于 gen)