From 0bd1fc225d90c5b0a002e201f2b2ca1d7e93bc35 Mon Sep 17 00:00:00 2001 From: Nikita Popov Date: Tue, 28 May 2019 15:25:19 +0200 Subject: [PATCH] JIT: Fix SWITCH_LONG/STRING codegen with exact type We were not loading the operand if the type was known exactly. --- ext/opcache/jit/zend_jit_x86.dasc | 12 ++++--- ext/opcache/tests/jit/switch_jumptable.phpt | 38 +++++++++++++++++++++ 2 files changed, 46 insertions(+), 4 deletions(-) create mode 100644 ext/opcache/tests/jit/switch_jumptable.phpt diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 1cd59ffc86..d74a350bf6 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -9968,8 +9968,10 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, zend_op_arra | jmp >2 |.code |2: - } else if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)) { - | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >3 + } else { + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_LONG)) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_LONG, >3 + } | GET_ZVAL_LVAL ZREG_FCARG2a, op1_addr } if (HT_IS_PACKED(jumptable)) { @@ -10050,8 +10052,10 @@ static int zend_jit_switch(dasm_State **Dst, const zend_op *opline, zend_op_arra | jmp >2 |.code |2: - } else if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_STRING)) { - | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, >3 + } else { + if (op1_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-MAY_BE_STRING)) { + | IF_NOT_ZVAL_TYPE op1_addr, IS_STRING, >3 + } | GET_ZVAL_PTR FCARG2a, op1_addr } | LOAD_ADDR FCARG1a, jumptable diff --git a/ext/opcache/tests/jit/switch_jumptable.phpt b/ext/opcache/tests/jit/switch_jumptable.phpt new file mode 100644 index 0000000000..80df4ac0c2 --- /dev/null +++ b/ext/opcache/tests/jit/switch_jumptable.phpt @@ -0,0 +1,38 @@ +--TEST-- +Switch jumptable generation +--INI-- +opcache.enable=1 +opcache.enable_cli=1 +opcache.file_update_protection=0 +opcache.jit_buffer_size=1M +--FILE-- + +--EXPECT-- +correct +correct -- 2.50.1