Allow ByteArray# objects outside of HEAP_ALLOCED()
Motivation
I want to be able to have static ByteArray#s, and mmaped files that appear as ByteArray#s. Both require byte array heap objects that are not HEAP_ALLOCED().
Proposal
It appears that the only thing we need to do is to extend evacuate() (in rts/sm/Evac.c) so that in the !HEAP_ALLOCED_GC(q) case it appropriately handles the ARR_WORDS closure type.
In evacuate(), if !HEAP_ALLOCED_GC(q) then it does a case analysis on the object's closure type (info->type). It only expects to find a few closure types here. These are the ones expected/allowed to be found outside of the heap. It includes special cases for "static" objects (calling evacuate_static_object). However for those heap objects that contain no pointers at all it does nothing:
case CONSTR_0_1:
case CONSTR_0_2:
case CONSTR_NOCAF:
/* no need to put these on the static linked list, they don't need
* to be scavenged.
*/
return;
I think all we need to do is add case ARR_WORDS: to this list, so that byte arrays are also allowed and appropriately ignored.
Does this sound like the only case we would have to adjust?
I intend to provide a MR with a test case.