ART: Add SparseSwitch support to the optimizing compiler
Add simple sparse-switch support through chained IFs. Refactor a
bit to better reuse code between switch types.
Now enables compiled versions of 015-switch and 095-switch-MAX_INT.
Bug: 18410979
Change-Id: Ib617e4b877f0b7fbc3bb289800f612f013480713
diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h
index e4e3705..73c2f50 100644
--- a/compiler/optimizing/builder.h
+++ b/compiler/optimizing/builder.h
@@ -29,6 +29,7 @@
namespace art {
class Instruction;
+class SwitchTable;
class HGraphBuilder : public ValueObject {
public:
@@ -203,10 +204,17 @@
uint16_t type_index,
uint32_t dex_pc);
- // Builds an instruction sequence for a packed switch statement. This will punt to the interpreter
- // for a switch with a full 64k set of cases.
+ // Builds an instruction sequence for a packed switch statement.
bool BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc);
+ // Builds an instruction sequence for a sparse switch statement.
+ bool BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc);
+
+ void BuildSwitchCaseHelper(const Instruction& instruction, size_t index,
+ bool is_last_case, const SwitchTable& table,
+ HInstruction* value, int32_t case_value_int,
+ int32_t target_offset, uint32_t dex_pc);
+
ArenaAllocator* const arena_;
// A list of the size of the dex code holding block information for