Using Types to Analyze and Optimize Object-Oriented Programs By: Amer Diwan Presented By: Jess Martin, Noah Wallace, and Will von Rosenberg.

Slides:



Advertisements
Similar presentations
Objects and Classes David Walker CS 320. Advanced Languages advanced programming features –ML data types, exceptions, modules, objects, concurrency,...
Advertisements

ASSUMPTION HIERARCHY FOR A CHA CALL GRAPH CONSTRUCTION ALGORITHM JASON SAWIN & ATANAS ROUNTEV.
Copyright © 1998 by Addison Wesley Longman, Inc. 1 Chapter 4 Names - Design issues: - Maximum length? - Are connector characters allowed? - Are names case.
P3 / 2004 Register Allocation. Kostis Sagonas 2 Spring 2004 Outline What is register allocation Webs Interference Graphs Graph coloring Spilling Live-Range.
Semantic Analysis Chapter 6. Two Flavors  Static (done during compile time) –C –Ada  Dynamic (done during run time) –LISP –Smalltalk  Optimization.
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
Context-Sensitive Interprocedural Points-to Analysis in the Presence of Function Pointers Presentation by Patrick Kaleem Justin.
Programming Languages and Paradigms
Kernighan/Ritchie: Kelley/Pohl:
1 Chapter Three Using Methods. 2 Objectives Learn how to write methods with no arguments and no return value Learn about implementation hiding and how.
CSE 425: Semantics II Implementing Scopes A symbol table is in essence a dictionary –I.e., every name appears in it, with the info known about it –Usually.
Introduction to Advanced Topics Chapter 1 Mooly Sagiv Schrierber
CS 211 Inheritance AAA.
Inheritance Inheritance Reserved word protected Reserved word super
6/10/2015C++ for Java Programmers1 Pointers and References Timothy Budd.
Next Section: Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis (Wilson & Lam) –Unification.
ISBN Chapter 9 Subprograms. Copyright © 2006 Addison-Wesley. All rights reserved.1-2 Introduction Two fundamental abstraction facilities.
Previous finals up on the web page use them as practice problems look at them early.
Type Systems For Distributed Data Sharing Ben Liblit Alex AikenKathy Yelick.
Range Analysis. Intraprocedural Points-to Analysis Want to compute may-points-to information Lattice:
1 CS 201 Compiler Construction Lecture 3 Data Flow Analysis.
© The McGraw-Hill Companies, 2006 Chapter 5 Arrays.
Intraprocedural Points-to Analysis Flow functions:
ARRAYS AND POINTERS Although pointer types are not integer types, some integer arithmetic operators can be applied to pointers. The affect of this arithmetic.
Review on pointers and dynamic objects. Memory Management  Static Memory Allocation  Memory is allocated at compiling time  Dynamic Memory  Memory.
Comparison Caller precisionCallee precisionCode bloat Inlining context-insensitive interproc Context sensitive interproc Specialization.
Pointer analysis. Pointer Analysis Outline: –What is pointer analysis –Intraprocedural pointer analysis –Interprocedural pointer analysis Andersen and.
Learners Support Publications Pointers, Virtual Functions and Polymorphism.
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
P ARALLEL P ROCESSING I NSTITUTE · F UDAN U NIVERSITY 1.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
CSC3315 (Spring 2009)1 CSC 3315 Programming Languages Hamid Harroud School of Science and Engineering, Akhawayn University
Names Variables Type Checking Strong Typing Type Compatibility 1.
1 Abstraction  Identify important aspects and ignore the details  Permeates software development programming languages are abstractions built on hardware.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
1 Chapter 10: Data Abstraction and Object Orientation Aaron Bloomfield CS 415 Fall 2005.
Defining and Converting Data Copyright Kip Irvine, 2003 Last Update: 11/4/2003.
Basic Semantics Associating meaning with language entities.
1 Records Record aggregate of data elements –Possibly heterogeneous –Elements/slots are identified by names –Elements in same fixed order in all records.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
1 Data Flow Analysis Data flow analysis is used to collect information about the flow of data values across basic blocks. Dominator analysis collected.
C++ Programming: From Problem Analysis to Program Design, Third Edition Chapter 15: Overloading and Templates.
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
© 2004 Pearson Addison-Wesley. All rights reserved April 14, 2006 Polymorphism ComS 207: Programming I (in Java) Iowa State University, SPRING 2006 Instructor:
CS 343 presentation Concrete Type Inference Department of Computer Science Stanford University.
From C++ to C# Part 5. Enums Similar to C++ Similar to C++ Read up section 1.10 of Spec. Read up section 1.10 of Spec.
Chapter 13: Overloading and Templates. Objectives In this chapter, you will – Learn about overloading – Become familiar with the restrictions on operator.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
COM S 228 Introduction to Data Structures Instructor: Ying Cai Department of Computer Science Iowa State University Office: Atanasoff.
Semantic Analysis II Type Checking EECS 483 – Lecture 12 University of Michigan Wednesday, October 18, 2006.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Procedure Definitions and Semantics Procedures support control abstraction in programming languages. In most programming languages, a procedure is defined.
1 CSC 533: Programming Languages Spring 2014 Subprogram implementation  subprograms (procedures/functions/subroutines)  subprogram linkage  parameter.
Internet Computing Module II. Syllabus Creating & Using classes in Java – Methods and Classes – Inheritance – Super Class – Method Overriding – Packages.
CPSC 252Inheritance II Page 1 Inheritance & Pointers Consider the following client code: const int MAXCLOCKS = 2; Clock* clockPtr[ MAXCLOCKS ]; clockPtr[0]
ISBN Chapter 12 Support for Object-Oriented Programming.
C++ for Engineers and Scientists Second Edition Chapter 12 Pointers.
Detecting Type-Based Alias Analysis Violations in C Iain Ireland (University of Alberta) Jose Nelson Amaral (University of Alberta) Raul Silvera (IBM Canada)
Dynamic Allocation in C
Compositional Pointer and Escape Analysis for Java Programs
Pointers and References
Pointers and References
1. Reaching Definitions Definition d of variable v: a statement d that assigns a value to v. Use of variable v: reference to value of v in an expression.
CSC 533: Programming Languages Spring 2015
Semantic Analysis Chapter 6.
Pointer analysis.
자바 언어를 위한 정적 분석 (Static Analyses for Java) ‘99 한국정보과학회 가을학술발표회 튜토리얼
Overview of C++ Polymorphism
CSC 533: Programming Languages Spring 2018
CSC 533: Programming Languages Spring 2019
Presentation transcript:

