com php-src: JIT: Fix SWITCH_LONG/STRING codegen with e xact type: ext/opcache/jit/zend_jit_x86.dasc ext/opcache/tests/jit/switch_jumptable.phpt

From: Date: Tue, 28 May 2019 13:25:19 +0000
Subject: com php-src: JIT: Fix SWITCH_LONG/STRING codegen with e xact type: ext/opcache/jit/zend_jit_x86.dasc ext/opcache/tests/jit/switch_jumptable.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-106393@lists.php.net to get a copy of this message
Commit: 0bd1fc225d90c5b0a002e201f2b2ca1d7e93bc35 Author: Nikita Popov <nikita.ppv@gmail.com> Tue, 28 May 2019 15:25:19 +0200 Parents: 7791784bc9229433f03b0529a61c8e843a30c8ea Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=0bd1fc225d90c5b0a002e201f2b2ca1d7e93bc35 Log: JIT: Fix SWITCH_LONG/STRING codegen with exact type We were not loading the operand if the type was known exactly. Changed paths: M ext/opcache/jit/zend_jit_x86.dasc A ext/opcache/tests/jit/switch_jumptable.phpt Diff: diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 1cd59ff..d74a350 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 0000000..80df4ac --- /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-- +<?php + +function test1(string $val) { + switch ($val) { + case 'str1': + case 'str2': + echo "correct\n"; + return; + } + echo "wrong\n"; +} +function test2(int $val) { + switch ($val) { + case 1: + case 2: + case 3: + case 4: + case 5: + echo "correct\n"; + return; + } + echo "wrong\n"; +} +test1("str1"); +test2(1); + +?> +--EXPECT-- +correct +correct

« previous php.cvs (#106393) next »