Nu: a Dynamic Aspect-Oriented Intermediate Language Model and - - PowerPoint PPT Presentation

nu a dynamic aspect oriented intermediate language model
SMART_READER_LITE
LIVE PREVIEW

Nu: a Dynamic Aspect-Oriented Intermediate Language Model and - - PowerPoint PPT Presentation

Nu: a Dynamic Aspect-Oriented Intermediate Language Model and Virtual Machine for Flexible Runtime Adaptation Robert Dyer and Hridesh Rajan Department of Computer Science Iowa State University { rdyer,hridesh } @cs.iastate.edu 7 th


slide-1
SLIDE 1

Nu: a Dynamic Aspect-Oriented Intermediate Language Model and Virtual Machine for Flexible Runtime Adaptation

Robert Dyer and Hridesh Rajan

Department of Computer Science Iowa State University {rdyer,hridesh}@cs.iastate.edu

7th International Conference on Aspect-Oriented Software Development

slide-2
SLIDE 2

Overview Motivation Our Approach Evaluation Summary

◮ Motivation: Supporting dynamic aspect-oriented constructs ◮ Approach: Nu ◮ Evaluation: Expressiveness and performance ◮ Technical Contributions:

◮ Flexible, dynamic AO intermediate language model ◮ Implementation in industrial strength VM (Sun Hotspot) ◮ Dedicated AO caching mechanism Robert Dyer and Hridesh Rajan 2 Nu: Dynamic AO IL Model and VM

slide-3
SLIDE 3

Overview Motivation Our Approach Evaluation Summary

Need For a Dynamic IL Model

◮ Currently: Dynamic, high-level AO constructs → low-level

OO representation

◮ AO compilers need “building blocks”! ◮ Perhaps an example...

Robert Dyer and Hridesh Rajan 3 Nu: Dynamic AO IL Model and VM

slide-4
SLIDE 4

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts

◮ History-based pointcuts [Douence, Fradet, and S¨

udholt]

◮ Temporal constructs in AspectJ [Stolz and Bodden]

Robert Dyer and Hridesh Rajan 4 Nu: Dynamic AO IL Model and VM

slide-5
SLIDE 5

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts

◮ History-based pointcuts [Douence, Fradet, and S¨

udholt]

◮ Temporal constructs in AspectJ [Stolz and Bodden]

  • Robert Dyer and Hridesh Rajan

5 Nu: Dynamic AO IL Model and VM

slide-6
SLIDE 6

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts - Static Translation

Robert Dyer and Hridesh Rajan 6 Nu: Dynamic AO IL Model and VM

slide-7
SLIDE 7

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts - Static Translation

Robert Dyer and Hridesh Rajan 7 Nu: Dynamic AO IL Model and VM

slide-8
SLIDE 8

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts - Dynamic Support

Robert Dyer and Hridesh Rajan 8 Nu: Dynamic AO IL Model and VM

slide-9
SLIDE 9

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts - Dynamic Support

Robert Dyer and Hridesh Rajan 9 Nu: Dynamic AO IL Model and VM

slide-10
SLIDE 10

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts - Dynamic Support

Robert Dyer and Hridesh Rajan 10 Nu: Dynamic AO IL Model and VM

slide-11
SLIDE 11

Overview Motivation Our Approach Evaluation Summary

History-based Pointcuts - Dynamic Support

Robert Dyer and Hridesh Rajan 11 Nu: Dynamic AO IL Model and VM

slide-12
SLIDE 12

Overview Motivation Our Approach Evaluation Summary

Need For a Dynamic IL Model

◮ Inadequate support for dynamic use cases in current ILs

◮ Dynamic deployment, ◮ Dynamic adaptation, ◮ Policy changes, etc

◮ Dynamically adapting set of advised join points

◮ Morphing aspects [Hanenberg et al.] ◮ Open Aspects [Hirschfeld and Hanenberg] Robert Dyer and Hridesh Rajan 12 Nu: Dynamic AO IL Model and VM

slide-13
SLIDE 13

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Overview of the Nu Model

◮ JPM: Point-in-time model [Masuhara et al.] ◮ New primitives: bind and remove ◮ Advice as delegate methods ◮ Library of patterns

◮ First-class, immutable objects Robert Dyer and Hridesh Rajan 13 Nu: Dynamic AO IL Model and VM

slide-14
SLIDE 14

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Two New Primitives: Bind and Remove