Using Types to Analyze and Optimize Object-Oriented Programs By: Amer Diwan Presented By: Jess Martin, Noah Wallace, and Will von Rosenberg

Type-Based Alias Analysis (TBAA) Assumes type safe programming language, i.e. Modula-3. Comparative Analysis of Types and Subtypes Four Functions (Versions) of TBAA –TypeDecl –FieldTypeDecl –SMTypeRefs –SMFieldTypeRefs

TypeDecl Examine the declared type of AP and assume the AP may reference any object with the same declared type or subtype.

TypeDecl Example Class X{} Class Y{} : X Class Z{} : X Class D{} : Y Class F{} : Z

FieldTypeDecl Given AP1 and AP2 it returns true if AP1 and AP2 are Aliases Modula-3 programs may take the addresses of memory locations in only two ways: via the pass-by-reference parameter passing mechanism and the WITH statement.

FieldTypeDecl (cont’d) Identical APs always alias each other. Two qualified expressions may be aliases if they access the same field in potentially the same object. A pointer dereference may refer to the same location as a qualified subscripted expression only if their types are compatible and the program may take the address of the qualified or subscripted expression. In Modula-3, a subscripted expression cannot alias a qualified expression. Two subscripted expressions are aliases if they may subscript the same array. FieldTypeDecl ignores the actual subscripts. For all other cases of APs, including two pointer dereferences, FieldTypeDecl uses TypeDecl to determine aliases.

