Skip to content

Commit ad28e92

Browse files
committed
Move live range check into cleanup_call
1 parent a90cffd commit ad28e92

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
@@ -3883,9 +3883,27 @@ static zend_always_inline zend_generator *zend_get_running_generator(EXECUTE_DAT
38833883
}
38843884
/* }}} */
38853885

3886+
/* TODO Can this be done using find_live_range? */
3887+
static bool is_in_silence_live_range(const zend_op_array op_array, uint32_t op_num) {
3888+
for (int i = 0; i < op_array.last_live_range; i++) {
3889+
zend_live_range range = op_array.live_range[i];
3890+
if (op_num >= range.start && op_num < range.end
3891+
&& (range.var & ZEND_LIVE_MASK) == ZEND_LIVE_SILENCE) {
3892+
return true;
3893+
}
3894+
}
3895+
return false;
3896+
}
3897+
38863898
static void cleanup_unfinished_calls(zend_execute_data *execute_data, uint32_t op_num) /* {{{ */
38873899
{
38883900
if (UNEXPECTED(EX(call))) {
3901+
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
3902+
* However, this can only happen if the exception is an instance of Exception
3903+
* (Error never gets suppressed) */
3904+
if (UNEXPECTED(is_in_silence_live_range(EX(func)->op_array, op_num))) {
3905+
return;
3906+
}
38893907
zend_execute_data *call = EX(call);
38903908
zend_op *opline = EX(func)->op_array.opcodes + op_num;
38913909
int level;
@@ -4028,18 +4046,6 @@ static const zend_live_range *find_live_range(const zend_op_array *op_array, uin
40284046
}
40294047
/* }}} */
40304048

4031-
/* TODO Can this be done using find_live_range? */
4032-
static bool is_in_silence_live_range(const zend_op_array op_array, uint32_t op_num) {
4033-
for (int i = 0; i < op_array.last_live_range; i++) {
4034-
zend_live_range range = op_array.live_range[i];
4035-
if (op_num >= range.start && op_num < range.end
4036-
&& (range.var & ZEND_LIVE_MASK) == ZEND_LIVE_SILENCE) {
4037-
return true;
4038-
}
4039-
}
4040-
return false;
4041-
}
4042-
40434049
static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) /* {{{ */
40444050
{
40454051
int i;

Zend/zend_vm_def.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7881,12 +7881,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
78817881
}
78827882
}
78837883

7884-
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
7885-
* However, this can only happen if the exception is an instance of Exception
7886-
* (Error never gets suppressed) */
7887-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
7888-
cleanup_unfinished_calls(execute_data, throw_op_num);
7889-
}
7884+
cleanup_unfinished_calls(execute_data, throw_op_num);
78907885

78917886
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {
78927887
switch (throw_op->opcode) {

Zend/zend_vm_execute.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3149,12 +3149,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_HANDLE_EXCEPTION_SPEC_HANDLER(
31493149
}
31503150
}
31513151

3152-
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
3153-
* However, this can only happen if the exception is an instance of Exception
3154-
* (Error never gets suppressed) */
3155-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
3156-
cleanup_unfinished_calls(execute_data, throw_op_num);
3157-
}
3152+
cleanup_unfinished_calls(execute_data, throw_op_num);
31583153

31593154
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {
31603155
switch (throw_op->opcode) {

0 commit comments

Comments
 (0)