|
Input: F(A), A.exe, A_inputs[ ] |
//The function collection of the program, binary file, and input list |
Output: Res |
//Output optimal granularity division plan |
{ |
//F(A) is the set of all functions of the program |
F(A).count = 0; //the number of functions of the program A |
F(A).size[ ] = 0; //the number of control-flow events of each function |
static_func (F(A), A.exe, inputs[ ], F(A).count , F(A).size[ ]); |
//Count the number of function calls and control-flow events in each function |
GranularityDivide (F(A).count , F(A).size[ ], Res); |
//Granularity division, return the optimal granularity division plan |
} |
GranularityDivide (count, size[ ], best_scheme) |
{ |
= 0; |
InitPopulation (Pt: N); |
//The population Pt is initialized, containing N individuals representing a granularity division plan each |
while ≤ do: |
CreateOffspring (Pt, Qt); |
//The crossover and mutation on Pt and Qt produce offspring |
Rt = Merge (Pt, Qt); |
for p in Rt do: |
//Objective calculation |
security = f_security (count, size[ ], p); |
//Calculate the security benefits of each individual p according to formulas (8) and (9) |
overhead = f_overhead (count, size[ ], p); |
//Calculate the overhead costs of each individual p according to formula (10) |
end for |
NonDominatedSorting(Rt); |
//Non-dominated sorting based on objective function according to formulas (11) and (12) |
CrowdingDistanceSorting(Rt); |
//Sort the congestion degree of Rt |
Pt = Rt[0, N]; |
//Select the top N better solutions |
= + 1;//go to the next generation, trying to get better granularity division plan |
end while |
best_scheme = Pt[0]; |
//Return to the optimal partition plan |
} |
|