Check point root marking.

Added thread list checkpoint function, this goes through every thread and runs
the checkpoint on each thread. Threads that are runnable run the checkpoint
callback themselves in the next suspend check, while suspended threads are
left suspended but have the callback called on them.

Added a checkpoint visitor member to each thread, this visitor called when the
checkpoint request flag is set during transitions to suspended from runnable.

Using the checkpoint to mark the roots reduces the first pause of partial /
full gc to around 1 ms.

Change-Id: I97239cc72ee0e4a3397e9138a62ee559268dce0a
diff --git a/src/signal_catcher.cc b/src/signal_catcher.cc
index 80c37d4..b54c819 100644
--- a/src/signal_catcher.cc
+++ b/src/signal_catcher.cc
@@ -145,8 +145,11 @@
     }
   }
   os << "----- end " << getpid() << " -----\n";
-
   CHECK_EQ(self->SetStateUnsafe(old_state), kRunnable);
+  if (self->ReadFlag(kCheckpointRequest)) {
+    self->RunCheckpointFunction();
+    self->AtomicClearFlag(kCheckpointRequest);
+  }
   self->EndAssertNoThreadSuspension(old_cause);
   thread_list->ResumeAll();
 
@@ -186,7 +189,7 @@
   CHECK(runtime->AttachCurrentThread("Signal Catcher", true, runtime->GetSystemThreadGroup()));
 
   Thread* self = Thread::Current();
-
+  DCHECK_NE(self->GetState(), kRunnable);
   {
     MutexLock mu(self, signal_catcher->lock_);
     signal_catcher->thread_ = self;