Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wicca v2 demo Dynamic weaving using the.NET 2.0 Debugging APIs Marc Eaddy Columbia University.

Similar presentations


Presentation on theme: "Wicca v2 demo Dynamic weaving using the.NET 2.0 Debugging APIs Marc Eaddy Columbia University."— Presentation transcript:

1 Wicca v2 demo Dynamic weaving using the.NET 2.0 Debugging APIs Marc Eaddy Columbia University

2 Marc Eaddy – Columbia University Wicca: A research platform Advanced separation of concerns (ASOC) ◦ First dynamic weaver based on.NET 2.0 Debugging APIs ◦ New breakpoint weaving technique ◦ New metrics for measuring crosscutting Novel language mechanisms ◦ Statement annotations ◦ Side classes Dynamic software updating 2 AOSD 2007 Experimenting with techniques for modularizing crosscutting concerns

3 Marc Eaddy – Columbia University Wicca: A research platform 3 AOSD 2007 Experimenting with techniques for modularizing crosscutting concerns

4 Marc Eaddy – Columbia University Wicca supports multiple weaving strategies 4 AOSD 2007

5 Marc Eaddy – Columbia University Wicca transformation pipeline 5 AOSD 2007 Compiler Post-Link Weaver Post-Link Weaver Deltas Aspect Assemblies Aspect Assemblies Compiled Program Compiled Program Source Files Source Files Woven Program Break Points Break Points

6 Marc Eaddy – Columbia University Phx.Morph 6 AOSD 2007

