Multiple Ownership Nicholas Cameron Sophia Drossopoulou James Noble Matthew Smith
Background – Ownership Types Multiple Ownership Objects in Boxes Variance - ? MOJO Effects
Background
Ownership Types The heap is messy:
Ownership Types Organise it:
Ownership Types Give each object an owner:
Ownership Types class Project { Task t1; Task t2; List clients; }
Our Work
The Objects In Boxes Model
A Box is a Set of Objects
Objects in Boxes Single owner interpretation: An object is in its owner’s box
Programs are not Trees
One Owner is not Enough 75% of ownership structures require multiple ownership [34] Mitchell, ECOOP, ’06 Trees can not describe non-hierarchical structures
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:
Objects in Boxes
A Descriptive System Describes the heap Does not restrict references etc.
MOJO
MOJO Class declarations have the usual, formal ownership parameters: class C …
MOJO Class declarations have the usual, formal ownership parameters: class C … Types may have multiple corresponding actual owner parameters: C
MOJO Class declarations have the usual, formal ownership parameters: class C … Types may have multiple corresponding actual owner parameters: C
MOJO Class declarations have the usual, formal ownership parameters: class C … Types may have multiple corresponding actual owner parameters: C
MOJO class Connection { … } class Client { Connection c; } class Server { Connection c; }
Variance
Variance Connection Some owner
Variance Connection Some box May be the intersection of several boxes Variance in the number of owners
Subtyping Subtyping with wildcards is variant with respect to owners: C
Subtyping Subtyping with wildcards is variant with respect to owners: C
Subtyping Subtyping with wildcards is variant with respect to owners: C
Subtyping Subtyping with wildcards is variant with respect to owners: C
Constraints class C a intersects b, b disjoint c { … }
Constraints class D a intersects b { D } class E a disjoint b { }
Constraints class D a intersects b { D } class E a disjoint b { D }
Constraints class D a intersects b { D Object } class E a disjoint b { D }
Typing - strict Strict method sends and assignments to deal with variance of owners: class C { C f; } C ca; C c1; C c2; ca.f = ca;
Typing - strict Strict method sends and assignments to deal with variance of owners: class C { C f; } C ca; C c1; C c2; ca.f = ca; c1.f = c2;
Typing - strict
Effects
Effects
Effects Task t1; Task t2; … t1.f; // reads x / writes ε
Effects Task t1; Task t2; … t1.f; // reads x / writes ε t1.f = t2.f; // reads x,y / writes x
Effects with Multiple Owners Task t1; Task t2; … t1.f; // reads x & ? / writes ε
Effects with Multiple Owners Task t1; Task t2; … t1.f; // reads x & ? / writes ε t1.f = t2.f; // reads x & ?,y & z/ writes x & ?
Effects with Multiple Owners t1.f = t2.f; // reads x & ?,y & z/ writes x & ?
Disjointness Two expressions are disjoint if their effects do not overlap Complicated by ? – but & = intersection
Future Work
Future Work Explore variant owners using existential types class TaskList { Task datum; TaskList next; }
Future Work Reference and modification control
Future Work Constraints Topology - inside Unary - may read, may write Binary – may point to, may modify
Summary Ownership Types Multiple Ownership Objects in Boxes Variance MOJO Effects Thank you! Any questions?