Add an option to disable explicit GC requests.

Change-Id: Ibb2ca9d99fccfba61492a8059201777f59c81274
diff --git a/vm/Globals.h b/vm/Globals.h
index aa3be76..41ad68c 100644
--- a/vm/Globals.h
+++ b/vm/Globals.h
@@ -132,6 +132,7 @@
     bool        generateRegisterMaps;
     bool        concurrentMarkSweep;
     bool        verifyCardTable;
+    bool        disableExplicitGc;
 
     int         assertionCtrlCount;
     AssertionControl*   assertionCtrl;
diff --git a/vm/Init.c b/vm/Init.c
index ae609c6..7002b5f 100644
--- a/vm/Init.c
+++ b/vm/Init.c
@@ -810,6 +810,8 @@
                 return -1;
             }
 
+        } else if (strncmp(argv[i], "-XX:+DisableExplicitGC", 22) == 0) {
+            gDvm.disableExplicitGc = true;
         } else if (strcmp(argv[i], "-verbose") == 0 ||
             strcmp(argv[i], "-verbose:class") == 0)
         {
diff --git a/vm/alloc/Alloc.c b/vm/alloc/Alloc.c
index a479426..3f95442 100644
--- a/vm/alloc/Alloc.c
+++ b/vm/alloc/Alloc.c
@@ -297,6 +297,9 @@
  */
 void dvmCollectGarbage(bool collectSoftReferences)
 {
+    if (gDvm.disableExplicitGc) {
+        return;
+    }
     dvmLockHeap();
     dvmWaitForConcurrentGcToComplete();
     dvmCollectGarbageInternal(collectSoftReferences, GC_EXPLICIT);