summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMingyao Yang <mingyao@google.com>2015-07-28 21:26:10 +0000
committerAndroid Git Automerger <android-git-automerger@android.com>2015-07-28 21:26:10 +0000
commit12e2907f73834244d4f0403767b527ed13df4fdc (patch)
tree5444f5832d76d91b8fef997ce6ff665b917aaf51
parent94f2ce5ff743580829bdcabbba795918ea760769 (diff)
parent681652d8e8a33bc07c5c082a71aea13d0f15e0a0 (diff)
downloadandroid_art-12e2907f73834244d4f0403767b527ed13df4fdc.tar.gz
android_art-12e2907f73834244d4f0403767b527ed13df4fdc.tar.bz2
android_art-12e2907f73834244d4f0403767b527ed13df4fdc.zip
am 681652d8: HDeoptimize should hold values live in env.
* commit '681652d8e8a33bc07c5c082a71aea13d0f15e0a0': HDeoptimize should hold values live in env.
-rw-r--r--compiler/optimizing/ssa_liveness_analysis.cc2
-rw-r--r--compiler/optimizing/ssa_liveness_analysis.h8
-rw-r--r--test/449-checker-bce/expected.txt1
-rw-r--r--test/449-checker-bce/src/Main.java23
4 files changed, 32 insertions, 2 deletions
diff --git a/compiler/optimizing/ssa_liveness_analysis.cc b/compiler/optimizing/ssa_liveness_analysis.cc
index 250eb04a1c..ce376da70d 100644
--- a/compiler/optimizing/ssa_liveness_analysis.cc
+++ b/compiler/optimizing/ssa_liveness_analysis.cc
@@ -225,7 +225,7 @@ void SsaLivenessAnalysis::ComputeLiveRanges() {
// SsaLivenessAnalysis.
for (size_t i = 0, e = environment->Size(); i < e; ++i) {
HInstruction* instruction = environment->GetInstructionAt(i);
- bool should_be_live = ShouldBeLiveForEnvironment(instruction);
+ bool should_be_live = ShouldBeLiveForEnvironment(current, instruction);
if (should_be_live) {
DCHECK(instruction->HasSsaIndex());
live_in->SetBit(instruction->GetSsaIndex());
diff --git a/compiler/optimizing/ssa_liveness_analysis.h b/compiler/optimizing/ssa_liveness_analysis.h
index 82c5454bb0..c46fac27df 100644
--- a/compiler/optimizing/ssa_liveness_analysis.h
+++ b/compiler/optimizing/ssa_liveness_analysis.h
@@ -1190,8 +1190,14 @@ class SsaLivenessAnalysis : public ValueObject {
// Update the live_out set of the block and returns whether it has changed.
bool UpdateLiveOut(const HBasicBlock& block);
- static bool ShouldBeLiveForEnvironment(HInstruction* instruction) {
+ // Returns whether `instruction` in an HEnvironment held by `env_holder`
+ // should be kept live by the HEnvironment.
+ static bool ShouldBeLiveForEnvironment(HInstruction* env_holder,
+ HInstruction* instruction) {
if (instruction == nullptr) return false;
+ // A value that's not live in compiled code may still be needed in interpreter,
+ // due to code motion, etc.
+ if (env_holder->IsDeoptimize()) return true;
if (instruction->GetBlock()->GetGraph()->IsDebuggable()) return true;
return instruction->GetType() == Primitive::kPrimNot;
}
diff --git a/test/449-checker-bce/expected.txt b/test/449-checker-bce/expected.txt
index e69de29bb2..e114c50371 100644
--- a/test/449-checker-bce/expected.txt
+++ b/test/449-checker-bce/expected.txt
@@ -0,0 +1 @@
+java.lang.ArrayIndexOutOfBoundsException: length=5; index=82
diff --git a/test/449-checker-bce/src/Main.java b/test/449-checker-bce/src/Main.java
index 7a45ce357d..c7246e0aa4 100644
--- a/test/449-checker-bce/src/Main.java
+++ b/test/449-checker-bce/src/Main.java
@@ -1101,6 +1101,28 @@ public class Main {
}
+ public void testExceptionMessage() {
+ short[] B1 = new short[5];
+ int[] B2 = new int[5];
+ Exception err = null;
+ try {
+ testExceptionMessage1(B1, B2, null, -1, 6);
+ } catch (Exception e) {
+ err = e;
+ }
+ System.out.println(err);
+ }
+
+ void testExceptionMessage1(short[] a1, int[] a2, long a3[], int start, int finish) {
+ int j = finish + 77;
+ // Bug: 22665511
+ // A deoptimization will be triggered here right before the loop. Need to make
+ // sure the value of j is preserved for the interpreter.
+ for (int i = start; i <= finish; i++) {
+ a2[j - 1] = a1[i + 1];
+ }
+ }
+
// Make sure this method is compiled with optimizing.
// CHECK-START: void Main.main(java.lang.String[]) register (after)
// CHECK: ParallelMove
@@ -1141,6 +1163,7 @@ public class Main {
};
testUnknownBounds();
+ new Main().testExceptionMessage();
}
}