nu: a dynamic aspect-oriented intermediate language model ...nu/papers/aosd08-slides.pdf ·...
TRANSCRIPT
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
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
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
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
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
OverviewMotivation
Our ApproachEvaluationSummary
History-based Pointcuts - Static Translation
Robert Dyer and Hridesh Rajan 6 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
History-based Pointcuts - Static Translation
Robert Dyer and Hridesh Rajan 7 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
History-based Pointcuts - Dynamic Support
Robert Dyer and Hridesh Rajan 8 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
History-based Pointcuts - Dynamic Support
Robert Dyer and Hridesh Rajan 9 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
History-based Pointcuts - Dynamic Support
Robert Dyer and Hridesh Rajan 10 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
History-based Pointcuts - Dynamic Support
Robert Dyer and Hridesh Rajan 11 Nu: Dynamic AO IL Model and VM
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
OverviewMotivation
Our ApproachEvaluationSummary
ExpressivenessPerformance
cflow(execution(setWord)) && execution(setBit)
Robert Dyer and Hridesh Rajan 29 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
ExpressivenessPerformance
cflow(execution(setWord)) && execution(setBit)
Robert Dyer and Hridesh Rajan 30 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
ExpressivenessPerformance
cflow(execution(setWord)) && execution(setBit)
Robert Dyer and Hridesh Rajan 31 Nu: Dynamic AO IL Model and VM
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
OverviewMotivation
Our ApproachEvaluationSummary
ExpressivenessPerformance
Robert Dyer and Hridesh Rajan 33 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
ExpressivenessPerformance
Robert Dyer and Hridesh Rajan 34 Nu: Dynamic AO IL Model and VM
OverviewMotivation
Our ApproachEvaluationSummary
ExpressivenessPerformance
Robert Dyer and Hridesh Rajan 35 Nu: Dynamic AO IL Model and VM
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
OverviewMotivation
Our ApproachEvaluationSummary
Future Work
Robert Dyer and Hridesh Rajan 37 Nu: Dynamic AO IL Model and VM
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
OverviewMotivation
Our ApproachEvaluationSummary
Questions?
http://www.cs.iastate.edu/˜nu/
Robert Dyer and Hridesh Rajan 39 Nu: Dynamic AO IL Model and VM
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:
Pattern Library Example
�������������� ����� ����������������
�� ������������
�� ���������
���
�� �������
�� ������������
Pattern Library Example
�������������� ����� ����������������
�� ������������
�� ���������
���
�� �������
�� ������������
Pattern Library Example
�������������� ����� ����������������
�� ������������
�� ���������
���
�� �������
�� ������������
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>();
...
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>();
...
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>();
...
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}
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}
Temporal Constructs - Nu
class Tcheck {int p1 = 1;int p2 = 2;
Formula state = Globally(p1, Finally(p2));Set<int> propSet = new Set<int>();
...
Temporal Constructs - Nu
class Tcheck {int p1 = 1;int p2 = 2;
Formula state = Globally(p1, Finally(p2));Set<int> propSet = new Set<int>();
...
Temporal Constructs - Nu
class Tcheck {int p1 = 1;int p2 = 2;
Formula state = Globally(p1, Finally(p2));Set<int> propSet = new Set<int>();
...
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);
}
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);
}
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);
}
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
}
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
}
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
}