summaryrefslogtreecommitdiff
path: root/Zend/zend_inheritance.c
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2019-06-26 01:08:43 +0300
committerDmitry Stogov <dmitry@zend.com>2019-06-26 01:08:43 +0300
commitdb97bbc0c5eeb1374a0362407fd026f145a4cefb (patch)
treecdc68a3e55dbf8c54b407a025ea02aea40ce8bb4 /Zend/zend_inheritance.c
parent0c932e0aff18945437188f2b4ff4f49c60b83f2f (diff)
parentf7faa62c43e4eccd5f43dd5f1ca8580aad80f98c (diff)
downloadphp-git-db97bbc0c5eeb1374a0362407fd026f145a4cefb.tar.gz
Merge branch 'PHP-7.4'
* PHP-7.4: Reorder conditions to minimize number of checks on fast path
Diffstat (limited to 'Zend/zend_inheritance.c')
-rw-r--r--Zend/zend_inheritance.c45
1 files changed, 29 insertions, 16 deletions
diff --git a/Zend/zend_inheritance.c b/Zend/zend_inheritance.c
index 04b716da0f..a2f74bc4d6 100644
--- a/Zend/zend_inheritance.c
+++ b/Zend/zend_inheritance.c
@@ -449,10 +449,12 @@ static inheritance_status zend_do_perform_implementation_check(
local_status = zend_do_perform_arg_type_hint_check(
unresolved_class, fe, fe_arg_info, proto, proto_arg_info);
- if (local_status == INHERITANCE_ERROR) {
- return INHERITANCE_ERROR;
- }
- if (local_status == INHERITANCE_UNRESOLVED) {
+
+ if (UNEXPECTED(local_status != INHERITANCE_SUCCESS)) {
+ if (UNEXPECTED(local_status == INHERITANCE_ERROR)) {
+ return INHERITANCE_ERROR;
+ }
+ ZEND_ASSERT(local_status == INHERITANCE_UNRESOLVED);
status = INHERITANCE_UNRESOLVED;
}
@@ -472,10 +474,12 @@ static inheritance_status zend_do_perform_implementation_check(
local_status = zend_perform_covariant_type_check(
unresolved_class, fe, fe->common.arg_info - 1, proto, proto->common.arg_info - 1);
- if (local_status == INHERITANCE_ERROR) {
- return INHERITANCE_ERROR;
- }
- if (local_status == INHERITANCE_UNRESOLVED) {
+
+ if (UNEXPECTED(local_status != INHERITANCE_SUCCESS)) {
+ if (UNEXPECTED(local_status == INHERITANCE_ERROR)) {
+ return INHERITANCE_ERROR;
+ }
+ ZEND_ASSERT(local_status == INHERITANCE_UNRESOLVED);
status = INHERITANCE_UNRESOLVED;
}
}
@@ -678,7 +682,8 @@ static void perform_delayable_implementation_check(
if (UNEXPECTED(status != INHERITANCE_SUCCESS)) {
if (EXPECTED(status == INHERITANCE_UNRESOLVED)) {
add_compatibility_obligation(ce, fe, proto);
- } else if (status == INHERITANCE_ERROR) {
+ } else {
+ ZEND_ASSERT(status == INHERITANCE_ERROR);
emit_incompatible_method_error(
fe, proto, status, unresolved_class);
}
@@ -2185,10 +2190,11 @@ static int check_variance_obligation(zval *zv) {
zend_string *unresolved_class;
inheritance_status status = zend_do_perform_implementation_check(
&unresolved_class, obligation->child_fn, obligation->parent_fn);
- if (status == INHERITANCE_UNRESOLVED) {
- return ZEND_HASH_APPLY_KEEP;
- }
- if (status == INHERITANCE_ERROR) {
+ if (UNEXPECTED(status != INHERITANCE_SUCCESS)) {
+ if (EXPECTED(status == INHERITANCE_UNRESOLVED)) {
+ return ZEND_HASH_APPLY_KEEP;
+ }
+ ZEND_ASSERT(status == INHERITANCE_ERROR);
emit_incompatible_method_error(
obligation->child_fn, obligation->parent_fn, status, unresolved_class);
}
@@ -2323,9 +2329,16 @@ zend_bool zend_can_early_bind(zend_class_entry *ce, zend_class_entry *parent_ce)
}
zv = zend_hash_find_ex(&ce->function_table, key, 1);
- if (zv
- && zend_do_perform_implementation_check(&unresolved_class, Z_FUNC_P(zv), parent_func) == INHERITANCE_UNRESOLVED) {
- return 0;
+ if (zv) {
+ zend_function *child_func = Z_FUNC_P(zv);
+ inheritance_status status;
+
+ status = zend_do_perform_implementation_check(
+ &unresolved_class, child_func, parent_func);
+
+ if (UNEXPECTED(status == INHERITANCE_UNRESOLVED)) {
+ return 0;
+ }
}
} ZEND_HASH_FOREACH_END();
return 1;