composing heterogeneous software with style
play

Composing heterogeneous software with style Stephen Kell - PowerPoint PPT Presentation

Composing heterogeneous software with style Stephen Kell stephen.kell@cs.ox.ac.uk Composing. . . p.1/12 Software is heterogeneous When building software, we have a lot of choices. Composing. . . p.2/12 Heterogeneous software doesnt


  1. Composing heterogeneous software with style Stephen Kell stephen.kell@cs.ox.ac.uk Composing. . . – p.1/12

  2. Software is heterogeneous When building software, we have a lot of choices. Composing. . . – p.2/12

  3. Heterogeneous software doesn’t compose What if we didn’t choose the same x ? I say ... You say ... x language java.util libraries GLib conventions throw new IOException(); return EIO; patterns while (it.hasNext()) while (it != end()) Let’s call the whole thing off! Composing. . . – p.3/12

  4. Simple example struct wc; // opaque to client struct wc ∗ wc new( const char ∗ fname); // returns NULL and sets errno on error int wc get words( struct wc ∗ obj); int wc get characters( struct wc ∗ obj); int wc get lines( struct wc ∗ obj); int wc get all( struct wc ∗ obj, int ∗ words out, int ∗ chars out, int ∗ lines out ); void wc free( struct wc ∗ obj); Composing. . . – p.4/12

  5. Simple example struct wc; class WordCounter { // opaque to client / ∗ fields not shown... ∗ / struct wc ∗ wc new( const char ∗ fname); public WordCounter(String filename) // returns NULL and sets errno on error throws IOException { / ∗ ... ∗ / } int wc get words( struct wc ∗ obj); public int getWords() { / ∗ ... ∗ / } int wc get characters( struct wc ∗ obj); public int getCharacters() { / ∗ ... ∗ / } int wc get lines( struct wc ∗ obj); public int getLines() { / ∗ ... ∗ / } int wc get all( struct wc ∗ obj, public Triple < Integer, Integer, Integer > int ∗ words out, int ∗ chars out, getAll () { / ∗ ... ∗ / } int ∗ lines out ); } ; void wc free( struct wc ∗ obj); // deallocation by + GC Goal: link an implementation with alternate client. Composing. . . – p.4/12

  6. Styles in one slide What is a style? � It’s any set of interface conventions... � ... that recur across many components Why do we care about styles? � By describing them explicitly in some way ... � ... we can link components that use different styles. How do we identify styles? � Empirically! By looking at existing code... � ... through a unifying lens. Composing. . . – p.5/12

  7. Unifying lens A lot of code is (or can be) compiled down to object code. wc_new("README") = 0x9cd6180[struct wc] wc_get_words(0x9cd6180[struct wc]) = 311 wc_get_characters(0x9cd6180[struct wc]) = 2275 wc_get_lines(0x9cd6180[struct wc]) = 59 wc_get_all(0x9cd6180[struct wc], 0xbffeed00[stack], 0xbffeecfc[stack], 0xbffeecf8[stack]) = 0 wc_free(0x9cd6180[struct wc]) = () Composing. . . – p.6/12

  8. Unifying lens A lot of code is (or can be) compiled down to object code. _Jv_InitClass(..., 0x6015e0[java::lang::Class], ...) = ... _Jv_AllocObjectNoFinalizer(..., 0x6015e0, ...) = 0x9158d20 WordCounter::WordCounter(java::lang::String*)( 0x9158d20[WordCounter], 0x9ae3dc8[java::lang::String]) = WordCounter::getWords()(0x9158d20[WordCounter]) = 311 WordCounter::getCharacters()(0x9158d20[WordCounter]) = 2275 WordCounter::getLines()(0x9158d20[WordCounter]) = 59 WordCounter::getAll()(0x9158d20[WordCounter]) = 0x9f6093e8[Triple] Goal: abstract these traces to be alike... Composing. . . – p.6/12

  9. Unifying lens A lot of code is (or can be) compiled down to object code. I NITIALIZE S TATIC WC S TATE A LLOCATE WC O BJECT �− → O I NITIALIZE WC O BJECT ( O ) G ET W ORDS ( O ) �− → W G ET C HARACTERS ( O ) �− → C G ET L INES ( O ) �− → L G ET A LL ( O ) �− → ( AW , AC , AL ) F INALIZE WC O BJECT ( O ) ... so that they link directly! Composing. . . – p.6/12

  10. Cake in three slides (1) To capture styles, we extend the Cake linking language: � a rule-based language for describing adapters � declarative, black-box, convenient... ���� ����� ���� ���� ���� ���� ������� ���������� ������� ��� ��� Composing. . . – p.7/12

  11. Cake in two slides (2) Cake code consists of rules which relate interface elements. ����� ����� � � foo (...) ← → bar (...); Composing. . . – p.8/12

  12. Cake in two slides (2) Cake code consists of rules which relate interface elements. ����� ����� �������� �������� � � foo (...) ← → bar (...); baz(a, b) ← → baz(b, a); Composing. . . – p.8/12

  13. Cake in two slides (2) Cake code consists of rules which relate interface elements. ����� ����� �������� �������� ������ ��������� � � foo (...) ← → bar (...); baz(a, b) ← → baz(b, a); xyz(a) ← → xyz(a, 42); Composing. . . – p.8/12

  14. Cake in two slides (2) Cake code consists of rules which relate interface elements. ����� ����� �������� �������� ������ ��������� � � ��������� ��������� foo (...) ← → bar (...); baz(a, b) ← → baz(b, a); xyz(a) ← → xyz(a, 42); values Br ← → Tr Composing. . . – p.8/12

  15. Cake in two slides (2) Cake code consists of rules which relate interface elements. ����� ����� �������� �������� ������ ��������� � � ��������� ��������� ����������� ������������ foo (...) ← → bar (...); baz(a, b) ← → baz(b, a); xyz(a) ← → xyz(a, 42); values Br ← → Tr { sz ← → len; } ; Not shown: many-to-many rules, context-sensitive rules... Composing. . . – p.8/12

  16. Cake in three slides (3) Style rules relate concrete with abstracted interfaces. style name of style(parameter, ...) { concrete form ← → abstracted form / ∗ ... ∗ / ; // ... } Existing Cake compositions... ��� ��� Composing. . . – p.9/12

  17. Cake in three slides (3) Style rules relate concrete with abstracted interfaces. style name of style(parameter, ...) { concrete form ← → abstracted form / ∗ ... ∗ / ; // ... } ...cf. with styles: ����������� ��� ��� Composing. . . – p.9/12

  18. Style rules Styles relate more concrete with more abstract interfaces. style c89 style booleans(BOOL) { table BOOL ← → bool { 0 − → false ; − → true; 1 ← − true; } } ; style shell style booleans(BOOL) { table BOOL ← → bool { 0 − → true; − → false ; 1 ← − false ; } } ; Styles are applied when declaring a pre-existing component. exists c89 style booleans(elf reloc (”componentA.o”)) componentA; exists shell style booleans( elf reloc (”componentB.o”)) componentB; Composing. . . – p.10/12

  19. How it works ��������������������� ����������� ��������������������� ��������� ��������� ������������������ �������������������� �������������������� ������ ������ �������������� ����� ����� ������������������� �������������� � � �������������� �������������� ��� ��� ��������������������� ������������������������ ������������������� Composing. . . – p.11/12

  20. Conclusions & work in progress Extra stuff in the paper: � a more complex example (JNI dispatch) � composition of styles � preliminary styles survey (in Appendix) – more needed! No implementation yet! � Cake compiler includes some foundations � background project for me (collaborators welcome!) Thanks for listening. Any questions? Composing. . . – p.12/12

Recommend


More recommend