Merge branch 'PHP-7.4'

* PHP-7.4:
  Reduce register pressure by reloading values on CPUs with few general purpose registers
This commit is contained in:
Dmitry Stogov 2019-05-31 00:15:18 +03:00
commit 10cf2c07f2
3 changed files with 41 additions and 0 deletions

View File

@ -636,4 +636,9 @@ static zend_always_inline double _zend_get_nan(void) /* {{{ */
# define ZEND_EXPAND_VA(code) code # define ZEND_EXPAND_VA(code) code
#endif #endif
/* On CPU with few registers, it's cheaper to reload value then use spill slot */
#if defined(__i386__) || (defined(_WIN32) && !defined(_WIN64))
# define ZEND_PREFER_RELOAD
#endif
#endif /* ZEND_PORTABILITY_H */ #endif /* ZEND_PORTABILITY_H */

View File

@ -2801,6 +2801,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) { if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
EG(current_execute_data) = EX(prev_execute_data); EG(current_execute_data) = EX(prev_execute_data);
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) { if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
OBJ_RELEASE(Z_OBJ(execute_data->This)); OBJ_RELEASE(Z_OBJ(execute_data->This));
@ -2820,6 +2823,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
} else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) { } else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) { if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
zend_clean_and_cache_symbol_table(EX(symbol_table)); zend_clean_and_cache_symbol_table(EX(symbol_table));
} }
@ -2846,6 +2852,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
zend_detach_symbol_table(execute_data); zend_detach_symbol_table(execute_data);
destroy_op_array(&EX(func)->op_array); destroy_op_array(&EX(func)->op_array);
efree_size(EX(func), sizeof(zend_op_array)); efree_size(EX(func), sizeof(zend_op_array));
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
old_execute_data = execute_data; old_execute_data = execute_data;
execute_data = EG(current_execute_data) = EX(prev_execute_data); execute_data = EG(current_execute_data) = EX(prev_execute_data);
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
@ -2861,6 +2870,9 @@ ZEND_VM_HOT_HELPER(zend_leave_helper, ANY, ANY)
} else { } else {
if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) { if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) { if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) {
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) { if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
zend_clean_and_cache_symbol_table(EX(symbol_table)); zend_clean_and_cache_symbol_table(EX(symbol_table));

View File

@ -794,6 +794,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) { if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
EG(current_execute_data) = EX(prev_execute_data); EG(current_execute_data) = EX(prev_execute_data);
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) { if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
OBJ_RELEASE(Z_OBJ(execute_data->This)); OBJ_RELEASE(Z_OBJ(execute_data->This));
@ -813,6 +816,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_
} else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) { } else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) { if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
zend_clean_and_cache_symbol_table(EX(symbol_table)); zend_clean_and_cache_symbol_table(EX(symbol_table));
} }
@ -839,6 +845,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_
zend_detach_symbol_table(execute_data); zend_detach_symbol_table(execute_data);
destroy_op_array(&EX(func)->op_array); destroy_op_array(&EX(func)->op_array);
efree_size(EX(func), sizeof(zend_op_array)); efree_size(EX(func), sizeof(zend_op_array));
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
old_execute_data = execute_data; old_execute_data = execute_data;
execute_data = EG(current_execute_data) = EX(prev_execute_data); execute_data = EG(current_execute_data) = EX(prev_execute_data);
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
@ -854,6 +863,9 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_
} else { } else {
if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) { if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) { if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) {
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) { if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
zend_clean_and_cache_symbol_table(EX(symbol_table)); zend_clean_and_cache_symbol_table(EX(symbol_table));
@ -60471,6 +60483,9 @@ zend_leave_helper_SPEC_LABEL:
if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) { if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP|ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS|ZEND_CALL_ALLOCATED)) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
EG(current_execute_data) = EX(prev_execute_data); EG(current_execute_data) = EX(prev_execute_data);
if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) { if (UNEXPECTED(call_info & ZEND_CALL_RELEASE_THIS)) {
OBJ_RELEASE(Z_OBJ(execute_data->This)); OBJ_RELEASE(Z_OBJ(execute_data->This));
@ -60490,6 +60505,9 @@ zend_leave_helper_SPEC_LABEL:
} else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) { } else if (EXPECTED((call_info & (ZEND_CALL_CODE|ZEND_CALL_TOP)) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) { if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
zend_clean_and_cache_symbol_table(EX(symbol_table)); zend_clean_and_cache_symbol_table(EX(symbol_table));
} }
@ -60516,6 +60534,9 @@ zend_leave_helper_SPEC_LABEL:
zend_detach_symbol_table(execute_data); zend_detach_symbol_table(execute_data);
destroy_op_array(&EX(func)->op_array); destroy_op_array(&EX(func)->op_array);
efree_size(EX(func), sizeof(zend_op_array)); efree_size(EX(func), sizeof(zend_op_array));
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
old_execute_data = execute_data; old_execute_data = execute_data;
execute_data = EG(current_execute_data) = EX(prev_execute_data); execute_data = EG(current_execute_data) = EX(prev_execute_data);
zend_vm_stack_free_call_frame_ex(call_info, old_execute_data); zend_vm_stack_free_call_frame_ex(call_info, old_execute_data);
@ -60531,6 +60552,9 @@ zend_leave_helper_SPEC_LABEL:
} else { } else {
if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) { if (EXPECTED((call_info & ZEND_CALL_CODE) == 0)) {
i_free_compiled_variables(execute_data); i_free_compiled_variables(execute_data);
#ifdef ZEND_PREFER_RELOAD
call_info = EX_CALL_INFO();
#endif
if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) { if (UNEXPECTED(call_info & (ZEND_CALL_HAS_SYMBOL_TABLE|ZEND_CALL_FREE_EXTRA_ARGS))) {
if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) { if (UNEXPECTED(call_info & ZEND_CALL_HAS_SYMBOL_TABLE)) {
zend_clean_and_cache_symbol_table(EX(symbol_table)); zend_clean_and_cache_symbol_table(EX(symbol_table));