[sgen] Add parallel copying infrastructure
authorVlad Brezae <brezaevlad@gmail.com>
Tue, 27 Sep 2016 14:48:22 +0000 (17:48 +0300)
committerVlad Brezae <brezaevlad@gmail.com>
Thu, 19 Jan 2017 22:45:11 +0000 (00:45 +0200)
commit6dd609be32144c149f4b51b4f5eea79a4c3e0b44
treeb4f4103371535bc82c133118a3098b5e22752410
parente382aa00b577f3908b4d822984f1e4b343741a6b
[sgen] Add parallel copying infrastructure

Parallel copying should happen only when the world is stopped and the gc thread is not running. Each thread allocates from its own block freelist, which he obtains by pop-ing the global block free list.

When a worker has to copy an object, it first allocates a new object in a major block and initialises its contents. Afterwards it tries to forward the vtable, using a CAS operation. If the vtable already contains a forwarded object, we just return the forwarded address, and the object that we allocated will be left to die (we expect this case to be extremely unlikely, otherwise we could re-enque the free object in its block's freelist).

After the copying is done, the caller has the duty to update references and mark the new object (which we have to do it also with a CAS).

FIXME : This means that an object can reside on a gray queue without being marked, so another thread can enque again this same object. We should refactor this copying/mark/enqueing mechansim to avoid these issues.
mono/sgen/sgen-copy-object.h
mono/sgen/sgen-gc.h
mono/sgen/sgen-marksweep-drain-gray-stack.h
mono/sgen/sgen-marksweep.c