diff options
author | David Brazdil <dbrazdil@google.com> | 2015-06-17 18:20:52 +0100 |
---|---|---|
committer | David Brazdil <dbrazdil@google.com> | 2015-06-18 17:08:13 +0100 |
commit | df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62 (patch) | |
tree | b83e5d90f517e3d70cff4c35a38c4c84608084f5 /runtime/interpreter | |
parent | a8b41003a717ecf399b890c18e9b0df49f55472f (diff) | |
download | art-df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62.zip art-df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62.tar.gz art-df75bca6bd100ca9c2c395b1b8d2f8a871ab2c62.tar.bz2 |
ART: Allow PackedSwitch instructions with zero targets
Optimizing and the interpreter wrongly assumed that a PackedSwitch
always has at least one target. This patch removes the corresponding
DCHECKs and adds a regression test case.
This is a resubmission of CL I32b7033ed38de6f1d1a6ee5d5bf12f3a47c9b37e
Bug: 21863783
Change-Id: I04e6e124bdd16591ba27c79490e6ce183c36b691
(cherry picked from commit 2ef645ba50544b879a82ea30e606f18c9af98917)
Diffstat (limited to 'runtime/interpreter')
-rw-r--r-- | runtime/interpreter/interpreter_common.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/runtime/interpreter/interpreter_common.h b/runtime/interpreter/interpreter_common.h index 6fafcd1..0124d90 100644 --- a/runtime/interpreter/interpreter_common.h +++ b/runtime/interpreter/interpreter_common.h @@ -295,7 +295,10 @@ static inline int32_t DoPackedSwitch(const Instruction* inst, const ShadowFrame& int32_t test_val = shadow_frame.GetVReg(inst->VRegA_31t(inst_data)); DCHECK_EQ(switch_data[0], static_cast<uint16_t>(Instruction::kPackedSwitchSignature)); uint16_t size = switch_data[1]; - DCHECK_GT(size, 0); + if (size == 0) { + // Empty packed switch, move forward by 3 (size of PACKED_SWITCH). + return 3; + } const int32_t* keys = reinterpret_cast<const int32_t*>(&switch_data[2]); DCHECK(IsAligned<4>(keys)); int32_t first_key = keys[0]; |