Stack Transition Exceptions bind ..., Pattern, Delegate → ..., BindHandle NullPointerEx remove ..., BindHandle → ... IllegalArgumentEx This talk uses source representation for ease.

Robert Dyer and Hridesh Rajan 14 Nu: Dynamic AO IL Model and VM

slide-15
SLIDE 15

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Bind and Remove Example

public class AuthLogger { }

Robert Dyer and Hridesh Rajan 15 Nu: Dynamic AO IL Model and VM

slide-16
SLIDE 16

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Bind and Remove Example

public class AuthLogger { protected static Pattern p; protected static Delegate d; static { p = new Execution(new Method("*.login")); d = new Delegate(AuthLogger.class, "log"); } public static void log() { // record the time of login } }

Robert Dyer and Hridesh Rajan 16 Nu: Dynamic AO IL Model and VM

slide-17
SLIDE 17

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Bind and Remove Example

public class AuthLogger { protected static Pattern p; protected static Delegate d; static { p = new Execution(new Method("*.login")); d = new Delegate(AuthLogger.class, "log"); } public static void log() { // record the time of login } }

Robert Dyer and Hridesh Rajan 17 Nu: Dynamic AO IL Model and VM

slide-18
SLIDE 18

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Bind and Remove Example

public class AuthLogger { protected static Pattern p; protected static Delegate d; static { p = new Execution(new Method("*.login")); d = new Delegate(AuthLogger.class, "log"); } public static void log() { // record the time of login } }

Robert Dyer and Hridesh Rajan 18 Nu: Dynamic AO IL Model and VM

slide-19
SLIDE 19

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Bind and Remove Example

public class AuthLogger { protected static Pattern p; protected static Delegate d; protected static BindHandle id = null; static { p = new Execution(new Method("*.login")); d = new Delegate(AuthLogger.class, "log"); } public static void enable() { id = bind(p, d); } public static void log() { // record the time of login } }

Robert Dyer and Hridesh Rajan 19 Nu: Dynamic AO IL Model and VM

slide-20
SLIDE 20

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Bind and Remove Example

public class AuthLogger { protected static Pattern p; protected static Delegate d; protected static BindHandle id = null; static { p = new Execution(new Method("*.login")); d = new Delegate(AuthLogger.class, "log"); } public static void enable() { id = bind(p, d); } public static void disable() { remove(id); } public static void log() { // record the time of login } }

Robert Dyer and Hridesh Rajan 20 Nu: Dynamic AO IL Model and VM

slide-21
SLIDE 21

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Implementation Overview

◮ Built on top of Sun Hotspot VM ◮ Adds code to the interpreter for join point dispatch ◮ bind and remove implemented as native methods

Robert Dyer and Hridesh Rajan 21 Nu: Dynamic AO IL Model and VM

slide-22
SLIDE 22

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Implementation Overview

Robert Dyer and Hridesh Rajan 22 Nu: Dynamic AO IL Model and VM

slide-23
SLIDE 23

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Implementation Overview

Robert Dyer and Hridesh Rajan 23 Nu: Dynamic AO IL Model and VM

slide-24
SLIDE 24

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Novel AO Caching Mechanism

Robert Dyer and Hridesh Rajan 24 Nu: Dynamic AO IL Model and VM

slide-25
SLIDE 25

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Caching Mechanism

  • !
  • Robert Dyer and Hridesh Rajan

25 Nu: Dynamic AO IL Model and VM

slide-26
SLIDE 26

Overview Motivation Our Approach Evaluation Summary The Nu Intermediate Language Model The Nu Virtual Machine

Caching Mechanism