FieldTypeDecl Class P{ int a; float b; char c;} Class D{ int e; float g; char f;} : P Int ra[]; P and D? P.a and D.e? P.a and ra[i]? *P.f and ra[i]? D and D?

SMTypeRefs Selective Type Merging Produces a TypeRefsTable

SMTypeRefs (cont’d) Initializes Group Examines all assignment statements, merges and if types are different. Filters infeasible aliases from Group, creating asymmetry.

SMTypeRefs (cont’d)

Applause

SMTypeRefs (cont’d)

SMTypeRefs Class Blah{} Class Piglet{}:Blah Class Pooh{}:Blah Class Pinky{}:Piglet Class Brain{}:Piglet Class Scooby{}:Pooh Class Yogi{}:Pooh T New Blah; P New Piglet; F New Pooh; T = P; P = F; T = F; What are the typeref tables for the three assignments?

SMFieldTypeRefs Fields + Selectively Merge Type References We use SMTypeRefs instead of TypeDecl in the FieldTypeDecl algorithm Final version of TBAA

Using TBAA Redundant Load Elimination –Loop invariant code motion –Common subexpression elimination Resolving method invocation –Type hierarchy analysis –Intraprocedural type propagation –Intraprocedural type propagation using TBAA –Interprocedural type propagation –Interprocedural type propagation using TBAA

Polymorphism through subtyping Polymorphic – method invocation site calls more than one user procedure at run time. Monomorphic – method invocation site calls only one user procedure at run time. A method is resolved if it is identified as being monomorphic. We wish to resolve all calls and replace them with direct calls.

Type Hierarchy Analysis Simply evaluates all possible overrides (overloads) for a particular function when passed a specific variable type.

Intraprocedural Type Propogation Breaks down types into type events –Allocation –Implicit and explicit type discrimination –Assignment Complexity O(n*v) where n is number of statements and v is the number of variables in the procedure

Intraprocedural Type Propogation using TBAA When it encounters a pointer dereference, it invokes SMFieldTypeRefs to get the set of locations referenced by the pointer deref Analysis discovers monomorphic uses of general data structures Complexity – O(n*(v+NT*NF)), where n is number of statements, v is number of variables, NT is number of types, and NF is number of fields

Interprocedural Type Propogation Call graph w/edges for each Builds work list Puts functions on work list if new information Merges parameter types Interprocedural Type Propogation using TBAA is the same implementation

Summary of analysis Type Hierarchy Intraprocedural Type Propagation Intraprocedural Type Propagation using TBAA Interprocedural Type Propagation Interprocedural Type Propagation using TBAA

Results Evaluates TBAA and Method resolution analyses. Static evaluation Dynamic evaluation Limit evaluation

TBAA Evaluation

Static Evaluation of TBAA

Static (cont’d) FieldType declare is more precise than TypeDecl. SMFieldTypeRefs offers little added precision. FieldTypeDecl finds more redundant loads than TypeDecl and SMFieldTypeRefs does not change by any significant amount

Static (cont’d)

Dynamic Evaluation of TBAA

Dynamic (cont’d) Two important points –1) a more precise alias analyses is not necessarily better it depends on how the analyses is used. –2) Static metrics are insufficient by themselves for evaluation

Limit Evaluation on TBAA Optimizations eliminate between 35% - 88% of the RL. Only 5% or fewer are redundant. Reveals that TBAA performs as well as any alias analysis could with the RLE and their benchmark.

Limit evaluation (cont’d)

Method Invocation

Static and Dynamic Evaluation Type Hierarchy analysis resolves many method invocations Intraprocedural type propagations resolves very few additional method invocations but removes NIL. Type propagation is useful for languages that have defined semantics such as Modula-3 or Java TBAA along with type propagation resolves most of the method invocation in the benchmarks.

Limit Evaluation (cont’d)

Explicit type tests and cloning combined with aggressive alias analyses may be able to resolve these method invocations. 4 sites are polymorphic but they comprise more than 80% of the total method invocations.