10
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 (McGill) Aske Simon Christensen (Århus)

Introducing ABC: Programming Languages and AOP

  • Upload
    zhen

  • View
    24

  • Download
    0

Embed Size (px)

DESCRIPTION

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) - PowerPoint PPT Presentation

Citation preview

Page 1: Introducing ABC: Programming Languages and AOP

Introducing ABC:Programming Languages and

AOPOege de Moor

Programming Tools GroupUniversity 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)

Page 2: 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

Page 3: Introducing ABC: Programming Languages and AOP

Tracecutsa

d

eb

c

g

f

h

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

joinpoint tree

Page 4: Introducing ABC: Programming Languages and AOP

Observer as tracecutaspect 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();}

}

Page 5: Introducing ABC: Programming Languages and AOP

Performance

DCM ProdLin Bean NllChk Figure LoD0

20

40

60

80

100

120

Overheads(%)

Slowdown(*)

Page 6: Introducing ABC: Programming Languages and AOP

The AspectBench Compiler

AspectJextension

AspectJsource,and jars

Polyglot Javacompiler

aspectInfo

Java extracts of source

Jimple

intertypeadjuster

advice weaver

Sootanalysis and

transformationframework

class files

analyse &optimise

Page 7: Introducing ABC: Programming Languages and AOP

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”

Page 8: Introducing ABC: Programming Languages and AOP

Jimple public static 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

Page 9: Introducing ABC: Programming Languages and AOP

ABC performance

DCM prdlin bean nllptr figure LoD0

1

2

3

4

5

6

7

8

9

ajc/abc

Page 10: Introducing ABC: Programming Languages and AOP

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