Revert^2 "Add spin loop to mutex, overhaul monitor"

This reverts commit d56f7d1086b16f32c0771a41a4afb376b5fd3076.

Reason for revert: PS2 fixes the problems I identified.

PS1 is straight revert^2 of, and thus identical to aosp/1111800.

PS2 in addition:
- Reduces the size of the test, when not modified to run as benchmark.
- Disables the test in slow-running configurations, which timed out.
- Stops using the mutex recursion count, and instead reintroduces
  one at the monitor level. The plan is to eliminate the one in mutex
  in a future CL.
- Avoids modifying various monitor fields in suspended state.
  MonitorInfo, deflation, etc., may look at the state of a suspended
  thread and expect not to race. I don't think the original code had
  this completely correct either, but PS1 made it worse.
- Documents some aspects of the code that confused me at times.
- Avoids dereferencing the monitor owner Thread* unless it holds the
  thread list lock, and thus knows that the thread won't go away.
- Stores a Thread* instead of a thread_id with the monitor owner method
  and dex pc information used for debugging. This is required to avoid
  extra thread list lock acquisitions, since we need to dereference the
  owner to get the thread id.
- Makes the thread list Contains method public, again in order to
  support the above. (This ignores C/C++ restrictions on dangling
  pointer use. We already rely on violating those elsewhere, and
  the committees are trying to get their story straight about this.)
- Causes the spin loop to give up immediately if the process is
  shutting down. This gets us to an actual idle state sooner in that
  case, and should hopefully mitigate the shutdown issues somewhat.
  (We tried not spinnning in "suspended" state, but that reintroduced
  some performance issues.)
- Makes runtime shutdown code more defensive. Clear fields pointing to
  deallocated objects. Always wait for quiescence AFTER all threads
  are suspended.
- Consistently checks for a runtime that's shutting down or missing
  after waking up from a futex wait, thus avoiding touching deallocated
  memory. I believe this was the cause of b/121302864, which PS1
  managed to aggravate.
- SleepForever() was a very light sleeper, waking up once a second.
  Fix that, so the daemon threads we leak on runtime shutdown cost
  us less.
- Remove a data race from the "was the runtime deleted" logic.

Bug: 140590186
Bug: 121302864
Test: Build and boot AOSP.
Test: art/test/testrunner/testrunner.py --host -b -t 1932-monitor-events-misc
Test: art/test/testrunner/testrunner.py --host -b -t 132-daemon-locks-shutdown
Test: art/test/testrunner/testrunner.py --host -b -t 004-ThreadStress

Change-Id: I6667c61beed2ba68c84cd4c0821fb8e21e188bbc
17 files changed