@@ -16250,15 +16250,22 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
1625016250 if (opline->op1_type == IS_CONST) {
1625116251 zval *zv = RT_CONSTANT(opline, opline->op1);
1625216252 zval *jump_zv = NULL;
16253+ const zend_op *target;
1625316254 int b;
1625416255
16256+ /* Wrong type for SWITCH_LONG/SWITCH_STRING falls back to the ZEND_CASE chain */
16257+ target = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
1625516258 if (opline->opcode == ZEND_SWITCH_LONG) {
1625616259 if (Z_TYPE_P(zv) == IS_LONG) {
1625716260 jump_zv = zend_hash_index_find(jumptable, Z_LVAL_P(zv));
16261+ } else {
16262+ target = opline + 1;
1625816263 }
1625916264 } else if (opline->opcode == ZEND_SWITCH_STRING) {
1626016265 if (Z_TYPE_P(zv) == IS_STRING) {
1626116266 jump_zv = zend_hash_find_known_hash(jumptable, Z_STR_P(zv));
16267+ } else {
16268+ target = opline + 1;
1626216269 }
1626316270 } else if (opline->opcode == ZEND_MATCH) {
1626416271 if (Z_TYPE_P(zv) == IS_LONG) {
@@ -16269,21 +16276,13 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
1626916276 } else {
1627016277 ZEND_UNREACHABLE();
1627116278 }
16279+ if (jump_zv != NULL) {
16280+ target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv));
16281+ }
1627216282 if (next_opline) {
16273- const zend_op *target;
16274-
16275- if (jump_zv != NULL) {
16276- target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv));
16277- } else {
16278- target = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
16279- }
1628016283 ZEND_ASSERT(target == next_opline);
1628116284 } else {
16282- if (jump_zv != NULL) {
16283- b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes];
16284- } else {
16285- b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes];
16286- }
16285+ b = ssa->cfg.map[target - op_array->opcodes];
1628716286 _zend_jit_add_predecessor_ref(jit, b, jit->b, ir_END());
1628816287 jit->b = -1;
1628916288 }
0 commit comments