diff options
Diffstat (limited to 'Zend/zend_operators.h')
| -rw-r--r-- | Zend/zend_operators.h | 49 |
1 files changed, 23 insertions, 26 deletions
diff --git a/Zend/zend_operators.h b/Zend/zend_operators.h index dad23bc4d8..8b9e06f17e 100644 --- a/Zend/zend_operators.h +++ b/Zend/zend_operators.h @@ -63,8 +63,13 @@ ZEND_API int ZEND_FASTCALL is_not_equal_function(zval *result, zval *op1, zval * ZEND_API int ZEND_FASTCALL is_smaller_function(zval *result, zval *op1, zval *op2); ZEND_API int ZEND_FASTCALL is_smaller_or_equal_function(zval *result, zval *op1, zval *op2); -ZEND_API zend_bool ZEND_FASTCALL instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool is_interface); -ZEND_API zend_bool ZEND_FASTCALL instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce); +ZEND_API zend_bool ZEND_FASTCALL zend_class_implements_interface(const zend_class_entry *class_ce, const zend_class_entry *interface_ce); +ZEND_API zend_bool ZEND_FASTCALL instanceof_function_slow(const zend_class_entry *instance_ce, const zend_class_entry *ce); + +static zend_always_inline zend_bool instanceof_function( + const zend_class_entry *instance_ce, const zend_class_entry *ce) { + return instance_ce == ce || instanceof_function_slow(instance_ce, ce); +} /** * Checks whether the string "str" with length "length" is numeric. The value @@ -148,10 +153,13 @@ static zend_always_inline const char * zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const char *end) { const char *p = haystack; - const char ne = needle[needle_len-1]; ptrdiff_t off_p; size_t off_s; + if (needle_len == 0) { + return p; + } + if (needle_len == 1) { return (const char *)memchr(p, *needle, (end-p)); } @@ -164,6 +172,7 @@ zend_memnstr(const char *haystack, const char *needle, size_t needle_len, const } if (EXPECTED(off_s < 1024 || needle_len < 9)) { /* glibc memchr is faster when needle is too short */ + const char ne = needle[needle_len-1]; end -= needle_len; while (p <= end) { @@ -206,10 +215,13 @@ static zend_always_inline const char * zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const char *end) { const char *p = end; - const char ne = needle[needle_len-1]; ptrdiff_t off_p; size_t off_s; + if (needle_len == 0) { + return p; + } + if (needle_len == 1) { return (const char *)zend_memrchr(haystack, *needle, (p - haystack)); } @@ -222,6 +234,7 @@ zend_memnrstr(const char *haystack, const char *needle, size_t needle_len, const } if (EXPECTED(off_s < 1024 || needle_len < 3)) { + const char ne = needle[needle_len-1]; p -= needle_len; do { @@ -388,6 +401,8 @@ again: return result; } +ZEND_API int ZEND_FASTCALL zend_compare(zval *op1, zval *op2); + ZEND_API int ZEND_FASTCALL compare_function(zval *result, zval *op1, zval *op2); ZEND_API int ZEND_FASTCALL numeric_compare_function(zval *op1, zval *op2); @@ -842,7 +857,6 @@ static zend_always_inline int zend_fast_equal_strings(zend_string *s1, zend_stri static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2) { - zval result; if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) { if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { return Z_LVAL_P(op1) == Z_LVAL_P(op2); @@ -860,28 +874,23 @@ static zend_always_inline int fast_equal_check_function(zval *op1, zval *op2) return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); } } - compare_function(&result, op1, op2); - return Z_LVAL(result) == 0; + return zend_compare(op1, op2) == 0; } static zend_always_inline int fast_equal_check_long(zval *op1, zval *op2) { - zval result; if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) { return Z_LVAL_P(op1) == Z_LVAL_P(op2); } - compare_function(&result, op1, op2); - return Z_LVAL(result) == 0; + return zend_compare(op1, op2) == 0; } static zend_always_inline int fast_equal_check_string(zval *op1, zval *op2) { - zval result; if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) { return zend_fast_equal_strings(Z_STR_P(op1), Z_STR_P(op2)); } - compare_function(&result, op1, op2); - return Z_LVAL(result) == 0; + return zend_compare(op1, op2) == 0; } static zend_always_inline zend_bool fast_is_identical_function(zval *op1, zval *op2) @@ -905,19 +914,7 @@ static zend_always_inline zend_bool fast_is_not_identical_function(zval *op1, zv } #define ZEND_TRY_BINARY_OP1_OBJECT_OPERATION(opcode, binary_op) \ - if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ - && op1 == result \ - && UNEXPECTED(Z_OBJ_HANDLER_P(op1, get)) \ - && EXPECTED(Z_OBJ_HANDLER_P(op1, set))) { \ - int ret; \ - zval rv; \ - zval *objval = Z_OBJ_HANDLER_P(op1, get)(op1, &rv); \ - Z_TRY_ADDREF_P(objval); \ - ret = binary_op(objval, objval, op2); \ - Z_OBJ_HANDLER_P(op1, set)(op1, objval); \ - zval_ptr_dtor(objval); \ - return ret; \ - } else if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ + if (UNEXPECTED(Z_TYPE_P(op1) == IS_OBJECT) \ && UNEXPECTED(Z_OBJ_HANDLER_P(op1, do_operation))) { \ if (EXPECTED(SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2))) { \ return SUCCESS; \ |
