Fix search for implicit null check.
There are additional instructions that can be emitted at use
site for x86/x86-64, such as ArrayLength, and the implicit
null check may therefore be emitted later than at the next
instruction. Search for the implicit null check until we
reach an instruction that's not emitted at use site.
This also reverts the blacklisting of the test, i.e.
commit 5be5260cfec2fc0a8c21ef1a08e7144523a8bfcd.
Test: testrunner.py --host \
--jit-on-first-use --debuggable -t 122-npe
Test: testrunner.py --host \
--optimizing --jit --jit-on-first-use \
--debuggable --ndebuggable
Bug: 136021898
Change-Id: I768f55d8c8975dbd0376802c10ca8508df3fe3b0
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index 8ac33a4..3736413 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -2140,12 +2140,13 @@
// If this instruction will do an implicit null check, return the `HNullCheck` associated
// with it. Otherwise return null.
HNullCheck* GetImplicitNullCheck() const {
- // Find the first previous instruction which is not a move.
- HInstruction* first_prev_not_move = GetPreviousDisregardingMoves();
- if (first_prev_not_move != nullptr &&
- first_prev_not_move->IsNullCheck() &&
- first_prev_not_move->IsEmittedAtUseSite()) {
- return first_prev_not_move->AsNullCheck();
+ // Go over previous non-move instructions that are emitted at use site.
+ HInstruction* prev_not_move = GetPreviousDisregardingMoves();
+ while (prev_not_move != nullptr && prev_not_move->IsEmittedAtUseSite()) {
+ if (prev_not_move->IsNullCheck()) {
+ return prev_not_move->AsNullCheck();
+ }
+ prev_not_move = prev_not_move->GetPreviousDisregardingMoves();
}
return nullptr;
}