Skip to content

Commit ec7e7de

Browse files
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/.pages‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ nav:
99
- operator= (non-member): friend_operator_equality.md
1010
- operator=: assignment.md
1111
- reflect (non-member): friend_reflect.md
12-
- reinterpret_invoke (non-member): friend_reinterpret_invoke.md
1312
- reset: reset.md
1413
- swap (non-member): friend_swap.md
1514
- swap: swap.md

‎docs/spec/proxy/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,6 @@ As per `facade<F>`, `typename F::convention_types` shall be a [tuple-like](https
4747
| [`swap`](friend_swap.md) | overload the [`std::swap`](https://en.cppreference.com/w/cpp/algorithm/swap) algorithm |
4848
| [`invoke`](friend_invoke.md) | invokes a `proxy` with a specified convention |
4949
| [`reflect`](friend_reflect.md) | acquires reflection information of a contained type |
50-
| [`reinterpret_invoke`](friend_reinterpret_invoke.md) | invokes a dispatch on a `proxy` whose contained type is known statically |
5150

5251
## Comparing with Other Standard Polymorphic Wrappers
5352

‎docs/spec/proxy/friend_invoke.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,3 @@ int main() {
6060
## See Also
6161

6262
- [function template `reflect` (`proxy<F>`)](friend_reflect.md)
63-
- [function template `reinterpret_invoke` (`proxy<F>`)](friend_reinterpret_invoke.md)

‎docs/spec/proxy/friend_reinterpret_invoke.md‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

‎docs/spec/proxy_indirect_accessor/.pages‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ nav:
22
- proxy_indirect_accessor: README.md
33
- invoke: friend_invoke.md
44
- reflect: friend_reflect.md
5-
- reinterpret_invoke: friend_reinterpret_invoke.md

‎docs/spec/proxy_indirect_accessor/README.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ Class template `proxy_indirect_accessor` provides indirection accessibility for
2929
| ---------------------------------------------------- | ------------------------------------------------------------ |
3030
| [`invoke`](friend_invoke.md) | invokes a `proxy` with a specified convention |
3131
| [`reflect`](friend_reflect.md) | acquires reflection information of a contained type |
32-
| [`reinterpret_invoke`](friend_reinterpret_invoke.md) | invokes a dispatch on a `proxy` whose contained type is known statically |
3332

3433
## See also
3534

‎docs/spec/proxy_indirect_accessor/friend_invoke.md‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,3 @@ int main() {
5959
## See Also
6060

6161
- [function template `reflect` (`proxy_indirect_accessor<F>`)](friend_reflect.md)
62-
- [function template `reinterpret_invoke` (`proxy_indirect_accessor<F>`)](friend_reinterpret_invoke.md)

‎docs/spec/proxy_indirect_accessor/friend_reinterpret_invoke.md‎

Lines changed: 0 additions & 60 deletions
This file was deleted.

0 commit comments

Comments
 (0)