Skip to content

Tail call VM [2] #18720

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

Draft
wants to merge 11 commits into
base: master
Choose a base branch
from
Draft
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
3 changes: 2 additions & 1 deletion Zend/zend_compile.h
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include "zend_types.h"
#include "zend_map_ptr.h"
#include "zend_alloc.h"
#include "zend_vm_opcodes.h"

#include <stdarg.h>
#include <stdint.h>
Expand Down Expand Up @@ -135,7 +136,7 @@ void zend_const_expr_to_zval(zval *result, zend_ast **ast_ptr, bool allow_dynami
typedef int (*user_opcode_handler_t) (zend_execute_data *execute_data);

struct _zend_op {
const void *handler;
zend_vm_opcode_handler_t handler;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typed handler pointers in a few places to prevent confusion between orig handler and call handlers (zend_vm_opcode_handler_t / zend_vm_opcode_handler_func_t).

znode_op op1;
znode_op op2;
znode_op result;
Expand Down
18 changes: 18 additions & 0 deletions Zend/zend_portability.h
Original file line number Diff line number Diff line change
Expand Up @@ -318,6 +318,24 @@ char *alloca();
# define ZEND_FASTCALL
#endif

/* Compilers may report to have preserve_none, but support it only on some architectures */
#if __has_attribute(preserve_none) && (defined(_M_X64) || defined(__x86_64__) || defined(_M_ARM64) || defined(__aarch64__))
# define HAVE_PRESERVE_NONE
# define ZEND_PRESERVE_NONE __attribute__((preserve_none))
#else
# define ZEND_PRESERVE_NONE
#endif

#if __has_attribute(musttail)
# define HAVE_MUSTTAIL
# define ZEND_MUSTTAIL __attribute__((musttail))
#endif

#if __has_attribute(sysv_abi)
# define HAVE_SYSV_ABI
# define ZEND_SYSV_ABI __attribute__((sysv_abi))
#endif

#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)
# define HAVE_NORETURN
# define ZEND_NORETURN __attribute__((noreturn))
Expand Down
6 changes: 3 additions & 3 deletions Zend/zend_vm_def.h
Original file line number Diff line number Diff line change
Expand Up @@ -4917,7 +4917,7 @@ ZEND_VM_HOT_SEND_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, CONST|UNUSED|NUM, SPE
ZEND_VM_C_GOTO(send_val_by_ref);
}
} else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
ZEND_VM_C_LABEL(send_val_by_ref):
ZEND_VM_C_LABEL(send_val_by_ref):;
ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper, _arg_num, arg_num, _arg, arg);
}
value = GET_OP1_ZVAL_PTR(BP_VAR_R);
Expand Down Expand Up @@ -8231,9 +8231,9 @@ ZEND_VM_HANDLER(150, ZEND_USER_OPCODE, ANY, ANY)
case ZEND_USER_OPCODE_LEAVE:
ZEND_VM_LEAVE();
case ZEND_USER_OPCODE_DISPATCH:
ZEND_VM_DISPATCH(opline->opcode, opline);
ZEND_VM_DISPATCH_OPCODE(opline->opcode, opline);
default:
ZEND_VM_DISPATCH((uint8_t)(ret & 0xff), opline);
ZEND_VM_DISPATCH_OPCODE((uint8_t)(ret & 0xff), opline);
}
}

Expand Down
Loading
Loading