Composing heterogeneous software with style Stephen Kell - - PowerPoint PPT Presentation

composing heterogeneous software with style
SMART_READER_LITE
LIVE PREVIEW

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


slide-1
SLIDE 1

Composing heterogeneous software with style

Stephen Kell

stephen.kell@cs.ox.ac.uk

  • Composing. . . – p.1/12
slide-2
SLIDE 2

Software is heterogeneous When building software, we have a lot of choices.

  • Composing. . . – p.2/12
slide-3
SLIDE 3

Heterogeneous software doesn’t compose What if we didn’t choose the same x? x I say ... You say ... language libraries GLib java.util conventions

return EIO;

throw new IOException();

patterns

while (it != end())

while (it.hasNext())

Let’s call the whole thing off!

  • Composing. . . – p.3/12
slide-4
SLIDE 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
slide-5
SLIDE 5

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); class WordCounter { /∗ fields not shown... ∗/ public WordCounter(String filename) throws IOException { /∗ ... ∗/ } public int getWords() { /∗ ... ∗/ } public int getCharacters() { /∗ ... ∗/ } public int getLines() { /∗ ... ∗/ } public Triple<Integer, Integer, Integer> getAll () { /∗ ... ∗/ } }; // deallocation by + GC

Goal: link an implementation with alternate client.

  • Composing. . . – p.4/12
slide-6
SLIDE 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
slide-7
SLIDE 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
slide-8
SLIDE 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
slide-9
SLIDE 9

Unifying lens A lot of code is (or can be) compiled down to object code.

INITIALIZE STATIC WC STATE ALLOCATE WC OBJECT − →O INITIALIZE WC OBJECT(O) GET WORDS(O) − →W GET CHARACTERS(O) − →C GET LINES(O) − → L GET ALL(O) − →(AW, AC, AL) FINALIZE WC OBJECT(O)

... so that they link directly!

  • Composing. . . – p.6/12
slide-10
SLIDE 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
slide-11
SLIDE 11

Cake in two slides (2) Cake code consists of rules which relate interface elements.

  • foo (...)

← → bar (...);

  • Composing. . . – p.8/12
slide-12
SLIDE 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
slide-13
SLIDE 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
slide-14
SLIDE 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
slide-15
SLIDE 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
slide-16
SLIDE 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
slide-17
SLIDE 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
slide-18
SLIDE 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
slide-19
SLIDE 19

How it works

  • Composing. . . – p.11/12
slide-20
SLIDE 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