Repository navigation
Commit ec7e7de
authored
Invoke through an erased context instead of the proxy type (#68)
An invoker's erased function pointer was typed R (*)(proxy<F>&, D,
Args...), so its type named the facade it was built for. That is fine
while metadata is only ever read by a proxy of exactly that facade, but
it prevents one proxy from reusing another's invoker: two proxy types
have different layouts, so passing one where the other is expected is
not valid.
Introduce erased_context, which carries only a pointer to the storage of
the contained value, and type invokers as invoker<Ctx, O>. Invocation
now resolves the contained type inside the context rather than through
reinterpret_invoke, and the lifetime dispatches take a void* rather than
a target proxy, so their invokers no longer mention F either. Resetting
the source metadata after an rvalue-qualified call moves to the call
site, where the facade is known.
Declare ptr_ ahead of meta_ so that the storage of the contained value
lies at offset 0. Every invocation now builds a context from it, and at
offset 0 that context is the address of the proxy itself. Where a proxy
is invoked more than once, the caller then keeps a single value live
instead of a separate context pointer: on aarch64 that removes a spill
and reload of the context across the first call, and shrinks the frame
by 16 bytes. Neither sizeof(proxy) nor its alignment changes.
relocate_dispatch becomes a tag with its own erased_context
specialization, which absorbs the bitwise-relocation path that used to
be selected via internal_dispatch, and internal_dispatch is removed.
substitution_dispatch needs the same path, because it relocates a
bitwise-relocatable value without requiring it to be move-constructible,
so it gets a specialization too; both it and the specialization drop out
once `super` replaces substitution.
Removes the public reinterpret_invoke, which had no remaining use: the
invoker macro was its only caller inside the library.1 parent 96e00f2 commit ec7e7de
10 files changed
Lines changed: 208 additions & 329 deletions
File tree
- docs/spec
- proxy_indirect_accessor
- proxy
- include/proxy/v4/detail
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
9 | 9 | | |
10 | 10 | | |
11 | 11 | | |
12 | | - | |
13 | 12 | | |
14 | 13 | | |
15 | 14 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
51 | 50 | | |
52 | 51 | | |
53 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
60 | 60 | | |
61 | 61 | | |
62 | 62 | | |
63 | | - | |
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | 32 | | |
34 | 33 | | |
35 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
59 | 59 | | |
60 | 60 | | |
61 | 61 | | |
62 | | - | |
This file was deleted.
0 commit comments