Skip to content

Commit 9dc134f

Browse files
committed
Move live range check into cleanup_call
1 parent 819f765 commit 9dc134f

File tree

3 files changed

+20
-24
lines changed

3 files changed

+20
-24
lines changed

Zend/zend_execute.c

Lines changed: 18 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3792,9 +3792,27 @@ static zend_always_inline zend_generator *zend_get_running_generator(EXECUTE_DAT
37923792
}
37933793
/* }}} */
37943794

3795+
/* TODO Can this be done using find_live_range? */
3796+
static bool is_in_silence_live_range(const zend_op_array op_array, uint32_t op_num) {
3797+
for (int i = 0; i < op_array.last_live_range; i++) {
3798+
zend_live_range range = op_array.live_range[i];
3799+
if (op_num >= range.start && op_num < range.end
3800+
&& (range.var & ZEND_LIVE_MASK) == ZEND_LIVE_SILENCE) {
3801+
return true;
3802+
}
3803+
}
3804+
return false;
3805+
}
3806+
37953807
static void cleanup_unfinished_calls(zend_execute_data *execute_data, uint32_t op_num) /* {{{ */
37963808
{
37973809
if (UNEXPECTED(EX(call))) {
3810+
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
3811+
* However, this can only happen if the exception is an instance of Exception
3812+
* (Error never gets suppressed) */
3813+
if (UNEXPECTED(is_in_silence_live_range(EX(func)->op_array, op_num))) {
3814+
return;
3815+
}
37983816
zend_execute_data *call = EX(call);
37993817
zend_op *opline = EX(func)->op_array.opcodes + op_num;
38003818
int level;
@@ -3937,18 +3955,6 @@ static const zend_live_range *find_live_range(const zend_op_array *op_array, uin
39373955
}
39383956
/* }}} */
39393957

3940-
/* TODO Can this be done using find_live_range? */
3941-
static bool is_in_silence_live_range(const zend_op_array op_array, uint32_t op_num) {
3942-
for (int i = 0; i < op_array.last_live_range; i++) {
3943-
zend_live_range range = op_array.live_range[i];
3944-
if (op_num >= range.start && op_num < range.end
3945-
&& (range.var & ZEND_LIVE_MASK) == ZEND_LIVE_SILENCE) {
3946-
return true;
3947-
}
3948-
}
3949-
return false;
3950-
}
3951-
39523958
static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) /* {{{ */
39533959
{
39543960
int i;

Zend/zend_vm_def.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7865,12 +7865,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
78657865
}
78667866
}
78677867

7868-
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
7869-
* However, this can only happen if the exception is an instance of Exception
7870-
* (Error never gets suppressed) */
7871-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
7872-
cleanup_unfinished_calls(execute_data, throw_op_num);
7873-
}
7868+
cleanup_unfinished_calls(execute_data, throw_op_num);
78747869

78757870
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {
78767871
switch (throw_op->opcode) {

Zend/zend_vm_execute.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3141,12 +3141,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(
31413141
}
31423142
}
31433143

3144-
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
3145-
* However, this can only happen if the exception is an instance of Exception
3146-
* (Error never gets suppressed) */
3147-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
3148-
cleanup_unfinished_calls(execute_data, throw_op_num);
3149-
}
3144+
cleanup_unfinished_calls(execute_data, throw_op_num);
31503145

31513146
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {
31523147
switch (throw_op->opcode) {

0 commit comments

Comments
 (0)