100 likes | 185 Views
Oege de Moor Programming Tools Group University of Oxford joint work with Ganesh Sittampalam, Sascha Kuzins, Chris Allan, Pavel Avgustinov, Julian Tibble, Damien Sereni (Oxford)
E N D
Oege de Moor Programming Tools Group University of Oxford joint work with Ganesh Sittampalam, Sascha Kuzins, Chris Allan, Pavel Avgustinov, Julian Tibble, Damien Sereni (Oxford) Laurie Hendren, Jennifer Lhoták, Ondřej Lhoták, Bruno Dufour, Christopher Goard, Clark Verbrugge (McGill) Aske Simon Christensen (Århus) Introducing ABC:Programming Languages and AOP
Roadmap • Novel features • The fun has just begun • Performance • It may become cheap • ABC: the AspectBench Compiler • Extensible: Polyglot • Analysis & optimisation: Soot
a e b f d c h g Tracecuts joinpoint tree before a, before b, before c, after c, before d, after d, after b, before e, before f, before g, after g, before h, after h, after f, after e, after a
Observer as tracecut aspectobserver { tracecutupdate(Subjects, Observero): // declaration of events of interest: create_observer: after returning(o) call(Observer.new(..)) && args(s) update_subject: after call(* Subject.update(..)) && target(s); // regular expression pattern to match against suffixes of traces: create_observer update_subject+ // advice to execute (once for each (s,o) binding) { o.update_view(); } }
Polyglot Java compiler Java extracts of source AspectJ extension Jimple Soot analysis and transformation framework aspectInfo intertype adjuster advice weaver The AspectBench Compiler AspectJ source, and jars analyse & optimise class files
Polyglot: scope for intertype decls public class A { int x; class B { int x; } } aspect Aspect { static int x; static int y; int A.B.foo() { class C { int x = 3; int bar() {return x + A.this.x;} } return (new C()).bar() + x + y; } } need to disambiguate: when do we refer to host? • no explicit receiver? if it was introduced into environment by the host, give it “this” from host. • explicit “this” or “super”? if there is no qualifier and we're not inside a local class, it refers to the host. If there is a qualifier Q, it refers to the host if the host has an enclosing instance of type Q. implementation: • extend environment type • new AST nodes “hostSpecial” (this/super) • ITDs add accessible members from host • rewrite rules to disambiguate this/super to “Special” or “hostSpecial”
Jimple publicstatic int Aspect$foo$1(A$B) { A$B this$2; Aspect$1C $r0; int $i0, $i1, $i2, $i3, $i4; this$2 := @parameter0: A$B; $r0 = new Aspect$1C; specialinvoke $r0.<Aspect$1C: void <init>(A$B)>(this$2); $i0 = virtualinvoke $r0.<Aspect$1C: int bar()>(); $i1 = this$2.<A$B: int x>; $i2 = $i0 + $i1; $i3 = <Aspect: int y>; $i4 = $i2 + $i3; return $i4; } • 3-address intermediate form • proven basis for static analysis • easy to weave into
ABC Summary • A second compiler helps language research • precise language description • Whole-program, aimed at • extensibility, • static analysis • performance of compiled code • Suite of tools: decompiler, performance measurement, visualisation in Eclipse • Small, easy to learn: < 500 classes, 45 KLOC • Current status: • pass majority of ajc tests • likely release mid-October