From: Dmitry Stogov Date: Mon, 23 Sep 2019 20:04:08 +0000 (+0300) Subject: Use cheaper code for scalar type check X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=1030ff5f5fa555116755979aea6d41b504af2ef2;p=php Use cheaper code for scalar type check --- diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 57d688491d..410a6d0ed9 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -8967,13 +8967,18 @@ static int zend_jit_recv(dasm_State **Dst, const zend_op *opline, zend_op_array | add r0, offsetof(zend_reference, val) } if (!ZEND_TYPE_IS_CLASS(type)) { - // TODO: Use bt? uint32_t type_mask = ZEND_TYPE_MASK(type); - | mov edx, 1 - | mov cl, byte [r0 + 8] - | shl edx, cl - | test edx, type_mask - | je >8 + if (is_power_of_two(type_mask)) { + uint32_t type_code = concrete_type(type_mask); + | cmp byte [r0 + 8], type_code + | jne >8 + } else { + | mov edx, 1 + | mov cl, byte [r0 + 8] + | shl edx, cl + | test edx, type_mask + | je >8 + } } else { | SAVE_VALID_OPLINE opline | cmp byte [r0 + 8], IS_OBJECT @@ -9111,12 +9116,18 @@ static int zend_jit_recv_init(dasm_State **Dst, const zend_op *opline, zend_op_a | LOAD_ZVAL_ADDR r0, res_addr | ZVAL_DEREF r0, MAY_BE_REF if (!ZEND_TYPE_IS_CLASS(arg_info->type)) { - // TODO: Use bt? - | mov edx, 1 - | mov cl, byte [r0 + 8] - | shl edx, cl - | test edx, ZEND_TYPE_MASK(arg_info->type) - | je >8 + uint32_t type_mask = ZEND_TYPE_MASK(arg_info->type); + if (is_power_of_two(type_mask)) { + uint32_t type_code = concrete_type(type_mask); + | cmp byte [r0 + 8], type_code + | jne >8 + } else { + | mov edx, 1 + | mov cl, byte [r0 + 8] + | shl edx, cl + | test edx, type_mask + | je >8 + } } else { | cmp byte [r0 + 8], IS_OBJECT | jne >8