From fe57faa2e0349418dda38e77ef1c0ac29db75f4d Mon Sep 17 00:00:00 2001 From: Mark Mendell Date: Fri, 18 Sep 2015 09:26:15 -0400 Subject: [optimizing] Add basic PackedSwitch support Add HPackedSwitch, and generate it from the builder. Code generators convert this to a series of compare/branch tests. Better implementation in the code generators as a real jump table will follow as separate CLs. Change-Id: If14736fa4d62809b6ae95280148c55682e856911 Signed-off-by: Mark Mendell --- compiler/optimizing/builder.h | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'compiler/optimizing/builder.h') diff --git a/compiler/optimizing/builder.h b/compiler/optimizing/builder.h index ae452f2589..7f87df6df2 100644 --- a/compiler/optimizing/builder.h +++ b/compiler/optimizing/builder.h @@ -90,6 +90,9 @@ class HGraphBuilder : public ValueObject { static constexpr const char* kBuilderPassName = "builder"; + // The number of entries in a packed switch before we use a jump table. + static constexpr uint16_t kSmallSwitchThreshold = 5; + private: // Analyzes the dex instruction and adds HInstruction to the graph // to execute that instruction. Returns whether the instruction can @@ -239,6 +242,12 @@ class HGraphBuilder : public ValueObject { // Builds an instruction sequence for a packed switch statement. void BuildPackedSwitch(const Instruction& instruction, uint32_t dex_pc); + // Build a switch instruction from a packed switch statement. + void BuildSwitchJumpTable(const SwitchTable& table, + const Instruction& instruction, + HInstruction* value, + uint32_t dex_pc); + // Builds an instruction sequence for a sparse switch statement. void BuildSparseSwitch(const Instruction& instruction, uint32_t dex_pc); -- cgit v1.2.3-59-g8ed1b