Automated Software Engineering Using - SUNY

advertisement
Automated Software
Engineering with Concurrent
Class Machines
Radu Grosu
SUNY at Stony Brook
joint work with
Y. Liu, S. Smolka, S.Stoller, J. Yan
SUNY at Stony Brook
Motivation (ASE)
Automated OO software development method:
• OO language for req.specification/modeling/implem,
• transition semantics capturing OO constructs,
• trace semantics supporting compositional refinement,
• analysis exploiting OO structure,
• generation of optimized (and monitored) code.
Close the gap between:
• object oriented methods (UML,OMT,…),
• formal methods (Model Checking, Static Analysis,…).
Concurrent Class Machines (CCM)
1. Modeling language for concurrent OO systems
•
•
•
classes, inheritance, objects, object creation
methods, exceptions, multithreading,
abstract collection types, nondeterminism.
2. Observational trace semantics
•
•
class machine refinement,
modular reasoning.
3. Code generation and analysis
•
•
prototype code generation.
exploits the hierarchy information (in progress),
Readers/Writers Problem
Resource
Class Diagram
res
Monitor
1
Thread
*
m
1
*
RdCap
m
Client
WrCap
Classes
Monitor
attributes
res: Resource; -free: boolean; ar: int;
+Monitor(r:Resource)
+acqRd(): void
void
Call entry+acqWr():
point
return exit point
+relRd(): void
+relWr(): void
Method signature
methods
Transitions
Monitor
res: Resource; -free: boolean; ar: int;
+Monitor(r:Resource)
+acqRd()
transition
(atomic)
free | ar > 0 -> free := false; ar := ar+1
+acqWr() guard
+relRd()
(blocking)
+relWr()
method can be
declared atomic
assignments
(parallel)
Call Hierarchy (Boxes)
RdCap
-m: Monitor; -inCS: boolean;
+RdCap(m:Monitor)
+acq():void throws MonExc
local
return
variables
+rel():void throws MonExc
expression
choice point
return
+read():int throws MonExc
v: int; e:MonExc
(nondeterminism)
v
variable
v
inCs
! inCS
new MonExc
object
creation box
e
m.res.read()
method
invocation box
e
exception
exit point
Concurrency
Client extends Thread
-m: Monitor
+main(): void
new Resource
r
new Monitor(r)
+run(): void
thread
run method
r: Resource; c: Client
m
new Client(m)
c
new Client(m)
c
c.start
c.start
thread
start box
Operational Semantics
Transition system A* = (S, s0, )
Ctrl Frame
Stack Stack
n0
f0k0
ni
b0k0 f0k0-1
…
…
b01
f00
biki fiki-1
…
Object Pool
…
n’0
fiki
…
…
bi1
fi0
t0:Thread … ti:Thread
Attrt0
Ctrl Frame
Stack Stack
Ctrl Frame
Stack Stack
Attrti
t0
Ctrl Frame
Stack Stack
f’0k0
ni
b0k0 f0k0-1
…
…
b01
f00
fiki
biki fiki-1
…
…
…
bi1
fi0
t0:Thread … ti:Thread
Attr’t0
Object Pool
…
Attrti
Method Invocation Box
Client
Ctrl Frame
Stack Stack
-m: Monitor
+run(): int
r: Resource; i: int
i
r.read()
b
Resource
+read(): int
RResource
+read(): int
v
v
b.c
f
…
…
Method Invocation Box (Call)
Client
Ctrl Frame
Stack Stack
-m: Monitor
+run(): int
r: Resource; i: int
i
r.read()
b.c
f
…
…
b
Resource
+read(): int
RResource
+read(): int

v
v
c
fb
b
f
…
…
Ctrl Frame
Stack Stack
Method Invocation Box (Return)
Client
Ctrl Frame
Stack Stack
-m: Monitor
+run(): int
r: Resource; i: int
i
r.read()
b.r f[v/i]
…
b
Resource
+read(): int
RResource
+read(): int
…

v
v
r
fb
b
f
…
…
Ctrl Frame
Stack Stack
Environment (Interface) Objects
Client
Ctrl Frame
Stack Stack
-m: Monitor
+run(): int
r: Resource; i: int
i
r.read()
b.r f[v/i]
…
…
b
Resource
+read(): int
Static vars, streams…
v
Allow compositional
modeling & reasoning:
• Their body is not known and not part of 
• Allow any update of public objects. The latter are
determined via an escape analysis.
Denotational Semantics
Execution of CCM m
•
•
•
s0-> s1-> s2->… -> sn
si-> si+1 is a CCM transition in  or
si-> si+1 is an environment transition.
Set of Traces Lm of m
•
Projection of executions on global variables.
•
Object escape analysis is necessary.
Refinement m < n
•
Inclusion of the sets of traces Lm  Ln
•
Compositional w.r.t. beh/arch hierarchies.
Modular Reasoning
N
M
N
<
<
N’
M
N
N’
M
M
Sub-CCM refinement
M
<
N
=
N
M’
Super-CCM refinement
M
lfp
<
M’
N
M’
M’
M
<
N
Fixpoint induction
<
N
Wrap Up
1. Modeling language for concurrent OO systems
•
•
•
classes, inheritance, objects, object creation
methods, exceptions, multithreading,
abstract collection types, nondeterminism.
2. Observational trace semantics
•
•
class machine refinement,
modular reasoning.
3. Code generation and analysis
•
•
prototype code generation.
exploits the hierarchy information (in progress),
Download