switch_jmp is a conditional jump after all.

This commit is contained in:
Daan Vanden Bosch 2020-11-15 00:32:33 +01:00
parent cd70d22da2
commit 4e65cc1882
2 changed files with 4 additions and 5 deletions

View File

@ -11,13 +11,12 @@ enum class BranchType {
None, None,
/** /**
* ret * ret.
*/ */
Return, Return,
/** /**
* jmp or switch_jmp. switch_jmp is a non-conditional jump because it always jumps even though * jmp.
* the jump location is dynamic.
*/ */
Jump, Jump,
@ -200,7 +199,7 @@ private fun createBasicBlocks(cfg: ControlFlowGraphBuilder, segment: Instruction
branchLabels = listOf(inst.args[2].value as Int) branchLabels = listOf(inst.args[2].value as Int)
} }
OP_SWITCH_JMP.code -> { OP_SWITCH_JMP.code -> {
branchType = BranchType.Jump branchType = BranchType.ConditionalJump
branchLabels = inst.args.drop(1).map { it.value as Int } branchLabels = inst.args.drop(1).map { it.value as Int }
} }

View File

@ -411,7 +411,7 @@ private fun parseInstructionsSegment(
for (i in instructions.size - 1 downTo 0) { for (i in instructions.size - 1 downTo 0) {
val opcode = instructions[i].opcode.code val opcode = instructions[i].opcode.code
if (opcode == OP_RET.code || opcode == OP_JMP.code || opcode == OP_SWITCH_JMP.code) { if (opcode == OP_RET.code || opcode == OP_JMP.code) {
dropThrough = false dropThrough = false
break break
} }