Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/NEWS b/NEWS
- index 350729c..1c57996 100644
- --- a/NEWS
- +++ b/NEWS
- @@ -3,6 +3,7 @@ PHP NEWS
- ?? ??? 201?, PHP 5.5.0
- - General improvements:
- + . Optimized access to temporary VM variables. 5% less memory reads. (Dmitry)
- . The VM stacks for passing function arguments and syntaticaly nested calls
- were merged into a single stack. The stack size needed for op_array
- execution is calculated at compile time and preallocated at once. As result
- diff --git a/UPGRADING b/UPGRADING
- index f8cb6fa..170c6de 100755
- --- a/UPGRADING
- +++ b/UPGRADING
- @@ -48,6 +48,17 @@ PHP 5.5 UPGRADE NOTES
- corresponding stack space is preallocated together with execute_data.
- ZEND_SEND* and ZEND_DO_FCALL* don't need to check for stack overflow
- anymore.
- +- Removed execute_data->Ts field. The VM temporary variables always allocated
- + immediately before execute_data structure. Now they are accessed by offset
- + from the execute_data base pointer (instead of execute_data->Ts). Compiler
- + stores new offsets in op_array->opcodes[*].op?.num. You can use macros
- + EX_TMP_VAR() and EX_TMP_VAR_NUM() to access temp_variable by offset or
- + number. You can convert number to offset using EX_TMP_VAR_NUM(0, num) or
- + offset to number (EX_TMP_VAR(0,offset)-EX_TMP_VAR_NUM(0,0)).
- +- Removed execute_data->CVs field. The VM compiled variables always allocated
- + immediately after execute_data structure. Now they are accessed by offset
- + from the execute_data base pointer (instead of execute_data->CVs). You can
- + use macros EX_CV_NUM() to access compiled variables by number.
- ========================================
- 2. New Features
- diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
- index e768996..109949a 100644
- --- a/Zend/zend_compile.c
- +++ b/Zend/zend_compile.c
- @@ -287,7 +287,7 @@ ZEND_API zend_bool zend_is_compiling(TSRMLS_D) /* {{{ */
- static zend_uint get_temporary_variable(zend_op_array *op_array) /* {{{ */
- {
- - return (op_array->T)++ * ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable));
- + return EX_TMP_VAR_NUM(0, (op_array->T)++);
- }
- /* }}} */
- diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
- index def6341..e06c270 100644
- --- a/Zend/zend_compile.h
- +++ b/Zend/zend_compile.h
- @@ -387,8 +387,6 @@ struct _zend_execute_data {
- zend_function_state function_state;
- zend_op_array *op_array;
- zval *object;
- - union _temp_variable *Ts;
- - zval ***CVs;
- HashTable *symbol_table;
- struct _zend_execute_data *prev_execute_data;
- zval *old_error_reporting;
- @@ -404,6 +402,11 @@ struct _zend_execute_data {
- #define EX(element) execute_data.element
- +#define EX_TMP_VAR(ex, n) ((temp_variable*)(((char*)(ex)) + (n)))
- +#define EX_TMP_VAR_NUM(ex, n) (EX_TMP_VAR(ex, 0) - (1 + (n)))
- +
- +#define EX_CV_NUM(ex, n) (((zval***)(((char*)(ex))+ZEND_MM_ALIGNED_SIZE(sizeof(zend_execute_data))))+(n))
- +
- #define IS_CONST (1<<0)
- #define IS_TMP_VAR (1<<1)
- diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
- index 5f04ba7..e5198eb 100644
- --- a/Zend/zend_execute.c
- +++ b/Zend/zend_execute.c
- @@ -50,10 +50,10 @@
- typedef int (*incdec_t)(zval *);
- -#define get_zval_ptr(op_type, node, Ts, should_free, type) _get_zval_ptr(op_type, node, Ts, should_free, type TSRMLS_CC)
- -#define get_zval_ptr_ptr(op_type, node, Ts, should_free, type) _get_zval_ptr_ptr(op_type, node, Ts, should_free, type TSRMLS_CC)
- -#define get_obj_zval_ptr(op_type, node, Ts, should_free, type) _get_obj_zval_ptr(op_type, node, Ts, should_free, type TSRMLS_CC)
- -#define get_obj_zval_ptr_ptr(op_type, node, Ts, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, Ts, should_free, type TSRMLS_CC)
- +#define get_zval_ptr(op_type, node, ex, should_free, type) _get_zval_ptr(op_type, node, ex, should_free, type TSRMLS_CC)
- +#define get_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC)
- +#define get_obj_zval_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr(op_type, node, ex, should_free, type TSRMLS_CC)
- +#define get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type) _get_obj_zval_ptr_ptr(op_type, node, ex, should_free, type TSRMLS_CC)
- /* Prototypes */
- static void zend_extension_statement_handler(const zend_extension *extension, zend_op_array *op_array TSRMLS_DC);
- @@ -62,8 +62,8 @@ static void zend_extension_fcall_end_handler(const zend_extension *extension, ze
- #define RETURN_VALUE_USED(opline) (!((opline)->result_type & EXT_TYPE_UNUSED))
- -#define T(offset) (*(temp_variable *)((char *) Ts + offset))
- -#define CV(var) CVs[var]
- +#define EX_T(offset) (*EX_TMP_VAR(execute_data, offset))
- +#define EX_CV(var) (*EX_CV_NUM(execute_data, var))
- #define TEMP_VAR_STACK_LIMIT 2000
- @@ -154,7 +154,6 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
- /* End of zend_execute_locks.h */
- -#define CV_OF(i) (EG(current_execute_data)->CVs[i])
- #define CV_DEF_OF(i) (EG(active_op_array)->vars[i])
- #define CTOR_CALL_BIT 0x1
- @@ -168,19 +167,19 @@ static zend_always_inline void zend_pzval_unlock_free_func(zval *z TSRMLS_DC)
- #define DECODE_CTOR(ce) \
- ((zend_class_entry*)(((zend_uintptr_t)(ce)) & ~(CTOR_CALL_BIT|CTOR_USED_BIT)))
- -ZEND_API zval** zend_get_compiled_variable_value(const zend_execute_data *execute_data_ptr, zend_uint var)
- +ZEND_API zval** zend_get_compiled_variable_value(const zend_execute_data *execute_data, zend_uint var)
- {
- - return execute_data_ptr->CVs[var];
- + return EX_CV(var);
- }
- -static zend_always_inline zval *_get_zval_ptr_tmp(zend_uint var, const temp_variable *Ts, zend_free_op *should_free TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_tmp(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
- {
- - return should_free->var = &T(var).tmp_var;
- + return should_free->var = &EX_T(var).tmp_var;
- }
- -static zend_always_inline zval *_get_zval_ptr_var(zend_uint var, const temp_variable *Ts, zend_free_op *should_free TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_var(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
- {
- - zval *ptr = T(var).var.ptr;
- + zval *ptr = EX_T(var).var.ptr;
- PZVAL_UNLOCK(ptr, should_free);
- return ptr;
- @@ -206,7 +205,7 @@ static zend_never_inline zval **_get_zval_cv_lookup(zval ***ptr, zend_uint var,
- case BP_VAR_W:
- Z_ADDREF(EG(uninitialized_zval));
- if (!EG(active_symbol_table)) {
- - *ptr = (zval**)EG(current_execute_data)->CVs + (EG(active_op_array)->last_var + var);
- + *ptr = (zval**)EX_CV_NUM(EG(current_execute_data), EG(active_op_array)->last_var + var);
- **ptr = &EG(uninitialized_zval);
- } else {
- zend_hash_quick_update(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, &EG(uninitialized_zval_ptr), sizeof(zval *), (void **)ptr);
- @@ -258,7 +257,7 @@ static zend_never_inline zval **_get_zval_cv_lookup_BP_VAR_RW(zval ***ptr, zend_
- if (!EG(active_symbol_table)) {
- Z_ADDREF(EG(uninitialized_zval));
- - *ptr = (zval**)EG(current_execute_data)->CVs + (EG(active_op_array)->last_var + var);
- + *ptr = (zval**)EX_CV_NUM(EG(current_execute_data), EG(active_op_array)->last_var + var);
- **ptr = &EG(uninitialized_zval);
- zend_error(E_NOTICE, "Undefined variable: %s", cv->name);
- } else if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
- @@ -275,7 +274,7 @@ static zend_never_inline zval **_get_zval_cv_lookup_BP_VAR_W(zval ***ptr, zend_u
- if (!EG(active_symbol_table)) {
- Z_ADDREF(EG(uninitialized_zval));
- - *ptr = (zval**)EG(current_execute_data)->CVs + (EG(active_op_array)->last_var + var);
- + *ptr = (zval**)EX_CV_NUM(EG(current_execute_data), EG(active_op_array)->last_var + var);
- **ptr = &EG(uninitialized_zval);
- } else if (zend_hash_quick_find(EG(active_symbol_table), cv->name, cv->name_len+1, cv->hash_value, (void **)ptr)==FAILURE) {
- Z_ADDREF(EG(uninitialized_zval));
- @@ -286,7 +285,7 @@ static zend_never_inline zval **_get_zval_cv_lookup_BP_VAR_W(zval ***ptr, zend_u
- static zend_always_inline zval *_get_zval_ptr_cv(zend_uint var, int type TSRMLS_DC)
- {
- - zval ***ptr = &CV_OF(var);
- + zval ***ptr = EX_CV_NUM(EG(current_execute_data), var);
- if (UNEXPECTED(*ptr == NULL)) {
- return *_get_zval_cv_lookup(ptr, var, type TSRMLS_CC);
- @@ -294,9 +293,9 @@ static zend_always_inline zval *_get_zval_ptr_cv(zend_uint var, int type TSRMLS_
- return **ptr;
- }
- -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return *_get_zval_cv_lookup_BP_VAR_R(ptr, var TSRMLS_CC);
- @@ -304,9 +303,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_R(zval ***CVs, zend_uint
- return **ptr;
- }
- -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return *_get_zval_cv_lookup_BP_VAR_UNSET(ptr, var TSRMLS_CC);
- @@ -314,9 +313,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_UNSET(zval ***CVs, zend_
- return **ptr;
- }
- -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return *_get_zval_cv_lookup_BP_VAR_IS(ptr, var TSRMLS_CC);
- @@ -324,9 +323,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_IS(zval ***CVs, zend_uin
- return **ptr;
- }
- -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return *_get_zval_cv_lookup_BP_VAR_RW(ptr, var TSRMLS_CC);
- @@ -334,9 +333,9 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_RW(zval ***CVs, zend_uin
- return **ptr;
- }
- -static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return *_get_zval_cv_lookup_BP_VAR_W(ptr, var TSRMLS_CC);
- @@ -344,7 +343,7 @@ static zend_always_inline zval *_get_zval_ptr_cv_BP_VAR_W(zval ***CVs, zend_uint
- return **ptr;
- }
- -static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC)
- +static inline zval *_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)
- {
- /* should_free->is_var = 0; */
- switch (op_type) {
- @@ -353,11 +352,11 @@ static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const temp_
- return node->zv;
- break;
- case IS_TMP_VAR:
- - should_free->var = TMP_FREE(&T(node->var).tmp_var);
- - return &T(node->var).tmp_var;
- + should_free->var = TMP_FREE(&EX_T(node->var).tmp_var);
- + return &EX_T(node->var).tmp_var;
- break;
- case IS_VAR:
- - return _get_zval_ptr_var(node->var, Ts, should_free TSRMLS_CC);
- + return _get_zval_ptr_var(node->var, execute_data, should_free TSRMLS_CC);
- break;
- case IS_UNUSED:
- should_free->var = 0;
- @@ -372,22 +371,22 @@ static inline zval *_get_zval_ptr(int op_type, const znode_op *node, const temp_
- return NULL;
- }
- -static zend_always_inline zval **_get_zval_ptr_ptr_var(zend_uint var, const temp_variable *Ts, zend_free_op *should_free TSRMLS_DC)
- +static zend_always_inline zval **_get_zval_ptr_ptr_var(zend_uint var, const zend_execute_data *execute_data, zend_free_op *should_free TSRMLS_DC)
- {
- - zval** ptr_ptr = T(var).var.ptr_ptr;
- + zval** ptr_ptr = EX_T(var).var.ptr_ptr;
- if (EXPECTED(ptr_ptr != NULL)) {
- PZVAL_UNLOCK(*ptr_ptr, should_free);
- } else {
- /* string offset */
- - PZVAL_UNLOCK(T(var).str_offset.str, should_free);
- + PZVAL_UNLOCK(EX_T(var).str_offset.str, should_free);
- }
- return ptr_ptr;
- }
- static zend_always_inline zval **_get_zval_ptr_ptr_cv(zend_uint var, int type TSRMLS_DC)
- {
- - zval ***ptr = &CV_OF(var);
- + zval ***ptr = EX_CV_NUM(EG(current_execute_data), var);
- if (UNEXPECTED(*ptr == NULL)) {
- return _get_zval_cv_lookup(ptr, var, type TSRMLS_CC);
- @@ -395,9 +394,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv(zend_uint var, int type TS
- return *ptr;
- }
- -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_R(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_R(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return _get_zval_cv_lookup_BP_VAR_R(ptr, var TSRMLS_CC);
- @@ -405,9 +404,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_R(zval ***CVs, zend
- return *ptr;
- }
- -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_UNSET(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_UNSET(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return _get_zval_cv_lookup_BP_VAR_UNSET(ptr, var TSRMLS_CC);
- @@ -415,9 +414,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_UNSET(zval ***CVs,
- return *ptr;
- }
- -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_IS(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_IS(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return _get_zval_cv_lookup_BP_VAR_IS(ptr, var TSRMLS_CC);
- @@ -425,9 +424,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_IS(zval ***CVs, zen
- return *ptr;
- }
- -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_RW(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_RW(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return _get_zval_cv_lookup_BP_VAR_RW(ptr, var TSRMLS_CC);
- @@ -435,9 +434,9 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_RW(zval ***CVs, zen
- return *ptr;
- }
- -static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_W(zval ***CVs, zend_uint var TSRMLS_DC)
- +static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_W(const zend_execute_data *execute_data, zend_uint var TSRMLS_DC)
- {
- - zval ***ptr = &CV(var);
- + zval ***ptr = EX_CV_NUM(execute_data, var);
- if (UNEXPECTED(*ptr == NULL)) {
- return _get_zval_cv_lookup_BP_VAR_W(ptr, var TSRMLS_CC);
- @@ -445,13 +444,13 @@ static zend_always_inline zval **_get_zval_ptr_ptr_cv_BP_VAR_W(zval ***CVs, zend
- return *ptr;
- }
- -static inline zval **_get_zval_ptr_ptr(int op_type, const znode_op *node, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC)
- +static inline zval **_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)
- {
- if (op_type == IS_CV) {
- should_free->var = 0;
- return _get_zval_ptr_ptr_cv(node->var, type TSRMLS_CC);
- } else if (op_type == IS_VAR) {
- - return _get_zval_ptr_ptr_var(node->var, Ts, should_free TSRMLS_CC);
- + return _get_zval_ptr_ptr_var(node->var, execute_data, should_free TSRMLS_CC);
- } else {
- should_free->var = 0;
- return NULL;
- @@ -468,7 +467,7 @@ static zend_always_inline zval *_get_obj_zval_ptr_unused(TSRMLS_D)
- }
- }
- -static inline zval **_get_obj_zval_ptr_ptr(int op_type, const znode_op *op, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC)
- +static inline zval **_get_obj_zval_ptr_ptr(int op_type, const znode_op *op, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
- {
- if (op_type == IS_UNUSED) {
- if (EXPECTED(EG(This) != NULL)) {
- @@ -480,7 +479,7 @@ static inline zval **_get_obj_zval_ptr_ptr(int op_type, const znode_op *op, cons
- zend_error_noreturn(E_ERROR, "Using $this when not in object context");
- }
- }
- - return get_zval_ptr_ptr(op_type, op, Ts, should_free, type);
- + return get_zval_ptr_ptr(op_type, op, execute_data, should_free, type);
- }
- static zend_always_inline zval **_get_obj_zval_ptr_ptr_unused(TSRMLS_D)
- @@ -493,7 +492,7 @@ static zend_always_inline zval **_get_obj_zval_ptr_ptr_unused(TSRMLS_D)
- }
- }
- -static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const temp_variable *Ts, zend_free_op *should_free, int type TSRMLS_DC)
- +static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const zend_execute_data *execute_data, zend_free_op *should_free, int type TSRMLS_DC)
- {
- if (op_type == IS_UNUSED) {
- if (EXPECTED(EG(This) != NULL)) {
- @@ -503,7 +502,7 @@ static inline zval *_get_obj_zval_ptr(int op_type, znode_op *op, const temp_vari
- zend_error_noreturn(E_ERROR, "Using $this when not in object context");
- }
- }
- - return get_zval_ptr(op_type, op, Ts, should_free, type);
- + return get_zval_ptr(op_type, op, execute_data, should_free, type);
- }
- static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **value_ptr_ptr TSRMLS_DC)
- @@ -654,11 +653,11 @@ static inline int zend_verify_arg_type(zend_function *zf, zend_uint arg_num, zva
- return 1;
- }
- -static inline void zend_assign_to_object(zval **retval, zval **object_ptr, zval *property_name, int value_type, znode_op *value_op, const temp_variable *Ts, int opcode, const zend_literal *key TSRMLS_DC)
- +static inline void zend_assign_to_object(zval **retval, zval **object_ptr, zval *property_name, int value_type, znode_op *value_op, const zend_execute_data *execute_data, int opcode, const zend_literal *key TSRMLS_DC)
- {
- zval *object = *object_ptr;
- zend_free_op free_value;
- - zval *value = get_zval_ptr(value_type, value_op, Ts, &free_value, BP_VAR_R);
- + zval *value = get_zval_ptr(value_type, value_op, execute_data, &free_value, BP_VAR_R);
- if (Z_TYPE_P(object) != IS_OBJECT) {
- if (object == &EG(error_zval)) {
- @@ -1410,7 +1409,7 @@ static void zend_fetch_property_address(temp_variable *result, zval **container_
- }
- }
- -static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const temp_variable *Ts TSRMLS_DC)
- +static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_offset, const zend_op_array *op_array, const zend_execute_data *execute_data TSRMLS_DC)
- {
- int original_nest_levels = nest_levels;
- zend_brk_cont_element *jmp_to;
- @@ -1426,12 +1425,12 @@ static inline zend_brk_cont_element* zend_brk_cont(int nest_levels, int array_of
- switch (brk_opline->opcode) {
- case ZEND_SWITCH_FREE:
- if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
- - zval_ptr_dtor(&T(brk_opline->op1.var).var.ptr);
- + zval_ptr_dtor(&EX_T(brk_opline->op1.var).var.ptr);
- }
- break;
- case ZEND_FREE:
- if (!(brk_opline->extended_value & EXT_TYPE_FREE_ON_RETURN)) {
- - zendi_zval_dtor(T(brk_opline->op1.var).tmp_var);
- + zendi_zval_dtor(EX_T(brk_opline->op1.var).tmp_var);
- }
- break;
- }
- @@ -1482,7 +1481,7 @@ ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, zend_fcall_i
- *fci->retval_ptr_ptr, fci->retval_ptr_ptr, fci->object_ptr, 1 TSRMLS_CC);
- } else {
- - zval **return_value_ptr = &(*(temp_variable *)((char *) execute_data_ptr->Ts + execute_data_ptr->opline->result.var)).var.ptr;
- + zval **return_value_ptr = &EX_TMP_VAR(execute_data_ptr, execute_data_ptr->opline->result.var)->var.ptr;
- ((zend_internal_function *) execute_data_ptr->function_state.function)->handler(execute_data_ptr->opline->extended_value, *return_value_ptr,
- (execute_data_ptr->function_state.function->common.fn_flags & ZEND_ACC_RETURN_REFERENCE)?return_value_ptr:NULL,
- execute_data_ptr->object, return_value_used TSRMLS_CC);
- @@ -1537,12 +1536,12 @@ ZEND_API user_opcode_handler_t zend_get_user_opcode_handler(zend_uchar opcode)
- return zend_user_opcode_handlers[opcode];
- }
- -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) {
- - return get_zval_ptr(op_type, node, Ts, should_free, type);
- +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) {
- + return get_zval_ptr(op_type, node, execute_data, should_free, type);
- }
- -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) {
- - return get_zval_ptr_ptr(op_type, node, Ts, should_free, type);
- +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) {
- + return get_zval_ptr_ptr(op_type, node, execute_data, should_free, type);
- }
- void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{ */
- @@ -1559,12 +1558,12 @@ void zend_clean_and_cache_symbol_table(HashTable *symbol_table TSRMLS_DC) /* {{{
- }
- /* }}} */
- -void zend_free_compiled_variables(zval ***CVs, int num) /* {{{ */
- +void zend_free_compiled_variables(zend_execute_data *execute_data) /* {{{ */
- {
- int i;
- - for (i = 0; i < num; ++i) {
- - if (CVs[i]) {
- - zval_ptr_dtor(CVs[i]);
- + for (i = 0; i < EX(op_array)->last_var; ++i) {
- + if (EX_CV(i)) {
- + zval_ptr_dtor(EX_CV(i));
- }
- }
- }
- diff --git a/Zend/zend_execute.h b/Zend/zend_execute.h
- index fdd9f56..963decd 100644
- --- a/Zend/zend_execute.h
- +++ b/Zend/zend_execute.h
- @@ -394,13 +394,13 @@ 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(zval ***CVs, int num);
- +void zend_free_compiled_variables(zend_execute_data *execute_data);
- #define CACHED_PTR(num) \
- EG(active_op_array)->run_time_cache[(num)]
- diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
- index 3df0ca2..4a635b2 100644
- --- a/Zend/zend_execute_API.c
- +++ b/Zend/zend_execute_API.c
- @@ -1689,7 +1689,7 @@ ZEND_API void zend_reset_all_cv(HashTable *symbol_table TSRMLS_DC) /* {{{ */
- for (ex = EG(current_execute_data); ex; ex = ex->prev_execute_data) {
- if (ex->op_array && ex->symbol_table == symbol_table) {
- for (i = 0; i < ex->op_array->last_var; i++) {
- - ex->CVs[i] = NULL;
- + *EX_CV_NUM(ex, i) = NULL;
- }
- }
- }
- @@ -1708,7 +1708,7 @@ ZEND_API void zend_delete_variable(zend_execute_data *ex, HashTable *ht, const c
- if (ex->op_array->vars[i].hash_value == hash_value &&
- ex->op_array->vars[i].name_len == name_len &&
- !memcmp(ex->op_array->vars[i].name, name, name_len)) {
- - ex->CVs[i] = NULL;
- + *EX_CV_NUM(ex, i) = NULL;
- break;
- }
- }
- @@ -1732,7 +1732,7 @@ ZEND_API int zend_delete_global_variable_ex(const char *name, int name_len, ulon
- ex->op_array->vars[i].name_len == name_len &&
- !memcmp(ex->op_array->vars[i].name, name, name_len)
- ) {
- - ex->CVs[i] = NULL;
- + *EX_CV_NUM(ex, i) = NULL;
- break;
- }
- }
- @@ -1779,20 +1779,20 @@ ZEND_API void zend_rebuild_symbol_table(TSRMLS_D) /* {{{ */
- ex->symbol_table = EG(active_symbol_table);
- if (ex->op_array->this_var != -1 &&
- - !ex->CVs[ex->op_array->this_var] &&
- + !*EX_CV_NUM(ex, ex->op_array->this_var) &&
- EG(This)) {
- - ex->CVs[ex->op_array->this_var] = (zval**)ex->CVs + ex->op_array->last_var + ex->op_array->this_var;
- - *ex->CVs[ex->op_array->this_var] = EG(This);
- + *EX_CV_NUM(ex, ex->op_array->this_var) = (zval**)EX_CV_NUM(ex, ex->op_array->last_var + ex->op_array->this_var);
- + **EX_CV_NUM(ex, ex->op_array->this_var) = EG(This);
- }
- for (i = 0; i < ex->op_array->last_var; i++) {
- - if (ex->CVs[i]) {
- + if (*EX_CV_NUM(ex, i)) {
- zend_hash_quick_update(EG(active_symbol_table),
- ex->op_array->vars[i].name,
- ex->op_array->vars[i].name_len + 1,
- ex->op_array->vars[i].hash_value,
- - (void**)ex->CVs[i],
- + (void**)*EX_CV_NUM(ex, i),
- sizeof(zval*),
- - (void**)&ex->CVs[i]);
- + (void**)EX_CV_NUM(ex, i));
- }
- }
- }
- diff --git a/Zend/zend_generators.c b/Zend/zend_generators.c
- index 4450374..dc7ae14 100644
- --- a/Zend/zend_generators.c
- +++ b/Zend/zend_generators.c
- @@ -35,7 +35,7 @@ void zend_generator_close(zend_generator *generator, zend_bool finished_executio
- void **stack_frame;
- if (!execute_data->symbol_table) {
- - zend_free_compiled_variables(execute_data->CVs, op_array->last_var);
- + zend_free_compiled_variables(execute_data);
- } else {
- zend_clean_and_cache_symbol_table(execute_data->symbol_table TSRMLS_CC);
- }
- @@ -66,13 +66,13 @@ void zend_generator_close(zend_generator *generator, zend_bool finished_executio
- switch (brk_opline->opcode) {
- case ZEND_SWITCH_FREE:
- {
- - temp_variable *var = (temp_variable *) ((char *) execute_data->Ts + brk_opline->op1.var);
- + temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var);
- zval_ptr_dtor(&var->var.ptr);
- }
- break;
- case ZEND_FREE:
- {
- - temp_variable *var = (temp_variable *) ((char *) execute_data->Ts + brk_opline->op1.var);
- + temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var);
- zval_dtor(&var->tmp_var);
- }
- break;
- @@ -198,10 +198,10 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
- /* Copy compiled variables */
- for (i = 0; i < op_array->last_var; i++) {
- - if (execute_data->CVs[i]) {
- - clone->execute_data->CVs[i] = (zval **) clone->execute_data->CVs + op_array->last_var + i;
- - *clone->execute_data->CVs[i] = (zval *) execute_data->CVs[op_array->last_var + i];
- - Z_ADDREF_PP(clone->execute_data->CVs[i]);
- + if (*EX_CV_NUM(execute_data, i)) {
- + *EX_CV_NUM(clone->execute_data, i) = (zval **) EX_CV_NUM(clone->execute_data, op_array->last_var + i);
- + **EX_CV_NUM(clone->execute_data, i) = *(zval **) EX_CV_NUM(execute_data, op_array->last_var + i);
- + Z_ADDREF_PP(*EX_CV_NUM(clone->execute_data, i));
- }
- }
- } else {
- @@ -214,8 +214,8 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
- {
- int i;
- for (i = 0; i < op_array->last_var; i++) {
- - if (zend_hash_quick_find(clone->execute_data->symbol_table, op_array->vars[i].name, op_array->vars[i].name_len + 1, op_array->vars[i].hash_value, (void **) &clone->execute_data->CVs[i]) == FAILURE) {
- - clone->execute_data->CVs[i] = NULL;
- + if (zend_hash_quick_find(clone->execute_data->symbol_table, op_array->vars[i].name, op_array->vars[i].name_len + 1, op_array->vars[i].hash_value, (void **) EX_CV_NUM(clone->execute_data, i)) == FAILURE) {
- + *EX_CV_NUM(clone->execute_data, i) = NULL;
- }
- }
- }
- @@ -228,7 +228,7 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
- } else {
- clone->execute_data->call = NULL;
- }
- - memcpy(clone->execute_data->call_slots, execute_data->call_slots, sizeof(call_slot) * op_array->nested_calls);
- + memcpy(clone->execute_data->call_slots, execute_data->call_slots, ZEND_MM_ALIGNED_SIZE(sizeof(call_slot)) * op_array->nested_calls);
- if (clone->execute_data->call >= clone->execute_data->call_slots) {
- call_slot *call = clone->execute_data->call;
- @@ -241,14 +241,14 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
- }
- /* Copy the temporary variables */
- - memcpy(clone->execute_data->Ts, execute_data->Ts, sizeof(temp_variable) * op_array->T);
- + memcpy(EX_TMP_VAR_NUM(clone->execute_data, op_array->T-1), EX_TMP_VAR_NUM(execute_data, op_array->T-1), ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T);
- /* Copy arguments passed on stack */
- stack_frame = zend_vm_stack_frame_base(clone->execute_data);
- orig_stack_frame = zend_vm_stack_frame_base(execute_data);
- clone->stack->top = stack_frame + (orig->stack->top - orig_stack_frame);
- if (clone->stack->top != stack_frame) {
- - memcpy(stack_frame, orig_stack_frame, sizeof(zval*) * (orig->stack->top - orig_stack_frame));
- + memcpy(stack_frame, orig_stack_frame, ZEND_MM_ALIGNED_SIZE(sizeof(zval*)) * (orig->stack->top - orig_stack_frame));
- while (clone->stack->top != stack_frame) {
- Z_ADDREF_PP((zval**)stack_frame);
- stack_frame++;
- @@ -271,7 +271,7 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
- zend_op *brk_opline = op_array->opcodes + brk_cont->brk;
- if (brk_opline->opcode == ZEND_SWITCH_FREE) {
- - temp_variable *var = (temp_variable *) ((char *) execute_data->Ts + brk_opline->op1.var);
- + temp_variable *var = EX_TMP_VAR(execute_data, brk_opline->op1.var);
- Z_ADDREF_P(var->var.ptr);
- }
- @@ -283,10 +283,8 @@ static void zend_generator_clone_storage(zend_generator *orig, zend_generator **
- * offset as the original generator, but in our temporary variable
- * memory segment. */
- if (orig->send_target) {
- - size_t offset = (char *) orig->send_target - (char *) execute_data->Ts;
- - clone->send_target = (temp_variable *) (
- - (char *) clone->execute_data->Ts + offset
- - );
- + size_t offset = (char *) orig->send_target - (char *)execute_data;
- + clone->send_target = EX_TMP_VAR(clone->execute_data, offset);
- Z_ADDREF_P(clone->send_target->var.ptr);
- }
- diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
- index 966827d..c309ca0 100644
- --- a/Zend/zend_vm_def.h
- +++ b/Zend/zend_vm_def.h
- @@ -334,7 +334,7 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, VAR|UNUSED|CV, CONST|TMP|VAR
- zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW);
- zval *object;
- zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R);
- - zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R);
- + zval *value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
- int have_get_ptr = 0;
- if (OP1_TYPE == IS_VAR && UNEXPECTED(object_ptr == NULL)) {
- @@ -465,8 +465,8 @@ ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, VAR|UNUSED|CV, CONST|TMP|VAR|UNU
- zval *dim = GET_OP2_ZVAL_PTR(BP_VAR_R);
- zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), container, dim, OP2_TYPE, BP_VAR_RW TSRMLS_CC);
- - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R);
- - var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC);
- + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
- + var_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC);
- }
- }
- break;
- @@ -1636,7 +1636,7 @@ ZEND_VM_HANDLER(136, ZEND_ASSIGN_OBJ, VAR|UNUSED|CV, CONST|TMP|VAR|CV)
- if (OP1_TYPE == IS_VAR && UNEXPECTED(object_ptr == NULL)) {
- zend_error_noreturn(E_ERROR, "Cannot use string offset as an array");
- }
- - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_OBJ, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
- + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_OBJ, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
- if (IS_OP2_TMP_FREE()) {
- zval_ptr_dtor(&property_name);
- } else {
- @@ -1668,7 +1668,7 @@ ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
- if (IS_OP2_TMP_FREE()) {
- MAKE_REAL_ZVAL_PTR(property_name);
- }
- - zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), ZEND_ASSIGN_DIM, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
- + zend_assign_to_object(RETURN_VALUE_USED(opline)?&EX_T(opline->result.var).var.ptr:NULL, object_ptr, property_name, (opline+1)->op1_type, &(opline+1)->op1, execute_data, ZEND_ASSIGN_DIM, ((OP2_TYPE == IS_CONST) ? opline->op2.literal : NULL) TSRMLS_CC);
- if (IS_OP2_TMP_FREE()) {
- zval_ptr_dtor(&property_name);
- } else {
- @@ -1683,8 +1683,8 @@ ZEND_VM_HANDLER(147, ZEND_ASSIGN_DIM, VAR|CV, CONST|TMP|VAR|UNUSED|CV)
- zend_fetch_dimension_address(&EX_T((opline+1)->op2.var), object_ptr, dim, OP2_TYPE, BP_VAR_W TSRMLS_CC);
- FREE_OP2();
- - value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, EX_Ts(), &free_op_data1, BP_VAR_R);
- - variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, EX_Ts(), &free_op_data2 TSRMLS_CC);
- + value = get_zval_ptr((opline+1)->op1_type, &(opline+1)->op1, execute_data, &free_op_data1, BP_VAR_R);
- + variable_ptr_ptr = _get_zval_ptr_ptr_var((opline+1)->op2.var, execute_data, &free_op_data2 TSRMLS_CC);
- if (UNEXPECTED(variable_ptr_ptr == NULL)) {
- if (zend_assign_to_string_offset(&EX_T((opline+1)->op2.var), value, (opline+1)->op1_type TSRMLS_CC)) {
- if (RETURN_VALUE_USED(opline)) {
- @@ -1866,7 +1866,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
- EG(current_execute_data) = EX(prev_execute_data);
- EG(opline_ptr) = NULL;
- if (!EG(active_symbol_table)) {
- - zend_free_compiled_variables(EX_CVs(), op_array->last_var);
- + zend_free_compiled_variables(execute_data);
- }
- if ((op_array->fn_flags & ZEND_ACC_CLOSURE) && op_array->prototype) {
- @@ -1875,7 +1875,7 @@ ZEND_VM_HELPER(zend_leave_helper, ANY, ANY)
- nested = EX(nested);
- - zend_vm_stack_free(execute_data TSRMLS_CC);
- + zend_vm_stack_free((char*)execute_data - (ZEND_MM_ALIGNED_SIZE(sizeof(temp_variable)) * op_array->T) TSRMLS_CC);
- if (nested) {
- execute_data = EG(current_execute_data);
- @@ -2029,7 +2029,7 @@ ZEND_VM_HELPER(zend_do_fcall_common_helper, ANY, ANY)
- /* saves one function call if zend_execute_internal is not used */
- fbc->internal_function.handler(opline->extended_value, ret->var.ptr, (fbc->common.fn_flags & ZEND_ACC_RETURN_REFERENCE) ? &ret->var.ptr : NULL, EX(object), RETURN_VALUE_USED(opline) TSRMLS_CC);
- } else {
- - zend_execute_internal(EXECUTE_DATA, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC);
- + zend_execute_internal(execute_data, NULL, RETURN_VALUE_USED(opline) TSRMLS_CC);
- }
- if (!RETURN_VALUE_USED(opline)) {
- @@ -3043,7 +3043,7 @@ ZEND_VM_HANDLER(107, ZEND_CATCH, CONST, CV)
- if (EX_CV(opline->op2.var)) {
- zval_ptr_dtor(EX_CV(opline->op2.var));
- }
- - EX_CV(opline->op2.var) = (zval**)EX_CVs() + (EX(op_array)->last_var + opline->op2.var);
- + EX_CV(opline->op2.var) = (zval**)EX_CV_NUM(execute_data, EX(op_array)->last_var + opline->op2.var);
- *EX_CV(opline->op2.var) = EG(exception);
- } else {
- zend_compiled_variable *cv = &CV_DEF_OF(opline->op2.var);
- @@ -3245,7 +3245,7 @@ ZEND_VM_HANDLER(63, ZEND_RECV, ANY, ANY)
- zval **var_ptr;
- zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param, opline->extended_value TSRMLS_CC);
- - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->result.var TSRMLS_CC);
- + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
- Z_DELREF_PP(var_ptr);
- *var_ptr = *param;
- Z_ADDREF_PP(var_ptr);
- @@ -3281,7 +3281,7 @@ ZEND_VM_HANDLER(64, ZEND_RECV_INIT, ANY, CONST)
- }
- zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value, opline->extended_value TSRMLS_CC);
- - var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(EX_CVs(), opline->result.var TSRMLS_CC);
- + var_ptr = _get_zval_ptr_ptr_cv_BP_VAR_W(execute_data, opline->result.var TSRMLS_CC);
- Z_DELREF_PP(var_ptr);
- *var_ptr = assignment_value;
- @@ -3311,7 +3311,7 @@ ZEND_VM_HANDLER(50, ZEND_BRK, ANY, CONST)
- SAVE_OPLINE();
- el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
- - EX(op_array), EX_Ts() TSRMLS_CC);
- + EX(op_array), execute_data TSRMLS_CC);
- FREE_OP2();
- ZEND_VM_JMP(EX(op_array)->opcodes + el->brk);
- }
- @@ -3323,7 +3323,7 @@ ZEND_VM_HANDLER(51, ZEND_CONT, ANY, CONST)
- SAVE_OPLINE();
- el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->op1.opline_num,
- - EX(op_array), EX_Ts() TSRMLS_CC);
- + EX(op_array), execute_data TSRMLS_CC);
- FREE_OP2();
- ZEND_VM_JMP(EX(op_array)->opcodes + el->cont);
- }
- @@ -3336,7 +3336,7 @@ ZEND_VM_HANDLER(100, ZEND_GOTO, ANY, CONST)
- SAVE_OPLINE();
- el = zend_brk_cont(Z_LVAL_P(opline->op2.zv), opline->extended_value,
- - EX(op_array), EX_Ts() TSRMLS_CC);
- + EX(op_array), execute_data TSRMLS_CC);
- brk_opline = EX(op_array)->opcodes + el->brk;
- @@ -3953,7 +3953,7 @@ ZEND_VM_HANDLER(74, ZEND_UNSET_VAR, CONST|TMP|VAR|CV, UNUSED|CONST|VAR)
- ulong hash_value = zend_inline_hash_func(varname->value.str.val, varname->value.str.len+1);
- target_symbol_table = zend_get_target_symbol_table(opline->extended_value & ZEND_FETCH_TYPE_MASK TSRMLS_CC);
- - zend_delete_variable(EXECUTE_DATA, target_symbol_table, varname->value.str.val, varname->value.str.len+1, hash_value TSRMLS_CC);
- + zend_delete_variable(execute_data, target_symbol_table, varname->value.str.val, varname->value.str.len+1, hash_value TSRMLS_CC);
- }
- if (OP1_TYPE != IS_CONST && varname == &tmp) {
- @@ -5035,7 +5035,7 @@ ZEND_VM_HANDLER(149, ZEND_HANDLE_EXCEPTION, ANY, ANY)
- /* Figure out where the next stack frame (which maybe contains pushed
- * arguments that have to be dtor'ed) starts */
- - stack_frame = zend_vm_stack_frame_base(EXECUTE_DATA);
- + stack_frame = zend_vm_stack_frame_base(execute_data);
- /* If the exception was thrown during a function call there might be
- * arguments pushed to the stack that have to be dtor'ed. */
- diff --git a/Zend/zend_vm_execute.skl b/Zend/zend_vm_execute.skl
- index 85d3dfb..63f8349 100644
- --- a/Zend/zend_vm_execute.skl
- +++ b/Zend/zend_vm_execute.skl
- @@ -15,24 +15,24 @@
- * +========================================+ |
- * |
- * +========================================+ |
- + * | TMP_VAR[op_arrat->T-1] | |
- + * | ... | |
- + * EX_TMP_VAR_NUM(0) ----> | TMP_VAR[0] | |
- + * +----------------------------------------+ |
- * EG(current_execute_data) -> | zend_execute_data | |
- * | EX(prev_execute_data) |----+
- * +----------------------------------------+
- - * EX(Ts) ---------> | EX(Ts)[0] |
- - * | ... |
- - * | EX(Tx)[op_arrat->T] |
- - * +----------------------------------------+
- - * EX(CVs) --------> | EX(CVs)[0] |--+
- + * EX_CV_NUM(0) ---------> | CV[0] |--+
- * | ... | |
- - * | EX(CVs)[op_array->last_var] | |
- + * | CV[op_array->last_var-1] | |
- * +----------------------------------------+ |
- * | Optional slot for CV[0] zval* |<-+
- * | ... |
- - * | ... for CV [op_array->last_var] zval* |
- + * | ...for CV [op_array->last_var-1] zval* |
- * +----------------------------------------+
- - * EX(call_slots) -> | EX(call_slots)[0] |
- + * EX(call_slots) -> | CALL_SLOT[0] |
- * | ... |
- - * | EX(call_slots)[op_array->nested_calls] |
- + * | CALL_SLOT[op_array->nested_calls-1] |
- * +----------------------------------------+
- * zend_vm_stack_frame_base -> | ARGUMENTS STACK [0] |
- * | ... |
- @@ -82,7 +82,7 @@ zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_arra
- EG(argument_stack) = zend_vm_stack_new_page((total_size + (sizeof(void*) - 1)) / sizeof(void*));
- EG(argument_stack)->prev = NULL;
- - execute_data = (zend_execute_data*)((char*)ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + args_size + execute_data_size);
- + execute_data = (zend_execute_data*)((char*)ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + args_size + execute_data_size + Ts_size);
- /* copy prev_execute_data */
- EX(prev_execute_data) = (zend_execute_data*)((char*)ZEND_VM_STACK_ELEMETS(EG(argument_stack)) + args_size);
- @@ -104,15 +104,13 @@ zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_arra
- }
- } else {
- execute_data = zend_vm_stack_alloc(total_size TSRMLS_CC);
- + execute_data = (zend_execute_data*)((char*)execute_data + Ts_size);
- EX(prev_execute_data) = EG(current_execute_data);
- }
- - EX(Ts) = (temp_variable *) ((char *) execute_data + execute_data_size);
- -
- - EX(CVs) = (zval ***) ((char *) EX(Ts) + Ts_size);
- - memset(EX(CVs), 0, sizeof(zval **) * op_array->last_var);
- + memset(EX_CV_NUM(execute_data, 0), 0, sizeof(zval **) * op_array->last_var);
- - EX(call_slots) = (call_slot*)((char *) EX(CVs) + CVs_size);
- + EX(call_slots) = (call_slot*)((char *)execute_data + execute_data_size + CVs_size);
- EX(op_array) = op_array;
- @@ -134,10 +132,10 @@ zend_execute_data *zend_create_execute_data_from_op_array(zend_op_array *op_arra
- if (op_array->this_var != -1 && EG(This)) {
- Z_ADDREF_P(EG(This)); /* For $this pointer */
- if (!EG(active_symbol_table)) {
- - EX(CVs)[op_array->this_var] = (zval **) EX(CVs) + op_array->last_var + op_array->this_var;
- - *EX(CVs)[op_array->this_var] = EG(This);
- + EX_CV(op_array->this_var) = (zval **) EX_CV_NUM(execute_data, op_array->last_var + op_array->this_var);
- + *EX_CV(op_array->this_var) = EG(This);
- } else {
- - if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void **) &EX(CVs)[op_array->this_var])==FAILURE) {
- + if (zend_hash_add(EG(active_symbol_table), "this", sizeof("this"), &EG(This), sizeof(zval *), (void **) EX_CV_NUM(execute_data, op_array->this_var))==FAILURE) {
- Z_DELREF_P(EG(This));
- }
- }
- diff --git a/Zend/zend_vm_gen.php b/Zend/zend_vm_gen.php
- index bd5f2de..6c9dcaf 100644
- --- a/Zend/zend_vm_gen.php
- +++ b/Zend/zend_vm_gen.php
- @@ -118,75 +118,75 @@ $op2_free = array(
- );
- $op1_get_zval_ptr = array(
- - "ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \)",
- - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
- - "VAR" => "_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
- + "ANY" => "get_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \)",
- + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
- "CONST" => "opline->op1.zv",
- "UNUSED" => "NULL",
- - "CV" => "_get_zval_ptr_cv_\(EX_CVs(), opline->op1.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_cv_\(execute_data, opline->op1.var TSRMLS_CC)",
- );
- $op2_get_zval_ptr = array(
- - "ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \)",
- - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
- - "VAR" => "_get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
- + "ANY" => "get_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \)",
- + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
- "CONST" => "opline->op2.zv",
- "UNUSED" => "NULL",
- - "CV" => "_get_zval_ptr_cv_\(EX_CVs(), opline->op2.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_cv_\(execute_data, opline->op2.var TSRMLS_CC)",
- );
- $op1_get_zval_ptr_ptr = array(
- - "ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \)",
- + "ANY" => "get_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \)",
- "TMP" => "NULL",
- - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
- "CONST" => "NULL",
- "UNUSED" => "NULL",
- - "CV" => "_get_zval_ptr_ptr_cv_\(EX_CVs(), opline->op1.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_ptr_cv_\(execute_data, opline->op1.var TSRMLS_CC)",
- );
- $op2_get_zval_ptr_ptr = array(
- - "ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \)",
- + "ANY" => "get_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \)",
- "TMP" => "NULL",
- - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
- "CONST" => "NULL",
- "UNUSED" => "NULL",
- - "CV" => "_get_zval_ptr_ptr_cv_\(EX_CVs(), opline->op2.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_ptr_cv_\(execute_data, opline->op2.var TSRMLS_CC)",
- );
- $op1_get_obj_zval_ptr = array(
- - "ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \)",
- - "TMP" => "_get_zval_ptr_tmp(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
- - "VAR" => "_get_zval_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
- + "ANY" => "get_obj_zval_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \)",
- + "TMP" => "_get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
- "CONST" => "opline->op1.zv",
- "UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
- - "CV" => "_get_zval_ptr_cv_\(EX_CVs(), opline->op1.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_cv_\(execute_data, opline->op1.var TSRMLS_CC)",
- );
- $op2_get_obj_zval_ptr = array(
- - "ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \)",
- - "TMP" => "_get_zval_ptr_tmp(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
- - "VAR" => "_get_zval_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
- + "ANY" => "get_obj_zval_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \)",
- + "TMP" => "_get_zval_ptr_tmp(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
- "CONST" => "opline->op2.zv",
- "UNUSED" => "_get_obj_zval_ptr_unused(TSRMLS_C)",
- - "CV" => "_get_zval_ptr_cv_\(EX_CVs(), opline->op2.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_cv_\(execute_data, opline->op2.var TSRMLS_CC)",
- );
- $op1_get_obj_zval_ptr_ptr = array(
- - "ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, EX_Ts(), &free_op1, \)",
- + "ANY" => "get_obj_zval_ptr_ptr(opline->op1_type, &opline->op1, execute_data, &free_op1, \)",
- "TMP" => "NULL",
- - "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, EX_Ts(), &free_op1 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC)",
- "CONST" => "NULL",
- "UNUSED" => "_get_obj_zval_ptr_ptr_unused(TSRMLS_C)",
- - "CV" => "_get_zval_ptr_ptr_cv_\(EX_CVs(), opline->op1.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_ptr_cv_\(execute_data, opline->op1.var TSRMLS_CC)",
- );
- $op2_get_obj_zval_ptr_ptr = array(
- - "ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, EX_Ts(), &free_op2, \)",
- + "ANY" => "get_obj_zval_ptr_ptr(opline->op2_type, &opline->op2, execute_data, &free_op2, \)",
- "TMP" => "NULL",
- - "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, EX_Ts(), &free_op2 TSRMLS_CC)",
- + "VAR" => "_get_zval_ptr_ptr_var(opline->op2.var, execute_data, &free_op2 TSRMLS_CC)",
- "CONST" => "NULL",
- "UNUSED" => "_get_obj_zval_ptr_ptr_unused(TSRMLS_C)",
- - "CV" => "_get_zval_ptr_ptr_cv_\(EX_CVs(), opline->op2.var TSRMLS_CC)",
- + "CV" => "_get_zval_ptr_ptr_cv_\(execute_data, opline->op2.var TSRMLS_CC)",
- );
- $op1_is_tmp_free = array(
- @@ -841,14 +841,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
- out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
- - out($f,"#undef EX_CV\n");
- - out($f,"#define EX_CV(var) EX(CVs)[var]\n");
- - out($f,"#undef EX_CVs\n");
- - out($f,"#define EX_CVs() EX(CVs)\n");
- - out($f,"#undef EX_T\n");
- - out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n");
- - out($f,"#undef EX_Ts\n");
- - out($f,"#define EX_Ts() EX(Ts)\n\n");
- break;
- case ZEND_VM_KIND_SWITCH:
- out($f,"\n");
- @@ -868,7 +860,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
- out($f,"#define CHECK_EXCEPTION() LOAD_OPLINE()\n");
- out($f,"#define HANDLE_EXCEPTION() LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
- out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
- - out($f,"#define LOAD_REGS() do {Ts = EX(Ts); CVs = EX(CVs);} while (0)\n");
- + out($f,"#define LOAD_REGS()\n");
- out($f,"#define ZEND_VM_CONTINUE() goto zend_vm_continue\n");
- out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
- out($f,"#define ZEND_VM_ENTER() execute_data = zend_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC); LOAD_REGS(); LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
- @@ -877,14 +869,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
- out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
- - out($f,"#undef EX_CV\n");
- - out($f,"#define EX_CV(var) CVs[var]\n");
- - out($f,"#undef EX_CVs\n");
- - out($f,"#define EX_CVs() CVs\n");
- - out($f,"#undef EX_T\n");
- - out($f,"#define EX_T(offset) T(offset)\n");
- - out($f,"#undef EX_Ts\n");
- - out($f,"#define EX_Ts() Ts\n\n");
- break;
- case ZEND_VM_KIND_GOTO:
- out($f,"\n");
- @@ -904,7 +888,7 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
- out($f,"#define CHECK_EXCEPTION() if (UNEXPECTED(EG(exception) != NULL)) goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
- out($f,"#define HANDLE_EXCEPTION() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
- out($f,"#define HANDLE_EXCEPTION_LEAVE() goto ZEND_HANDLE_EXCEPTION_SPEC_HANDLER\n");
- - out($f,"#define LOAD_REGS() do {Ts = EX(Ts); CVs = EX(CVs);} while (0)\n");
- + out($f,"#define LOAD_REGS()\n");
- out($f,"#define ZEND_VM_CONTINUE() goto *(void**)(OPLINE->handler)\n");
- out($f,"#define ZEND_VM_RETURN() EG(in_execution) = original_in_execution; return\n");
- out($f,"#define ZEND_VM_ENTER() execute_data = zend_create_execute_data_from_op_array(EG(active_op_array), 1 TSRMLS_CC); LOAD_REGS(); LOAD_OPLINE(); ZEND_VM_CONTINUE()\n");
- @@ -913,14 +897,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
- out($f,"#define ZEND_OPCODE_HANDLER_ARGS_PASSTHRU_INTERNAL execute_data TSRMLS_CC\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
- - out($f,"#undef EX_CV\n");
- - out($f,"#define EX_CV(var) CVs[var]\n");
- - out($f,"#undef EX_CVs\n");
- - out($f,"#define EX_CVs() CVs\n");
- - out($f,"#undef EX_T\n");
- - out($f,"#define EX_T(offset) T(offset)\n\n");
- - out($f,"#undef EX_Ts\n");
- - out($f,"#define EX_Ts() Ts\n\n");
- break;
- }
- break;
- @@ -929,8 +905,6 @@ function gen_executor($f, $skl, $spec, $kind, $executor_name, $initializer_name,
- break;
- case "HELPER_VARS":
- if ($kind != ZEND_VM_KIND_CALL) {
- - out($f,$m[1]."temp_variable *Ts;\n");
- - out($f,$m[1]."zval ***CVs;\n");
- if ($kind == ZEND_VM_KIND_SWITCH) {
- out($f,$m[1]."opcode_handler_t dispatch_handler;\n");
- }
- @@ -1243,12 +1217,6 @@ function gen_vm($def, $skel) {
- out($f,"\n/* Old executor */\n\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data.element\n\n");
- - out($f,"#undef EX_CV\n");
- - out($f,"#define EX_CV(var) EX(CVs)[var]\n");
- - out($f,"#undef EX_CVs\n");
- - out($f,"#define EX_CVs() EX(CVs)\n");
- - out($f,"#undef EX_T\n");
- - out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n\n");
- out($f,"#undef ZEND_VM_CONTINUE\n\n");
- out($f,"#undef ZEND_VM_RETURN\n\n");
- out($f,"#undef ZEND_VM_ENTER\n\n");
- @@ -1323,12 +1291,6 @@ function gen_vm($def, $skel) {
- out($f,"#define HANDLE_EXCEPTION_LEAVE() LOAD_OPLINE(); ZEND_VM_LEAVE()\n");
- out($f,"#undef EX\n");
- out($f,"#define EX(element) execute_data->element\n\n");
- - out($f,"#undef EX_CV\n");
- - out($f,"#define EX_CV(var) EX(CVs)[var]\n");
- - out($f,"#undef EX_CVs\n");
- - out($f,"#define EX_CVs() EX(CVs)\n");
- - out($f,"#undef EX_T\n");
- - out($f,"#define EX_T(offset) (*(temp_variable *)((char *) EX(Ts) + offset))\n\n");
- out($f,"#undef ZEND_VM_CONTINUE\n");
- out($f,"#undef ZEND_VM_RETURN\n");
- out($f,"#undef ZEND_VM_ENTER\n");
Advertisement
Add Comment
Please, Sign In to add comment