11th Nov 2004PLDI 20041 Region Inference for an Object-Oriented Language Wei Ngan Chin 1,2 Joint work with Florin Craciun 1, Shengchao Qin 1,2, Martin.

Slides:



Advertisements
Similar presentations
Chapter 22 Implementing lists: linked implementations.
Advertisements

Containers CMPS Reusable containers Simple data structures in almost all nontrivial programs Examples: vectors, linked lists, stacks, queues, binary.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Programming Paradigms Introduction. 6/15/2005 Copyright 2005, by the authors of these slides, and Ateneo de Manila University. All rights reserved. L1:
Type-Based Flow Analysis: From Polymorphic Subtyping to CFL-Reachability Jakob Rehof and Manuel Fähndrich Microsoft Research.
Inferring Disjunctive Postconditions Corneliu Popeea and Wei-Ngan Chin School of Computing National University of Singapore - ASIAN
Program Representations. Representing programs Goals.
5. Memory Management From: Chapter 5, Modern Compiler Design, by Dick Grunt et al.
Generic programming in Java
OBJECT ORIENTED PROGRAMMING M Taimoor Khan
1 Practical Object-sensitive Points-to Analysis for Java Ana Milanova Atanas Rountev Barbara Ryder Rutgers University.
Georgia Institute of Technology Workshop for CS-AP Teachers Chapter 3 Advanced Object-Oriented Concepts.
CS 326 Programming Languages, Concepts and Implementation Instructor: Mircea Nicolescu Lecture 18.
Chapter 8 Runtime Support. How program structures are implemented in a computer memory? The evolution of programming language design has led to the creation.
ISMM Analyzing Memory Resource Bounds for Low-Level Programs Wei-Ngan Chin 1 Huu Hai Nguyen 1 Corneliu Popeea 1 Shengchao Qin 2 1 National Univ.
Preliminaries Attendance sheets –I remembered! Survey links –HW1 time survey –Anonymous feedback survey HW discussion (4PM, Commons 9)
The Ant and The Grasshopper Fast and Accurate Pointer Analysis for Millions of Lines of Code Ben Hardekopf and Calvin Lin PLDI 2007 (Best Paper & Best.
No homework this week Stage 2 starts next week. Code review Team with N members is assigned N submissions to review Discuss submissions within team Everyone.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Programming Language Paradigms: summary. Object-oriented programming Objects are the fundamental building blocks of a program. Interaction is structured.
Recap from last time We were trying to do Common Subexpression Elimination Compute expressions that are available at each program point.
Pointer and Shape Analysis Seminar Context-sensitive points-to analysis: is it worth it? Article by Ondřej Lhoták & Laurie Hendren from McGill University.
Laboratory for Computer Science Massachusetts Institute of Technology Ownership Types for Safe Region-Based Memory Management in Real-Time Java Chandrasekhar.
The environment of the computation Declarations introduce names that denote entities. At execution-time, entities are bound to values or to locations:
U NIVERSITY OF M ASSACHUSETTS A MHERST Department of Computer Science Computer Systems Principles C/C++ Emery Berger and Mark Corner University of Massachusetts.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Programming Languages: Design, Specification, and Implementation G Rob Strom October 19, 2006.
From last class. The above is Click’s solution (PLDI 95)
Maria-Cristina Marinescu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology A Synthesis Algorithm for Modular Design of.
Programming Languages and Paradigms Object-Oriented Programming.
CS 363 Comparative Programming Languages
Implications of Inheritance COMP204, Bernhard Pfahringer.
Core Java: Essential Features 08/05/2015 Kien Tran.
Guided Notes Ch. 9 ADT and Modules Ch. 10 Object-Oriented Programming PHP support for OOP and Assignment 4 Term project proposal C++ and Java Designer.
Basic Semantics Associating meaning with language entities.
User-defined type checkers for error detection and prevention in Java Michael D. Ernst MIT Computer Science & AI Lab
Mark Marron 1, Deepak Kapur 2, Manuel Hermenegildo 1 1 Imdea-Software (Spain) 2 University of New Mexico 1.
Design Principle & Patterns by A.Surasit Samaisut Copyrights : All Rights Reserved.
Mark Marron IMDEA-Software (Madrid, Spain) 1.
Object Oriented Software Development
Lecture 12 March 16, The Scope of a Variable What if there are two variables with the same name? –A local or block-local variable can have the same.
COMP3190: Principle of Programming Languages
Verifying Safety Policies with Size Properties and Alias Controls Wei Ngan Chin 1,2, Siau-Cheng Khoo 1, Shengchao Qin 3, Corneliu Popeea 1, Huu Hai Nguyen.
Understanding Data Types and Collections Lesson 2.
Standard Template Library The Standard Template Library was recently added to standard C++. –The STL contains generic template classes. –The STL permits.
Pointer Analysis Survey. Rupesh Nasre. Aug 24, 2007.
CS 343 presentation Concrete Type Inference Department of Computer Science Stanford University.
CSSE501 Object-Oriented Development. Chapter 10: Subclasses and Subtypes  In this chapter we will explore the relationships between the two concepts.
Pointer and Escape Analysis for Multithreaded Programs Alexandru Salcianu Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
ReIm & ReImInfer: Checking and Inference of Reference Immutability and Method Purity Wei Huang 1, Ana Milanova 1, Werner Dietl 2, Michael D. Ernst 2 1.
Types and Programming Languages Lecture 10 Simon Gay Department of Computing Science University of Glasgow 2006/07.
UMBC CMSC 331 Java Review of objects and variables in Java.
Csontos Péter, Porkoláb Zoltán Eötvös Loránd Tudományegyetem, Budapest ECOOP 2001 On the complexity of exception handling.
CSC 520 – Advanced Object Oriented Programming, Fall, 2010 Thursday, September 30 Week 5, Generics and Inheritance Techniques, Meyer Ch. 10 & 16.
서울대한양대 ( 안 산 ) 충남대 1년1년 컴퓨터기초 (C) 컴퓨터프로그래밍 (C, Java) 컴퓨터프로그래밍 (C) 2. 봄 프로그래밍 원리 (Scheme, ML) Structure & Interpretation of Computer Programs 프로그래밍 방법론.
Language Paradigms CS655.
Code Generation Instruction Selection Higher level instruction -> Low level instruction Register Allocation Which register to assign to hold which items?
Design issues for Object-Oriented Languages
C11, Implications of Inheritance
Enhancing Modular OO Verification with Separation Logic
Scope and Code Generation
Component Based Software Engineering
About the Presentations
Lecture 2 of Computer Science II
Object orientation concepts
Generic programming in Java
자바 언어를 위한 정적 분석 (Static Analyses for Java) ‘99 한국정보과학회 가을학술발표회 튜토리얼
Presentation transcript:

11th Nov 2004PLDI Region Inference for an Object-Oriented Language Wei Ngan Chin 1,2 Joint work with Florin Craciun 1, Shengchao Qin 1,2, Martin Rinard 3 1 National University of Singapore 2 Singapore-MIT Alliance 3 MIT

2 Background Problem: objects have different lifetimes garbage collection can be expensive One Solution: Use regions with different lifetimes Avoid dangling references. Previous Works : Region checkers for Java [DIKU98], Real-Time Java : [Boyapati et al PLDI03], C [Cyclone PLDI02]. Our Goal: auto. region inference for OO paradigm

3 Assumptions Lexically-Scoped Regions: LIFO behaviour construct : letreg r in e No-Dangling References: Regions of fields must outlive the region of its enclosing object. top (younger) bottom (older)

4 Main Contributions Region Inference for Core-Java Constraint-Based Type System. Region Polymorphism & Region Subtyping Handles Inheritance, Overriding, Downcast Implementation

5 Core-Java

6 Region-Annotated Core-Java region types, parameters, constraints, letreg

7 Inferring for Class

8 Key Principles : Classes Region type : c h r 1,…, r n i r 1 : (region for current object of this type) r 2,…,r n (regions for components/fields) r k º r 1, 8 k 2 2..n (no dangling references) First region is special. Keep regions of components distinct.

9 List Example

10 Key Principles : Methods Region polymorphism from the region types of parameters and output t mn h r * i ((t v) * ) where rc e r * captures region polymorphism Keep region constraints of classes and methods separate.

11 Inference of Methods class invariant method precondition

12 Outline Background Key Principles Region Subtyping Region Inference Method Overriding + Downcast Experimental Results

13 No Region Subtyping [Boyapati et al PLDI03] supports class subtyping but not region subtyping

14 (Object) Region Subtyping concept from [Cyclone PLDI02] A variable location v::c can be passed an object of type c provided r  s

15 Example Variables a and b are assigned to tmp. Without region subtyping, their regions are equal. With region subtyping, their regions may be distinct.

16 Problem – Recursive Fields Recursive nodes being forced into the same region Some programs permit recursive nodes to be in different regions …..

17 Example - Reynolds3 Escape Analysis [Deutsch:POPL97] allows the List(x,p) object to be build on runtime stack. This effect is equivalent to local region at each recursive call.

18 (Field) Region Subtyping Our Extension : Covariance for Read-Only Fields.

19 Outline Background Key Principles Region Subtyping Region Inference Method Overriding + Downcast Experimental Results

20 Region Inference Format of type inference rules Flow-insensitive but context sensitive. Modular inference according to dependency graph.

21 Inference Rule for Block rs: the set of regions that do not escape the block They are coalesced into a single localised region r

22 Example – Localised Region

23 Example – Localised Region

24 Example – Cyclic Structure p1p2

25 Outline Background Key Principles Region Subtyping Region Inference Overriding + Downcast Experimental Results

26 Method Overriding class B h r 1.. r n i extends A h r 1.. r m i where C B  In class A: Y mn h r’ 1,..,r’ p i (X) where M A {  } In class B: Y mn h r’ 1,..,r’ p i (X) where M B {  } Function Subtyping Rule: Method Override Rule: C B Æ M A ) M B argumentresultselection

