diff options
| author | Vladimir Marko <vmarko@google.com> | 2015-09-25 17:10:15 +0100 |
|---|---|---|
| committer | Vladimir Marko <vmarko@google.com> | 2015-09-25 17:13:13 +0100 |
| commit | 430c4f561ec41a59813a17f7e3b4da10996a4774 (patch) | |
| tree | 978b9a6bc7c3ce8028347fabe478df6bd98d183f /compiler/optimizing/dead_code_elimination.cc | |
| parent | ec7e44f7afe0ff48d4d1ae54a12d375e0392d24c (diff) | |
| download | art-430c4f561ec41a59813a17f7e3b4da10996a4774.tar.gz art-430c4f561ec41a59813a17f7e3b4da10996a4774.tar.bz2 art-430c4f561ec41a59813a17f7e3b4da10996a4774.zip | |
Optimizing: Add comment on DCE's packed-switch value check.
Change-Id: I0c264d00b889917f88347c16c53e7647d0d8fd0f
Diffstat (limited to 'compiler/optimizing/dead_code_elimination.cc')
| -rw-r--r-- | compiler/optimizing/dead_code_elimination.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/compiler/optimizing/dead_code_elimination.cc b/compiler/optimizing/dead_code_elimination.cc index b322759a6c..007d0e3332 100644 --- a/compiler/optimizing/dead_code_elimination.cc +++ b/compiler/optimizing/dead_code_elimination.cc @@ -56,7 +56,11 @@ static void MarkReachableBlocks(HGraph* graph, ArenaBitVector* visited) { if (switch_input->IsIntConstant()) { int32_t switch_value = switch_input->AsIntConstant()->GetValue(); int32_t start_value = switch_instruction->GetStartValue(); - uint32_t switch_index = static_cast<uint32_t>(switch_value - start_value); + // Note: Though the spec forbids packed-switch values to wrap around, we leave + // that task to the verifier and use unsigned arithmetic with it's "modulo 2^32" + // semantics to check if the value is in range, wrapped or not. + uint32_t switch_index = + static_cast<uint32_t>(switch_value) - static_cast<uint32_t>(start_value); if (switch_index < switch_instruction->GetNumEntries()) { live_successors = live_successors.SubArray(switch_index, 1u); DCHECK_EQ(live_successors[0], block->GetSuccessor(switch_index)); |
