Skip to content

Fix GH-16879: JIT dead code skipping does not update call_level #16939

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 28 additions & 1 deletion ext/opcache/jit/zend_jit.c
Original file line number Diff line number Diff line change
Expand Up @@ -2576,7 +2576,34 @@ static int zend_jit(const zend_op_array *op_array, zend_ssa *ssa, const zend_op
}
/* THROW and EXIT may be used in the middle of BB */
/* don't generate code for the rest of BB */
i = end;

/* Skip current opline for call_level computation
* Don't include last opline because end of loop already checks call level of last opline */
i++;
for (; i < end; i++) {
opline = op_array->opcodes + i;
switch (opline->opcode) {
case ZEND_INIT_FCALL:
case ZEND_INIT_FCALL_BY_NAME:
case ZEND_INIT_NS_FCALL_BY_NAME:
case ZEND_INIT_METHOD_CALL:
case ZEND_INIT_DYNAMIC_CALL:
case ZEND_INIT_STATIC_METHOD_CALL:
case ZEND_INIT_PARENT_PROPERTY_HOOK_CALL:
case ZEND_INIT_USER_CALL:
case ZEND_NEW:
call_level++;
break;
case ZEND_DO_FCALL:
case ZEND_DO_ICALL:
case ZEND_DO_UCALL:
case ZEND_DO_FCALL_BY_NAME:
case ZEND_CALLABLE_CONVERT:
call_level--;
break;
}
}
opline = op_array->opcodes + i;
break;
/* stackless execution */
case ZEND_INCLUDE_OR_EVAL:
Expand Down
22 changes: 22 additions & 0 deletions ext/opcache/tests/jit/gh16879.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
--TEST--
GH-16879 (JIT dead code skipping does not update call_level)
--EXTENSIONS--
opcache
--INI--
opcache.enable=1
opcache.enable_cli=1
opcache.file_update_protection=0
opcache.jit_buffer_size=32M
opcache.jit=1235
opcache.jit_hot_func=1
--FILE--
<?php
match(0){};
var_dump(new stdClass);
var_dump(3);
?>
--EXPECTF--
Fatal error: Uncaught UnhandledMatchError: Unhandled match case 0 in %s:%d
Stack trace:
#0 {main}
thrown in %s on line %d