Merge "Make gc-thrash able to handle OOME"
diff --git a/compiler/dex/mir_optimization.cc b/compiler/dex/mir_optimization.cc
index 322b737..84c056d 100644
--- a/compiler/dex/mir_optimization.cc
+++ b/compiler/dex/mir_optimization.cc
@@ -929,7 +929,9 @@
         mir->optimization_flags |= MIR_IGNORE_NULL_CHECK;
       } else {
         // Do the null check.
-        // Do not clear MIR_IGNORE_NULL_CHECK flag as it may be set by another optimization
+        // TODO: Rewrite the pass to converge first before doing any modifications so that
+        // we don't lose the MIR_IGNORE_NULL_CHECK here if previously set by some other pass.
+        mir->optimization_flags &= ~MIR_IGNORE_NULL_CHECK;
         // Mark s_reg as null-checked
         ssa_regs_to_check->ClearBit(src_sreg);
       }
diff --git a/runtime/asm_support.h b/runtime/asm_support.h
index 62f3593..40f79f7 100644
--- a/runtime/asm_support.h
+++ b/runtime/asm_support.h
@@ -21,7 +21,7 @@
 
 // Value loaded into rSUSPEND for quick. When this value is counted down to zero we do a suspend
 // check.
-#define SUSPEND_CHECK_INTERVAL (1000)
+#define SUSPEND_CHECK_INTERVAL (16)
 
 // Offsets within java.lang.Object.
 #define CLASS_OFFSET 0
diff --git a/test/083-compiler-regressions/expected.txt b/test/083-compiler-regressions/expected.txt
index e907fd1..c43d1f7 100644
--- a/test/083-compiler-regressions/expected.txt
+++ b/test/083-compiler-regressions/expected.txt
@@ -16,6 +16,7 @@
 b13679511Test finishing
 b16177324TestWrapper caught NPE as expected.
 b16230771TestWrapper caught NPE as expected.
+b17969907TestWrapper caught NPE as expected.
 largeFrame passes
 largeFrameFloat passes
 mulBy1Test passes
diff --git a/test/083-compiler-regressions/src/Main.java b/test/083-compiler-regressions/src/Main.java
index 8d7bf01..9c772b9 100644
--- a/test/083-compiler-regressions/src/Main.java
+++ b/test/083-compiler-regressions/src/Main.java
@@ -38,6 +38,7 @@
         b13679511Test();
         b16177324TestWrapper();
         b16230771TestWrapper();
+        b17969907TestWrapper();
         largeFrameTest();
         largeFrameTestFloat();
         mulBy1Test();
@@ -977,6 +978,24 @@
       }
     }
 
+    static void b17969907TestWrapper() {
+      try {
+        b17969907Test();
+        System.out.println("b17969907Test unexpectedly didn't throw NPE.");
+      } catch (NullPointerException expected) {
+        System.out.println("b17969907TestWrapper caught NPE as expected.");
+      }
+    }
+
+    public static void b17969907Test() {
+      Integer i = new Integer(1);
+      int sum = 0;
+      while (sum < 100) {
+        sum += i;
+        i = null;
+      }
+    }
+
     static double TooManyArgs(
           long l00,
           long l01,