360 likes | 382 Views
ECE 750 Topic 8. Meta-programming languages, systems, and applications Automatic Program Specialization for J ava – U. P. Schultz, J. L. Lawall, C. Consel June 29, 2004 Presented by Shimin Li ECE750 University of waterloo. Paper Overview. Contents: Overview. Roughly six parts:
E N D
ECE 750 Topic 8 Meta-programming languages, systems, and applications Automatic Program Specialization for Java – U. P. Schultz, J. L. Lawall, C. Consel June 29, 2004 Presented by Shimin Li ECE750University of waterloo
Contents: Overview Roughly six parts: • Introduction to Automatic Program Specialization(APS) • How OO programs can be specialized automatically • Outline of JSpec • Case studies • Experimental study • Related work, conclusion, and future work
Contents: Detail • Automatic Program Specialization - Definition - Approach to APS » Off-line partial evaluation - Important features of partial evaluation - Means to declare the specialization context
Contents: Detail • Specialization of OO Programs - How specialization transforms a program - How to express the specialized program - Example - Program specializer features » Analysis precision - Compare to compilation - Compare to inheritance
Contents: Detail • JSpec Specializer - Overview of JSpec • Features • Specialization process - How JSpec specializes Java programs • Methods in concrete classes • Methods in abstract classes and interfaces - Limitations
Contents: Detail • Case Studies - Specialization of the program written using visitor design pattern • Visitor Specialization Pattern - Specialization of OoLALA Linear Algebra Library • Bridge Specialization Pattern • Iterator Specialization Pattern
Contents: Detail • Experimental Study - Benchmark programs to be experimented - Experiments - Results
Related Work • A run-time specializer, Masuhara, Yonezawa, 2002 • An on-line partial evaluator, Jones et al. 1993 • C++ specialization, Fujinami, 1998 • C++ specialization, Veldhuizen, 1999 • Dynamic partial evaluation, Sullivan, 2001 • Manual specialization, Lujan et al, 2001 • JaMake • Jax • Some compiler optimization techniques • AOP
Future Work • Support exception handlers in JSpec • Support run-time specialization for Java
Contributions and Novelties • Apply automatic program specialization to OO programs • Java program specializer – JSpec • Experimental study - Selection of benchmark programs - Achievement of JSpec - Comparison of specialization and compiler optimization
What I like • Techniques to eliminate overheads due to the use of OO abstractions • Re-using existing tools to develop JSpec - Tempo for C programs - AspectJ • Concrete examples - illustrate the approaches to specialization for OO programs • Experimental study - JSpec can produce significant speedups - JSpec and compiler optimization are complementary
What I don’t like • To ensure that a program will specialize, some restrictions must be imposed on its implementation • Lack explanation of JSpec alias and bind time analysis • Paper can be shorter
Question 1 What is program specialization?
Answer Program specialization is a program transformation technique that optimizes a program fragment with respect to information about a context in which it is used, by generating an implementation dedicated to this usage context One approach to automatic program specialization is partial evaluation
Question 2 How does the program specialization eliminate the genericness of OO programs?
Answer • Eliminate virtual calls • Bypass encapsulation in a safe manner • Simplify invariant computations
Question 3 What is binding-time analysis? How does it assist to perform partial evaluation?
Answer The process to identify the static and dynamic computations in a program based on information about which inputs can be considered static in the execution context. Based on the results of the binding-time analysis, the partial evaluator can specialize the program with respect to any concrete context that provides values for the static inputs.
Question 4 Compare the automatic program specialization to the compiler optimization
Answer • CO and APS are complementary • APS can significantly optimizes programs beyond the capabilities of compilers
Question 5 How does specializing a method optimize the use of encapsulated date?
Answer Accessing an encapsulated value is implemented in terms of a sequence of pointer dereferences whose cost depends on the embedding depth of the object structure. Specialization replaces a reference to a field containing a static value by the value itself. This transformation eliminates memory references and improves performance.
Question 6 How does specializing a method optimize the use of virtual dispatches?
Answer The choice of which method is invoked by a Java method call depends on the type of the receiver object. When definition of the invoked method cannot be determined at compile time, the method call is said to be virtual and is typically implemented using a table and a pointer dereference. If the type of the receiver object can be determined based on extra information available during specialization, then specialization replaces a virtual method call by an ordinary procedure call. Such a procedure call can be inlined, leading to further optimizations.
Question 7 Why it is appropriate to express the specialized program as an aspect-oriented program( i.e. encapsulate the specialized methods into an aspect)?
Answer • Separates the specialized method definition from the source program • Inserts these definitions into the right scope at compilation time • Specialized methods always are called from a safe context • Specialized code can be removed easily
Question 8 Describe the two important aspects of the precision of the analysis for a program specializer.
Answer • Granularity(What kinds of values are given individual binding times) – class ployvariance – method ployvariance • The number of descriptions assigned to each analyzed value – use sensitivity(static and dynamic)
Question 9 What does JSpec use C as an intermediate language?
Answer In order to use Tempo, a mature specializer for C Programs? Or other reasons?
Question 10 How do the visitor, bridge, and iterator specialization patterns perform specialization?
Answer Visitor specialization pattern: The visitor specialization pattern suggests that when the choice of the visitor is fixed, automatic program specialization can eliminate the double dispatching that takes place between the visitor and the objects that it traverses.
Bridge specialization pattern: The bridge specialization pattern suggests that when the representation is known, automatic program specialization can eliminate virtual dispatches between the interface object and the representation object.
Iterator specialization pattern: The iterator specialization pattern suggests that when the structure that the iterator traverses is known and the program manipulates the iterator in a fixed way, then automatic program specialization can replace uses of the iterator method by direct manipulation of the structure.