Revert^12 "Thread suspension cleanup and deadlock fix"

This reverts commit b6f3b439d4f12e89393ba8101eea8671c94ba237.

PS1: Identical to aosp/2652371 .

PS2: Introduce kSuspensionImmune to disable suspension of a thread
  that is being relied upon to execute ResumeAll(). This replaces
  the test in SuspendAll() to check whether the caller was being asked
  to suspend itself. That test was deadlock-prone, since a SuspendAll
  request from e.g. the GC to block, and GC progress might be required
  to resume the thread running the GC.
  Since SuspendAll() now only loops for a single reason, we no longer
  need to track why we looped.
  Reduce the number of iterations in each 129-ThreadGetId thread
  drammatically.

PS3: Address reviewer comments, including fixing a newly introduced
  bug in CheckSuspend(). Fix 129-GetThreadId by drammatically reducing
  the iteration count when we appear to be running slowly, which is
  normally the case for gcstress. Earlier versions of this CL were
  apparently also failing on this test, but the failure was hidden by
  other failures. This mostly undoes the PS2 change to this test, now
  that the failure is better understood.

PS4: Rebase.

PS5: Fix 129-GetThreadId code formatting.

PS6: Address more reviewer comments related to 129-GetThreadId.

PS7: Remove DCHECK in EnsureFlipFunctionStarted. It was unsafe,
  since the thread may no longer be around.

Test: Treehugger.
Bug: 240742796
Bug: 203363895
Bug: 238032384
Bug: 253671779
Bug: 276660630
Bug: 295880862
Bug: 294334417
(and more)

Change-Id: I99260fdc4feb9bcdc8b8b566e40912532f1a4937
30 files changed