Re-enable NonMovingAlloc operations in ThreadStress, except with GSS.

When the Generational Semi-Space (GSS) collector is used,
explicitly assign frequencies to all ThreadStress operations
and set the frequency of NonMovingAlloc operations to 0.

Also properly handle ThreadStress' `-nonmovingalloc` option,
which was documented but not implemented.

Test: art/test/testrunner/testrunner.py -t 004-ThreadStress (with GSS)
Test: art/test/testrunner/testrunner.py -t 004-ThreadStress (without GSS)
Bug: 72738921
Change-Id: Ia033a77d997eafa2bfa7244697ba7ffe31926133
diff --git a/test/004-ThreadStress/run b/test/004-ThreadStress/run
index 8004036..067e0d0 100755
--- a/test/004-ThreadStress/run
+++ b/test/004-ThreadStress/run
@@ -15,7 +15,29 @@
 # limitations under the License.
 
 # Enable lock contention logging.
-${RUN} --runtime-option -Xlockprofthreshold:10 "${@}"
+if [[ "x$ART_DEFAULT_GC_TYPE" = xGSS ]]; then
+  # NonMovingAlloc operations fail an assertion with the Generational
+  # Semi-Space (GSS) collector (see b/72738921); disable them for now
+  # by explicitly assigning frequencies to operations when the GSS
+  # collector is used.
+  #
+  # Note: The trick to use command substitution to have comments within
+  # a multi-line command is from https://stackoverflow.com/a/12797512.
+  ${RUN} --runtime-option -Xlockprofthreshold:10 "${@}" Main \
+    -oom:0.005           `#   1/200` \
+    -sigquit:0.095       `#  19/200` \
+    -alloc:0.225         `#  45/200` \
+    -largealloc:0.05     `#  10/200` \
+    -nonmovingalloc:0.0  `#   0/200` \
+    -stacktrace:0.1      `#  20/200` \
+    -exit:0.225          `#  45/200` \
+    -sleep:0.125         `#  25/200` \
+    -timedwait:0.05      `#  10/200` \
+    -wait:0.075          `#  15/200` \
+    -queuedwait:0.05     `#  10/200`
+else
+  ${RUN} --runtime-option -Xlockprofthreshold:10 "${@}"
+fi
 return_status1=$?
 
 # Run locks-only mode with stack-dump lock profiling. Reduce the number of total operations from
diff --git a/test/004-ThreadStress/src-art/Main.java b/test/004-ThreadStress/src-art/Main.java
index a142934..3a89f4f 100644
--- a/test/004-ThreadStress/src-art/Main.java
+++ b/test/004-ThreadStress/src-art/Main.java
@@ -315,11 +315,9 @@
         Map<Operation, Double> frequencyMap = new HashMap<Operation, Double>();
         frequencyMap.put(new OOM(), 0.005);                   //   1/200
         frequencyMap.put(new SigQuit(), 0.095);               //  19/200
-        frequencyMap.put(new Alloc(), 0.225);                 //  45/200
+        frequencyMap.put(new Alloc(), 0.2);                   //  40/200
         frequencyMap.put(new LargeAlloc(), 0.05);             //  10/200
-        // TODO: NonMovingAlloc operations fail an assertion with the
-        // GSS collector (see b/72738921); disable them for now.
-        frequencyMap.put(new NonMovingAlloc(), 0.0);          //   0/200
+        frequencyMap.put(new NonMovingAlloc(), 0.025);        //   5/200
         frequencyMap.put(new StackTrace(), 0.1);              //  20/200
         frequencyMap.put(new Exit(), 0.225);                  //  45/200
         frequencyMap.put(new Sleep(), 0.125);                 //  25/200
@@ -379,6 +377,8 @@
             op = new Alloc();
         } else if (split[0].equals("-largealloc")) {
             op = new LargeAlloc();
+        } else if (split[0].equals("-nonmovingalloc")) {
+            op = new NonMovingAlloc();
         } else if (split[0].equals("-stacktrace")) {
             op = new StackTrace();
         } else if (split[0].equals("-exit")) {