Add option for changing number of GC threads.

The number of threads was previously set to 1 by an accidential
checkin. This hurts on all devices which aren't dual core. We now
properly use sysconf to determine how many threads we should create.

Also added a -XX:HeapGCThreads heap option which lets us change
how many GC threads we create. The default value is equal to the
number of processors on the device minus one.

Change-Id: If65065ef09174a3813b8741efdd5ea7bbe82a4e2
diff --git a/runtime/runtime.cc b/runtime/runtime.cc
index ba18311..cf6e537 100644
--- a/runtime/runtime.cc
+++ b/runtime/runtime.cc
@@ -338,6 +338,8 @@
   parsed->heap_max_free_ = gc::Heap::kDefaultMaxFree;
   parsed->heap_target_utilization_ = gc::Heap::kDefaultTargetUtilization;
   parsed->heap_growth_limit_ = 0;  // 0 means no growth limit.
+  // Default to number of processors minus one since the main GC thread also does work.
+  parsed->heap_gc_threads_ = sysconf(_SC_NPROCESSORS_CONF) - 1;
   parsed->stack_size_ = 0; // 0 means default.
 
   parsed->is_compiler_ = false;
@@ -472,6 +474,9 @@
         return NULL;
       }
       parsed->heap_target_utilization_ = value;
+    } else if (StartsWith(option, "-XX:HeapGCThreads=")) {
+      parsed->heap_gc_threads_ =
+          ParseMemoryOption(option.substr(strlen("-XX:HeapGCThreads=")).c_str(), 1024);
     } else if (StartsWith(option, "-Xss")) {
       size_t size = ParseMemoryOption(option.substr(strlen("-Xss")).c_str(), 1);
       if (size == 0) {
@@ -829,7 +834,8 @@
                        options->heap_target_utilization_,
                        options->heap_maximum_size_,
                        options->image_,
-                       options->is_concurrent_gc_enabled_);
+                       options->is_concurrent_gc_enabled_,
+                       options->heap_gc_threads_);
 
   BlockSignals();
   InitPlatformSignalHandlers();