Clean up compile time null checks for VarHandle intrinsics.

A few small changes:

- In the instruction simplifier, re-do the `object->IsNullConstant()`
  check as this might have changed after the inliner.

- Make `CanEnsureNotNullAt()` a static member: it is used locally and
  should have local visibility, which was accidentally changed.

Bug: 191765508
Test: art/test.py --host -r
Change-Id: Ib7d88ded4cd73543f66cae75117679a40021c84c
diff --git a/compiler/optimizing/instruction_simplifier.cc b/compiler/optimizing/instruction_simplifier.cc
index 1a7544d..ba2b3c0 100644
--- a/compiler/optimizing/instruction_simplifier.cc
+++ b/compiler/optimizing/instruction_simplifier.cc
@@ -124,6 +124,8 @@
   void SimplifyAllocationIntrinsic(HInvoke* invoke);
   void SimplifyVarHandleIntrinsic(HInvoke* invoke);
 
+  static bool CanEnsureNotNullAt(HInstruction* input, HInstruction* at);
+
   CodeGenerator* codegen_;
   OptimizingCompilerStats* stats_;
   bool simplification_occurred_ = false;
@@ -580,7 +582,7 @@
   }
 }
 
-bool CanEnsureNotNullAt(HInstruction* input, HInstruction* at) {
+bool InstructionSimplifierVisitor::CanEnsureNotNullAt(HInstruction* input, HInstruction* at) {
   if (!input->CanBeNull()) {
     return true;
   }
@@ -2774,8 +2776,13 @@
   size_t expected_coordinates_count = GetExpectedVarHandleCoordinatesCount(invoke);
   if (expected_coordinates_count == 1u) {
     HInstruction* object = invoke->InputAt(1);
-    // The following has been ensured by static checks in done in the instruction builder.
-    DCHECK(object->GetType() == DataType::Type::kReference && !object->IsNullConstant());
+    // The following has been ensured by static checks in the instruction builder.
+    DCHECK(object->GetType() == DataType::Type::kReference);
+    // Re-check for null constant, as this might have changed after the inliner.
+    if (object->IsNullConstant()) {
+      optimizations.SetDoNotIntrinsify();
+      return;
+    }
     // Test whether we can avoid the null check on the object.
     if (CanEnsureNotNullAt(object, invoke)) {
       optimizations.SetSkipObjectNullCheck();