中国科学技术大学:《程序分析与程序验证》课程教学资源(课件讲稿)第3章 基于约束的分析(Nielson等)Principles of Program Analysis - Control Flow Analysis

Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book:Flemming Nielson, Hanne Riis Nielson and Chris Hankin:Principles of Program Analysis. Springer Verlag 2005.CFlemming Nielson Hanne Riis Nielson Chris Hankin. PPA Chapter 3 C F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 1
Principles of Program Analysis: Control Flow Analysis Transparencies based on Chapter 3 of the book: Flemming Nielson, Hanne Riis Nielson and Chris Hankin: Principles of Program Analysis. Springer Verlag 2005. c Flemming Nielson & Hanne Riis Nielson & Chris Hankin. PPA Chapter 3 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 1

The Dynamic Dispatch Problem proc p(procval q,val x,res y)isen Ical1 P(pi1v) [call q (x,y) which procedure is called? [cal1 p(p2,2.v ende These problems arise for: imperative languages with procedures as parameters object oriented languages functional languages PPA Chapter 3 C F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 2
The Dynamic Dispatch Problem ... [call p(p1,1,v)] ` 1 c ` 1 r ... [call p(p2,2,v)] ` 2 c ` 2 r ... proc p(procval q, val x, res y) is`n ... [call q (x,y)] ` p c ` p r which procedure is called? ... end`x These problems arise for: • imperative languages with procedures as parameters • object oriented languages • functional languages PPA Chapter 3 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 2

Example: let f fn x =x 1; g fn y =y+2; h fn z =z+3 in (f g)+(f h) The aim of Control Flow Analysis: For each function application,which functions may be applied? Control Flow Analysis computes the interprocedural flow relation used when formulating interprocedural Data Flow Analysis. PPA Chapter 3 C F.Nielson H.Rlis Nielson C.Hankin (Dec.2004) 3
Example: let f = fn x => x 1 ; g = fn y => y+2; h = fn z => z+3 in ( f g ) + ( f h ) The aim of Control Flow Analysis: For each function application, which functions may be applied? Control Flow Analysis computes the interprocedural flow relation used when formulating interprocedural Data Flow Analysis. PPA Chapter 3 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 3

Syntax of the Fun Language Syntactic categories: e∈Exp expressions (or labelled terms) t∈Term terms (or unlabelled expressions) f,x E Var variables Const constants Op∈ Op binary operators ∈ Lab labels Syntax: e :; t :c x fn x =eo fun f x=>eo e1 e2 if eo then e1 else e2 let x=e1 in e2 e1 op e2 (Labels correspond to program points or nodes in the parse tree. PPA Section 3.1 F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 4
Syntax of the Fun Language Syntactic categories: e ∈ Exp expressions (or labelled terms) t ∈ Term terms (or unlabelled expressions) f, x ∈ Var variables c ∈ Const constants op ∈ Op binary operators ` ∈ Lab labels Syntax: e ::= t ` t ::= c | x | fn x => e0 | fun f x => e0 | e1 e2 | if e0 then e1 else e2 | let x = e1 in e2 | e1 op e2 (Labels correspond to program points or nodes in the parse tree.) PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 4

Examples: 。(fnx=>x2)2(fny=>y3)4)5 ●(1etf=(fnx=>(x112)3)4; in (let g=(fn y =y5)6; in (let h=(fn z =z7)8 in(f9g10)11+(f12h13)14)15)16)17)18 (1et g=(fun f x =>(f1 (fn y =y2)3)4)5 in(g5(fnz=>z7)8)9)10 PPA Section 3.1 F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 5
Examples: • ((fn x => x1) 2 (fn y => y3) 4) 5 • (let f = (fn x => (x1 1 2) 3) 4; in (let g = (fn y => y5) 6; in (let h = (fn z => z7) 8 in ((f9 g 10) 11 + (f12 h 13) 14) 15) 16) 17) 18 • (let g = (fun f x => (f 1 (fn y => y2) 3) 4) 5 in (g 6 (fn z => z7) 8) 9) 10 PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 5

Abstract 0-CFA Analysis ●Abstract domains Specification of the analysis Well-definedness of the analysis PPA Section 3.1 C F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 6
Abstract 0-CFA Analysis • Abstract domains • Specification of the analysis • Well-definedness of the analysis PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 6

Towards defining the Abstract Domains The result of a 0-CFA analysis is a pair (C,p): .C is the abstract cache associating abstract values with each labelled program point p is the abstract environment associating abstract values with each variable PPA Section 3.1 C F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 7
Towards defining the Abstract Domains The result of a 0-CFA analysis is a pair (bC, ρb): • bC is the abstract cache associating abstract values with each labelled program point • ρb is the abstract environment associating abstract values with each variable PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 7

Example: (Enx=>x1)2(fny=>y3)4)5 Three guesses of a 0-CFA analysis result: (Ce;pe (C,) (Cg,) 1 {fn y = 3) {fn y =y3] {fn x = x1,fn y = 2 {fn x =x1} {fn x = x2} {fn x = , y=> y3) 3 0 0 fn ax -xl,fn y =y3 4 {fn y = y3) {fn y =>y3} {fn x = xl,fn y =y3) 5 {fn y => y3) {fn y => y3 {fn x = xl,fn y =y3] {fn y=>y3) 0 {fn x = x2, =>y3} y 0 0 fn x =>x1,fn y => y3) PPA Section 3.1 C F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 8
Example: ((fn x => x1) 2 (fn y => y3) 4) 5 Three guesses of a 0-CFA analysis result: ( bCe, ρbe) ( bC 0 e , ρb 0 e ) ( bC 00 e , ρb 00 e ) 1 2 3 4 5 x y {fn y => y3} {fn x => x1} ∅ {fn y => y3} {fn y => y3} {fn y => y3} ∅ {fn y => y3} {fn x => x1} ∅ {fn y => y3} {fn y => y3} ∅ ∅ {fn x => x1 , fn y => y3} {fn x => x1 , fn y => y3} {fn x => x1 , fn y => y3} {fn x => x1 , fn y => y3} {fn x => x1 , fn y => y3} {fn x => x1 , fn y => y3} {fn x => x1 , fn y => y3} PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 8

Example: (let g=(fun f x=>(f1 (fn y =y2)3)4)5 in(g6(fnz=>z7)8)9)10 Abbreviations: f三 fun f x=>(f1 (fn y =y2)3)4 idy 三 fn y =y2 idz 三 fn z =z7 One guess of a 0-CFA analysis result: Cp(1) = f Cp(6) 三 (f) {f) (2) 0 Cp(7) Pip(f) = 0 Pp(g) {f} Cp(3) 二 idy Cp(8) 三 fidz Plp(x) === idy,idz Cp(4) 三 0 Cp(9) 三 0 pp(y) = 0 Cp(5) 三 (o) Cp(10) 三 0 PIp(z) 三 0 PPA Section 3.1 F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 9
Example: (let g = (fun f x => (f 1 (fn y => y2) 3) 4) 5 in (g 6 (fn z => z7) 8) 9) 10 Abbreviations: f = fun f x => (f 1 (fn y => y2) 3) 4 idy = fn y => y2 idz = fn z => z7 One guess of a 0-CFA analysis result: bClp(1) = {f} bClp(2) = ∅ bClp(3) = {idy} bClp(4) = ∅ bClp(5) = {f} bClp(6) = {f} bClp(7) = ∅ bClp(8) = {idz} bClp(9) = ∅ bClp(10) = ∅ ρblp(f) = {f} ρblp(g) = {f} ρblp(x) = {idy, idz} ρblp(y) = ∅ ρblp(z) = ∅ PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 9

Abstract Domains Formally: Val -P(Term) abstract values p∈Env 三 Var-Val abstract environments c∈Cache=Lab→Val abstract caches An abstract value o is a set of terms of the forms ●fnx=>e0 ●fun f x=>e0 PPA Section 3.1 C F.Nielson H.Riis Nielson C.Hankin (Dec.2004) 10
Abstract Domains Formally: vb ∈ Val d = P(Term) abstract values ρb ∈ Env d = Var → Val d abstract environments bC ∈ Cache d = Lab → Val d abstract caches An abstract value vb is a set of terms of the forms • fn x => e0 • fun f x => e0 PPA Section 3.1 c F.Nielson & H.Riis Nielson & C.Hankin (Dec. 2004) 10
按次数下载不扣除下载券;
注册用户24小时内重复下载只扣除一次;
顺序:VIP每日次数-->可用次数-->下载券;
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第2章 数据流分析(补充).ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(课件讲稿)第2章 数据流分析(Nielson等)Principles of Program Analysis - Data Flow Analysis.pdf
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第1章 引言(主讲:陈意云).ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第9章 独立于机器的优化.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第8章 代码生成.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第7章 中间代码生成.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第13章 函数式语言的编译.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第12章 面向对象语言的编译.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第11章 编译系统和运行系统.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第10章 依赖于机器的优化.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第6章 运行时存储空间的组织和管理.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第5章 类型检查.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第4章 语法制导的翻译.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第3章 语法分析.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第2章 词法分析.ppt
- 中国科学技术大学:《编译原理与技术》课程教学资源(PPT课件讲稿)第1章 引论(主讲:张昱、陈意云).ppt
- 中国科学技术大学:《计算机科学导论》课程教学资源(PPT课件讲稿)第十讲 大数据的处理和分析.pptx
- 中国科学技术大学:《计算机科学导论》课程教学资源(PPT课件讲稿)第九讲 新型计算模型和顺序交互的数学.ppt
- 中国科学技术大学:《计算机科学导论》课程教学资源(PPT课件讲稿)第六讲 计算复杂性和算法分析.ppt
- 中国科学技术大学:《计算机科学导论》课程教学资源(PPT课件讲稿)第八讲 多核体系结构与并行编程模型.ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第3章 基于约束的分析(补充).ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(课件讲稿)第4章 抽象解释(Nielson等)Principles of Program Analysis - Abstract Interpretation.pdf
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第4章 抽象解释(补充).ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(课件讲稿)第5章 类型和效果系统(Nielson等)Principles of Program Analysis - Type and Effect Systems.pdf
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第5章 类型和效果系统(补充).ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第6章 模型检测.ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第7章 程序验证 Program verification.ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第7章 程序验证 ProgramVerification Necula 01 Theorem Proving.ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第7章 程序验证 ProgramVerification Necula 02 Finish Verification Condition Generation Simple Prover for FOL.ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第7章 程序验证 ProgramVerification Necula 03 Theorem Proving for FOL Satisfiability Procedures.ppt
- 中国科学技术大学:《程序分析与程序验证》课程教学资源(PPT课件讲稿)第7章 程序验证 ProgramVerification Necula 04 Decision-Procedure Based Theorem Provers Tactic-Based Theorem Proving Inferring Loop Invariants.ppt
- 中国科学技术大学:《程序设计语言理论》课程教学资源(参考教材)第1章 引言.pdf
- 中国科学技术大学:《程序设计语言理论》课程教学资源(参考教材)第2章 泛代数和代数数据类型.pdf
- 中国科学技术大学:《程序设计语言理论》课程教学资源(参考教材)第6章 递归类型.pdf
- 中国科学技术大学:《程序设计语言理论》课程教学资源(PPT课件讲稿)第1章 引言(主讲:陈意云).ppt
- 中国科学技术大学:《程序设计语言理论》课程教学资源(PPT课件讲稿)第2章 泛代数和代数数据类型.ppt
- 中国科学技术大学:《程序设计语言理论》课程教学资源(PPT课件讲稿)第3章 简单类型化λ演算.ppt
- 中国科学技术大学:《程序设计语言理论》课程教学资源(PPT课件讲稿)第4章 类型化λ演算的模型.ppt
- 中国科学技术大学:《程序设计语言理论》课程教学资源(PPT课件讲稿)第5章 命令式程序的语义.ppt
- 中国科学技术大学:《程序设计语言理论》课程教学资源(PPT课件讲稿)第6章 递归类型.ppt