Skip to content

Commit ef29236

Browse files
committed
Remove child-reentrance special-case in CABI
1 parent 8b080cf commit ef29236

3 files changed

Lines changed: 13 additions & 28 deletions

File tree

design/mvp/CanonicalABI.md

Lines changed: 7 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1603,13 +1603,11 @@ When instantiating component instance `$inst`:
16031603

16041604
where `canon_lower` is defined:
16051605
```python
1606-
def canon_lower(opts, inst, callee, calling_import, ft, flat_args):
1606+
def canon_lower(opts, inst, callee, ft, flat_args):
16071607
import_call = ImportCall(opts, inst)
16081608
trap_if(not inst.may_leave)
1609-
16101609
assert(inst.may_enter)
1611-
if calling_import:
1612-
inst.may_enter = False
1610+
inst.may_enter = False
16131611

16141612
flat_args = CoreValueIter(flat_args)
16151613
flat_results = None
@@ -1623,9 +1621,7 @@ def canon_lower(opts, inst, callee, calling_import, ft, flat_args):
16231621

16241622
callee(start_thunk, return_thunk)
16251623

1626-
if calling_import:
1627-
inst.may_enter = True
1628-
1624+
inst.may_enter = True
16291625
import_call.exit()
16301626
return flat_results
16311627
```
@@ -1638,17 +1634,10 @@ as post-MVP [adapter functions].
16381634

16391635
By clearing `may_enter` for the duration of calls to imports, the `may_enter`
16401636
guard in `canon_lift` ensures that components cannot be externally reentered,
1641-
which is part of the [component invariants]. The `calling_import` condition
1642-
allows a parent component to call into a child component (which is, by
1643-
definition, not a call to an import) and for the child to then reenter the
1644-
parent through a function the parent explicitly supplied to the child's
1645-
`instantiate`. This form of internal reentrance allows the parent to fully
1646-
virtualize the child's imports.
1647-
1648-
Because `may_enter` is not cleared on the exceptional exit path taken by
1649-
`trap()`, if there is a trap during Core WebAssembly execution of lifting or
1650-
lowering, the component is left permanently un-enterable, ensuring the
1651-
lockdown-after-trap [component invariant].
1637+
which is part of the [component invariants]. Because `may_enter` is not cleared
1638+
on the exceptional exit path taken by `trap()`, if there is a trap during Core
1639+
WebAssembly execution of lifting or lowering, the component is left permanently
1640+
un-enterable, ensuring the lockdown-after-trap [component invariant].
16521641

16531642
### `canon resource.new`
16541643

design/mvp/canonical-abi/definitions.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1148,13 +1148,11 @@ def call_and_trap_on_throw(callee, args):
11481148

11491149
### `canon lower`
11501150

1151-
def canon_lower(opts, inst, callee, calling_import, ft, flat_args):
1151+
def canon_lower(opts, inst, callee, ft, flat_args):
11521152
import_call = ImportCall(opts, inst)
11531153
trap_if(not inst.may_leave)
1154-
11551154
assert(inst.may_enter)
1156-
if calling_import:
1157-
inst.may_enter = False
1155+
inst.may_enter = False
11581156

11591157
flat_args = CoreValueIter(flat_args)
11601158
flat_results = None
@@ -1168,9 +1166,7 @@ def return_thunk(results):
11681166

11691167
callee(start_thunk, return_thunk)
11701168

1171-
if calling_import:
1172-
inst.may_enter = True
1173-
1169+
inst.may_enter = True
11741170
import_call.exit()
11751171
return flat_results
11761172

design/mvp/canonical-abi/run_tests.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import definitions
2-
from functools import partial
32
from definitions import *
3+
from functools import partial
44

55
def equal_modulo_string_encoding(s, t):
66
if s is None and t is None:
@@ -353,7 +353,7 @@ def test_roundtrip(t, v):
353353
flat_args = lower_values(caller_cx, definitions.MAX_FLAT_PARAMS, [v], [t])
354354
if return_in_heap:
355355
flat_args += [ caller_heap.realloc(0, 0, alignment(t), elem_size(t)) ]
356-
flat_results = canon_lower(caller_opts, caller_inst, lifted_callee, True, ft, flat_args)
356+
flat_results = canon_lower(caller_opts, caller_inst, lifted_callee, ft, flat_args)
357357
if return_in_heap:
358358
flat_results = [ flat_args[-1] ]
359359
[got] = lift_values(caller_cx, definitions.MAX_FLAT_PARAMS, CoreValueIter(flat_results), [t])
@@ -420,7 +420,7 @@ def core_wasm(args):
420420
1,
421421
3
422422
]
423-
results = canon_lower(opts, inst, host_import, True, host_ft, args)
423+
results = canon_lower(opts, inst, host_import, host_ft, args)
424424
assert(len(results) == 1)
425425
assert(results[0] == 4)
426426
assert(canon_resource_rep(inst, rt, 4)[0] == 45)

0 commit comments

Comments
 (0)