Fix getter/setter special case codegen

The special-purpose code generators for simple methods that get
or set and instance field and then return require that no throws
are possible.  The previous code incorrectly relied on the first
argument being a "this" pointer, and thus previously null-checked.
This did not take into account the possibility of a static method
which happened to pass an object referece as it's first argument.

The fix is to avoid making any assumptions, but rather rely
solely on the results of the null-check elimination pass which
will correctly recoginize the "this" case.

Change-Id: Icf001a10a19234cf3f4d87cf1baede93fdf0360c
diff --git a/src/compiler/codegen/arm/Thumb2/Gen.cc b/src/compiler/codegen/arm/Thumb2/Gen.cc
index d5a4efc..4319ec8 100644
--- a/src/compiler/codegen/arm/Thumb2/Gen.cc
+++ b/src/compiler/codegen/arm/Thumb2/Gen.cc
@@ -149,18 +149,12 @@
     uint32_t fieldIdx = mir->dalvikInsn.vC;
     bool fastPath = fastInstance(cUnit, fieldIdx, fieldOffset, isVolatile,
                                  false);
-    if (!fastPath) {
+    if (!fastPath || !(mir->optimizationFlags & MIR_IGNORE_NULL_CHECK)) {
         return NULL;
     }
     RegLocation rlObj = oatGetSrc(cUnit, mir, 0);
     lockLiveArgs(cUnit, mir);
     rlObj = argLoc(cUnit, rlObj);
-    // Reject if object reference is not "this"
-    if ((rlObj.location == kLocInvalid) ||
-        (inPosition(cUnit, rlObj.sRegLow) != 0)) {
-        oatResetRegPool(cUnit);
-        return NULL;
-    }
     RegLocation rlDest;
     if (longOrDouble) {
         rlDest = oatGetReturnWide(cUnit, false);
@@ -168,7 +162,6 @@
         rlDest = oatGetReturn(cUnit, false);
     }
     // Point of no return - no aborts after this
-    mir->optimizationFlags |= MIR_IGNORE_NULL_CHECK;
     genPrintLabel(cUnit, mir);
     rlObj = loadArg(cUnit, rlObj);
     genIGet(cUnit, mir, size, rlDest, rlObj, longOrDouble, isObject);
@@ -183,7 +176,7 @@
     uint32_t fieldIdx = mir->dalvikInsn.vC;
     bool fastPath = fastInstance(cUnit, fieldIdx, fieldOffset, isVolatile,
                                  false);
-    if (!fastPath) {
+    if (!fastPath || !(mir->optimizationFlags & MIR_IGNORE_NULL_CHECK)) {
         return NULL;
     }
     RegLocation rlSrc;
@@ -198,15 +191,12 @@
     }
     rlSrc = argLoc(cUnit, rlSrc);
     rlObj = argLoc(cUnit, rlObj);
-    // Reject if object reference is not "this"
-    if ((rlObj.location == kLocInvalid) ||
-        (inPosition(cUnit, rlObj.sRegLow) != 0) ||
-        (rlSrc.location == kLocInvalid)) {
+    // Reject if source is split across registers & frame
+    if (rlObj.location == kLocInvalid) {
         oatResetRegPool(cUnit);
         return NULL;
     }
     // Point of no return - no aborts after this
-    mir->optimizationFlags |= MIR_IGNORE_NULL_CHECK;
     genPrintLabel(cUnit, mir);
     rlObj = loadArg(cUnit, rlObj);
     rlSrc = loadArg(cUnit, rlSrc);