7 Marc Eaddy – Columbia University Demo setup: Simple Draw SimpleDraw draws Shapes on a Display Naïve implementation couples Shape and Display concerns public init() { s = new Shape[3]; s[0] = new Point(10, 10); s[1] = new Point(5, 5); s[2] = new Line(new Point(1, 9), new Point(9, 1)); for (int i = 0; i < s.Length; i++) Display.instance().addShape(s[i]); Display.instance().update(); SimpleDraw.cs public void moveBy(int dx, int dy) { x += dx; y += dy; Display.instance().update(); public void moveBy(int dx, int dy) { a.moveBy(dx, dy); b.moveBy(dx, dy); Display.instance().update(); Point.cs Line.cs 7 AOSD 2007

8 Marc Eaddy – Columbia University Demo setup: Simple Draw SimpleDraw draws Shapes on a Display Naïve implementation couples Shape and Display concerns public init() { s = new Shape[3]; s[0] = new Point(10, 10); s[1] = new Point(5, 5); s[2] = new Line(new Point(1, 9), new Point(9, 1)); for (int i = 0; i < s.Length; i++) Display.instance().addShape(s[i]); Display.instance().update(); SimpleDraw.cs public void moveBy(int dx, int dy) { x += dx; y += dy; Display.instance().update(); public void moveBy(int dx, int dy) { a.moveBy(dx, dy); b.moveBy(dx, dy); Display.instance().update(); Point.cs Line.cs 8 AOSD 2007

9 Marc Eaddy – Columbia University Demo 1: Static byte code weaving AOSD C# Compiler C# Compiler Phx.Morph Deltas Aspect Assemblies Aspect Assemblies Compiled Program Compiled Program C# Files C# Files Woven Program Break Points

10 Marc Eaddy – Columbia University Dynamic weaving.NET 2.0 Debugging APIs ◦ Edit-and-Continue API  Replaces the.NET 1.1 Profiler API  Dynamic AOP  Edit-and-Continue  Patching ◦ Breakpoint API – Noninvasive advising ◦ FuncEval API – In-process advice execution ◦ Intended for debugging, not dynamic AOP Microsoft Managed Debugger ◦ Hosts Wicca plug-in ◦ Hosts client program in separate process ◦ Command-line shell for weaving commands 10 AOSD 2007

11 Marc Eaddy – Columbia University Demo 2: Dynamic byte code weaving Using.NET 2.0 Edit-and-Continue API 11 AOSD 2007 C# Compiler C# Compiler Phx.Morph Aspect Assemblies Aspect Assemblies Compiled Program Compiled Program C# Files C# Files Deltas Woven Program Break Points

12 Marc Eaddy – Columbia University Demo 3: Dynamic bp weaving Noninvasive advising via Breakpoint API In-process advice execution via FuncEval API 12 AOSD 2007 Phx.Morph Aspect Assemblies Aspect Assemblies Compiled Program Compiled Program C# Files C# Files Break Points Break Points Woven Program Deltas C# Compiler C# Compiler

13 Marc Eaddy – Columbia University Wicca’s frontend ◦ Wicca# compiler Extends C# to support ◦ Statement annotations ◦ Side classes Goal ◦ Actually “modularize” crosscutting concerns (without sacrificing other modularity properties) Wicca# language 13 AOSD 2007

14 Marc Eaddy – Columbia University Statement annotations Fine-grained advising ◦ Statement-level advising (more elegant than dummy methods) ◦ Declarative instance-level advising Other possibilities ◦ Optimization and parallelization hints ◦ Contracts ◦ Avoiding reweaving ◦ Fault isolation ◦ Oblivious debugging “Statement Annotations for Fine-Grained Advising”, RAM-SE 2006 Allows any program statement to be annotated //[Concern("Input")] inputMapper.Update(elapsedTime); 14 AOSD 2007

15 Marc Eaddy – Columbia University Quantifying crosscutting “Identifying, Assigning, and Quantifying Crosscutting Concerns”, ACOM 2007 Display updating in SimpleDraw ◦ Degree of scattering: ◦ Scattering visualization (ala SeeSoft): 15 AOSD 2007

16 Marc Eaddy – Columbia University Demo 4: Concern profiling Statement annotation-based advising 16 AOSD 2007 Wicca# Compiler Wicca# Compiler Compiled Program Compiled Program Wicca# Source Files Wicca# Source Files Phx.Morph Aspect Assemblies Aspect Assemblies Woven Program Deltas Break Points

17 Marc Eaddy – Columbia University Side classes Powerful and disciplined class extension Powerful Combines subclasses, aspects, open classes, and refinements Unified subclass-like notation and semantics (similar to Eos) Virtual fields, constructors, and static members Multiple base classes can be extended simultaneously Extension order is arbitrary or explicit Disciplined Extensions must be explicitly allowed Honors access restrictions (public, private, virtual, …) Limits quantification 17 AOSD 2007

18 Marc Eaddy – Columbia University Expression problem revisited Need to parse simple expression language e.g., Expressions: Literal, Add Operations: eval Extensibility goals Easily add new expressions Easily add new operations Cannot do both easily 18 AOSD 2007 P. Tarr, H. Ossher, W. Harrison, and S. Sutton Jr., "N Degrees of Separation: Multi-Dimensional Separation of Concerns," ICSE 1999 M. Torgersen, "The Expression Problem Revisited," ECOOP 2004

19 Marc Eaddy – Columbia University abstract class Expression { abstract int eval(); } class Add : Expression { public Expression left, right; public Add(Expression left, Expression right) { this.left = left; this.right = right; } public int eval() { return left.eval() + right.eval(); } } Parser implementation in OO 19 AOSD 2007 Concern: Add printing Operations are crosscutting!

20 Marc Eaddy – Columbia University abstract class PrintingExpr : Expression { abstract void print(); } class PrintingAdd : Add { public void print() { Console.WriteLine(left + “+” + right); } Add printing using subclassing 20 AOSD 2007 Invasive Inflexible

21 Marc Eaddy – Columbia University abstract class PrintingExpr + Expression { abstract void print(); } class PrintingAdd + Add { public void print() { Console.WriteLine(left + “+” + right); } Printing the side class way 21 AOSD 2007 Modularizes the printing concern Side class implicitly extends base class Clients (or other sub/side classess) oblivious

22 Marc Eaddy – Columbia University Caching Concern: Cache expression evaluation Invalidate cache when expression changes AOSD

23 Marc Eaddy – Columbia University interface IObserver { void onChange(); } class CachableExpr + Expression : IObserver { protected IObserver observer = null; protected int cache; protected bool isCacheValid = false; void onChanged() { isCacheValid = false; if (observer != null) observer.onChanged(); } Side class: Caching eval 23 AOSD 2007

24 Marc Eaddy – Columbia University interface IObserver { void onChange(); } class CachableExpr + Expression : IObserver { protected IObserver observer = null; protected int cache; protected bool isCacheValid = false; void onChanged() { isCacheValid = false; if (observer != null) observer.onChanged(); } Side class: Caching eval 24 AOSD 2007

25 Marc Eaddy – Columbia University class CachableAdd + Add { public Add(Expression left, Expression right) { base(left, right); this.left.observer = this; this.right.observer = this; } override public int eval() { if (!isCacheValid) { cache = base.eval(); isCacheValid = true; } return cache; } Side class: Caching eval (2) 25 AOSD 2007

26 Marc Eaddy – Columbia University class CachableAdd + Add { public Add(Expression left, Expression right) { base(left, right); this.left.observer = this; this.right.observer = this; } override public int eval() { if (!isCacheValid) { cache = base.eval(); isCacheValid = true; } return cache; } Side class: Caching eval (2) 26 AOSD 2007

27 Marc Eaddy – Columbia University Side class: Caching eval (3) override Expression left { set { base.left = value; this.left.observer = this; this.onChange(); } override Expression right { set { base.right = value; this.right.observer = this; this.onChange(); } 27 AOSD 2007

28 Marc Eaddy – Columbia University Side class: Caching eval (3) override Expression left { set { base.left = value; this.left.observer = this; this.onChange(); } override Expression right { set { base.right = value; this.right.observer = this; this.onChange(); } 28 AOSD 2007

29 Marc Eaddy – Columbia University Side class: Caching eval (4) override Expression [$which = left | right] { set { base.$which = value; this.$which.observer = this; this.onChange(); } 29 AOSD 2007

30 Marc Eaddy – Columbia University class Add : Expression { public virtual Expression left, right; public Add(Expression left, Expression right) { this.left = left; this.right = right; } public virtual int eval() {return left.eval() + right.eval();} } Base class must allow extension 30 AOSD 2007

31 Marc Eaddy – Columbia University Addresses needs of existing mechanisms Subclasses ◦ Inflexible composition ◦ Only extend one base class ◦ Only extend instance methods ◦ Requires invasive changes in clients Open classes/refinements/mixins ◦ Need for composition ordering ◦ Need for constructor and static member overriding Aspects ◦ Lack of modular reasoning ◦ Poor integration with existing OO semantics and notation ◦ Need for symmetric model ◦ Matching wrong join points AOSD

32 Marc Eaddy – Columbia University Conclusions Wicca is for experimenting with ASOC Side classes unifies aspects and subclasses to better modularize concerns 32 AOSD 2007

33 Marc Eaddy – Columbia University Acknowledgements Microsoft Phoenix Team Wicca developers ◦ Boriana Ditcheva ◦ Rajesh Ramakrishnan ◦ Adam Vartanian 33 AOSD 2007

34 Marc Eaddy – Columbia University Thank you! 34 AOSD 2007

35 Marc Eaddy – Columbia University Phx.Morph architecture Phx.Morph Editors Open Classes, binary and breakpoint weaving Phoenix-specific AOP Attribute Handlers Phoenix PEREW Assembly Re-Writer Phx.Aop AOP Joinpoints, pointcuts, … Attributes Custom AOP annotations.NET Morph Plugin 35 AOSD 2007

36 Copyright © Marc Eaddy Wicca architecture 36AOSD 2007

37 Copyright © Marc Eaddy Phx.Morph Wicca # Compiler Wicca# Compiler Wicca architecture 37AOSD 2007

38 Marc Eaddy – Columbia University38 AOSD 2007 Legalizing statement annotations

39 Marc Eaddy – Columbia University Legalizing statement annotations 39 AOSD 2007


Download ppt "Wicca v2 demo Dynamic weaving using the.NET 2.0 Debugging APIs Marc Eaddy Columbia University."

Similar presentations


Ads by Google