static4 - Control Flow Analysis Static Analysis 2009...

Info iconThis preview shows pages 1–7. Sign up to view the full content.

View Full Document Right Arrow Icon
1 Control Flow Analysis Control Flow Analysis Static Analysis 2009 Static Analysis 2009 Michael I. Schwartzbach Computer Science, University of Aarhus
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
2 2 Static Analysis Control Flow Complications Control Flow Complications ± Function pointers complicate CFG construction: • several functions may be invoked at a call site • this depends on the dataflow • but dataflow analysis first requires a CFG ± Same situation for other features: • higher-order functions • a class hierarchy with objects and methods • prototype objects with dynamic properties
Background image of page 2
3 3 Static Analysis Control Flow Analysis Control Flow Analysis ± A control flow analysis approximates the CFG • conservatively computes possible functions at call sites • the trivial answer: all functions ± This is a flow- insensitive analysis: • it is based on the AST • the CFG is not available yet ± A subsequent analysis may use the CFG: • a flow-sensitive CFA may be less conservative • this could be iterated
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
4 4 Static Analysis CFA for The Lambda Calculus CFA for The Lambda Calculus ± The pure lambda calculus E →λ x . E | (function definition) E 1 E 2 | (function application) x (variable reference) ± Assume all λ -bound variables are distinct ± A closure λ x abstracts the function λ x . E in all contexts (values of free variables) ± For each call site E 1 E 2 determine the possible functions for E 1 from the set { λ x 1 , λ x 2 , . .., λ x n }
Background image of page 4
5 5 Static Analysis Closure Analysis Closure Analysis ± For every AST node, v, we introduce a variable [[v]] ranging over subsets of closures ± For λ id . E we have the constraint: { λ id } [[ λ id . E ]] ± For E 1 E 2 we have the conditional constraint: λ id [[ E 1 ]] [[ E 2 ]] [[ id ]] [[ E ]] [[ E 1 E 2 ]] for every closure λ id
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
6 6 Static Analysis The Cubic Framework The Cubic Framework ± We have a set of tokens { t 1 , t 2 , . .., t k } ± We have a collection of variables { x 1 , . .., x n } ranging over subsets of tokens ± A collection of constraints of the form: •{ t } x t x y z ± Compute the unique minimal solution • this exists since solutions are closed under intersection ± An cubic time algorithm is available
Background image of page 6
Image of page 7
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 04/18/2011 for the course COMPUTER 091 taught by Professor Rajivsir during the Spring '11 term at MIT.

Page1 / 27

static4 - Control Flow Analysis Static Analysis 2009...

This preview shows document pages 1 - 7. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online