Skip to content

opcache: optimize some more functions on compile time #5870

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions ext/opcache/Optimizer/sccp.c
Original file line number Diff line number Diff line change
Expand Up @@ -844,13 +844,16 @@ static inline int ct_eval_func_call(
|| zend_string_equals_literal(name, "urldecode")
|| zend_string_equals_literal(name, "rawurlencode")
|| zend_string_equals_literal(name, "rawurldecode")
|| zend_string_equals_literal(name, "php_uname")) {
|| zend_string_equals_literal(name, "php_uname")
|| zend_string_equals_literal(name, "dirname")
|| zend_string_equals_literal(name, "crc32")) {
if (Z_TYPE_P(args[0]) != IS_STRING) {
return FAILURE;
}
/* pass */
} else if (zend_string_equals_literal(name, "array_keys")
|| zend_string_equals_literal(name, "array_values")) {
|| zend_string_equals_literal(name, "array_values")
|| zend_string_equals_literal(name, "array_filter")) {
if (Z_TYPE_P(args[0]) != IS_ARRAY) {
return FAILURE;
}
Expand All @@ -867,7 +870,8 @@ static inline int ct_eval_func_call(
}
} ZEND_HASH_FOREACH_END();
/* pass */
} else if (zend_string_equals_literal(name, "implode")) {
} else if (zend_string_equals_literal(name, "implode")
|| zend_string_equals_literal(name, "array_unique")) {
zval *entry;

if (Z_TYPE_P(args[0]) != IS_ARRAY) {
Expand Down Expand Up @@ -905,6 +909,17 @@ static inline int ct_eval_func_call(
&& Z_TYPE_P(args[0]) != IS_NULL)) {
return FAILURE;
}
/* pass */
} else if (zend_string_equals_literal(name, "dirname")) {
if (Z_TYPE_P(args[0]) != IS_STRING
|| (Z_TYPE_P(args[1]) != IS_LONG)) {
return FAILURE;
}
if (Z_LVAL_P(args[1]) < 1) {
// levels must be >= 1, else we get a ValueError
return FAILURE;
}

/* pass */
} else if (zend_string_equals_literal(name, "trim")
|| zend_string_equals_literal(name, "rtrim")
Expand Down Expand Up @@ -1004,7 +1019,8 @@ static inline int ct_eval_func_call(
}
}
/* pass */
} else if (zend_string_equals_literal(name, "version_compare")) {
// todo: version_compare with 3 arguments got removed, as we should add a proper check for the comperator, else we hide a ValueError
} else if (zend_string_equals_literal(name, "str_replace")) {
if (Z_TYPE_P(args[0]) != IS_STRING
|| Z_TYPE_P(args[1]) != IS_STRING
|| Z_TYPE_P(args[2]) != IS_STRING) {
Expand Down