-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrefcaps.lyx
9881 lines (7146 loc) · 179 KB
/
refcaps.lyx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\save_transient_properties true
\origin unavailable
\textclass extreport
\use_default_options true
\begin_modules
fixltx2e
fix-cm
theorems-ams-bytype
\end_modules
\maintain_unincluded_children false
\language british
\language_package default
\inputencoding auto
\fontencoding global
\font_roman "default" "default"
\font_sans "default" "default"
\font_typewriter "default" "default"
\font_math "auto" "auto"
\font_default_family default
\use_non_tex_fonts false
\font_sc false
\font_osf false
\font_sf_scale 100 100
\font_tt_scale 100 100
\graphics default
\default_output_format default
\output_sync 0
\bibtex_command default
\index_command default
\paperfontsize default
\spacing single
\use_hyperref false
\papersize default
\use_geometry false
\use_package amsmath 1
\use_package amssymb 1
\use_package cancel 1
\use_package esint 1
\use_package mathdots 1
\use_package mathtools 1
\use_package mhchem 1
\use_package stackrel 1
\use_package stmaryrd 1
\use_package undertilde 1
\cite_engine basic
\cite_engine_type default
\biblio_style plain
\use_bibtopic false
\use_indices false
\paperorientation portrait
\suppress_date true
\justification true
\use_refstyle 1
\index Index
\shortcut idx
\color #008000
\end_index
\secnumdepth 3
\tocdepth 1
\paragraph_separation indent
\paragraph_indentation default
\quotes_language english
\papercolumns 1
\papersides 2
\paperpagestyle default
\tracking_changes false
\output_changes false
\html_math_output 0
\html_css_as_file 0
\html_be_strict false
\end_header
\begin_body
\begin_layout Chapter
\begin_inset CommandInset label
LatexCommand label
name "chap:Reference-Capabilities"
\end_inset
Reference Capabilities
\end_layout
\begin_layout Standard
Capabilities were introduced to support protection across processes
\begin_inset CommandInset citation
LatexCommand cite
key "lampson1974protection"
\end_inset
, and have been adopted into several branches of computing since.
The term
\emph on
object capabilities
\emph default
was coined by Mark Miller
\begin_inset CommandInset citation
LatexCommand cite
key "miller2006robust,miller2003capability"
\end_inset
to describe the set of operations an object is allowed to apply on some
other object.
Mark Miller proposes that in order to restrict this set, one should create
a new object which only offers these capabilities, and which delegates
to the original object.
This is a critical insight: in a memory safe language, the methods on an
object are the capabilities available on that object.
\end_layout
\begin_layout Standard
A
\emph on
reference capability
\emph default
is a type qualifier annotation on a reference, rather than an object, that
modifies the capabilities available on the underlying object when it is
accessed through that reference.
In Pony, reference capabilities are used to statically ensure data-race
freedom.
The term
\emph on
reference capability
\emph default
was introduced specifically to distinguish these Pony annotations from
object capabilities
\begin_inset CommandInset citation
LatexCommand cite
key "clebsch2015deny"
\end_inset
.
\end_layout
\begin_layout Standard
In previous work, type qualifiers for data-race freedom have been expressed
as
\emph on
permissions
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "boyland2001capabilities"
\end_inset
,
\emph on
fractional permissions
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "boyland2003checking"
\end_inset
,
\emph on
uniqueness
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "clarke2003external"
\end_inset
,
\emph on
immutability
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "ostlund2008ownership"
\end_inset
, and
\emph on
isolation
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "gordon2012uniqueness"
\end_inset
(a refinement of
\emph on
separate uniqueness
\emph default
\begin_inset CommandInset citation
LatexCommand cite
key "haller2010capabilities"
\end_inset
, which is a refinement of
\emph on
external uniqueness
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "clarke2003external"
\end_inset
).
\end_layout
\begin_layout Standard
These approaches use type qualifiers to describe what a reference is
\emph on
allowed
\emph default
to do.
Pony's type system takes a different approach and uses reference capabilities
to describe what other aliases are
\emph on
denied
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "dodds2009deny"
\end_inset
by the existence of a reference.
This is accomplished using a matrix of
\emph on
deny properties
\emph default
, with notions such as isolation, mutability, and immutability all being
derived from these properties.
What aliases to the object are allowed to do is explicit rather than implied,
whereas what the reference is allowed is derived.
This change in approach gives a derivation for properties previously considered
intrinsic, and models a reduction in reference capabilities as a weaker
guarantee.
\end_layout
\begin_layout Standard
Other approaches have combined actors with data-race freedom, such as minimal
ownership for active objects
\begin_inset CommandInset citation
LatexCommand cite
key "clarke2008minimal"
\end_inset
, capabilities for uniqueness and borrowing in Scala
\begin_inset CommandInset citation
LatexCommand cite
key "haller2010capabilities"
\end_inset
, and Kilim
\begin_inset CommandInset citation
LatexCommand cite
key "srinivasan2008kilim"
\end_inset
.
However, various useful patterns have not been supported, e.g.
traversing and modifying an isolated data structure, or updating an object
and then sending it in a message while keeping read access to it.
By taking a more fundamental view of reference capabilities, a more flexible
type system that supports such patterns became possible.
\end_layout
\begin_layout Standard
The matrix of deny properties exposes two novel reference capability types,
\begin_inset Formula $\mathtt{tag}$
\end_inset
and
\begin_inset Formula $\mathtt{trn}$
\end_inset
(
\emph on
transition
\emph default
).
A
\begin_inset Formula $\mathtt{tag}$
\end_inset
reference capability allows identity comparison and
\emph on
asynchronous
\emph default
method call, but does not allow reading from or writing to the reference.
Actors are typed as
\begin_inset Formula $\mathtt{tag}$
\end_inset
, which allows them to be integrated into the object type system and passed
in messages.
A
\begin_inset Formula $\mathtt{trn}$
\end_inset
reference capability is a new form of uniqueness,
\emph on
write uniqueness
\emph default
, that describes objects that can only be written to through a single reference,
but can be read from through many aliases.
\end_layout
\begin_layout Standard
This work also extends
\emph on
viewpoint adaptation
\emph default
\begin_inset CommandInset citation
LatexCommand cite
key "cunningham2008universe,gordon2012uniqueness"
\end_inset
to apply to every reference capability and introduce the concept of
\emph on
safe to write
\emph default
, which, taken together, allow reading from and writing to both unique objects
and unique fields.
The types of
\emph on
temporary identifiers
\emph default
are treated differently from those of permanent paths, which allows the
traversal of unique structures, something that is not possible using other
approaches
\begin_inset CommandInset citation
LatexCommand cite
key "gordon2012uniqueness,haller2010capabilities,clarke2008minimal"
\end_inset
.
\end_layout
\begin_layout Standard
In this system, an alias may have a different reference capability from
the initial reference.
This addresses a key issue in reference capability systems, namely that
sub-typing is not reflexive: an isolated type cannot be assigned to a field
or local variable unless the source reference is eliminated with a technique
such as
\emph on
destructive read
\emph default
or
\emph on
alias burying
\emph default
\begin_inset CommandInset citation
LatexCommand citep*
key "boyland2001alias"
\end_inset
.
As a part of this, the type system supports
\emph on
unaliased types
\emph default
, which provide static alias tracking without alias analysis.
\end_layout
\begin_layout Standard
Reference capabilities based on deny properties also provide a static
\emph on
region
\emph default
system
\begin_inset CommandInset citation
LatexCommand citep*
key "grossman2002region"
\end_inset
, requiring no additional annotation.
The
\begin_inset Formula $\mathtt{trn}$
\end_inset
reference capability provides a new form of
\emph on
write region
\emph default
, in which a region boundary applies to write operations but not read operations.
\end_layout
\begin_layout Section
Deny Properties
\end_layout
\begin_layout Standard
\begin_inset Float table
wide true
sideways false
status open
\begin_layout Plain Layout
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
makebox[
\backslash
textwidth][c]{
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\align center
\begin_inset Tabular
<lyxtabular version="3" rows="5" columns="4">
<features tabularvalignment="middle">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top" width="0pt">
<column alignment="center" valignment="top">
<column alignment="center" valignment="top">
<row>
<cell alignment="center" valignment="top" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
Deny global read/write aliases
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
Deny global write aliases
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
Allow all global aliases
\end_layout
\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
Deny local read/write aliases
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{writeable}
\end_layout
\end_inset
Isolated (
\begin_inset Formula $iso$
\end_inset
)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
Deny local write aliases
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{writeable}
\end_layout
\end_inset
\emph default
Transition (
\begin_inset Formula $\mathtt{trn}$
\end_inset
)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{readable}
\end_layout
\end_inset
Value (
\begin_inset Formula $val$
\end_inset
)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
Allow all local aliases
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{writeable}
\end_layout
\end_inset
\emph default
Reference (
\begin_inset Formula $\mathtt{ref}$
\end_inset
)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{readable}
\end_layout
\end_inset
\emph default
Box (
\begin_inset Formula $\mathtt{box}$
\end_inset
)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" topline="true" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{opaque}
\end_layout
\end_inset
Tag (
\begin_inset Formula $tag$
\end_inset
)
\end_layout
\end_inset
</cell>
</row>
<row>
<cell alignment="center" valignment="top" topline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" leftline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{writeable}
\end_layout
\end_inset
\emph default
(Mutable)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{readable}
\end_layout
\end_inset
\emph default
(Immutable)
\end_layout
\end_inset
</cell>
<cell alignment="center" valignment="top" bottomline="true" rightline="true" usebox="none">
\begin_inset Text
\begin_layout Plain Layout
\size tiny
\emph on
\begin_inset ERT
status open
\begin_layout Plain Layout
\backslash
cellcolor{opaque}
\end_layout
\end_inset
\emph default
(Opaque)
\end_layout
\end_inset
</cell>
</row>
</lyxtabular>
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset ERT
status open
\begin_layout Plain Layout
}
\end_layout
\end_inset
\end_layout
\begin_layout Plain Layout
\begin_inset Caption Standard
\begin_layout Plain Layout
\begin_inset CommandInset label
LatexCommand label
name "tab:Capability-matrix.-Capabilities"
\end_inset
Reference capability matrix
\end_layout
\end_inset
\end_layout
\end_inset
\end_layout
\begin_layout Standard
Rather than indicate which operations are allowed on a reference
\begin_inset Foot
status collapsed
\begin_layout Plain Layout
The term
\emph on
reference
\emph default
is used to mean the path currently being considered, and
\emph on
alias
\emph default
to mean any other path to the same object.
\end_layout
\end_inset
, reference capabilities indicate what operations are
\emph on
denied
\emph default
on aliases (other references) to the same object.
Deny properties distinguish what is denied to the actor that holds a reference
(local aliases) from what is denied to all other actors (global aliases).
Each reference capability stands for a pair of local and global deny properties.
These are shown in table
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Capability-matrix.-Capabilities"
\end_inset
.
For example,
\begin_inset Formula $\mathtt{ref}$
\end_inset
denies global aliases that can read from or write to the object, but it
allows local aliases to both read from and write to it.
\end_layout
\begin_layout Standard
No reference capability can deny local aliases that it allows globally.
Therefore, some cells in the matrix are empty.
For example, there is no reference capability that denies local read and
write aliases, but denies only write aliases globally.
This is because local execution is a subset of global execution.
As such, local deny properties can be weaker than global deny properties,
but not stronger.
\end_layout
\begin_layout Standard
These deny properties are used to derive the operations permitted on a reference.
A reference that denies global read and write aliases is safe to both read
and write, i.e.
is
\emph on
mutable
\emph default
, since it guarantees that no other actor can read from or write to the
object.
A reference that denies only global write aliases is only safe to read,
i.e.
\emph on
immutable
\emph default
, since it guarantees no other actor will write to the object, but does
not guarantee no other actor will read from it.
A reference that allows all global aliases is not safe to either read or
write, i.e.
it is opaque.
\end_layout
\begin_layout Standard
When the local deny properties and the global deny properties of a reference
are the same, the reference can be safely sent as an argument to an asynchronou
s method call to another actor, i.e.
it is
\emph on
sendable
\emph default
.
In other words, when the local alias deny properties are the same as the
global alias deny properties, it does not matter which actor holds the
reference.
Reference capabilities in italics in table
\begin_inset CommandInset ref
LatexCommand ref
reference "tab:Capability-matrix.-Capabilities"
\end_inset
are
\emph on
sendable.
\end_layout
\begin_layout Section
Short Examples
\end_layout
\begin_layout Standard
The following examples are compact and artificial.
A more complete example, using a sample program from the compiler distribution,
is in section
\begin_inset CommandInset ref
LatexCommand ref
reference "sec:Code-Example"
\end_inset
, along with a line by line explanation.
\end_layout
\begin_layout Standard
A
\begin_inset Formula $\mathtt{ref}$
\end_inset
reference to an object denies global read/write aliases.
As a result, it is safe to mutate the object, since no other actor can
read from it.
This is effectively a traditional object-oriented
\emph on
reference type
\emph default
.