summaryrefslogtreecommitdiffstats
path: root/compiler
diff options
context:
space:
mode:
authorDavid Brazdil <dbrazdil@google.com>2015-06-18 16:13:16 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2015-06-18 16:13:17 +0000
commitee9bc65d3069c7c5c3f66dd9459915df54c3482f (patch)
treeeb452dea385626d6a065eafb11a2eb085bf4d579 /compiler
parent6ecc2967918e7d7bed299d4dbf48ac63effc1088 (diff)
parentdf75bca6bd100ca9c2c395b1b8d2f8a871ab2c62 (diff)
downloadart-ee9bc65d3069c7c5c3f66dd9459915df54c3482f.zip
art-ee9bc65d3069c7c5c3f66dd9459915df54c3482f.tar.gz
art-ee9bc65d3069c7c5c3f66dd9459915df54c3482f.tar.bz2
Merge "ART: Allow PackedSwitch instructions with zero targets" into mnc-dev
Diffstat (limited to 'compiler')
-rw-r--r--compiler/optimizing/builder.cc14
1 files changed, 12 insertions, 2 deletions
diff --git a/compiler/optimizing/builder.cc b/compiler/optimizing/builder.cc
index 58416ee..9468f36 100644
--- a/compiler/optimizing/builder.cc
+++ b/compiler/optimizing/builder.cc
@@ -1175,14 +1175,20 @@ bool HGraphBuilder::NeedsAccessCheck(uint32_t type_index) const {
}
void HGraphBuilder::BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc) {
+ // Verifier guarantees that the payload for PackedSwitch contains:
+ // (a) number of entries (may be zero)
+ // (b) first and lowest switch case value (entry 0, always present)
+ // (c) list of target pcs (entries 1 <= i <= N)
SwitchTable table(instruction, dex_pc, false);
// Value to test against.
HInstruction* value = LoadLocal(instruction.VRegA(), Primitive::kPrimInt);
+ // Retrieve number of entries.
uint16_t num_entries = table.GetNumEntries();
- // There should be at least one entry here.
- DCHECK_GT(num_entries, 0U);
+ if (num_entries == 0) {
+ return;
+ }
// Chained cmp-and-branch, starting from starting_key.
int32_t starting_key = table.GetEntryAt(0);
@@ -1194,6 +1200,10 @@ void HGraphBuilder::BuildPackedSwitch(const Instruction& instruction, uint32_t d
}
void HGraphBuilder::BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc) {
+ // Verifier guarantees that the payload for SparseSwitch contains:
+ // (a) number of entries (may be zero)
+ // (b) sorted key values (entries 0 <= i < N)
+ // (c) target pcs corresponding to the switch values (entries N <= i < 2*N)
SwitchTable table(instruction, dex_pc, true);
// Value to test against.