com php-src: Optimize out usless conditions used by specializer: Zend/zend_execute.h Zend/zend_portability.h
| From: | Dmitry Stogov | Date: | Thu, 25 Jun 2015 15:56:14 +0000 |
| Subject: | com php-src: Optimize out usless conditions used by specializer: Zend/zend_execute.h Zend/zend_portability.h | ||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-87529@lists.php.net to get a copy of this message | ||
Commit: 2a2f42c25d068a5233bd1239222ad7d2948963ee
Author: Dmitry Stogov <dmitry@zend.com> Thu, 25 Jun 2015 18:56:14 +0300
Parents: 04b26ba5c6a26fc5499a32251fd8b4666581b36a
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=2a2f42c25d068a5233bd1239222ad7d2948963ee
Log:
Optimize out usless conditions used by specializer
Changed paths:
M Zend/zend_execute.h
M Zend/zend_portability.h
Diff:
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 9719eda..f595edc 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -58,7 +58,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
{
zend_refcounted *ref = NULL;
- if ((value_type & (IS_VAR|IS_CV)) && Z_ISREF_P(value)) {
+ if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && Z_ISREF_P(value)) {
ref = Z_COUNTED_P(value);
value = Z_REFVAL_P(value);
}
@@ -78,7 +78,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
Z_OBJ_HANDLER_P(variable_ptr, set)(variable_ptr, value);
return variable_ptr;
}
- if ((value_type & (IS_VAR|IS_CV)) && variable_ptr == value) {
+ if (ZEND_CONST_COND(value_type & (IS_VAR|IS_CV), 1) && variable_ptr == value) {
return variable_ptr;
}
garbage = Z_COUNTED_P(variable_ptr);
@@ -93,7 +93,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
- } else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
+ } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
efree_size(ref, sizeof(zend_reference));
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
@@ -122,7 +122,7 @@ static zend_always_inline zval* zend_assign_to_variable(zval *variable_ptr, zval
if (UNEXPECTED(Z_OPT_REFCOUNTED_P(variable_ptr))) {
Z_ADDREF_P(variable_ptr);
}
- } else if (/* value_type == IS_VAR && */ UNEXPECTED(ref)) {
+ } else if (ZEND_CONST_COND(value_type == IS_VAR, 1) && UNEXPECTED(ref)) {
if (UNEXPECTED(--GC_REFCOUNT(ref) == 0)) {
efree_size(ref, sizeof(zend_reference));
} else if (Z_OPT_REFCOUNTED_P(variable_ptr)) {
diff --git a/Zend/zend_portability.h b/Zend/zend_portability.h
index 8c6989d..214ece5 100644
--- a/Zend/zend_portability.h
+++ b/Zend/zend_portability.h
@@ -250,6 +250,14 @@ char *alloca();
# define HAVE_BUILTIN_CONSTANT_P
#endif
+#ifdef HAVE_BUILTIN_CONSTANT_P
+# define ZEND_CONST_COND(_condition, _default) \
+ (__builtin_constant_p(_condition) ? (_condition) : (_default))
+#else
+# define ZEND_CONST_COND(_condition, _default) \
+ (_default)
+#endif
+
#if ZEND_DEBUG
# define zend_always_inline inline
# define zend_never_inline