Merge "Extend the liveness of the receiver to the entire method."
diff --git a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
index 75bf9c0..b4995c9 100644
--- a/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
+++ b/src/main/java/com/android/tools/r8/ir/regalloc/LinearScanRegisterAllocator.java
@@ -2465,7 +2465,8 @@
// This assumption is used during verification. Allowing the receiver register to be
// overwritten can therefore lead to verification errors. If we could be targeting one of these
// VMs we block the receiver register throughout the method.
- if (options.canHaveThisTypeVerifierBug() && !code.method.accessFlags.isStatic()) {
+ if ((options.canHaveThisTypeVerifierBug() || options.canHaveThisJitCodeDebuggingBug())
+ && !code.method.accessFlags.isStatic()) {
for (Instruction instruction : code.blocks.get(0).getInstructions()) {
if (instruction.isArgument() && instruction.outValue().isThis()) {
Value thisValue = instruction.outValue();
diff --git a/src/main/java/com/android/tools/r8/utils/InternalOptions.java b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
index c7d6561..e0e4227 100644
--- a/src/main/java/com/android/tools/r8/utils/InternalOptions.java
+++ b/src/main/java/com/android/tools/r8/utils/InternalOptions.java
@@ -577,6 +577,17 @@
return minApiLevel < AndroidApiLevel.M.getLevel();
}
+ // Art crashes if we do dead reference elimination of the receiver in release mode and Art
+ // is asked for the |this| object over a JDWP connection at a point where the receiver
+ // register has been clobbered.
+ //
+ // See b/116683601 and b/116837585.
+ public boolean canHaveThisJitCodeDebuggingBug() {
+ // TODO(b/116841249): Make this an actual min-sdk guard once we know that Art no longer crashes
+ // on these accesses.
+ return true;
+ }
+
// The dalvik jit had a bug where the long operations add, sub, or, xor and and would write
// the first part of the result long before reading the second part of the input longs.
public boolean canHaveOverlappingLongRegisterBug() {