AspectC and Its Tool Support - PowerPoint PPT Presentation

1 / 60
About This Presentation
Title:

AspectC and Its Tool Support

Description:

Plan a viable commercial product supporting the program goals ... Verilog. VHDL. Jovial. ASTs. symbol table. local def, use, conditional kill, and pointer info ... – PowerPoint PPT presentation

Number of Views:18
Avg rating:3.0/5.0
Slides: 61
Provided by: gramm4
Category:

less

Transcript and Presenter's Notes

Title: AspectC and Its Tool Support


1
AspectC and Its Tool Support
An STTR Phase-I Project
Paul Anderson GrammaTech, Inc. David Binkley
GrammaTech, Inc. and Loyola College Susan
Horwitz University of Wisconsin Tim Teitelbaum
GrammaTech, Inc. and Cornell University
2
STTR Phase I Goals
  • Generic Phase I Goals
  • Plan a viable commercial product supporting the
    program goals
  • Sustainable competitive advantage
  • Leverage existing infrastructure

3
STTR Phase I Goals
  • Generic Phase I Goals
  • Plan a viable commercial product supporting the
    program goals
  • Sustainable competitive advantage
  • Leverage existing infrastructure
  • Our Phase I Goals as refined after last PCES
    meeting
  • Design an AspectC1
  • Plan associated tool support
  • 1GrammaTechs take on what such a language could
    be.

4
STTR Phase I Goals
  • Generic Phase I Goals
  • Plan a viable commercial product supporting the
    program goals
  • Sustainable competitive advantage
  • Leverage existing infrastructure
  • Our Phase I Goals as refined after last PCES
    meeting
  • Design an AspectC1
  • What can be mapped over from AspectJ?
  • What features are enabled by our infrastructure?
  • Plan associated tool support
  • 1GrammaTechs take on what such a language could
    be.

5
STTR Phase I Goals
  • Generic Phase I Goals
  • Plan a viable commercial product supporting the
    program goals
  • Sustainable competitive advantage
  • Leverage existing infrastructure
  • Our Phase I Goals as refined after last PCES
    meeting
  • Design an AspectC1
  • What can be mapped over from AspectJ?
  • What features are enabled by our infrastructure?
  • Plan associated tool support
  • Understanding/debugging woven code
  • Reengineering (find and extract latent aspects in
    existing code)
  • Preventing/detecting aspect interference
  • 1GrammaTechs take on what such a language could
    be.

6
GrammaTech Infrastructure
Analysis operations
FE1
C client code
A P I
Builder
...
IR
Pre-IR
GUI
FEm
Synthesis operations
Schemescripts
  • ASTs
  • symbol table
  • local def, use, conditional kill, and pointer
    info
  • CFGs
  • Pre-IR
  • points-to graph
  • call multi-graph
  • GMOD / GREF
  • PDGs / SDG
  • front ends
  • EDG
  • ANSI C
  • other C
  • C
  • Java
  • UML (Rose/RT)
  • Verilog
  • VHDL
  • Jovial
  • Precise interprocedural
  • - predecessors and successors
  • - slice
  • - chop
  • Boolean operations on sets of PDG nodes
  • model checking
  • semantics-based merging

Other infrastructure command-line, preprocessor,
library, and loader support
Color code done current work suspended
prototyped
7
Dependence Graphs and Slicing
void main() int sum, i sum 0 i 1
while (ilt11) sum add(sum,i) i
add(i, 1) printf(sumd\n, sum)
printf(id\n, i) static int add(int a, int
b) return (ab)
The backward slice from printf(id\n,i)
shows all possible influences on that statement.
8
AOP
  • Reminder What is an aspect?
  • An object (with fields and methods)
  • Plus advice (code to be executed at pointcuts,
    i.e., designated subsets of join points)
  • Plus introductions (new fields added to classes)
  • Questions for AspectC
  • What are the join points?
  • How are pointcuts designated?
  • Where are aspects instantiated?

9
Join Points
  • AspectJ
  • Method and constructor call/reception/execution
  • AspectC
  • Function call/execution

10
Join Points
  • AspectJ
  • Method and constructor call/reception/execution
  • AspectC
  • Function call/execution direct calls/indirect
    calls
  • pointer analysis enables efficiency for calls via
    function pointers!

