Towards a Full Multiple-Inheritance Virtual Machine Roland - - PowerPoint PPT Presentation

towards a full multiple inheritance virtual machine
SMART_READER_LITE
LIVE PREVIEW

Towards a Full Multiple-Inheritance Virtual Machine Roland - - PowerPoint PPT Presentation

Towards a Full Multiple-Inheritance Virtual Machine Roland Ducournau & Floral Morandat LIRMM the University of Montpellier & CNRS MASPEGHI/ICOOOLPS10 Maribor, June 22, 2010 R. Ducournau & F. Morandat (LIRMM) Multiple


slide-1
SLIDE 1

Towards a Full Multiple-Inheritance Virtual Machine

Roland Ducournau & Floréal Morandat

LIRMM the University of Montpellier & CNRS

MASPEGHI/ICOOOLPS’10 Maribor, June 22, 2010

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 1 / 22

slide-2
SLIDE 2

Plan

Plan

1

Context and Motivations

2

Virtual Machine Principle

3

Experiments

4

Conclusion and prospects

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 2 / 22

slide-3
SLIDE 3

Context and Motivations

Plan

1

Context and Motivations

2

Virtual Machine Principle

3

Experiments

4

Conclusion and prospects

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 3 / 22

slide-4
SLIDE 4

Context and Motivations

Motivations (1/2)

Why be afraid of multiple inheritance? from the semantic standpoint (so-called conflicts);

◮ this is another story...

from the efficiency standpoint.

◮ my point today.

Alternatives to multiple inheritance multiple subtyping (Java); mixins/traits (Scala). They are supposed to improve both aspects.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 4 / 22

slide-5
SLIDE 5

Context and Motivations

Motivations (1/2)

Why be afraid of multiple inheritance? from the semantic standpoint (so-called conflicts);

◮ this is another story...

from the efficiency standpoint.

◮ my point today.

Alternatives to multiple inheritance multiple subtyping (Java); mixins/traits (Scala). They are supposed to improve both aspects.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 4 / 22

slide-6
SLIDE 6

Context and Motivations

Motivations (2/2)

Our position this improvement is illusory, interfaces are as inefficient as full multiple inheritance (the only possible improvement involves attribute access) Our project designing a virtual machine for full multiple inheritance, as efficient as Java or .Net systems. Possible target language: think of Scala without class/trait distinction.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 5 / 22

slide-7
SLIDE 7

Context and Motivations

Context

Implementation of OO mechanisms method invocation, attribute access, subtype testing. Modern runtime systems static typing, dynamic class loading, adaptive compilers. Consequences code optimization based on temporary CWA, possible recompilations when assumptions are questioned.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 6 / 22

slide-8
SLIDE 8

Context and Motivations

Context

Implementation of OO mechanisms method invocation, attribute access, subtype testing. Modern runtime systems static typing, dynamic class loading, adaptive compilers. Consequences code optimization based on temporary CWA, possible recompilations when assumptions are questioned.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 6 / 22

slide-9
SLIDE 9

Context and Motivations

Objectives

Design and simulation before hard coding design of

◮ an object-oriented implementation, ◮ a collection of optimizations, ◮ a (re)compilation protocol,

simulation and assessment

◮ of the recompilation cost ◮ of various optimizations, ◮ on real class hierarchies.

focus on multiple-inheritance effects

◮ we do not consider (yet) other optimizations

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 7 / 22

slide-10
SLIDE 10

Virtual Machine Principle

Plan

1

Context and Motivations

2

Virtual Machine Principle

3

Experiments

4

Conclusion and prospects

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 8 / 22

slide-11
SLIDE 11

Virtual Machine Principle

Principle

Object representation incremental, definitive object representation based on perfect class hashing, Code sequences for OO mechanisms single-subtyping code for constant-position sites,

= class-typed invocations in Java

perfect-hashing code for variable-position sites.

≈ interface-typed invocations in Java

Compilation and recompilation protocol computes the object representation, selects the appropriate code generation, decides method recompilations.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 9 / 22

slide-12
SLIDE 12

Virtual Machine Principle

Object representation (1/3)

A

A

Single-subtyping implementation methods/attributes introduced by a given class are grouped, superclasses are ordered, the superclass order is a prefix of the subclass order, invariable positions.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 10 / 22

slide-13
SLIDE 13

Virtual Machine Principle

Object representation (1/3)

A

A

B A

B

A

A

Single-subtyping implementation methods/attributes introduced by a given class are grouped, superclasses are ordered, the superclass order is a prefix of the subclass order, invariable positions.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 10 / 22

slide-14
SLIDE 14

Virtual Machine Principle

Object representation (1/3)

A

A

B A

B

A

A

B A

B

A

A

C A B

C

Single-subtyping implementation methods/attributes introduced by a given class are grouped, superclasses are ordered, the superclass order is a prefix of the subclass order, invariable positions.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 10 / 22

slide-15
SLIDE 15

Virtual Machine Principle

Object representation (2/3)

