Skip to content

Commit 82c64a8

Browse files
committed
Adapt generator interceptor to tail call VM
Signed-off-by: Bob Weinand <[email protected]>
1 parent efb2d1e commit 82c64a8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

zend_abstract_interface/interceptor/php8/interceptor.c

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,12 +751,16 @@ static zend_never_inline const void *zai_interceptor_handle_created_generator_fu
751751
return zai_interceptor_generator_post_op[2].handler;
752752
}
753753

754+
#ifndef ZEND_OPCODE_HANDLER_CCONV
755+
#define ZEND_OPCODE_HANDLER_CCONV ZEND_FASTCALL
756+
#endif
757+
754758
#ifdef __GNUC__
755759
bool zai_interceptor_avoid_compile_opt = true;
756760
uintptr_t zai_interceptor_dummy_label_use;
757761

758762
// a bit of stuff to make the function control flow undecidable for the compiler, so that it doesn't optimize anything away
759-
static void *ZEND_FASTCALL zai_interceptor_handle_created_generator_goto(void) {
763+
static void *ZEND_OPCODE_HANDLER_CCONV zai_interceptor_handle_created_generator_goto(void) {
760764
if (zai_interceptor_avoid_compile_opt) {
761765
uintptr_t tmp = (uintptr_t)&&zai_interceptor_handle_created_generator_goto_LABEL2;
762766
zai_interceptor_dummy_label_use = tmp;
@@ -773,10 +777,17 @@ static void *ZEND_FASTCALL zai_interceptor_handle_created_generator_goto(void) {
773777
#endif
774778

775779
// Windows & Mac use call VM without IP/FP
776-
static int ZEND_FASTCALL zai_interceptor_handle_created_generator_call(void) {
780+
#if PHP_VERSION_ID < 80500
781+
static int ZEND_OPCODE_HANDLER_CCONV zai_interceptor_handle_created_generator_call(void) {
777782
zai_interceptor_handle_created_generator_func();
778783
return 0 /* ZEND_VM_CONTINUE */;
779784
}
785+
#else
786+
static const zend_op *ZEND_OPCODE_HANDLER_CCONV zai_interceptor_handle_created_generator_call(void) {
787+
zai_interceptor_handle_created_generator_func();
788+
return &zai_interceptor_generator_post_op[2] /* ZEND_VM_CONTINUE */;
789+
}
790+
#endif
780791

781792
static zend_object *(*generator_create_prev)(zend_class_entry *class_type);
782793
static zend_object *zai_interceptor_generator_create(zend_class_entry *class_type) {

0 commit comments

Comments
 (0)