Implicit NPE support when no exception given to throw.

This change adds support for creating an implicit NPE when throw is used
without giving an exception object. It extends the CatchTest to check
the functionality is correct. It also weakens a too strong assertion
about when an address lies within code.

Change-Id: I33742cce4deb31b4e0e9b7bd386f78e8cba3e53a
diff --git a/src/object.cc b/src/object.cc
index 6490797..63c9237 100644
--- a/src/object.cc
+++ b/src/object.cc
@@ -579,8 +579,14 @@
     // assume that this is some initial value that will always lie in code
     return true;
   } else {
+#if defined(__arm__)
+    pc &= ~0x1;  // clear any possible thumb instruction mode bit
+#endif
     uint32_t rel_offset = pc - reinterpret_cast<uintptr_t>(GetCodeArray()->GetData());
-    return rel_offset < static_cast<uint32_t>(GetCodeArray()->GetLength());
+    // Strictly the following test should be a less-than, however, if the last
+    // instruction is a call to an exception throw we may see return addresses
+    // that are 1 beyond the end of code.
+    return rel_offset <= static_cast<uint32_t>(GetCodeArray()->GetLength());
   }
 }