OSDN Git Service

ART: cleanup exit_block_ in graph if exit block is removed
authorSerguei Katkov <serguei.i.katkov@intel.com>
Wed, 2 Mar 2016 10:25:36 +0000 (16:25 +0600)
committerSerguei Katkov <serguei.i.katkov@intel.com>
Thu, 3 Mar 2016 10:54:31 +0000 (16:54 +0600)
If we remove the exit block from the graph (for example method
contains infinite loop) we should also clean the field exit_block_
in graph. At least inliner expects it.

Change-Id: Icda668da2233cdd6cd673635a1949f5ed34cf270
Signed-off-by: Serguei Katkov <serguei.i.katkov@intel.com>
compiler/optimizing/nodes.cc
test/579-inline-infinite/expected.txt [new file with mode: 0644]
test/579-inline-infinite/info.txt [new file with mode: 0644]
test/579-inline-infinite/src/Main.java [new file with mode: 0644]

index 0e0b83e..77ded29 100644 (file)
@@ -127,6 +127,9 @@ void HGraph::RemoveDeadBlocks(const ArenaBitVector& visited) {
       // Remove the block from the list of blocks, so that further analyses
       // never see it.
       blocks_[i] = nullptr;
+      if (block->IsExitBlock()) {
+        SetExitBlock(nullptr);
+      }
     }
   }
 }
@@ -1870,7 +1873,7 @@ void HGraph::DeleteDeadEmptyBlock(HBasicBlock* block) {
   DCHECK(block->GetPhis().IsEmpty());
 
   if (block->IsExitBlock()) {
-    exit_block_ = nullptr;
+    SetExitBlock(nullptr);
   }
 
   RemoveElement(reverse_post_order_, block);
diff --git a/test/579-inline-infinite/expected.txt b/test/579-inline-infinite/expected.txt
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/test/579-inline-infinite/info.txt b/test/579-inline-infinite/info.txt
new file mode 100644 (file)
index 0000000..6fb917c
--- /dev/null
@@ -0,0 +1,2 @@
+Regression test for optimizing.
+Inlining of method with infinite loop cause a crash.
diff --git a/test/579-inline-infinite/src/Main.java b/test/579-inline-infinite/src/Main.java
new file mode 100644 (file)
index 0000000..f214ed4
--- /dev/null
@@ -0,0 +1,38 @@
+/*
+ * Copyright (C) 2016 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 Infinite implements Runnable {
+  public int field;
+
+  private final void $noinline$infinite() {
+    while(true) {
+      field++;
+    }
+  }
+
+  public void run() {
+    $noinline$infinite();
+  }
+}
+
+public class Main {
+  public static void main(String[] args) {
+    Thread thr = new Thread(new Infinite());
+    thr.setDaemon(true);
+    thr.start();
+    // This is a compiler test, so just finish.
+  }
+}