Typestate Checking - PowerPoint PPT Presentation

1 / 15
About This Presentation
Title:

Typestate Checking

Description:

'Extending Typestate Checking Using Conditional Liveness Analysis', Robert E. ... stronger analysis techniques must be used to handle conditional initialization. ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 16
Provided by: csWu4
Category:

less

Transcript and Presenter's Notes

Title: Typestate Checking


1
Typestate Checking
Talk and extensive quotes taken from the
following papers 'Extending Typestate Checking
Using Conditional Liveness Analysis', Robert E.
Strom and Daniel M Yellin, 1993 'Typestae A
Programming Language Concept for Enhancing
Software Reliability', Robert E. Strom and Shaula
Yemini, 1986
2
Topics covered - Definition and history of
typestate checking - Example Code and States -
Questions for discussion - Uses for typestate
checking - Changes in programming practices
3
Typestate checking is 'a compile time program
analysis technique which enhances program
reliability by detecting type-correct
applications of operations which are non-sensical
in their current context' 'Strom and Yemini,
1986' 'a dataflow analysis technique for
verifying the operations performed on variables
obey the typestate rules of the
language'. 'Strom and Yellin, 1993
4
The purpose of typestate checking is to -
ensure that programs performed their intended
operation. - security - design
assistance - eliminate 'non-sensical' programs,
which occur when an object is used illegally in
reference to its current state.
5
Typestate checking mechanics
'To track typestate in a program at compile-time,
we make typestate a static invariant proerpty of
each variable name at each poin in the program
text. That is, if a variable name has a
particular typestate at a particular point the
program text, then the corresponding
execution-time data object will have that
typestate regardless of the path taken in the
program.' Strom and Yemini, 1986
6
File handle Typestate Diagram
Uninitialized
Closed
Open
EOF
7
Public static void main(String args)
Filehandle class_grades class_grades new
Filehandle('CS431') class_grades.open()
while(!class_grades.EOF()) Student_Obj
student student class_grades.read('Stephen
Torri') student.grade 'A'
class_grades.write('Stephen Torri', student)
class_grades.close()
8
Start
Write('....')
Read('...')
Filehandle class_grades
Class_grades
EOF()
Open()
Exit
Close()
9
Important Points about Coercions 'One important
benefit of typestate analysis is that it enables
the compiler to automatically insert storage
deallocation (finalization) code.' 'At the end
of the program, we require all initialized
variables to be finalized. We could enforce this
by run-time garbage collection. However, we can
also use typestate analysis to insert static
finalization when it can be statically determined
that a data structure is dead. The inserted
operations are called coercions' Strom and
Yellin, 1993
10
Important Points about Coercions
(continued) 'Coercions give the run-time
environment the option of reclaiming memory
eagerly rather than performing periodic
reclamation.' 'Backwards dataflow analysis can
also be used to generate coercions. In fact,
using backward analysis, we sometimes finalize a
variable at an earlier point in the program
(thereby freeing storage sooner.' Strom and
Yellin, 1993
11
Points to ponder
What kind of program languages lend themselves to
incorporating typestate checking?
12
What kind of information do we expect the
programmer to provide? What part will we hide
in the compiler? How do you specify states in
the programming language?
13
What some possible uses for typestate checking?
14
Future work ideas of the authors - The framework
given is useful for checking program
correctness. - Optimizing compiles that make use
of liveness information. - To make typestate
checking practical for languages like C, stronger
analysis techniques must be used to handle
conditional initialization.
15
That's All Folks! Picture courtesy of
www.warnerbros.com
Write a Comment
User Comments (0)
About PowerShow.com