Skip to content

Commit bdfa03d

Browse files
committed
Save a TSRMLS_FETCH() for zval_ptr_dtor in executor
This gives me about 9% improvement on Zend/bench.php for a zts build.
1 parent 8748e14 commit bdfa03d

6 files changed

+12
-15
lines changed

Zend/zend_execute.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
9494
}
9595

9696
#undef zval_ptr_dtor
97-
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC)
97+
#define zval_ptr_dtor(pzv) i_zval_ptr_dtor(*(pzv) ZEND_FILE_LINE_CC TSRMLS_CC)
9898

9999
#define PZVAL_UNLOCK(z, f) zend_pzval_unlock_func(z, f, 1 TSRMLS_CC)
100100
#define PZVAL_UNLOCK_EX(z, f, u) zend_pzval_unlock_func(z, f, u TSRMLS_CC)
@@ -1500,7 +1500,7 @@ void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{
15001500
}
15011501
/* }}} */
15021502

1503-
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
1503+
static zend_always_inline void i_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
15041504
{
15051505
zval ***cv = EX_CV_NUM(execute_data, 0);
15061506
zval ***end = cv + EX(op_array)->last_var;
@@ -1513,9 +1513,9 @@ static zend_always_inline void i_free_compiled_variables(zend_execute_data *exec
15131513
}
15141514
/* }}} */
15151515

1516-
void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
1516+
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC) /* {{{ */
15171517
{
1518-
i_free_compiled_variables(execute_data);
1518+
i_free_compiled_variables(execute_data TSRMLS_CC);
15191519
}
15201520
/* }}} */
15211521

Zend/zend_execute.h

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -71,18 +71,14 @@ ZEND_API int zend_eval_stringl_ex(char *str, int str_len, zval *retval_ptr, char
7171
ZEND_API char * zend_verify_arg_class_kind(const zend_arg_info *cur_arg_info, ulong fetch_type, const char **class_name, zend_class_entry **pce TSRMLS_DC);
7272
ZEND_API int zend_verify_arg_error(int error_type, const zend_function *zf, zend_uint arg_num, const char *need_msg, const char *need_kind, const char *given_msg, const char *given_kind TSRMLS_DC);
7373

74-
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
74+
static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC TSRMLS_DC)
7575
{
7676
if (!Z_DELREF_P(zval_ptr)) {
77-
TSRMLS_FETCH();
78-
7977
ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
8078
GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
8179
zval_dtor(zval_ptr);
8280
efree_rel(zval_ptr);
8381
} else {
84-
TSRMLS_FETCH();
85-
8682
if (Z_REFCOUNT_P(zval_ptr) == 1) {
8783
Z_UNSET_ISREF_P(zval_ptr);
8884
}
@@ -295,7 +291,7 @@ static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC
295291
while (p != end) {
296292
zval *q = (zval *) *(--p);
297293
*p = NULL;
298-
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
294+
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC TSRMLS_CC);
299295
}
300296
if (nested) {
301297
EG(argument_stack)->top = p;
@@ -394,7 +390,7 @@ ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const z
394390
ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS);
395391

396392
void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC);
397-
void zend_free_compiled_variables(zend_execute_data *execute_data);
393+
void zend_free_compiled_variables(zend_execute_data *execute_data TSRMLS_DC);
398394

399395
#define CACHED_PTR(num) \
400396
EG(active_op_array)->run_time_cache[(num)]

Zend/zend_execute_API.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -423,7 +423,8 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */
423423

424424
ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
425425
{
426-
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC);
426+
TSRMLS_FETCH();
427+
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC TSRMLS_CC);
427428
}
428429
/* }}} */
429430

Zend/zend_generators.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ ZEND_API void zend_generator_close(zend_generator *generator, zend_bool finished
4646
zend_op_array *op_array = execute_data->op_array;
4747

4848
if (!execute_data->symbol_table) {
49-
zend_free_compiled_variables(execute_data);
49+
zend_free_compiled_variables(execute_data TSRMLS_CC);
5050
} else {
5151
zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC);
5252
}

Zend/zend_vm_def.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1833,7 +1833,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
18331833
EG(current_execute_data) = EX(prev_execute_data);
18341834
EG(opline_ptr) = NULL;
18351835
if (!EG(active_symbol_table)) {
1836-
i_free_compiled_variables(execute_data);
1836+
i_free_compiled_variables(execute_data TSRMLS_CC);
18371837
}
18381838

18391839
zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);

Zend/zend_vm_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
396396
EG(current_execute_data) = EX(prev_execute_data);
397397
EG(opline_ptr) = NULL;
398398
if (!EG(active_symbol_table)) {
399-
i_free_compiled_variables(execute_data);
399+
i_free_compiled_variables(execute_data TSRMLS_CC);
400400
}
401401

402402
zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);

0 commit comments

Comments
 (0)