Hi Jason
> On 22 Aug 2024, at 17:47, Jason Merrill <[email protected]> wrote:
>
> On 8/22/24 12:35 PM, Iain Sandoe wrote:
>> Hi Jason,
>> Firstly, Arsen has WIP to revise the allocation / deallocation to deal with
>> coroutine frames that are more aligned than 2 * sizeof (pointer). We will
>> also
>> be considering Lewis' P2014 (use of the aligned allocator). So this patch is
>> very much a staging point.
>>>> operator new for the params provided. Extract a simplified version
>>>> + of the machinery from build_operator_new_call.
>>> This seems like a call to that function, not a simplified version of it?
>> Fixed the comment.
>>>> + NOTE: This can update the frame size so we need to account for that
>>>> + when building the IFN_CO_FRAME later. */
>>> I don't think it can when cookie and size_check are both NULL, as they are
>>> here.
>> That is good to know and I think we can factor in a change to the revisions
>> we
>> are making for more aligned frames (since we will need to intercept and
>> change
>> the frame allocation size to deal with those).
>>>> +build_coroutine_frame_delete_expr (tree coro_fp, tree orig, tree
>>>> frame_size,
>>>> + tree promise_type, location_t loc)
>>>> +{
>>> Here it seems like you could already use build_op_delete_call for all of
>>> this, just by converting coro_fp to pointer-to-promise_type instead of to
>>> ptr_type_node?
>> I am missing something - the frame pointer is not a pointer to a promise
>> object
>> it is a pointer to the whole coroutine state?
>
> Yes, but you could lie about that; build_op_delete_call only uses the type
> for lookup (which we want to do in the promise type), then converts to void*.
hmm I’m having trouble with this, but not sure what I’m doing wrong - this is
what I have now:
...
tree pptr_type = build_pointer_type (promise_type);
tree frame_arg = build1_loc (loc, CONVERT_EXPR, pptr_type, coro_fp);
…
del_coro_fr = build_op_delete_call (DELETE_EXPR, frame_arg, frame_size,
/*global_p=*/false,
/*placement=*/NULL,
/*alloc_fn=*/NULL,
tf_warning_or_error);
http://eel.is/c++draft/dcl.fct.def.coroutine#12 (sentence 2) says " If both a
usual deallocation function with only a pointer parameter and a usual
deallocation function with both a pointer parameter and a size parameter are
found, then the selected deallocation function shall be the one with two
parameters.”
however, if my promise provides both - the one with a single param is always
chosen.
It is not that the other overload is invalid - if I do not include the single
param version, the two param one is happily selected.
(I’m stumped at the moment)
>>>> + location_t save_input_loc = input_location;
>>>> + location_t loc = fn_start;
>>>> + input_location = loc;
>>> Here using iloc_sentinel is simple.
>> now using it.
>>>> + /* The decl_expr for the coro frame pointer, initialize to zero so that
>>>> we
>>>> + can pass it to the IFN_CO_FRAME (since there's no way to pass a type,
>>>> + directly apparently). This avoids a "used uninitialized" warning.
>>>> */
>>> You could pass build_zero_cst (frame_ptr_type) instead of the variable?
>> changed to do that.
>
> I meant pass the zero_cst to IFN_CO_FRAME, so you don't need to initialize
> coro_fp until after that call.
ack, I’ll tackle that once the op del is fixed.
Iain
>
> Jason