multiple ownership nicholas cameron sophia drossopoulou james noble matthew smith

49
Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

Upload: joshua-day

Post on 17-Jan-2016

219 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

Multiple Ownership

Nicholas CameronSophia Drossopoulou

James NobleMatthew Smith

Page 2: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 2

• Background – Ownership Types

• Multiple Ownership• Objects in Boxes• Variance - ?• MOJO

• Effects

Page 3: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 3

Background

Page 4: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 4

Ownership Types

• The heap is messy:

Page 5: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 5

Ownership Types

• Organise it:

Page 6: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 6

Ownership Types

• Give each object an owner:

Page 7: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 7

Ownership Types

class Project<o> { Task<this> t1; Task<this> t2; List<this, o> clients;}

Page 8: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 8

Our Work

Page 9: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 9

The Objects In Boxes Model

Page 10: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 10

A Box is a Set of Objects

Page 11: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 11

Objects in Boxes

• Single owner interpretation:

• An object is in its owner’s box

Page 12: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 12

Programs are not Trees

Page 13: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 13

One Owner is not Enough

• 75% of ownership structures require multiple ownership• [34] Mitchell, ECOOP, ’06

• Trees can not describe non-hierarchical structures

Page 14: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 14

Objects in Boxes

• Multiple Ownership: objects may be in more than one box

• An object with multiple owners is in the intersection of their boxes:

Page 15: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 15

Objects in Boxes

Page 16: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 16

A Descriptive System

• Describes the heap• Does not restrict

references etc.

Page 17: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 17

MOJO

Page 18: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 18

MOJO

• Class declarations have the usual, formal ownership parameters:

class C<o, d> …

Page 19: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 19

MOJO

• Class declarations have the usual, formal ownership parameters:

class C<o, d> …• Types may have multiple corresponding

actual owner parameters:

C<b, c>

Page 20: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 20

MOJO

• Class declarations have the usual, formal ownership parameters:

class C<o, d> …• Types may have multiple corresponding

actual owner parameters:

C<b, c>

C<a & b, c >

Page 21: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 21

MOJO

• Class declarations have the usual, formal ownership parameters:

class C<o, d> …• Types may have multiple corresponding

actual owner parameters:

C<b, c>

C<a & b, c >

C<a & b & ?, c & a>

Page 22: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 22

MOJO

class Connection<o> { … }

class Client<o, s> { Connection<this & s> c;}

class Server<o> { Connection<this & ?> c;}

Page 23: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 23

Variance

Page 24: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 24

Variance

• Connection<this & ?>• Some owner

Page 25: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 25

Variance

• Connection<this & ?>• Some box

• May be the intersection of several boxes

• Variance in the number of owners

Page 26: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 26

Subtyping

• Subtyping with wildcards is variant with respect to owners:

C<a> <: C<?>

Page 27: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 27

Subtyping

• Subtyping with wildcards is variant with respect to owners:

C<a> <: C<?>

C<a> <: C<a & ?>

Page 28: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 28

Subtyping

• Subtyping with wildcards is variant with respect to owners:

C<a> <: C<?>

C<a> <: C<a & ?>

C<a & b & ?> <: C<a & ?>

Page 29: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 29

Subtyping

• Subtyping with wildcards is variant with respect to owners:

C<a> <: C<?>

C<a> <: C<a & ?>

C<a & b & ?> <: C<a & ?>

C<?> </: C<a>

C<a> </: C<a & b>

Page 30: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 30

Constraints

class C<a, b, c> a intersects b, b disjoint c{ … }

Page 31: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 31

Constraintsclass D<a, b> a intersects b { D<a, b>

}

class E<a, b> a disjoint b { }

Page 32: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 32

Constraintsclass D<a, b> a intersects b { D<a, b> }

class E<a, b> a disjoint b { D<a, b> }

Page 33: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 33

Constraintsclass D<a, b> a intersects b { D<a, b> Object<a & b> }

class E<a, b> a disjoint b { D<a, b> }

Page 34: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 34

Typing - strict

• Strict method sends and assignments to deal with variance of owners:class C<o> { C<o> f;}

C<a> ca; C<a & ?> c1; C<a & ?> c2;

ca.f = ca;

Page 35: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 35

Typing - strict

• Strict method sends and assignments to deal with variance of owners:class C<o> { C<o> f;}

C<a> ca; C<a & ?> c1; C<a & ?> c2;

ca.f = ca; c1.f = c2;

Page 36: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 36

Typing - strict

Page 37: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 37

Effects

Page 38: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 38

Effects

Page 39: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 39

Effects

Task<x> t1;Task<y> t2;…t1.f; // reads x / writes ε

Page 40: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 40

Effects

Task<x> t1;Task<y> t2;…t1.f; // reads x / writes εt1.f = t2.f; // reads x,y / writes x

Page 41: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 41

Effects with Multiple Owners

Task<x & ?> t1;Task<y & z> t2;…t1.f; // reads x & ? / writes ε

Page 42: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 42

Effects with Multiple Owners

Task<x & ?> t1;Task<y & z> t2;…t1.f; // reads x & ? / writes εt1.f = t2.f; // reads x & ?,y & z/ writes x & ?

Page 43: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 43

Effects with Multiple Ownerst1.f = t2.f; // reads x & ?,y & z/ writes x & ?

Page 44: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 44

Disjointness

• Two expressions are disjoint if their effects do not overlap

• Complicated by ? – but & = intersection

Page 45: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 45

Future Work

Page 46: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 46

Future Work

• Explore variant owners using existential types

class TaskList<o, d> { Task<d & ?> datum; TaskList<o, d> next;}

Page 47: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 47

Future Work

• Reference and modification control

Page 48: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 48

Future Work

• Constraints• Topology - inside• Unary - may read, may write• Binary – may point to, may modify

Page 49: Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith

[email protected] 49

Summary

• Ownership Types• Multiple Ownership

• Objects in Boxes• Variance• MOJO

• Effects

• Thank you!• Any questions?