diff options
author | Dmitry Stogov <dmitry@zend.com> | 2018-04-28 14:13:12 +0300 |
---|---|---|
committer | Dmitry Stogov <dmitry@zend.com> | 2018-04-28 14:13:12 +0300 |
commit | c88be6aee1f5127b9017812bdcfecb335e6e5d4c (patch) | |
tree | 8e167931ced8567edf7f3cf8a6221dddd87fe9e2 | |
parent | 8a719c1b12f16e22fd71ff993b64ebfc4e5d67be (diff) | |
download | php-git-c88be6aee1f5127b9017812bdcfecb335e6e5d4c.tar.gz |
Bit check micro-optimization
-rw-r--r-- | Zend/zend_vm_def.h | 4 | ||||
-rw-r--r-- | Zend/zend_vm_execute.h | 16 | ||||
-rw-r--r-- | ext/json/json_encoder.c | 2 | ||||
-rw-r--r-- | ext/mysqlnd/mysqlnd_result.c | 4 | ||||
-rw-r--r-- | ext/opcache/Optimizer/sccp.c | 2 | ||||
-rw-r--r-- | ext/standard/array.c | 4 |
6 files changed, 16 insertions, 16 deletions
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index 72e197e9ed..cad1ca2ebc 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -7603,7 +7603,7 @@ ZEND_VM_HANDLER(123, ZEND_TYPE_CHECK, CONST|TMP|VAR|CV, ANY, TYPE_MASK) zend_free_op free_op1; value = GET_OP1_ZVAL_PTR_UNDEF(BP_VAR_R); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { ZEND_VM_C_LABEL(type_check_resource): if (EXPECTED(Z_TYPE_P(value) != IS_RESOURCE) || EXPECTED(NULL != zend_rsrc_list_get_rsrc_type(Z_RES_P(value)))) { @@ -7611,7 +7611,7 @@ ZEND_VM_C_LABEL(type_check_resource): } } else if ((OP1_TYPE & (IS_CV|IS_VAR)) && Z_ISREF_P(value)) { value = Z_REFVAL_P(value); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { ZEND_VM_C_GOTO(type_check_resource); } } else if (OP1_TYPE == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) { diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index b6a6e9753c..2fbbf0fb21 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -3908,7 +3908,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CONST_HANDLER( value = RT_CONSTANT(opline, opline->op1); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { type_check_resource: if (EXPECTED(Z_TYPE_P(value) != IS_RESOURCE) || EXPECTED(NULL != zend_rsrc_list_get_rsrc_type(Z_RES_P(value)))) { @@ -3916,7 +3916,7 @@ type_check_resource: } } else if ((IS_CONST & (IS_CV|IS_VAR)) && Z_ISREF_P(value)) { value = Z_REFVAL_P(value); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { goto type_check_resource; } } else if (IS_CONST == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) { @@ -18562,7 +18562,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_TMP_HANDLER(ZE zend_free_op free_op1; value = _get_zval_ptr_tmp(opline->op1.var, &free_op1 EXECUTE_DATA_CC); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { type_check_resource: if (EXPECTED(Z_TYPE_P(value) != IS_RESOURCE) || EXPECTED(NULL != zend_rsrc_list_get_rsrc_type(Z_RES_P(value)))) { @@ -18570,7 +18570,7 @@ type_check_resource: } } else if ((IS_TMP_VAR & (IS_CV|IS_VAR)) && Z_ISREF_P(value)) { value = Z_REFVAL_P(value); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { goto type_check_resource; } } else if (IS_TMP_VAR == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) { @@ -22052,7 +22052,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_VAR_HANDLER(ZE zend_free_op free_op1; value = _get_zval_ptr_var(opline->op1.var, &free_op1 EXECUTE_DATA_CC); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { type_check_resource: if (EXPECTED(Z_TYPE_P(value) != IS_RESOURCE) || EXPECTED(NULL != zend_rsrc_list_get_rsrc_type(Z_RES_P(value)))) { @@ -22060,7 +22060,7 @@ type_check_resource: } } else if ((IS_VAR & (IS_CV|IS_VAR)) && Z_ISREF_P(value)) { value = Z_REFVAL_P(value); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { goto type_check_resource; } } else if (IS_VAR == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) { @@ -38026,7 +38026,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_TYPE_CHECK_SPEC_CV_HANDLER(ZEN value = _get_zval_ptr_cv_undef(opline->op1.var EXECUTE_DATA_CC); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { type_check_resource: if (EXPECTED(Z_TYPE_P(value) != IS_RESOURCE) || EXPECTED(NULL != zend_rsrc_list_get_rsrc_type(Z_RES_P(value)))) { @@ -38034,7 +38034,7 @@ type_check_resource: } } else if ((IS_CV & (IS_CV|IS_VAR)) && Z_ISREF_P(value)) { value = Z_REFVAL_P(value); - if ((1 << (uint32_t)Z_TYPE_P(value) & opline->extended_value)) { + if ((opline->extended_value >> (uint32_t)Z_TYPE_P(value)) & 1) { goto type_check_resource; } } else if (IS_CV == IS_CV && UNEXPECTED(Z_TYPE_P(value) == IS_UNDEF)) { diff --git a/ext/json/json_encoder.c b/ext/json/json_encoder.c index 6c288a11c7..3ec12b8968 100644 --- a/ext/json/json_encoder.c +++ b/ext/json/json_encoder.c @@ -350,7 +350,7 @@ static int php_json_escape_string( 0xffffffff, 0x500080c4, 0x10000000, 0x00000000}; pos++; - if (EXPECTED(!(charmap[us >> 5] & (1 << (us & 0x1f))))) { + if (EXPECTED(!((charmap[us >> 5] >> (us & 0x1f)) & 1))) { smart_str_appendc(buf, (unsigned char) us); } else { switch (us) { diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c index 27e32a7d21..653197e302 100644 --- a/ext/mysqlnd/mysqlnd_result.c +++ b/ext/mysqlnd/mysqlnd_result.c @@ -108,7 +108,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, initialize_result_set_rest)(MYSQLND_RE for (i = 0; i < result->row_count; i++) { /* (i / 8) & the_bit_for_i*/ - if (initialized[i >> 3] & (1 << (i & 7))) { + if ((initialized[i >> 3] >> (i & 7)) & 1) { continue; } @@ -1151,7 +1151,7 @@ MYSQLND_METHOD(mysqlnd_result_buffered_c, fetch_row)(MYSQLND_RES * result, void if (rc != PASS) { DBG_RETURN(FAIL); } - if (!(set->initialized[set->current_row >> 3] & (1 << (set->current_row & 7)))) { + if (!((set->initialized[set->current_row >> 3] >> (set->current_row & 7)) & 1)) { set->initialized[set->current_row >> 3] |= (1 << (set->current_row & 7)); /* mark initialized */ ++set->initialized_rows; diff --git a/ext/opcache/Optimizer/sccp.c b/ext/opcache/Optimizer/sccp.c index 575b92bb0a..5f5f7da3d8 100644 --- a/ext/opcache/Optimizer/sccp.c +++ b/ext/opcache/Optimizer/sccp.c @@ -660,7 +660,7 @@ static inline int ct_eval_isset_isempty(zval *result, uint32_t extended_value, z } static inline void ct_eval_type_check(zval *result, uint32_t type_mask, zval *op1) { - ZVAL_BOOL(result, (1 << Z_TYPE_P(op1)) & type_mask); + ZVAL_BOOL(result, (type_mask >> Z_TYPE_P(op1)) & 1); } static inline int ct_eval_in_array(zval *result, uint32_t extended_value, zval *op1, zval *op2) { diff --git a/ext/standard/array.c b/ext/standard/array.c index 8f5556f393..cfd29378a0 100644 --- a/ext/standard/array.c +++ b/ext/standard/array.c @@ -1679,7 +1679,7 @@ static zend_always_inline int php_valid_var_name(const char *var_name, size_t va /* These are allowed as first char: [a-zA-Z_\x7f-\xff] */ ch = (uint32_t)((unsigned char *)var_name)[0]; #if 1 - if (UNEXPECTED(!(charset[ch >> 5] & (1 << (ch & 0x1f))))) { + if (UNEXPECTED(!((charset[ch >> 5] >> (ch & 0x1f)) & 1))) { #else if (var_name[0] != '_' && (ch < 65 /* A */ || /* Z */ ch > 90) && @@ -1696,7 +1696,7 @@ static zend_always_inline int php_valid_var_name(const char *var_name, size_t va do { ch = (uint32_t)((unsigned char *)var_name)[i]; #if 1 - if (UNEXPECTED(!(charset[8 + (ch >> 5)] & (1 << (ch & 0x1f))))) { + if (UNEXPECTED(!((charset[8 + (ch >> 5)] >> (ch & 0x1f)) & 1))) { #else if (var_name[i] != '_' && (ch < 48 /* 0 */ || /* 9 */ ch > 57) && |