diff options
| author | 2018-02-06 15:02:42 -0800 | |
|---|---|---|
| committer | 2018-02-07 10:33:41 -0800 | |
| commit | 7cf9af2ce0bb72c5bd2ff7c5bd82df5c05877355 (patch) | |
| tree | 7cd74d68e4a43e1e82bcf3ca49017db5a0a39fa6 /compiler | |
| parent | 8bcecf915545581bf23b5348cd94d3f5ec6eb669 (diff) | |
Do not eliminate array allocation if it may throw NegativeArraySizeException
Bug: 70023972
Test: run-test on host. 530-checker-lse.
Change-Id: I00e2d69f82b3dda21559ffcba827e0a52d900ff1
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/optimizing/load_store_elimination.cc | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/compiler/optimizing/load_store_elimination.cc b/compiler/optimizing/load_store_elimination.cc index 8b4eae1780..237ecd3c10 100644 --- a/compiler/optimizing/load_store_elimination.cc +++ b/compiler/optimizing/load_store_elimination.cc @@ -882,6 +882,7 @@ class LSEVisitor : public HGraphDelegateVisitor { } if (ref_info->IsSingletonAndRemovable() && !new_instance->NeedsChecks()) { DCHECK(!new_instance->IsFinalizable()); + // new_instance can potentially be eliminated. singleton_new_instances_.push_back(new_instance); } ScopedArenaVector<HInstruction*>& heap_values = @@ -904,7 +905,13 @@ class LSEVisitor : public HGraphDelegateVisitor { return; } if (ref_info->IsSingletonAndRemovable()) { - singleton_new_instances_.push_back(new_array); + if (new_array->GetLength()->IsIntConstant() && + new_array->GetLength()->AsIntConstant()->GetValue() >= 0) { + // new_array can potentially be eliminated. + singleton_new_instances_.push_back(new_array); + } else { + // new_array may throw NegativeArraySizeException. Keep it. + } } ScopedArenaVector<HInstruction*>& heap_values = heap_values_for_[new_array->GetBlock()->GetBlockId()]; |