summaryrefslogtreecommitdiff
path: root/Zend/zend_vm_execute.h
diff options
context:
space:
mode:
Diffstat (limited to 'Zend/zend_vm_execute.h')
-rw-r--r--Zend/zend_vm_execute.h82
1 files changed, 47 insertions, 35 deletions
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 4b09ac05a3..7a31d2685e 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -1129,13 +1129,15 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
- if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
- && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
- zend_vm_stack_free_call_frame(call);
- zend_rethrow_exception(execute_data);
- UNDEF_RESULT();
- HANDLE_EXCEPTION();
- }
+
+#if ZEND_DEBUG
+ /* Type checks for internal functions are usually only performed by zpp.
+ * In debug mode we additionally run arginfo checks to detect cases where
+ * arginfo and zpp went out of sync. */
+ zend_bool wrong_arg_types =
+ (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
+ !zend_verify_internal_arg_types(fbc, call);
+#endif
ret = 0 ? EX_VAR(opline->result.var) : &retval;
ZVAL_NULL(ret);
@@ -1144,6 +1146,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
#if ZEND_DEBUG
if (!EG(exception) && call->func) {
+ ZEND_ASSERT(!wrong_arg_types && "Arginfo / zpp type mismatch?");
ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
zend_verify_internal_return_type(call->func, ret));
ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
@@ -1205,13 +1208,15 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
- if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
- && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
- zend_vm_stack_free_call_frame(call);
- zend_rethrow_exception(execute_data);
- UNDEF_RESULT();
- HANDLE_EXCEPTION();
- }
+
+#if ZEND_DEBUG
+ /* Type checks for internal functions are usually only performed by zpp.
+ * In debug mode we additionally run arginfo checks to detect cases where
+ * arginfo and zpp went out of sync. */
+ zend_bool wrong_arg_types =
+ (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
+ !zend_verify_internal_arg_types(fbc, call);
+#endif
ret = 1 ? EX_VAR(opline->result.var) : &retval;
ZVAL_NULL(ret);
@@ -1220,6 +1225,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_BY_NAME_S
#if ZEND_DEBUG
if (!EG(exception) && call->func) {
+ ZEND_ASSERT(!wrong_arg_types && "Arginfo / zpp type mismatch?");
ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
zend_verify_internal_return_type(call->func, ret));
ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
@@ -1291,11 +1297,14 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
- if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
- && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
- UNDEF_RESULT();
- goto fcall_end;
- }
+#if ZEND_DEBUG
+ /* Type checks for internal functions are usually only performed by zpp.
+ * In debug mode we additionally run arginfo checks to detect cases where
+ * arginfo and zpp went out of sync. */
+ zend_bool wrong_arg_types =
+ (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
+ !zend_verify_internal_arg_types(fbc, call);
+#endif
ret = 0 ? EX_VAR(opline->result.var) : &retval;
ZVAL_NULL(ret);
@@ -1309,6 +1318,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
#if ZEND_DEBUG
if (!EG(exception) && call->func) {
+ ZEND_ASSERT(!wrong_arg_types && "Arginfo / zpp type mismatch?");
ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
zend_verify_internal_return_type(call->func, ret));
ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
@@ -1324,7 +1334,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
}
}
-fcall_end:
if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS)) {
OBJ_RELEASE(Z_OBJ(call->This));
}
@@ -1386,11 +1395,14 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
call->prev_execute_data = execute_data;
EG(current_execute_data) = call;
- if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
- && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
- UNDEF_RESULT();
- goto fcall_end;
- }
+#if ZEND_DEBUG
+ /* Type checks for internal functions are usually only performed by zpp.
+ * In debug mode we additionally run arginfo checks to detect cases where
+ * arginfo and zpp went out of sync. */
+ zend_bool wrong_arg_types =
+ (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
+ !zend_verify_internal_arg_types(fbc, call);
+#endif
ret = 1 ? EX_VAR(opline->result.var) : &retval;
ZVAL_NULL(ret);
@@ -1404,6 +1416,7 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
#if ZEND_DEBUG
if (!EG(exception) && call->func) {
+ ZEND_ASSERT(!wrong_arg_types && "Arginfo / zpp type mismatch?");
ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
zend_verify_internal_return_type(call->func, ret));
ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
@@ -1419,7 +1432,6 @@ static ZEND_VM_HOT ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_DO_FCALL_SPEC_RETV
}
}
-fcall_end:
if (UNEXPECTED(ZEND_CALL_INFO(call) & ZEND_CALL_RELEASE_THIS)) {
OBJ_RELEASE(Z_OBJ(call->This));
}
@@ -2418,14 +2430,14 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z
EG(current_execute_data) = call;
- if (UNEXPECTED(fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS)
- && UNEXPECTED(!zend_verify_internal_arg_types(fbc, call))) {
- zend_vm_stack_free_call_frame(call);
- if (ret) {
- ZVAL_UNDEF(ret);
- }
- goto call_trampoline_end;
- }
+#if ZEND_DEBUG
+ /* Type checks for internal functions are usually only performed by zpp.
+ * In debug mode we additionally run arginfo checks to detect cases where
+ * arginfo and zpp went out of sync. */
+ zend_bool wrong_arg_types =
+ (fbc->common.fn_flags & ZEND_ACC_HAS_TYPE_HINTS) &&
+ !zend_verify_internal_arg_types(fbc, call);
+#endif
if (ret == NULL) {
ZVAL_NULL(&retval);
@@ -2441,6 +2453,7 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z
#if ZEND_DEBUG
if (!EG(exception) && call->func) {
+ ZEND_ASSERT(!wrong_arg_types && "Arginfo / zpp type mismatch?");
ZEND_ASSERT(!(call->func->common.fn_flags & ZEND_ACC_HAS_RETURN_TYPE) ||
zend_verify_internal_return_type(call->func, ret));
ZEND_ASSERT((call->func->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)
@@ -2457,7 +2470,6 @@ static ZEND_OPCODE_HANDLER_RET ZEND_FASTCALL ZEND_CALL_TRAMPOLINE_SPEC_HANDLER(Z
}
}
-call_trampoline_end:
execute_data = EG(current_execute_data);
if (!EX(func) || !ZEND_USER_CODE(EX(func)->type) || (call_info & ZEND_CALL_TOP)) {