1 / 39

Wicca v2 demo

Wicca v2 demo. Dynamic weaving using the .NET 2.0 Debugging APIs. Marc Eaddy Columbia University. Wicca: A research platform. Experimenting with techniques for modularizing crosscutting concerns. Advanced separation of concerns (ASOC) First dynamic weaver based on .NET 2.0 Debugging APIs

dudley
Download Presentation

Wicca v2 demo

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


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

  2. Wicca: A research platform Experimenting with techniques for modularizing crosscutting concerns • 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 AOSD 2007

  3. Wicca: A research platform Experimenting with techniques for modularizing crosscutting concerns • 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 AOSD 2007

  4. Wicca supports multiple weaving strategies AOSD 2007

  5. Wicca transformation pipeline Aspect Assemblies Deltas Source Files Post-Link Weaver Compiled Program WovenProgram Compiler Break Points Backend Frontend AOSD 2007

  6. Phx.Morph • Wicca’s backend • .NET byte code and breakpoint weaver • Built using Microsoft Phoenix • Supports .NET 1.0, 1.1, and 2.0 • Demoed at AOSD 2006 • New: Dynamic weaving, breakpoint weaving, statement annotation support AOSD 2007

  7. Demo setup: Simple Draw • SimpleDraw draws Shapes on a Display • Naïve implementation couples Shape and Display concerns SimpleDraw.cs Point.cs public void moveBy(intdx, intdy) { x += dx; y += dy; Display.instance().update(); 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 (inti = 0; i < s.Length; i++) Display.instance().addShape(s[i]); Display.instance().update(); Line.cs public void moveBy(intdx, intdy) { a.moveBy(dx, dy); b.moveBy(dx, dy); Display.instance().update(); AOSD 2007

  8. Demo setup: Simple Draw • SimpleDraw draws Shapes on a Display • Naïve implementation couples Shape and Display concerns SimpleDraw.cs Point.cs public void moveBy(intdx, intdy) { x += dx; y += dy; Display.instance().update(); Crosscutting 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 (inti = 0; i < s.Length; i++) Display.instance().addShape(s[i]); Display.instance().update(); Line.cs public void moveBy(intdx, intdy) { a.moveBy(dx, dy); b.moveBy(dx, dy); Display.instance().update(); AOSD 2007

  9. Demo 1: Static byte code weaving Aspect Assemblies Deltas C# Files C# Compiler Phx.Morph Compiled Program WovenProgram Break Points AOSD 2007

  10. 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 AOSD 2007

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

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

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

  14. Statement annotations Allows any program statement to be annotated //[Concern("Input")] inputMapper.Update(elapsedTime); • 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 AOSD 2007

  15. Quantifying crosscutting 0.92 • “Identifying, Assigning, and Quantifying Crosscutting Concerns”, ACOM 2007 • Display updating in SimpleDraw • Degree of scattering: • Scattering visualization (ala SeeSoft): AOSD 2007

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

  17. Side classes Powerful and disciplined class extension AOSD 2007

  18. Expression problem revisited • Need to parse simple expression language • e.g., 3 + 4 • Expressions: Literal, Add • Operations: eval • Extensibility goals • Easily add new expressions • Easily add new operations • Cannot do both easily Easy in FP Easy in OO 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 AOSD 2007

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

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

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

  22. Caching Concern: Cache expression evaluation Invalidate cache when expression changes AOSD 2007

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

  24. Side class: Caching eval Interface intertype declaration Member intertype declarations interface IObserver { void onChange(); } class CachableExpr + Expression : IObserver { protected IObserver observer = null;   protected int cache;protected boolisCacheValid = false; void onChanged() { isCacheValid = false; if (observer != null) observer.onChanged(); } } AOSD 2007

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

  26. Side class: Caching eval (2) Call ‘next’ delegate (i.e., proceed) class CachableAdd + Add { public Add(Expression left, Expression right) { base(left, right); this.left.observer = this; this.right.observer = this; } override public inteval() { if (!isCacheValid) { cache = base.eval(); isCacheValid = true; } return cache; }  AOSD 2007

  27. 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(); } } } AOSD 2007

  28. Side class: Caching eval (3) Override virtual field 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(); } } } AOSD 2007

  29. Side class: Caching eval (4) Metavariable Limited quantification override Expression [$which = left | right] { set { base.$which = value; this.$which.observer = this; this.onChange(); } } AOSD 2007

  30. Base class must allow extension class Add : Expression { public virtual Expression left, right; public Add(Expression left, Expression right) { this.left = left; this.right = right; } public virtualinteval() {return left.eval() + right.eval();} } AOSD 2007

  31. 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 2007

  32. Conclusions sideClasses Wicca# @Statement AOSD 2007

  33. Acknowledgements • Microsoft Phoenix Team • Wicca developers • BorianaDitcheva • Rajesh Ramakrishnan • Adam Vartanian AOSD 2007

  34. Thank you! AOSD 2007

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

  36. Wicca architecture AOSD 2007

  37. Wicca architecture Phx.Morph Wicca# Compiler Wicca # Compiler AOSD 2007

  38. Legalizing statement annotations public OnDraw() { //[Note("Creating a line")] line = new Line(); AOSD 2007

  39. Legalizing statement annotations Legalize public OnDraw() { //[Note("Creating a line")] line = new Line(); [Statement(9, "Note", "Creating a line")] public OnDraw() { line = new Line(); AOSD 2007

More Related