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
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
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
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
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
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
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
Single Subtyping (SST)
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
Single Subtyping (SST)
Offset attr
value
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
Single Subtyping (SST)
meth Offset
method
Offset attr
value
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
Single Subtyping (SST)
Offset class
id class
meth Offset
method
Offset attr
value
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
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
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
C++ Subobjects (SO)
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
C++ Subobjects (SO)
table
method table
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
C++ Subobjects (SO)
method delta2
meth Offset
table
method table
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
C++ Subobjects (SO)
table2
delta2
method delta2
meth Offset
table
method table
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
C++ Subobjects (SO)
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
C++ Subobjects (SO)
table
method table
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
C++ Subobjects (SO)
Offset cast
delta1 table
method table
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
C++ Subobjects (SO)
table1
delta1 Offset cast
delta1 table
method table
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
C++ Subobjects (SO)
table1
Offset attr
value
delta1 Offset cast
delta1 table
method table
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
C++ Subobjects (SO)
table1
delta1 Offset cast
delta1 table
method table
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
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
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
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
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
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
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
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
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
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
Perfect Class Hashing (PH)
method
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
Perfect Class Hashing (PH)
method
method
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
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
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
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
Perfect Class Hashing (PH)
aOffset
attr
attr
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
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
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
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
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
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
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
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
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
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
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
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
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
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