  • !
  • Robert Dyer and Hridesh Rajan

26 Nu: Dynamic AO IL Model and VM

slide-27
SLIDE 27

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance

Expressing Constructs

◮ Supports multiple language constructs:

◮ AspectJ aspects, pointcuts and advice ◮ cflow, cflowbelow ◮ History-based pointcuts ◮ CaesarJ’s deploy Robert Dyer and Hridesh Rajan 27 Nu: Dynamic AO IL Model and VM

slide-28
SLIDE 28

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance

Expressing Constructs

◮ Supports multiple language constructs:

◮ AspectJ aspects, pointcuts and advice ◮ cflow, cflowbelow ◮ History-based pointcuts ◮ CaesarJ’s deploy Robert Dyer and Hridesh Rajan 28 Nu: Dynamic AO IL Model and VM

slide-29
SLIDE 29

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance

cflow(execution(setWord)) && execution(setBit)

Robert Dyer and Hridesh Rajan 29 Nu: Dynamic AO IL Model and VM

slide-30
SLIDE 30

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance

cflow(execution(setWord)) && execution(setBit)

Robert Dyer and Hridesh Rajan 30 Nu: Dynamic AO IL Model and VM

slide-31
SLIDE 31

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance

cflow(execution(setWord)) && execution(setBit)

Robert Dyer and Hridesh Rajan 31 Nu: Dynamic AO IL Model and VM

slide-32
SLIDE 32

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance

Performance Evaluation Overview

◮ Java Grande, SPEC JVM98, and custom

micro-benchmarks

◮ Unmodified VM, Nu VM (caching), Nu VM (no caching) ◮ Only about 1.5% overhead

Robert Dyer and Hridesh Rajan 32 Nu: Dynamic AO IL Model and VM

slide-33
SLIDE 33

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance Robert Dyer and Hridesh Rajan 33 Nu: Dynamic AO IL Model and VM

slide-34
SLIDE 34

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance Robert Dyer and Hridesh Rajan 34 Nu: Dynamic AO IL Model and VM

slide-35
SLIDE 35

Overview Motivation Our Approach Evaluation Summary Expressiveness Performance Robert Dyer and Hridesh Rajan 35 Nu: Dynamic AO IL Model and VM

slide-36
SLIDE 36

Overview Motivation Our Approach Evaluation Summary

Related Work

◮ Steamloom - Bockisch, Haupt, Mezini, and Ostermann ◮ Prose - Popovici, Alonso, and Gross ◮ Delegation-based Machine Model - Haupt and Schippers ◮ Morphing Aspects and Continuous Weaving - Hanenberg,

Hirschfeld, and Unland

Robert Dyer and Hridesh Rajan 36 Nu: Dynamic AO IL Model and VM

slide-37
SLIDE 37

Overview Motivation Our Approach Evaluation Summary

Future Work

Robert Dyer and Hridesh Rajan 37 Nu: Dynamic AO IL Model and VM

slide-38
SLIDE 38

Overview Motivation Our Approach Evaluation Summary

◮ Motivation: Supporting dynamic aspect-oriented constructs

◮ cflow, deploy, history-based, etc ◮ Compiled into static constructs ◮ Lower-level support may yield run-time benefits

◮ Approach: Nu

◮ IL-level primitives for dynamic deployment ◮ Dedicated caching mechanism (low overhead)

◮ Evaluation: Expressiveness and performance

◮ Supports large subset of dynamic AO constructs ◮ Only about 1.5% overhead

◮ Technical Contributions:

◮ Flexible, dynamic AO intermediate language model ◮ Implementation in industrial strength VM (Sun Hotspot) ◮ Dedicated AO caching mechanism Robert Dyer and Hridesh Rajan 38 Nu: Dynamic AO IL Model and VM

slide-39
SLIDE 39

Overview Motivation Our Approach Evaluation Summary

Questions?

http://www.cs.iastate.edu/˜nu/

Robert Dyer and Hridesh Rajan 39 Nu: Dynamic AO IL Model and VM

slide-40
SLIDE 40
slide-41
SLIDE 41

Caching Mechanism Assembly Code

movl eax, methodOop.counter movl ecx, globalCounter // methodOop.counter == globalCounter? cmpl eax, ecx jcc equals, InvokeDelegates call_VM incrementalMatcher InvokeDelegates: movl eax, methodOop.cache.head // cache.head == NULL? testl eax, eax jcc zero, ContinueJP // invoke the cached delegates ContinueJP:

slide-42
SLIDE 42

Pattern Library Example

slide-43
SLIDE 43

Pattern Library Example

slide-44
SLIDE 44

Pattern Library Example

slide-45
SLIDE 45

Temporal Constructs - AspectJ

aspect Tcheck { pointcut p1(): call(* Word.set(..)); int p1 = 1; pointcut p2(): call(* Bit.set(..)); int p2 = 2; Formula state = Globally(p1, Finally(p2)); Set<int> propSet = new Set<int>(); ...

slide-46
SLIDE 46

Temporal Constructs - AspectJ

aspect Tcheck { pointcut p1(): call(* Word.set(..)); int p1 = 1; pointcut p2(): call(* Bit.set(..)); int p2 = 2; Formula state = Globally(p1, Finally(p2)); Set<int> propSet = new Set<int>(); ...

slide-47
SLIDE 47

Temporal Constructs - AspectJ

aspect Tcheck { pointcut p1(): call(* Word.set(..)); int p1 = 1; pointcut p2(): call(* Bit.set(..)); int p2 = 2; Formula state = Globally(p1, Finally(p2)); Set<int> propSet = new Set<int>(); ...

slide-48
SLIDE 48

Temporal Constructs - AspectJ

... after(): p1() { propSet.add(p1); } after(): p2() { propSet.add(p2); } after(): p1() || p2() { state = state.transition(propSet); if (state.equals(Formula.TT)) // report formula as satisfied else if(state.equals(Formula.FF)) // report formula as falsified state.clear(); //reset proposition vector }

slide-49
SLIDE 49

Temporal Constructs - AspectJ

... after(): p1() { propSet.add(p1); } after(): p2() { propSet.add(p2); } after(): p1() || p2() { state = state.transition(propSet); if (state.equals(Formula.TT)) // report formula as satisfied else if(state.equals(Formula.FF)) // report formula as falsified state.clear(); //reset proposition vector }

slide-50
SLIDE 50

Temporal Constructs - Nu

class Tcheck { int p1 = 1; int p2 = 2; Formula state = Globally(p1, Finally(p2)); Set<int> propSet = new Set<int>(); ...

slide-51
SLIDE 51

Temporal Constructs - Nu

class Tcheck { int p1 = 1; int p2 = 2; Formula state = Globally(p1, Finally(p2)); Set<int> propSet = new Set<int>(); ...

slide-52
SLIDE 52

Temporal Constructs - Nu

class Tcheck { int p1 = 1; int p2 = 2; Formula state = Globally(p1, Finally(p2)); Set<int> propSet = new Set<int>(); ...

slide-53
SLIDE 53

Temporal Constructs - Nu

... protected static Pattern prop2; protected static Delegate d2; static { Pattern prop1 = new Call("* Word.set(..)"); d1 = new Delegate(Tcheck.class, "afterP1"); bind(prop1, d1); prop2 = new Call("* Bit.set(..)"); d2 = new Delegate(Tcheck.class, "afterP2"); Pattern afterP1P2 = new Or(prop1, prop2); d3 = new Delegate(Tcheck.class, "afterP1P2"); bind(afterP1P2, d3); }

slide-54
SLIDE 54

Temporal Constructs - Nu

... protected static Pattern prop2; protected static Delegate d2; static { Pattern prop1 = new Call("* Word.set(..)"); d1 = new Delegate(Tcheck.class, "afterP1"); bind(prop1, d1); prop2 = new Call("* Bit.set(..)"); d2 = new Delegate(Tcheck.class, "afterP2"); Pattern afterP1P2 = new Or(prop1, prop2); d3 = new Delegate(Tcheck.class, "afterP1P2"); bind(afterP1P2, d3); }

slide-55
SLIDE 55

Temporal Constructs - Nu

... protected static Pattern prop2; protected static Delegate d2; static { Pattern prop1 = new Call("* Word.set(..)"); d1 = new Delegate(Tcheck.class, "afterP1"); bind(prop1, d1); prop2 = new Call("* Bit.set(..)"); d2 = new Delegate(Tcheck.class, "afterP2"); Pattern afterP1P2 = new Or(prop1, prop2); d3 = new Delegate(Tcheck.class, "afterP1P2"); bind(afterP1P2, d3); }

slide-56
SLIDE 56

Temporal Constructs - Nu

... protected static BindHandle id; public void afterP1() { propSet.add(p1); id = bind(prop2, d2); } public void afterP2() { propSet.add(p2); remove(id); } public void afterP1P2() { ... // same as before }

slide-57
SLIDE 57

Temporal Constructs - Nu

... protected static BindHandle id; public void afterP1() { propSet.add(p1); id = bind(prop2, d2); } public void afterP2() { propSet.add(p2); remove(id); } public void afterP1P2() { ... // same as before }

slide-58
SLIDE 58

Temporal Constructs - Nu

... protected static BindHandle id; public void afterP1() { propSet.add(p1); id = bind(prop2, d2); } public void afterP2() { propSet.add(p2); remove(id); } public void afterP1P2() { ... // same as before }