Change suspend order in GC
The GC currently does this:
1. acquire heapLock
2. suspend all threads
3. acquire heapWorkerLock
When the HeapWorker thread is suspended in #2, it might be holding
the lock we want in step #3, leading to VM deadlock. This change
reverses the order of #2 and #3, which should allow the HeapWorker
thread to progress to a point where it releases the lock before
the GC requests the suspension.
If futexes are being unfair, the GC might have to wait a bit
longer while the HeapWorker does stuff (it might unlock, do work,
and re-lock without the scheduler giving time to the GC thread;
with the old scheme the HeapWorker would see the pending thread
suspension immediately and stop). A better fix is planned.
Bug 3340837
Change-Id: Ib9b37c130903a2800f8f28ae61540a428dbfc5be
1 file changed