A garbage collector operates in multiple threads, and one thread can be parsing
a region containing a free block while another thread is allocating space from
that free block for an object being relocated to that region. The object being
relocated may be an array object, for which the length determination is based on
more than one word in the object; it may be based on a class-identifying word and
a number-of-elements word. To prevent a parsing thread from parsing erroneously
by reading both of those words between the relocating thread's writing one of them
and writing the other, the relocating thread first writes into the classifying
word a distinguished value from which a parsing thread can conclude that the values
it reads in other fields of the block are not to be trusted. The relocating thread
then completes writing the other fields before it writes the relocated object's
classifying word, and any parsing thread repeats the size-determining routine until
the uninitialized value is removed and it can therefore rely on other values in
the block.