Filipe Militão 1,2 Filipe Militão 1,2 Jonathan Aldrich 1 Luís Caires 2 1 Carnegie Mellon University Pittsburgh, USA 2 CITI / Dep. Informática FCT-UNL,

Slides:



Advertisements
Similar presentations
Writing specifications for object-oriented programs K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 21 Jan 2005 Invited talk, AIOOL 2005 Paris,
Advertisements

Challenges in increasing tool support for programming K. Rustan M. Leino Microsoft Research, Redmond, WA, USA 23 Sep 2004 ICTAC Guiyang, Guizhou, PRC joint.
Chapter 3 – Lists A list is just what the name implies, a finite, ordered sequence of items. Order indicates each item has a position. A list of size 0.
Lecture 5: Interfaces.
CS18000: Problem Solving and Object-Oriented Programming.
Constraint Semantics for Abstract Read Permissions 28 th July 2014, FTfJP, Uppsala John Tang Boyland (UW-Milwaukee/ETH Zurich) Peter Müller, Malte Schwerhoff,
Automated Software Verification with a Permission-Based Logic 20 th June 2014, Zürich Malte Schwerhoff, ETH Zürich.
Verification of Multithreaded Object- Oriented Programs with Invariants Bart Jacobs, K. Rustan M. Leino, Wolfram Schulte.
Chapter 10 Introduction to Arrays
Lightweight Abstraction for Mathematical Computation in Java 1 Pavel Bourdykine and Stephen M. Watt Department of Computer Science Western University London.
Inferring Object Invariants Bor-Yuh Evan ChangK. Rustan M. Leino University of California, BerkeleyMicrosoft Research January 21, 2005 AIOOL 2005 Paris,
INLS 560 – D ICTIONARIES Instructor: Jason Carter.
AN EXCEPTION AWARE BEHAVIORAL TYPE SYSTEM FOR OBJECT-ORIENTED PROGRAMS Filipe Militão and Luís Caires CITI / Departamento de Informática Universidade Nova.
Verifying Correct Usage of Atomic Blocks and Typestate Nels E. Beckman Nels E. Beckman, Kevin Bierhoff, and Jonathan Aldrich Carnegie Mellon University.
Software Testing and Quality Assurance
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Introduction to Structured Query Language (SQL)
Introduction to Sets. A set is just a collection of stuff But the stuff must be written inside curly braces Each item in the curly braces is separated.
Modular Typestate Checking for Concurrent Java Programs Nels E. Beckman Carnegie Mellon University (Advised by Jonathan Aldrich)
Chair of Software Engineering Concurrent Object-Oriented Programming Prof. Dr. Bertrand Meyer Lecture 9: Contracts and Inheritance (based on work with.
Using data groups to specify and check side effects K. Rustan M. Leino Microsoft Research Arnd Poetzsch-Heffter Universität Kaiserslautern Yunhong Zhou.
Using data groups to specify and check side effects K. Rustan M. Leino Microsoft Research Arnd Poetzsch-Heffter Universität Kaiserslautern Yunhong Zhou.
Abstract Classes b b An abstract class is a placeholder in a class hierarchy that represents a generic concept b b An abstract class cannot be instantiated.
Ownership Types for Object Encapsulation Authors:Chandrasekhar Boyapati Barbara Liskov Liuba Shrira Presented by: Charles Lin Course: CMSC 631.
Computer Science and Software Engineering University of Wisconsin - Platteville 7. Inheritance and Polymorphism Yan Shi CS/SE 2630 Lecture Notes.
SEC(R) 2008 Intel® Concurrent Collections for C++ - a model for parallel programming Nikolay Kurtov Software and Services.
Modern Concurrency Abstractions for C# by Nick Benton, Luca Cardelli & C´EDRIC FOURNET Microsoft Research.
Object Oriented Data Structures
REFACTORING Lecture 4. Definition Refactoring is a process of changing the internal structure of the program, not affecting its external behavior and.
Programming Languages -1 (Introduction to C) arrays Instructor: M.Fatih AMASYALI
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
CSE 425: Data Types II Survey of Common Types I Records –E.g., structs in C++ –If elements are named, a record is projected into its fields (e.g., via.
CSCI-383 Object-Oriented Programming & Design Lecture 13.
CSE 425: Object-Oriented Programming I Object-Oriented Programming A design method as well as a programming paradigm –For example, CRC cards, noun-verb.
Refactoring Improving the structure of existing code Refactoring1.
Low-Level Detailed Design SAD (Soft Arch Design) Mid-level Detailed Design Low-Level Detailed Design Design Finalization Design Document.
Session 08 Module 14: Generics and Iterator Module 15: Anonymous & partial class & Nullable type.
Hoang Anh Viet Hà Nội University of Technology Chapter 1. Introduction to C# Programming.
Java 5 Part 1 CSE301 University of Sunderland Harry Erwin, PhD.
Nirmalya Roy School of Electrical Engineering and Computer Science Washington State University Cpt S 122 – Data Structures Classes: A Deeper Look Part.
Built-in Data Structures in Python An Introduction.
1 Chapter Four Creating and Using Classes. 2 Objectives Learn about class concepts How to create a class from which objects can be instantiated Learn.
A Type System for Borrowing Permissions Karl Naden, Rob Bocchino Jonathan Aldrich, Kevin Bierhoff POPL – January 27, 2012 School of Computer Science.
ICOM 4035 – Data Structures Lecture 4 – Set ADT Manuel Rodriguez Martinez Electrical and Computer Engineering University of Puerto Rico, Mayagüez ©Manuel.
Introduction to Combinational Verilog EECS270 rev 9/25/12.
ANU COMP2110 Software Design in 2003 Lecture 10Slide 1 COMP2110 Software Design in 2004 Lecture 12 Documenting Detailed Design How to write down detailed.
Types and Programming Languages Lecture 11 Simon Gay Department of Computing Science University of Glasgow 2006/07.
SECTION 9 Orbits, Cycles, and the Alternating Groups Given a set A, a relation in A is defined by : For a, b  A, let a  b if and only if b =  n (a)
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
C++ Programming Lecture 14 Arrays – Part I The Hashemite University Computer Engineering Department (Adapted from the textbook slides)
1 Verification of object-oriented programs with invariants Mike Barnett, Robert DeLine, Manuel Fahndrich, K. Rustan M. Leino, Wolfram Schulte ECOOP 2003.
Faithful mapping of model classes to mathematical structures Ádám Darvas ETH Zürich Switzerland Peter Müller Microsoft Research Redmond, WA, USA SAVCBS.
Collections Using Generics in Collections. 2 Chapter Objectives Define the concept and terminology related to collections Explore the basic structure.
Seven Steps in Essay Writing. Step 1—Analyzing the question Without a clear understanding of what the question is, you can not write an adequate answer.
Arrays Declaring arrays Passing arrays to functions Searching arrays with linear search Sorting arrays with insertion sort Multidimensional arrays Programming.
Object-Oriented Programming: Classes and Objects Chapter 1 1.
CPSC 252 ADTs and C++ Classes Page 1 Abstract data types (ADTs) An abstract data type is a user-defined data type that has: private data hidden inside.
Chapter 9 Introduction to Arrays Fundamentals of Java.
Chapter 1: Preliminaries Lecture # 2. Chapter 1: Preliminaries Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation.
Object Invariants in Dynamic Contexts K.R.M. Leino and P. Muller : Objects and Aspects Presented by Jonathan Aldrich.
© Bertrand Meyer and Yishai Feldman Notice Some of the material is taken from Object-Oriented Software Construction, 2nd edition, by Bertrand Meyer (Prentice.
Research Project Overview. General Outline I. Abstract II. Introduction III. Literature Review IV. Methods V. Results VI. Discussion/Conclusion VII. References.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Copyright © 2002 Pearson Education, Inc. Slide 1.
Abstraction A way of managing complexity for large programs A means of separating details of computation from use of computation Types of Abstraction Data.
Objects and Aspects: What we’ve seen so far
Defining A Formal Semantics For The Rosetta Specification Language
Contents Preface I Introduction Lesson Objectives I-2
WebDAV Design Overview
Declarative Computation Model Single assignment store (VRH 2
Presentation transcript:

Filipe Militão 1,2 Filipe Militão 1,2 Jonathan Aldrich 1 Luís Caires 2 1 Carnegie Mellon University Pittsburgh, USA 2 CITI / Dep. Informática FCT-UNL, Portugal FTfJP 2010 – Maribor, Slovenia (June 22 nd 2010)

What is an object protocol ?What is an object protocol ?  Type-check Object-Oriented Languages  Some objects define protocols : clients are required to obey specific sequences in calls to that object  Example: File  call close after open, not before.  Goal: check protocol correctness statically 2

open() close() T YPE S TATE tracks protocolsT YPE S TATE tracks protocols  T YPES to reason about S TATE  File example ( P LAID –like syntax: explicit states ): none open()[ File >> OpenFile ] { … } File Open File Open File Closed File Closed File none close()[ OpenFile >> ClosedFile ] { … } 3 receiver pre -state receiver pre -state receiver post -state receiver post -state

The aliasing problemThe aliasing problem  How to handle state transitions if there are aliases ?  How to express aliasing information ? none openThese(File>>OpenFile a, File>>OpenFile b)[…]{ a.open(); b.open(); } What if a and b point to the same object? File 4

Aliasing descriptorsAliasing descriptors  aliasing descriptors – fixed number of tags  Example (access permissions): unique  full * pure unique File  full File * pure File  Each permission puts methods into separate sets  Are these permissions enough? More sets ?  Do we always need that many? Always meaningful?  Are they too complex to use? 5

Introducing V IEWS  Each V IEW is:  a portion/partition of the full object  unique (with only one single owner/alias)  checked separately of other views  V IEWS are small chunks of an object object view 6 client

Beyond unique V IEWS  Allow unbounded sharing of (replicable) V IEWS :  single owner  read + write  multiple owners  read  track sharing using fractions [Boyland2003] 7 R + W R R R R 1 1/ 2 1/ 4 collecting all restores write access 1/ 2 1/ 4

Goals of this workGoals of this work  Merge S TATE and A LIASING C ONTROL in a single abstraction: V IEWS  More generic ( …beyond aliasing descriptors )  Improved clarity ( more tightly modeling the designer’s intent )  More fine grained permission control  Type system  Type based verification of correct use of object protocols using views 8

Pair ExamplePair Example A Pair is a group of two elements: Left & Right 9

Pair InitializationPair Initialization E MPTY P AIR E MPTY L EFT E MPTY R IGHT L EFT R IGHT setLeftsetRight 10 Splits / Merges (symmetric) Transitions (asymmetric) N OT INITIALIZE D N OT INITIALIZE D

accessible fields ( private ) Syntax class EmptyPair { /* view declarations */ view EmptyLeft { none l; } view EmptyRight { none r; } view Pair { L l; R r; } view Right { R r; } view Left { L l; } /* view equations */ EmptyPair = EmptyLeft * EmptyRight Pair = Left * Right /* methods */ none setLeft(L>>none x)[EmptyLeft>>Left]{ this.l = x; } //... } V IEW D ECLARATIONS V IEW E QUATIONS M ETHOD D ECLARATIONS C LASS C ODE 11 new EmptyPair() contains union of all view fields initially set to null  empty type : none x taken by the method body! equations ( public ) checked for consistency

none auto_init(EmptyLeft>>Left l, EmptyRight>>Right r) [none>>none]{ l.setLeft( new L() ); r.setRight( new R() ); } r : EmptyRight l : EmptyLeft l : Leftr : EmptyRight l : Leftr : Right Transitions 12 No access to this

none init()[EmptyPair >> Pair] { this.auto_init(this,this); } Splitting & MergingSplitting & Merging this : EmptyPair this : none * EmptyLeft * EmptyRight this : none * Left * Right this : Pair //view equations EmptyPair = EmptyLeft * EmptyRight Pair = Left * Right this : none * EmptyPair 13 borrows each view

none method()[Pair>>Pair]{ this.destroyX(this.r); } none destroyX(R>>none x)[Pair>>Pair]{ … } Problem: Pack / UnpackProblem: Pack / Unpack  Disallow simultaneous access to this and its fields this XOR FIELDS illegal call! x would be a partial alias of this ! illegal call! x would be a partial alias of this ! 14 this: Pair this.r: R

none pair-method()[Pair>>Pair]{ this.inspectR(this.r); } none inspectR(R>>R x)[Left>>Left] { … } Pack / UnpackPack / Unpack 15 this: Pair this: Left * Rightthis: Left this.r: R Unpack only requires Left and not Pair legal call!

Lamp Example  Unique owner to modify the state of the Lamp  Unbounded reading of its light intensity value 16

Lamp class LampOff { view LampOn { Integer bulb; } view StaticLamp { const Integer bulb; } LampOn = StaticLamp! //… } const – immutable, safe to duplicate LampOn = StaticLamp! READ + WRITE READ ONLY full (1) StaticLamp partial (1/2) StaticLamp Single Writer XOR Multiple Readers 17 Replicable! All collected, full fraction All collected, full fraction

Fractions N!N! N/ * N/ N/ * N// * N// 18

Lamp class LampOff { view LampOn { Integer bulb; } view StaticLamp { const Integer bulb; } LampOn = StaticLamp! none turnOn() [ LampOff >> LampOn ] { … } none turnOff()[ LampOn >> LampOff ] { … } Integer getLightIntensity() [ StaticLamp? >> StaticLamp? ] { bulb } } works with any generic fraction (both full and partial) works with any generic fraction (both full and partial) 19

Cell Example  Cell containing one Lamp 20

Cell class EmptyCell { view ReadOnly { const StaticLamp! lamp; } view FilledCellOff { LampOff lamp; } view FilledCellOn { LampOn lamp; } FilledCellOn = ReadOnly! Integer readIntensity()[ReadOnly? >> ReadOnly?] { … } //… } field type must also be replicable (!) 21

Type SystemType System 22

none m1(ReadOnly! >> ReadOnly! x ) [none >> none]{ this.n(x,x,x); } x: ReadOnly! x: ReadOnly/ * ReadOnly/ x: ReadOnly/ * ReadOnly// * ReadOnly// x: ReadOnly/ * ReadOnly/ x: ReadOnly! none n( ReadOnly >> ReadOnly a, ReadOnly >> ReadOnly b, ReadOnly >> ReadOnly c )[none>>none] { … } Call ( ? Instantiation ) ? / // 23

none cell-method()[ReadOnly!>>ReadOnly!]{ this.checkLamp(this.lamp); } this: ReadOnly! this: ReadOnly/ * ReadOnly/ this: ReadOnly/ this.lamp const : StaticLamp/ this: ReadOnly/ none checkLamp( StaticLamp? >> StaticLamp? x)[ ReadOnly? >> ReadOnly? ] { … } view ReadOnly { const StaticLamp! lamp; } Pack / UnpackPack / Unpack 24

Related WorkRelated Work  Bierhoff & Aldrich, M ODULAR T YPE S TATE C HECKING O F A LIASED O BJECTS ( 2007 ).  Caires, S PATIAL -B EHAVIORAL T YPES F OR C ONCURRENCY A ND R ESOURCE C ONTROL I N D ISTRIBUTED S YSTEMS ( 2008 ).  Qi & Myers, M ASKED T YPES F OR S OUND O BJECT I NITIALIZATION ( 2009 ).  Leino, D ATA G ROUPS : S PECIFYING T HE M ODIFICATION O F E XTENDED S TATE ( 1998 ). 25

S INGLE C ELL S INGLE C ELL Future Work: coordination 26 READER WRITE R S HARED BUFFER Full Empt y coordinator

Future Work: coordination Full Empt y 27 READER WRITE R S HARED BUFFER coordinator E MPTY ? I can write ! E MPTY ? I can write ! F ULL ? I can read ! F ULL ? I can read !

Summary  V IEWS - new abstraction merges state and aliasing  multiple readers  single writer  readers counted using fractions  brief introduction of the type system  more details in the paper: Filipe Militão, Jonathan Aldrich, Luís Caires Aliasing control with view-based typestate 28