1 / 12

Review of Static Program Analysis and Co/Contra-variance

Review of Static Program Analysis and Co/Contra-variance. Ras Bodik, Thibaud Hottelier, James Ide UC Berkeley CS164: Introduction to Programming Languages and Compilers Fall 2010. Improve the course (we need your feedback). Office hours with Pizza this Wed, Nov 17, 5pm, in La Val’s

maili
Download Presentation

Review of Static Program Analysis and Co/Contra-variance

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. Review of Static Program Analysis and Co/Contra-variance Ras Bodik, Thibaud Hottelier, James Ide UC Berkeley CS164: Introduction to Programming Languages and Compilers Fall 2010

  2. Improve the course (we need your feedback) Office hours with Pizza this Wed, Nov 17, 5pm, in La Val’s HKN surveys: Next Monday, Nov 22

  3. HW8: Static analysis (types and flow analysis) • Three problems, one for each lecture L18-20 • Preparation for the exam. • Some reading • Due in two weeks (Two days before exam) • Today’s lecture and Thursday recitation will review the material

  4. HW9: Final Project Design Document Main goal: Flesh out HW7. Include details for implementation and evaluation. What programs you want to write in your language? • if you are building a tool, answer “What programs do you want to analyze with your debugger / …?” • be specific, write down these programs What implementation steps will you follow? • finish your design before you submit the document • break down the implementation into ~6 steps • say what data structures and modules you’ll implement

  5. Announcements Contest 1: Fastest 164 Parser workload: large files + many tiny files (onclick handlers) Contest 2: Most Impressive 164 Browser Demo goal: combine bQuery with Rx, potentially extending them simplicity: future 164 students must be able to build it Prizes: iPod nanos Deadline: a few days after the second midterm

  6. Paid 164 Courseware Developer Job Do you want to improve 164? Some of the tasks where we need your help: Improve the browser, the language, the parser. Rewrite the handouts with creative technical writing. Develop homeworks that prepare for PAs (like HW4). Talk to Ras if interested.

  7. Prolog program for Andersen algorithm new(o1,x). % x=new_1 Foo() new(o2,z). % z=new_2 Bar() assign(x,y). % y=x assign(x,w). % w=x pf(z,y,f). % y.f=z gf(w,v,f). % v=w.f flowsTo(O,X) :- new(O,X). flowsTo(O,X) :- assign(Y,X), flowsTo(O,Y). flowsTo(O,X) :- pf(Y,P,F), gf(R,X,F), aliasP,R), flowsTo(O,Y). alias(X,Y) :- flowsTo(O,X), flowsTo(O,Y).

  8. Computing pointsToand alias relations o1 new x assign assign w y gf[f] pf[f] new v z o2

  9. Handling of method calls Issue 1: Arguments and return values: these are translated into assignments of the form p=r Example: Object foo(T x) { return x.f } r = new T; s = foo(r.g) is translated into foo_retval = foo_x.f r = new T; s = foo_retval; foo_x = r.g

  10. Imprecision in modeling of function calls Example where our modeling leads to imprecision: def id(x) { return x } a = id(new Foo()) b = id(new Bar()) Let’s draw our inference graph:

  11. Handling of method calls Issue 2: targets of virtual calls call p.f() may call many possible methods to do the translation shown on previous slide, must determine what these targets are Suggest two simple methods:

  12. Nominal type systems: co/contra-variance Assume: C extends B extends A. class B has method B foo(B). class C also has method foo. Assume you are designing the type system for this language. What types of C’s foo should you allow? B-->B, A-->A, C-->A, A-->C, … How do we decide? Want some statements to be type safe. What does type safety mean?

More Related