diff options
author | 2024-10-15 20:15:17 +0800 | |
---|---|---|
committer | 2024-10-17 13:36:01 +0000 | |
commit | f0c45c0576f53b81c80a7d868d54fad41a7bae8b (patch) | |
tree | bb4ccc8eaff7379d392e943831cdbacdd74a0967 /compiler/optimizing/inliner.cc | |
parent | a5f50ab9af9f5456bbd4b49def3393e3986b21e1 (diff) |
fix inliner bug
I see field index of a class member variable is 0xFFFF which will cause TryPatternSubstitution throw away the iput-xxx instruction
```code
void zyb.<init>(com.mi.fitness.netproxy.NetProxyManager) (dex_method_idx=20258)
DEX CODE:
0x0000: 7010 273f 0000 | invoke-direct {v0}, void java.lang.Object.<init>() // method@16167
0x0003: 5b01 ffff | iput-object v1, v0, Lcom/mi/fitness/netproxy/NetProxyManager; zyb.a // field@65535
0x0005: 0e00 | return-void
```
Bug: 368471540
Test: the above bug doesn't reproduce
Change-Id: I6bee31e07e17982e00e0e22d476a36f554081c3d
Signed-off-by: wangmingming1 <wangmingming1@xiaomi.com>
Diffstat (limited to 'compiler/optimizing/inliner.cc')
-rw-r--r-- | compiler/optimizing/inliner.cc | 17 |
1 files changed, 7 insertions, 10 deletions
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc index 396aa95692..c90308d39c 100644 --- a/compiler/optimizing/inliner.cc +++ b/compiler/optimizing/inliner.cc @@ -1768,17 +1768,14 @@ bool HInliner::TryPatternSubstitution(HInvoke* invoke_instruction, uint16_t iput_args[] = { data.iput0_arg, data.iput1_arg, data.iput2_arg }; static_assert(arraysize(iput_args) == arraysize(iput_field_indexes), "Size mismatch"); // Count valid field indexes. - size_t number_of_iputs = 0u; - while (number_of_iputs != arraysize(iput_field_indexes) && - iput_field_indexes[number_of_iputs] != DexFile::kDexNoIndex16) { + for (size_t i = 0, end = data.iput_count; i < end; i++) { // Check that there are no duplicate valid field indexes. - DCHECK_EQ(0, std::count(iput_field_indexes + number_of_iputs + 1, - iput_field_indexes + arraysize(iput_field_indexes), - iput_field_indexes[number_of_iputs])); - ++number_of_iputs; + DCHECK_EQ(0, std::count(iput_field_indexes + i + 1, + iput_field_indexes + end, + iput_field_indexes[i])); } // Check that there are no valid field indexes in the rest of the array. - DCHECK_EQ(0, std::count_if(iput_field_indexes + number_of_iputs, + DCHECK_EQ(0, std::count_if(iput_field_indexes + data.iput_count, iput_field_indexes + arraysize(iput_field_indexes), [](uint16_t index) { return index != DexFile::kDexNoIndex16; })); @@ -1786,7 +1783,7 @@ bool HInliner::TryPatternSubstitution(HInvoke* invoke_instruction, HInstruction* obj = GetInvokeInputForArgVRegIndex(invoke_instruction, /* arg_vreg_index= */ 0u); bool needs_constructor_barrier = false; - for (size_t i = 0; i != number_of_iputs; ++i) { + for (size_t i = 0, end = data.iput_count; i != end; ++i) { HInstruction* value = GetInvokeInputForArgVRegIndex(invoke_instruction, iput_args[i]); if (!IsZeroBitPattern(value)) { uint16_t field_index = iput_field_indexes[i]; @@ -1811,7 +1808,7 @@ bool HInliner::TryPatternSubstitution(HInvoke* invoke_instruction, invoke_instruction); } *return_replacement = nullptr; - number_of_instructions = number_of_iputs + (needs_constructor_barrier ? 1u : 0u); + number_of_instructions = data.iput_count + (needs_constructor_barrier ? 1u : 0u); break; } } |