Skip to content

Commit 36891a6

Browse files
authored
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.
1 parent 88f546b commit 36891a6

File tree

2 files changed

+16
-16
lines changed

2 files changed

+16
-16
lines changed

Zend/zend_vm_def.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5962,16 +5962,16 @@ ZEND_VM_HANDLER(68, ZEND_NEW, UNUSED|CLASS_FETCH|CONST|VAR, UNUSED|CACHE_SLOT, N
59625962

59635963
constructor = Z_OBJ_HT_P(result)->get_constructor(Z_OBJ_P(result));
59645964
if (constructor == NULL) {
5965-
if (UNEXPECTED(EG(exception))) {
5966-
HANDLE_EXCEPTION();
5967-
}
5968-
59695965
/* If there are no arguments, skip over the DO_FCALL opcode. We check if the next
59705966
* opcode is DO_FCALL in case EXT instructions are used. */
59715967
if (EXPECTED(opline->extended_value == 0 && (opline+1)->opcode == ZEND_DO_FCALL)) {
59725968
ZEND_VM_NEXT_OPCODE_EX(1, 2);
59735969
}
59745970

5971+
if (UNEXPECTED(EG(exception))) {
5972+
HANDLE_EXCEPTION();
5973+
}
5974+
59755975
/* Perform a dummy function call */
59765976
call = zend_vm_stack_push_call_frame(
59775977
ZEND_CALL_FUNCTION, (zend_function *) &zend_pass_function,

Zend/zend_vm_execute.h

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

0 commit comments

Comments
 (0)