Skip to content

Commit 438cd86

Browse files
committed
Removed unnecessary checks
1 parent ff1e1d7 commit 438cd86

File tree

4 files changed

+14
-10
lines changed

4 files changed

+14
-10
lines changed

Zend/zend_execute.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -287,17 +287,21 @@ static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC)
287287
}
288288
}
289289

290-
static zend_always_inline void zend_vm_stack_clear_multiple(TSRMLS_D)
290+
static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC)
291291
{
292292
void **p = EG(argument_stack)->top - 1;
293-
int delete_count = (int)(zend_uintptr_t) *p;
293+
void **end = p - (int)(zend_uintptr_t)*p;
294294

295-
while (--delete_count>=0) {
295+
while (p != end) {
296296
zval *q = *(zval **)(--p);
297297
*p = NULL;
298298
i_zval_ptr_dtor(q ZEND_FILE_LINE_CC);
299299
}
300-
zend_vm_stack_free_int(p TSRMLS_CC);
300+
if (nested) {
301+
EG(argument_stack)->top = p;
302+
} else {
303+
zend_vm_stack_free_int(p TSRMLS_CC);
304+
}
301305
}
302306

303307
static zend_always_inline int zend_vm_stack_get_args_count_ex(zend_execute_data *ex)

Zend/zend_execute_API.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
841841
if (i || UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (EG(argument_stack)->top))) {
842842
/* hack to clean up the stack */
843843
zend_vm_stack_push((void *) (zend_uintptr_t)i TSRMLS_CC);
844-
zend_vm_stack_clear_multiple(TSRMLS_C);
844+
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
845845
}
846846

847847
zend_error(E_WARNING, "Parameter %d to %s%s%s() expected to be a reference, value given",
@@ -995,7 +995,7 @@ int zend_call_function(zend_fcall_info *fci, zend_fcall_info_cache *fci_cache TS
995995
*fci->retval_ptr_ptr = NULL;
996996
}
997997
}
998-
zend_vm_stack_clear_multiple(TSRMLS_C);
998+
zend_vm_stack_clear_multiple(0 TSRMLS_CC);
999999

10001000
if (EG(This)) {
10011001
zval_ptr_dtor(&EG(This));

Zend/zend_vm_def.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1922,7 +1922,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
19221922

19231923
EX(call)--;
19241924

1925-
zend_vm_stack_clear_multiple(TSRMLS_C);
1925+
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
19261926

19271927
if (UNEXPECTED(EG(exception) != NULL)) {
19281928
zend_throw_exception_internal(NULL TSRMLS_CC);
@@ -2098,7 +2098,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
20982098

20992099
EX(call)--;
21002100

2101-
zend_vm_stack_clear_multiple(TSRMLS_C);
2101+
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
21022102

21032103
if (UNEXPECTED(EG(exception) != NULL)) {
21042104
zend_throw_exception_internal(NULL TSRMLS_CC);

Zend/zend_vm_execute.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static int ZEND_FASTCALL zend_leave_helper_SPEC(ZEND_OPCODE_HANDLER_ARGS)
463463

464464
EX(call)--;
465465

466-
zend_vm_stack_clear_multiple(TSRMLS_C);
466+
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
467467

468468
if (UNEXPECTED(EG(exception) != NULL)) {
469469
zend_throw_exception_internal(NULL TSRMLS_CC);
@@ -639,7 +639,7 @@ static int ZEND_FASTCALL zend_do_fcall_common_helper_SPEC(ZEND_OPCODE_HANDLER_AR
639639

640640
EX(call)--;
641641

642-
zend_vm_stack_clear_multiple(TSRMLS_C);
642+
zend_vm_stack_clear_multiple(1 TSRMLS_CC);
643643

644644
if (UNEXPECTED(EG(exception) != NULL)) {
645645
zend_throw_exception_internal(NULL TSRMLS_CC);

0 commit comments

Comments
 (0)