Skip to content

Commit b92f8fb

Browse files
committed
Tail call VM
1 parent 399cb4c commit b92f8fb

17 files changed

+60733
-1794
lines changed

Zend/zend_compile.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
#include "zend_types.h"
2525
#include "zend_map_ptr.h"
2626
#include "zend_alloc.h"
27+
#include "zend_vm_opcodes.h"
2728

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

137138
struct _zend_op {
138-
const void *handler;
139+
zend_vm_opcode_handler_t handler;
139140
znode_op op1;
140141
znode_op op2;
141142
znode_op result;

Zend/zend_portability.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,18 @@ char *alloca();
313313
# define ZEND_FASTCALL
314314
#endif
315315

316+
#if __has_attribute(preserve_none) && !defined(__SANITIZE_ADDRESS__)
317+
# define HAVE_PRESERVE_NONE
318+
# define ZEND_PRESERVE_NONE __attribute__((preserve_none))
319+
#else
320+
# define ZEND_PRESERVE_NONE
321+
#endif
322+
323+
#if __has_attribute(musttail)
324+
# define HAVE_MUSTTAIL
325+
# define ZEND_MUSTTAIL __attribute__((musttail))
326+
#endif
327+
316328
#if (defined(__GNUC__) && __GNUC__ >= 3 && !defined(__INTEL_COMPILER) && !defined(__APPLE__) && !defined(__hpux) && !defined(_AIX) && !defined(__osf__)) || __has_attribute(noreturn)
317329
# define HAVE_NORETURN
318330
# define ZEND_NORETURN __attribute__((noreturn))

Zend/zend_vm.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
#define ZEND_VM_H
2121

2222
#include "zend_portability.h"
23+
#include "zend_vm_opcodes.h"
2324

2425
typedef struct _zend_op zend_op;
2526
typedef struct _zend_execute_data zend_execute_data;
@@ -30,7 +31,7 @@ ZEND_API void ZEND_FASTCALL zend_vm_set_opcode_handler(zend_op* opcode);
3031
ZEND_API void ZEND_FASTCALL zend_vm_set_opcode_handler_ex(zend_op* opcode, uint32_t op1_info, uint32_t op2_info, uint32_t res_info);
3132
ZEND_API void ZEND_FASTCALL zend_serialize_opcode_handler(zend_op *op);
3233
ZEND_API void ZEND_FASTCALL zend_deserialize_opcode_handler(zend_op *op);
33-
ZEND_API const void* ZEND_FASTCALL zend_get_opcode_handler_func(const zend_op *op);
34+
ZEND_API zend_vm_opcode_handler_func_t ZEND_FASTCALL zend_get_opcode_handler_func(const zend_op *op);
3435
ZEND_API const zend_op *zend_get_halt_op(void);
3536
ZEND_API int ZEND_FASTCALL zend_vm_call_opcode_handler(zend_execute_data *ex);
3637
ZEND_API int zend_vm_kind(void);

Zend/zend_vm_def.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4917,7 +4917,7 @@ ZEND_VM_HOT_SEND_HANDLER(116, ZEND_SEND_VAL_EX, CONST|TMP, CONST|UNUSED|NUM, SPE
49174917
ZEND_VM_C_GOTO(send_val_by_ref);
49184918
}
49194919
} else if (ARG_MUST_BE_SENT_BY_REF(EX(call)->func, arg_num)) {
4920-
ZEND_VM_C_LABEL(send_val_by_ref):
4920+
ZEND_VM_C_LABEL(send_val_by_ref):;
49214921
ZEND_VM_DISPATCH_TO_HELPER(zend_cannot_pass_by_ref_helper, _arg_num, arg_num, _arg, arg);
49224922
}
49234923
value = GET_OP1_ZVAL_PTR(BP_VAR_R);
@@ -8229,9 +8229,9 @@ ZEND_VM_HANDLER(150, ZEND_USER_OPCODE, ANY, ANY)
82298229
case ZEND_USER_OPCODE_LEAVE:
82308230
ZEND_VM_LEAVE();
82318231
case ZEND_USER_OPCODE_DISPATCH:
8232-
ZEND_VM_DISPATCH(opline->opcode, opline);
8232+
ZEND_VM_DISPATCH_OPCODE(opline->opcode, opline);
82338233
default:
8234-
ZEND_VM_DISPATCH((uint8_t)(ret & 0xff), opline);
8234+
ZEND_VM_DISPATCH_OPCODE((uint8_t)(ret & 0xff), opline);
82358235
}
82368236
}
82378237

0 commit comments

Comments
 (0)