Multiple subtyping and dynamic loading methods/attributes introduced by a given class are grouped, superclasses are ordered, the prefix condition does not hold for all direct superclasses but it can hold for at least one superclass, invariable positions when the prefix condition holds, the superclass order depends on the class loading order. On a single-inheritance hierarchy the same layout as the single-subtyping implementation.

⇒ the multiple-inheritance overhead might concern only the multiple-inheritance cases

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 11 / 22

slide-16
SLIDE 16

Virtual Machine Principle

Object representation (3/3)

A

A

D satisfies the prefix condition wrt B not C, C has variable positions, C-typed invocations must be recompiled.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 12 / 22

slide-17
SLIDE 17

Virtual Machine Principle

Object representation (3/3)

A

A

A B

B

A

A

D satisfies the prefix condition wrt B not C, C has variable positions, C-typed invocations must be recompiled.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 12 / 22

slide-18
SLIDE 18

Virtual Machine Principle

Object representation (3/3)

A

A

A B

B

A

A

A C

C

A B

B

A

A

D satisfies the prefix condition wrt B not C, C has variable positions, C-typed invocations must be recompiled.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 12 / 22

slide-19
SLIDE 19

Virtual Machine Principle

Object representation (3/3)

A

A

A B

B

A

A

A C

C

A B

B

A

A

A B C D

D

A C

C

A B

B

A

A

D satisfies the prefix condition wrt B not C, C has variable positions, C-typed invocations must be recompiled.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 12 / 22

slide-20
SLIDE 20

Virtual Machine Principle

Compilation Protocol (1/2)

Code generation single-subtyping code for

◮ root-invocations, ie methods introduced by the root class, ◮ self-invocations, ie receiver typed by the current class,

when this class has an invariable position (so far),

perfect-hashing code for

◮ self-invocations with variable-position classes, ◮ non-self-invocations.

Possible recompilations for self-invocations of invariable-position attributes/methods, each class maintains the list of methods to recompile when its attribute/method group is moved.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 13 / 22

slide-21
SLIDE 21

Virtual Machine Principle

Compilation Protocol (2/2)

At class loading greedy optimization for

◮ selecting a preferred direct superclass (for prefix condition)

(possibly different for attributes and methods)

◮ computing the superclass order(s)

update of the group positions of superclasses (not in the prefix)

⇒ newly moved groups

(lazy) method (re)compilation

◮ newly loaded ◮ already compiled but invoking newly moved attributes/methods

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 14 / 22

slide-22
SLIDE 22

Experiments

Plan

1

Context and Motivations

2

Virtual Machine Principle

3

Experiments

4

Conclusion and prospects

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 15 / 22

slide-23
SLIDE 23

Experiments

Random class loading simulation

Statistics on class hierarchy Number of classes, methods and attributes, methods that contain self-invocations, method/attribute invocation sites, root/self/other invocation sites. Statistics on random class loading Worst-case (ie maximum or minimum) number of classes, methods and attributes with variable/invariable positions,

  • ptimized/unoptimized invocation sites,

method compilations and recompilations.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 16 / 22

slide-24
SLIDE 24

Experiments

Benchmarks and results

A single benchmark, the PRM compiler Recompilation numbers number of recompilations classes 550 11% method definitions 4407 6% Optimization numbers number of

  • ptimized

method root-invocations 1599 100% method self-invocation 3030 91%

  • ther method invocations

12747 0% attribute invocations 4513 98%

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 17 / 22

slide-25
SLIDE 25

Conclusion and prospects

Plan

1

Context and Motivations

2

Virtual Machine Principle

3

Experiments

4

Conclusion and prospects

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 18 / 22

slide-26
SLIDE 26

Conclusion and prospects

Related Works

  • A. Myers [OOPSLA 1995]

An extension of his double compilation scheme to multiple compilations, dynamic loading and adaptive compilers, method invocation and subtype testing.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 19 / 22

slide-27
SLIDE 27

Conclusion and prospects

Conclusion

A promising simulation worst-case assessment (for the considered hierarchy...) very few recompilations (6%) attribute invocation as efficient as with multiple subtyping (97%) method invocation as efficient as with an intensive use of interfaces (25%) ⇒ as efficient as perfect hashing and attribute coloring [OOPSLA’09] Simulation is a promising approach compilers are atomic bombs, simulate them! random simulations are required to vary class loading orders, the key to empirical assessment of worst cases and scalability.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 20 / 22

slide-28
SLIDE 28

Conclusion and prospects

Prospects

Extending the random simulation finer-grain recompilation protocol

◮ eg distinguishing between introduction class and static type

  • ptimization of non-self-invocations

≈ 75% of all method invocations

◮ static analysis (eg CHA, type analysis), ◮ monomorphic calls as static calls.

More benchmarks you are welcome! Simulation is a promising approach but eventually a real virtual machine will be needed...

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 21 / 22

slide-29
SLIDE 29

Conclusion and prospects

That’s all folks!

drawings by F’murr.

  • R. Ducournau & F. Morandat (LIRMM)

Multiple Inheritance Virtual Machine June 22, 2010 22 / 22