Skip to content

Commit ff1e1d7

Browse files
committed
Removed redundand checks from release build
1 parent 4b1b115 commit ff1e1d7

File tree

4 files changed

+11
-40
lines changed

4 files changed

+11
-40
lines changed

Zend/zend.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,7 @@ char *alloca ();
225225
#define ZEND_FILE_LINE_EMPTY_CC , ZEND_FILE_LINE_EMPTY_C
226226
#define ZEND_FILE_LINE_ORIG_RELAY_C __zend_orig_filename, __zend_orig_lineno
227227
#define ZEND_FILE_LINE_ORIG_RELAY_CC , ZEND_FILE_LINE_ORIG_RELAY_C
228+
#define ZEND_ASSERT(c) assert(c)
228229
#else
229230
#define ZEND_FILE_LINE_D
230231
#define ZEND_FILE_LINE_DC
@@ -238,6 +239,7 @@ char *alloca ();
238239
#define ZEND_FILE_LINE_EMPTY_CC
239240
#define ZEND_FILE_LINE_ORIG_RELAY_C
240241
#define ZEND_FILE_LINE_ORIG_RELAY_CC
242+
#define ZEND_ASSERT(c)
241243
#endif /* ZEND_DEBUG */
242244

243245
#ifdef ZTS

Zend/zend_execute.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -86,11 +86,10 @@ static zend_always_inline void zend_pzval_unlock_func(zval *z, zend_free_op *sho
8686
static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
8787
{
8888
if (!Z_DELREF_P(z)) {
89-
if (z != &EG(uninitialized_zval)) {
90-
GC_REMOVE_ZVAL_FROM_BUFFER(z);
91-
zval_dtor(z);
92-
efree(z);
93-
}
89+
ZEND_ASSERT(z != &EG(uninitialized_zval));
90+
GC_REMOVE_ZVAL_FROM_BUFFER(z);
91+
zval_dtor(z);
92+
efree(z);
9493
}
9594
}
9695

Zend/zend_execute.h

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,6 @@ ZEND_API void zend_execute(zend_op_array *op_array TSRMLS_DC);
6161
ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC);
6262
ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC);
6363
ZEND_API int zend_is_true(zval *op);
64-
#define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
65-
static zend_always_inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC)
66-
{
67-
TSRMLS_FETCH();
68-
69-
if (p!=EG(uninitialized_zval_ptr)) {
70-
FREE_ZVAL_REL(p);
71-
}
72-
}
7364
ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC);
7465
ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC);
7566
ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC);
@@ -85,11 +76,10 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC)
8576
if (!Z_DELREF_P(zval_ptr)) {
8677
TSRMLS_FETCH();
8778

88-
if (zval_ptr != &EG(uninitialized_zval)) {
89-
GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
90-
zval_dtor(zval_ptr);
91-
efree_rel(zval_ptr);
92-
}
79+
ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval));
80+
GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr);
81+
zval_dtor(zval_ptr);
82+
efree_rel(zval_ptr);
9383
} else {
9484
TSRMLS_FETCH();
9585

Zend/zend_execute_API.c

Lines changed: 1 addition & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -425,27 +425,7 @@ ZEND_API zend_bool zend_is_executing(TSRMLS_D) /* {{{ */
425425

426426
ZEND_API void _zval_ptr_dtor(zval **zval_ptr ZEND_FILE_LINE_DC) /* {{{ */
427427
{
428-
#if DEBUG_ZEND>=2
429-
printf("Reducing refcount for %x (%x): %d->%d\n", *zval_ptr, zval_ptr, Z_REFCOUNT_PP(zval_ptr), Z_REFCOUNT_PP(zval_ptr) - 1);
430-
#endif
431-
Z_DELREF_PP(zval_ptr);
432-
if (Z_REFCOUNT_PP(zval_ptr) == 0) {
433-
TSRMLS_FETCH();
434-
435-
if (*zval_ptr != &EG(uninitialized_zval)) {
436-
GC_REMOVE_ZVAL_FROM_BUFFER(*zval_ptr);
437-
zval_dtor(*zval_ptr);
438-
efree_rel(*zval_ptr);
439-
}
440-
} else {
441-
TSRMLS_FETCH();
442-
443-
if (Z_REFCOUNT_PP(zval_ptr) == 1) {
444-
Z_UNSET_ISREF_PP(zval_ptr);
445-
}
446-
447-
GC_ZVAL_CHECK_POSSIBLE_ROOT(*zval_ptr);
448-
}
428+
i_zval_ptr_dtor(*zval_ptr ZEND_FILE_LINE_RELAY_CC);
449429
}
450430
/* }}} */
451431

0 commit comments

Comments
 (0)