浅论成本控制与财务管理目标课件.ppt
- 【下载声明】
1. 本站全部试题类文档,若标题没写含答案,则无答案;标题注明含答案的文档,主观题也可能无答案。请谨慎下单,一旦售出,不予退换。
2. 本站全部PPT文档均不含视频和音频,PPT中出现的音频或视频标识(或文字)仅表示流程,实际无音频或视频文件。请谨慎下单,一旦售出,不予退换。
3. 本页资料《浅论成本控制与财务管理目标课件.ppt》由用户(晟晟文业)主动上传,其收益全归该用户。163文库仅提供信息存储空间,仅对该用户上传内容的表现方式做保护处理,对上传内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知163文库(点击联系客服),我们立即给予删除!
4. 请根据预览情况,自愿下载本文。本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
5. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007及以上版本和PDF阅读器,压缩文件请下载最新的WinRAR软件解压。
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 成本 控制 财务管理 目标 课件
- 资源描述:
-
1、静态代码分析静态代码分析梁广泰2011-05-25提纲提纲q动机动机q程序静态分析(概念程序静态分析(概念+实例)实例)q程序缺陷分析(科研工作)程序缺陷分析(科研工作)动机动机q云平台特点云平台特点 应用程序直接部署在云端服务器上,存在安全隐患应用程序直接部署在云端服务器上,存在安全隐患 直接操作破坏服务器文件系统直接操作破坏服务器文件系统 存在安全漏洞时,可提供黑客入口存在安全漏洞时,可提供黑客入口 资源共享,动态分配资源共享,动态分配 单个应用的性能低下,会侵占其他应用的资源单个应用的性能低下,会侵占其他应用的资源q解决方案之一:解决方案之一:在部署应用程序之前,对其进行静态代码分析:在
2、部署应用程序之前,对其进行静态代码分析:是否存在违禁调用?(非法文件访问)是否存在违禁调用?(非法文件访问)是否存在低效代码?(未借助是否存在低效代码?(未借助StringBuilder对对String进行大量进行大量拼接)拼接)是否存在安全漏洞?(是否存在安全漏洞?(SQL注入,跨站攻击,拒绝服务)注入,跨站攻击,拒绝服务)是否存在恶意病毒?是否存在恶意病毒?提纲提纲q动机动机q程序静态分析(概念程序静态分析(概念+实例)实例)q程序缺陷分析(科研工作)程序缺陷分析(科研工作)静态代码分析静态代码分析q定义:定义:程序静态分析是在不执行程序的情况下对其进行分析的技术,简称程序静态分析是在不执
3、行程序的情况下对其进行分析的技术,简称为静态分析。为静态分析。q对比:对比:程序动态分析:需要实际执行程序程序动态分析:需要实际执行程序 程序理解:静态分析这一术语一般用来形容自动化工具的分析,而程序理解:静态分析这一术语一般用来形容自动化工具的分析,而人工分析则往往叫做程序理解人工分析则往往叫做程序理解q用途:用途:程序翻译程序翻译/编译编译(编译器),程序优化重构,软件缺陷检测等(编译器),程序优化重构,软件缺陷检测等 q过程:过程:大多数情况下,静态分析的输入都是源程序代码或者中间码(如大多数情况下,静态分析的输入都是源程序代码或者中间码(如Java bytecode),只有极少数情况会
4、使用目标代码;以特定形式输),只有极少数情况会使用目标代码;以特定形式输出分析结果出分析结果静态代码分析静态代码分析 qBasic BlocksqControl Flow GraphqDataflow Analysis Live Variable Analysis Reaching Definition AnalysisqLattice Theory Basic BlocksqA basic block is a maximal sequence of consecutive three-address instructions with the following properties:Th
5、e flow of control can only enter the basic block thru the 1st instr.Control will leave the block without halting or branching,except possibly at the last instr.qBasic blocks become the nodes of a flow graph,with edges indicating the order.Basic Block ExampleLeaders1.i=12.j=13.t1=10*i4.t2=t1+j5.t3=8*
6、t26.t4=t3-887.at4=0.08.j=j+19.if j=10 goto(3)10.i=i+111.if i=10 goto(2)12.i=113.t5=i-114.t6=88*t515.at6=1.016.i=i+117.if i=10 goto(13)Basic BlocksControl-Flow GraphsqControl-flow graph:Node:an instruction or sequence of instructions(a basic block)Two instructions i,j in same basic blockiff execution
7、 of i guarantees execution of j Directed edge:potential flow of control Distinguished start node Entry&Exit First&last instruction in programControl-Flow EdgesqBasic blocks=nodesqEdges:Add directed edge between B1 and B2 if:Branch from last statement of B1 to first statement of B2(B2 is a leader),or
8、 B2 immediately follows B1 in program order and B1 does not end with unconditional branch(goto)Definition of predecessor and successor B1 is a predecessor of B2 B2 is a successor of B1CFG Example静态代码分析静态代码分析qBasic BlocksqControl Flow GraphqDataflow Analysis Live Variable Analysis Reaching Definition
9、 AnalysisqLattice Theory Dataflow AnalysisqCompile-Time Reasoning About Run-Time Values of Variables or ExpressionsqAt Different Program Points Which assignment statements produced value of variable at this point?Which variables contain values that are no longer used after this program point?What is
10、 the range of possible values of variable at this program point?Program Points One program point before each node One program point after each node Join point point with multiple predecessors Split point point with multiple successorsLive Variable AnalysisqA variable v is live at point p if v is use
11、d along some path starting at p,and no definition of v along the path before the use.qWhen is a variable v dead at point p?No use of v on any path from p to exit node,orIf all paths from p redefine v before using v.What Use is Liveness Information?qRegister allocation.If a variable is dead,can reass
12、ign its registerqDead code elimination.Eliminate assignments to variables not read later.But must not eliminate last assignment to variable(such as instance variable)visible outside CFG.Can eliminate other dead assignments.Handle by making all externally visible variables live on exit from CFGConcep
13、tual Idea of Analysisqstart from exit and go backwards in CFGqCompute liveness information from end to beginning of basic blocksLiveness Example a=x+y;t=a;c=a+x;x=0 b=t+z;c=y+1;11001001110000qAssume a,b,c visible outside methodqSo are live on exitqAssume x,y,z,t not visibleqRepresent Liveness Using
14、Bit Vectorqorder is abcxyzt1100111100011111001000101110a b c x y z ta b c x y z ta b c x y z tFormalizing AnalysisnEach basic block hasnIN-set of variables live at start of blocknOUT-set of variables live at end of blocknUSE-set of variables with upwards exposed uses in block(use prior to definition
15、)nDEF-set of variables defined in block prior to usenUSEx=z;x=x+1;=z (x not in USE)nDEFx=z;x=x+1;y=1;=x,ynCompiler scans each basic block to derive USE and DEF setsAlgorithmfor all nodes n in N-Exit INn=emptyset;OUTExit=emptyset;INExit=useExit;Changed=N-Exit;while(Changed!=emptyset)choose a node n i
16、n Changed;Changed=Changed-n;OUTn=emptyset;for all nodes s in successors(n)OUTn=OUTn U INp;INn=usen U(outn-defn);if(INn changed)for all nodes p in predecessors(n)Changed=Changed U p;静态代码分析静态代码分析 概念概念qBasic BlocksqControl Flow GraphqDataflow Analysis Live Variable Analysis Reaching Definition Analysis
17、qLattice Theory Reaching DefinitionsqConcept of definition and use a=x+y is a definition of a is a use of x and yqA definition reaches a use if value written by definition may be read by useReaching Definitions s=0;a=4;i=0;k=0 b=1;b=2;i ns=s+a*b;i=i+1;return sReaching Definitions and Constant Propag
18、ationqIs a use of a variable a constant?Check all reaching definitions If all assign variable to same constant Then use is in fact a constantqCan replace variable with constant s=0;a=4;i=0;k=0 b=1;b=2;i ns=s+a*b;i=i+1;return sYes!On all reaching definitionsa=4 s=0;a=4;i=0;k=0 b=1;b=2;i ns=s+4*b;i=i+
展开阅读全文