2004-10-23 05:42:14 +08:00
|
|
|
{%DEFINES%}
|
|
|
|
|
2015-03-13 08:28:21 +08:00
|
|
|
ZEND_API void {%EXECUTOR_NAME%}_ex(zend_execute_data *ex)
|
2012-05-26 23:53:13 +08:00
|
|
|
{
|
|
|
|
DCL_OPLINE
|
|
|
|
|
|
|
|
{%HELPER_VARS%}
|
|
|
|
|
|
|
|
{%INTERNAL_LABELS%}
|
|
|
|
|
|
|
|
LOAD_OPLINE();
|
2016-06-27 15:36:41 +08:00
|
|
|
ZEND_VM_LOOP_INTERRUPT_CHECK();
|
2012-05-26 23:53:13 +08:00
|
|
|
|
2004-10-23 05:42:14 +08:00
|
|
|
while (1) {
|
2016-02-02 10:03:21 +08:00
|
|
|
{%ZEND_VM_CONTINUE_LABEL%}
|
2004-10-23 05:42:14 +08:00
|
|
|
{%ZEND_VM_DISPATCH%} {
|
2007-11-20 17:51:12 +08:00
|
|
|
{%INTERNAL_EXECUTOR%}
|
2004-10-23 05:42:14 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
2015-04-02 18:07:17 +08:00
|
|
|
zend_error_noreturn(E_CORE_ERROR, "Arrived at end of main loop which shouldn't happen");
|
2004-10-23 05:42:14 +08:00
|
|
|
}
|
|
|
|
|
2014-12-14 06:06:14 +08:00
|
|
|
ZEND_API void zend_{%EXECUTOR_NAME%}(zend_op_array *op_array, zval *return_value)
|
2012-05-26 23:53:13 +08:00
|
|
|
{
|
2014-06-27 03:51:14 +08:00
|
|
|
zend_execute_data *execute_data;
|
|
|
|
|
2014-02-10 14:04:30 +08:00
|
|
|
if (EG(exception) != NULL) {
|
2012-11-04 12:48:35 +08:00
|
|
|
return;
|
2014-06-27 03:51:14 +08:00
|
|
|
}
|
|
|
|
|
2016-04-28 20:17:24 +08:00
|
|
|
execute_data = zend_vm_stack_push_call_frame(ZEND_CALL_TOP_CODE | ZEND_CALL_HAS_SYMBOL_TABLE,
|
2015-04-23 17:16:37 +08:00
|
|
|
(zend_function*)op_array, 0, zend_get_called_scope(EG(current_execute_data)), zend_get_this_object(EG(current_execute_data)));
|
2014-07-07 19:50:44 +08:00
|
|
|
if (EG(current_execute_data)) {
|
2014-12-14 06:06:14 +08:00
|
|
|
execute_data->symbol_table = zend_rebuild_symbol_table();
|
2014-06-27 03:51:14 +08:00
|
|
|
} else {
|
2014-07-04 22:03:45 +08:00
|
|
|
execute_data->symbol_table = &EG(symbol_table);
|
2014-06-27 03:51:14 +08:00
|
|
|
}
|
|
|
|
EX(prev_execute_data) = EG(current_execute_data);
|
2017-06-29 15:10:57 +08:00
|
|
|
i_init_code_execute_data(execute_data, op_array, return_value);
|
2014-12-14 06:06:14 +08:00
|
|
|
zend_{%EXECUTOR_NAME%}_ex(execute_data);
|
2015-05-18 17:44:40 +08:00
|
|
|
zend_vm_stack_free_call_frame(execute_data);
|
2012-05-26 23:53:13 +08:00
|
|
|
}
|
|
|
|
|
2004-10-23 05:42:14 +08:00
|
|
|
{%EXTERNAL_EXECUTOR%}
|
|
|
|
|
2007-07-21 08:35:15 +08:00
|
|
|
void {%INITIALIZER_NAME%}(void)
|
2004-10-23 05:42:14 +08:00
|
|
|
{
|
2016-02-02 10:03:21 +08:00
|
|
|
{%EXTERNAL_LABELS%}
|
2004-10-23 05:42:14 +08:00
|
|
|
}
|
2016-03-18 03:00:27 +08:00
|
|
|
|
|
|
|
static HashTable *zend_handlers_table = NULL;
|
|
|
|
|
|
|
|
static void init_opcode_serialiser(void)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
zval tmp;
|
|
|
|
|
|
|
|
zend_handlers_table = malloc(sizeof(HashTable));
|
|
|
|
zend_hash_init_ex(zend_handlers_table, zend_handlers_count, NULL, NULL, 1, 0);
|
|
|
|
zend_hash_real_init(zend_handlers_table, 0);
|
|
|
|
Z_TYPE_INFO(tmp) = IS_LONG;
|
|
|
|
for (i = 0; i < zend_handlers_count; i++) {
|
|
|
|
Z_LVAL(tmp) = i;
|
|
|
|
zend_hash_index_add(zend_handlers_table, (zend_long)(zend_uintptr_t)zend_opcode_handlers[i], &tmp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
ZEND_API void zend_serialize_opcode_handler(zend_op *op)
|
|
|
|
{
|
|
|
|
zval *zv;
|
|
|
|
|
|
|
|
if (!zend_handlers_table) {
|
|
|
|
init_opcode_serialiser();
|
|
|
|
}
|
|
|
|
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(zend_uintptr_t)op->handler);
|
|
|
|
ZEND_ASSERT(zv != NULL);
|
|
|
|
op->handler = (const void *)(zend_uintptr_t)Z_LVAL_P(zv);
|
|
|
|
}
|
|
|
|
|
|
|
|
ZEND_API void zend_deserialize_opcode_handler(zend_op *op)
|
|
|
|
{
|
|
|
|
op->handler = zend_opcode_handlers[(zend_uintptr_t)op->handler];
|
|
|
|
}
|
|
|
|
|
2017-05-16 14:24:23 +08:00
|
|
|
ZEND_API const void *zend_get_opcode_handler_func(const zend_op *op)
|
2017-05-03 15:01:22 +08:00
|
|
|
{
|
|
|
|
#if ZEND_VM_KIND == ZEND_VM_KIND_CALL
|
|
|
|
return op->handler;
|
|
|
|
#elif ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
|
|
|
|
zval *zv;
|
|
|
|
|
|
|
|
if (!zend_handlers_table) {
|
|
|
|
init_opcode_serialiser();
|
|
|
|
}
|
|
|
|
zv = zend_hash_index_find(zend_handlers_table, (zend_long)(zend_uintptr_t)op->handler);
|
|
|
|
ZEND_ASSERT(zv != NULL);
|
2017-05-16 14:24:23 +08:00
|
|
|
return zend_opcode_handler_funcs[Z_LVAL_P(zv)];
|
2017-05-03 15:01:22 +08:00
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2017-05-16 14:24:23 +08:00
|
|
|
ZEND_API const zend_op *zend_get_halt_op(void)
|
2017-05-03 15:01:22 +08:00
|
|
|
{
|
|
|
|
#if ZEND_VM_KIND == ZEND_VM_KIND_HYBRID
|
2017-05-16 14:24:23 +08:00
|
|
|
return &hybrid_halt_op;
|
2017-05-03 15:01:22 +08:00
|
|
|
#else
|
|
|
|
return NULL;
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
ZEND_API int zend_vm_kind(void)
|
|
|
|
{
|
|
|
|
return ZEND_VM_KIND;
|
|
|
|
}
|