1 / 21

Multi-Method Dispatch Using Multiple Row Displacement

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.  1. AxA AxB BxA AxC BxB CxA BxC CxB

thanos
Download Presentation

Multi-Method Dispatch Using Multiple Row Displacement

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. 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 1 AxA AxB BxA AxC BxB CxA BxC CxB CxC 3 2 4

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

  3. 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 );

  4. 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 )

  5. 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 aPerson; if (…) aPerson = new Person(); else aPerson = new Student(); aPerson.id( ); Person (id1) Student (id2) id1 id2

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

  7. Inheritance Conflicts 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. 1 AxC AxD BxC AxE BxD ExC BxE ExD ExE • Relaxation • Let  = { P1 … Pn } and P < P1 … Pn, the methods in Pi and Pj do not conflict in P if : • i.e. 1 <= i, j, k <= n • Pi < Pj or • Pj < Pi or • { Pk  | Pk Pi Pk Pj } 2 2 2 2

  8. Review of single-receiver Row displacement Dispatch (RD) 4 Example: E anE = new E(); anE.(); 1 + 4 = 5 D:: A0 D3  B1 C2, E4

  9. MRD Dispatch Table for method  with 2 arguments AA AB BA AC BB CA AD BC CB DA AEBD CC DB EA BE CD DC EB CE DD EC DEED EE 1 2 3

  10. MRD Dispatch Table for method  with 2 arguments AA AB BA AC BB CA ADBC CB DA AEBD CC DB EA BE CD DC EB CE DD EC DE ED EE 1 2

  11. Data Structure per Behavior - Array of pointers to arrays • ( Level-0 array ) L0 - indexed by the 1st argument type • ( Level-1 array ) L1 - indexed by the 2nd argument type and • contains method addresses A0 B1 C2 D3 E4 A0 B1 C2 D3 E4

  12. Compressing the Data Structure for  M - Global Master Array I0 - Global Index Array B - Global Behavior Array

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

  14. 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

  15. BD DB EE M [I1 [I0 [ B[] +4] +3] +1] = M [I1 [I0 [ 7+4] +3] +1] = M [I1 [ 5+3] +1] = M[ 15+1] Example: dispatch a call-site  (anE, aD, aB)

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

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

  18. 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.

  19. 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

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

  21. 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.

More Related