dependent advice a general approach to optimizing history-based aspects
DESCRIPTION
Dependent Advice A General Approach to Optimizing History-based Aspects. AspectJ. as an intermediate language. Various specification languages. LTL spec. J-LO. JavaMOP. LSC. S2A. History-based. AJ aspect. abc. M2Aspects. tracematches. MSC. MOFScript. relational aspects. - PowerPoint PPT PresentationTRANSCRIPT
![Page 1: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/1.jpg)
Dependent AdviceA General Approach to
Optimizing History-based Aspects
McGill University Eric Bodden
University of Illinois at Urbana ChampaignFeng ChenGrigore Roşu
![Page 2: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/2.jpg)
JavaMOP
Various specification languages
AJ aspect
J-LOLTL spec.
S2ALSC
M2AspectsMSC
abc
relational aspects
tracematches
AspectJ
History-based
as an intermediate language
Java-STAIRS AspectsMOFScript
![Page 3: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/3.jpg)
3
Example concern
Do not write to adisconnected connection.
![Page 4: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/4.jpg)
4
aspect ConnectionClosed {Set closed = new WeakIdentityHashSet();
after / disconn /∗ ∗ (Connection c) returning:call( Connection.disconnect()) && target(c) {∗closed.add(c);
}
after / reconn /∗ ∗ (Connection c) returning:call( Connection.reconnect()) && target(c) {∗closed.remove(c);
}
before / write /∗ ∗ (Connection c) :call( Connection.write (..)) && target(c) {∗if (closed.contains(c))
error(c+” is closed !”);}
}
![Page 5: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/5.jpg)
5
AspectJ compiler
History-basedaspect
![Page 6: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/6.jpg)
6
Problem:
Potentially large
runtime overhead
![Page 7: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/7.jpg)
7
aspect ConnectionClosed {Set closed = new WeakIdentityHashSet();
after / disconn /∗ ∗ (Connection c) returning:call( Connection.disconnect()) && target(c) {∗closed.add(c);
}
after / reconn /∗ ∗ (Connection c) returning:call( Connection.reconnect()) && target(c) {∗closed.remove(c);
}
before / write /∗ ∗ (Connection c):call( Connection.write (..)) && target(c) {∗if (closed.contains(c))
error(c+” is closed !”);}
}
![Page 8: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/8.jpg)
8
“disconn write”
tracematch
Previous work: ECOOP 2007
Staticprogram analysis
Optimized Runtime
Now: general caseHistory-based
AJ aspects
![Page 9: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/9.jpg)
![Page 10: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/10.jpg)
10
Analyzing history-based aspects?/* Monitor aspect for HasNext+*/import java.util.*;import org.apache.commons.collections.map.*;class HasNextMonitorPM {
Vector monitorList = new Vector();synchronized public void hasNext(Iterator i) {
HashSet monitorSet = new HashSet();Iterator it = monitorList.iterator();while (it.hasNext()){
HasNextMonitor monitor = (HasNextMonitor)it.next();monitor.hasNext(i);if (monitorSet.contains(monitor) || monitor.failed())it.remove();else {
monitorSet.add(monitor);if (monitor.suceeded()){
… about 10 more pages
![Page 11: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/11.jpg)
11
Staticprogram analysis
History-based
AJ aspects+ Dependency
annotations
![Page 12: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/12.jpg)
Contributions and OutlineSyntax of dep. advice Semantics of dep. advice
Generating dep. advice Experimental results
![Page 13: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/13.jpg)
13
Dependent adviceaspect ConnectionClosed {
Set closed = new WeakIdentityHashSet();
after disconn(Connection c) returning:call( Connection.disconnect()) && target(c) {∗closed.add(c);
} ...
before write(Connection c):call( Connection.write (..)) && target(c) {∗if (closed.contains(c))
error(c+” is closed !”);}
} dependency{ strong disconn,write; }
![Page 14: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/14.jpg)
14
Dependent adviceaspect ConnectionClosed {
Set closed = new WeakIdentityHashSet();
after disconn(Connection c) returning:call( Connection.disconnect()) && target(c) {∗closed.add(c);
}
after reconn(Connection c) returning:call( Connection.reconnect()) && target(c) {∗closed.remove(c);
}
before write(Connection c):...
}
dependency{ strong disconn,write; weak reconn; }dependency{ strong disconn,write; }
![Page 15: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/15.jpg)
15
dependency{ strong disconn,write; weak reconn; }
disconn
write
strong
reconn
weak
ly connected”“
ly connected”“
![Page 16: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/16.jpg)
16
Verbose syntaxdependency{
strong disconn,write;weak reconn;
}
… is a shorthand for:
dependency{strong disconn(c),write(c);weak reconn(c);
}
after disconn(Connection c)before write(Connection c)after reconn(Connection c)
![Page 17: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/17.jpg)
17
When is a dependency fulfilled?dependency{
strong disconn(c),write(c);weak reconn(c);
}
Dependency is fulfilled for Connection cif both disconn(c) and write(c)do execute on c at some point in time.
![Page 18: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/18.jpg)
18
Exampledependency{
strong disconn(c),write(c);weak reconn(c);
}
Connection c1 = new Connection();Connection c2 = new Connection();c1.disconnect();c2.write(“foo”);c1.reconnect();c1.write(“bar”);
dependency fulfilled for c1,
but not fulfilled for c2
![Page 19: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/19.jpg)
19
When does a Dep. Adv. execute?
Dependent advice a must execute at a joinpoint j on objects o if there exists a
dependency d that references aand is fulfilled for objects o.
![Page 20: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/20.jpg)
20
Exampledependency{
strong disconn(c),write(c);weak reconn(c);
}
Connection c1 = new Connection();Connection c2 = new Connection();c1.disconnect();c2.write(“foo”);c1.reconnect();c1.write(“bar”);
disconn/write/reconn will execute on c1,
do not have to execute (but may) on c2
?
![Page 21: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/21.jpg)
21
Optimizing Dependent AdviceMotivated by tracematch-based analysis,
Bodden, Hendren & Lhotak (ECOOP 2007)
Two analysis stages: Quick check
syntactic Flow-insensitive Orphan-shadows
analysisuses context-sensitive points-to information
![Page 22: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/22.jpg)
![Page 23: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/23.jpg)
JavaMOP
Various specification languages
AJ aspectabc
relational aspects
tracematches
History-based
J-LOLTL spec.
S2ALSC
M2AspectsMSC
Java-STAIRS AspectsMOFScript
Auto-generating dependent advice
![Page 24: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/24.jpg)
tracematchabc compiler JavaMOP
ERE spec.FTLTL spec.PTLTL spec.
Finite-state machineFinite-state machine
Generic Algorithm Generic Algorithm
Dependency Declarations
![Page 25: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/25.jpg)
c,
a,b,ddependency{ strong a,d; }weak c; }
FSM dependency declarations
0 1 3
2
a d
c c
b b
Represents aspect’s
visual effect
dependency{ strong a,c,d; }weak b; }
err
d c∑ Represents
program startName of
dependent advice
![Page 26: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/26.jpg)
26
Proven: Algorithm is "stable"
Equivalent automata yieldequivalent dependency declarations
![Page 27: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/27.jpg)
![Page 28: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/28.jpg)
28
Benchmarks - PropertiesASyncIter FailSafeIterM
ASyncIterM HasNext
FailSafeEnum LeakingSync
FailSafeEnumHT Reader
FailSafeIter Writer
![Page 29: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/29.jpg)
29
Benchmarks - PropertiesFor each of the ten properties: Hand-coded AspectJ aspect & annotations Tracematch
Where possible: JavaMOP specification in ERE
For three specifications also: JavaMOP specification in FTLTL JavaMOP specification in PTLTL
![Page 30: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/30.jpg)
Benchmark programs
30
antlr hsqldbbloat jythonchart luceneeclipse pmdfop xalan
DaCapo benchmark suite:
![Page 31: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/31.jpg)
31
Runtime overhead
<=10%; 308 >10%; 72
380 woven programs
![Page 32: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/32.jpg)
32
Elimination of all shadows
Quick-Check; 24
Orphan-shadows
analysis; 12
Shadows remaining;
36
72 programs with overhead >10%
zero overhead after optimization
![Page 33: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/33.jpg)
33
Reduction of runtime overhead
reduced to <=10%; 8 Some reduction;
18 No reduction; 10
36 programs with overhead >10%and shadows remaining
average reduction:by 37%
![Page 34: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/34.jpg)
34
Limitations
after() returning(Object o):IgnoreTargets() {ignoredTargets.put(o,o);
}
after(Object thiz,Object targt):Any.MethodCall(thiz,targt) && !IgnoreCalls() {if (!ignoredTargets.containsKey(targt) && !Pertarget.aspectOf(thiz).contains(targt)){objectVolations.put(tjSP, tjSP); }
}
¬Law-of-Demeter Checker (Lieberherr et al.)
![Page 35: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/35.jpg)
![Page 36: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/36.jpg)
36
Related work
![Page 37: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/37.jpg)
37
Related workAlready mentioned: S2A (Maoz & Harel, FSE 2006) M2Aspects (Krüger et al., SCESM 2006) Java-STAIRS Aspects (Oldevik & Haugen, 5pm) J-LO (Bodden, Diploma Thesis)
Other possible clients of dependent advice: Association aspects (Sakurai et al., AOSD 2004) LogicAJ (Kniesel et al., RAM-SE 2004) Dataflow pointcuts (Masuhara & Kawauchi, APLAS
2003; and tomorrow, 14:30) Conditional compilation (Adams et al., Friday)
![Page 38: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/38.jpg)
38
Related workOptimizations for tracematches: Bodden, Hendren & Lhotak, ECOOP 2007 Bodden, Lam & Hendren, FSE 2008 Naeem & Lhotak, OOPSLA 2008
Optimizations of the Runtime Monitor: Avgustinov et al., OOPSLA 2007 Chen & Rosu, TACAS 2009
![Page 39: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/39.jpg)
39
Important conclusionApproach hard to formalize without AOP History-based aspect modularizes
instrumentation Hence can use modular dependency
annotation
![Page 40: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/40.jpg)
40
Acknowledgementsco-workers: Laurie Hendren Patrick Lam
developer of S2A: Shahar Maoz
abc/tracematch maintainers: Pavel Avgustinov Julian Tibble
![Page 41: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/41.jpg)
![Page 42: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/42.jpg)
www.aspectbench.orgwww.bodden.de
![Page 43: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/43.jpg)
![Page 44: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/44.jpg)
![Page 45: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/45.jpg)
45
Static analysisdependency{
strong disconn(c),write(c);weak reconn(c);
}
Connection c1 = new Connection(); //(1)
Connection c2 = new Connection(), c3; //(2)c1.disconnect();c2.write(“foo”);c1.reconnect();c3 = c1;c3.write(“bar”);
![Page 46: Dependent Advice A General Approach to Optimizing History-based Aspects](https://reader036.vdocument.in/reader036/viewer/2022062520/568161ce550346895dd1be07/html5/thumbnails/46.jpg)
46
Results – Static-analysis time
45%
53%
2%
compilationpoints-to analysisour analyses
Average total: 12 minutesMax total: 58 minutes