1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

Move VM exception checks (#18730)

Checking the non-exception path without arguments first, this avoids a redundant check in the case without arguments. The exception path may become more expensive, but we don't optimize for exception flow, rather we optimize for the happy flow. The other paths are unaffected.
This commit is contained in:
Niels Dossche
2025-06-02 23:35:42 +02:00
committed by GitHub
parent 88f546b166
commit 36891a6775
2 changed files with 16 additions and 16 deletions

View File

@@ -5962,16 +5962,16 @@ ZEND_VM_HANDLER(68, ZEND_NEW, UNUSED|CLASS_FETCH|CONST|VAR, UNUSED|CACHE_SLOT, N
constructor = Z_OBJ_HT_P(result)->get_constructor(Z_OBJ_P(result));
if (constructor == NULL) {
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* If there are no arguments, skip over the DO_FCALL opcode. We check if the next
* opcode is DO_FCALL in case EXT instructions are used. */
if (EXPECTED(opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL)) {
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* Perform a dummy function call */
call = zend_vm_stack_push_call_frame(
ZEND_CALL_FUNCTION, (zend_function *) &zend_pass_function,

24
Zend/zend_vm_execute.h generated
View File

@@ -11046,16 +11046,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NEW_SPEC_CONST_UNUSED_HANDLER(
constructor = Z_OBJ_HT_P(result)->get_constructor(Z_OBJ_P(result));
if (constructor == NULL) {
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* If there are no arguments, skip over the DO_FCALL opcode. We check if the next
* opcode is DO_FCALL in case EXT instructions are used. */
if (EXPECTED(opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL)) {
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* Perform a dummy function call */
call = zend_vm_stack_push_call_frame(
ZEND_CALL_FUNCTION, (zend_function *) &zend_pass_function,
@@ -30594,16 +30594,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NEW_SPEC_VAR_UNUSED_HANDLER(ZE
constructor = Z_OBJ_HT_P(result)->get_constructor(Z_OBJ_P(result));
if (constructor == NULL) {
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* If there are no arguments, skip over the DO_FCALL opcode. We check if the next
* opcode is DO_FCALL in case EXT instructions are used. */
if (EXPECTED(opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL)) {
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* Perform a dummy function call */
call = zend_vm_stack_push_call_frame(
ZEND_CALL_FUNCTION, (zend_function *) &zend_pass_function,
@@ -38059,16 +38059,16 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_NEW_SPEC_UNUSED_UNUSED_HANDLER
constructor = Z_OBJ_HT_P(result)->get_constructor(Z_OBJ_P(result));
if (constructor == NULL) {
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* If there are no arguments, skip over the DO_FCALL opcode. We check if the next
* opcode is DO_FCALL in case EXT instructions are used. */
if (EXPECTED(opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL)) {
ZEND_VM_NEXT_OPCODE_EX(1, 2);
}
if (UNEXPECTED(EG(exception))) {
HANDLE_EXCEPTION();
}
/* Perform a dummy function call */
call = zend_vm_stack_push_call_frame(
ZEND_CALL_FUNCTION, (zend_function *) &zend_pass_function,