summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2015-06-25 18:56:14 +0300
committerDmitry Stogov <dmitry@zend.com>2015-06-25 18:56:14 +0300
commit2a2f42c25d068a5233bd1239222ad7d2948963ee (patch)
tree385415f87aaa7e1a034327e8ec08220869e2827e
parent04b26ba5c6a26fc5499a32251fd8b4666581b36a (diff)
downloadphp-git-2a2f42c25d068a5233bd1239222ad7d2948963ee.tar.gz
Optimize out usless conditions used by specializer
-rw-r--r--Zend/zend_execute.h8
-rw-r--r--Zend/zend_portability.h8
2 files changed, 12 insertions, 4 deletions
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index 9719eda42b..f595edca9b 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 8c6989d030..214ece53e6 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