Use thread-local is_gc_marking flags for the CC collector.

The currently global is_marking flag is used to check if the read
barrier slow path needs to be taken for GC roots access. Changing it
to a thread-local flag simplifies the fast path check and makes it
easier to do it in assembly code. It also solves the issue that we
need to avoid accessing the global flag during startup before the heap
or the collector object isn't allocated and initialized.

Bug: 12687968
Change-Id: Ibf0dca12f400bf3490188b12dfe96c7de30583e0
diff --git a/runtime/thread_list.cc b/runtime/thread_list.cc
index d449f42..d63781b 100644
--- a/runtime/thread_list.cc
+++ b/runtime/thread_list.cc
@@ -1175,7 +1175,10 @@
   CHECK(!Contains(self));
   list_.push_back(self);
   if (kUseReadBarrier) {
-    // Initialize this according to the state of the CC collector.
+    // Initialize according to the state of the CC collector.
+    bool is_gc_marking =
+        Runtime::Current()->GetHeap()->ConcurrentCopyingCollector()->IsMarking();
+    self->SetIsGcMarking(is_gc_marking);
     bool weak_ref_access_enabled =
         Runtime::Current()->GetHeap()->ConcurrentCopyingCollector()->IsWeakRefAccessEnabled();
     self->SetWeakRefAccessEnabled(weak_ref_access_enabled);