@@ -16301,15 +16301,22 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
1630116301 if (opline->op1_type == IS_CONST) {
1630216302 zval *zv = RT_CONSTANT(opline, opline->op1);
1630316303 zval *jump_zv = NULL;
16304+ const zend_op *target;
1630416305 int b;
1630516306
16307+ /* Wrong type for SWITCH_LONG/SWITCH_STRING falls back to the ZEND_CASE chain */
16308+ target = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
1630616309 if (opline->opcode == ZEND_SWITCH_LONG) {
1630716310 if (Z_TYPE_P(zv) == IS_LONG) {
1630816311 jump_zv = zend_hash_index_find(jumptable, Z_LVAL_P(zv));
16312+ } else {
16313+ target = opline + 1;
1630916314 }
1631016315 } else if (opline->opcode == ZEND_SWITCH_STRING) {
1631116316 if (Z_TYPE_P(zv) == IS_STRING) {
1631216317 jump_zv = zend_hash_find_known_hash(jumptable, Z_STR_P(zv));
16318+ } else {
16319+ target = opline + 1;
1631316320 }
1631416321 } else if (opline->opcode == ZEND_MATCH) {
1631516322 if (Z_TYPE_P(zv) == IS_LONG) {
@@ -16320,21 +16327,13 @@ static int zend_jit_switch(zend_jit_ctx *jit, const zend_op *opline, const zend_
1632016327 } else {
1632116328 ZEND_UNREACHABLE();
1632216329 }
16330+ if (jump_zv != NULL) {
16331+ target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv));
16332+ }
1632316333 if (next_opline) {
16324- const zend_op *target;
16325-
16326- if (jump_zv != NULL) {
16327- target = ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv));
16328- } else {
16329- target = ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value);
16330- }
1633116334 ZEND_ASSERT(target == next_opline);
1633216335 } else {
16333- if (jump_zv != NULL) {
16334- b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, Z_LVAL_P(jump_zv)) - op_array->opcodes];
16335- } else {
16336- b = ssa->cfg.map[ZEND_OFFSET_TO_OPLINE(opline, opline->extended_value) - op_array->opcodes];
16337- }
16336+ b = ssa->cfg.map[target - op_array->opcodes];
1633816337 _zend_jit_add_predecessor_ref(jit, b, jit->b, ir_END());
1633916338 jit->b = -1;
1634016339 }
0 commit comments