Revert "Revert^2: Deopt does not throw"

This reverts commit 240384b7d96c2d579bf58ed7a3e9c9ba1911dae3.

Reason for revert: P1 b/78360004 points to this so reverting for now (will triage later)

Change-Id: I041c1d9fc045391c73e887268c3b1b9b69fcc216
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc
index 79bb70b..f784f8f 100644
--- a/compiler/optimizing/nodes.cc
+++ b/compiler/optimizing/nodes.cc
@@ -1916,6 +1916,15 @@
   }
 }
 
+bool HBasicBlock::HasThrowingInstructions() const {
+  for (HInstructionIterator it(GetInstructions()); !it.Done(); it.Advance()) {
+    if (it.Current()->CanThrow()) {
+      return true;
+    }
+  }
+  return false;
+}
+
 static bool HasOnlyOneInstruction(const HBasicBlock& block) {
   return block.GetPhis().IsEmpty()
       && !block.GetInstructions().IsEmpty()
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index b315c81..79d7330 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -1272,6 +1272,8 @@
   // the appropriate try entry will be returned.
   const HTryBoundary* ComputeTryEntryOfSuccessors() const;
 
+  bool HasThrowingInstructions() const;
+
   // Returns whether this block dominates the blocked passed as parameter.
   bool Dominates(HBasicBlock* block) const;
 
@@ -2130,7 +2132,6 @@
         !CanThrow() &&
         !IsSuspendCheck() &&
         !IsControlFlow() &&
-        !IsDeoptimize() &&
         !IsNativeDebugInfo() &&
         !IsParameterValue() &&
         // If we added an explicit barrier then we should keep it.
@@ -3237,9 +3238,7 @@
 
   bool NeedsEnvironment() const OVERRIDE { return true; }
 
-  // Even though deoptimize is often used for "exceptional cases" to go back to
-  // the interpreter, it never throws an exception.
-  bool CanThrow() const OVERRIDE { return false; }
+  bool CanThrow() const OVERRIDE { return true; }
 
   DeoptimizationKind GetDeoptimizationKind() const { return GetPackedField<DeoptimizeKindField>(); }