Skip to content

Commit 9771000

Browse files
committed
Move live range check into cleanup_call
1 parent 83fa045 commit 9771000

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
@@ -4077,9 +4077,27 @@ static zend_always_inline zend_generator *zend_get_running_generator(EXECUTE_DAT
40774077
}
40784078
/* }}} */
40794079

4080+
/* TODO Can this be done using find_live_range? */
4081+
static bool is_in_silence_live_range(const zend_op_array op_array, uint32_t op_num) {
4082+
for (int i = 0; i < op_array.last_live_range; i++) {
4083+
zend_live_range range = op_array.live_range[i];
4084+
if (op_num >= range.start && op_num < range.end
4085+
&& (range.var & ZEND_LIVE_MASK) == ZEND_LIVE_SILENCE) {
4086+
return true;
4087+
}
4088+
}
4089+
return false;
4090+
}
4091+
40804092
static void cleanup_unfinished_calls(zend_execute_data *execute_data, uint32_t op_num) /* {{{ */
40814093
{
40824094
if (UNEXPECTED(EX(call))) {
4095+
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
4096+
* However, this can only happen if the exception is an instance of Exception
4097+
* (Error never gets suppressed) */
4098+
if (UNEXPECTED(is_in_silence_live_range(EX(func)->op_array, op_num))) {
4099+
return;
4100+
}
40834101
zend_execute_data *call = EX(call);
40844102
zend_op *opline = EX(func)->op_array.opcodes + op_num;
40854103
int level;
@@ -4222,18 +4240,6 @@ static const zend_live_range *find_live_range(const zend_op_array *op_array, uin
42224240
}
42234241
/* }}} */
42244242

4225-
/* TODO Can this be done using find_live_range? */
4226-
static bool is_in_silence_live_range(const zend_op_array op_array, uint32_t op_num) {
4227-
for (int i = 0; i < op_array.last_live_range; i++) {
4228-
zend_live_range range = op_array.live_range[i];
4229-
if (op_num >= range.start && op_num < range.end
4230-
&& (range.var & ZEND_LIVE_MASK) == ZEND_LIVE_SILENCE) {
4231-
return true;
4232-
}
4233-
}
4234-
return false;
4235-
}
4236-
42374243
static void cleanup_live_vars(zend_execute_data *execute_data, uint32_t op_num, uint32_t catch_op_num) /* {{{ */
42384244
{
42394245
int i;

Zend/zend_vm_def.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7975,12 +7975,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
79757975
}
79767976
}
79777977

7978-
/* Do not cleanup unfinished calls for SILENCE live range as it might still get executed
7979-
* However, this can only happen if the exception is an instance of Exception
7980-
* (Error never gets suppressed) */
7981-
if (!is_in_silence_live_range(EX(func)->op_array, throw_op_num)) {
7982-
cleanup_unfinished_calls(execute_data, throw_op_num);
7983-
}
7978+
cleanup_unfinished_calls(execute_data, throw_op_num);
79847979

79857980
if (throw_op->result_type & (IS_VAR | IS_TMP_VAR)) {
79867981
switch (throw_op->opcode) {

Zend/zend_vm_execute.h

Lines changed: 1 addition & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)