diff options
Diffstat (limited to 'Zend/zend_execute.h')
-rw-r--r-- | Zend/zend_execute.h | 133 |
1 files changed, 49 insertions, 84 deletions
diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h index b74fd9614d..ea06328d93 100644 --- a/Zend/zend_execute.h +++ b/Zend/zend_execute.h @@ -5,7 +5,7 @@ | Copyright (c) 1998-2014 Zend Technologies Ltd. (http://www.zend.com) | +----------------------------------------------------------------------+ | This source file is subject to version 2.00 of the Zend license, | - | that is bundled with this package in the file LICENSE, and is | + | that is bundled with this package in the file LICENSE, and is | | available through the world-wide-web at the following url: | | http://www.zend.com/license/2_00.txt. | | If you did not receive a copy of the Zend license and are unable to | @@ -49,24 +49,18 @@ typedef union _temp_variable { BEGIN_EXTERN_C() -ZEND_API extern void (*zend_execute)(zend_op_array *op_array TSRMLS_DC); -ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); +struct _zend_fcall_info; +ZEND_API extern void (*zend_execute_ex)(zend_execute_data *execute_data TSRMLS_DC); +ZEND_API extern void (*zend_execute_internal)(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC); void init_executor(TSRMLS_D); void shutdown_executor(TSRMLS_D); void shutdown_destructors(TSRMLS_D); -ZEND_API void execute(zend_op_array *op_array TSRMLS_DC); -ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC); +zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_array, zend_bool nested TSRMLS_DC); +ZEND_API void zend_execute(zend_op_array *op_array TSRMLS_DC); +ZEND_API void execute_ex(zend_execute_data *execute_data TSRMLS_DC); +ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, struct _zend_fcall_info *fci, int return_value_used TSRMLS_DC); ZEND_API int zend_is_true(zval *op); -#define safe_free_zval_ptr(p) safe_free_zval_ptr_rel(p ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC) -static zend_always_inline void safe_free_zval_ptr_rel(zval *p ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC) -{ - TSRMLS_FETCH(); - - if (p!=EG(uninitialized_zval_ptr)) { - FREE_ZVAL_REL(p); - } -} ZEND_API int zend_lookup_class(const char *name, int name_length, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_lookup_class_ex(const char *name, int name_length, const zend_literal *key, int use_autoload, zend_class_entry ***ce TSRMLS_DC); ZEND_API int zend_eval_string(char *str, zval *retval_ptr, char *string_name TSRMLS_DC); @@ -82,11 +76,10 @@ static zend_always_inline void i_zval_ptr_dtor(zval *zval_ptr ZEND_FILE_LINE_DC) if (!Z_DELREF_P(zval_ptr)) { TSRMLS_FETCH(); - if (zval_ptr != &EG(uninitialized_zval)) { - GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr); - zval_dtor(zval_ptr); - efree_rel(zval_ptr); - } + ZEND_ASSERT(zval_ptr != &EG(uninitialized_zval)); + GC_REMOVE_ZVAL_FROM_BUFFER(zval_ptr); + zval_dtor(zval_ptr); + efree_rel(zval_ptr); } else { TSRMLS_FETCH(); @@ -219,12 +212,6 @@ static zend_always_inline void **zend_vm_stack_top(TSRMLS_D) static zend_always_inline void zend_vm_stack_push(void *ptr TSRMLS_DC) { - ZEND_VM_STACK_GROW_IF_NEEDED(1); - *(EG(argument_stack)->top++) = ptr; -} - -static zend_always_inline void zend_vm_stack_push_nocheck(void *ptr TSRMLS_DC) -{ *(EG(argument_stack)->top++) = ptr; } @@ -232,11 +219,6 @@ static zend_always_inline void *zend_vm_stack_pop(TSRMLS_D) { void *el = *(--EG(argument_stack)->top); - if (UNEXPECTED(EG(argument_stack)->top == ZEND_VM_STACK_ELEMETS(EG(argument_stack)))) { - zend_vm_stack p = EG(argument_stack); - EG(argument_stack) = p->prev; - efree(p); - } return el; } @@ -269,8 +251,14 @@ static zend_always_inline void *zend_vm_stack_alloc(size_t size TSRMLS_DC) return ret; } +static zend_always_inline void** zend_vm_stack_frame_base(zend_execute_data *ex) +{ + return (void**)((char*)ex->call_slots + + ZEND_MM_ALIGNED_SIZE(sizeof(call_slot)) * ex->op_array->nested_calls); +} + static zend_always_inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC) -{ +{ if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) { zend_vm_stack p = EG(argument_stack); @@ -282,7 +270,7 @@ static zend_always_inline void zend_vm_stack_free_int(void *ptr TSRMLS_DC) } static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC) -{ +{ if (UNEXPECTED(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) == (void**)ptr)) { zend_vm_stack p = EG(argument_stack); @@ -299,51 +287,36 @@ static zend_always_inline void zend_vm_stack_free(void *ptr TSRMLS_DC) } } -static zend_always_inline void** zend_vm_stack_push_args(int count TSRMLS_DC) +static zend_always_inline void zend_vm_stack_clear_multiple(int nested TSRMLS_DC) { + void **p = EG(argument_stack)->top - 1; + void **end = p - (int)(zend_uintptr_t)*p; - if (UNEXPECTED(EG(argument_stack)->top - ZEND_VM_STACK_ELEMETS(EG(argument_stack)) < count) || - UNEXPECTED(EG(argument_stack)->top == EG(argument_stack)->end)) { - zend_vm_stack p = EG(argument_stack); - - zend_vm_stack_extend(count + 1 TSRMLS_CC); - - EG(argument_stack)->top += count; - *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count; - while (count-- > 0) { - void *data = *(--p->top); - - if (UNEXPECTED(p->top == ZEND_VM_STACK_ELEMETS(p))) { - zend_vm_stack r = p; - - EG(argument_stack)->prev = p->prev; - p = p->prev; - efree(r); - } - *(ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + count) = data; - } - return EG(argument_stack)->top++; + while (p != end) { + zval *q = (zval *) *(--p); + *p = NULL; + i_zval_ptr_dtor(q ZEND_FILE_LINE_CC); + } + if (nested) { + EG(argument_stack)->top = p; + } else { + zend_vm_stack_free_int(p TSRMLS_CC); } - *(EG(argument_stack)->top) = (void*)(zend_uintptr_t)count; - return EG(argument_stack)->top++; } -static zend_always_inline void zend_vm_stack_clear_multiple(TSRMLS_D) +static zend_always_inline int zend_vm_stack_get_args_count_ex(zend_execute_data *ex) { - void **p = EG(argument_stack)->top - 1; - int delete_count = (int)(zend_uintptr_t) *p; - - while (--delete_count>=0) { - zval *q = *(zval **)(--p); - *p = NULL; - i_zval_ptr_dtor(q ZEND_FILE_LINE_CC); + if (ex) { + void **p = ex->function_state.arguments; + return (int)(zend_uintptr_t) *p; + } else { + return 0; } - zend_vm_stack_free_int(p TSRMLS_CC); } -static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC) +static zend_always_inline zval** zend_vm_stack_get_arg_ex(zend_execute_data *ex, int requested_arg) { - void **p = EG(current_execute_data)->prev_execute_data->function_state.arguments; + void **p = ex->function_state.arguments; int arg_count = (int)(zend_uintptr_t) *p; if (UNEXPECTED(requested_arg > arg_count)) { @@ -352,25 +325,14 @@ static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_ return (zval**)p - arg_count + requested_arg - 1; } -static zend_always_inline void zend_arg_types_stack_2_pop(zend_ptr_stack *stack, zval **object, zend_function **fbc) +static zend_always_inline int zend_vm_stack_get_args_count(TSRMLS_D) { - void *a, *b; - - zend_ptr_stack_2_pop(stack, &a, &b); - - *object = (zval *) a; - *fbc = (zend_function *) b; + return zend_vm_stack_get_args_count_ex(EG(current_execute_data)->prev_execute_data); } -static zend_always_inline void zend_arg_types_stack_3_pop(zend_ptr_stack *stack, zend_class_entry **called_scope, zval **object, zend_function **fbc) +static zend_always_inline zval** zend_vm_stack_get_arg(int requested_arg TSRMLS_DC) { - void *a, *b, *c; - - zend_ptr_stack_3_pop(stack, &a, &b, &c); - - *called_scope = (zend_class_entry *) a; - *object = (zval *) b; - *fbc = (zend_function *) c; + return zend_vm_stack_get_arg_ex(EG(current_execute_data)->prev_execute_data, requested_arg); } void execute_new_code(TSRMLS_D); @@ -426,11 +388,14 @@ typedef struct _zend_free_op { /* int is_var; */ } zend_free_op; -ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC); -ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC); +ZEND_API zval *zend_get_zval_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC); +ZEND_API zval **zend_get_zval_ptr_ptr(int op_type, const znode_op *node, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC); ZEND_API int zend_do_fcall(ZEND_OPCODE_HANDLER_ARGS); +void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC); +void zend_free_compiled_variables(zend_execute_data *execute_data); + #define CACHED_PTR(num) \ EG(active_op_array)->run_time_cache[(num)] |