diff options
author | 2018-04-19 05:32:07 +0000 | |
---|---|---|
committer | 2018-04-19 05:32:07 +0000 | |
commit | cee49280366af9aa35e889e90d0ae0e90b453a22 (patch) | |
tree | 6b0b08d809291da44d9fdd368e4d6c5d9e4ce25e | |
parent | b8b38900bef869495afe63458f04c85ef9d5aae7 (diff) | |
parent | 080820c8e7a25bc3fb28d7c5a1524b0e5537c7a9 (diff) |
Merge "Revert "Deopt does not throw""
-rw-r--r-- | compiler/optimizing/nodes.cc | 9 | ||||
-rw-r--r-- | compiler/optimizing/nodes.h | 7 | ||||
-rw-r--r-- | test/683-deopt-regression/expected.txt | 3 | ||||
-rw-r--r-- | test/683-deopt-regression/info.txt | 1 | ||||
-rw-r--r-- | test/683-deopt-regression/smali/Deopt.smali | 60 | ||||
-rw-r--r-- | test/683-deopt-regression/src/Main.java | 45 |
6 files changed, 12 insertions, 113 deletions
diff --git a/compiler/optimizing/nodes.cc b/compiler/optimizing/nodes.cc index 79bb70b9aa..f784f8f7f3 100644 --- a/compiler/optimizing/nodes.cc +++ b/compiler/optimizing/nodes.cc @@ -1916,6 +1916,15 @@ const HTryBoundary* HBasicBlock::ComputeTryEntryOfSuccessors() const { } } +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 b315c81693..79d733060b 100644 --- a/compiler/optimizing/nodes.h +++ b/compiler/optimizing/nodes.h @@ -1272,6 +1272,8 @@ class HBasicBlock : public ArenaObject<kArenaAllocBasicBlock> { // 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 @@ class HInstruction : public ArenaObject<kArenaAllocInstruction> { !CanThrow() && !IsSuspendCheck() && !IsControlFlow() && - !IsDeoptimize() && !IsNativeDebugInfo() && !IsParameterValue() && // If we added an explicit barrier then we should keep it. @@ -3237,9 +3238,7 @@ class HDeoptimize FINAL : public HVariableInputSizeInstruction { 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>(); } diff --git a/test/683-deopt-regression/expected.txt b/test/683-deopt-regression/expected.txt deleted file mode 100644 index 54ce0514ff..0000000000 --- a/test/683-deopt-regression/expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -120 -0 -passed diff --git a/test/683-deopt-regression/info.txt b/test/683-deopt-regression/info.txt deleted file mode 100644 index 0c2cb81af7..0000000000 --- a/test/683-deopt-regression/info.txt +++ /dev/null @@ -1 +0,0 @@ -Regression test on deopt from BCE diff --git a/test/683-deopt-regression/smali/Deopt.smali b/test/683-deopt-regression/smali/Deopt.smali deleted file mode 100644 index 3bd9f6cf75..0000000000 --- a/test/683-deopt-regression/smali/Deopt.smali +++ /dev/null @@ -1,60 +0,0 @@ -# Copyright (C) 2018 The Android Open Source Project -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -.class public LDeopt; - -.super Ljava/lang/Object; - -.method public constructor <init>()V -.registers 1 - invoke-direct {v0}, Ljava/lang/Object;-><init>()V - return-void -.end method - -.method public static testCase([I)I - .registers 8 - - const v0, 0x0 # counter - const v1, 0xF # loop max - const v2, 0x0 # result - - :try_start - # Something throwing to start the try block. v6 contains a reference. - move-object v6, p0 - aget v3, p0, v0 - - # Invalidate v6 before entering the loop. - const-wide v5, 0x0 - - :loop_start - # Set v6 to a different reference (creates a catch phi). - const v6, 0x0 - - aget v3, p0, v0 - add-int/2addr v2, v3 - add-int/lit8 v0, v0, 0x1 - if-lt v0, v1, :loop_start - - :try_end - .catchall {:try_start .. :try_end} :catch - - :exit - return v2 - - :catch - invoke-virtual {v6}, Ljava/lang/Object;->hashCode()I # use v6 as a reference - goto :exit - -.end method - diff --git a/test/683-deopt-regression/src/Main.java b/test/683-deopt-regression/src/Main.java deleted file mode 100644 index fdf749612f..0000000000 --- a/test/683-deopt-regression/src/Main.java +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (C) 2018 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -import java.lang.reflect.Method; - -public class Main { - public static void main(String[] args) throws Exception { - if (System.getProperty("java.vm.name").equals("Dalvik")) { - Class<?> c = Class.forName("Deopt"); - Method m = c.getMethod("testCase", int[].class); - int[] p = null; - try { - m.invoke(null, p); - System.out.println("should not reach"); - } catch (Exception e) { - // Tried to invoke hashCode on incoming null. - } - int[] q = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 }; - System.out.println((Integer) m.invoke(null, q)); - int[] r = { }; - System.out.println((Integer) m.invoke(null, r)); - int[] s = { 1 }; - try { - System.out.println((Integer) m.invoke(null, s)); - System.out.println("should not reach"); - } catch (Exception e) { - // Tried to invoke hashCode on generated null. - } - } - System.out.println("passed"); - } -} |