PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LCOV - code coverage report
Current view: top level - Zend - zend_operators.h (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 272 280 97.1 %
Date: 2014-09-19 Functions: 4 4 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | Zend Engine                                                          |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 2.00 of the Zend license,     |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.zend.com/license/2_00.txt.                                |
      11             :    | If you did not receive a copy of the Zend license and are unable to  |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@zend.com so we can mail you a copy immediately.              |
      14             :    +----------------------------------------------------------------------+
      15             :    | Authors: Andi Gutmans <andi@zend.com>                                |
      16             :    |          Zeev Suraski <zeev@zend.com>                                |
      17             :    +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : /* $Id$ */
      21             : 
      22             : #ifndef ZEND_OPERATORS_H
      23             : #define ZEND_OPERATORS_H
      24             : 
      25             : #include <errno.h>
      26             : #include <math.h>
      27             : #include <assert.h>
      28             : 
      29             : #ifdef __GNUC__
      30             : #include <stddef.h>
      31             : #endif
      32             : 
      33             : #ifdef HAVE_IEEEFP_H
      34             : #include <ieeefp.h>
      35             : #endif
      36             : 
      37             : #include "zend_strtod.h"
      38             : #include "zend_multiply.h"
      39             : 
      40             : #if 0&&HAVE_BCMATH
      41             : #include "ext/bcmath/libbcmath/src/bcmath.h"
      42             : #endif
      43             : 
      44             : #define LONG_SIGN_MASK (((zend_long)1) << (8*sizeof(zend_long)-1))
      45             : 
      46             : BEGIN_EXTERN_C()
      47             : ZEND_API int add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      48             : ZEND_API int sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      49             : ZEND_API int mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      50             : ZEND_API int pow_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      51             : ZEND_API int div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      52             : ZEND_API int mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      53             : ZEND_API int boolean_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      54             : ZEND_API int boolean_not_function(zval *result, zval *op1 TSRMLS_DC);
      55             : ZEND_API int bitwise_not_function(zval *result, zval *op1 TSRMLS_DC);
      56             : ZEND_API int bitwise_or_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      57             : ZEND_API int bitwise_and_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      58             : ZEND_API int bitwise_xor_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      59             : ZEND_API int shift_left_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      60             : ZEND_API int shift_right_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      61             : ZEND_API int concat_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      62             : 
      63             : ZEND_API int is_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      64             : ZEND_API int is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      65             : ZEND_API int is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      66             : ZEND_API int is_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      67             : ZEND_API int is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      68             : ZEND_API int is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
      69             : 
      70             : ZEND_API zend_bool instanceof_function_ex(const zend_class_entry *instance_ce, const zend_class_entry *ce, zend_bool interfaces_only TSRMLS_DC);
      71             : ZEND_API zend_bool instanceof_function(const zend_class_entry *instance_ce, const zend_class_entry *ce TSRMLS_DC);
      72             : END_EXTERN_C()
      73             : 
      74             : #if ZEND_DVAL_TO_LVAL_CAST_OK
      75             : # define zend_dval_to_lval(d) ((zend_long) (d))
      76             : #elif SIZEOF_ZEND_LONG == 4
      77             : static zend_always_inline zend_long zend_dval_to_lval(double d)
      78             : {
      79             :         if (d > ZEND_LONG_MAX || d < ZEND_LONG_MIN) {
      80             :                 double  two_pow_32 = pow(2., 32.),
      81             :                                 dmod;
      82             : 
      83             :                 dmod = fmod(d, two_pow_32);
      84             :                 if (dmod < 0) {
      85             :                         /* we're going to make this number positive; call ceil()
      86             :                          * to simulate rounding towards 0 of the negative number */
      87             :                         dmod = ceil(dmod) + two_pow_32;
      88             :                 }
      89             :                 return (zend_long)(zend_ulong)dmod;
      90             :         }
      91             :         return (zend_long)d;
      92             : }
      93             : #else
      94             : static zend_always_inline zend_long zend_dval_to_lval(double d)
      95             : {
      96             :         /* >= as (double)ZEND_LONG_MAX is outside signed range */
      97       26574 :         if (d >= ZEND_LONG_MAX || d < ZEND_LONG_MIN) {
      98         149 :                 double  two_pow_64 = pow(2., 64.),
      99             :                                 dmod;
     100             : 
     101         149 :                 dmod = fmod(d, two_pow_64);
     102         149 :                 if (dmod < 0) {
     103             :                         /* no need to call ceil; original double must have had no
     104             :                          * fractional part, hence dmod does not have one either */
     105           7 :                         dmod += two_pow_64;
     106             :                 }
     107         149 :                 return (zend_long)(zend_ulong)dmod;
     108             :         }
     109       26425 :         return (zend_long)d;
     110             : }
     111             : #endif
     112             : /* }}} */
     113             : 
     114             : #define ZEND_IS_DIGIT(c) ((c) >= '0' && (c) <= '9')
     115             : #define ZEND_IS_XDIGIT(c) (((c) >= 'A' && (c) <= 'F') || ((c) >= 'a' && (c) <= 'f'))
     116             : 
     117             : /**
     118             :  * Checks whether the string "str" with length "length" is numeric. The value
     119             :  * of allow_errors determines whether it's required to be entirely numeric, or
     120             :  * just its prefix. Leading whitespace is allowed.
     121             :  *
     122             :  * The function returns 0 if the string did not contain a valid number; IS_LONG
     123             :  * if it contained a number that fits within the range of a long; or IS_DOUBLE
     124             :  * if the number was out of long range or contained a decimal point/exponent.
     125             :  * The number's value is returned into the respective pointer, *lval or *dval,
     126             :  * if that pointer is not NULL.
     127             :  *
     128             :  * This variant also gives information if a string that represents an integer
     129             :  * could not be represented as such due to overflow. It writes 1 to oflow_info
     130             :  * if the integer is larger than ZEND_LONG_MAX and -1 if it's smaller than ZEND_LONG_MIN.
     131             :  */
     132     1095500 : static inline zend_uchar is_numeric_string_ex(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors, int *oflow_info)
     133             : {
     134             :         const char *ptr;
     135     1095500 :         int base = 10, digits = 0, dp_or_e = 0;
     136     1095500 :         double local_dval = 0.0;
     137             :         zend_uchar type;
     138             : 
     139     1095500 :         if (!length) {
     140        1451 :                 return 0;
     141             :         }
     142             : 
     143     1094049 :         if (oflow_info != NULL) {
     144      938393 :                 *oflow_info = 0;
     145             :         }
     146             : 
     147             :         /* Skip any whitespace
     148             :          * This is much faster than the isspace() function */
     149     2189907 :         while (*str == ' ' || *str == '\t' || *str == '\n' || *str == '\r' || *str == '\v' || *str == '\f') {
     150        1809 :                 str++;
     151        1809 :                 length--;
     152             :         }
     153     1094049 :         ptr = str;
     154             : 
     155     1094049 :         if (*ptr == '-' || *ptr == '+') {
     156        2450 :                 ptr++;
     157             :         }
     158             : 
     159     1648332 :         if (ZEND_IS_DIGIT(*ptr)) {
     160             :                 /* Handle hex numbers
     161             :                  * str is used instead of ptr to disallow signs and keep old behavior */
     162      759540 :                 if (length > 2 && *str == '0' && (str[1] == 'x' || str[1] == 'X')) {
     163         236 :                         base = 16;
     164         236 :                         ptr += 2;
     165             :                 }
     166             : 
     167             :                 /* Skip any leading 0s */
     168     1785182 :                 while (*ptr == '0') {
     169      266102 :                         ptr++;
     170             :                 }
     171             : 
     172             :                 /* Count the number of digits. If a decimal point/exponent is found,
     173             :                  * it's a double. Otherwise, if there's a dval or no need to check for
     174             :                  * a full match, stop when there are too many digits for a long */
     175    10861234 :                 for (type = IS_LONG; !(digits >= MAX_LENGTH_OF_LONG && (dval || allow_errors == 1)); digits++, ptr++) {
     176             : check_digits:
     177     5428401 :                         if (ZEND_IS_DIGIT(*ptr) || (base == 16 && ZEND_IS_XDIGIT(*ptr))) {
     178     4671077 :                                 continue;
     179      757324 :                         } else if (base == 10) {
     180      757088 :                                 if (*ptr == '.' && dp_or_e < 1) {
     181             :                                         goto process_double;
     182      554363 :                                 } else if ((*ptr == 'e' || *ptr == 'E') && dp_or_e < 2) {
     183         357 :                                         const char *e = ptr + 1;
     184             : 
     185         357 :                                         if (*e == '-' || *e == '+') {
     186           9 :                                                 ptr = e++;
     187             :                                         }
     188         357 :                                         if (ZEND_IS_DIGIT(*e)) {
     189         314 :                                                 goto process_double;
     190             :                                         }
     191             :                                 }
     192             :                         }
     193             : 
     194      554285 :                         break;
     195             :                 }
     196             : 
     197      556521 :                 if (base == 10) {
     198      556285 :                         if (digits >= MAX_LENGTH_OF_LONG) {
     199        2238 :                                 if (oflow_info != NULL) {
     200        2233 :                                         *oflow_info = *str == '-' ? -1 : 1;
     201             :                                 }
     202        2238 :                                 dp_or_e = -1;
     203        2238 :                                 goto process_double;
     204             :                         }
     205         236 :                 } else if (!(digits < SIZEOF_ZEND_LONG * 2 || (digits == SIZEOF_ZEND_LONG * 2 && ptr[-digits] <= '7'))) {
     206           0 :                         if (dval) {
     207           0 :                                 local_dval = zend_hex_strtod(str, &ptr);
     208             :                         }
     209           0 :                         if (oflow_info != NULL) {
     210           0 :                                 *oflow_info = 1;
     211             :                         }
     212           0 :                         type = IS_DOUBLE;
     213             :                 }
     214      539986 :         } else if (*ptr == '.' && ZEND_IS_DIGIT(ptr[1])) {
     215             : process_double:
     216      205497 :                 type = IS_DOUBLE;
     217             : 
     218             :                 /* If there's a dval, do the conversion; else continue checking
     219             :                  * the digits if we need to check for a full match */
     220      205497 :                 if (dval) {
     221      205475 :                         local_dval = zend_strtod(str, &ptr);
     222          22 :                 } else if (allow_errors != 1 && dp_or_e != -1) {
     223          20 :                         dp_or_e = (*ptr++ == '.') ? 1 : 2;
     224          20 :                         goto check_digits;
     225             :                 }
     226             :         } else {
     227      334289 :                 return 0;
     228             :         }
     229             : 
     230      759760 :         if (ptr != str + length) {
     231       14851 :                 if (!allow_errors) {
     232       14021 :                         return 0;
     233             :                 }
     234         830 :                 if (allow_errors == -1) {
     235          58 :                         zend_error(E_NOTICE, "A non well formed numeric value encountered");
     236             :                 }
     237             :         }
     238             : 
     239      745739 :         if (type == IS_LONG) {
     240      541030 :                 if (digits == MAX_LENGTH_OF_LONG - 1) {
     241         179 :                         int cmp = strcmp(&ptr[-digits], long_min_digits);
     242             : 
     243         179 :                         if (!(cmp < 0 || (cmp == 0 && *str == '-'))) {
     244           3 :                                 if (dval) {
     245           3 :                                         *dval = zend_strtod(str, NULL);
     246             :                                 }
     247           3 :                                 if (oflow_info != NULL) {
     248           3 :                                         *oflow_info = *str == '-' ? -1 : 1;
     249             :                                 }
     250             : 
     251           3 :                                 return IS_DOUBLE;
     252             :                         }
     253             :                 }
     254             : 
     255      541027 :                 if (lval) {
     256      540966 :                         *lval = ZEND_STRTOL(str, NULL, base);
     257             :                 }
     258             : 
     259      541027 :                 return IS_LONG;
     260             :         } else {
     261      204709 :                 if (dval) {
     262      204691 :                         *dval = local_dval;
     263             :                 }
     264             : 
     265      204709 :                 return IS_DOUBLE;
     266             :         }
     267             : }
     268             : 
     269      155826 : static inline zend_uchar is_numeric_string(const char *str, size_t length, zend_long *lval, double *dval, int allow_errors) {
     270      155826 :     return is_numeric_string_ex(str, length, lval, dval, allow_errors, NULL);
     271             : }
     272             : 
     273             : ZEND_API zend_uchar is_numeric_str_function(const zend_string *str, zend_long *lval, double *dval);
     274             : 
     275             : static inline const char *
     276     2628343 : zend_memnstr(const char *haystack, const char *needle, size_t needle_len, char *end)
     277             : {
     278     2628343 :         const char *p = haystack;
     279     2628343 :         const char ne = needle[needle_len-1];
     280             :         ptrdiff_t off_p;
     281             :         size_t off_s;
     282             : 
     283     2628343 :         if (needle_len == 1) {
     284     1842701 :                 return (char *)memchr(p, *needle, (end-p));
     285             :         }
     286             : 
     287      785642 :         off_p = end - haystack;
     288      785642 :         off_s = (off_p > 0) ? (size_t)off_p : 0;
     289      785642 :         if (needle_len > off_s) {
     290        6386 :                 return NULL;
     291             :         }
     292             : 
     293      779256 :         end -= needle_len;
     294             : 
     295     4819674 :         while (p <= end) {
     296     3967764 :                 if ((p = (char *)memchr(p, *needle, (end-p+1))) && ne == p[needle_len-1]) {
     297      527640 :                         if (!memcmp(needle, p, needle_len-1)) {
     298      181679 :                                 return p;
     299             :                         }
     300             :                 }
     301             : 
     302     3786085 :                 if (p == NULL) {
     303      524923 :                         return NULL;
     304             :                 }
     305             : 
     306     3261162 :                 p++;
     307             :         }
     308             : 
     309       72654 :         return NULL;
     310             : }
     311             : 
     312     3220687 : static inline const void *zend_memrchr(const void *s, int c, size_t n)
     313             : {
     314             :         register const unsigned char *e;
     315             : 
     316     3220687 :         if (n <= 0) {
     317         428 :                 return NULL;
     318             :         }
     319             : 
     320    47018365 :         for (e = (const unsigned char *)s + n - 1; e >= (const unsigned char *)s; e--) {
     321    43835026 :                 if (*e == (const unsigned char)c) {
     322       36920 :                         return (const void *)e;
     323             :                 }
     324             :         }
     325             : 
     326     3183339 :         return NULL;
     327             : }
     328             : 
     329             : BEGIN_EXTERN_C()
     330             : ZEND_API int increment_function(zval *op1);
     331             : ZEND_API int decrement_function(zval *op2);
     332             : 
     333             : ZEND_API void convert_scalar_to_number(zval *op TSRMLS_DC);
     334             : ZEND_API void _convert_to_cstring(zval *op ZEND_FILE_LINE_DC);
     335             : ZEND_API void _convert_to_string(zval *op ZEND_FILE_LINE_DC);
     336             : ZEND_API void convert_to_long(zval *op);
     337             : ZEND_API void convert_to_double(zval *op);
     338             : ZEND_API void convert_to_long_base(zval *op, int base);
     339             : ZEND_API void convert_to_null(zval *op);
     340             : ZEND_API void convert_to_boolean(zval *op);
     341             : ZEND_API void convert_to_array(zval *op);
     342             : ZEND_API void convert_to_object(zval *op);
     343             : ZEND_API void multi_convert_to_long_ex(int argc, ...);
     344             : ZEND_API void multi_convert_to_double_ex(int argc, ...);
     345             : ZEND_API void multi_convert_to_string_ex(int argc, ...);
     346             : 
     347             : ZEND_API zend_long _zval_get_long_func(zval *op TSRMLS_DC);
     348             : ZEND_API double _zval_get_double_func(zval *op TSRMLS_DC);
     349             : ZEND_API zend_string *_zval_get_string_func(zval *op TSRMLS_DC);
     350             : 
     351             : static zend_always_inline zend_long _zval_get_long(zval *op TSRMLS_DC) {
     352      276243 :         return Z_TYPE_P(op) == IS_LONG ? Z_LVAL_P(op) : _zval_get_long_func(op TSRMLS_CC);
     353             : }
     354             : static zend_always_inline double _zval_get_double(zval *op TSRMLS_DC) {
     355      206052 :         return Z_TYPE_P(op) == IS_DOUBLE ? Z_DVAL_P(op) : _zval_get_double_func(op TSRMLS_CC);
     356             : }
     357             : static zend_always_inline zend_string *_zval_get_string(zval *op TSRMLS_DC) {
     358     6489264 :         return Z_TYPE_P(op) == IS_STRING ? zend_string_copy(Z_STR_P(op)) : _zval_get_string_func(op TSRMLS_CC);
     359             : }
     360             : 
     361             : #define zval_get_long(op) _zval_get_long((op) TSRMLS_CC)
     362             : #define zval_get_double(op) _zval_get_double((op) TSRMLS_CC)
     363             : #define zval_get_string(op) _zval_get_string((op) TSRMLS_CC)
     364             : 
     365             : ZEND_API int add_char_to_string(zval *result, const zval *op1, const zval *op2);
     366             : ZEND_API int add_string_to_string(zval *result, const zval *op1, const zval *op2);
     367             : #define convert_to_cstring(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_cstring((op) ZEND_FILE_LINE_CC); }
     368             : #define convert_to_string(op) if (Z_TYPE_P(op) != IS_STRING) { _convert_to_string((op) ZEND_FILE_LINE_CC); }
     369             : 
     370             : ZEND_API int zval_is_true(zval *op);
     371             : ZEND_API int compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
     372             : ZEND_API int numeric_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
     373             : ZEND_API int string_compare_function_ex(zval *result, zval *op1, zval *op2, zend_bool case_insensitive TSRMLS_DC);
     374             : ZEND_API int string_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
     375             : ZEND_API int string_case_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
     376             : #if HAVE_STRCOLL
     377             : ZEND_API int string_locale_compare_function(zval *result, zval *op1, zval *op2 TSRMLS_DC);
     378             : #endif
     379             : 
     380             : ZEND_API void zend_str_tolower(char *str, size_t length);
     381             : ZEND_API char *zend_str_tolower_copy(char *dest, const char *source, size_t length);
     382             : ZEND_API char *zend_str_tolower_dup(const char *source, size_t length);
     383             : 
     384             : ZEND_API int zend_binary_zval_strcmp(zval *s1, zval *s2);
     385             : ZEND_API int zend_binary_zval_strncmp(zval *s1, zval *s2, zval *s3);
     386             : ZEND_API int zend_binary_zval_strcasecmp(zval *s1, zval *s2);
     387             : ZEND_API int zend_binary_zval_strncasecmp(zval *s1, zval *s2, zval *s3);
     388             : ZEND_API int zend_binary_strcmp(const char *s1, size_t len1, const char *s2, size_t len2);
     389             : ZEND_API int zend_binary_strncmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
     390             : ZEND_API int zend_binary_strcasecmp(const char *s1, size_t len1, const char *s2, size_t len2);
     391             : ZEND_API int zend_binary_strncasecmp(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
     392             : ZEND_API int zend_binary_strcasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2);
     393             : ZEND_API int zend_binary_strncasecmp_l(const char *s1, size_t len1, const char *s2, size_t len2, size_t length);
     394             : 
     395             : ZEND_API void zendi_smart_strcmp(zval *result, zval *s1, zval *s2);
     396             : ZEND_API void zend_compare_symbol_tables(zval *result, HashTable *ht1, HashTable *ht2 TSRMLS_DC);
     397             : ZEND_API void zend_compare_arrays(zval *result, zval *a1, zval *a2 TSRMLS_DC);
     398             : ZEND_API void zend_compare_objects(zval *result, zval *o1, zval *o2 TSRMLS_DC);
     399             : 
     400             : ZEND_API int zend_atoi(const char *str, int str_len);
     401             : ZEND_API zend_long zend_atol(const char *str, int str_len);
     402             : 
     403             : ZEND_API void zend_locale_sprintf_double(zval *op ZEND_FILE_LINE_DC);
     404             : END_EXTERN_C()
     405             : 
     406             : #define convert_to_ex_master(pzv, lower_type, upper_type)       \
     407             :         if (Z_TYPE_P(pzv)!=upper_type) {                                        \
     408             :                 SEPARATE_ZVAL_IF_NOT_REF(pzv);                                          \
     409             :                 convert_to_##lower_type(pzv);                                           \
     410             :         }
     411             : 
     412             : #define convert_to_explicit_type(pzv, type)             \
     413             :         do {                                                                            \
     414             :                 switch (type) {                                                 \
     415             :                         case IS_NULL:                                           \
     416             :                                 convert_to_null(pzv);                   \
     417             :                                 break;                                                  \
     418             :                         case IS_LONG:                                           \
     419             :                                 convert_to_long(pzv);                   \
     420             :                                 break;                                                  \
     421             :                         case IS_DOUBLE:                                         \
     422             :                                 convert_to_double(pzv);                 \
     423             :                                 break;                                                  \
     424             :                         case _IS_BOOL:                                          \
     425             :                                 convert_to_boolean(pzv);                \
     426             :                                 break;                                                  \
     427             :                         case IS_ARRAY:                                          \
     428             :                                 convert_to_array(pzv);                  \
     429             :                                 break;                                                  \
     430             :                         case IS_OBJECT:                                         \
     431             :                                 convert_to_object(pzv);                 \
     432             :                                 break;                                                  \
     433             :                         case IS_STRING:                                         \
     434             :                                 convert_to_string(pzv);                 \
     435             :                                 break;                                                  \
     436             :                         default:                                                        \
     437             :                                 assert(0);                                              \
     438             :                                 break;                                                  \
     439             :                 }                                                                               \
     440             :         } while (0);
     441             : 
     442             : #define convert_to_explicit_type_ex(pzv, str_type)      \
     443             :         if (Z_TYPE_P(pzv) != str_type) {                                \
     444             :                 SEPARATE_ZVAL_IF_NOT_REF(pzv);                          \
     445             :                 convert_to_explicit_type(pzv, str_type);        \
     446             :         }
     447             : 
     448             : #define convert_to_boolean_ex(pzv)      convert_to_ex_master(pzv, boolean, _IS_BOOL)
     449             : #define convert_to_long_ex(pzv)         convert_to_ex_master(pzv, long, IS_LONG)
     450             : #define convert_to_double_ex(pzv)       convert_to_ex_master(pzv, double, IS_DOUBLE)
     451             : #define convert_to_string_ex(pzv)       convert_to_ex_master(pzv, string, IS_STRING)
     452             : #define convert_to_array_ex(pzv)        convert_to_ex_master(pzv, array, IS_ARRAY)
     453             : #define convert_to_object_ex(pzv)       convert_to_ex_master(pzv, object, IS_OBJECT)
     454             : #define convert_to_null_ex(pzv)         convert_to_ex_master(pzv, null, IS_NULL)
     455             : 
     456             : #define convert_scalar_to_number_ex(pzv)                                                        \
     457             :         if (Z_TYPE_P(pzv)!=IS_LONG && Z_TYPE_P(pzv)!=IS_DOUBLE) {               \
     458             :                 SEPARATE_ZVAL_IF_NOT_REF(pzv);                                                          \
     459             :                 convert_scalar_to_number(pzv TSRMLS_CC);                                        \
     460             :         }
     461             : 
     462             : #if HAVE_SETLOCALE && defined(ZEND_WIN32) && !defined(ZTS) && defined(_MSC_VER) && (_MSC_VER >= 1400)
     463             : /* This is performance improvement of tolower() on Windows and VC2005
     464             :  * Gives 10-18% on bench.php
     465             :  */
     466             : #define ZEND_USE_TOLOWER_L 1
     467             : #endif
     468             : 
     469             : #ifdef ZEND_USE_TOLOWER_L
     470             : ZEND_API void zend_update_current_locale(void);
     471             : #else
     472             : #define zend_update_current_locale()
     473             : #endif
     474             : 
     475             : /* The offset in bytes between the value and type fields of a zval */
     476             : #define ZVAL_OFFSETOF_TYPE      \
     477             :         (offsetof(zval, u1.type_info) - offsetof(zval, value))
     478             : 
     479             : static zend_always_inline int fast_increment_function(zval *op1)
     480             : {
     481     5139191 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     482             : #if defined(__GNUC__) && defined(__i386__)
     483             :                 __asm__(
     484             :                         "incl (%0)\n\t"
     485             :                         "jno  0f\n\t"
     486             :                         "movl $0x0, (%0)\n\t"
     487             :                         "movl $0x41e00000, 0x4(%0)\n\t"
     488             :                         "movl %1, %c2(%0)\n"
     489             :                         "0:"
     490             :                         :
     491             :                         : "r"(&op1->value),
     492             :                           "n"(IS_DOUBLE),
     493             :                           "n"(ZVAL_OFFSETOF_TYPE)
     494             :                         : "cc");
     495             : #elif defined(__GNUC__) && defined(__x86_64__)
     496     5139191 :                 __asm__(
     497             :                         "incq (%0)\n\t"
     498             :                         "jno  0f\n\t"
     499             :                         "movl $0x0, (%0)\n\t"
     500             :                         "movl $0x43e00000, 0x4(%0)\n\t"
     501             :                         "movl %1, %c2(%0)\n"
     502             :                         "0:"
     503             :                         :
     504     5139191 :                         : "r"(&op1->value),
     505             :                           "n"(IS_DOUBLE),
     506             :                           "n"(ZVAL_OFFSETOF_TYPE)
     507             :                         : "cc");
     508             : #else
     509             :                 if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MAX)) {
     510             :                         /* switch to double */
     511             :                         ZVAL_DOUBLE(op1, (double)ZEND_LONG_MAX + 1.0);
     512             :                 } else {
     513             :                         Z_LVAL_P(op1)++;
     514             :                 }
     515             : #endif
     516     5139191 :                 return SUCCESS;
     517             :         }
     518           0 :         return increment_function(op1);
     519             : }
     520             : 
     521             : static zend_always_inline int fast_decrement_function(zval *op1)
     522             : {
     523      423504 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     524             : #if defined(__GNUC__) && defined(__i386__)
     525             :                 __asm__(
     526             :                         "decl (%0)\n\t"
     527             :                         "jno  0f\n\t"
     528             :                         "movl $0x00200000, (%0)\n\t"
     529             :                         "movl $0xc1e00000, 0x4(%0)\n\t"
     530             :                         "movl %1,%c2(%0)\n"
     531             :                         "0:"
     532             :                         :
     533             :                         : "r"(&op1->value),
     534             :                           "n"(IS_DOUBLE),
     535             :                           "n"(ZVAL_OFFSETOF_TYPE)
     536             :                         : "cc");
     537             : #elif defined(__GNUC__) && defined(__x86_64__)
     538      423504 :                 __asm__(
     539             :                         "decq (%0)\n\t"
     540             :                         "jno  0f\n\t"
     541             :                         "movl $0x00000000, (%0)\n\t"
     542             :                         "movl $0xc3e00000, 0x4(%0)\n\t"
     543             :                         "movl %1,%c2(%0)\n"
     544             :                         "0:"
     545             :                         :
     546      423504 :                         : "r"(&op1->value),
     547             :                           "n"(IS_DOUBLE),
     548             :                           "n"(ZVAL_OFFSETOF_TYPE)
     549             :                         : "cc");
     550             : #else
     551             :                 if (UNEXPECTED(Z_LVAL_P(op1) == ZEND_LONG_MIN)) {
     552             :                         /* switch to double */
     553             :                         ZVAL_DOUBLE(op1, (double)ZEND_LONG_MIN - 1.0);
     554             :                 } else {
     555             :                         Z_LVAL_P(op1)--;
     556             :                 }
     557             : #endif
     558      423504 :                 return SUCCESS;
     559             :         }
     560           0 :         return decrement_function(op1);
     561             : }
     562             : 
     563             : static zend_always_inline int fast_add_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     564             : {
     565      743419 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     566      741688 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     567             : #if defined(__GNUC__) && defined(__i386__)
     568             :                 __asm__(
     569             :                         "movl      (%1), %%eax\n\t"
     570             :                         "addl   (%2), %%eax\n\t"
     571             :                         "jo     0f\n\t"     
     572             :                         "movl   %%eax, (%0)\n\t"
     573             :                         "movl   %3, %c5(%0)\n\t"
     574             :                         "jmp    1f\n"
     575             :                         "0:\n\t"
     576             :                         "fildl     (%1)\n\t"
     577             :                         "fildl     (%2)\n\t"
     578             :                         "faddp     %%st, %%st(1)\n\t"
     579             :                         "movl   %4, %c5(%0)\n\t"
     580             :                         "fstpl     (%0)\n"
     581             :                         "1:"
     582             :                         : 
     583             :                         : "r"(&result->value),
     584             :                           "r"(&op1->value),
     585             :                           "r"(&op2->value),
     586             :                           "n"(IS_LONG),
     587             :                           "n"(IS_DOUBLE),
     588             :                           "n"(ZVAL_OFFSETOF_TYPE)
     589             :                         : "eax","cc");
     590             : #elif defined(__GNUC__) && defined(__x86_64__)
     591      741592 :                 __asm__(
     592             :                         "movq      (%1), %%rax\n\t"
     593             :                         "addq   (%2), %%rax\n\t"
     594             :                         "jo     0f\n\t"     
     595             :                         "movq   %%rax, (%0)\n\t"
     596             :                         "movl   %3, %c5(%0)\n\t"
     597             :                         "jmp    1f\n"
     598             :                         "0:\n\t"
     599             :                         "fildq     (%1)\n\t"
     600             :                         "fildq     (%2)\n\t"
     601             :                         "faddp     %%st, %%st(1)\n\t"
     602             :                         "movl   %4, %c5(%0)\n\t"
     603             :                         "fstpl     (%0)\n"
     604             :                         "1:"
     605             :                         : 
     606      741592 :                         : "r"(&result->value),
     607      741592 :                           "r"(&op1->value),
     608      741592 :                           "r"(&op2->value),
     609             :                           "n"(IS_LONG),
     610             :                           "n"(IS_DOUBLE),
     611             :                           "n"(ZVAL_OFFSETOF_TYPE)
     612             :                         : "rax","cc");
     613             : #else
     614             :                         /*
     615             :                          * 'result' may alias with op1 or op2, so we need to
     616             :                          * ensure that 'result' is not updated until after we
     617             :                          * have read the values of op1 and op2.
     618             :                          */
     619             : 
     620             :                         if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) == (Z_LVAL_P(op2) & LONG_SIGN_MASK)
     621             :                                 && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != ((Z_LVAL_P(op1) + Z_LVAL_P(op2)) & LONG_SIGN_MASK))) {
     622             :                                 ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) + (double) Z_LVAL_P(op2));
     623             :                         } else {
     624             :                                 ZVAL_LONG(result, Z_LVAL_P(op1) + Z_LVAL_P(op2));
     625             :                         }
     626             : #endif
     627      741592 :                         return SUCCESS;
     628          96 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     629          78 :                         ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) + Z_DVAL_P(op2));
     630          78 :                         return SUCCESS;
     631             :                 }
     632        1731 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     633        1306 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     634         202 :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) + Z_DVAL_P(op2));
     635         202 :                         return SUCCESS;
     636        1104 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     637        1095 :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) + ((double)Z_LVAL_P(op2)));
     638        1095 :                         return SUCCESS;
     639             :                 }
     640             :         }
     641         452 :         return add_function(result, op1, op2 TSRMLS_CC);
     642             : }
     643             : 
     644             : static zend_always_inline int fast_sub_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     645             : {
     646      312076 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     647      200091 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     648             : #if defined(__GNUC__) && defined(__i386__)
     649             :                 __asm__(
     650             :                         "movl      (%1), %%eax\n\t"
     651             :                         "subl   (%2), %%eax\n\t"
     652             :                         "jo     0f\n\t"     
     653             :                         "movl   %%eax, (%0)\n\t"
     654             :                         "movl   %3, %c5(%0)\n\t"
     655             :                         "jmp    1f\n"
     656             :                         "0:\n\t"
     657             :                         "fildl     (%2)\n\t"
     658             :                         "fildl     (%1)\n\t"
     659             : #if defined(__clang__) && (__clang_major__ < 2 || (__clang_major__ == 2 && __clang_minor__ < 10))
     660             :                         "fsubp  %%st(1), %%st\n\t"  /* LLVM bug #9164 */
     661             : #else
     662             :                         "fsubp     %%st, %%st(1)\n\t"
     663             : #endif
     664             :                         "movl   %4, %c5(%0)\n\t"
     665             :                         "fstpl     (%0)\n"
     666             :                         "1:"
     667             :                         : 
     668             :                         : "r"(&result->value),
     669             :                           "r"(&op1->value),
     670             :                           "r"(&op2->value),
     671             :                           "n"(IS_LONG),
     672             :                           "n"(IS_DOUBLE),
     673             :                           "n"(ZVAL_OFFSETOF_TYPE)
     674             :                         : "eax","cc");
     675             : #elif defined(__GNUC__) && defined(__x86_64__)
     676      200012 :                 __asm__(
     677             :                         "movq      (%1), %%rax\n\t"
     678             :                         "subq   (%2), %%rax\n\t"
     679             :                         "jo     0f\n\t"     
     680             :                         "movq   %%rax, (%0)\n\t"
     681             :                         "movl   %3, %c5(%0)\n\t"
     682             :                         "jmp    1f\n"
     683             :                         "0:\n\t"
     684             :                         "fildq     (%2)\n\t"
     685             :                         "fildq     (%1)\n\t"
     686             : #if defined(__clang__) && (__clang_major__ < 2 || (__clang_major__ == 2 && __clang_minor__ < 10))
     687             :                         "fsubp  %%st(1), %%st\n\t"  /* LLVM bug #9164 */
     688             : #else
     689             :                         "fsubp     %%st, %%st(1)\n\t"
     690             : #endif
     691             :                         "movl   %4, %c5(%0)\n\t"
     692             :                         "fstpl     (%0)\n"
     693             :                         "1:"
     694             :                         : 
     695      200012 :                         : "r"(&result->value),
     696      200012 :                           "r"(&op1->value),
     697      200012 :                           "r"(&op2->value),
     698             :                           "n"(IS_LONG),
     699             :                           "n"(IS_DOUBLE),
     700             :                           "n"(ZVAL_OFFSETOF_TYPE)
     701             :                         : "rax","cc");
     702             : #else
     703             :                         ZVAL_LONG(result, Z_LVAL_P(op1) - Z_LVAL_P(op2));
     704             : 
     705             :                         if (UNEXPECTED((Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(op2) & LONG_SIGN_MASK)
     706             :                                 && (Z_LVAL_P(op1) & LONG_SIGN_MASK) != (Z_LVAL_P(result) & LONG_SIGN_MASK))) {
     707             :                                 ZVAL_DOUBLE(result, (double) Z_LVAL_P(op1) - (double) Z_LVAL_P(op2));
     708             :                         }
     709             : #endif
     710      200012 :                         return SUCCESS;
     711          79 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     712          62 :                         ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) - Z_DVAL_P(op2));
     713          62 :                         return SUCCESS;
     714             :                 }
     715      111985 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     716      111765 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     717      111746 :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) - Z_DVAL_P(op2));
     718      111746 :                         return SUCCESS;
     719          19 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     720          19 :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) - ((double)Z_LVAL_P(op2)));
     721          19 :                         return SUCCESS;
     722             :                 }
     723             :         }
     724         237 :         return sub_function(result, op1, op2 TSRMLS_CC);
     725             : }
     726             : 
     727             : static zend_always_inline int fast_mul_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     728             : {
     729      444872 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     730      444406 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     731             :                         zend_long overflow;
     732             : 
     733      443789 :                         ZEND_SIGNED_MULTIPLY_LONG(Z_LVAL_P(op1), Z_LVAL_P(op2), Z_LVAL_P(result), Z_DVAL_P(result), overflow);
     734      443789 :                         Z_TYPE_INFO_P(result) = overflow ? IS_DOUBLE : IS_LONG;
     735      443789 :                         return SUCCESS;
     736         617 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     737         614 :                         ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) * Z_DVAL_P(op2));
     738         614 :                         return SUCCESS;
     739             :                 }
     740         466 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     741         239 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     742         170 :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) * Z_DVAL_P(op2));
     743         170 :                         return SUCCESS;
     744          69 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     745          69 :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) * ((double)Z_LVAL_P(op2)));
     746          69 :                         return SUCCESS;
     747             :                 }
     748             :         }
     749         230 :         return mul_function(result, op1, op2 TSRMLS_CC);
     750             : }
     751             : 
     752             : static zend_always_inline int fast_div_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     753             : {
     754             : #if 0
     755             :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG) && 0) {
     756             :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     757             :                         if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
     758             :                                 zend_error(E_WARNING, "Division by zero");
     759             :                                 ZVAL_BOOL(result, 0);
     760             :                                 return FAILURE;
     761             :                         } else if (UNEXPECTED(Z_LVAL_P(op2) == -1 && Z_LVAL_P(op1) == ZEND_LONG_MIN)) {
     762             :                                 /* Prevent overflow error/crash */
     763             :                                 ZVAL_DOUBLE(result, (double) ZEND_LONG_MIN / -1);
     764             :                         } else if (EXPECTED(Z_LVAL_P(op1) % Z_LVAL_P(op2) == 0)) {
     765             :                                 /* integer */
     766             :                                 ZVAL_LONG(result, Z_LVAL_P(op1) / Z_LVAL_P(op2));
     767             :                         } else {
     768             :                                 ZVAL_DOUBLE(result, ((double) Z_LVAL_P(op1)) / ((double)Z_LVAL_P(op2)));
     769             :                         }
     770             :                         return SUCCESS;
     771             :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     772             :                         if (UNEXPECTED(Z_DVAL_P(op2) == 0)) {
     773             :                                 zend_error(E_WARNING, "Division by zero");
     774             :                                 ZVAL_BOOL(result, 0);
     775             :                                 return FAILURE;
     776             :                         }
     777             :                         ZVAL_DOUBLE(result, ((double)Z_LVAL_P(op1)) / Z_DVAL_P(op2));
     778             :                         return SUCCESS;
     779             :                 }
     780             :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE) && 0) {
     781             :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     782             :                         if (UNEXPECTED(Z_DVAL_P(op2) == 0)) {
     783             :                                 zend_error(E_WARNING, "Division by zero");
     784             :                                 ZVAL_BOOL(result, 0);
     785             :                                 return FAILURE;
     786             :                         }
     787             :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) / Z_DVAL_P(op2));
     788             :                         return SUCCESS;
     789             :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     790             :                         if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
     791             :                                 zend_error(E_WARNING, "Division by zero");
     792             :                                 ZVAL_BOOL(result, 0);
     793             :                                 return FAILURE;
     794             :                         }
     795             :                         ZVAL_DOUBLE(result, Z_DVAL_P(op1) / ((double)Z_LVAL_P(op2)));
     796             :                         return SUCCESS;
     797             :                 }
     798             :         }
     799             : #endif
     800      145920 :         return div_function(result, op1, op2 TSRMLS_CC);
     801             : }
     802             : 
     803             : static zend_always_inline int fast_mod_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     804             : {
     805       67476 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     806       67155 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     807       67136 :                         if (UNEXPECTED(Z_LVAL_P(op2) == 0)) {
     808          13 :                                 zend_error(E_WARNING, "Division by zero");
     809          13 :                                 ZVAL_BOOL(result, 0);
     810          13 :                                 return FAILURE;
     811       67123 :                         } else if (UNEXPECTED(Z_LVAL_P(op2) == -1)) {
     812             :                                 /* Prevent overflow error/crash if op1==ZEND_LONG_MIN */
     813          13 :                                 ZVAL_LONG(result, 0);
     814          13 :                                 return SUCCESS;
     815             :                         }
     816       67110 :                         ZVAL_LONG(result, Z_LVAL_P(op1) % Z_LVAL_P(op2));
     817       67110 :                         return SUCCESS;
     818             :                 }
     819             :         }
     820         340 :         return mod_function(result, op1, op2 TSRMLS_CC);
     821             : }
     822             : 
     823             : static zend_always_inline int fast_equal_check_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     824             : {
     825      504966 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     826        8066 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     827        7865 :                         return Z_LVAL_P(op1) == Z_LVAL_P(op2);
     828         201 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     829           8 :                         return ((double)Z_LVAL_P(op1)) == Z_DVAL_P(op2);
     830             :                 }
     831      496900 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     832         316 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     833          16 :                         return Z_DVAL_P(op1) == Z_DVAL_P(op2);
     834         300 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     835         128 :                         return Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2));
     836             :                 }
     837      496584 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
     838      482773 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
     839      482122 :                         if (Z_STR_P(op1) == Z_STR_P(op2)) {
     840          46 :                                 return 1;
     841      482076 :                         } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
     842      478256 :                                 if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
     843      435307 :                                         return 0;
     844             :                                 } else {
     845       42949 :                                         return memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0;
     846             :                                 }
     847             :                         } else {
     848        3820 :                                 zendi_smart_strcmp(result, op1, op2);
     849        3820 :                                 return Z_LVAL_P(result) == 0;
     850             :                         }
     851             :                 }
     852             :         }
     853       14827 :         compare_function(result, op1, op2 TSRMLS_CC);
     854       14827 :         return Z_LVAL_P(result) == 0;
     855             : }
     856             : 
     857             : static zend_always_inline void fast_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     858             : {
     859     2487637 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     860     1318488 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     861     1317116 :                         ZVAL_BOOL(result, Z_LVAL_P(op1) == Z_LVAL_P(op2));
     862             :                         return;
     863        1372 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     864          19 :                         ZVAL_BOOL(result, (double)Z_LVAL_P(op1) == Z_DVAL_P(op2));
     865             :                         return;
     866             :                 }
     867     1169149 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     868          90 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     869          41 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) == Z_DVAL_P(op2));
     870             :                         return;
     871          49 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     872          14 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) == ((double)Z_LVAL_P(op2)));
     873             :                         return;
     874             :                 }
     875     1169059 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
     876     1074598 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
     877     1074492 :                         if (Z_STR_P(op1) == Z_STR_P(op2)) {
     878        1081 :                                 ZVAL_TRUE(result);
     879             :                                 return;
     880     1073411 :                         } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
     881      933339 :                                 if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
     882      425027 :                                         ZVAL_FALSE(result);
     883             :                                         return;
     884             :                                 } else {
     885      508312 :                                         ZVAL_BOOL(result, memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) == 0);
     886             :                                         return;
     887             :                                 }
     888             :                         } else {
     889      140072 :                                 zendi_smart_strcmp(result, op1, op2);
     890      140072 :                                 ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
     891             :                                 return;
     892             :                         }
     893             :                 }
     894             :         }
     895       95955 :         compare_function(result, op1, op2 TSRMLS_CC);
     896       95954 :         ZVAL_BOOL(result, Z_LVAL_P(result) == 0);
     897             : }
     898             : 
     899             : static zend_always_inline void fast_not_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     900             : {
     901      483948 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     902      108294 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     903      106647 :                         ZVAL_BOOL(result, Z_LVAL_P(op1) != Z_LVAL_P(op2));
     904             :                         return;
     905        1647 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     906          20 :                         ZVAL_BOOL(result, (double)Z_LVAL_P(op1) != Z_DVAL_P(op2));
     907             :                         return;
     908             :                 }
     909      375654 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     910         116 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     911          13 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) != Z_DVAL_P(op2));
     912             :                         return;
     913         103 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     914           0 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) != ((double)Z_LVAL_P(op2)));
     915             :                         return;
     916             :                 }
     917      375538 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_STRING)) {
     918      181994 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_STRING)) {
     919      178878 :                         if (Z_STR_P(op1) == Z_STR_P(op2)) {
     920         117 :                                 ZVAL_FALSE(result);
     921             :                                 return;
     922      178761 :                         } else if (Z_STRVAL_P(op1)[0] > '9' || Z_STRVAL_P(op2)[0] > '9') {
     923       33287 :                                 if (Z_STRLEN_P(op1) != Z_STRLEN_P(op2)) {
     924       13590 :                                         ZVAL_TRUE(result);
     925             :                                         return;
     926             :                                 } else {
     927       19697 :                                         ZVAL_BOOL(result, memcmp(Z_STRVAL_P(op1), Z_STRVAL_P(op2), Z_STRLEN_P(op1)) != 0);
     928             :                                         return;
     929             :                                 }
     930             :                         } else {
     931      145474 :                                 zendi_smart_strcmp(result, op1, op2);
     932      145474 :                                 ZVAL_BOOL(result, Z_LVAL_P(result) != 0);
     933             :                                 return;
     934             :                         }
     935             :                 }
     936             :         }
     937      198390 :         compare_function(result, op1, op2 TSRMLS_CC);
     938      198390 :         ZVAL_BOOL(result, Z_LVAL_P(result) != 0);
     939             : }
     940             : 
     941             : static zend_always_inline void fast_is_smaller_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     942             : {
     943     7631124 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     944     7230881 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     945     6987669 :                         ZVAL_BOOL(result, Z_LVAL_P(op1) < Z_LVAL_P(op2));
     946             :                         return;
     947      243212 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     948      209928 :                         ZVAL_BOOL(result, (double)Z_LVAL_P(op1) < Z_DVAL_P(op2));
     949             :                         return;
     950             :                 }
     951      400243 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     952      111925 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     953         188 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) < Z_DVAL_P(op2));
     954             :                         return;
     955      111737 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     956      111703 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) < ((double)Z_LVAL_P(op2)));
     957             :                         return;
     958             :                 }
     959             :         }
     960      321636 :         compare_function(result, op1, op2 TSRMLS_CC);
     961      321636 :         ZVAL_BOOL(result, Z_LVAL_P(result) < 0);
     962             : }
     963             : 
     964             : static zend_always_inline void fast_is_smaller_or_equal_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     965             : {
     966      578445 :         if (EXPECTED(Z_TYPE_P(op1) == IS_LONG)) {
     967      477818 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     968      461771 :                         ZVAL_BOOL(result, Z_LVAL_P(op1) <= Z_LVAL_P(op2));
     969             :                         return;
     970       16047 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     971       15939 :                         ZVAL_BOOL(result, (double)Z_LVAL_P(op1) <= Z_DVAL_P(op2));
     972             :                         return;
     973             :                 }
     974      100627 :         } else if (EXPECTED(Z_TYPE_P(op1) == IS_DOUBLE)) {
     975          86 :                 if (EXPECTED(Z_TYPE_P(op2) == IS_DOUBLE)) {
     976          19 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) <= Z_DVAL_P(op2));
     977             :                         return;
     978          67 :                 } else if (EXPECTED(Z_TYPE_P(op2) == IS_LONG)) {
     979          25 :                         ZVAL_BOOL(result, Z_DVAL_P(op1) <= ((double)Z_LVAL_P(op2)));
     980             :                         return;
     981             :                 }
     982             :         }
     983      100691 :         compare_function(result, op1, op2 TSRMLS_CC);
     984      100691 :         ZVAL_BOOL(result, Z_LVAL_P(result) <= 0);
     985             : }
     986             : 
     987             : static zend_always_inline void fast_is_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     988             : {
     989     3432254 :         if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
     990     2418860 :                 ZVAL_BOOL(result, 0);
     991             :                 return;
     992             :         }
     993     1013394 :         is_identical_function(result, op1, op2 TSRMLS_CC);
     994             : }
     995             : 
     996             : static zend_always_inline void fast_is_not_identical_function(zval *result, zval *op1, zval *op2 TSRMLS_DC)
     997             : {
     998      532010 :         if (Z_TYPE_P(op1) != Z_TYPE_P(op2)) {
     999      476900 :                 ZVAL_BOOL(result, 1);
    1000             :                 return;
    1001             :         }
    1002       55110 :         is_identical_function(result, op1, op2 TSRMLS_CC);
    1003       55110 :         ZVAL_BOOL(result, Z_TYPE_P(result) != IS_TRUE);
    1004             : }
    1005             : 
    1006             : #define ZEND_TRY_BINARY_OBJECT_OPERATION(opcode)                                                  \
    1007             :         if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, do_operation)) {                       \
    1008             :                 if (SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, op2 TSRMLS_CC)) {  \
    1009             :                         return SUCCESS;                                                                       \
    1010             :                 }                                                                                         \
    1011             :         } else if (Z_TYPE_P(op2) == IS_OBJECT && Z_OBJ_HANDLER_P(op2, do_operation)) {                \
    1012             :                 if (SUCCESS == Z_OBJ_HANDLER_P(op2, do_operation)(opcode, result, op1, op2 TSRMLS_CC)) {  \
    1013             :                         return SUCCESS;                                                                       \
    1014             :                 }                                                                                         \
    1015             :         }
    1016             : 
    1017             : #define ZEND_TRY_UNARY_OBJECT_OPERATION(opcode)                                                   \
    1018             :         if (Z_TYPE_P(op1) == IS_OBJECT && Z_OBJ_HANDLER_P(op1, do_operation)                          \
    1019             :          && SUCCESS == Z_OBJ_HANDLER_P(op1, do_operation)(opcode, result, op1, NULL TSRMLS_CC)        \
    1020             :         ) {                                                                                           \
    1021             :                 return SUCCESS;                                                                           \
    1022             :         }
    1023             : 
    1024             : /* input: buf points to the END of the buffer */
    1025             : #define _zend_print_unsigned_to_buf(buf, num, vartype, result) do {    \
    1026             :         char *__p = (buf);                                                 \
    1027             :         vartype __num = (num);                                             \
    1028             :         *__p = '\0';                                                       \
    1029             :         do {                                                               \
    1030             :                 *--__p = (char) (__num % 10) + '0';                            \
    1031             :                 __num /= 10;                                                   \
    1032             :         } while (__num > 0);                                               \
    1033             :         result = __p;                                                      \
    1034             : } while (0)
    1035             : 
    1036             : /* buf points to the END of the buffer */
    1037             : #define _zend_print_signed_to_buf(buf, num, vartype, result) do {               \
    1038             :         if (num < 0) {                                                              \
    1039             :             _zend_print_unsigned_to_buf((buf), (~((vartype)(num)) + 1), vartype, (result)); \
    1040             :             *--(result) = '-';                                                      \
    1041             :         } else {                                                                    \
    1042             :             _zend_print_unsigned_to_buf((buf), (num), vartype, (result));           \
    1043             :         }                                                                           \
    1044             : } while (0)
    1045             : 
    1046             : ZEND_API zend_string *zend_long_to_str(zend_long num);
    1047             : 
    1048             : #endif
    1049             : 
    1050             : /*
    1051             :  * Local variables:
    1052             :  * tab-width: 4
    1053             :  * c-basic-offset: 4
    1054             :  * indent-tabs-mode: t
    1055             :  * End:
    1056             :  */

Generated by: LCOV version 1.10

Generated at Fri, 19 Sep 2014 17:11:04 +0000 (3 days ago)

Copyright © 2005-2014 The PHP Group
All rights reserved.