• No results found

Link-Time Static Analysis for Efficient Separate Compilation of Object-Oriented Languages

N/A
N/A
Protected

Academic year: 2021

Share "Link-Time Static Analysis for Efficient Separate Compilation of Object-Oriented Languages"

Copied!
24
0
0

Loading.... (view fulltext now)

Full text

(1)

Link-Time Static Analysis for Efficient

Separate Compilation of Object-Oriented

Languages

Jean Privat Roland Ducournau

LIRMM

CNRS/Universit´e Montpellier II France

Program Analysis for Software Tools and Engineering Lisbon 2005

(2)

Outline

1 Motivation

2 Global Techniques

Type Analysis Coloring

Binary Tree Dispatch

3 Separate Compilation 4 Benchmarks

Description Results

(3)

Outline

1 Motivation 2 Global Techniques

Type Analysis Coloring

Binary Tree Dispatch 3 Separate Compilation 4 Benchmarks

Description Results

(4)

Software Engineering Ideal

Production of Modular Software

Extensible software

Reusable software components

⇒Object-Oriented Programming (inheritance + late binding)

Production of Software in a Modular Way

Small code modification →small recompilation

Shared software components are compiled only once

Software components can be distributed in a compiled form

(5)

Compilation of OO Programs

Global Techniques

Knowledge of thewhole program → more efficient implementation:

Method invocation Access to attribute Subtyping test

The Problem

Previous works use global technique withglobal compilation

(6)

Our Proposition

A Compromise

Aseparate compilation framework

that includes 3 global compilation techniques

How To?

(7)

Outline

1 Motivation

2 Global Techniques

Type Analysis Coloring

Binary Tree Dispatch

3 Separate Compilation 4 Benchmarks

Description Results

(8)

Type Analysis

Problems

Most method invocations are actually monomorphic

→Implement them with a static direct call (no late binding)

Many methods are dead

→Remove them

How to?

Approximate 3 sets:

Live classes and methods

Concrete type of each expression Called methods of each call site Many type analysis exist

(9)

Coloring

Problem

Overheadwith standard VFT in multiple inheritance: Subobjects

Many VFT (quadratic number, cubic size)

Solution

→Simple inheritance implementation even in multiple inheritance

How to?

Assign an identifier by class

Assign a color (index) by class, method and attribute Minimize size of the tables

(10)

Coloring (example)

A B C D D table C table B table A table Methods introduced in A Gap

(11)

Binary Tree Dispatch

Problem

Prediction of conditional branching of modern processors does not work with VFT

Solution

→Use static jumpsinstead of VFT

How to?

Perform a type analysis

Assign an identifier by live class

(12)

Binary Tree Dispatch (Example)

Compiling call site x.foo

id is the class itentifier of the receiver x

Concrete type of x is{A, B, C}

Class A B C

Identifier 19 12 15

fooimplementation A foo B foo C foo

Generated Code if id <= 15 then

if id <= 12 then call B foo else call C foo

(13)

Outline

1 Motivation

2 Global Techniques Type Analysis Coloring

Binary Tree Dispatch 3 Separate Compilation 4 Benchmarks

Description Results

(14)

Separate Compilation

local phase global phase ... metadata metadata local phase

Source code Compiled component

Final executable ... call ... call ... 0x05175 0x05217 bar? foo? ... call ... call ... void foo() void bar() { ... bar ... } ... ... { ... foo ... } ... ... Two Phases

Local phase compiles independently of future use

(15)

Local Phase

Source code Metamodel Local phase Compiled component Metamodel Internal model Input

Source code of a class

Metamodel of required classes

Outputs

Compiled version of the class (with unresolved symbols) Metadata : metamodel, internal model

(16)

Compiled Component

Method Call Site

Assign a unique symbol by call site Compile into a direct call

Attribute Access and Subtype Test

Assign a unique symbol by color and identifier Compile into a direct access:

I in the instance for attribute access I in the subtyping table for subtype tests

(17)

Global phase

Metadata

Type analysis Coloring Symbol substitution Compiled component Live

modelglobal excutableFinal

3 Stages

Type analysis: based on the metadata Coloring: computes colors

Symbol substitution: generates the final executable

Method Call Site Symbols

Substitute the address of:

monomorphic→ the invoked method

polymorphic w/ BTD → a generated select tree

(18)

Outline

1 Motivation

2 Global Techniques Type Analysis Coloring

Binary Tree Dispatch 3 Separate Compilation 4 Benchmarks

Description Results

(19)

Benchmarks Description

Language and Compilers

g++: Separate + VFT w/ subobjects SmartEiffel: Global + Binary Tree Dispatch prmc w/ VFT: Separate + Coloring + VFT prmc w/ BTD: Separate + Coloring + BTD

Programs

The same programs for all language 1 program per OO mechanism

(20)

Size of Executables

0 20 40 60 80 100 120 0 10 20 30 40 50 60 70

Size of the Exec. (kB)

Number of Classes

g++ SmartEiffel prmc w/ btd prmc w/ vft

Subobjects: many VTF→ an important overhead

prmc: BTD 'VFT

(21)

Late Binding

0 2 4 6 8 10 12 14 0 10 20 30 40 50 60 70 Time (s)

Size of the Concrete Type of the Reicever g++

SmartEiffel

prmc w/ btd prmc w/ vft

Subobjects: constant overhead + cache misses Coloring: better on megamorphic calls

(22)

Attribute Access

0 1 2 3 4 5 6 7 8 9 10 0 10 20 30 40 50 60 70 Time (s)

Size of the Concrete Type of Receiver g++ SmartEiffel prmc

Subobjects: constant overhead Coloring: constant attribute access SmartEiffel: can degenerate

(23)

Type Downcast

0 5 10 15 20 25 30 35 0 10 20 30 40 50 60 70 Time (s)

Size of the Concrete Type of the Casted Expression g++ SmartEiffel prmc

g++: bad performances

(24)

Summary

Summary

Aseparate compilation framework with global techniques for statically typed class-based languages

Bettermodularity than global compilers

Betterperformance than other separate compilers

Outlook

Shared libraries linked at load-time or dynamically loaded Time overhead of the global phase (link)

References

Related documents

Sections 65J (2) (a) and (b) require that that the judgment debtor consents to the emoluments attachment in writing. In addition, the judgment creditor or an appointed attorney

In tests looking at market measures of the possibility of information asymmetry, we find that, relative to SEC Only investigations, earnings responsiveness and institu- tional

The TIP research emphasis also complements the R&amp;D investment by other Federal agencies such as the National Cancer Institute (NCI)’s Clinical Proteomic Technologies for

These two schools, Connections Academy- USA and Global Studies High, took intersecting yet distinct paths: while Connections Academy-USA realized a global education primarily through

n Abstract: During the first half of the ‘90s, those who wished to acquire, in an organised manner, information (including professional general knowledge) regarding built heritage

The purpose of this study was to determine if teachers in an identified historically low performing Georgia Title I elementary school perceived the school was effectively organized

Artiklene med nøytral eller ingen holdning er ofte artikler der offisielle kilder er benyttet for å gi informasjon om situasjonen, mens de positive artiklene ofte inneholder

Committee Program Office Email, meetings Monthly or as needed feedback from group Updates on project, Mike Frangi. Project Team Tracy