11
Join Points
  • AspectJ
  • Method and constructor call/reception/execution
  • Field gets/sets
  • AspectC
  • Function call/execution direct calls/indirect
    calls
  • pointer analysis enables efficiency for calls via
    function pointers!
  • Location gets/sets
  • heap/static/stack direct/indirect access union
    casts
  • pointer analysis enables efficency for gets/sets
    via pointer!

12
Join Points
  • AspectJ
  • Method and constructor call/reception/execution
  • Field gets/sets
  • Exception handler execution
  • AspectC
  • Function call/execution direct calls/indirect
    calls
  • pointer analysis enables efficiency for calls via
    function pointers!
  • Location gets/sets
  • heap/static/stack direct/indirect access union
    casts
  • pointer analysis enables efficency for gets/sets
    via pointer!

13
Join Points
  • AspectJ
  • Method and constructor call/reception/execution
  • Field gets/sets
  • Exception handler execution
  • AspectC
  • Function call/execution direct calls/indirect
    calls
  • pointer analysis enables efficiency for calls via
    function pointers!
  • Location gets/sets
  • heap/static/stack direct/indirect access union
    casts
  • pointer analysis enables efficency for read/write
    via pointer!
  • Exercising a def-use edge i.e., a get of v that
    was set at p
  • e.g., for test-coverage monitoring
  • Instantiating a points-to set fact i.e., p is
    made to point to x

14
Pointcuts
  • AspectC
  • Similar to AspectJ
  • Designators based on static analysis results
  • DFLOW(v, p) i.e., gets of v that were set
    at p
  • POINTSTO(x,y) i.e., x is made to point to y
  • GREF( , x ) i.e., executions of functions
    that may use x
  • GMOD( , x ) i.e., executions of functions
    that may modify x
  • Possible uses of GMOD/GREF
  • Distribution aspect transform shared-variables
    (in a uni-processor model) into message passing
  • Checkpointing aspect a function on entry that
    may fail if it attempts to access a given
    variable

15
Pointcuts
  • AspectC
  • Same as AspectJ
  • Designators based on static analysis results,
    e.g.,
  • GREF( , x ) executions of
    functions that may use x
  • calls-to(GREF( , x )) calls to same
  • GMOD( , x ) executions of
    functions that may modify x
  • Example
  • Suppose
  • Functions that access variable x may fail
  • Every possibly failing function must be
    checkpointed on entry
  • The use of GREF( , x ) allows selective
    checkpointing

16
Aspect Instantiation
  • AspectJ one per
  • program execution
  • class and method
  • object instance
  • control-flow root
  • AspectC one per
  • program execution
  • file and function
  • chunk of heap-allocated storage
  • control-flow root

17
AOP Tools
  • Supporting
  • Understanding
  • what code is affected by an aspect?
  • what aspects affect a piece of code?
  • Reengineering (procedural gt aspect-oriented)
  • Preventing/reporting aspect interference

18
AOP Tools
  • Supporting
  • Understanding / debugging
  • what code is affected by an aspect?
  • forward slicing
  • what aspects affect a piece of code?
  • backward slicing
  • Reengineering (procedural gt aspect-oriented)
  • pattern matching in dependence graph
  • Preventing/reporting aspect interference
  • dependence-preserving code merging

19
Understanding Example Adding Message Decoding /
Re-encoding
main
msg _at_?x
20
Message Decoding / Re-encoding
main
msg _at_?x
decode msg
re-encode msg
high security
low security
21
Bug
main
msg _at_?x
decode msg
high security
low security
print msg
22
Show Code Affected by an Aspect Use Forward Slice
main
msg _at_?x
decode msg
high security
low security
print msg
23
Show Code Affected by an Aspect Use Forward Slice
main
msg _at_?x
decode msg
high security
low security
print msg
24
Show Code Affected by an Aspect Use Forward Slice
main
msg _at_?x
decode msg
high security
low security
print msg
25
Show Code Affected by an Aspect Use Forward Slice
main
msg _at_?x
decode msg
high security
low security
print msg
26
Show Code Affected by an Aspect Use Forward Slice
main
msg _at_?x
decode msg
high security
low security
print msg
Print statement is in the forward slice from the
decode advice, with no re-encode advice!
27
Show Code Affected by an Aspect Use Backward
Slice
main
msg _at_?x
decode msg
high security
low security
print msg
28
Show Code Affected by an Aspect Use Backward
Slice
main
msg _at_?x
decode msg
high security
low security
print msg
decode advice is in the backward slice from
the print , with no re-encode advice!
29
Reengineering example find aspects
  • Goal Find latent aspects, extract into advice
  • Use partial backward slicing to find isomorphic
    PDG subgraphs modulo possible parameterization
    (clones).

