Empirical Assessment of C ++ -like Implementations for Multiple - - PowerPoint PPT Presentation

empirical assessment of c like implementations for
SMART_READER_LITE
LIVE PREVIEW

Empirical Assessment of C ++ -like Implementations for Multiple - - PowerPoint PPT Presentation

Empirical Assessment of C ++ -like Implementations for Multiple Inheritance Floral Morandat Roland Ducournau LIRMM The University of Montpellier & CNRS MASPEGHI/ICOOOLPS10, June 2115, 2010, Maribor Slovenia Outline


slide-1
SLIDE 1

Empirical Assessment of C++-like Implementations for Multiple Inheritance

Floréal Morandat ∗ Roland Ducournau

LIRMM — The University of Montpellier & CNRS

MASPEGHI/ICOOOLPS’10, June 21–15, 2010, Maribor — Slovenia

slide-2
SLIDE 2

Outline

1

Introduction

2

Implementation Techniques

3

Execution Testbed

4

Results and Discussion

5

Conclusion and Prospects

2 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-3
SLIDE 3

Outline

1

Introduction

2

Implementation Techniques

3

Execution Testbed

4

Results and Discussion

5

Conclusion and Prospects

3 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-4
SLIDE 4

Introduction

Context & Motivation Compilation of multiple inheritance with static typing:

Constant time Reasonable space Compatible with dynamic loading (OWA)

Objective Only two implementation techniques satisfy these requirements:

C++ Subobjects (virtual inheritance) Perfect Class Hashing

Which is the best one?

4 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-5
SLIDE 5

Outline

1

Introduction

2

Implementation Techniques Single Subtyping C++ Subobjects Perfect Class Hashing Abstract assessment

3

Execution Testbed

4

Results and Discussion

5

Conclusion and Prospects

5 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-6
SLIDE 6

Single Subtyping (SST)

  • bject
  • bject layout

table

method table

