21.01.2013 Views

Lecture Notes in Computer Science 4917

Lecture Notes in Computer Science 4917

Lecture Notes in Computer Science 4917

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

392 Y. Ben Asher et al.<br />

3 Cyclic Paths<br />

Given the call graph of the program, the proposed algorithm must handle recursive<br />

function calls that are reflected by cyclic paths <strong>in</strong> the call graph. To handle<br />

cyclic paths, the algorithm must remove one of the edges <strong>in</strong> the cycle.<br />

Different <strong>in</strong>l<strong>in</strong><strong>in</strong>g orders are created for different edges be<strong>in</strong>g removed from the<br />

graph, as can be seen from Figure 6. The figure shows an example of a cycle <strong>in</strong><br />

the call graph of a given program, <strong>in</strong> which function f <strong>in</strong>cludes a call to function<br />

i that <strong>in</strong> turn calls j, which calls back to f. Different possible <strong>in</strong>l<strong>in</strong><strong>in</strong>g cha<strong>in</strong>s are<br />

created by remov<strong>in</strong>g different edges (lower part of Figure 6). They are drawn<br />

accord<strong>in</strong>g to the follow<strong>in</strong>g rules:<br />

1. If a function foo conta<strong>in</strong>s an embedded call<strong>in</strong>g site to an <strong>in</strong>l<strong>in</strong>ed function<br />

bar, thenbar is drawn beneath foo and slightly aligned to the right.<br />

2. If bar is drawn directly beneath function foo, without be<strong>in</strong>g aligned to<br />

the right, then both foo and bar are <strong>in</strong>l<strong>in</strong>ed <strong>in</strong>to some other function gal<br />

conta<strong>in</strong><strong>in</strong>g the two call<strong>in</strong>g sites to foo and bar.<br />

Figure 6 shows all possible <strong>in</strong>l<strong>in</strong><strong>in</strong>g cha<strong>in</strong>s created by remov<strong>in</strong>g different edges <strong>in</strong><br />

the f – i – j cycle. For example, remov<strong>in</strong>g the j – f edge, causes function j to be<br />

<strong>in</strong>l<strong>in</strong>ed <strong>in</strong>to i, which <strong>in</strong> turn is <strong>in</strong>l<strong>in</strong>ed <strong>in</strong>to f (as shown <strong>in</strong> Figure 6a). Therefore,<br />

it is important to search for the maximal directed acyclic graph representation<br />

of the given call graph. This problem is a variation of the feedback edge set<br />

problem [6] . The problem is NP-hard and the time complexity of the algorithm<br />

is exponential <strong>in</strong> respect to the number of edges <strong>in</strong> the largest strongly connected<br />

component of G. However, <strong>in</strong> practice, the number of recursive functions that<br />

participate <strong>in</strong> the creation of cycles <strong>in</strong> a call graph is usually very small. Thus,<br />

the time complexity is manageable.<br />

f<br />

i<br />

j<br />

g<br />

h<br />

(a) Remov<strong>in</strong>g<br />

the j-f<br />

edge<br />

j<br />

f<br />

i<br />

g<br />

h<br />

(b) Remov<strong>in</strong>g<br />

the i-j<br />

edge<br />

i<br />

j<br />

f<br />

g<br />

h<br />

(c) Remov<strong>in</strong>g<br />

the f-i<br />

edge<br />

Fig. 6. Different <strong>in</strong>l<strong>in</strong><strong>in</strong>g options for cycles <strong>in</strong> the call graph<br />

4 The Synergy of Function Inl<strong>in</strong><strong>in</strong>g and Global Code<br />

Reorder<strong>in</strong>g<br />

One of the fundamental issues related to function <strong>in</strong>l<strong>in</strong><strong>in</strong>g is the <strong>in</strong>sertion of ‘cold’<br />

(rarely executed) code next to ‘hot’ (frequently executed) code. This <strong>in</strong>struction

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!