30
Step (1) Identify Aspect Clones
original program
clones
31
Step (2) Extract Clones into Advice
aspect foo before bar
original program
clones
32
Fragment 1
while (isalpha(c) c '_' c
'-') if (p token_buffermaxtoken) p
grow_token_buffer(p) if (c '-') c '_'
p c c getc(finput)
33
Fragment 1
while (isalpha(c) c '_' c
'-') if (p token_buffermaxtoken) p
grow_token_buffer(p) if (c '-') c '_'
p c c getc(finput)
34
Fragment 2
while (isdigit(c)) if (p
token_buffermaxtoken) p
grow_token_buffer(p) numval numval20 c -
0 p c c getc(finput)
35
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
36
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
37
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
38
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
39
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
40
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
41
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
42
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
43
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
44
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
45
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
46
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
47
while(isalpha(c) c- c_)
if (p token_buffer maxtoken)
if(c-)
p c
c getc(finput)
p grow_token_buffer(p)
c _
while(isdigit(c))
if (p token_buffer maxtoken)
p c
c getc(finput)
numvalnumval20 c-0
p grow_token_buffer(p)
48
Program Merging
B
X
Y
M
  • Given base program B, and two variants X and Y,
  • either derive a merged program M that preserves
    the respective differences from B of variants X
    and Y
  • or report that X and Y are incompatible variants
    (i.e., it is not possible to preserve their
    respective differences from B)

49
Aspect Merging
B
X
Y
M
  • variants X and Y are the result of weaving
    aspects x and y into separate copies of program B

50
Aspect Merging
B
X
Y
M
  • variants X and Y are the result of weaving
    aspects x and y into separate copies of program B
  • if no interference, then M is a safe composition
    of the independently woven aspects x and y

51
Aspect Merging
B
X
Y
M
  • variants X and Y are the result of weaving
    aspects x and y into separate copies of program
    B.
  • if no interference, then M is a safe composition
    of the independently woven aspects x and y.
  • if interference, then the programmer can be shown
    the source of the problem.

52
Example 1 Secret Message Aspects
  • Aspect 1 Decode the secret message on every call
    to a high-security operation, re-encode on
    return.
  • Aspect 2 Write the (encoded) secret message to a
    log file on every call to an operation that might
    modify it.

53
Which advice comes first?
main
msg _at_?x
decode msg
re-encode msg
print msg
order??
54
Choose order consistent with merged PDG
Merged PDG
Merged PDG has no data dependence from decode
to print, so print must come first!
55
Wrong order changes edges
Merged PDG
56
Example 2 Two Decode Aspects
  • Aspect 1 Decode the secret message on every call
    to a high-security operation, re-encode on
    return.
  • Aspect 2 Decode the secret message on every call
    to a non low-security operation, re-encode on
    return.

57
Which advice comes first?
main
msg _at_?x
1 re-encode msg
1 decode msg
2 re-encode msg
2 decode msg
order??
order??
use msg
Double decode produces garbage unless it is
idempotent!
58
Choose order consistent with merged PDG
main
msg _at_?x
1 re-encode msg
1 decode msg
2 re-encode msg
2 decode msg
use msg
No way to produce code without changing data
dependences interference!
59
Merged PDG
60
One order changes edges
Merged PDG
61
Other order changes edges
Merged PDG
62
Summary
  • Preliminary design for an AspectC
  • Follows example of AspectJ in many ways
  • Availability of analysis results allows some
    (old) features to be implemented more efficiently
    (e.g., pointer analysis gt gets/sets)
  • Availability of analysis results allows some new
    kinds of pointcut designators
  • PDG operations (slicing, clone finding, merging)
    can support useful AOP tools
Write a Comment
User Comments (0)
About PowerShow.com