com php-src: Manual loop optimizaton. Cost of the loops body is still the same, but the loop headers are improved.: Zend/zend_execute .c
Zend/zend_execute.h
| From: | Dmitry Stogov | Date: | Thu, 14 Dec 2017 00:39:22 +0000 |
| Subject: | com php-src: Manual loop optimizaton. Cost of the loops body is still the same, but the loop headers are improved.: Zend/zend_execute .c Zend/zend_execute.h |
||
| Groups: | php.cvs | ||
| Request: | Send a blank email to php-cvs+get-100574@lists.php.net to get a copy of this message | ||
Commit: 3aceab825a391b26c03525fef5ae9a54d0e64f57
Author: Dmitry Stogov <dmitry@zend.com> Thu, 14 Dec 2017 03:39:22 +0300
Parents: 4d19bc2279ddbc9c4a07814b3c1b468938d44eae
Branches: master
Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=3aceab825a391b26c03525fef5ae9a54d0e64f57
Log:
Manual loop optimizaton.
Cost of the loops body is still the same, but the loop headers are improved.
Changed paths:
M Zend/zend_execute.c
M Zend/zend_execute.h
Diff:
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index d2dad66...aaa45a8 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -2103,8 +2103,8 @@ ZEND_API void zend_clean_and_cache_symbol_table(zend_array *symbol_table) /*
{{{
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
{
zval *cv = EX_VAR_NUM(0);
- zval *end = cv + EX(func)->op_array.last_var;
- while (EXPECTED(cv != end)) {
+ int count = EX(func)->op_array.last_var;
+ while (EXPECTED(count != 0)) {
if (Z_REFCOUNTED_P(cv)) {
zend_refcounted *r = Z_COUNTED_P(cv);
if (!GC_DELREF(r)) {
@@ -2115,7 +2115,8 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data
*exec
}
}
cv++;
- }
+ count--;
+ }
}
/* }}} */
@@ -2201,13 +2202,13 @@ static zend_never_inline void zend_copy_extra_args(EXECUTE_DATA_D)
static zend_always_inline void zend_init_cvs(uint32_t first, uint32_t last EXECUTE_DATA_DC)
{
if (EXPECTED(first < last)) {
+ uint32_t count = last - first;
zval *var = EX_VAR_NUM(first);
- zval *end = EX_VAR_NUM(last);
do {
ZVAL_UNDEF(var);
var++;
- } while (var != end);
+ } while (--count);
}
}
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
index a8798ae..7724698 100644
--- a/Zend/zend_execute.h
+++ b/Zend/zend_execute.h
@@ -217,8 +217,8 @@ static zend_always_inline zend_execute_data *zend_vm_stack_push_call_frame(uint3
static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_info,
zend_execute_data *call)
{
if (UNEXPECTED(call_info & ZEND_CALL_FREE_EXTRA_ARGS)) {
- zval *end = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var +
call->func->op_array.T);
- zval *p = end + (ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args);
+ uint32_t count = ZEND_CALL_NUM_ARGS(call) - call->func->op_array.num_args;
+ zval *p = ZEND_CALL_VAR_NUM(call, call->func->op_array.last_var +
call->func->op_array.T + count);
do {
p--;
if (Z_REFCOUNTED_P(p)) {
@@ -230,7 +230,7 @@ static zend_always_inline void zend_vm_stack_free_extra_args_ex(uint32_t call_in
gc_check_possible_root(r);
}
}
- } while (p != end);
+ } while (--count);
}
}