120 likes | 216 Views
Aspect Oriented Compilation. James L. Simister Department of Computer Science University of Utah. What Are Objects?. A system’s functional units Patterned after some natural division of labor Interact according to well-defined interfaces Co-locate data with code that acts on that data.
E N D
Aspect Oriented Compilation James L. Simister Department of Computer Science University of Utah
What Are Objects? • A system’s functional units • Patterned after some natural division of labor • Interact according to well-defined interfaces • Co-locate data with code that acts on that data
What’s Wrong with Objects? • What about functionality that inherently belongs to several components, and cannot be contained by a single object? • Architecture of program vs. architecture of task • Examples: • Debugging/tracing • Communication • Synchronization
What Are Aspects? • A system’s units that cross-cut other (multiple) components • Patterned after some natural division of labor • Interact according to well-defined interfaces • Co-locate data with code that acts on that data, even though the functionality may be distributed between many other system components
Aspect Example - Part I /** * The HelloWorld class implements an application that * simply displays "Hello World!" on the standard output. */ class HelloWorld { public static void main(String[] args) { System.out.println("Hello world!"); } }
Aspect Example - Part II /** * The Trace aspect injects tracing messages before and after * method main of class HelloWorld. */ aspect Trace { static advice void main(String[] args) & HelloWorld { before { System.out.println("*** Entering HelloWorld.main ***"); } after { System.out.println("*** Exiting HelloWorld.main ***"); } } }
Aspect Example - Output *** Entering HelloWorld.main *** Hello World! *** Exiting HelloWorld.main ***
Proposal • Design and implement a compiler for an Aspect-Oriented Language • Investigate the advantages of an aspect compiler vs. an aspect preprocessor • Investigate challenges of optimization in Aspect-Oriented Compilation
The Compiler • Input: • Toy OO Language • Somewhat patterned after AspectJ • Translation • Weave aspects into base code • Output: • Sparc Assembly
Compiler Vs. Pre-Processor • What limits are placed on aspects when using a pre-processor? • What limits are placed on aspects when using a compiler? • What useful aspects need access to compiler knowledge or analysis, rather than just syntax? • Can aspects be more powerful or useful as first-class data structures? If so, how?
Optimization • Techniques: • Register Allocation • Redundant/Unreachable Code Elimination • Common Subexpression Elimination • How do aspects make optimization harder? • How do aspects make optimization easier?
Project Summary • Implement a compiler for a simple language with objects and aspects • Research methods of declaring and implementing aspects • Observe benefits/challenges affecting optimization with regards to aspects