Skip to content

Commit 994085a

Browse files
committed
Rename 'remove' to 'transfer' in CABI and remove dead paragraph
1 parent 0f5a93f commit 994085a

File tree

2 files changed

+20
-25
lines changed

2 files changed

+20
-25
lines changed

design/mvp/CanonicalABI.md

Lines changed: 15 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ class HandleTable:
333333
return i
334334
```
335335
The `HandleTable` class maintains a dense array of handles that can contain
336-
holes created by the `remove_or_drop` method (defined below). These holes are
336+
holes created by the `transfer_or_drop` method (defined below). These holes are
337337
kept in a separate Python list here, but an optimizing implementation could
338338
instead store the free list in the free elements of `array`. When adding a new
339339
handle, `HandleTable` first consults the `free` list, which is popped LIFO to
@@ -349,11 +349,11 @@ use-after-free:
349349
return self.array[i]
350350
```
351351

352-
The last method of `HandleTable`, `remove_or_drop`, is used to drop or transfer
353-
a handle out of the handle table. `remove_or_drop` adds the removed handle to
354-
the `free` list for later recycling by `add` (above).
352+
The last method of `HandleTable`, `transfer_or_drop`, is used to transfer or
353+
drop a handle out of the handle table. `transfer_or_drop` adds the removed
354+
handle to the `free` list for later recycling by `add` (above).
355355
```python
356-
def remove_or_drop(self, i, t, drop):
356+
def transfer_or_drop(self, i, t, drop):
357357
h = self.get(i)
358358
trap_if(h.lend_count != 0)
359359
match t:
@@ -370,13 +370,13 @@ the `free` list for later recycling by `add` (above).
370370
return h
371371
```
372372
The `lend_count` guard ensures that no dangling borrows are created when
373-
destroying a resource. Because `remove_or_drop` is used for cross-component
373+
destroying a resource. Because `transfer_or_drop` is used for cross-component
374374
transfer of `own` handles (via `lift_own` below), this `lend_count` guard
375375
ensures that when a component receives an `own`, it receives a unique reference
376376
to the resource and that there aren't any dangling borrows hanging around from
377-
the previous owner. The bookkeeping performed by `remove_or_drop` for borrowed
378-
handles records the fulfillment of the obligation of the borrower to drop the
379-
handle before the end of the call.
377+
the previous owner. The bookkeeping performed by `transfer_or_drop` for
378+
borrowed handles records the fulfillment of the obligation of the borrower to
379+
drop the handle before the end of the call.
380380

381381
Finally, we can define `HandleTables` (plural) as simply a wrapper around
382382
a mutable mapping from `ResourceType` to `HandleTable`:
@@ -396,16 +396,16 @@ class HandleTables:
396396
return self.table(t.rt).add(h, t)
397397
def get(self, i, rt):
398398
return self.table(rt).get(i)
399-
def remove(self, i, t):
400-
return self.table(t.rt).remove_or_drop(i, t, drop = False)
399+
def transfer(self, i, t):
400+
return self.table(t.rt).transfer_or_drop(i, t, drop = False)
401401
def drop(self, i, t):
402-
self.table(t.rt).remove_or_drop(i, t, drop = True)
402+
self.table(t.rt).transfer_or_drop(i, t, drop = True)
403403
```
404404
While this Python code performs a dynamic hash-table lookup on each handle
405405
table access, as we'll see below, the `rt` parameter is always statically
406406
known such that a normal implementation can statically enumerate all
407407
`HandleTable` objects at compile time and then route the calls to `add`,
408-
`get` and `remove_or_drop` to the correct `HandleTable` at the callsite. The
408+
`get` and `transfer_or_drop` to the correct `HandleTable` at the callsite. The
409409
net result is that each component instance will contain one handle table per
410410
resource type used by the component, with each compiled adapter function
411411
accessing the correct handle table as-if it were a global variable.
@@ -623,10 +623,10 @@ side will wrap this representation value in its own new `OwnHandle` in its on
623623
handle table.
624624
```python
625625
def lift_own(cx, i, t):
626-
h = cx.inst.handles.remove(i, t)
626+
h = cx.inst.handles.transfer(i, t)
627627
return OwnHandle(h.rep, 0)
628628
```
629-
Note that `t` refers to an `own` type and thus `HandleTable.remove` will, as
629+
Note that `t` refers to an `own` type and thus `HandleTable.transfer` will, as
630630
shown above, ensure that the handle at index `i` is an `OwnHandle`.
631631

632632
Lastly, `borrow` handles are lifted by getting the handle out of the
@@ -1002,11 +1002,6 @@ type, the only thing the borrowed handle is good for is calling
10021002
`resource.rep`, so lowering might as well avoid the overhead of creating an
10031003
intermediate borrow handle.
10041004

1005-
Note that the `rt` value that is stored in the runtime `Handle` captures what
1006-
is statically known about the handle right before losing this information in
1007-
the homogeneous `HandleTable`. Moreoever, as described above, distinct type
1008-
imports are given distinct `rt` values so that handles produced by lowering
1009-
different type imports are never interchangeable.
10101005

10111006
### Flattening
10121007

design/mvp/canonical-abi/definitions.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -369,7 +369,7 @@ def get(self, i):
369369

370370
#
371371

372-
def remove_or_drop(self, i, t, drop):
372+
def transfer_or_drop(self, i, t, drop):
373373
h = self.get(i)
374374
trap_if(h.lend_count != 0)
375375
match t:
@@ -402,10 +402,10 @@ def add(self, h, t):
402402
return self.table(t.rt).add(h, t)
403403
def get(self, i, rt):
404404
return self.table(rt).get(i)
405-
def remove(self, i, t):
406-
return self.table(t.rt).remove_or_drop(i, t, drop = False)
405+
def transfer(self, i, t):
406+
return self.table(t.rt).transfer_or_drop(i, t, drop = False)
407407
def drop(self, i, t):
408-
self.table(t.rt).remove_or_drop(i, t, drop = True)
408+
self.table(t.rt).transfer_or_drop(i, t, drop = True)
409409

410410
### Loading
411411

@@ -576,7 +576,7 @@ def unpack_flags_from_int(i, labels):
576576
#
577577

578578
def lift_own(cx, i, t):
579-
h = cx.inst.handles.remove(i, t)
579+
h = cx.inst.handles.transfer(i, t)
580580
return OwnHandle(h.rep, 0)
581581

582582
#

0 commit comments

Comments
 (0)