Skip to content

Introduce StgRetBCO struct in RTS

Motivation

It's a bit hard to grasp how RET_BCO frames are layed out on stack.

This example from Scav.c shows how RET_BCO frames are deconstructed:

    case RET_BCO: {
        StgBCO *bco;
        StgWord size;

        p++;
        evacuate((StgClosure **)p);
        bco = (StgBCO *)*p;
        p++;
        size = BCO_BITMAP_SIZE(bco);
        scavenge_large_bitmap(p, BCO_BITMAP(bco), size);
...
    }

Following the example above, the layout is:

  • There is a StgClosure
  • Its payload (word after header) is a StgBCO*
  • Then, the arguments follow

Proposal

To make this a bit more obvious, introduce struct StgRetBCO:

struct StgRetBCO {
  StgHeader header;
  StgBCO** bco;
  StgWord args[];
}

I haven't tried this, yet. I'm writing this ticket to keep the idea. It may be, that I'm missing something.

Edited by Sven Tennie
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information