Presentation is loading. Please wait.

Presentation is loading. Please wait.

Multi-Method Dispatch Using Multiple Row Displacement Candy Pang, Wade Holst, Yuri Leontiev, and Duane Szafron ECOOP’99 Presented by: Irene Cheng Date:

Similar presentations


Presentation on theme: "Multi-Method Dispatch Using Multiple Row Displacement Candy Pang, Wade Holst, Yuri Leontiev, and Duane Szafron ECOOP’99 Presented by: Irene Cheng Date:"— Presentation transcript:

1

2 Multi-Method Dispatch Using Multiple Row Displacement Candy Pang, Wade Holst, Yuri Leontiev, and Duane Szafron ECOOP’99 Presented by: Irene Cheng Date: 7 November 2002 AxA AxB BxA AxC BxB CxA BxC CxB CxC 11 22 33 44

3 Review of Terminology Review of Row Displacement Dispatch for Single-Receiver Multiple Row Displacement (MRD) Optimizations Performance Results and Conclusion Presentation Topics

4 Review of Terminology Single-receiver dispatch uses the dynamic type of a receiver object and the method name to determine which method to execute at run-time, e.g. aPerson.id(); Multi-method dispatch uses the dynamic types of the arguments and the method name to determine the method to execute, e.g. shape.intersect( rectangle, circle );

5 Review of Terminology (cont) What is a call-site ? In single-receiver languages - viewed as a message sent to the receiver object. e.g. In multi-method languages - viewed as the execution of a behavior on a set of arguments. e.g. The run-time determination of the method to invoke at a call-site is called method dispatch. aPerson.id() shape.intersect( rectangle, circle )

6 Review of Terminology (cont) Dispatch strategy: Cache-based (global or local) Table-based - Pre-determine the method for every possible call-site, and record these methods in a table. When a method is defined, each argument has a specific static type. However, at a call-site, the dynamic type of each argument can either be the static type, or any of its subtypes, e.g. Person ( id 1 ) Student ( id 2 ) Person aPerson; if (…) aPerson = new Person(); else aPerson = new Student(); aPerson.id( ); id 1 id 2

7 Product-Type Graph (for 2 arguments) AxA AxB BxA AxC BxB CxA BxC CxB CxC 11 22 33 44 The underlying Inheritance Hierarchy, H The 2-arity product-type graph, H 2 ABCABC A product-type graph hierarchy contains all the possible call-sites

8 Inheritance Conflicts AxC AxD BxC AxE BxD ExC BxE ExD ExE 11 22 General Definition A conflict occurs when a product-type can see 2 different method definitions by looking up different paths in the induced product- type graph. Relaxation Let  = { P 1 … P n } and P < P 1 … P n, the methods in P i and P j do not conflict in P if : i.e. 1 <= i, j, k <= n P i < P j or P j < P i or {  P k  | P k  P i  P k  P j }  2

9 Review of single-receiver Row displacement Dispatch (RD) Example: E anE = new E(); anE.  (); 1 + 4 = 5 D::  A 0  D 3  B 1 C 2 ,  E 4 4

10 MRD Dispatch Table for method  with 2 arguments AA AB BA AC BB CA AD BC CB DA AE BD CC DB EA BE CD DC EB CE DD EC DE ED EE 11 22 33

11 AA AB BA AC BB CA AD BC CB DA AE BD CC DB EA BE CD DC EB CE DD EC DE ED EE 11 22 MRD Dispatch Table for method  with 2 arguments

12 Data Structure per Behavior - Array of pointers to arrays A 0 B 1 C 2 D 3 E 4 ( Level-0 array ) L 0 - indexed by the 1 st argument type ( Level-1 array ) L 1 - indexed by the 2nd argument type and contains method addresses

13 Compressing the Data Structure for  M - Global Master Array I 0 - Global Index Array B - Global Behavior Array

14 Compressing the Data Structure for  and  M - Global Master Array I 0 - Global Index Array B - Global Behavior Array Example: Dispatch a call-site  (anE, aD) M [ I 0 [5 + 4 = 9 ] + 3 = 14 ]

15 MRD is designed for n-dimensional dispatch tables  1 BDB BDE BEB BEE EDB EDE EEB EEE  2 DBD DBE DED DEE EBD EBE EED EEE

16 Example: dispatch a call-site  (anE, aD, aB) M [I 1 [I 0 [ B [  ] +4] +3] +1] = M [I 1 [I 0 [ 7+4] +3] +1] = M [I 1 [ 5+3] +1] = M[ 15+1] BDDB EE

17 Optimizations Single I - One Global Index Array, I, to store all L 0 to L k-2 arrays I0I0 0 0 1 1 5 8 11 - - 11 - - 14 15 15 14 14 - 15 19 L0L0 - 8 - 9 13 0 5 17 B    0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 M [ I 0 [ I 0 [ B[  ] +4] +3] +1] = M [ I 0 [ I 0 [ 17+4] +3] +1] = M [ I 0 [ 13+3] +1] = M [ 15+1] Example:  (anE, aD, aB) I1I1

18 Optimizations (cont) Row-matching instead of row-shifting (additional 10-14% ) Row-shifting Row-matching Row-matching cannot be used in single-receiver RD because different rows contain different behavior, and thus different method addresses. Before displacement

19 Optimizations (cont) Byte vs. Word Storage (MRD-B) M is the most memory consuming data structure (duplicate 4-byte method address) Use method-map per behavior (each method address is stored only once) Only 1 byte (max. 256 methods) is used in M to store the index of the corresponding method in the method-map. Size of M is reduced to 1/4 but extra redirection time at dispatch.

20 Timing results Noop - dummy function to time the overhead incurred MRD - multiple row displacement MRD-B - MRD using byte instead of word for Master array CNT - Compressed N-Dimensional Tables SRP - Single Receiver Projections LUA - Lookup Automata

21 Memory Utilization LUA - Lookup Automata MRD - multiple row displacement MRD-B - MRD using byte instead of word for Master array CNT - Compressed N-DimensionalTables SRP - Single Receiver Projections

22 Conclusion A new multi-method dispatch technique is introduced to compress an n-dimensional table by row displacement. The first time a comparison of multi-method techniques has appeared in the literature. Experimental results shows that when comparing with other table-based multi-method techniques, MRD has the fastest dispatch time and the second smallest per-call-site code size.


Download ppt "Multi-Method Dispatch Using Multiple Row Displacement Candy Pang, Wade Holst, Yuri Leontiev, and Duane Szafron ECOOP’99 Presented by: Irene Cheng Date:"

Similar presentations


Ads by Google