58
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 International Conference on Aspect-Oriented Software Development

Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

  • Upload
    others

  • View
    2

  • Download
    0

Embed Size (px)

Citation preview

Page 1: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Nu: a Dynamic Aspect-Oriented IntermediateLanguage Model and Virtual Machine for

Flexible Runtime Adaptation

Robert Dyer and Hridesh Rajan

Department of Computer ScienceIowa State University

{rdyer,hridesh}@cs.iastate.edu

7th International Conference onAspect-Oriented Software Development

Page 2: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

I Motivation: Supporting dynamic aspect-oriented constructsI Approach: NuI Evaluation: Expressiveness and performanceI Technical Contributions:

I Flexible, dynamic AO intermediate language modelI Implementation in industrial strength VM (Sun Hotspot)I Dedicated AO caching mechanism

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

Page 3: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

Need For a Dynamic IL Model

I Currently: Dynamic, high-level AO constructs → low-levelOO representation

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

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

Page 4: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts

I History-based pointcuts [Douence, Fradet, and Sudholt]I Temporal constructs in AspectJ [Stolz and Bodden]

�� ����������� �

������������

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

Page 5: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts

I History-based pointcuts [Douence, Fradet, and Sudholt]I Temporal constructs in AspectJ [Stolz and Bodden]

�� ����������� � ������������

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

Page 6: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts - Static Translation

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

Page 7: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts - Static Translation

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

Page 8: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts - Dynamic Support

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

Page 9: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts - Dynamic Support

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

Page 10: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts - Dynamic Support

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

Page 11: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

History-based Pointcuts - Dynamic Support

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

Page 12: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

Need For a Dynamic IL Model

I Inadequate support for dynamic use cases in current ILsI Dynamic deployment,I Dynamic adaptation,I Policy changes, etc

I Dynamically adapting set of advised join pointsI Morphing aspects [Hanenberg et al.]I Open Aspects [Hirschfeld and Hanenberg]

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

Page 13: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Overview of the Nu Model

I JPM: Point-in-time model [Masuhara et al.]I New primitives: bind and removeI Advice as delegate methodsI Library of patterns

I First-class, immutable objects

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

Page 14: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Two New Primitives: Bind and Remove

Stack Transition Exceptionsbind ..., Pattern, Delegate →

..., BindHandleNullPointerEx

remove ..., BindHandle → ... IllegalArgumentEx

This talk uses source representation for ease.

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

Page 15: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe 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 15 Nu: Dynamic AO IL Model and VM

Page 16: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe 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 16 Nu: Dynamic AO IL Model and VM

Page 17: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe 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 17 Nu: Dynamic AO IL Model and VM

Page 18: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe 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 18 Nu: Dynamic AO IL Model and VM

Page 19: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe 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 19 Nu: Dynamic AO IL Model and VM

Page 20: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe 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

Page 21: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Implementation Overview

I Built on top of Sun Hotspot VMI Adds code to the interpreter for join point dispatchI bind and remove implemented as native methods

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

Page 22: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Implementation Overview

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

Page 23: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Implementation Overview

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

Page 24: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Novel AO Caching Mechanism

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

Page 25: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Caching Mechanism

��������������

��� ���������

������������������

����

������������

��

�����������������

����

���������������� !������

��

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

Page 26: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

The Nu Intermediate Language ModelThe Nu Virtual Machine

Caching Mechanism

��������������

��� ���������

������������������

����

������������

��

�����������������

����

���������������� !������

��

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

Page 27: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

Expressing Constructs

I Supports multiple language constructs:I AspectJ aspects, pointcuts and adviceI cflow, cflowbelowI History-based pointcutsI CaesarJ’s deploy

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

Page 28: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

Expressing Constructs

I Supports multiple language constructs:I AspectJ aspects, pointcuts and adviceI cflow, cflowbelowI History-based pointcutsI CaesarJ’s deploy

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

Page 29: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

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

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

Page 30: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

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

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

Page 31: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

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

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

Page 32: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

Performance Evaluation Overview

I Java Grande, SPEC JVM98, and custommicro-benchmarks

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

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

Page 33: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

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

Page 34: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

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

Page 35: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

ExpressivenessPerformance

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

Page 36: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

Related Work

I Steamloom - Bockisch, Haupt, Mezini, and OstermannI Prose - Popovici, Alonso, and GrossI Delegation-based Machine Model - Haupt and SchippersI Morphing Aspects and Continuous Weaving - Hanenberg,

Hirschfeld, and Unland

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

Page 37: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

Future Work

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

Page 38: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

I Motivation: Supporting dynamic aspect-oriented constructsI cflow, deploy, history-based, etcI Compiled into static constructsI Lower-level support may yield run-time benefits

I Approach: NuI IL-level primitives for dynamic deploymentI Dedicated caching mechanism (low overhead)

I Evaluation: Expressiveness and performanceI Supports large subset of dynamic AO constructsI Only about 1.5% overhead

I Technical Contributions:I Flexible, dynamic AO intermediate language modelI Implementation in industrial strength VM (Sun Hotspot)I Dedicated AO caching mechanism

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

Page 39: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

OverviewMotivation

Our ApproachEvaluationSummary

Questions?

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

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

Page 40: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented
Page 41: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Caching Mechanism Assembly Code

movl eax, methodOop.countermovl ecx, globalCounter

// methodOop.counter == globalCounter?cmpl eax, ecxjcc equals, InvokeDelegates

call_VM incrementalMatcher

InvokeDelegates:

movl eax, methodOop.cache.head

// cache.head == NULL?testl eax, eaxjcc zero, ContinueJP

// invoke the cached delegates

ContinueJP:

Page 42: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Pattern Library Example

�������������� ����� ����������������

�� ������������

�� ���������

���

�� �������

�� ������������

Page 43: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Pattern Library Example

�������������� ����� ����������������

�� ������������

�� ���������

���

�� �������

�� ������������

Page 44: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Pattern Library Example

�������������� ����� ����������������

�� ������������

�� ���������

���

�� �������

�� ������������

Page 45: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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>();

...

Page 46: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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>();

...

Page 47: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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>();

...

Page 48: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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 satisfiedelse if(state.equals(Formula.FF))// report formula as falsified

state.clear(); //reset proposition vector}

Page 49: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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 satisfiedelse if(state.equals(Formula.FF))// report formula as falsified

state.clear(); //reset proposition vector}

Page 50: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Temporal Constructs - Nu

class Tcheck {int p1 = 1;int p2 = 2;

Formula state = Globally(p1, Finally(p2));Set<int> propSet = new Set<int>();

...

Page 51: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Temporal Constructs - Nu

class Tcheck {int p1 = 1;int p2 = 2;

Formula state = Globally(p1, Finally(p2));Set<int> propSet = new Set<int>();

...

Page 52: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

Temporal Constructs - Nu

class Tcheck {int p1 = 1;int p2 = 2;

Formula state = Globally(p1, Finally(p2));Set<int> propSet = new Set<int>();

...

Page 53: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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);

}

Page 54: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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);

}

Page 55: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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);

}

Page 56: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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

}

Page 57: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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

}

Page 58: Nu: a Dynamic Aspect-Oriented Intermediate Language Model ...nu/papers/aosd08-slides.pdf · Overview Motivation Our Approach Evaluation Summary I Motivation: Supporting dynamic aspect-oriented

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

}