Use a flag from the verifier to know if we should compile.

Only used for the lack of bottom type in the aget-object case
for now. Could be used for more.

bug:21865466

Change-Id: I64c2c84dfa1c0d259631e65e5f44b94e4139e6a7
diff --git a/compiler/dex/quick/quick_compiler.cc b/compiler/dex/quick/quick_compiler.cc
index 2523a83..28c485a 100644
--- a/compiler/dex/quick/quick_compiler.cc
+++ b/compiler/dex/quick/quick_compiler.cc
@@ -33,6 +33,7 @@
 #include "dex/pass_driver_me_post_opt.h"
 #include "dex/pass_manager.h"
 #include "dex/quick/mir_to_lir.h"
+#include "dex/verified_method.h"
 #include "driver/compiler_driver.h"
 #include "driver/compiler_options.h"
 #include "elf_writer_quick.h"
@@ -661,6 +662,10 @@
     return nullptr;
   }
 
+  if (driver->GetVerifiedMethod(&dex_file, method_idx)->HasRuntimeThrow()) {
+    return nullptr;
+  }
+
   DCHECK(driver->GetCompilerOptions().IsCompilationEnabled());
 
   Runtime* const runtime = Runtime::Current();
diff --git a/compiler/dex/verified_method.cc b/compiler/dex/verified_method.cc
index 8a009cb..273b1628 100644
--- a/compiler/dex/verified_method.cc
+++ b/compiler/dex/verified_method.cc
@@ -41,6 +41,7 @@
                                              bool compile) {
   std::unique_ptr<VerifiedMethod> verified_method(new VerifiedMethod);
   verified_method->has_verification_failures_ = method_verifier->HasFailures();
+  verified_method->has_runtime_throw_ = method_verifier->HasInstructionThatWillThrow();
   if (compile) {
     /* Generate a register map. */
     if (!verified_method->GenerateGcMap(method_verifier)) {
diff --git a/compiler/dex/verified_method.h b/compiler/dex/verified_method.h
index 07f9a9b..bf11839 100644
--- a/compiler/dex/verified_method.h
+++ b/compiler/dex/verified_method.h
@@ -75,6 +75,10 @@
     return has_verification_failures_;
   }
 
+  bool HasRuntimeThrow() const {
+    return has_runtime_throw_;
+  }
+
   void SetStringInitPcRegMap(SafeMap<uint32_t, std::set<uint32_t>>& string_init_pc_reg_map) {
     string_init_pc_reg_map_ = string_init_pc_reg_map;
   }
@@ -121,6 +125,7 @@
   SafeCastSet safe_cast_set_;
 
   bool has_verification_failures_ = false;
+  bool has_runtime_throw_ = false;
 
   // Copy of mapping generated by verifier of dex PCs of string init invocations
   // to the set of other registers that the receiver has been copied into.