Skip to content

Commit 27e01cd

Browse files
committed
Implemented HYBRID VM instruction dispatch method that takes advantages of both CALL and GOTO VMs.
1 parent 9d6b743 commit 27e01cd

File tree

7 files changed

+310
-124
lines changed

7 files changed

+310
-124
lines changed

Zend/zend_vm.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ ZEND_API void zend_vm_set_opcode_handler(zend_op* opcode);
2828
ZEND_API void zend_vm_set_opcode_handler_ex(zend_op* opcode, uint32_t op1_info, uint32_t op2_info, uint32_t res_info);
2929
ZEND_API void zend_serialize_opcode_handler(zend_op *op);
3030
ZEND_API void zend_deserialize_opcode_handler(zend_op *op);
31+
ZEND_API const void *zend_get_real_opcode_handler(const zend_op *op);
32+
ZEND_API const zend_op *zend_get_real_exit_op(void);
3133
ZEND_API int zend_vm_call_opcode_handler(zend_execute_data *ex);
34+
ZEND_API int zend_vm_kind(void);
3235

3336
END_EXTERN_C()
3437

Zend/zend_vm_def.h

Lines changed: 52 additions & 52 deletions
Large diffs are not rendered by default.

Zend/zend_vm_execute.h

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59177,6 +59177,38 @@ ZEND_API void zend_deserialize_opcode_handler(zend_op *op)
5917759177
op->handler = zend_opcode_handlers[(zend_uintptr_t)op->handler];
5917859178
}
5917959179

59180+
ZEND_API const void *zend_get_real_opcode_handler(const zend_op *op)
59181+
{
59182+
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL
59183+
return op->handler;
59184+
#elif ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
59185+
zval *zv;
59186+
59187+
if (!zend_handlers_table) {
59188+
init_opcode_serialiser();
59189+
}
59190+
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(zend_uintptr_t)op->handler);
59191+
ZEND_ASSERT(zv != NULL);
59192+
return zend_opcode_real_handlers[Z_LVAL_P(zv)];
59193+
#else
59194+
return NULL;
59195+
#endif
59196+
}
59197+
59198+
ZEND_API const zend_op *zend_get_real_exit_op(void)
59199+
{
59200+
#if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
59201+
return &hybrid_return_op;
59202+
#else
59203+
return NULL;
59204+
#endif
59205+
}
59206+
59207+
ZEND_API int zend_vm_kind(void)
59208+
{
59209+
return ZEND_VM_KIND;
59210+
}
59211+
5918059212
static const void *zend_vm_get_opcode_handler_ex(uint32_t spec, const zend_op* op)
5918159213
{
5918259214
static const int zend_vm_decode[] = {

Zend/zend_vm_execute.skl

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,3 +83,35 @@ ZEND_API void zend_deserialize_opcode_handler(zend_op *op)
8383
op->handler = zend_opcode_handlers[(zend_uintptr_t)op->handler];
8484
}
8585

86+
ZEND_API const void *zend_get_real_opcode_handler(const zend_op *op)
87+
{
88+
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL
89+
return op->handler;
90+
#elif ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
91+
zval *zv;
92+
93+
if (!zend_handlers_table) {
94+
init_opcode_serialiser();
95+
}
96+
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(zend_uintptr_t)op->handler);
97+
ZEND_ASSERT(zv != NULL);
98+
return zend_opcode_real_handlers[Z_LVAL_P(zv)];
99+
#else
100+
return NULL;
101+
#endif
102+
}
103+
104+
ZEND_API const zend_op *zend_get_real_exit_op(void)
105+
{
106+
#if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
107+
return &hybrid_return_op;
108+
#else
109+
return NULL;
110+
#endif
111+
}
112+
113+
ZEND_API int zend_vm_kind(void)
114+
{
115+
return ZEND_VM_KIND;
116+
}
117+

0 commit comments

Comments
 (0)