https://gcc.gnu.org/bugzilla/show_bug.cgi?id=94359

--- Comment #6 from Iain Sandoe <iains at gcc dot gnu.org> ---
(In reply to Iain Sandoe from comment #5)
> (In reply to Iain Sandoe from comment #4)

> I'm going to discuss this with the coroutines paper authors - as to whether
> any constraints had been considered.  Note, once again, that failure to
> implement this does not make us non-conforming.

coro paper author hadn't tested this configuration.

==
basically, the intent is that one can continue an arbitrary number
of coroutines, without overflowing the stack.  Maybe there's an alternate
pattern that we could construct that would allow this;  modulo the caller-
save of the TOC. Coroutine actor functions are marked with a flag, so we
do have a mechanism for handling them differently.

In the meantime, I guess this isn't going to work for PPC (AIX/powerpc64) 
:( and we have to XFAIL or switch it off.

/* A C equivalent of what's being done.  */
extern void actor (void *p);

/* This is how the public part of the coroutine frame ABI looks.  */
typedef struct __frame {
  void (*a) (void *);
  void (*d) (void *);
  float _other_things;
} generic_frame_t;

/* This is what a coroutine handle looks like.  */
typedef struct __handle {
  generic_frame_t *fp;
} generic_handle_t;

/* A fake call to get a handle...  */
__attribute__((__noinline__))
generic_handle_t get_handle (void)
{
  generic_frame_t *f = (generic_frame_t *)__builtin_malloc (sizeof
(generic_frame_t));
  f->a = actor;
  f->d = actor;
  f->_other_things = 0.0F;
  generic_handle_t h = {f};
  return h;
}

/* .. and part of coroutine state machine that wants to continue
   by executing another coroutine.
   X86 tail-calls this for O2+ (even for PIC) m32/m64
   PPC tail-calls for m32 (even for PIC), but not for ELFv2 m64.
   with the TOC reg caller-saved, perhaps there's no sequence that can
   work.
*/

void actor2 (void *p2)
{
  generic_handle_t h = get_handle ();

  generic_frame_t *t = h.fp;
  /* Use the TOC. */
  t->other_things = 1.1F;

   (*t->a) ((void *)t);
}

Reply via email to