Algorithm 5.3 Call-Graph-Construction

Input: Signature of entry methods mentrym^{entry}.

Output: Call Graph CG, a set of call edges.

1:procedure BuildCallGraph(mentrym^{entry})

2:WL=[mentry]WL = [m^{entry}] // Work List, containing the methods to be processed

3:CG={}CG = \{\} // Call Graph, a set of call edges

4:RM={}RM = \{\} // A set of reachable methods

5:while WLWL is not empty do

6:remove mm from WLWL // mm is a method

7:if mRMm \notin RM then

8:add mm to RMRM

9:for each call site cscs in mm do

10:T:=T := Resolve(cscs) // Resolve target methods, probably via CHA

11:for each target method mm' in TT do

12:add csmcs \to m' to CGCG

13:add mm' to WLWL

14:end for

15:end for

16:end if

17:end while

18:return CGCG

19:end procedure