Introducing ABC Programming Languages and AOP Oege de
Introducing ABC: Programming Languages and AOP 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 (Mc. Gill) Aske Simon Christensen (Århus)
Roadmap ● Novel features – ● Performance – ● The fun has just begun It may become cheap ABC: the Aspect. Bench Compiler – Extensible: Polyglot – Analysis & optimisation: Soot
Tracecuts a e b c joinpoint tree f d g h before a, before b, before c, after c, before d, after b, before e, before f, before g, after g, before h, after f, after e, after a
Observer as tracecut aspect observer { tracecut update(Subject s, Observer o): // 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(); } }
Performance
The Aspect. Bench Compiler Aspect. J source, and jars Polyglot Java compiler Java extracts of source Aspect. J extension Jimple aspect. Info intertype adjuster analyse & optimise advice weaver class files Soot analysis and transformation framework
Polyglot: scope for intertype decls public class A { int x; need to disambiguate: when do we refer to host? ● class B { no explicit receiver? if it was introduced into environment by the host, give it “this” from host. int x; ● 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. 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; } } implementation: ● extend environment type ● new AST nodes “host. Special” (this/super) ● ITDs add accessible members from host ● rewrite rules to disambiguate this/super to “Special” or “host. Special”
Jimple public static int Aspect$foo$1(A$B) { A$B this$2; Aspect$1 C $r 0; int $i 0, $i 1, $i 2, $i 3, $i 4; 3 -address intermediate form ● proven basis for static analysis ● easy to weave into ● this$2 : = @parameter 0: A$B; $r 0 = new Aspect$1 C; specialinvoke $r 0. <Aspect$1 C: void <init>(A$B)>(this$2); $i 0 = virtualinvoke $r 0. <Aspect$1 C: int bar()>(); $i 1 = this$2. <A$B: int x>; $i 2 = $i 0 + $i 1; $i 3 = <Aspect: int y>; $i 4 = $i 2 + $i 3; return $i 4; }
ABC performance
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
- Slides: 10