1 / 25

Program Schemas In Dependence Analysis

Program Schemas In Dependence Analysis. Sebastian Danicic (Goldsmiths) Mark Harman (King’s) Rob Hierons (Brunel) John Howroyd (Scotland) Mike Laurence (Liverpool). Program Schemas. A program schema is a program where all expressions are replaced by symbolic expressions. if p(x)

chin
Download Presentation

Program Schemas In Dependence Analysis

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Program Schemas In Dependence Analysis Sebastian Danicic (Goldsmiths) Mark Harman (King’s) Rob Hierons (Brunel) John Howroyd (Scotland) Mike Laurence (Liverpool)

  2. Program Schemas A program schema is a program where all expressions are replaced by symbolic expressions. if p(x) then x:=f(x); else y:=g(k); if (x<1) then x:=x+2; else y:=x+2; if (x<1) then x:=x+2; else y:=x+2; Different programs in the same equivalence class.

  3. Two Classes of Schema • Free Schemas For every path, , through S, there is a program in the equivalence class of S that takes . • Liberal Schemas The same symbolic expression does not occur more than once along any path.

  4. History of Schemas • Schemas were first introduced in the late 1950s for compiler optimisation and verification. • Two schemas are equivalent if and only if for all interpretations the resulting programs are semantically identical. • The most important problems concerned decidability of equivalence. • By the 1970s interest in schemas waned due to the scarcity of positive results.

  5. Positive Results in Schematology • Equivalence of Ianov Schemas is decidable. (Ianov 1958) • Equivalence of Progressive Schemas is decidable. (Paterson 1967 - PhD) • Equivalence of Through Schemas is decidable. (Sabelfeld 1990)

  6. Linear Schemas A linear schema is one where each function and predicate symbol occurs at most once. • Importantly for us, linear schemas are at exactly the same level of abstraction as program dependence analysis. • If equivalence of linear schemas is decidable the so is dataflow minimal slicing.

  7. Linearity Makes Things Easier! • Considering only schemas to be linear, which is exactly what we want for dataflow analysis has also enabled us to prove some more positive results about schemas. • Linearity captures the “normal” abstraction: we never need worry about things like two variables having the same value in all interpretations.

  8. Our Positive Results on Schemas • Equivalence of Conservative Free Linear Schemas is decidable. (TCS - 2003) • Equivalence of Liberal Free Linear Schemas is decidable. (M.Laurence PhD thesis) • For Liberal Free Linear Schemas, traditional program dependence produces dataflow minimal slices.(submitted to TCS)

  9. What is Dependence Analysis? P . . . . . . . . . Which bits of P affect this? Which bits of P affect variable x? Which bits can we delete without affecting x? Slicing

  10. Slicing • Slicing program P on a variable x deletes statements from P to produce a program P’ which behaves the same with respect to variable x. • P is a slice of itself - useless! • We want slices to be small - useful!

  11. Applications of Dependence Analysis • Testing and Debugging Cuts down search space when looking for bugs • Program Restructuring Helps us convert monolithic programs into many procedures • Program Comprehension and Maintenance Prism

  12. The Traditional Approach to PDA Program CFG Start while(i>0) { x=x+1; i=i-1; } i > 0 exit x=x+1 i=i-1

  13. Data & Control Dependence 1 x=x+1 2 y=5 3 x > 0 4 5 a=y b=x+1 Node 5 is data dependent on Node 1 Node 5 is control dependent on Node 3

  14. Data Dependence & Control Dependence x:=x+1; y:=5; A B C D E is Data Dependent on A E is Control Dependent on C x>0 E z:=x; z:=x+1;

  15. Dataflow Abstraction Program Dependence Analysis is reduced to a graph theoretic problem where the only informationused is the set of defined variables and the set of referenced variables of each node.  x=y+a+b x=2*y-a-b

  16. Transitivity Assumption In Program Dependence Analysis, Node A is considered to be dependent on Node B if and only if there is a chain of nodes A=A1…An=B where Ai is either data or control dependent on Ai+1

  17. Limitations of Traditional Program Dependence Analysis The final value of x is not dependent on the loop, so the loop is removed. But the loop does have an effect on the final value of x! Program dependence does not consider  as a value. while(true) { y:=y+1; } x:=5; x=5; Slice w.r.t. x

  18. So using traditional program dependence analysis a program P and its slice agree in all states where P terminates. Now what about ? while p(x) { if q(k) then k:=f(k); else{ k:=g(k); x:=h(x); } } Slice on x. PDA removes nothing. But can we?

  19. So using traditional program dependence analysis a program P and its slice agree in all states where P terminates. Now what about ? This line can be removed as its only contribution is to non-termination. So why isn’t it? while p(x) { if q(k) then k:=f(k); else{ k:=g(k); x:=h(x); } } Slice on x. PDA removes nothing. But can we?

  20. while p(x) { if q(k) then k:=f(k); else{ k:=g(k); x:=h(x); } } while x>0 { if k>0 then k:=k-1; else{ k:=k+17; x:=x-1; } } while x<0 { if k>0 then k:=k+1; else{ k:=k+1; x:=x+5; } }

  21. Traditional Dependence analysis is producing “spurious dependences”. Let S be the schema on the previous slide and S’ be the schema with the statement k:=g(k) removed. For all programs P in the equivalence class of the schema S, the corresponding program P’ in the equivalence class of S’ will be a slice of P with respect to x. S’ is a smaller slice than that produced by traditional dependence analysis although it is constructed at the same level of abstraction. Smaller slices are good!

  22. The Dataflow Minimality problem S’ is a minimal slice of S. That is, should we delete more statement to produce a schema S’’ then there will exist an interpretation, I, such that program P’’ is not a slice of P. Where P and P’’ are the result of respectively interpreting S and S’’ in I.

  23. Open Question Are dataflow minimal slices computable? I.e Given a schema S are the minimal slices of S computable. This result is obviously not true about programs. But at the schema level it may be.

  24. Future Work • Is equivalence of linear schemas decidable? • Is freeness of linear schemas decidable? • Non standard semantics for schemas to match non standard semantics for program dependence.

  25. The End Any Questions?

More Related