Attribute Access load [object + #attributeOffset] -> value ; Read store value -> [object + #attributeOffset] ; Write

6 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-7
SLIDE 7

Single Subtyping (SST)

Offset attr

value

  • bject
  • bject layout

table

method table

Attribute Access load [object + #attributeOffset] -> value ; Read store value -> [object + #attributeOffset] ; Write

6 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-8
SLIDE 8

Single Subtyping (SST)

meth Offset

method

Offset attr

value

  • bject
  • bject layout

table

method table

Method invocation load [object + #tableOffset] -> table load [table + #methodOffset] -> method call method

7 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-9
SLIDE 9

Single Subtyping (SST)

Offset class

id class

meth Offset

method

Offset attr

value

  • bject
  • bject layout

table

method table

Subtype test load [object + #tableOffset], table load [table + #classIdPosition], class cmp #classId, class bne #checkFailed

8 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-10
SLIDE 10

Single Subtyping (SST)

Advantages

Compatible with OWA Optimal time/space for dynamic loading

Time: Constant for all mechanism Space: Linear in the specialization relationship size

i.e. quadratic in the class number

Simple at compile-time

Invariants

References don’t depend on their static type Positions independent of receiver’s dynamic type

9 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-11
SLIDE 11

From SST to MI

MI can’t preserve both OWA and SST invariants

Preserving SST invariants Coloring

[Dixon et al. 1989]

Requires CWA at link-time

Preserving OWA and position invariant C++ Subobjects (virtual inheritance)

References depend on their static types Overhead: Cubic table size, pointer adjustments, . . .

Preserving OWA and reference invariant Perfect Class Hashing

Positions depend on the dynamic type Overhead: Hashing + Hashtable

10 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-12
SLIDE 12

C++ Subobjects (SO)

  • bject

Method invocation load [object + #tableOffset], table load [table + #methOffset + fieldLen], delta2 load [table + #methOffset], method add object, delta2, object2 call method

11 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-13
SLIDE 13

C++ Subobjects (SO)

table

method table

  • bject

Method invocation load [object + #tableOffset], table load [table + #methOffset + fieldLen], delta2 load [table + #methOffset], method add object, delta2, object2 call method

11 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-14
SLIDE 14

C++ Subobjects (SO)

method delta2

meth Offset

table

method table

  • bject

Method invocation load [object + #tableOffset], table load [table + #methOffset + fieldLen], delta2 load [table + #methOffset], method add object, delta2, object2 call method

11 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-15
SLIDE 15

C++ Subobjects (SO)

table2

delta2

  • bject2

method delta2

meth Offset

table

method table

  • bject

Method invocation load [object + #tableOffset], table load [table + #methOffset + fieldLen], delta2 load [table + #methOffset], method add object, delta2, object2 call method

11 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-16
SLIDE 16

C++ Subobjects (SO)

  • bject1

table1

Offset attr

value

Attribute access load [object + #tableOffset], table load [table + #castOffset], delta1 add object, delta1, object1 load [object1 + #attrOffset], value

12 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-17
SLIDE 17

C++ Subobjects (SO)

table

method table

  • bject

Attribute access load [object + #tableOffset], table load [table + #castOffset], delta1 add object, delta1, object1 load [object1 + #attrOffset], value

12 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-18
SLIDE 18

C++ Subobjects (SO)

Offset cast

delta1 table

method table

  • bject

Attribute access load [object + #tableOffset], table load [table + #castOffset], delta1 add object, delta1, object1 load [object1 + #attrOffset], value

12 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-19
SLIDE 19

C++ Subobjects (SO)

  • bject1

table1

delta1 Offset cast

delta1 table

method table

  • bject

Attribute access load [object + #tableOffset], table load [table + #castOffset], delta1 add object, delta1, object1 load [object1 + #attrOffset], value

12 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-20
SLIDE 20

C++ Subobjects (SO)

  • bject1

table1

Offset attr

value

delta1 Offset cast

delta1 table

method table

  • bject

Attribute access load [object + #tableOffset], table load [table + #castOffset], delta1 add object, delta1, object1 load [object1 + #attrOffset], value

12 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-21
SLIDE 21

C++ Subobjects (SO)

  • bject1

table1

delta1 Offset cast

delta1 table

method table

  • bject

Pointer adjustment load [object + #tableOffset], table load [table + #castOffset], delta1 add object, delta1, object1 load [object1 + #attrOffset], value

12 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-22
SLIDE 22

Perfect Class Hashing (PH)

Object

Preamble load [object + #tableOffset], table load [table + #hashingOffset], h and #classId, h, hv sub table, hv, htable

13 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-23
SLIDE 23

Perfect Class Hashing (PH)

table

method table Object

Preamble load [object + #tableOffset], table load [table + #hashingOffset], h and #classId, h, hv sub table, hv, htable

13 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-24
SLIDE 24

Perfect Class Hashing (PH)

h table

method table Object

Preamble load [object + #tableOffset], table load [table + #hashingOffset], h and #classId, h, hv sub table, hv, htable

13 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-25
SLIDE 25

Perfect Class Hashing (PH)

hashtable hv

h table

method table Object

Preamble load [object + #tableOffset], table load [table + #hashingOffset], h and #classId, h, hv sub table, hv, htable

13 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-26
SLIDE 26

Perfect Class Hashing (PH)

hashtable hv

h table

method table Object

Subtype testing load [htable + #htOffset-fieldLen], id comp #classId, id bne #fail % succeed

14 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-27
SLIDE 27

Perfect Class Hashing (PH)

Id class

hashtable hv

h table

method table Object

Subtype testing load [htable + #htOffset-fieldLen], id comp #classId, id bne #fail % succeed

14 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-28
SLIDE 28

Perfect Class Hashing (PH)

Id class

hashtable hv

h table

method table Object

Subtype testing load [htable + #htOffset-fieldLen], id comp #classId, id bne #fail % succeed

14 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-29
SLIDE 29

Perfect Class Hashing (PH)

hashtable hv

h table

method table Object

Method invocation load [htable + #htOffset], cOffset load [ctable + #methOffset], method call method

15 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-30
SLIDE 30

Perfect Class Hashing (PH)

cTable hashtable hv

h table

method table Object

Method invocation load [htable + #htOffset], cOffset load [ctable + #methOffset], method call method

15 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-31
SLIDE 31

Perfect Class Hashing (PH)

method

  • ffset

cTable hashtable hv

h table

method table Object

Method invocation load [htable + #htOffset], cOffset load [ctable + #methOffset], method call method

15 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-32
SLIDE 32

Perfect Class Hashing (PH)

method

method

  • ffset

cTable hashtable hv

h table

method table Object

Method invocation load [htable + #htOffset], cOffset load [ctable + #methOffset], method call method

15 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-33
SLIDE 33

Perfect Class Hashing (PH)

hashtable hv

h table

method table Object

Attribute access load [htable + #htOffset], aOffset add objet, aOffset, aGroup load [aGroup + #attributeOffset], value

16 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-34
SLIDE 34

Perfect Class Hashing (PH)

aOffset

hashtable hv

h table

method table Object

Attribute access load [htable + #htOffset], aOffset add objet, aOffset, aGroup load [aGroup + #attributeOffset], value

16 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-35
SLIDE 35

Perfect Class Hashing (PH)

aOffset

aOffset

hashtable hv

h table

method table Object

Attribute access load [htable + #htOffset], aOffset add objet, aOffset, aGroup load [aGroup + #attributeOffset], value

16 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-36
SLIDE 36

Perfect Class Hashing (PH)

aOffset

attr

attr

  • ffset

aOffset

hashtable hv

h table

method table Object

Attribute access load [htable + #htOffset], aOffset add objet, aOffset, aGroup load [aGroup + #attributeOffset], value

16 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-37
SLIDE 37

Abstract assessment

Subobjects (SO)

Pointer adjustments Cubic space Overhead in object layout

Perfect Class Hashing (PH)

Overhead for hashing Quadratic space

Abstract cycle count Subtype test Method call Attr access Ptr adjust SST 2L + 2 2L + B L SO 4L + 4 2L + B + 2 L 2L +1 PH 3L + 4 L + B + 3 4L + 3

17 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-38
SLIDE 38

Outline

1

Introduction

2

Implementation Techniques

3

Execution Testbed

4

Results and Discussion

5

Conclusion and Prospects

18 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-39
SLIDE 39

Test Language

The Prm Language

Full multiple inheritance (methods & attributes) Genericity Primitive types are subtypes of Object

The PrmC Compiler

A Prm program Modular Generates C code

19 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-40
SLIDE 40

Meta-Compiling Test Protocol

executable Test executable Test executable Test Compiler Test program

All boxes are compilers Time measurement of the red path

20 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-41
SLIDE 41

Meta-Compiling Test Protocol

result Test data Test executable Test executable Test executable Test Compiler Test program

All boxes are compilers Time measurement of the red path

20 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-42
SLIDE 42

Meta-Compiling Test Protocol

Runtime Reproducibility

Deterministic code generation

Hashmap with predictable iteration order Produces diff-equivalent binaries

Bootstrap = actual fix point

Measurements

Time spent by the Prm to C process Best time among severals tens of runs

21 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-43
SLIDE 43

Outline

1

Introduction

2

Implementation Techniques

3

Execution Testbed

4

Results and Discussion

5

Conclusion and Prospects

22 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-44
SLIDE 44

Runtime Efficiency

Overhead wrt SST Core2 E8500 3.16Gz Xeon Irwindale 2.8Gz

% 10 20 30 40 50 Perfect Hashing Subobject Without GC Without GC

Static Dynamic space space

% 50 100 150

23 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-45
SLIDE 45

Discussion

Subobjects

Dynamic space overhead ⇒ Increase GC time Numerous pointer adjustments ⇒ Offset PH overhead

Perfect Class Hashing

Time: Similar to SO Space:

Slight static overhead vs SST (Code length + Hashtable size) No dynamic overhead

Allow for Just-In-Time optimizations

24 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-46
SLIDE 46

Outline

1

Introduction

2

Implementation Techniques

3

Execution Testbed

4

Results and Discussion

5

Conclusion and Prospects

25 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-47
SLIDE 47

Conclusion

Comparisons

First “language-independent” comparisons of SO implementation First comparison of PH vs OWA compatible implementation

Perfect Class Hashing According to these tests:

Time Efficiency similar to Subobjects Allow for Just-In-Time optimizations

The Prm Testbed

Modular compiler open to new implementations Repeatable and reproducible tests Single benchmark, but intensive OO mechanism usage

26 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-48
SLIDE 48

Prospects

Testbed extension

Improving Subobjects

Empty Subojects optimization Thunk implementation Heterogeneous vs homogeneous genericity

Other processors and architectures Other optimisations (garbage collector, . . . )

Virtual Machine application

Perfect Class Hashing on Production VM Full multiple inheritance VM (as efficient as Java/.NET)

27 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance

slide-49
SLIDE 49

Thanks ...

Prm the languages

Prm : Dedicated to test http://www.lirmm.fr/prm/ Nit : User friendly language (recommended) http://www.nitlanguage.org/

28 Introduction Implementation Techniques Testbed Results Conclusion Empirical Assessment of C++-like Implementations for Multiple Inheritance