27 Override Conflict Resolution If method override rule do not hold for: C B M A M B Can strengthen C B, M A to C’ B, M’ A using: Until:C’ B Æ M’ A ) M B C B, M A, M B ` C’ B, M’ A

28 Downcast Safety In our framework : regions may be lost during upcast e.g.Object o = new Pair (…) lost regions must be recovered during downcast. e.g.Pair p = (Pair) o Key technique : maintain extra regions that were supposedly lost during upcasting! e.g.Object [r2,r3] p = new Pair (…) Solution : Flow analysis

29 Experiments Region annotation needed in 12% of the code. Comparable space reuse for all programs. Inference is as good as hand-annotation. On Olden benchmark, inference takes < 5s.

30 Concluding Remarks Automatic region inference for CoreJava. Support classes and methods with region polymorphism. Supports region subtyping. Supports OO features : class subtyping, method overriding, and downcast safety. Implementation

31 Future Work Better Lifetime Precision variable liveness analysis flow sensitivity via SSA treat null as a primitive value Memory Efficiency : Sized Regions + Reuse Extensions : Genericity + RTSJ

32 Inference Rule for Sequence Inference rule is flow-insensitive. Improvement possible via SSA.

33 Correctness

34 Example : Fixed-Point Analysis

35 Inference of Methods

36 Experiments Region inference is fast for large programs too. Our prototype was built using Glasgow Haskell Compiler.