cvs: ZendEngine2 / zend_compile.h zend_exceptions.c zend_execute.c zend_execute.h zend_execute_API.c zend_opcode.c zend_vm.h zend_vm_handlers.h
zend_vm_spec.h
| From: | Andi Gutmans | Date: | Wed, 08 Sep 2004 22:14:13 +0000 |
| Subject: | cvs: ZendEngine2 / zend_compile.h zend_exceptions.c zend_execute.c zend_execute.h zend_execute_API.c zend_opcode.c zend_vm.h zend_vm_handlers.h zend_vm_spec.h |
||
| Groups: | php.zend-engine.cvs | ||
| Request: | Send a blank email to php-zend-engine-cvs+get-2933@lists.php.net to get a copy of this message | ||
andi Wed Sep 8 18:14:13 2004 EDT
Added files:
/ZendEngine2 zend_vm.h zend_vm_handlers.h zend_vm_spec.h
Modified files:
/ZendEngine2 zend_compile.h zend_exceptions.c zend_execute.c
zend_execute.h zend_execute_API.c zend_opcode.c
Log:
- Some architectural changes:
a) We specialize opcodes according to op_type fields. Each opcode has to
be marked with which op_type's it uses.
b) We support different execution methods. Function handlers, switch()
and goto dispatching. goto seems to be the fastest but it really
depends on the compiler and how well it optimizes. I suggest playing
around with optimization flags.
- Warning: Things might break so keep us posted on how things are going.
(Dmitry, Andi)
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.289&r2=1.290&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.289 ZendEngine2/zend_compile.h:1.290 --- ZendEngine2/zend_compile.h:1.289 Thu Aug 19 16:03:06 2004 +++ ZendEngine2/zend_compile.h Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.289 2004/08/19 20:03:06 andi Exp $ */ +/* $Id: zend_compile.h,v 1.290 2004/09/08 22:14:12 andi Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -72,7 +72,7 @@ typedef int (*opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS); -extern ZEND_API opcode_handler_t zend_opcode_handlers[512]; +extern ZEND_API opcode_handler_t *zend_opcode_handlers; struct _zend_op { opcode_handler_t handler; http://cvs.php.net/diff.php/ZendEngine2/zend_exceptions.c?r1=1.70&r2=1.71&ty=u Index: ZendEngine2/zend_exceptions.c diff -u ZendEngine2/zend_exceptions.c:1.70 ZendEngine2/zend_exceptions.c:1.71 --- ZendEngine2/zend_exceptions.c:1.70 Tue Jul 27 12:21:56 2004 +++ ZendEngine2/zend_exceptions.c Wed Sep 8 18:14:12 2004 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_exceptions.c,v 1.70 2004/07/27 16:21:56 helly Exp $ */ +/* $Id: zend_exceptions.c,v 1.71 2004/09/08 22:14:12 andi Exp $ */ #include "zend.h" #include "zend_API.h" @@ -175,7 +175,7 @@ if (argc >= 4) { zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC); if (argc < 5) { - lineno = 0; // invalidate lineno + lineno = 0; /* invalidate lineno */ } zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC); } http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.671&r2=1.672&ty=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.671 ZendEngine2/zend_execute.c:1.672 --- ZendEngine2/zend_execute.c:1.671 Mon Aug 30 04:57:40 2004 +++ ZendEngine2/zend_execute.c Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.671 2004/08/30 08:57:40 stas Exp $ */ +/* $Id: zend_execute.c,v 1.672 2004/09/08 22:14:12 andi Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -34,6 +34,9 @@ #include "zend_fast_cache.h" #include "zend_ini.h" #include "zend_exceptions.h" +#include "zend_vm.h" + +typedef int (*incdec_t)(zval *); #define get_zval_ptr(node, Ts, should_free, type) _get_zval_ptr(node, Ts, should_free TSRMLS_CC) #define get_zval_ptr_ptr(node, Ts, should_free, type) _get_zval_ptr_ptr(node, Ts, should_free TSRMLS_CC) @@ -41,10 +44,6 @@ #define get_obj_zval_ptr_ptr(node, Ts, should_free, type) _get_obj_zval_ptr_ptr(node, Ts, should_free TSRMLS_CC) /* Prototypes */ -static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type TSRMLS_DC); -static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC); -static void zend_fetch_property_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC); -static void zend_fetch_dimension_address_from_tmp_var(znode *result, znode *op1, znode *op2, temp_variable *Ts TSRMLS_DC); static void zend_extension_statement_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_fcall_begin_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_fcall_end_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC); @@ -59,7 +58,7 @@ /* former zend_execute_locks.h */ typedef struct _zend_free_op { zval* var; - int is_var; +/* int is_var; */ } zend_free_op; static inline void zend_pzval_unlock_func(zval *z, zend_free_op *should_free) @@ -68,7 +67,7 @@ z->refcount = 1; z->is_ref = 0; should_free->var = z; - should_free->is_var = 1; +/* should_free->is_var = 1; */ } else { should_free->var = 0; } @@ -98,15 +97,15 @@ #define FREE_OP(should_free) \ if (should_free.var) { \ - if (!should_free.is_var) { \ - zval_dtor(should_free.var); \ + if ((long)should_free.var & 1L) { \ + zval_dtor((zval*)((long)should_free.var & ~1L)); \ } else { \ zval_ptr_dtor(&should_free.var); \ } \ } -#define FREE_OP_VAR(should_free) \ - if (should_free.var && should_free.is_var) { \ +#define FREE_OP_IF_VAR(should_free) \ + if (should_free.var != NULL && (((long)should_free.var & 1L) == 0)) { \ zval_ptr_dtor(&should_free.var); \ } @@ -115,20 +114,29 @@ zval_ptr_dtor(&should_free.var); \ } -#define IS_TMP_FREE(should_free) (should_free.var && !should_free.is_var) +#define TMP_FREE(z) (zval*)(((long)(z)) | 1L) + +#define IS_TMP_FREE(should_free) ((long)should_free.var & 1L) + +#define INIT_PZVAL_COPY(z,v) \ + (z)->value = (v)->value; \ + (z)->type = (v)->type; \ + (z)->refcount = 1; \ + (z)->is_ref = 0; /* End of zend_execute_locks.h */ static inline zval *_get_zval_ptr(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) { - should_free->is_var = 0; +/* should_free->is_var = 0; */ switch (node->op_type) { case IS_CONST: should_free->var = 0; return &node->u.constant; break; case IS_TMP_VAR: - return should_free->var = &T(node->u.var).tmp_var; + should_free->var = TMP_FREE(&T(node->u.var).tmp_var); + return &T(node->u.var).tmp_var; break; case IS_VAR: if (T(node->u.var).var.ptr) { @@ -139,7 +147,7 @@ zval *str = T->str_offset.str; /* string offset */ - should_free->var = &T(node->u.var).tmp_var; + should_free->var = TMP_FREE(&T(node->u.var).tmp_var); if (T->str_offset.str->type != IS_STRING || ((int)T->str_offset.offset<0) @@ -185,49 +193,131 @@ } } -static inline void zend_fetch_property_address_inner(zval *object, znode *op2, znode *result, temp_variable *Ts, int type TSRMLS_DC) +#ifdef ZEND_VM_SPEC + +static inline zval *_get_zval_ptr_const(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) { - zend_free_op free_op2; - zval *prop_ptr = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - zval tmp; + return &node->u.constant; +} +static inline zval *_get_zval_ptr_tmp(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return should_free->var = &T(node->u.var).tmp_var; +} - switch (op2->op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *prop_ptr; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - prop_ptr = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(prop_ptr); - break; - } +static inline zval *_get_zval_ptr_var(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (T(node->u.var).var.ptr) { + PZVAL_UNLOCK(T(node->u.var).var.ptr, should_free); + return T(node->u.var).var.ptr; + } else { + temp_variable *T = &T(node->u.var); + zval *str = T->str_offset.str; - if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **ptr_ptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, prop_ptr TSRMLS_CC); - if(NULL == ptr_ptr) { - zend_error(E_ERROR, "Cannot access undefined property %s::$%s for object with overloaded property access", Z_OBJCE_P(object)->name, Z_STRVAL_P(prop_ptr)); + /* string offset */ + should_free->var = TMP_FREE(&T(node->u.var).tmp_var); + + if (T->str_offset.str->type != IS_STRING + || ((int)T->str_offset.offset<0) + || (T->str_offset.str->value.str.len <= T->str_offset.offset)) { + zend_error(E_NOTICE, "Uninitialized string offset: %d", T->str_offset.offset); + T->tmp_var.value.str.val = STR_EMPTY_ALLOC(); + T->tmp_var.value.str.len = 0; + } else { + char c = str->value.str.val[T->str_offset.offset]; + + T->tmp_var.value.str.val = estrndup(&c, 1); + T->tmp_var.value.str.len = 1; } - T(result->u.var).var.ptr_ptr = ptr_ptr; - } else if (Z_OBJ_HT_P(object)->read_property) { - T(result->u.var).var.ptr = Z_OBJ_HT_P(object)->read_property(object, prop_ptr, BP_VAR_W TSRMLS_CC); - T(result->u.var).var.ptr_ptr = &T(result->u.var).var.ptr; + PZVAL_UNLOCK_FREE(str); + T->tmp_var.refcount=1; + T->tmp_var.is_ref=1; + T->tmp_var.type = IS_STRING; + return &T->tmp_var; + } +} + +static inline zval *_get_zval_ptr_unused(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval **_get_zval_ptr_ptr_const(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval **_get_zval_ptr_ptr_tmp(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval **_get_zval_ptr_ptr_var(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (T(node->u.var).var.ptr_ptr) { + PZVAL_UNLOCK(*T(node->u.var).var.ptr_ptr, should_free); } else { - zend_error(E_WARNING, "This object doesn't support property references"); - T(result->u.var).var.ptr_ptr = &EG(error_zval_ptr); + /* string offset */ + PZVAL_UNLOCK(T(node->u.var).str_offset.str, should_free); } - - if (prop_ptr == &tmp) { - zval_dtor(prop_ptr); + return T(node->u.var).var.ptr_ptr; +} + +static inline zval **_get_zval_ptr_ptr_unused(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval *_get_obj_zval_ptr_const(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_const(op, Ts, should_free TSRMLS_CC); +} + +static inline zval *_get_obj_zval_ptr_tmp(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_tmp(op, Ts, should_free TSRMLS_CC); +} + +static inline zval *_get_obj_zval_ptr_var(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_var(op, Ts, should_free TSRMLS_CC); +} + +static inline zval *_get_obj_zval_ptr_unused(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (EG(This)) { + return EG(This); + } else { + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); + return NULL; } - FREE_OP(free_op2); } +static inline zval **_get_obj_zval_ptr_ptr_const(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_ptr_const(op, Ts, should_free TSRMLS_CC); +} + +static inline zval **_get_obj_zval_ptr_ptr_tmp(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_ptr_tmp(op, Ts, should_free TSRMLS_CC); +} + +static inline zval **_get_obj_zval_ptr_ptr_var(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_ptr_var(op, Ts, should_free TSRMLS_CC); +} +static inline zval **_get_obj_zval_ptr_ptr_unused(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (EG(This)) { + return &EG(This); + } else { + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); + return NULL; + } +} +#endif static inline void zend_switch_free(zend_op *opline, temp_variable *Ts TSRMLS_DC) { @@ -253,13 +343,13 @@ } } -void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC) +static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **value_ptr_ptr TSRMLS_DC) { zval *variable_ptr; zval *value_ptr; if (!value_ptr_ptr || !variable_ptr_ptr) { - zend_error(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); return; } @@ -305,12 +395,6 @@ } (*variable_ptr_ptr)->is_ref = 1; } - - if (result && !RETURN_VALUE_UNUSED(result)) { - T(result->u.var).var.ptr_ptr = variable_ptr_ptr; - PZVAL_LOCK(*variable_ptr_ptr); - AI_USE_PTR(T(result->u.var).var); - } } static inline void make_real_object(zval **object_ptr TSRMLS_DC) @@ -336,7 +420,7 @@ should_free->var = 0; return &EG(This); } else { - zend_error(E_ERROR, "Using $this when not in object context"); + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); } } return _get_zval_ptr_ptr(op, Ts, should_free TSRMLS_CC); @@ -349,7 +433,7 @@ should_free->var = 0; return EG(This); } else { - zend_error(E_ERROR, "Using $this when not in object context"); + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); } } return _get_zval_ptr(op, Ts, should_free TSRMLS_CC); @@ -369,12 +453,12 @@ if (cur_arg_info->class_name) { if (!arg) { - zend_error(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); + zend_error_noreturn(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); } switch (Z_TYPE_P(arg)) { case IS_NULL: if (!cur_arg_info->allow_null) { - zend_error(E_ERROR, "Argument %d must not be null", arg_num); + zend_error_noreturn(E_ERROR, "Argument %d must not be null", arg_num); } break; case IS_OBJECT: { @@ -387,17 +471,18 @@ } else { error_msg = "be an instance of"; } - zend_error(E_ERROR, "Argument %d must %s %s", arg_num, error_msg, ce->name); + zend_error_noreturn(E_ERROR, "Argument %d must %s %s", arg_num, error_msg, ce->name); } } break; default: - zend_error(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); + zend_error_noreturn(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); break; } } } + static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode *op2, znode *value_op, temp_variable *Ts, int opcode TSRMLS_DC) { zval *object; @@ -431,7 +516,7 @@ value->is_ref = 0; value->refcount = 0; if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(orig_value)->name); + zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(orig_value)->name); } zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(orig_value)->name); value->value.obj = Z_OBJ_HANDLER_P(orig_value, clone_obj)(orig_value TSRMLS_CC); @@ -478,7 +563,7 @@ } else { /* Note: property_name in this case is really the array index! */ if (!Z_OBJ_HT_P(object)->write_dimension) { - zend_error(E_ERROR, "Cannot use object as array"); + zend_error_noreturn(E_ERROR, "Cannot use object as array"); } Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC); } @@ -490,7 +575,7 @@ PZVAL_LOCK(value); } zval_ptr_dtor(&value); - FREE_OP_VAR(free_value); + FREE_OP_IF_VAR(free_value); } @@ -529,7 +614,7 @@ if (value->type!=IS_STRING) { tmp = *value; - if (op2 && op2->op_type == IS_VAR) { + if (op2->op_type == IS_VAR) { zval_copy_ctor(&tmp); } convert_to_string(&tmp); @@ -538,28 +623,26 @@ T->str_offset.str->value.str.val[T->str_offset.offset] = final_value->value.str.val[0]; - if (op2) { - if (op2->op_type == IS_VAR) { - if (value == &T(op2->u.var).tmp_var) { - if (result->u.EA.type & EXT_TYPE_UNUSED) { - /* We are not going to use return value, drop it */ - STR_FREE(value->value.str.val); - } else { - /* We are going to use return value, make it real zval */ - ALLOC_ZVAL(value); - *value = T(op2->u.var).tmp_var; - value->is_ref = 0; - value->refcount = 0; /* LOCK will increase it */ - } - } - } else { - if (final_value == &T(op2->u.var).tmp_var) { - /* we can safely free final_value here - * because separation is done only - * in case op2->op_type == IS_VAR */ - STR_FREE(final_value->value.str.val); + if (op2->op_type == IS_VAR) { + if (value == &T(op2->u.var).tmp_var) { + if (result->u.EA.type & EXT_TYPE_UNUSED) { + /* We are not going to use return value, drop it */ + STR_FREE(value->value.str.val); + } else { + /* We are going to use return value, make it real zval */ + ALLOC_ZVAL(value); + *value = T(op2->u.var).tmp_var; + value->is_ref = 0; + value->refcount = 0; /* LOCK will increase it */ } } + } else { + if (final_value == &T(op2->u.var).tmp_var) { + /* we can safely free final_value here + * because separation is done only + * in case op2->op_type == IS_VAR */ + STR_FREE(final_value->value.str.val); + } } if (final_value == &tmp) { zval_dtor(final_value); @@ -605,7 +688,7 @@ if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) { if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(value)->name); + zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(value)->name); } else if (PZVAL_IS_REF(variable_ptr)) { if (variable_ptr != value) { zend_uint refcount = variable_ptr->refcount; @@ -724,6 +807,29 @@ } +static inline void zend_receive(zval **variable_ptr_ptr, zval *value TSRMLS_DC) +{ + zval *variable_ptr = *variable_ptr_ptr; + + if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) { + if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { + zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(value)->name); + } else { + variable_ptr->refcount--; + ALLOC_ZVAL(variable_ptr); + *variable_ptr_ptr = variable_ptr; + *variable_ptr = *value; + INIT_PZVAL(variable_ptr); + zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(value)->name); + variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC); + } + } else { + variable_ptr->refcount--; + *variable_ptr_ptr = value; + value->refcount++; + } +} + /* Utility Functions for Extensions */ static void zend_extension_statement_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) { @@ -749,12 +855,6 @@ } -static void print_refcount(zval *p, char *str) -{ - print_refcount(NULL, NULL); -} - - static inline HashTable *zend_get_target_symbol_table(zend_op *opline, temp_variable *Ts, int type, zval *variable TSRMLS_DC) { switch (opline->op2.u.EA.type) { @@ -776,81 +876,8 @@ return NULL; } - -static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type TSRMLS_DC) -{ - zend_free_op free_op1; - zval *varname = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R); - zval **retval; - zval tmp_varname; - HashTable *target_symbol_table; - zend_bool free_tmp = 0; - - if (varname->type != IS_STRING) { - tmp_varname = *varname; - zval_copy_ctor(&tmp_varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; - free_tmp = 1; - } - - if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { - target_symbol_table = NULL; - retval = zend_std_get_static_property(T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 0 TSRMLS_CC); - } else { - if (opline->op2.u.EA.type == ZEND_FETCH_GLOBAL && opline->op1.op_type == IS_VAR) { - varname->refcount++; - } - target_symbol_table = zend_get_target_symbol_table(opline, Ts, type, varname TSRMLS_CC); - if (!target_symbol_table) { - return; - } - if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &retval) == FAILURE) { - switch (type) { - case BP_VAR_R: - zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); - /* break missing intentionally */ - case BP_VAR_IS: - retval = &EG(uninitialized_zval_ptr); - break; - case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); - /* break missing intentionally */ - case BP_VAR_W: { - zval *new_zval = &EG(uninitialized_zval); - - new_zval->refcount++; - zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); - } - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - } - switch (opline->op2.u.EA.type) { - case ZEND_FETCH_LOCAL: - FREE_OP(free_op1); - break; - case ZEND_FETCH_STATIC: - zval_update_constant(retval, (void*) 1 TSRMLS_CC); - break; - } - } - - - if (free_tmp) { - zval_dtor(varname); - } - if (!RETURN_VALUE_UNUSED(&opline->result)) { - T(opline->result.u.var).var.ptr_ptr = retval; - PZVAL_LOCK(*retval); - } -} - - -static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, znode *op2, temp_variable *Ts, int type TSRMLS_DC) +static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, zval *dim, int type TSRMLS_DC) { - zend_free_op free_op2; - zval *dim = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); zval **retval; char *offset_key; int offset_key_length; @@ -938,32 +965,27 @@ } break; } - FREE_OP(free_op2); return retval; } -static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) +static void zend_fetch_dimension_address(temp_variable *result, zval **container_ptr, zval *dim, int type TSRMLS_DC) { - zend_free_op free_op1; - zval **container_ptr = get_zval_ptr_ptr(op1, Ts, &free_op1, type); zval *container; - zval ***retval = &T(result->u.var).var.ptr_ptr; if (!container_ptr) { - zend_error(E_ERROR, "Cannot use string offset as an array"); + zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } container = *container_ptr; if (container == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(result)) { - *retval = &EG(error_zval_ptr); - PZVAL_LOCK(**retval); + if (result) { + result->var.ptr_ptr = &EG(error_zval_ptr); + PZVAL_LOCK(*result->var.ptr_ptr); if (type == BP_VAR_R || type == BP_VAR_IS) { - AI_USE_PTR(T(result->u.var).var); + AI_USE_PTR(result->var); } } - FREE_OP_VAR_PTR(free_op1); return; } @@ -983,54 +1005,59 @@ } switch (container->type) { + zval **retval; + case IS_ARRAY: if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) { SEPARATE_ZVAL(container_ptr); container = *container_ptr; } + if (dim == NULL) { +/* if (op2->op_type == IS_UNUSED) { +*/ zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - if (zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) retval) == FAILURE) { + if (zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) &retval) == FAILURE) { zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied"); - *retval = &EG(uninitialized_zval_ptr); + retval = &EG(uninitialized_zval_ptr); new_zval->refcount--; } } else { - *retval = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, type TSRMLS_CC); + retval = zend_fetch_dimension_address_inner(container->value.ht, dim, type TSRMLS_CC); + } + if (result) { + result->var.ptr_ptr = retval; + PZVAL_LOCK(*result->var.ptr_ptr); } - SELECTIVE_PZVAL_LOCK(**retval, result); break; case IS_NULL: { /* for read-mode only */ - zend_free_op free_op2; - - get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - *retval = &EG(uninitialized_zval_ptr); - SELECTIVE_PZVAL_LOCK(**retval, result); - FREE_OP(free_op2); + if (result) { + result->var.ptr_ptr = &EG(uninitialized_zval_ptr); + PZVAL_LOCK(*result->var.ptr_ptr); + } if (type==BP_VAR_W || type==BP_VAR_RW) { zend_error(E_WARNING, "Cannot use a NULL value as an array"); } break; } case IS_STRING: { - zend_free_op free_op2; - zval *offset; zval tmp; + if (dim == NULL) { +/* if (op2->op_type==IS_UNUSED) { - zend_error(E_ERROR, "[] operator not supported for strings"); +*/ + zend_error_noreturn(E_ERROR, "[] operator not supported for strings"); } - offset = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - - if (offset->type != IS_LONG) { - tmp = *offset; + if (dim->type != IS_LONG) { + tmp = *dim; zval_copy_ctor(&tmp); convert_to_long(&tmp); - offset = &tmp; + dim = &tmp; } switch (type) { case BP_VAR_R: @@ -1042,25 +1069,23 @@ SEPARATE_ZVAL_IF_NOT_REF(container_ptr); break; } - container = *container_ptr; - T(result->u.var).str_offset.str = container; - PZVAL_LOCK(container); - T(result->u.var).str_offset.offset = offset->value.lval; - FREE_OP(free_op2); - *retval = NULL; - if (type == BP_VAR_R || type == BP_VAR_IS) { - AI_USE_PTR(T(result->u.var).var); + if (result) { + container = *container_ptr; + result->str_offset.str = container; + PZVAL_LOCK(container); + result->str_offset.offset = dim->value.lval; + result->var.ptr_ptr = NULL; + if (type == BP_VAR_R || type == BP_VAR_IS) { + AI_USE_PTR(result->var); + } } - FREE_OP_VAR_PTR(free_op1); return; } break; case IS_OBJECT: if (!Z_OBJ_HT_P(container)->read_dimension) { - zend_error(E_ERROR, "Cannot use object as array"); + zend_error_noreturn(E_ERROR, "Cannot use object as array"); } else { - zend_free_op free_op2; - zval *dim = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); zval *overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC); if (overloaded_result) { @@ -1069,83 +1094,62 @@ case BP_VAR_W: if (overloaded_result->type != IS_OBJECT && !overloaded_result->is_ref) { - zend_error(E_ERROR, "Objects used as arrays in post/pre increment/decrement must return values by reference"); + zend_error_noreturn(E_ERROR, "Objects used as arrays in post/pre increment/decrement must return values by reference"); } break; } - *retval = &overloaded_result; + retval = &overloaded_result; } else { - *retval = &EG(error_zval_ptr); + retval = &EG(error_zval_ptr); + } + if (result) { + result->var.ptr_ptr = retval; + AI_USE_PTR(result->var); + PZVAL_LOCK(*result->var.ptr_ptr); } - AI_USE_PTR(T(result->u.var).var); - FREE_OP(free_op2); - SELECTIVE_PZVAL_LOCK(**retval, result); + return; } break; - default: { - zend_free_op free_op2; - - get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - + default: { switch (type) { case BP_VAR_UNSET: zend_error(E_WARNING, "Cannot unset offset in a non-array variable"); /* break missing intentionally */ case BP_VAR_R: case BP_VAR_IS: - *retval = &EG(uninitialized_zval_ptr); + retval = &EG(uninitialized_zval_ptr); break; default: - *retval = &EG(error_zval_ptr); + retval = &EG(error_zval_ptr); break; } - FREE_OP(free_op2); - SELECTIVE_PZVAL_LOCK(**retval, result); + if (result) { + result->var.ptr_ptr = retval; + PZVAL_LOCK(*result->var.ptr_ptr); + } if (type==BP_VAR_W || type==BP_VAR_RW) { zend_error(E_WARNING, "Cannot use a scalar value as an array"); } } break; } - if (type == BP_VAR_R || type == BP_VAR_IS) { - AI_USE_PTR(T(result->u.var).var); - } - FREE_OP_VAR_PTR(free_op1); -} - - -static void zend_fetch_dimension_address_from_tmp_var(znode *result, znode *op1, znode *op2, temp_variable *Ts TSRMLS_DC) -{ - zend_free_op free_op1; - zval *container = get_zval_ptr(op1, Ts, &free_op1, BP_VAR_R); - - if (container->type != IS_ARRAY) { - if (!RETURN_VALUE_UNUSED(result)) { - T(result->u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); - PZVAL_LOCK(*T(result->u.var).var.ptr_ptr); - } - return; + if (result && (type == BP_VAR_R || type == BP_VAR_IS)) { + AI_USE_PTR(result->var); } - - T(result->u.var).var.ptr_ptr = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, BP_VAR_R TSRMLS_CC); - SELECTIVE_PZVAL_LOCK(*T(result->u.var).var.ptr_ptr, result); } -static void zend_fetch_property_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) +static void zend_fetch_property_address(temp_variable *result, zval **container_ptr, zval *prop_ptr, int op2_type, int type TSRMLS_DC) { - zend_free_op free_op1; - zval **container_ptr = get_obj_zval_ptr_ptr(op1, Ts, &free_op1, type); zval *container; - zval ***retval = &T(result->u.var).var.ptr_ptr; + zval tmp; container = *container_ptr; if (container == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(result)) { - *retval = &EG(error_zval_ptr); - PZVAL_LOCK(**retval); + if (result) { + result->var.ptr_ptr = &EG(error_zval_ptr); + PZVAL_LOCK(*result->var.ptr_ptr); } - FREE_OP_VAR_PTR(free_op1); return; } /* this should modify object only if it's empty */ @@ -1165,227 +1169,103 @@ } if (container->type != IS_OBJECT) { - zend_free_op free_op2; - - get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - FREE_OP(free_op2); - if (!RETURN_VALUE_UNUSED(result)) { + if (result) { if (type == BP_VAR_R || type == BP_VAR_IS) { - *retval = &EG(uninitialized_zval_ptr); + result->var.ptr_ptr = &EG(uninitialized_zval_ptr); } else { - *retval = &EG(error_zval_ptr); + result->var.ptr_ptr = &EG(error_zval_ptr); } - PZVAL_LOCK(**retval); + PZVAL_LOCK(*result->var.ptr_ptr); } - FREE_OP_VAR_PTR(free_op1); return; } - - + if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) { SEPARATE_ZVAL(container_ptr); container = *container_ptr; } - zend_fetch_property_address_inner(container, op2, result, Ts, type TSRMLS_CC); - SELECTIVE_PZVAL_LOCK(**retval, result); - FREE_OP_VAR_PTR(free_op1); -} - -static void zend_fetch_property_address_read(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) -{ - zval *container; - zval **retval; - zend_free_op free_op1; - - retval = &T(result->u.var).var.ptr; - T(result->u.var).var.ptr_ptr = retval; - - container = get_obj_zval_ptr(op1, Ts, &free_op1, type); - if (container == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(result)) { - *retval = EG(error_zval_ptr); - PZVAL_LOCK(*retval); - AI_USE_PTR(T(result->u.var).var); - } - FREE_OP(free_op1); - return; + switch (op2_type) { + case IS_CONST: + /* already a constant string */ + break; + case IS_VAR: + tmp = *prop_ptr; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + prop_ptr = &tmp; + break; + case IS_TMP_VAR: + convert_to_string(prop_ptr); + break; } - - if (container->type != IS_OBJECT) { - zend_error(E_NOTICE, "Trying to get property of non-object"); - - if (type==BP_VAR_R || type==BP_VAR_IS) { - *retval = EG(uninitialized_zval_ptr); - } else { - *retval = EG(error_zval_ptr); + if (Z_OBJ_HT_P(container)->get_property_ptr_ptr) { + zval **ptr_ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr TSRMLS_CC); + if(NULL == ptr_ptr) { + zend_error_noreturn(E_ERROR, "Cannot access undefined property %s::$%s for object with overloaded property access", Z_OBJCE_P(container)->name, Z_STRVAL_P(prop_ptr)); } - } else { - zend_free_op free_op2; - zval *offset; - zval tmp; - - offset = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - switch (op2->op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *offset; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - offset = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(offset); - break; + if (result) { + result->var.ptr_ptr = ptr_ptr; } - - /* here we are sure we are dealing with an object */ - *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (offset == &tmp) { - zval_dtor(offset); + } else if (Z_OBJ_HT_P(container)->read_property) { + if (result) { + result->var.ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, BP_VAR_W TSRMLS_CC); + result->var.ptr_ptr = &result->var.ptr; } - FREE_OP(free_op2); - - if (RETURN_VALUE_UNUSED(result) && ((*retval)->refcount == 0)) { - zval_dtor(*retval); - FREE_ZVAL(*retval); - return; /* no need for locking */ + } else { + zend_error(E_WARNING, "This object doesn't support property references"); + if (result) { + result->var.ptr_ptr = &EG(error_zval_ptr); } } - SELECTIVE_PZVAL_LOCK(*retval, result); - AI_USE_PTR(T(result->u.var).var); - FREE_OP(free_op1); + if (prop_ptr == &tmp) { + zval_dtor(prop_ptr); + } + + if (result) { + PZVAL_LOCK(*result->var.ptr_ptr); + } } -static void zend_pre_incdec_property(znode *result, znode *op1, znode *op2, temp_variable * Ts, int (*incdec_op)(zval *) TSRMLS_DC) +static inline zend_brk_cont_element* zend_brk_cont(zval *nest_levels_zval, int array_offset, zend_op_array *op_array, temp_variable *Ts TSRMLS_DC) { - zend_free_op free_op1, free_op2; - zval **object_ptr = get_obj_zval_ptr_ptr(op1, Ts, &free_op1, BP_VAR_W); - zval *object; - zval *property = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - zval **retval = &T(result->u.var).var.ptr; - int have_get_ptr = 0; - - make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ - object = *object_ptr; - - if (object->type != IS_OBJECT) { - zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - FREE_OP(free_op2); - if (!RETURN_VALUE_UNUSED(result)) { - *retval = EG(uninitialized_zval_ptr); - PZVAL_LOCK(*retval); - } - FREE_OP_VAR_PTR(free_op1); - return; - } - - /* here we are sure we are dealing with an object */ - - if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - SEPARATE_ZVAL_IF_NOT_REF(zptr); - - have_get_ptr = 1; - incdec_op(*zptr); - if (!RETURN_VALUE_UNUSED(result)) { - *retval = *zptr; - PZVAL_LOCK(*retval); - } - } - } - - if (!have_get_ptr) { - zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); - - if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - - if (z->refcount == 0) { - zval_dtor(z); - FREE_ZVAL(z); - } - z = value; - } - z->refcount++; - SEPARATE_ZVAL_IF_NOT_REF(&z); - incdec_op(z); - *retval = z; - Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); - SELECTIVE_PZVAL_LOCK(*retval, result); - zval_ptr_dtor(&z); - } - - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); -} - -static void zend_post_incdec_property(znode *result, znode *op1, znode *op2, temp_variable * Ts, int (*incdec_op)(zval *) TSRMLS_DC) -{ - zend_free_op free_op1, free_op2; - zval **object_ptr = get_obj_zval_ptr_ptr(op1, Ts, &free_op1, BP_VAR_W); - zval *object; - zval *property = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - zval *retval = &T(result->u.var).tmp_var; - int have_get_ptr = 0; + zval tmp; + int nest_levels, original_nest_levels; + zend_brk_cont_element *jmp_to; - make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ - object = *object_ptr; - - if (object->type != IS_OBJECT) { - zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - FREE_OP(free_op2); - *retval = *EG(uninitialized_zval_ptr); - FREE_OP_VAR_PTR(free_op1); - return; + if (nest_levels_zval->type != IS_LONG) { + tmp = *nest_levels_zval; + zval_copy_ctor(&tmp); + convert_to_long(&tmp); + nest_levels = tmp.value.lval; + } else { + nest_levels = nest_levels_zval->value.lval; } - - /* here we are sure we are dealing with an object */ - - if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - have_get_ptr = 1; - SEPARATE_ZVAL_IF_NOT_REF(zptr); - - *retval = **zptr; - zendi_zval_copy_ctor(*retval); - - incdec_op(*zptr); - + original_nest_levels = nest_levels; + do { + if (array_offset==-1) { + zend_error_noreturn(E_ERROR, "Cannot break/continue %d level%s", original_nest_levels, (original_nest_levels == 1) ? "" : "s"); } - } - - if (!have_get_ptr) { - zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); - - if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); + jmp_to = &op_array->brk_cont_array[array_offset]; + if (nest_levels>1) { + zend_op *brk_opline = &op_array->opcodes[jmp_to->brk]; - if (z->refcount == 0) { - zval_dtor(z); - FREE_ZVAL(z); + switch (brk_opline->opcode) { + case ZEND_SWITCH_FREE: + zend_switch_free(brk_opline, Ts TSRMLS_CC); + break; + case ZEND_FREE: + zendi_zval_dtor(T(brk_opline->op1.u.var).tmp_var); + break; } - z = value; } - *retval = *z; - zendi_zval_copy_ctor(*retval); - incdec_op(z); - z->refcount++; - Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); - zval_ptr_dtor(&z); - } - - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); + array_offset = jmp_to->parent; + } while (--nest_levels > 0); + return jmp_to; } - #if ZEND_INTENSIVE_DEBUGGING #define CHECK_SYMBOL_TABLES() \ @@ -1414,32 +1294,7 @@ #define CHECK_SYMBOL_TABLES() #endif -#define NEXT_OPCODE() \ - CHECK_SYMBOL_TABLES() \ - EX(opline)++; \ - return 0; /* CHECK_ME */ - -#define SET_OPCODE(new_op) \ - CHECK_SYMBOL_TABLES() \ - EX(opline) = new_op; - -#define INC_OPCODE() \ - if (!EG(exception)) { \ - CHECK_SYMBOL_TABLES() \ - EX(opline)++; \ - } - -#define RETURN_FROM_EXECUTE_LOOP(execute_data) \ - if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ - free_alloca(EX(Ts)); \ - } else { \ - efree(EX(Ts)); \ - } \ - EG(in_execution) = EX(original_in_execution); \ - EG(current_execute_data) = EX(prev_execute_data); \ - return 1; /* CHECK_ME */ - -ZEND_API opcode_handler_t zend_opcode_handlers[512]; +ZEND_API opcode_handler_t *zend_opcode_handlers; ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC) { @@ -1449,6 +1304,16 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) { zend_execute_data execute_data; + ZEND_VM_HELPER_VAR(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC)) + ZEND_VM_HELPER_VAR(incdec_t incdec_op) + ZEND_VM_HELPER_VAR(int prop_dim) + ZEND_VM_HELPER_VAR(int type) + +#if ZEND_VM_KIND == ZEND_VM_KIND_GOTO + if (op_array == NULL) { + goto init_labels; + } +#endif /* Initialize execute_data */ EX(fbc) = NULL; @@ -1465,9 +1330,9 @@ EG(in_execution) = 1; if (op_array->start_op) { - SET_OPCODE(op_array->start_op); + ZEND_VM_SET_OPCODE(op_array->start_op); } else { - SET_OPCODE(op_array->opcodes); + ZEND_VM_SET_OPCODE(op_array->opcodes); } if (op_array->uses_this && EG(This)) { @@ -1489,3364 +1354,50 @@ #endif while (1) { +ZEND_VM_CONTINUE_LABEL #ifdef ZEND_WIN32 if (EG(timed_out)) { zend_timeout(0); } #endif - if (EX(opline)->handler(&execute_data TSRMLS_CC)) { + ZEND_VM_DISPATCH() { +#if ZEND_VM_KIND == ZEND_VM_KIND_CALL return; - } - } - zend_error(E_ERROR, "Arrived at end of main loop which shouldn't happen"); -} - -/* CHECK_ME */ -#undef EX -#define EX(element) execute_data->element - -int zend_add_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - add_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_sub_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - sub_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_mul_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - mul_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_div_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - div_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_mod_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - mod_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_sl_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - shift_left_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_sr_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - shift_right_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_concat_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - concat_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_identical_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_identical_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_not_identical_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_not_identical_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_equal_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_not_equal_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_not_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_smaller_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_smaller_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_smaller_or_equal_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_smaller_or_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_or_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - bitwise_or_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_and_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - bitwise_and_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_xor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - bitwise_xor_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bool_xor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - boolean_xor_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_not_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - bitwise_not_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -int zend_bool_not_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - boolean_not_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -static inline int zend_binary_assign_op_obj_helper(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op *op_data = opline+1; - zend_free_op free_op1, free_op2, free_op_data1; - zval **object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - zval *object; - zval *property = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval *value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); - zval tmp; - znode *result = &opline->result; - zval **retval = &EX_T(result->u.var).var.ptr; - int have_get_ptr = 0; - - EX_T(result->u.var).var.ptr_ptr = NULL; - make_real_object(object_ptr TSRMLS_CC); - object = *object_ptr; - - if (object->type != IS_OBJECT) { - zend_error(E_WARNING, "Attempt to assign property of non-object"); - FREE_OP(free_op2); - FREE_OP(free_op_data1); - - if (!RETURN_VALUE_UNUSED(result)) { - *retval = EG(uninitialized_zval_ptr); - PZVAL_LOCK(*retval); - } - } else { - /* here we are sure we are dealing with an object */ - switch (opline->op2.op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *property; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - property = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(property); - break; - } - - /* here property is a string */ - if (opline->extended_value == ZEND_ASSIGN_OBJ - && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - SEPARATE_ZVAL_IF_NOT_REF(zptr); - - have_get_ptr = 1; - binary_op(*zptr, *zptr, value TSRMLS_CC); - if (!RETURN_VALUE_UNUSED(result)) { - *retval = *zptr; - PZVAL_LOCK(*retval); - } - } - } - - if (!have_get_ptr) { - zval *z; - - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); - break; - case ZEND_ASSIGN_DIM: - z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_RW TSRMLS_CC); - break; - } - if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - - if (z->refcount == 0) { - zval_dtor(z); - FREE_ZVAL(z); - } - z = value; - } - z->refcount++; - SEPARATE_ZVAL_IF_NOT_REF(&z); - binary_op(z, z, value TSRMLS_CC); - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); - break; - case ZEND_ASSIGN_DIM: - Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); - break; - } - if (!RETURN_VALUE_UNUSED(result)) { - *retval = z; - PZVAL_LOCK(*retval); - } - zval_ptr_dtor(&z); +#else +# include "zend_vm_spec.h" +#endif } - if (property == &tmp) { - zval_dtor(property); - } - - FREE_OP(free_op2); - FREE_OP(free_op_data1); } + zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); +#if ZEND_VM_KIND == ZEND_VM_KIND_GOTO + { + static const opcode_handler_t labels[] = {ZEND_VM_LABELS}; - FREE_OP_VAR_PTR(free_op1); - /* assign_obj has two opcodes! */ - INC_OPCODE(); - NEXT_OPCODE(); + init_labels: + zend_opcode_handlers = (opcode_handler_t*)labels; + return; + } +#endif } +#if ZEND_VM_KIND == ZEND_VM_KIND_CALL +# undef EX +# define EX(element) execute_data->element +# include"zend_vm_spec.h" +#endif -static inline int zend_binary_assign_op_helper(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +void zend_init_opcodes_handlers() { - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2, free_op_data2; - zval **var_ptr; - zval *value; - zend_bool increment_opline = 0; - - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - return zend_binary_assign_op_obj_helper(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - break; - case ZEND_ASSIGN_DIM: { - zval **object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ - - if ((*object_ptr)->type == IS_OBJECT) { - return zend_binary_assign_op_obj_helper(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } else { - zend_op *op_data = opline+1; - - zend_fetch_dimension_address(&op_data->op2, &opline->op1, &opline->op2, EX(Ts), BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op2, BP_VAR_R); - var_ptr = get_zval_ptr_ptr(&op_data->op2, EX(Ts), &free_op_data2, BP_VAR_RW); - increment_opline = 1; - } - } - break; - default: - value = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - var_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_RW); - /* do nothing */ - break; - } - - if (!var_ptr) { - zend_error(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); - } - - if (*var_ptr == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - FREE_OP_VAR_PTR(free_op1); - if (increment_opline) { - INC_OPCODE(); - } - NEXT_OPCODE(); - } - - SEPARATE_ZVAL_IF_NOT_REF(var_ptr); - - if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) - && Z_OBJ_HANDLER_PP(var_ptr, set)) { - /* proxy object */ - zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; - binary_op(objval, objval, value TSRMLS_CC); - Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); - zval_ptr_dtor(&objval); - } else { - binary_op(*var_ptr, *var_ptr, value TSRMLS_CC); - } - - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; - PZVAL_LOCK(*var_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - FREE_OP(free_op2); - - if (increment_opline) { - INC_OPCODE(); - FREE_OP_VAR_PTR(free_op_data2); - } - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); -} - - -int zend_assign_add_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(add_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_sub_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(sub_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_mul_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(mul_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_div_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(div_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_mod_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(mod_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_sl_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(shift_left_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_sr_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(shift_right_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_concat_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(concat_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_bw_or_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(bitwise_or_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_bw_and_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(bitwise_and_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_bw_xor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(bitwise_xor_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -int zend_pre_inc_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_pre_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), increment_function TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_pre_dec_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_pre_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), decrement_function TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_post_inc_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_post_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), increment_function TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_post_dec_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_post_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), decrement_function TSRMLS_CC); - NEXT_OPCODE(); -} - -typedef int (*incdec_t)(zval *); - -static inline int zend_incdec_op_helper(incdec_t incdec_op_arg, ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval **var_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_RW); - int (*incdec_op)(zval *op1) = incdec_op_arg; - - if (!var_ptr) { - zend_error(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); - } - if (*var_ptr == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); - } - - switch (opline->opcode) { - case ZEND_POST_INC: - case ZEND_POST_DEC: - EX_T(opline->result.u.var).tmp_var = **var_ptr; - zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); - break; - } - - SEPARATE_ZVAL_IF_NOT_REF(var_ptr); - - if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) - && Z_OBJ_HANDLER_PP(var_ptr, set)) { - /* proxy object */ - zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; - incdec_op(val); - Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); - zval_ptr_dtor(&val); - } else { - incdec_op(*var_ptr); - } - - switch (opline->opcode) { - case ZEND_PRE_INC: - case ZEND_PRE_DEC: - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; - PZVAL_LOCK(*var_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - break; - } - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); -} - - -int zend_pre_inc_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(increment_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_pre_dec_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(decrement_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_post_inc_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(increment_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_post_dec_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(decrement_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_echo_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval z_copy; - zval *z = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -int zend_print_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).tmp_var.value.lval = 1; - EX_T(opline->result.u.var).tmp_var.type = IS_LONG; - - return zend_echo_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_fetch_r_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_R TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - NEXT_OPCODE(); -} - - -int zend_fetch_w_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_W TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_rw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_RW TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_func_arg_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { - /* Behave like FETCH_W */ - zend_fetch_var_address(opline, EX(Ts), BP_VAR_W TSRMLS_CC); - } else { - /* Behave like FETCH_R */ - zend_fetch_var_address(opline, EX(Ts), BP_VAR_R TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - NEXT_OPCODE(); -} - - -int zend_fetch_unset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_res; - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_R TSRMLS_CC); - PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); - if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); - } - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - FREE_OP_VAR_PTR(free_res); - NEXT_OPCODE(); -} - - -int zend_fetch_is_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_IS TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_r_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - } - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_w_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_rw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_RW TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_is_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_IS TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_func_arg_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { - /* Behave like FETCH_DIM_W */ - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - } else { - /* Behave like FETCH_DIM_R, except for locking used for list() */ - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_fetch_dim_unset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - /* Not needed in DIM_UNSET - if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - } - */ - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_UNSET TSRMLS_CC); - if (EX_T(opline->result.u.var).var.ptr_ptr == NULL) { - zend_error(E_ERROR, "Cannot unset string offsets"); - } else { - zend_free_op free_res; - - PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); - if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); - } - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - FREE_OP_VAR_PTR(free_res); - } - NEXT_OPCODE(); -} - - -int zend_fetch_obj_r_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_property_address_read(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_w_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - EX_T(opline->op1.u.var).var.ptr = *EX_T(opline->op1.u.var).var.ptr_ptr; - } - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_rw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_RW TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_is_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_property_address_read(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_IS TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_func_arg_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { - /* Behave like FETCH_OBJ_W */ - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - } else { - zend_fetch_property_address_read(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_fetch_obj_unset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_res; - - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - - PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); - if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); - } - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - FREE_OP_VAR_PTR(free_res); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_tmp_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address_from_tmp_var(&opline->result, &opline->op1, &opline->op2, EX(Ts) TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - NEXT_OPCODE(); -} - - -int zend_assign_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op *op_data = opline+1; - zend_free_op free_op1; - zval **object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_OBJ TSRMLS_CC); - FREE_OP_VAR_PTR(free_op1); - /* assign_obj has two opcodes! */ - INC_OPCODE(); - NEXT_OPCODE(); -} - - -int zend_assign_dim_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op *op_data = opline+1; - zend_free_op free_op1; - zval **object_ptr; - - if (EX_T(opline->op1.u.var).var.ptr_ptr) { - /* not an array offset */ - object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - } else { - object_ptr = NULL; - free_op1.var = NULL; - } - - if (object_ptr && (*object_ptr)->type == IS_OBJECT) { - zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_DIM TSRMLS_CC); - } else { - zend_free_op free_op_data1; - zval *value; - - if (object_ptr) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ - } - zend_fetch_dimension_address(&op_data->op2, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - - value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); - zend_assign_to_variable(&opline->result, &op_data->op2, &op_data->op1, value, (IS_TMP_FREE(free_op_data1)?IS_TMP_VAR:op_data->op1.op_type), EX(Ts) TSRMLS_CC); - FREE_OP_VAR(free_op_data1); - } - FREE_OP_VAR_PTR(free_op1); - /* assign_dim has two opcodes! */ - INC_OPCODE(); - NEXT_OPCODE(); -} - - -int zend_assign_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op2; - zval *value = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - zend_assign_to_variable(&opline->result, &opline->op1, &opline->op2, value, (IS_TMP_FREE(free_op2)?IS_TMP_VAR:opline->op2.op_type), EX(Ts) TSRMLS_CC); - /* zend_assign_to_variable() always takes care of op2, never free it! */ - FREE_OP_VAR(free_op2); - - NEXT_OPCODE(); -} - - -int zend_assign_ref_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval **value_ptr_ptr = get_zval_ptr_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_W); - - zend_assign_to_variable_reference(&opline->result, get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W), value_ptr_ptr, EX(Ts) TSRMLS_CC); - - FREE_OP_VAR_PTR(free_op1); - FREE_OP_VAR_PTR(free_op2); - - NEXT_OPCODE(); -} - - -int zend_jmp_handler(ZEND_OPCODE_HANDLER_ARGS) -{ -#if DEBUG_ZEND>=2 - printf("Jumping to %d\n", opline->op1.u.opline_num); -#endif - SET_OPCODE(EX(opline)->op1.u.jmp_addr); - return 0; /* CHECK_ME */ -} - - -int zend_jmpz_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - znode *op1 = &opline->op1; - zend_free_op free_op1; - - if (!i_zend_is_true(get_zval_ptr(op1, EX(Ts), &free_op1, BP_VAR_R))) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - FREE_OP(free_op1); - return 0; /* CHECK_ME */ - } - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -int zend_jmpnz_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - znode *op1 = &opline->op1; - zend_free_op free_op1; - - if (zend_is_true(get_zval_ptr(op1, EX(Ts), &free_op1, BP_VAR_R))) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - FREE_OP(free_op1); - return 0; /* CHECK_ME */ - } - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -int zend_jmpznz_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - znode *res = &opline->op1; - zend_free_op free_op1; - - if (zend_is_true(get_zval_ptr(res, EX(Ts), &free_op1, BP_VAR_R))) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp on true to %d\n", opline->extended_value); -#endif - SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); - } else { -#if DEBUG_ZEND>=2 - printf("Conditional jmp on false to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(&EX(op_array)->opcodes[opline->op2.u.opline_num]); - } - FREE_OP(free_op1); - - return 0; /* CHECK_ME */ -} - - -int zend_jmpz_ex_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - int retval = zend_is_true(get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R)); - - FREE_OP(free_op1); - EX_T(opline->result.u.var).tmp_var.value.lval = retval; - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - if (!retval) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - return 0; /* CHECK_ME */ - } - NEXT_OPCODE(); -} - - -int zend_jmpnz_ex_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - int retval = zend_is_true(get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R)); - - FREE_OP(free_op1); - EX_T(opline->result.u.var).tmp_var.value.lval = retval; - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - if (retval) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - return 0; /* CHECK_ME */ - } - NEXT_OPCODE(); -} - - -int zend_free_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zendi_zval_dtor(EX_T(EX(opline)->op1.u.var).tmp_var); - NEXT_OPCODE(); -} - - -int zend_init_string_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zval *tmp = &EX_T(EX(opline)->result.u.var).tmp_var; - - tmp->value.str.val = emalloc(1); - tmp->value.str.val[0] = 0; - tmp->value.str.len = 0; - tmp->refcount = 1; - tmp->type = IS_STRING; - tmp->is_ref = 0; - NEXT_OPCODE(); -} - - -int zend_add_char_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - add_char_to_string(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_NA), - &opline->op2.u.constant); - /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ - NEXT_OPCODE(); -} - - -int zend_add_string_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - add_string_to_string(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_NA), - &opline->op2.u.constant); - /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ - NEXT_OPCODE(); -} - - -int zend_add_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval *var = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval var_copy; - int use_copy; - - zend_make_printable_zval(var, &var_copy, &use_copy); - if (use_copy) { - var = &var_copy; - } - add_string_to_string( &EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_NA), - var); - if (use_copy) { - zval_dtor(var); - } - /* original comment, possibly problematic: - * FREE_OP is missing intentionally here - we're always working on the same temporary variable - * (Zeev): I don't think it's problematic, we only use variables - * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're - * string offsets or overloaded objects - */ - FREE_OP(free_op2); - - NEXT_OPCODE(); -} - - -int zend_fetch_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *class_name; - zend_free_op free_op2; - - - if (opline->op2.op_type == IS_UNUSED) { - EX_T(opline->result.u.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); - NEXT_OPCODE(); - } - - class_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - switch (class_name->type) { - case IS_OBJECT: - EX_T(opline->result.u.var).class_entry = Z_OBJCE_P(class_name); - break; - case IS_STRING: - EX_T(opline->result.u.var).class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); - break; - default: - zend_error(E_ERROR, "Class name must be a valid object or a string"); - break; - } - - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_init_ctor_call_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - if (opline->op1.op_type == IS_VAR) { - SELECTIVE_PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr, &opline->op1); - } - - /* We are not handling overloaded classes right now */ - EX(object) = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - /* New always returns the object as is_ref=0, therefore, we can just increment the reference count */ - EX(object)->refcount++; /* For $this pointer */ - - EX(fbc) = EX(fbc_constructor); - - if (EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */ - EX(calling_scope) = EX(fbc)->common.scope; - } else { - EX(calling_scope) = NULL; - } - - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_init_method_call_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *function_name; - char *function_name_strval; - int function_name_strlen; - zend_free_op free_op1, free_op2; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - function_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (Z_TYPE_P(function_name)!=IS_STRING) { - zend_error(E_ERROR, "Method name must be a string"); - } - - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - - EX(calling_scope) = EG(scope); - - EX(object) = get_obj_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (EX(object) && EX(object)->type == IS_OBJECT) { - if (Z_OBJ_HT_P(EX(object))->get_method == NULL) { - zend_error(E_ERROR, "Object does not support method calls"); - } - - /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(EX(object), function_name_strval, function_name_strlen TSRMLS_CC); - if (!EX(fbc)) { - zend_error(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); - } - } else { - zend_error(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); - } - - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; - } else { - if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ - } else { - zval *this_ptr; - ALLOC_ZVAL(this_ptr); - *this_ptr = *EX(object); - INIT_PZVAL(this_ptr); - zval_copy_ctor(this_ptr); - EX(object) = this_ptr; - } - } - - if (EX(fbc)->type == ZEND_USER_FUNCTION) { - EX(calling_scope) = EX(fbc)->common.scope; - } else { - EX(calling_scope) = NULL; - } - - FREE_OP(free_op2); - FREE_OP_VAR(free_op1); - - NEXT_OPCODE(); -} - - -int zend_init_static_method_call_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *function_name; - zend_class_entry *ce; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - ce = EX_T(opline->op1.u.var).class_entry; - if(opline->op2.op_type != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (opline->op2.op_type == IS_CONST); - zend_free_op free_op2; - - if (is_const) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; - } else { - function_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (Z_TYPE_P(function_name) != IS_STRING) { - zend_error(E_ERROR, "Function name must be a string"); - } - function_name_strval = zend_str_tolower_dup(function_name->value.str.val, function_name->value.str.len); - function_name_strlen = function_name->value.str.len; - } - - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); - - if (!is_const) { - efree(function_name_strval); - FREE_OP(free_op2); - } - } else { - if(!ce->constructor) { - zend_error(E_ERROR, "Can not call constructor"); - } - EX(fbc) = ce->constructor; - } - - EX(calling_scope) = EX(fbc)->common.scope; - - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; - } else { - if ((EX(object) = EG(This))) { - EX(object)->refcount++; - } - } - - NEXT_OPCODE(); -} - -int zend_init_fcall_by_name_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *function_name; - zend_function *function; - char *function_name_strval, *lcname; - int function_name_strlen; - zend_free_op free_op2; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - if (opline->op2.op_type == IS_CONST) { - free_op2.var = 0; - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; - } else { - function_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (Z_TYPE_P(function_name) != IS_STRING) { - zend_error(E_ERROR, "Function name must be a string"); - } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); - zend_error(E_ERROR, "Call to undefined function %s()", function_name_strval); - } - - efree(lcname); - FREE_OP(free_op2); - - EX(calling_scope) = function->common.scope; - EX(object) = NULL; - - EX(fbc) = function; - - NEXT_OPCODE(); -} - -int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval **original_return_value; - zend_class_entry *current_scope; - zval *current_this; - int return_value_used = RETURN_VALUE_USED(opline); - zend_bool should_change_scope; - - if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_error(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); - NEXT_OPCODE(); /* Never reached */ - } - - zend_ptr_stack_2_push(&EG(argument_stack), (void *) opline->extended_value, NULL); - - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - - if (EX(function_state).function->type == ZEND_USER_FUNCTION - || EX(function_state).function->common.scope) { - should_change_scope = 1; - current_this = EG(This); - EG(This) = EX(object); - current_scope = EG(scope); - EG(scope) = EX(calling_scope); - } else { - should_change_scope = 0; - } - - EX_T(opline->result.u.var).var.fcall_returned_reference = 0; - - if (EX(function_state).function->common.scope) { - if (!EG(This) && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { - int severity; - char *severity_word; - if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - severity = E_STRICT; - severity_word = "should not"; - } else { - severity = E_ERROR; - severity_word = "cannot"; - } - zend_error(severity, "Non-static method %s::%s() %s be called statically", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name, severity_word); - } - } - if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); - - if (EX(function_state).function->common.arg_info) { - zend_uint i=0; - zval **p; - ulong arg_count; - - p = (zval **) EG(argument_stack).top_element-2; - arg_count = (ulong) *p; - - while (arg_count>0) { - zend_verify_arg_type(EX(function_state).function, ++i, *(p-arg_count) TSRMLS_CC); - arg_count--; - } - } - if (!zend_execute_internal) { - /* saves one function call if zend_execute_internal is not used */ - ((zend_internal_function *) EX(function_state).function)->handler(opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); - } else { - zend_execute_internal(execute_data, return_value_used TSRMLS_CC); - } - - EG(current_execute_data) = execute_data; - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; - if (!return_value_used) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - } else if (EX(function_state).function->type == ZEND_USER_FUNCTION) { - HashTable *calling_symbol_table; - - EX_T(opline->result.u.var).var.ptr = NULL; - if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { - /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ - EX(function_state).function_symbol_table = *(EG(symtable_cache_ptr)--); - } else { - ALLOC_HASHTABLE(EX(function_state).function_symbol_table); - zend_hash_init(EX(function_state).function_symbol_table, 0, NULL, ZVAL_PTR_DTOR, 0); - /*printf("Cache miss! Initialized %x\n", function_state.function_symbol_table);*/ - } - calling_symbol_table = EG(active_symbol_table); - EG(active_symbol_table) = EX(function_state).function_symbol_table; - original_return_value = EG(return_value_ptr_ptr); - EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; - EG(active_op_array) = (zend_op_array *) EX(function_state).function; - - zend_execute(EG(active_op_array) TSRMLS_CC); - EX_T(opline->result.u.var).var.fcall_returned_reference = EG(active_op_array)->return_reference; - - if (return_value_used && !EX_T(opline->result.u.var).var.ptr) { - if (!EG(exception)) { - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); - } - } else if (!return_value_used && EX_T(opline->result.u.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(return_value_ptr_ptr)=original_return_value; - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EX(function_state).function_symbol_table); - FREE_HASHTABLE(EX(function_state).function_symbol_table); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EX(function_state).function_symbol_table); - *(++EG(symtable_cache_ptr)) = EX(function_state).function_symbol_table; - } - EG(active_symbol_table) = calling_symbol_table; - } else { /* ZEND_OVERLOADED_FUNCTION */ - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); - - /* Not sure what should be done here if it's a static method */ - if (EX(object)) { - Z_OBJ_HT_P(EX(object))->call_method(EX(fbc)->common.function_name, opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); - } else { - zend_error(E_ERROR, "Cannot call overloaded function for non-object"); - } - - if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { - efree(EX(function_state).function->common.function_name); - } - efree(EX(fbc)); - - if (!return_value_used) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } else { - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; - } - } - - if (EG(This)) { - if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) { - EG(This)->refcount--; - if (EG(This)->refcount == 1) { - zend_object_store_ctor_failed(EG(This) TSRMLS_CC); - } - zval_ptr_dtor(&EG(This)); - } else if (should_change_scope) { - zval_ptr_dtor(&EG(This)); - } - } - - if (should_change_scope) { - EG(This) = current_this; - EG(scope) = current_scope; - } - zend_ptr_stack_3_pop(&EG(arg_types_stack), (void**)&EX(calling_scope), (void**)&EX(object), (void**)&EX(fbc)); - - EX(function_state).function = (zend_function *) EX(op_array); - EG(function_state_ptr) = &EX(function_state); - zend_ptr_stack_clear_multiple(TSRMLS_C); - - if (EG(exception)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - if (return_value_used && EX_T(opline->result.u.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - } - - NEXT_OPCODE(); -} - - -int zend_do_fcall_by_name_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - EX(function_state).function = EX(fbc); - return zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_do_fcall_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *fname = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { - zend_error(E_ERROR, "Unknown function: %s()\n", fname->value.str.val); - } - EX(object) = NULL; - EX(calling_scope) = EX(function_state).function->common.scope; - - FREE_OP(free_op1); - - return zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_return_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *retval_ptr; - zval **retval_ptr_ptr; - zend_free_op free_op1; - - if (EG(active_op_array)->return_reference == ZEND_RETURN_REF) { - - if (opline->op1.op_type == IS_CONST || opline->op1.op_type == IS_TMP_VAR) { - /* Not supposed to happen, but we'll allow it */ - zend_error(E_STRICT, "Only variable references should be returned by reference"); - goto return_by_value; - } - - retval_ptr_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - if (!retval_ptr_ptr) { - zend_error(E_ERROR, "Cannot return string offsets by reference"); - } - - if (!(*retval_ptr_ptr)->is_ref) { - if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr - || (opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op1.u.var).var.fcall_returned_reference)) { - zend_error(E_STRICT, "Only variable references should be returned by reference"); - PZVAL_LOCK(*retval_ptr_ptr); /* undo the effect of get_zval_ptr_ptr() */ - goto return_by_value; - } - } - - SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; - - (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); - FREE_OP_VAR_PTR(free_op1); - } else { -return_by_value: - - retval_ptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) { - ALLOC_ZVAL(*(EG(return_value_ptr_ptr))); - **EG(return_value_ptr_ptr) = *retval_ptr; - INIT_PZVAL(*EG(return_value_ptr_ptr)); - if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(retval_ptr)->name); - } - zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name); - (*EG(return_value_ptr_ptr))->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC); - } else if (!IS_TMP_FREE(free_op1)) { /* Not a temp var */ - if (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0) { - ALLOC_ZVAL(*(EG(return_value_ptr_ptr))); - **EG(return_value_ptr_ptr) = *retval_ptr; - (*EG(return_value_ptr_ptr))->is_ref = 0; - (*EG(return_value_ptr_ptr))->refcount = 1; - zval_copy_ctor(*EG(return_value_ptr_ptr)); - } else { - *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; - } - } else { - ALLOC_ZVAL(*(EG(return_value_ptr_ptr))); - **EG(return_value_ptr_ptr) = *retval_ptr; - (*EG(return_value_ptr_ptr))->refcount = 1; - (*EG(return_value_ptr_ptr))->is_ref = 0; - } - FREE_OP_VAR(free_op1); - } - RETURN_FROM_EXECUTE_LOOP(execute_data); -} - - -int zend_throw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *value; - zval *exception; - zend_free_op free_op1; - - value = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (value->type != IS_OBJECT) { - zend_error(E_ERROR, "Can only throw objects"); - } - /* Not sure if a complete copy is what we want here */ - MAKE_STD_ZVAL(exception); - *exception = *value; - if (!IS_TMP_FREE(free_op1)) { - zval_copy_ctor(exception); - } - INIT_PZVAL(exception); - - zend_throw_exception_object(exception TSRMLS_CC); - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_catch_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_class_entry *ce; - - /* Check whether an exception has been thrown, if not, jump over code */ - if (EG(exception) == NULL) { - SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); - return 0; /* CHECK_ME */ - } - ce = Z_OBJCE_P(EG(exception)); - if (ce != EX_T(opline->op1.u.var).class_entry) { - if (!instanceof_function(ce, EX_T(opline->op1.u.var).class_entry TSRMLS_CC)) { - if (opline->op1.u.EA.type) { - zend_throw_exception_internal(NULL TSRMLS_CC); - NEXT_OPCODE(); - } - SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); - return 0; /* CHECK_ME */ - } - } - - zend_hash_update(EG(active_symbol_table), opline->op2.u.constant.value.str.val, - opline->op2.u.constant.value.str.len+1, &EG(exception), sizeof(zval *), (void **) NULL); - EG(exception) = NULL; - NEXT_OPCODE(); -} - - -int zend_send_val_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { - zend_error(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); - } - { - zval *valptr; - zval *value; - zend_free_op free_op1; - - value = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - ALLOC_ZVAL(valptr); - *valptr = *value; - if (!IS_TMP_FREE(free_op1)) { - zval_copy_ctor(valptr); - } - INIT_PZVAL(valptr); - zend_ptr_stack_push(&EG(argument_stack), valptr); - FREE_OP_VAR(free_op1); - } - NEXT_OPCODE(); -} - - -static inline int zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *varptr; - zend_free_op free_op1; - varptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (varptr == &EG(uninitialized_zval)) { - ALLOC_ZVAL(varptr); - INIT_ZVAL(*varptr); - varptr->refcount = 0; - } else if (PZVAL_IS_REF(varptr)) { - zval *original_var = varptr; - - ALLOC_ZVAL(varptr); - *varptr = *original_var; - varptr->is_ref = 0; - varptr->refcount = 0; - zval_copy_ctor(varptr); - } - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - FREE_OP(free_op1); /* for string offsets */ - - NEXT_OPCODE(); -} - - -int zend_send_var_no_ref_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ - if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { - return zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { - return zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - { - zval *varptr; - zend_free_op free_op1; - varptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { - varptr->is_ref = 1; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); - } - zend_error(E_ERROR, "Only variables can be passed by reference"); - } - NEXT_OPCODE(); -} - - -int zend_send_ref_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval **varptr_ptr; - zval *varptr; - varptr_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - if (!varptr_ptr) { - zend_error(E_ERROR, "Only variables can be passed by reference"); - } - - SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); - varptr = *varptr_ptr; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); -} - - -int zend_send_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { - return zend_send_ref_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - return zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_recv_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval **param; - zend_uint arg_num = opline->op1.u.constant.value.lval; - - if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { - char *space; - char *class_name = get_active_class_name(&space TSRMLS_CC); - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC); - zend_error(E_WARNING, "Missing argument %ld for %s%s%s()", opline->op1.u.constant.value.lval, class_name, space, get_active_function_name(TSRMLS_C)); - if (opline->result.op_type == IS_VAR) { - PZVAL_UNLOCK_FREE(*EX_T(opline->result.u.var).var.ptr_ptr); - } - } else { - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param TSRMLS_CC); - if (PZVAL_IS_REF(*param)) { - zend_free_op free_res; - - zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W), param, NULL TSRMLS_CC); - FREE_OP_VAR_PTR(free_res); - } else { - zend_assign_to_variable(NULL, &opline->result, NULL, *param, IS_VAR, EX(Ts) TSRMLS_CC); - } - } - - NEXT_OPCODE(); -} - - -int zend_recv_init_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval **param, *assignment_value; - zend_uint arg_num = opline->op1.u.constant.value.lval; - - if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { - if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { - zval *default_value; - - ALLOC_ZVAL(default_value); - *default_value = opline->op2.u.constant; - if (opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { - zval_copy_ctor(default_value); - } - default_value->refcount=1; - zval_update_constant(&default_value, 0 TSRMLS_CC); - default_value->refcount=0; - default_value->is_ref=0; - param = &default_value; - assignment_value = default_value; - } else { - param = NULL; - assignment_value = &opline->op2.u.constant; - } - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); - zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC); - } else { - assignment_value = *param; - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); - if (PZVAL_IS_REF(assignment_value)) { - zend_free_op free_res; - - zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W), param, NULL TSRMLS_CC); - FREE_OP_VAR_PTR(free_res); - } else { - zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC); - } - } - - NEXT_OPCODE(); -} - - -int zend_bool_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - EX_T(opline->result.u.var).tmp_var.value.lval = zend_is_true(get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R)); - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -static inline int zend_brk_cont_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op2; - zval *nest_levels_zval = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval tmp; - int array_offset, nest_levels, original_nest_levels; - zend_brk_cont_element *jmp_to; - - if (nest_levels_zval->type != IS_LONG) { - tmp = *nest_levels_zval; - zval_copy_ctor(&tmp); - convert_to_long(&tmp); - nest_levels = tmp.value.lval; - } else { - nest_levels = nest_levels_zval->value.lval; - } - original_nest_levels = nest_levels; - array_offset = opline->op1.u.opline_num; - do { - if (array_offset==-1) { - zend_error(E_ERROR, "Cannot break/continue %d level%s", original_nest_levels, (original_nest_levels == 1) ? "" : "s"); - } - jmp_to = &EX(op_array)->brk_cont_array[array_offset]; - if (nest_levels>1) { - zend_op *brk_opline = &EX(op_array)->opcodes[jmp_to->brk]; - - switch (brk_opline->opcode) { - case ZEND_SWITCH_FREE: - zend_switch_free(brk_opline, EX(Ts) TSRMLS_CC); - break; - case ZEND_FREE: - zendi_zval_dtor(EX_T(brk_opline->op1.u.var).tmp_var); - break; - } - } - array_offset = jmp_to->parent; - } while (--nest_levels > 0); - - if (opline->opcode == ZEND_BRK) { - SET_OPCODE(EX(op_array)->opcodes+jmp_to->brk); - } else { - SET_OPCODE(EX(op_array)->opcodes+jmp_to->cont); - } - FREE_OP(free_op2); - return 0; /* CHECK_ME */ -} - - -int zend_brk_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_brk_cont_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_cont_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_brk_cont_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_case_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - int switch_expr_is_overloaded=0; - zend_free_op free_op1, free_op2; - - if (opline->op1.op_type==IS_VAR) { - if (EX_T(opline->op1.u.var).var.ptr_ptr) { - PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); - } else { - switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; - } - } - is_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - - FREE_OP(free_op2); - if (switch_expr_is_overloaded) { - /* We only free op1 if this is a string offset, - * Since if it is a TMP_VAR, it'll be reused by - * other CASE opcodes (whereas string offsets - * are allocated at each get_zval_ptr()) - */ - FREE_OP(free_op1); - EX_T(opline->op1.u.var).var.ptr_ptr = NULL; - AI_USE_PTR(EX_T(opline->op1.u.var).var); - } - NEXT_OPCODE(); -} - - -int zend_switch_free_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_switch_free(EX(opline), EX(Ts) TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_new_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (EX_T(opline->op1.u.var).class_entry->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { - char *class_type; - - if (EX_T(opline->op1.u.var).class_entry->ce_flags & ZEND_ACC_INTERFACE) { - class_type = "interface"; - } else { - class_type = "abstract class"; - } - zend_error(E_ERROR, "Cannot instantiate %s %s", class_type, EX_T(opline->op1.u.var).class_entry->name); - } - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - object_init_ex(EX_T(opline->result.u.var).var.ptr, EX_T(opline->op1.u.var).class_entry); - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=0; - - NEXT_OPCODE(); -} - - -int zend_clone_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *obj = get_obj_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zend_class_entry *ce; - zend_function *clone; - zend_object_clone_obj_t clone_call; - - if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { - zend_error(E_WARNING, "__clone method called on non-object"); - EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); - } - - ce = Z_OBJCE_P(obj); - clone = ce ? ce->clone : NULL; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; - if (!clone_call) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name); - EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; - } - - if (ce && clone) { - if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) { - /* Ensure that if we're calling a private function, we're allowed to do so. - */ - if (ce != EG(scope)) { - zend_error(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); - } - } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) { - /* Ensure that if we're calling a protected function, we're allowed to do so. - */ - if (!zend_check_protected(clone->common.scope, EG(scope))) { - zend_error(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); - } - } - } - - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - EX_T(opline->result.u.var).var.ptr->value.obj = clone_call(obj TSRMLS_CC); - if (EG(exception)) { - FREE_ZVAL(EX_T(opline->result.u.var).var.ptr); - } else { - EX_T(opline->result.u.var).var.ptr->type = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; - } - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_fetch_constant_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_class_entry *ce = NULL; - zval **value; - - if (opline->op1.op_type == IS_UNUSED) { -/* This seems to be a reminant of namespaces - if (EG(scope)) { - ce = EG(scope); - if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { - zval_update_constant(value, (void *) 1 TSRMLS_CC); - EX_T(opline->result.u.var).tmp_var = **value; - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - NEXT_OPCODE(); - } - } -*/ - if (!zend_get_constant(opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len, &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) { - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", - opline->op2.u.constant.value.str.val, - opline->op2.u.constant.value.str.val); - EX_T(opline->result.u.var).tmp_var = opline->op2.u.constant; - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - } - NEXT_OPCODE(); - } - - ce = EX_T(opline->op1.u.var).class_entry; - - if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { - zval_update_constant(value, (void *) 1 TSRMLS_CC); - EX_T(opline->result.u.var).tmp_var = **value; - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - } else { - zend_error(E_ERROR, "Undefined class constant '%s'", opline->op2.u.constant.value.str.val); - } - - NEXT_OPCODE(); -} - - -static inline int zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval *array_ptr = &EX_T(opline->result.u.var).tmp_var; - zval *expr_ptr, **expr_ptr_ptr = NULL; - zval *offset=get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (opline->extended_value) { - expr_ptr_ptr=get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - expr_ptr = *expr_ptr_ptr; - } else { - expr_ptr=get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - } - - if (opline->opcode == ZEND_INIT_ARRAY) { - array_init(array_ptr); - if (!expr_ptr) { - NEXT_OPCODE(); - } - } - if (!opline->extended_value && IS_TMP_FREE(free_op1)) { /* temporary variable */ - zval *new_expr; - - ALLOC_ZVAL(new_expr); - *new_expr = *expr_ptr; - expr_ptr = new_expr; - INIT_PZVAL(expr_ptr); - } else { - if (opline->extended_value) { - SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); - expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; - } else if (PZVAL_IS_REF(expr_ptr)) { - zval *new_expr; - - ALLOC_ZVAL(new_expr); - *new_expr = *expr_ptr; - expr_ptr = new_expr; - zendi_zval_copy_ctor(*expr_ptr); - INIT_PZVAL(expr_ptr); - } else { - expr_ptr->refcount++; - } - } - if (offset) { - switch (offset->type) { - case IS_DOUBLE: - zend_hash_index_update(array_ptr->value.ht, (long) offset->value.dval, &expr_ptr, sizeof(zval *), NULL); - break; - case IS_LONG: - case IS_BOOL: - zend_hash_index_update(array_ptr->value.ht, offset->value.lval, &expr_ptr, sizeof(zval *), NULL); - break; - case IS_STRING: - zend_symtable_update(array_ptr->value.ht, offset->value.str.val, offset->value.str.len+1, &expr_ptr, sizeof(zval *), NULL); - break; - case IS_NULL: - zend_hash_update(array_ptr->value.ht, "", sizeof(""), &expr_ptr, sizeof(zval *), NULL); - break; - default: - zend_error(E_WARNING, "Illegal offset type"); - zval_ptr_dtor(&expr_ptr); - /* do nothing */ - break; - } - FREE_OP(free_op2); - } else { - zend_hash_next_index_insert(array_ptr->value.ht, &expr_ptr, sizeof(zval *), NULL); - } - if (opline->extended_value) { - FREE_OP_VAR_PTR(free_op1); - } else { - FREE_OP_VAR(free_op1); - } - NEXT_OPCODE(); -} - - -int zend_init_array_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_add_array_element_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_cast_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *expr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval *result = &EX_T(opline->result.u.var).tmp_var; - - *result = *expr; - if (!IS_TMP_FREE(free_op1)) { - zendi_zval_copy_ctor(*result); - } - switch (opline->extended_value) { - case IS_NULL: - convert_to_null(result); - break; - case IS_BOOL: - convert_to_boolean(result); - break; - case IS_LONG: - convert_to_long(result); - break; - case IS_DOUBLE: - convert_to_double(result); - break; - case IS_STRING: { - zval var_copy; - int use_copy; - - zend_make_printable_zval(result, &var_copy, &use_copy); - if (use_copy) { - zval_dtor(result); - *result = var_copy; - } - break; - } - case IS_ARRAY: - convert_to_array(result); - break; - case IS_OBJECT: - convert_to_object(result); - break; - } - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_include_or_eval_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op_array *new_op_array=NULL; - zval **original_return_value = EG(return_value_ptr_ptr); - int return_value_used; - zend_free_op free_op1; - zval *inc_filename = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval tmp_inc_filename; - zend_bool failure_retval=0; - - if (inc_filename->type!=IS_STRING) { - tmp_inc_filename = *inc_filename; - zval_copy_ctor(&tmp_inc_filename); - convert_to_string(&tmp_inc_filename); - inc_filename = &tmp_inc_filename; - } - - return_value_used = RETURN_VALUE_USED(opline); - - switch (opline->op2.u.constant.value.lval) { - case ZEND_INCLUDE_ONCE: - case ZEND_REQUIRE_ONCE: { - int dummy = 1; - zend_file_handle file_handle; - - if (SUCCESS == zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC)) { - - if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); - } - - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { - new_op_array = zend_compile_file(&file_handle, (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); - zend_destroy_file_handle(&file_handle TSRMLS_CC); - } else { - zend_file_handle_dtor(&file_handle); - failure_retval=1; - } - } else { - if (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE) { - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, inc_filename->value.str.val); - } else { - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, inc_filename->value.str.val); - } - } - break; - } - break; - case ZEND_INCLUDE: - case ZEND_REQUIRE: - new_op_array = compile_filename(opline->op2.u.constant.value.lval, inc_filename TSRMLS_CC); - break; - case ZEND_EVAL: { - char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC); - - new_op_array = compile_string(inc_filename, eval_desc TSRMLS_CC); - efree(eval_desc); - } - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - if (inc_filename==&tmp_inc_filename) { - zval_dtor(&tmp_inc_filename); - } - FREE_OP(free_op1); - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - if (new_op_array) { - zval *saved_object; - zend_function *saved_function; - - EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; - EG(active_op_array) = new_op_array; - EX_T(opline->result.u.var).var.ptr = NULL; - - saved_object = EX(object); - saved_function = EX(function_state).function; - - EX(function_state).function = (zend_function *) new_op_array; - EX(object) = NULL; - - zend_execute(new_op_array TSRMLS_CC); - - EX(function_state).function = saved_function; - EX(object) = saved_object; - - if (!return_value_used) { - if (EX_T(opline->result.u.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - } else { /* return value is used */ - if (!EX_T(opline->result.u.var).var.ptr) { /* there was no return statement */ - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_PZVAL(EX_T(opline->result.u.var).var.ptr); - EX_T(opline->result.u.var).var.ptr->value.lval = 1; - EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; - } - } - - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(function_state_ptr) = &EX(function_state); - destroy_op_array(new_op_array TSRMLS_CC); - efree(new_op_array); - if (EG(exception)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - } - } else { - if (return_value_used) { - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); - EX_T(opline->result.u.var).var.ptr->value.lval = failure_retval; - EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; - } - } - EG(return_value_ptr_ptr) = original_return_value; - NEXT_OPCODE(); -} - - -int zend_unset_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval tmp, *varname; - HashTable *target_symbol_table; - zend_free_op free_op1; - - varname = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (varname->type != IS_STRING) { - tmp = *varname; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - varname = &tmp; - } - - if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { - zend_std_unset_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname) TSRMLS_CC); - } else { - target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); - zend_hash_del(target_symbol_table, varname->value.str.val, varname->value.str.len+1); - } - - if (varname == &tmp) { - zval_dtor(&tmp); - } - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - - -int zend_unset_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval **container = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval *offset = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - long index; - - if (container) { - HashTable *ht; - - if (opline->extended_value == ZEND_UNSET_DIM) { - switch (Z_TYPE_PP(container)) { - case IS_ARRAY: - ht = Z_ARRVAL_PP(container); - break; - case IS_OBJECT: - ht = NULL; - if (!Z_OBJ_HT_P(*container)->unset_dimension) { - zend_error(E_ERROR, "Cannot use object as array"); - } - Z_OBJ_HT_P(*container)->unset_dimension(*container, offset TSRMLS_CC); - break; - case IS_STRING: - zend_error(E_ERROR, "Cannot unset string offsets"); - return 0; /* bailed out before */ - default: - ht = NULL; - break; - } - } else { /* ZEND_UNSET_OBJ */ - ht = NULL; - if (Z_TYPE_PP(container) == IS_OBJECT) { - Z_OBJ_HT_P(*container)->unset_property(*container, offset TSRMLS_CC); - } - } - if (ht) { - switch (offset->type) { - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long) offset->value.dval; - } else { - index = offset->value.lval; - } - - zend_hash_index_del(ht, index); - break; - case IS_STRING: - zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1); - break; - case IS_NULL: - zend_hash_del(ht, "", sizeof("")); - break; - default: - zend_error(E_WARNING, "Illegal offset type in unset"); - break; - } - } - } else { - /* overloaded element */ - } - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); - - NEXT_OPCODE(); -} - - -int zend_fe_reset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *array_ptr, **array_ptr_ptr; - HashTable *fe_ht; - zend_object_iterator *iter = NULL; - zend_class_entry *ce = NULL; - - if (opline->extended_value) { - array_ptr_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - if (array_ptr_ptr == NULL) { - MAKE_STD_ZVAL(array_ptr); - } else if (Z_TYPE_PP(array_ptr_ptr) == IS_OBJECT) { - ce = Z_OBJCE_PP(array_ptr_ptr); - if (!ce || ce->get_iterator == NULL) { - SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; - } - array_ptr = *array_ptr_ptr; - } else { - SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - array_ptr = *array_ptr_ptr; - array_ptr->refcount++; - } - } else { - array_ptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - if (IS_TMP_FREE(free_op1)) { /* IS_TMP_VAR */ - zval *tmp; - - ALLOC_ZVAL(tmp); - *tmp = *array_ptr; - INIT_PZVAL(tmp); - array_ptr = tmp; - } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { - ce = Z_OBJCE_P(array_ptr); - } else { - array_ptr->refcount++; - } - } - - if (ce && ce->get_iterator) { - iter = ce->get_iterator(ce, array_ptr TSRMLS_CC); - - if (iter) { - array_ptr = zend_iterator_wrap(iter TSRMLS_CC); - } else { - array_ptr->refcount++; - } - } - - PZVAL_LOCK(array_ptr); - EX_T(opline->result.u.var).var.ptr = array_ptr; - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - - if (iter) { - iter->index = 0; - if (iter->funcs->rewind) { - iter->funcs->rewind(iter TSRMLS_CC); - } - } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) { - /* probably redundant */ - zend_hash_internal_pointer_reset(fe_ht); - } else { - zend_error(E_WARNING, "Invalid argument supplied for foreach()"); - - opline++; - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - if (opline->extended_value) { - FREE_OP_VAR_PTR(free_op1); - } else { - FREE_OP_VAR(free_op1); - } - return 0; - } - - if (opline->extended_value) { - FREE_OP_VAR_PTR(free_op1); - } else { - FREE_OP_VAR(free_op1); - } - NEXT_OPCODE(); -} - - -int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *array = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval **value, *key; - char *str_key; - uint str_key_len; - ulong int_key; - HashTable *fe_ht; - zend_object_iterator *iter = NULL; - int key_type; - zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY; - - PZVAL_LOCK(array); - - switch (zend_iterator_unwrap(array, &iter TSRMLS_CC)) { - default: - case ZEND_ITER_INVALID: - zend_error(E_WARNING, "Invalid argument supplied for foreach()"); - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - - case ZEND_ITER_PLAIN_OBJECT: { - char *class_name, *prop_name; - zend_object *zobj = zend_objects_get_address(array TSRMLS_CC); - - fe_ht = HASH_OF(array); - do { - if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { - /* reached end of iteration */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); - - zend_hash_move_forward(fe_ht); - } while (key_type != HASH_KEY_IS_STRING || zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS); - if (use_key) { - zend_unmangle_property_name(str_key, &class_name, &prop_name); - str_key_len = strlen(prop_name); - str_key = estrndup(prop_name, str_key_len); - str_key_len++; - } - break; - } - - case ZEND_ITER_PLAIN_ARRAY: - fe_ht = HASH_OF(array); - if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { - /* reached end of iteration */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - if (use_key) { - key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 1, NULL); - } - zend_hash_move_forward(fe_ht); - break; - - case ZEND_ITER_OBJECT: - /* !iter happens from exception */ - if (iter && iter->index++) { - /* This could cause an endless loop if index becomes zero again. - * In case that ever happens we need an additional flag. */ - iter->funcs->move_forward(iter TSRMLS_CC); - } - if (!iter || iter->funcs->valid(iter TSRMLS_CC) == FAILURE) { - /* reached end of iteration */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - iter->funcs->get_current_data(iter, &value TSRMLS_CC); - if (!value) { - /* failure in get_current_data */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - if (use_key) { - if (iter->funcs->get_current_key) { - key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); - } else { - key_type = HASH_KEY_IS_LONG; - int_key = iter->index; - } - } - - break; - } - - if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - SEPARATE_ZVAL_IF_NOT_REF(value); - (*value)->is_ref = 1; - } - - if (!use_key) { - if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - EX_T(opline->result.u.var).var.ptr_ptr = value; - (*value)->refcount++; - } else { - zval *result = &EX_T(opline->result.u.var).tmp_var; - - *result = **value; - zval_copy_ctor(result); - } - } else { - zval *result = &EX_T(opline->result.u.var).tmp_var; - - (*value)->refcount++; - - array_init(result); - - zend_hash_index_update(result->value.ht, 0, value, sizeof(zval *), NULL); - - ALLOC_ZVAL(key); - INIT_PZVAL(key); - - switch (key_type) { - case HASH_KEY_IS_STRING: - key->value.str.val = str_key; - key->value.str.len = str_key_len-1; - key->type = IS_STRING; - break; - case HASH_KEY_IS_LONG: - key->value.lval = int_key; - key->type = IS_LONG; - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - zend_hash_index_update(result->value.ht, 1, &key, sizeof(zval *), NULL); - } - - NEXT_OPCODE(); -} - - -int zend_jmp_no_ctor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *object_zval; - zend_function *constructor; - zend_free_op free_op1; - - if (opline->op1.op_type == IS_VAR) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - } - - object_zval = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - constructor = Z_OBJ_HT_P(object_zval)->get_constructor(object_zval TSRMLS_CC); - - EX(fbc_constructor) = NULL; - if (constructor == NULL) { - if(opline->op1.u.EA.type & EXT_TYPE_UNUSED) { - zval_ptr_dtor(EX_T(opline->op1.u.var).var.ptr_ptr); - } - SET_OPCODE(EX(op_array)->opcodes + opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } else { - EX(fbc_constructor) = constructor; - } - - NEXT_OPCODE(); -} - - -int zend_isset_isempty_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval tmp, *varname = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval **value; - zend_bool isset = 1; - HashTable *target_symbol_table; - - if (varname->type != IS_STRING) { - tmp = *varname; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - varname = &tmp; - } - - if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { - value = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 1 TSRMLS_CC); - if (!value) { - isset = 0; - } - } else { - target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); - if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &value) == FAILURE) { - isset = 0; - } - } - - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - - switch (opline->extended_value) { - case ZEND_ISSET: - if (isset && Z_TYPE_PP(value) == IS_NULL) { - EX_T(opline->result.u.var).tmp_var.value.lval = 0; - } else { - EX_T(opline->result.u.var).tmp_var.value.lval = isset; - } - break; - case ZEND_ISEMPTY: - if (!isset || !zend_is_true(*value)) { - EX_T(opline->result.u.var).tmp_var.value.lval = 1; - } else { - EX_T(opline->result.u.var).tmp_var.value.lval = 0; - } - break; - } - - if (varname == &tmp) { - zval_dtor(&tmp); - } - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -static int zend_isset_isempty_dim_prop_obj_handler(int prop_dim, ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval **container = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval *offset = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval **value = NULL; - int result = 0; - long index; - - if (container) { - if ((*container)->type == IS_ARRAY) { - HashTable *ht; - int isset = 0; - - ht = (*container)->value.ht; - - switch (offset->type) { - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long) offset->value.dval; - } else { - index = offset->value.lval; - } - if (zend_hash_index_find(ht, index, (void **) &value) == SUCCESS) { - isset = 1; - } - break; - case IS_STRING: - if (zend_symtable_find(ht, offset->value.str.val, offset->value.str.len+1, (void **) &value) == SUCCESS) { - isset = 1; - } - break; - case IS_NULL: - if (zend_hash_find(ht, "", sizeof(""), (void **) &value) == SUCCESS) { - isset = 1; - } - break; - default: - zend_error(E_WARNING, "Illegal offset type in unset"); - - break; - } - - switch (opline->extended_value) { - case ZEND_ISSET: - if (isset && Z_TYPE_PP(value) == IS_NULL) { - result = 0; - } else { - result = isset; - } - break; - case ZEND_ISEMPTY: - if (!isset || !zend_is_true(*value)) { - result = 0; - } else { - result = 1; - } - break; - } - } else if ((*container)->type == IS_OBJECT) { - if (prop_dim) { - result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); - } else { - result = Z_OBJ_HT_P(*container)->has_dimension(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); - } - } else if ((*container)->type == IS_STRING) { /* string offsets */ - switch (opline->extended_value) { - case ZEND_ISSET: - if (offset->value.lval < Z_STRLEN_PP(container)) { - result = 1; - } - break; - case ZEND_ISEMPTY: - if (offset->value.lval < Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] != '0') { - result = 1; - } - break; - } - } - } - - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - - switch (opline->extended_value) { - case ZEND_ISSET: - EX_T(opline->result.u.var).tmp_var.value.lval = result; - break; - case ZEND_ISEMPTY: - EX_T(opline->result.u.var).tmp_var.value.lval = !result; - break; - } - - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); - - NEXT_OPCODE(); -} - - -int zend_isset_isempty_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_isset_isempty_dim_prop_obj_handler(0, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_isset_isempty_prop_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_isset_isempty_dim_prop_obj_handler(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -int zend_exit_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (opline->op1.op_type != IS_UNUSED) { - zval *ptr; - zend_free_op free_op1; - - ptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); - } else { - zend_print_variable(ptr); - } - FREE_OP(free_op1); - } - zend_bailout(); - NEXT_OPCODE(); -} - - -int zend_begin_silence_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); - EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); - NEXT_OPCODE(); -} - - -int zend_raise_abstract_error_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_error(E_ERROR, "Cannot call abstract method %s::%s()", EG(scope)->name, EX(op_array)->function_name); - NEXT_OPCODE(); /* Never reached */ -} - - -int zend_end_silence_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval restored_error_reporting; - - if (!EG(error_reporting)) { - restored_error_reporting.type = IS_LONG; - restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; - convert_to_string(&restored_error_reporting); - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); - zendi_zval_dtor(restored_error_reporting); - } - NEXT_OPCODE(); -} - - -int zend_qm_assign_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *value = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - EX_T(opline->result.u.var).tmp_var = *value; - if (!IS_TMP_FREE(free_op1)) { - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - } - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_ext_stmt_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - if (!EG(no_extensions)) { - zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_statement_handler, EX(op_array) TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_ext_fcall_begin_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - if (!EG(no_extensions)) { - zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_begin_handler, EX(op_array) TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_ext_fcall_end_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - if (!EG(no_extensions)) { - zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_end_handler, EX(op_array) TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_declare_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).class_entry = do_bind_class(opline, EG(class_table), 0 TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_declare_inherited_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).class_entry = do_bind_inherited_class(opline, EG(class_table), EX_T(opline->extended_value).class_entry, 0 TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_declare_function_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - do_bind_function(EX(opline), EG(function_table), 0); - NEXT_OPCODE(); -} - - -int zend_ticks_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (++EG(ticks_count)>=opline->op1.u.constant.value.lval) { - EG(ticks_count)=0; - if (zend_ticks_function) { - zend_ticks_function(opline->op1.u.constant.value.lval); - } - } - NEXT_OPCODE(); -} - - -int zend_instanceof_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *expr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zend_bool result; - - if (Z_TYPE_P(expr) == IS_OBJECT) { - result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.u.var).class_entry TSRMLS_CC); - } else { - result = 0; - } - ZVAL_BOOL(&EX_T(opline->result.u.var).tmp_var, result); - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -int zend_ext_nop_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - NEXT_OPCODE(); -} - - -int zend_nop_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - NEXT_OPCODE(); -} - -int zend_add_interface_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry; - zend_class_entry *iface = EX_T(opline->op2.u.var).class_entry; - - if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) { - zend_error(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name); - } - - ce->interfaces[opline->extended_value] = iface; - - zend_do_implement_interface(ce, iface TSRMLS_CC); - - NEXT_OPCODE(); -} - - -int zend_handle_exception_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes; - int i; - int encapsulating_block=-1; - zval **stack_zval_pp; - - stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; - while (*stack_zval_pp != NULL) { - zval_ptr_dtor(stack_zval_pp); - EG(argument_stack).top_element--; - stack_zval_pp--; - } - - for (i=0; i<EG(active_op_array)->last_try_catch; i++) { - if (EG(active_op_array)->try_catch_array[i].try_op > op_num) { - /* further blocks will not be relevant... */ - break; - } - if (op_num >= EG(active_op_array)->try_catch_array[i].try_op - && op_num < EG(active_op_array)->try_catch_array[i].catch_op) { - encapsulating_block = i; - } - } - - if (encapsulating_block == -1) { - RETURN_FROM_EXECUTE_LOOP(execute_data); - } else { - SET_OPCODE(&EX(op_array)->opcodes[EG(active_op_array)->try_catch_array[encapsulating_block].catch_op]); - return 0; - } -} - - -int zend_verify_abstract_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_verify_abstract_class(EX_T(EX(opline)->op1.u.var).class_entry TSRMLS_CC); - NEXT_OPCODE(); -} - - -void zend_init_opcodes_handlers() -{ - memset(zend_opcode_handlers, sizeof(zend_opcode_handlers), 0); - zend_opcode_handlers[ZEND_NOP] = zend_nop_handler; - zend_opcode_handlers[ZEND_ADD] = zend_add_handler; - zend_opcode_handlers[ZEND_SUB] = zend_sub_handler; - zend_opcode_handlers[ZEND_MUL] = zend_mul_handler; - zend_opcode_handlers[ZEND_DIV] = zend_div_handler; - zend_opcode_handlers[ZEND_MOD] = zend_mod_handler; - zend_opcode_handlers[ZEND_SL] = zend_sl_handler; - zend_opcode_handlers[ZEND_SR] = zend_sr_handler; - zend_opcode_handlers[ZEND_CONCAT] = zend_concat_handler; - zend_opcode_handlers[ZEND_BW_OR] = zend_bw_or_handler; - zend_opcode_handlers[ZEND_BW_AND] = zend_bw_and_handler; - zend_opcode_handlers[ZEND_BW_XOR] = zend_bw_xor_handler; - zend_opcode_handlers[ZEND_BW_NOT] = zend_bw_not_handler; - zend_opcode_handlers[ZEND_BOOL_NOT] = zend_bool_not_handler; - zend_opcode_handlers[ZEND_BOOL_XOR] = zend_bool_xor_handler; - zend_opcode_handlers[ZEND_IS_IDENTICAL] = zend_is_identical_handler; - zend_opcode_handlers[ZEND_IS_NOT_IDENTICAL] = zend_is_not_identical_handler; - zend_opcode_handlers[ZEND_IS_EQUAL] = zend_is_equal_handler; - zend_opcode_handlers[ZEND_IS_NOT_EQUAL] = zend_is_not_equal_handler; - zend_opcode_handlers[ZEND_IS_SMALLER] = zend_is_smaller_handler; - zend_opcode_handlers[ZEND_IS_SMALLER_OR_EQUAL] = zend_is_smaller_or_equal_handler; - zend_opcode_handlers[ZEND_CAST] = zend_cast_handler; - zend_opcode_handlers[ZEND_QM_ASSIGN] = zend_qm_assign_handler; - - zend_opcode_handlers[ZEND_ASSIGN_ADD] = zend_assign_add_handler; - zend_opcode_handlers[ZEND_ASSIGN_SUB] = zend_assign_sub_handler; - zend_opcode_handlers[ZEND_ASSIGN_MUL] = zend_assign_mul_handler; - zend_opcode_handlers[ZEND_ASSIGN_DIV] = zend_assign_div_handler; - zend_opcode_handlers[ZEND_ASSIGN_MOD] = zend_assign_mod_handler; - zend_opcode_handlers[ZEND_ASSIGN_SL] = zend_assign_sl_handler; - zend_opcode_handlers[ZEND_ASSIGN_SR] = zend_assign_sr_handler; - zend_opcode_handlers[ZEND_ASSIGN_CONCAT] = zend_assign_concat_handler; - zend_opcode_handlers[ZEND_ASSIGN_BW_OR] = zend_assign_bw_or_handler; - zend_opcode_handlers[ZEND_ASSIGN_BW_AND] = zend_assign_bw_and_handler; - zend_opcode_handlers[ZEND_ASSIGN_BW_XOR] = zend_assign_bw_xor_handler; - - zend_opcode_handlers[ZEND_PRE_INC] = zend_pre_inc_handler; - zend_opcode_handlers[ZEND_PRE_DEC] = zend_pre_dec_handler; - zend_opcode_handlers[ZEND_POST_INC] = zend_post_inc_handler; - zend_opcode_handlers[ZEND_POST_DEC] = zend_post_dec_handler; - - zend_opcode_handlers[ZEND_ASSIGN] = zend_assign_handler; - zend_opcode_handlers[ZEND_ASSIGN_REF] = zend_assign_ref_handler; - - zend_opcode_handlers[ZEND_ECHO] = zend_echo_handler; - zend_opcode_handlers[ZEND_PRINT] = zend_print_handler; - - zend_opcode_handlers[ZEND_JMP] = zend_jmp_handler; - zend_opcode_handlers[ZEND_JMPZ] = zend_jmpz_handler; - zend_opcode_handlers[ZEND_JMPNZ] = zend_jmpnz_handler; - zend_opcode_handlers[ZEND_JMPZNZ] = zend_jmpznz_handler; - zend_opcode_handlers[ZEND_JMPZ_EX] = zend_jmpz_ex_handler; - zend_opcode_handlers[ZEND_JMPNZ_EX] = zend_jmpnz_ex_handler; - zend_opcode_handlers[ZEND_CASE] = zend_case_handler; - zend_opcode_handlers[ZEND_SWITCH_FREE] = zend_switch_free_handler; - zend_opcode_handlers[ZEND_BRK] = zend_brk_handler; - zend_opcode_handlers[ZEND_CONT] = zend_cont_handler; - zend_opcode_handlers[ZEND_BOOL] = zend_bool_handler; - - zend_opcode_handlers[ZEND_INIT_STRING] = zend_init_string_handler; - zend_opcode_handlers[ZEND_ADD_CHAR] = zend_add_char_handler; - zend_opcode_handlers[ZEND_ADD_STRING] = zend_add_string_handler; - zend_opcode_handlers[ZEND_ADD_VAR] = zend_add_var_handler; - - zend_opcode_handlers[ZEND_BEGIN_SILENCE] = zend_begin_silence_handler; - zend_opcode_handlers[ZEND_END_SILENCE] = zend_end_silence_handler; - - zend_opcode_handlers[ZEND_INIT_FCALL_BY_NAME] = zend_init_fcall_by_name_handler; - zend_opcode_handlers[ZEND_DO_FCALL] = zend_do_fcall_handler; - zend_opcode_handlers[ZEND_DO_FCALL_BY_NAME] = zend_do_fcall_by_name_handler; - zend_opcode_handlers[ZEND_RETURN] = zend_return_handler; - - zend_opcode_handlers[ZEND_RECV] = zend_recv_handler; - zend_opcode_handlers[ZEND_RECV_INIT] = zend_recv_init_handler; - - zend_opcode_handlers[ZEND_SEND_VAL] = zend_send_val_handler; - zend_opcode_handlers[ZEND_SEND_VAR] = zend_send_var_handler; - zend_opcode_handlers[ZEND_SEND_REF] = zend_send_ref_handler; - - zend_opcode_handlers[ZEND_NEW] = zend_new_handler; - zend_opcode_handlers[ZEND_JMP_NO_CTOR] = zend_jmp_no_ctor_handler; - zend_opcode_handlers[ZEND_FREE] = zend_free_handler; - - zend_opcode_handlers[ZEND_INIT_ARRAY] = zend_init_array_handler; - zend_opcode_handlers[ZEND_ADD_ARRAY_ELEMENT] = zend_add_array_element_handler; - - zend_opcode_handlers[ZEND_INCLUDE_OR_EVAL] = zend_include_or_eval_handler; - - zend_opcode_handlers[ZEND_UNSET_VAR] = zend_unset_var_handler; - zend_opcode_handlers[ZEND_UNSET_DIM_OBJ] = zend_unset_dim_obj_handler; - - zend_opcode_handlers[ZEND_FE_RESET] = zend_fe_reset_handler; - zend_opcode_handlers[ZEND_FE_FETCH] = zend_fe_fetch_handler; - - zend_opcode_handlers[ZEND_EXIT] = zend_exit_handler; - - zend_opcode_handlers[ZEND_FETCH_R] = zend_fetch_r_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_R] = zend_fetch_dim_r_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_R] = zend_fetch_obj_r_handler; - zend_opcode_handlers[ZEND_FETCH_W] = zend_fetch_w_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_W] = zend_fetch_dim_w_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_W] = zend_fetch_obj_w_handler; - zend_opcode_handlers[ZEND_FETCH_RW] = zend_fetch_rw_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_RW] = zend_fetch_dim_rw_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_RW] = zend_fetch_obj_rw_handler; - zend_opcode_handlers[ZEND_FETCH_IS] = zend_fetch_is_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_IS] = zend_fetch_dim_is_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_IS] = zend_fetch_obj_is_handler; - zend_opcode_handlers[ZEND_FETCH_FUNC_ARG] = zend_fetch_func_arg_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_FUNC_ARG] = zend_fetch_dim_func_arg_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_FUNC_ARG] = zend_fetch_obj_func_arg_handler; - zend_opcode_handlers[ZEND_FETCH_UNSET] = zend_fetch_unset_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_UNSET] = zend_fetch_dim_unset_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_UNSET] = zend_fetch_obj_unset_handler; - - zend_opcode_handlers[ZEND_FETCH_DIM_TMP_VAR] = zend_fetch_dim_tmp_var_handler; - zend_opcode_handlers[ZEND_FETCH_CONSTANT] = zend_fetch_constant_handler; - - zend_opcode_handlers[ZEND_EXT_STMT] = zend_ext_stmt_handler; - zend_opcode_handlers[ZEND_EXT_FCALL_BEGIN] = zend_ext_fcall_begin_handler; - zend_opcode_handlers[ZEND_EXT_FCALL_END] = zend_ext_fcall_end_handler; - zend_opcode_handlers[ZEND_EXT_NOP] = zend_ext_nop_handler; - - zend_opcode_handlers[ZEND_TICKS] = zend_ticks_handler; - - zend_opcode_handlers[ZEND_SEND_VAR_NO_REF] = zend_send_var_no_ref_handler; - - zend_opcode_handlers[ZEND_CATCH] = zend_catch_handler; - zend_opcode_handlers[ZEND_THROW] = zend_throw_handler; - - zend_opcode_handlers[ZEND_FETCH_CLASS] = zend_fetch_class_handler; - - zend_opcode_handlers[ZEND_CLONE] = zend_clone_handler; - - zend_opcode_handlers[ZEND_INIT_CTOR_CALL] = zend_init_ctor_call_handler; - zend_opcode_handlers[ZEND_INIT_METHOD_CALL] = zend_init_method_call_handler; - zend_opcode_handlers[ZEND_INIT_STATIC_METHOD_CALL] = zend_init_static_method_call_handler; - - zend_opcode_handlers[ZEND_ISSET_ISEMPTY_VAR] = zend_isset_isempty_var_handler; - zend_opcode_handlers[ZEND_ISSET_ISEMPTY_DIM_OBJ] = zend_isset_isempty_dim_obj_handler; - zend_opcode_handlers[ZEND_ISSET_ISEMPTY_PROP_OBJ] = zend_isset_isempty_prop_obj_handler; - - zend_opcode_handlers[ZEND_PRE_INC_OBJ] = zend_pre_inc_obj_handler; - zend_opcode_handlers[ZEND_PRE_DEC_OBJ] = zend_pre_dec_obj_handler; - zend_opcode_handlers[ZEND_POST_INC_OBJ] = zend_post_inc_obj_handler; - zend_opcode_handlers[ZEND_POST_DEC_OBJ] = zend_post_dec_obj_handler; - - zend_opcode_handlers[ZEND_ASSIGN_OBJ] = zend_assign_obj_handler; - zend_opcode_handlers[ZEND_OP_DATA] = NULL; - - zend_opcode_handlers[ZEND_INSTANCEOF] = zend_instanceof_handler; - - zend_opcode_handlers[ZEND_DECLARE_CLASS] = zend_declare_class_handler; - zend_opcode_handlers[ZEND_DECLARE_INHERITED_CLASS] = zend_declare_inherited_class_handler; - zend_opcode_handlers[ZEND_DECLARE_FUNCTION] = zend_declare_function_handler; - - zend_opcode_handlers[ZEND_RAISE_ABSTRACT_ERROR] = zend_raise_abstract_error_handler; - - zend_opcode_handlers[ZEND_ADD_INTERFACE] = zend_add_interface_handler; - zend_opcode_handlers[ZEND_VERIFY_ABSTRACT_CLASS] = zend_verify_abstract_class_handler; - - zend_opcode_handlers[ZEND_ASSIGN_DIM] = zend_assign_dim_handler; - - zend_opcode_handlers[ZEND_HANDLE_EXCEPTION] = zend_handle_exception_handler; +#if ZEND_VM_KIND == ZEND_VM_KIND_GOTO + TSRMLS_FETCH(); + zend_execute(NULL TSRMLS_CC); +#else + static const opcode_handler_t labels[] = {ZEND_VM_LABELS}; + zend_opcode_handlers = (opcode_handler_t*)labels; +#endif } /* http://cvs.php.net/diff.php/ZendEngine2/zend_execute.h?r1=1.73&r2=1.74&ty=u Index: ZendEngine2/zend_execute.h diff -u ZendEngine2/zend_execute.h:1.73 ZendEngine2/zend_execute.h:1.74 --- ZendEngine2/zend_execute.h:1.73 Sun Jul 25 03:14:25 2004 +++ ZendEngine2/zend_execute.h Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.h,v 1.73 2004/07/25 07:14:25 helly Exp $ */ +/* $Id: zend_execute.h,v 1.74 2004/09/08 22:14:12 andi Exp $ */ #ifndef ZEND_EXECUTE_H #define ZEND_EXECUTE_H @@ -166,8 +166,6 @@ #define zendi_zval_dtor(p) zval_dtor(&(p)) #define active_opline (*EG(opline_ptr)) - -void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC); /* The following tries to resolve the classname of a zval of type object. * Since it is slow it should be only used in error messages. http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.293&r2=1.294&ty=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.293 ZendEngine2/zend_execute_API.c:1.294 --- ZendEngine2/zend_execute_API.c:1.293 Mon Aug 23 16:57:40 2004 +++ ZendEngine2/zend_execute_API.c Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.293 2004/08/23 20:57:40 helly Exp $ */ +/* $Id: zend_execute_API.c,v 1.294 2004/09/08 22:14:12 andi Exp $ */ #include <stdio.h> #include <signal.h> @@ -30,6 +30,7 @@ #include "zend_constants.h" #include "zend_extensions.h" #include "zend_exceptions.h" +#include "zend_vm.h" #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -1073,7 +1074,7 @@ opline->op2.u.constant.is_ref = 1; opline->op2.u.constant.refcount = 2; } - opline->handler = zend_opcode_handlers[opline->opcode]; + ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; } http://cvs.php.net/diff.php/ZendEngine2/zend_opcode.c?r1=1.105&r2=1.106&ty=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.105 ZendEngine2/zend_opcode.c:1.106 --- ZendEngine2/zend_opcode.c:1.105 Thu Jul 29 13:45:31 2004 +++ ZendEngine2/zend_opcode.c Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.105 2004/07/29 17:45:31 pollita Exp $ */ +/* $Id: zend_opcode.c,v 1.106 2004/09/08 22:14:12 andi Exp $ */ #include <stdio.h> @@ -27,6 +27,8 @@ #include "zend_extensions.h" #include "zend_API.h" +#include "zend_vm.h" + static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) { if (extension->op_array_ctor) { @@ -361,7 +363,7 @@ opline->op2.u.jmp_addr = &op_array->opcodes[opline->op2.u.opline_num]; break; } - opline->handler = zend_opcode_handlers[opline->opcode]; + ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; } http://cvs.php.net/co.php/ZendEngine2/zend_vm.h?r=1.1&p=1 Index: ZendEngine2/zend_vm.h +++ ZendEngine2/zend_vm.h /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ | Copyright (c) 1998-2004 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 | | 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 | | obtain it through the world-wide-web, please send a note to | | license@zend.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ /* $Id: zend_vm.h,v 1.1 2004/09/08 22:14:12 andi Exp $ */ #ifndef ZEND_VM_H #define ZEND_VM_H #define ZEND_VM_KIND_CALL 1 #define ZEND_VM_KIND_SWITCH 2 #define ZEND_VM_KIND_GOTO 3 /* #define ZEND_VM_KIND ZEND_VM_KIND_CALL */ #define ZEND_VM_SPEC /* don't edit the rest of the file */ #define _CONST_CODE 0 #define _TMP_CODE 1 #define _VAR_CODE 2 #define _UNUSED_CODE 3 #ifndef ZEND_VM_KIND # ifdef __GNUC__ # define ZEND_VM_KIND ZEND_VM_KIND_GOTO # else # define ZEND_VM_KIND ZEND_VM_KIND_SWITCH # endif #endif #if defined(__GNUC__) && !defined(__INTEL_COMPILER) # define ZEND_VM_ALWAYS_INLINE __attribute__ ((always_inline)) void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn)); /*extern void zend_error_noreturn(int type, const char *format, ...) __asm__("zend_error") __attribute__ ((noreturn));*/ #else # define ZEND_VM_ALWAYS_INLINE # define zend_error_noreturn zend_error #endif #ifndef ZEND_VM_SPEC # define ZEND_VM_CODE(opcode, op1, op2) opcode # define ZEND_VM_SPEC_OPCODE(opcode, op1, op2) opcode # define ZEND_VM_SET_OPCODE_HANDLER(opline) \ opline->handler = zend_opcode_handlers[opline->opcode]; #else static const int zend_vm_decode[] = { _UNUSED_CODE, /* 0 */ _CONST_CODE, /* 1 = IS_CONST */ _TMP_CODE, /* 2 = IS_TMP_VAR */ _UNUSED_CODE, /* 3 */ _VAR_CODE, /* 4 = IS_VAR */ _UNUSED_CODE, /* 5 */ _UNUSED_CODE, /* 6 */ _UNUSED_CODE, /* 7 */ _UNUSED_CODE /* 8 = IS_UNUSED */ }; # define ZEND_VM_CODE(opcode, op1, op2) \ opcode * 16 + op1 * 4 + op2 # define ZEND_VM_SPEC_OPCODE(opcode, op1, op2) \ ZEND_VM_CODE(opcode, zend_vm_decode[op1], zend_vm_decode[op2]) # define ZEND_VM_SET_OPCODE_HANDLER(opline) \ opline->handler = zend_opcode_handlers[ZEND_VM_SPEC_OPCODE(opline->opcode, opline->op1.op_type, opline->op2.op_type)] #endif #if ZEND_VM_KIND == ZEND_VM_KIND_CALL # define EXECUTE_DATA execute_data # define ZEND_VM_HELPER_VAR(X) # define ZEND_VM_DISPATCH() \ if (EX(opline)->handler(&execute_data TSRMLS_CC) > 0) # define ZEND_VM_CONTINUE_LABEL # define ZEND_VM_HANDLER(OP) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_HANDLER_EX(OP) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_HELPER(NAME) \ static int NAME(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_HELPER_EX(NAME,PARAM) \ static int NAME(PARAM, ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HANDLER(OP, CODE) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HELPER(NAME) \ static int NAME(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \ static int NAME(PARAM, ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_NULL_HANDLER() \ int ZEND_VM_NULL(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ return OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_DISPATCH_TO_HELPER(NAME) \ return NAME(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ return NAME(VAL, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \ return OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \ return NAME(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ return NAME(VAL, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_CONTINUE() \ return 0 # define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ return 0 # define ZEND_VM_SET_OPCODE(new_op) \ CHECK_SYMBOL_TABLES() \ EX(opline) = new_op # define ZEND_VM_INC_OPCODE() \ if (!EG(exception)) { \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ } # define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ free_alloca(EX(Ts)); \ } else { \ efree(EX(Ts)); \ } \ EG(in_execution) = EX(original_in_execution); \ EG(current_execute_data) = EX(prev_execute_data); \ return 1; # define ZEND_VM_LABEL(OP) OP##_HANDLER # define ZEND_VM_NULL_LABEL ZEND_VM_NULL # define ZEND_VM_SPEC_LABEL(OP,CODE) OP##_HANDLER # define ZEND_VM_SPEC_NULL_LABEL ZEND_VM_NULL #elif ZEND_VM_KIND == ZEND_VM_KIND_SWITCH # define EXECUTE_DATA &execute_data # define ZEND_VM_HELPER_VAR(X) X; # define ZEND_VM_DISPATCH() \ switch ((int)EX(opline)->handler) # define ZEND_VM_CONTINUE_LABEL \ zend_vm_continue: # define ZEND_VM_HANDLER(OP) \ case OP: # define ZEND_VM_HANDLER_EX(OP) \ case OP: \ OP##_LABEL: # define ZEND_VM_HELPER(NAME) \ NAME: # define ZEND_VM_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_SPEC_HANDLER(OP, CODE) \ case CODE: # define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \ case CODE: \ OP##_LABEL: # define ZEND_VM_SPEC_HELPER(NAME) \ NAME: # define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_NULL_HANDLER() \ default: # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ goto OP##_LABEL # define ZEND_VM_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \ goto OP##_LABEL # define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_CONTINUE() \ goto zend_vm_continue # define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ ZEND_VM_CONTINUE() # define ZEND_VM_SET_OPCODE(new_op) \ CHECK_SYMBOL_TABLES() \ EX(opline) = new_op # define ZEND_VM_INC_OPCODE() \ if (!EG(exception)) { \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ } # define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ free_alloca(EX(Ts)); \ } else { \ efree(EX(Ts)); \ } \ EG(in_execution) = EX(original_in_execution); \ EG(current_execute_data) = EX(prev_execute_data); \ return; # define ZEND_VM_LABEL(OP) (opcode_handler_t)OP # define ZEND_VM_NULL_LABEL (opcode_handler_t)-1 # define ZEND_VM_SPEC_LABEL(OP,CODE) (opcode_handler_t)(CODE) # define ZEND_VM_SPEC_NULL_LABEL (opcode_handler_t)-1 #elif ZEND_VM_KIND == ZEND_VM_KIND_GOTO # define EXECUTE_DATA &execute_data # define ZEND_VM_HELPER_VAR(X) X; # define ZEND_VM_DISPATCH() \ goto *(void**)(EX(opline)->handler); # define ZEND_VM_CONTINUE_LABEL # define ZEND_VM_HANDLER(OP) \ OP##_HANDLER: # define ZEND_VM_HANDLER_EX(OP) \ OP##_HANDLER: # define ZEND_VM_HELPER(NAME) \ NAME: # define ZEND_VM_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_SPEC_HANDLER(OP, CODE) \ OP##_HANDLER: # define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \ OP##_HANDLER: # define ZEND_VM_SPEC_HELPER(NAME) \ NAME: # define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_NULL_HANDLER() \ ZEND_VM_NULL: # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ goto OP##_HANDLER # define ZEND_VM_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \ goto OP##_HANDLER # define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_CONTINUE() \ goto *(void**)(EX(opline)->handler) # define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ ZEND_VM_CONTINUE() # define ZEND_VM_SET_OPCODE(new_op) \ CHECK_SYMBOL_TABLES() \ EX(opline) = new_op # define ZEND_VM_INC_OPCODE() \ if (!EG(exception)) { \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ } # define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ free_alloca(EX(Ts)); \ } else { \ efree(EX(Ts)); \ } \ EG(in_execution) = EX(original_in_execution); \ EG(current_execute_data) = EX(prev_execute_data); \ return; # define ZEND_VM_LABEL(OP) (opcode_handler_t)&&OP##_HANDLER # define ZEND_VM_NULL_LABEL &&ZEND_VM_NULL # define ZEND_VM_SPEC_LABEL(OP,CODE) (opcode_handler_t)&&OP##_HANDLER # define ZEND_VM_SPEC_NULL_LABEL &&ZEND_VM_NULL #else # error "Unknown ZEND_VM_KIND" #endif #define ZEND_VM_CONTINUE_JMP() ZEND_VM_CONTINUE() #endif http://cvs.php.net/co.php/ZendEngine2/zend_vm_handlers.h?r=1.1&p=1 Index: ZendEngine2/zend_vm_handlers.h +++ ZendEngine2/zend_vm_handlers.h /* Don't edit the following defines. They are the part of opcode specializer */ #undef OP1_TYPE_PREFIX #if OP1 == IS_CONST # define OP1_TYPE_PREFIX _CONST #elif OP1 == IS_TMP_VAR # define OP1_TYPE_PREFIX _TMP #elif OP1 == IS_VAR # define OP1_TYPE_PREFIX _VAR #elif OP1 == IS_UNUSED # define OP1_TYPE_PREFIX _UNUSED #elif OP1 == IS_ANY # define OP1_TYPE_PREFIX _ANY #else # error "Wrong OP1_TYPE!" #endif #undef OP2_TYPE_PREFIX #if OP2 == IS_CONST # define OP2_TYPE_PREFIX _CONST #elif OP2 == IS_TMP_VAR # define OP2_TYPE_PREFIX _TMP #elif OP2 == IS_VAR # define OP2_TYPE_PREFIX _VAR #elif OP2 == IS_UNUSED # define OP2_TYPE_PREFIX _UNUSED #elif OP2 == IS_ANY # define OP2_TYPE_PREFIX _ANY #else # error "Wrong OP2_TYPE!" #endif /* ordered list of opcode handlers */ #define ZEND_VM_LABELS \ ZEND_VM_LABEL(ZEND_NOP), /* 0 */ \ ZEND_VM_LABEL(ZEND_ADD), /* 1 */ \ ZEND_VM_LABEL(ZEND_SUB), /* 2 */ \ ZEND_VM_LABEL(ZEND_MUL), /* 3 */ \ ZEND_VM_LABEL(ZEND_DIV), /* 4 */ \ ZEND_VM_LABEL(ZEND_MOD), /* 5 */ \ ZEND_VM_LABEL(ZEND_SL), /* 6 */ \ ZEND_VM_LABEL(ZEND_SR), /* 7 */ \ ZEND_VM_LABEL(ZEND_CONCAT), /* 8 */ \ ZEND_VM_LABEL(ZEND_BW_OR), /* 9 */ \ ZEND_VM_LABEL(ZEND_BW_AND), /* 10 */ \ ZEND_VM_LABEL(ZEND_BW_XOR), /* 11 */ \ ZEND_VM_LABEL(ZEND_BW_NOT), /* 12 */ \ ZEND_VM_LABEL(ZEND_BOOL_NOT), /* 13 */ \ ZEND_VM_LABEL(ZEND_BOOL_XOR), /* 14 */ \ ZEND_VM_LABEL(ZEND_IS_IDENTICAL), /* 15 */ \ ZEND_VM_LABEL(ZEND_IS_NOT_IDENTICAL), /* 16 */ \ ZEND_VM_LABEL(ZEND_IS_EQUAL), /* 17 */ \ ZEND_VM_LABEL(ZEND_IS_NOT_EQUAL), /* 18 */ \ ZEND_VM_LABEL(ZEND_IS_SMALLER), /* 19 */ \ ZEND_VM_LABEL(ZEND_IS_SMALLER_OR_EQUAL), /* 20 */ \ ZEND_VM_LABEL(ZEND_CAST), /* 21 */ \ ZEND_VM_LABEL(ZEND_QM_ASSIGN), /* 22 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_ADD), /* 23 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_SUB), /* 24 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_MUL), /* 25 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_DIV), /* 26 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_MOD), /* 27 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_SL), /* 28 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_SR), /* 29 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_CONCAT), /* 30 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_BW_OR), /* 31 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_BW_AND), /* 32 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_BW_XOR), /* 33 */ \ ZEND_VM_LABEL(ZEND_PRE_INC), /* 34 */ \ ZEND_VM_LABEL(ZEND_PRE_DEC), /* 35 */ \ ZEND_VM_LABEL(ZEND_POST_INC), /* 36 */ \ ZEND_VM_LABEL(ZEND_POST_DEC), /* 37 */ \ ZEND_VM_LABEL(ZEND_ASSIGN), /* 38 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_REF), /* 39 */ \ ZEND_VM_LABEL(ZEND_ECHO), /* 40 */ \ ZEND_VM_LABEL(ZEND_PRINT), /* 41 */ \ ZEND_VM_LABEL(ZEND_JMP), /* 42 */ \ ZEND_VM_LABEL(ZEND_JMPZ), /* 43 */ \ ZEND_VM_LABEL(ZEND_JMPNZ), /* 44 */ \ ZEND_VM_LABEL(ZEND_JMPZNZ), /* 45 */ \ ZEND_VM_LABEL(ZEND_JMPZ_EX), /* 46 */ \ ZEND_VM_LABEL(ZEND_JMPNZ_EX), /* 47 */ \ ZEND_VM_LABEL(ZEND_CASE), /* 48 */ \ ZEND_VM_LABEL(ZEND_SWITCH_FREE), /* 49 */ \ ZEND_VM_LABEL(ZEND_BRK), /* 50 */ \ ZEND_VM_LABEL(ZEND_CONT), /* 51 */ \ ZEND_VM_LABEL(ZEND_BOOL), /* 52 */ \ ZEND_VM_LABEL(ZEND_INIT_STRING), /* 53 */ \ ZEND_VM_LABEL(ZEND_ADD_CHAR), /* 54 */ \ ZEND_VM_LABEL(ZEND_ADD_STRING), /* 55 */ \ ZEND_VM_LABEL(ZEND_ADD_VAR), /* 56 */ \ ZEND_VM_LABEL(ZEND_BEGIN_SILENCE), /* 57 */ \ ZEND_VM_LABEL(ZEND_END_SILENCE), /* 58 */ \ ZEND_VM_LABEL(ZEND_INIT_FCALL_BY_NAME), /* 59 */ \ ZEND_VM_LABEL(ZEND_DO_FCALL), /* 60 */ \ ZEND_VM_LABEL(ZEND_DO_FCALL_BY_NAME), /* 61 */ \ ZEND_VM_LABEL(ZEND_RETURN), /* 62 */ \ ZEND_VM_LABEL(ZEND_RECV), /* 63 */ \ ZEND_VM_LABEL(ZEND_RECV_INIT), /* 64 */ \ ZEND_VM_LABEL(ZEND_SEND_VAL), /* 65 */ \ ZEND_VM_LABEL(ZEND_SEND_VAR), /* 66 */ \ ZEND_VM_LABEL(ZEND_SEND_REF), /* 67 */ \ ZEND_VM_LABEL(ZEND_NEW), /* 68 */ \ ZEND_VM_LABEL(ZEND_JMP_NO_CTOR), /* 69 */ \ ZEND_VM_LABEL(ZEND_FREE), /* 70 */ \ ZEND_VM_LABEL(ZEND_INIT_ARRAY), /* 71 */ \ ZEND_VM_LABEL(ZEND_ADD_ARRAY_ELEMENT), /* 72 */ \ ZEND_VM_LABEL(ZEND_INCLUDE_OR_EVAL), /* 73 */ \ ZEND_VM_LABEL(ZEND_UNSET_VAR), /* 74 */ \ ZEND_VM_LABEL(ZEND_UNSET_DIM_OBJ), /* 75 */ \ ZEND_VM_NULL_LABEL, /* 76 */ \ ZEND_VM_LABEL(ZEND_FE_RESET), /* 77 */ \ ZEND_VM_LABEL(ZEND_FE_FETCH), /* 78 */ \ ZEND_VM_LABEL(ZEND_EXIT), /* 79 */ \ ZEND_VM_LABEL(ZEND_FETCH_R), /* 80 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_R), /* 81 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_R), /* 82 */ \ ZEND_VM_LABEL(ZEND_FETCH_W), /* 83 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_W), /* 84 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_W), /* 85 */ \ ZEND_VM_LABEL(ZEND_FETCH_RW), /* 86 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_RW), /* 87 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_RW), /* 88 */ \ ZEND_VM_LABEL(ZEND_FETCH_IS), /* 89 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_IS), /* 90 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_IS), /* 91 */ \ ZEND_VM_LABEL(ZEND_FETCH_FUNC_ARG), /* 92 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_FUNC_ARG), /* 93 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_FUNC_ARG), /* 94 */ \ ZEND_VM_LABEL(ZEND_FETCH_UNSET), /* 95 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_UNSET), /* 96 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_UNSET), /* 97 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_TMP_VAR), /* 98 */ \ ZEND_VM_LABEL(ZEND_FETCH_CONSTANT), /* 99 */ \ ZEND_VM_NULL_LABEL, /* 100 */ \ ZEND_VM_LABEL(ZEND_EXT_STMT), /* 101 */ \ ZEND_VM_LABEL(ZEND_EXT_FCALL_BEGIN), /* 102 */ \ ZEND_VM_LABEL(ZEND_EXT_FCALL_END), /* 103 */ \ ZEND_VM_LABEL(ZEND_EXT_NOP), /* 104 */ \ ZEND_VM_LABEL(ZEND_TICKS), /* 105 */ \ ZEND_VM_LABEL(ZEND_SEND_VAR_NO_REF), /* 106 */ \ ZEND_VM_LABEL(ZEND_CATCH), /* 107 */ \ ZEND_VM_LABEL(ZEND_THROW), /* 108 */ \ ZEND_VM_LABEL(ZEND_FETCH_CLASS), /* 109 */ \ ZEND_VM_LABEL(ZEND_CLONE), /* 110 */ \ ZEND_VM_LABEL(ZEND_INIT_CTOR_CALL), /* 111 */ \ ZEND_VM_LABEL(ZEND_INIT_METHOD_CALL), /* 112 */ \ ZEND_VM_LABEL(ZEND_INIT_STATIC_METHOD_CALL), /* 113 */ \ ZEND_VM_LABEL(ZEND_ISSET_ISEMPTY_VAR), /* 114 */ \ ZEND_VM_LABEL(ZEND_ISSET_ISEMPTY_DIM_OBJ), /* 115 */ \ ZEND_VM_NULL_LABEL, /* 116 */ \ ZEND_VM_NULL_LABEL, /* 117 */ \ ZEND_VM_NULL_LABEL, /* 118 */ \ ZEND_VM_NULL_LABEL, /* 119 */ \ ZEND_VM_NULL_LABEL, /* 120 */ \ ZEND_VM_NULL_LABEL, /* 121 */ \ ZEND_VM_NULL_LABEL, /* 122 */ \ ZEND_VM_NULL_LABEL, /* 123 */ \ ZEND_VM_NULL_LABEL, /* 124 */ \ ZEND_VM_NULL_LABEL, /* 125 */ \ ZEND_VM_NULL_LABEL, /* 126 */ \ ZEND_VM_NULL_LABEL, /* 127 */ \ ZEND_VM_NULL_LABEL, /* 128 */ \ ZEND_VM_NULL_LABEL, /* 129 */ \ ZEND_VM_NULL_LABEL, /* 130 */ \ ZEND_VM_NULL_LABEL, /* 131 */ \ ZEND_VM_LABEL(ZEND_PRE_INC_OBJ), /* 132 */ \ ZEND_VM_LABEL(ZEND_PRE_DEC_OBJ), /* 133 */ \ ZEND_VM_LABEL(ZEND_POST_INC_OBJ), /* 134 */ \ ZEND_VM_LABEL(ZEND_POST_DEC_OBJ), /* 135 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_OBJ), /* 136 */ \ ZEND_VM_NULL_LABEL, /* 137 */ \ ZEND_VM_LABEL(ZEND_INSTANCEOF), /* 138 */ \ ZEND_VM_LABEL(ZEND_DECLARE_CLASS), /* 139 */ \ ZEND_VM_LABEL(ZEND_DECLARE_INHERITED_CLASS), /* 140 */ \ ZEND_VM_LABEL(ZEND_DECLARE_FUNCTION), /* 141 */ \ ZEND_VM_LABEL(ZEND_RAISE_ABSTRACT_ERROR), /* 142 */ \ ZEND_VM_NULL_LABEL, /* 143 */ \ ZEND_VM_LABEL(ZEND_ADD_INTERFACE), /* 144 */ \ ZEND_VM_NULL_LABEL, /* 145 */ \ ZEND_VM_LABEL(ZEND_VERIFY_ABSTRACT_CLASS), /* 146 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_DIM), /* 147 */ \ ZEND_VM_LABEL(ZEND_ISSET_ISEMPTY_PROP_OBJ), /* 148 */ \ ZEND_VM_LABEL(ZEND_HANDLE_EXCEPTION), /* 149 */ \ ZEND_VM_NULL_LABEL /* opcode handlers and helpers */ #define ZEND_ADD_SPEC() OPDEF(ZEND_ADD, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ADD) ZEND_VM_HANDLER(ZEND_ADD) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; add_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SUB_SPEC() OPDEF(ZEND_SUB, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_SUB) ZEND_VM_HANDLER(ZEND_SUB) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; sub_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_MUL_SPEC() OPDEF(ZEND_MUL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_MUL) ZEND_VM_HANDLER(ZEND_MUL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; mul_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DIV_SPEC() OPDEF(ZEND_DIV, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_DIV) ZEND_VM_HANDLER(ZEND_DIV) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; div_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_MOD_SPEC() OPDEF(ZEND_MOD, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_MOD) ZEND_VM_HANDLER(ZEND_MOD) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; mod_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SL_SPEC() OPDEF(ZEND_SL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_SL) ZEND_VM_HANDLER(ZEND_SL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; shift_left_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SR_SPEC() OPDEF(ZEND_SR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_SR) ZEND_VM_HANDLER(ZEND_SR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; shift_right_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_CONCAT_SPEC() OPDEF(ZEND_CONCAT, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_CONCAT) ZEND_VM_HANDLER(ZEND_CONCAT) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; concat_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_IDENTICAL_SPEC() OPDEF(ZEND_IS_IDENTICAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_IDENTICAL) ZEND_VM_HANDLER(ZEND_IS_IDENTICAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_identical_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_NOT_IDENTICAL_SPEC() OPDEF(ZEND_IS_NOT_IDENTICAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_NOT_IDENTICAL) ZEND_VM_HANDLER(ZEND_IS_NOT_IDENTICAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_not_identical_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_EQUAL_SPEC() OPDEF(ZEND_IS_EQUAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_EQUAL) ZEND_VM_HANDLER(ZEND_IS_EQUAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_NOT_EQUAL_SPEC() OPDEF(ZEND_IS_NOT_EQUAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_NOT_EQUAL) ZEND_VM_HANDLER(ZEND_IS_NOT_EQUAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_not_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_SMALLER_SPEC() OPDEF(ZEND_IS_SMALLER, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_SMALLER) ZEND_VM_HANDLER(ZEND_IS_SMALLER) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_smaller_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_SMALLER_OR_EQUAL_SPEC() OPDEF(ZEND_IS_SMALLER_OR_EQUAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_SMALLER_OR_EQUAL) ZEND_VM_HANDLER(ZEND_IS_SMALLER_OR_EQUAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_smaller_or_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_OR_SPEC() OPDEF(ZEND_BW_OR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BW_OR) ZEND_VM_HANDLER(ZEND_BW_OR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; bitwise_or_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_AND_SPEC() OPDEF(ZEND_BW_AND, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BW_AND) ZEND_VM_HANDLER(ZEND_BW_AND) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; bitwise_and_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_XOR_SPEC() OPDEF(ZEND_BW_XOR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BW_XOR) ZEND_VM_HANDLER(ZEND_BW_XOR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; bitwise_xor_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BOOL_XOR_SPEC() OPDEF(ZEND_BOOL_XOR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BOOL_XOR) ZEND_VM_HANDLER(ZEND_BOOL_XOR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; boolean_xor_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_NOT_SPEC() OPDEF(ZEND_BW_NOT, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_BW_NOT) ZEND_VM_HANDLER(ZEND_BW_NOT) { zend_op *opline = EX(opline); zend_free_op free_op1; bitwise_not_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BOOL_NOT_SPEC() OPDEF(ZEND_BOOL_NOT, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_BOOL_NOT) ZEND_VM_HANDLER(ZEND_BOOL_NOT) { zend_op *opline = EX(opline); zend_free_op free_op1; boolean_not_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC)) { zend_op *opline = EX(opline); zend_op *op_data = opline+1; zend_free_op free_op1, free_op2, free_op_data1; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); zval *value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); zval tmp; znode *result = &opline->result; zval **retval = &EX_T(result->u.var).var.ptr; int have_get_ptr = 0; EX_T(result->u.var).var.ptr_ptr = NULL; make_real_object(object_ptr TSRMLS_CC); object = *object_ptr; if (object->type != IS_OBJECT) { zend_error(E_WARNING, "Attempt to assign property of non-object"); FREE_OP2(); FREE_OP(free_op_data1); if (!RETURN_VALUE_UNUSED(result)) { *retval = EG(uninitialized_zval_ptr); PZVAL_LOCK(*retval); } } else { /* here we are sure we are dealing with an object */ switch (OP2_TYPE) { case IS_CONST: /* already a constant string */ break; case IS_VAR: tmp = *property; zval_copy_ctor(&tmp); convert_to_string(&tmp); property = &tmp; break; case IS_TMP_VAR: convert_to_string(property); break; } /* here property is a string */ if (opline->extended_value == ZEND_ASSIGN_OBJ && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ SEPARATE_ZVAL_IF_NOT_REF(zptr); have_get_ptr = 1; binary_op(*zptr, *zptr, value TSRMLS_CC); if (!RETURN_VALUE_UNUSED(result)) { *retval = *zptr; PZVAL_LOCK(*retval); } } } if (!have_get_ptr) { zval *z; switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); break; case ZEND_ASSIGN_DIM: z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_RW TSRMLS_CC); break; } if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); if (z->refcount == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } z->refcount++; SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); break; case ZEND_ASSIGN_DIM: Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); break; } if (!RETURN_VALUE_UNUSED(result)) { *retval = z; PZVAL_LOCK(*retval); } zval_ptr_dtor(&z); } if (property == &tmp) { zval_dtor(property); } FREE_OP2(); FREE_OP(free_op_data1); } FREE_OP1_VAR_PTR(); /* assign_obj has two opcodes! */ ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC)) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2, free_op_data2, free_op_data1; zval **var_ptr; zval *value; zend_bool increment_opline = 0; switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_obj_helper, binary_op, binary_op); break; case ZEND_ASSIGN_DIM: { zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ if ((*object_ptr)->type == IS_OBJECT) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_obj_helper, binary_op, binary_op); } else { zend_op *op_data = opline+1; zend_fetch_dimension_address(&EX_T(op_data->op2.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_RW TSRMLS_CC); value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); var_ptr = get_zval_ptr_ptr(&op_data->op2, EX(Ts), &free_op_data2, BP_VAR_RW); increment_opline = 1; } } break; default: value = GET_OP2_ZVAL_PTR(BP_VAR_R); var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); /* do nothing */ break; } if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP2(); FREE_OP1_VAR_PTR(); if (increment_opline) { ZEND_VM_INC_OPCODE(); } ZEND_VM_NEXT_OPCODE(); } SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); objval->refcount++; binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); } else { binary_op(*var_ptr, *var_ptr, value TSRMLS_CC); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; PZVAL_LOCK(*var_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP2(); if (increment_opline) { ZEND_VM_INC_OPCODE(); FREE_OP_VAR_PTR(free_op_data2); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_ADD_SPEC() OPDEF(ZEND_ASSIGN_ADD, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_ADD) ZEND_VM_HANDLER(ZEND_ASSIGN_ADD) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, add_function); } #endif #define ZEND_ASSIGN_SUB_SPEC() OPDEF(ZEND_ASSIGN_SUB, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_SUB) ZEND_VM_HANDLER(ZEND_ASSIGN_SUB) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, sub_function); } #endif #define ZEND_ASSIGN_MUL_SPEC() OPDEF(ZEND_ASSIGN_MUL, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_MUL) ZEND_VM_HANDLER(ZEND_ASSIGN_MUL) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, mul_function); } #endif #define ZEND_ASSIGN_DIV_SPEC() OPDEF(ZEND_ASSIGN_DIV, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_DIV) ZEND_VM_HANDLER(ZEND_ASSIGN_DIV) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, div_function); } #endif #define ZEND_ASSIGN_MOD_SPEC() OPDEF(ZEND_ASSIGN_MOD, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_MOD) ZEND_VM_HANDLER(ZEND_ASSIGN_MOD) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, mod_function); } #endif #define ZEND_ASSIGN_SL_SPEC() OPDEF(ZEND_ASSIGN_SL, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_SL) ZEND_VM_HANDLER(ZEND_ASSIGN_SL) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, shift_left_function); } #endif #define ZEND_ASSIGN_SR_SPEC() OPDEF(ZEND_ASSIGN_SR, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_SR) ZEND_VM_HANDLER(ZEND_ASSIGN_SR) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, shift_right_function); } #endif #define ZEND_ASSIGN_CONCAT_SPEC() OPDEF(ZEND_ASSIGN_CONCAT, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_CONCAT) ZEND_VM_HANDLER(ZEND_ASSIGN_CONCAT) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, concat_function); } #endif #define ZEND_ASSIGN_BW_OR_SPEC() OPDEF(ZEND_ASSIGN_BW_OR, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_BW_OR) ZEND_VM_HANDLER(ZEND_ASSIGN_BW_OR) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, bitwise_or_function); } #endif #define ZEND_ASSIGN_BW_AND_SPEC() OPDEF(ZEND_ASSIGN_BW_AND, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_BW_AND) ZEND_VM_HANDLER(ZEND_ASSIGN_BW_AND) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, bitwise_and_function); } #endif #define ZEND_ASSIGN_BW_XOR_SPEC() OPDEF(ZEND_ASSIGN_BW_XOR, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_BW_XOR) ZEND_VM_HANDLER(ZEND_ASSIGN_BW_XOR) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, bitwise_xor_function); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, incdec_t incdec_op) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); zval **retval = &EX_T(opline->result.u.var).var.ptr; int have_get_ptr = 0; make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ object = *object_ptr; if (object->type != IS_OBJECT) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); FREE_OP2(); if (!RETURN_VALUE_UNUSED(&opline->result)) { *retval = EG(uninitialized_zval_ptr); PZVAL_LOCK(*retval); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } /* here we are sure we are dealing with an object */ if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ SEPARATE_ZVAL_IF_NOT_REF(zptr); have_get_ptr = 1; incdec_op(*zptr); if (!RETURN_VALUE_UNUSED(&opline->result)) { *retval = *zptr; PZVAL_LOCK(*retval); } } } if (!have_get_ptr) { zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); if (z->refcount == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } z->refcount++; SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); SELECTIVE_PZVAL_LOCK(*retval, &opline->result); zval_ptr_dtor(&z); } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_PRE_INC_OBJ_SPEC() OPDEF(ZEND_PRE_INC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_PRE_INC_OBJ) ZEND_VM_HANDLER(ZEND_PRE_INC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_pre_incdec_property_helper, incdec_op, increment_function); } #endif #define ZEND_PRE_DEC_OBJ_SPEC() OPDEF(ZEND_PRE_DEC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_PRE_DEC_OBJ) ZEND_VM_HANDLER(ZEND_PRE_DEC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_pre_incdec_property_helper, incdec_op, decrement_function); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, incdec_t incdec_op) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); zval *retval = &EX_T(opline->result.u.var).tmp_var; int have_get_ptr = 0; make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ object = *object_ptr; if (object->type != IS_OBJECT) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); FREE_OP2(); *retval = *EG(uninitialized_zval_ptr); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } /* here we are sure we are dealing with an object */ if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ have_get_ptr = 1; SEPARATE_ZVAL_IF_NOT_REF(zptr); *retval = **zptr; zendi_zval_copy_ctor(*retval); incdec_op(*zptr); } } if (!have_get_ptr) { zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); if (z->refcount == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } *retval = *z; zendi_zval_copy_ctor(*retval); incdec_op(z); z->refcount++; Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); zval_ptr_dtor(&z); } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_POST_INC_OBJ_SPEC() OPDEF(ZEND_POST_INC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_POST_INC_OBJ) ZEND_VM_HANDLER(ZEND_POST_INC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_post_incdec_property_helper, incdec_op, increment_function); } #endif #define ZEND_POST_DEC_OBJ_SPEC() OPDEF(ZEND_POST_DEC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_POST_DEC_OBJ) ZEND_VM_HANDLER(ZEND_POST_DEC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_post_incdec_property_helper, incdec_op, decrement_function); } #endif #define ZEND_PRE_INC_SPEC() OPDEF(ZEND_PRE_INC, M_VAR, M_ANY) #if HAVE_OP(ZEND_PRE_INC) ZEND_VM_HANDLER(ZEND_PRE_INC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { increment_function(*var_ptr); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; PZVAL_LOCK(*var_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_PRE_DEC_SPEC() OPDEF(ZEND_PRE_DEC, M_VAR, M_ANY) #if HAVE_OP(ZEND_PRE_DEC) ZEND_VM_HANDLER(ZEND_PRE_DEC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { decrement_function(*var_ptr); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; PZVAL_LOCK(*var_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_POST_INC_SPEC() OPDEF(ZEND_POST_INC, M_VAR, M_ANY) #if HAVE_OP(ZEND_POST_INC) ZEND_VM_HANDLER(ZEND_POST_INC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } EX_T(opline->result.u.var).tmp_var = **var_ptr; zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { increment_function(*var_ptr); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_POST_DEC_SPEC() OPDEF(ZEND_POST_DEC, M_VAR, M_ANY) #if HAVE_OP(ZEND_POST_DEC) ZEND_VM_HANDLER(ZEND_POST_DEC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } EX_T(opline->result.u.var).tmp_var = **var_ptr; zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { decrement_function(*var_ptr); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ECHO_SPEC() OPDEF(ZEND_ECHO, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_ECHO) ZEND_VM_HANDLER_EX(ZEND_ECHO) { zend_op *opline = EX(opline); zend_free_op free_op1; zval z_copy; zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { zend_print_variable(&z_copy); zval_dtor(&z_copy); } else { zend_print_variable(z); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_PRINT_SPEC() OPDEF(ZEND_PRINT, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_PRINT) ZEND_VM_HANDLER(ZEND_PRINT) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).tmp_var.value.lval = 1; EX_T(opline->result.u.var).tmp_var.type = IS_LONG; ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ECHO); } #endif #if OP1_OP2_MASK(M_CONST_TMP_VAR, M_ANY) ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, int type) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *varname = GET_OP1_ZVAL_PTR(BP_VAR_R); zval **retval; zval tmp_varname; HashTable *target_symbol_table; if (varname->type != IS_STRING) { tmp_varname = *varname; zval_copy_ctor(&tmp_varname); convert_to_string(&tmp_varname); varname = &tmp_varname; } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { retval = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 0 TSRMLS_CC); } else { if (opline->op2.u.EA.type == ZEND_FETCH_GLOBAL && opline->op1.op_type == IS_VAR) { varname->refcount++; } target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), type, varname TSRMLS_CC); /* if (!target_symbol_table) { ZEND_VM_NEXT_OPCODE(); } */ if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &retval) == FAILURE) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); /* break missing intentionally */ case BP_VAR_IS: retval = &EG(uninitialized_zval_ptr); break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); /* break missing intentionally */ case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; EMPTY_SWITCH_DEFAULT_CASE() } } switch (opline->op2.u.EA.type) { case ZEND_FETCH_LOCAL: FREE_OP1(); break; case ZEND_FETCH_STATIC: zval_update_constant(retval, (void*) 1 TSRMLS_CC); break; } } if (varname == &tmp_varname) { zval_dtor(varname); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = retval; PZVAL_LOCK(*retval); switch (type) { case BP_VAR_R: case BP_VAR_IS: AI_USE_PTR(EX_T(opline->result.u.var).var); break; case BP_VAR_UNSET: { zend_free_op free_res; PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); } PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); FREE_OP_VAR_PTR(free_res); break; } } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_R_SPEC() OPDEF(ZEND_FETCH_R, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_R) ZEND_VM_HANDLER(ZEND_FETCH_R) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_R); } #endif #define ZEND_FETCH_W_SPEC() OPDEF(ZEND_FETCH_W, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_W) ZEND_VM_HANDLER(ZEND_FETCH_W) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_W); } #endif #define ZEND_FETCH_RW_SPEC() OPDEF(ZEND_FETCH_RW, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_RW) ZEND_VM_HANDLER(ZEND_FETCH_RW) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_RW); } #endif #define ZEND_FETCH_FUNC_ARG_SPEC() OPDEF(ZEND_FETCH_FUNC_ARG, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_FUNC_ARG) ZEND_VM_HANDLER(ZEND_FETCH_FUNC_ARG) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), EX(opline)->extended_value)?BP_VAR_W:BP_VAR_R); } #endif #define ZEND_FETCH_UNSET_SPEC() OPDEF(ZEND_FETCH_UNSET, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_UNSET) ZEND_VM_HANDLER(ZEND_FETCH_UNSET) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_UNSET); } #endif #define ZEND_FETCH_IS_SPEC() OPDEF(ZEND_FETCH_IS, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_IS) ZEND_VM_HANDLER(ZEND_FETCH_IS) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_IS); } #endif #define ZEND_FETCH_DIM_R_SPEC() OPDEF(ZEND_FETCH_DIM_R, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_R) ZEND_VM_HANDLER(ZEND_FETCH_DIM_R) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); } zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_R TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_W_SPEC() OPDEF(ZEND_FETCH_DIM_W, M_VAR, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_FETCH_DIM_W) ZEND_VM_HANDLER(ZEND_FETCH_DIM_W) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_W TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_RW_SPEC() OPDEF(ZEND_FETCH_DIM_RW, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_RW) ZEND_VM_HANDLER(ZEND_FETCH_DIM_RW) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_RW TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_IS_SPEC() OPDEF(ZEND_FETCH_DIM_IS, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_IS) ZEND_VM_HANDLER(ZEND_FETCH_DIM_IS) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_IS TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_FUNC_ARG_SPEC() OPDEF(ZEND_FETCH_DIM_FUNC_ARG, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_FUNC_ARG) ZEND_VM_HANDLER(ZEND_FETCH_DIM_FUNC_ARG) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; int type = ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)?BP_VAR_W:BP_VAR_R; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(type), GET_OP2_ZVAL_PTR(BP_VAR_R), type TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_UNSET_SPEC() OPDEF(ZEND_FETCH_DIM_UNSET, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_UNSET) ZEND_VM_HANDLER(ZEND_FETCH_DIM_UNSET) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; /* Not needed in DIM_UNSET if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); } */ zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_UNSET), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_UNSET TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); if (EX_T(opline->result.u.var).var.ptr_ptr == NULL) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } else { zend_free_op free_res; PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); } PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); FREE_OP_VAR_PTR(free_res); } ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_fetch_property_address_read_helper, int type) { zend_op *opline = EX(opline); zval *container; zval **retval; zend_free_op free_op1; retval = &EX_T(opline->result.u.var).var.ptr; EX_T(opline->result.u.var).var.ptr_ptr = retval; container = GET_OP1_OBJ_ZVAL_PTR(type); if (container == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { *retval = EG(error_zval_ptr); PZVAL_LOCK(*retval); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } if (container->type != IS_OBJECT) { zend_error(E_NOTICE, "Trying to get property of non-object"); *retval = EG(uninitialized_zval_ptr); } else { zend_free_op free_op2; zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); zval tmp; switch (OP2_TYPE) { case IS_CONST: /* already a constant string */ break; case IS_VAR: tmp = *offset; zval_copy_ctor(&tmp); convert_to_string(&tmp); offset = &tmp; break; case IS_TMP_VAR: convert_to_string(offset); break; } /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); if (offset == &tmp) { zval_dtor(offset); } FREE_OP2(); if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); ZEND_VM_NEXT_OPCODE(); } } SELECTIVE_PZVAL_LOCK(*retval, &opline->result); AI_USE_PTR(EX_T(opline->result.u.var).var); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_OBJ_R_SPEC() OPDEF(ZEND_FETCH_OBJ_R, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_R) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_R) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_property_address_read_helper, type, BP_VAR_R); } #endif #define ZEND_FETCH_OBJ_W_SPEC() OPDEF(ZEND_FETCH_OBJ_W, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_W) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_W) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); EX_T(opline->op1.u.var).var.ptr = *EX_T(opline->op1.u.var).var.ptr_ptr; } zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_W TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_OBJ_RW_SPEC() OPDEF(ZEND_FETCH_OBJ_RW, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_RW) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_RW) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_RW TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_OBJ_IS_SPEC() OPDEF(ZEND_FETCH_OBJ_IS, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_IS) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_IS) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_property_address_read_helper, type, BP_VAR_IS); } #endif #define ZEND_FETCH_OBJ_FUNC_ARG_SPEC() OPDEF(ZEND_FETCH_OBJ_FUNC_ARG, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_FUNC_ARG) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_FUNC_ARG) { zend_op *opline = EX(opline); if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_W TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } else { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_property_address_read_helper, type, BP_VAR_R); } } #endif #define ZEND_FETCH_OBJ_UNSET_SPEC() OPDEF(ZEND_FETCH_OBJ_UNSET, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_UNSET) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_UNSET) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2, free_res; zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); } PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); FREE_OP_VAR_PTR(free_res); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_TMP_VAR_SPEC() OPDEF(ZEND_FETCH_DIM_TMP_VAR, M_TMP, M_CONST) #if HAVE_OP(ZEND_FETCH_DIM_TMP_VAR) ZEND_VM_HANDLER(ZEND_FETCH_DIM_TMP_VAR) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *container = GET_OP1_ZVAL_PTR(BP_VAR_R); if (container->type != IS_ARRAY) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); } } else { zend_free_op free_op2; zval *dim = GET_OP2_ZVAL_PTR(BP_VAR_R); EX_T(opline->result.u.var).var.ptr_ptr = zend_fetch_dimension_address_inner(container->value.ht, dim, BP_VAR_R TSRMLS_CC); SELECTIVE_PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &opline->result); FREE_OP2(); } AI_USE_PTR(EX_T(opline->result.u.var).var); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_OBJ_SPEC() OPDEF(ZEND_ASSIGN_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_OBJ) ZEND_VM_HANDLER(ZEND_ASSIGN_OBJ) { zend_op *opline = EX(opline); zend_op *op_data = opline+1; zend_free_op free_op1; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_OBJ TSRMLS_CC); FREE_OP1_VAR_PTR(); /* assign_obj has two opcodes! */ ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_DIM_SPEC() OPDEF(ZEND_ASSIGN_DIM, M_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_ASSIGN_DIM) ZEND_VM_HANDLER(ZEND_ASSIGN_DIM) { zend_op *opline = EX(opline); zend_op *op_data = opline+1; zend_free_op free_op1; zval **object_ptr; if (EX_T(opline->op1.u.var).var.ptr_ptr) { /* not an array offset */ object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); } else { object_ptr = NULL; } if (object_ptr && (*object_ptr)->type == IS_OBJECT) { zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_DIM TSRMLS_CC); } else { zend_free_op free_op2, free_op_data1; zval *value; if (object_ptr) { (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ } zend_fetch_dimension_address(&EX_T(op_data->op2.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_W TSRMLS_CC); FREE_OP2(); value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); zend_assign_to_variable(&opline->result, &op_data->op2, &op_data->op1, value, (IS_TMP_FREE(free_op_data1)?IS_TMP_VAR:op_data->op1.op_type), EX(Ts) TSRMLS_CC); FREE_OP_IF_VAR(free_op_data1); } FREE_OP1_VAR_PTR(); /* assign_dim has two opcodes! */ ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_SPEC() OPDEF(ZEND_ASSIGN, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN) ZEND_VM_HANDLER(ZEND_ASSIGN) { zend_op *opline = EX(opline); zend_free_op free_op2; zval *value = GET_OP2_ZVAL_PTR(BP_VAR_R); zend_assign_to_variable(&opline->result, &opline->op1, &opline->op2, value, (IS_OP2_TMP_FREE()?IS_TMP_VAR:OP2_TYPE), EX(Ts) TSRMLS_CC); /* zend_assign_to_variable() always takes care of op2, never free it! */ FREE_OP2_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_REF_SPEC() OPDEF(ZEND_ASSIGN_REF, M_VAR, M_VAR) #if HAVE_OP(ZEND_ASSIGN_REF) ZEND_VM_HANDLER(ZEND_ASSIGN_REF) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **variable_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); zval **value_ptr_ptr = GET_OP2_ZVAL_PTR_PTR(BP_VAR_W); zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC); if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = variable_ptr_ptr; PZVAL_LOCK(*variable_ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); FREE_OP2_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMP_SPEC() OPDEF(ZEND_JMP, M_ANY, M_ANY) #if HAVE_OP(ZEND_JMP) ZEND_VM_HANDLER(ZEND_JMP) { #if DEBUG_ZEND>=2 printf("Jumping to %d\n", opline->op1.u.opline_num); #endif ZEND_VM_SET_OPCODE(EX(opline)->op1.u.jmp_addr); ZEND_VM_CONTINUE(); /* CHECK_ME */ } #endif #define ZEND_JMPZ_SPEC() OPDEF(ZEND_JMPZ, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPZ) ZEND_VM_HANDLER(ZEND_JMPZ) { zend_op *opline = EX(opline); zend_free_op free_op1; int ret = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); if (!ret) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMPNZ_SPEC() OPDEF(ZEND_JMPNZ, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPNZ) ZEND_VM_HANDLER(ZEND_JMPNZ) { zend_op *opline = EX(opline); zend_free_op free_op1; int ret = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); if (ret) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMPZNZ_SPEC() OPDEF(ZEND_JMPZNZ, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPZNZ) ZEND_VM_HANDLER(ZEND_JMPZNZ) { zend_op *opline = EX(opline); zend_free_op free_op1; int retval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); if (retval) { #if DEBUG_ZEND>=2 printf("Conditional jmp on true to %d\n", opline->extended_value); #endif ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); ZEND_VM_CONTINUE(); /* CHECK_ME */ } else { #if DEBUG_ZEND>=2 printf("Conditional jmp on false to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.u.opline_num]); ZEND_VM_CONTINUE_JMP(); } } #endif #define ZEND_JMPZ_EX_SPEC() OPDEF(ZEND_JMPZ_EX, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPZ_EX) ZEND_VM_HANDLER(ZEND_JMPZ_EX) { zend_op *opline = EX(opline); zend_free_op free_op1; int retval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); EX_T(opline->result.u.var).tmp_var.value.lval = retval; EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; if (!retval) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMPNZ_EX_SPEC() OPDEF(ZEND_JMPNZ_EX, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPNZ_EX) ZEND_VM_HANDLER(ZEND_JMPNZ_EX) { zend_op *opline = EX(opline); zend_free_op free_op1; int retval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); EX_T(opline->result.u.var).tmp_var.value.lval = retval; EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; if (retval) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FREE_SPEC() OPDEF(ZEND_FREE, M_TMP, M_ANY) #if HAVE_OP(ZEND_FREE) ZEND_VM_HANDLER(ZEND_FREE) { zendi_zval_dtor(EX_T(EX(opline)->op1.u.var).tmp_var); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_STRING_SPEC() OPDEF(ZEND_INIT_STRING, M_ANY, M_ANY) #if HAVE_OP(ZEND_INIT_STRING) ZEND_VM_HANDLER(ZEND_INIT_STRING) { zval *tmp = &EX_T(EX(opline)->result.u.var).tmp_var; tmp->value.str.val = emalloc(1); tmp->value.str.val[0] = 0; tmp->value.str.len = 0; tmp->refcount = 1; tmp->type = IS_STRING; tmp->is_ref = 0; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_CHAR_SPEC() OPDEF(ZEND_ADD_CHAR, M_TMP, M_CONST) #if HAVE_OP(ZEND_ADD_CHAR) ZEND_VM_HANDLER(ZEND_ADD_CHAR) { zend_op *opline = EX(opline); zend_free_op free_op1; add_char_to_string(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_NA), &opline->op2.u.constant); /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_STRING_SPEC() OPDEF(ZEND_ADD_STRING, M_TMP, M_CONST) #if HAVE_OP(ZEND_ADD_STRING) ZEND_VM_HANDLER(ZEND_ADD_STRING) { zend_op *opline = EX(opline); zend_free_op free_op1; add_string_to_string(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_NA), &opline->op2.u.constant); /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_VAR_SPEC() OPDEF(ZEND_ADD_VAR, M_TMP, M_TMP_VAR) #if HAVE_OP(ZEND_ADD_VAR) ZEND_VM_HANDLER(ZEND_ADD_VAR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval *var = GET_OP2_ZVAL_PTR(BP_VAR_R); zval var_copy; int use_copy; zend_make_printable_zval(var, &var_copy, &use_copy); if (use_copy) { var = &var_copy; } add_string_to_string( &EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_NA), var); if (use_copy) { zval_dtor(var); } /* original comment, possibly problematic: * FREE_OP is missing intentionally here - we're always working on the same temporary variable * (Zeev): I don't think it's problematic, we only use variables * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're * string offsets or overloaded objects */ FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_CLASS_SPEC() OPDEF(ZEND_FETCH_CLASS, M_ANY, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_FETCH_CLASS) ZEND_VM_HANDLER(ZEND_FETCH_CLASS) { zend_op *opline = EX(opline); zval *class_name; zend_free_op free_op2; if (OP2_TYPE == IS_UNUSED) { EX_T(opline->result.u.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } class_name = GET_OP2_ZVAL_PTR(BP_VAR_R); switch (class_name->type) { case IS_OBJECT: EX_T(opline->result.u.var).class_entry = Z_OBJCE_P(class_name); break; case IS_STRING: EX_T(opline->result.u.var).class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); break; default: zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string"); break; } FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_CTOR_CALL_SPEC() OPDEF(ZEND_INIT_CTOR_CALL, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_INIT_CTOR_CALL) ZEND_VM_HANDLER(ZEND_INIT_CTOR_CALL) { zend_op *opline = EX(opline); zend_free_op free_op1; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); if (OP1_TYPE == IS_VAR) { SELECTIVE_PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr, &opline->op1); } /* We are not handling overloaded classes right now */ EX(object) = GET_OP1_ZVAL_PTR(BP_VAR_R); /* New always returns the object as is_ref=0, therefore, we can just increment the reference count */ EX(object)->refcount++; /* For $this pointer */ EX(fbc) = EX(fbc_constructor); if (EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */ EX(calling_scope) = EX(fbc)->common.scope; } else { EX(calling_scope) = NULL; } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_METHOD_CALL_SPEC() OPDEF(ZEND_INIT_METHOD_CALL, M_TMP_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_INIT_METHOD_CALL) ZEND_VM_HANDLER(ZEND_INIT_METHOD_CALL) { zend_op *opline = EX(opline); zval *function_name; char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name)!=IS_STRING) { zend_error_noreturn(E_ERROR, "Method name must be a string"); } function_name_strval = function_name->value.str.val; function_name_strlen = function_name->value.str.len; EX(calling_scope) = EG(scope); EX(object) = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R); if (EX(object) && EX(object)->type == IS_OBJECT) { if (Z_OBJ_HT_P(EX(object))->get_method == NULL) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(EX(object), function_name_strval, function_name_strlen TSRMLS_CC); if (!EX(fbc)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); } } else { zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { EX(object)->refcount++; /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); INIT_PZVAL_COPY(this_ptr, EX(object)); zval_copy_ctor(this_ptr); EX(object) = this_ptr; } } if (EX(fbc)->type == ZEND_USER_FUNCTION) { EX(calling_scope) = EX(fbc)->common.scope; } else { EX(calling_scope) = NULL; } FREE_OP2(); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_STATIC_METHOD_CALL_SPEC() OPDEF(ZEND_INIT_STATIC_METHOD_CALL, M_ANY, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_INIT_STATIC_METHOD_CALL) ZEND_VM_HANDLER(ZEND_INIT_STATIC_METHOD_CALL) { zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); ce = EX_T(opline->op1.u.var).class_entry; if(OP2_TYPE != IS_UNUSED) { char *function_name_strval; int function_name_strlen; zend_bool is_const = (OP2_TYPE == IS_CONST); zend_free_op free_op2; if (is_const) { function_name_strval = opline->op2.u.constant.value.str.val; function_name_strlen = opline->op2.u.constant.value.str.len; } else { function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } function_name_strval = zend_str_tolower_dup(function_name->value.str.val, function_name->value.str.len); function_name_strlen = function_name->value.str.len; } EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { efree(function_name_strval); FREE_OP2(); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); } EX(fbc) = ce->constructor; } EX(calling_scope) = EX(fbc)->common.scope; if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { if ((EX(object) = EG(This))) { EX(object)->refcount++; } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_FCALL_BY_NAME_SPEC() OPDEF(ZEND_INIT_FCALL_BY_NAME, M_ANY, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_INIT_FCALL_BY_NAME) ZEND_VM_HANDLER(ZEND_INIT_FCALL_BY_NAME) { zend_op *opline = EX(opline); zval *function_name; zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); if (OP2_TYPE == IS_CONST) { #ifndef ZEND_VM_SPEC free_op2.var = NULL; #endif function_name_strval = opline->op2.u.constant.value.str.val; function_name_strlen = opline->op2.u.constant.value.str.len; } else { function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } function_name_strval = function_name->value.str.val; function_name_strlen = function_name->value.str.len; } lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { efree(lcname); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); FREE_OP2(); EX(calling_scope) = function->common.scope; EX(object) = NULL; EX(fbc) = function; ZEND_VM_NEXT_OPCODE(); } #endif #define zend_do_fcall_common_helper_CONST_ANY zend_do_fcall_common_helper_ANY_ANY #if OP1_OP2_MASK(M_ANY, M_ANY) ZEND_VM_HELPER(zend_do_fcall_common_helper) { zend_op *opline = EX(opline); zval **original_return_value; zend_class_entry *current_scope; zval *current_this; int return_value_used = RETURN_VALUE_USED(opline); zend_bool should_change_scope; if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); ZEND_VM_NEXT_OPCODE(); /* Never reached */ } zend_ptr_stack_2_push(&EG(argument_stack), (void *) opline->extended_value, NULL); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; if (EX(function_state).function->type == ZEND_USER_FUNCTION || EX(function_state).function->common.scope) { should_change_scope = 1; current_this = EG(This); EG(This) = EX(object); current_scope = EG(scope); EG(scope) = EX(calling_scope); } else { should_change_scope = 0; } EX_T(opline->result.u.var).var.fcall_returned_reference = 0; if (EX(function_state).function->common.scope) { if (!EG(This) && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { int severity; char *severity_word; if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { severity = E_STRICT; severity_word = "should not"; } else { severity = E_ERROR; severity_word = "cannot"; } zend_error(severity, "Non-static method %s::%s() %s be called statically", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name, severity_word); } } if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); if (EX(function_state).function->common.arg_info) { zend_uint i=0; zval **p; ulong arg_count; p = (zval **) EG(argument_stack).top_element-2; arg_count = (ulong) *p; while (arg_count>0) { zend_verify_arg_type(EX(function_state).function, ++i, *(p-arg_count) TSRMLS_CC); arg_count--; } } if (!zend_execute_internal) { /* saves one function call if zend_execute_internal is not used */ ((zend_internal_function *) EX(function_state).function)->handler(opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); } else { zend_execute_internal(EXECUTE_DATA, return_value_used TSRMLS_CC); } EG(current_execute_data) = EXECUTE_DATA; EX_T(opline->result.u.var).var.ptr->is_ref = 0; EX_T(opline->result.u.var).var.ptr->refcount = 1; if (!return_value_used) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } } else if (EX(function_state).function->type == ZEND_USER_FUNCTION) { HashTable *calling_symbol_table; EX_T(opline->result.u.var).var.ptr = NULL; if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ EX(function_state).function_symbol_table = *(EG(symtable_cache_ptr)--); } else { ALLOC_HASHTABLE(EX(function_state).function_symbol_table); zend_hash_init(EX(function_state).function_symbol_table, 0, NULL, ZVAL_PTR_DTOR, 0); /*printf("Cache miss! Initialized %x\n", function_state.function_symbol_table);*/ } calling_symbol_table = EG(active_symbol_table); EG(active_symbol_table) = EX(function_state).function_symbol_table; original_return_value = EG(return_value_ptr_ptr); EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; EG(active_op_array) = (zend_op_array *) EX(function_state).function; zend_execute(EG(active_op_array) TSRMLS_CC); EX_T(opline->result.u.var).var.fcall_returned_reference = EG(active_op_array)->return_reference; if (return_value_used && !EX_T(opline->result.u.var).var.ptr) { if (!EG(exception)) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); } } else if (!return_value_used && EX_T(opline->result.u.var).var.ptr) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr)=original_return_value; if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { zend_hash_destroy(EX(function_state).function_symbol_table); FREE_HASHTABLE(EX(function_state).function_symbol_table); } else { /* clean before putting into the cache, since clean could call dtors, which could use cached hash */ zend_hash_clean(EX(function_state).function_symbol_table); *(++EG(symtable_cache_ptr)) = EX(function_state).function_symbol_table; } EG(active_symbol_table) = calling_symbol_table; } else { /* ZEND_OVERLOADED_FUNCTION */ ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); /* Not sure what should be done here if it's a static method */ if (EX(object)) { Z_OBJ_HT_P(EX(object))->call_method(EX(fbc)->common.function_name, opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { efree(EX(function_state).function->common.function_name); } efree(EX(fbc)); if (!return_value_used) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } else { EX_T(opline->result.u.var).var.ptr->is_ref = 0; EX_T(opline->result.u.var).var.ptr->refcount = 1; } } if (EG(This)) { if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) { EG(This)->refcount--; if (EG(This)->refcount == 1) { zend_object_store_ctor_failed(EG(This) TSRMLS_CC); } zval_ptr_dtor(&EG(This)); } else if (should_change_scope) { zval_ptr_dtor(&EG(This)); } } if (should_change_scope) { EG(This) = current_this; EG(scope) = current_scope; } zend_ptr_stack_3_pop(&EG(arg_types_stack), (void**)&EX(calling_scope), (void**)&EX(object), (void**)&EX(fbc)); EX(function_state).function = (zend_function *) EX(op_array); EG(function_state_ptr) = &EX(function_state); zend_ptr_stack_clear_multiple(TSRMLS_C); if (EG(exception)) { zend_throw_exception_internal(NULL TSRMLS_CC); if (return_value_used && EX_T(opline->result.u.var).var.ptr) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DO_FCALL_BY_NAME_SPEC() OPDEF(ZEND_DO_FCALL_BY_NAME, M_ANY, M_ANY) #if HAVE_OP(ZEND_DO_FCALL_BY_NAME) ZEND_VM_HANDLER(ZEND_DO_FCALL_BY_NAME) { EX(function_state).function = EX(fbc); ZEND_VM_DISPATCH_TO_HELPER(zend_do_fcall_common_helper); } #endif #define ZEND_DO_FCALL_SPEC() OPDEF(ZEND_DO_FCALL, M_CONST, M_ANY) #if HAVE_OP(ZEND_DO_FCALL) ZEND_VM_HANDLER(ZEND_DO_FCALL) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *fname = GET_OP1_ZVAL_PTR(BP_VAR_R); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { zend_error_noreturn(E_ERROR, "Unknown function: %s()\n", fname->value.str.val); } EX(object) = NULL; EX(calling_scope) = EX(function_state).function->common.scope; FREE_OP1(); ZEND_VM_DISPATCH_TO_HELPER(zend_do_fcall_common_helper); } #endif #define ZEND_RETURN_SPEC() OPDEF(ZEND_RETURN, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_RETURN) ZEND_VM_HANDLER(ZEND_RETURN) { zend_op *opline = EX(opline); zval *retval_ptr; zval **retval_ptr_ptr; zend_free_op free_op1; if (EG(active_op_array)->return_reference == ZEND_RETURN_REF) { if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_STRICT, "Only variable references should be returned by reference"); ZEND_VM_C_GOTO(return_by_value); } retval_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); if (!retval_ptr_ptr) { zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } if (!(*retval_ptr_ptr)->is_ref) { if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr || (opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op1.u.var).var.fcall_returned_reference)) { zend_error(E_STRICT, "Only variable references should be returned by reference"); PZVAL_LOCK(*retval_ptr_ptr); /* undo the effect of get_zval_ptr_ptr() */ ZEND_VM_C_GOTO(return_by_value); } } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); (*retval_ptr_ptr)->refcount++; (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { ZEND_VM_C_LABEL(return_by_value): retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) { zval *ret; ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) { zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(retval_ptr)->name); } zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name); ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC); *EG(return_value_ptr_ptr) = ret; } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */ if (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0) { zval *ret; ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); zval_copy_ctor(ret); *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; retval_ptr->refcount++; } } else { zval *ret; ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; } } FREE_OP1_IF_VAR(); ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } #endif #define ZEND_THROW_SPEC() OPDEF(ZEND_THROW, M_VAR, M_ANY) #if HAVE_OP(ZEND_THROW) ZEND_VM_HANDLER(ZEND_THROW) { zend_op *opline = EX(opline); zval *value; zval *exception; zend_free_op free_op1; value = GET_OP1_ZVAL_PTR(BP_VAR_R); if (value->type != IS_OBJECT) { zend_error_noreturn(E_ERROR, "Can only throw objects"); } /* Not sure if a complete copy is what we want here */ ALLOC_ZVAL(exception); INIT_PZVAL_COPY(exception, value); if (!IS_OP1_TMP_FREE()) { zval_copy_ctor(exception); } zend_throw_exception_object(exception TSRMLS_CC); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_CATCH_SPEC() OPDEF(ZEND_CATCH, M_ANY, M_ANY) #if HAVE_OP(ZEND_CATCH) ZEND_VM_HANDLER(ZEND_CATCH) { zend_op *opline = EX(opline); zend_class_entry *ce; /* Check whether an exception has been thrown, if not, jump over code */ if (EG(exception) == NULL) { ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); ZEND_VM_CONTINUE(); /* CHECK_ME */ } ce = Z_OBJCE_P(EG(exception)); if (ce != EX_T(opline->op1.u.var).class_entry) { if (!instanceof_function(ce, EX_T(opline->op1.u.var).class_entry TSRMLS_CC)) { if (opline->op1.u.EA.type) { zend_throw_exception_internal(NULL TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); ZEND_VM_CONTINUE(); /* CHECK_ME */ } } zend_hash_update(EG(active_symbol_table), opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, &EG(exception), sizeof(zval *), (void **) NULL); EG(exception) = NULL; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_VAL_SPEC() OPDEF(ZEND_SEND_VAL, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_VAL) ZEND_VM_HANDLER(ZEND_SEND_VAL) { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { zval *valptr; zval *value; zend_free_op free_op1; value = GET_OP1_ZVAL_PTR(BP_VAR_R); ALLOC_ZVAL(valptr); INIT_PZVAL_COPY(valptr, value); if (!IS_OP1_TMP_FREE()) { zval_copy_ctor(valptr); } zend_ptr_stack_push(&EG(argument_stack), valptr); FREE_OP1_IF_VAR(); } ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR, M_ANY) ZEND_VM_HELPER(zend_send_by_var_helper) { zend_op *opline = EX(opline); zval *varptr; zend_free_op free_op1; varptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); INIT_ZVAL(*varptr); varptr->refcount = 0; } else if (PZVAL_IS_REF(varptr)) { zval *original_var = varptr; ALLOC_ZVAL(varptr); *varptr = *original_var; varptr->is_ref = 0; varptr->refcount = 0; zval_copy_ctor(varptr); } varptr->refcount++; zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1(); /* for string offsets */ ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_VAR_NO_REF_SPEC() OPDEF(ZEND_SEND_VAR_NO_REF, M_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_VAR_NO_REF) ZEND_VM_HANDLER(ZEND_SEND_VAR_NO_REF) { zend_op *opline = EX(opline); if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } { zval *varptr; zend_free_op free_op1; varptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { varptr->is_ref = 1; varptr->refcount++; zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_REF_SPEC() OPDEF(ZEND_SEND_REF, M_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_REF) ZEND_VM_HANDLER_EX(ZEND_SEND_REF) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **varptr_ptr; zval *varptr; varptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); if (!varptr_ptr) { zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); } SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); varptr = *varptr_ptr; varptr->refcount++; zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_VAR_SPEC() OPDEF(ZEND_SEND_VAR, M_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_VAR) ZEND_VM_HANDLER(ZEND_SEND_VAR) { zend_op *opline = EX(opline); if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF); } ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } #endif #define ZEND_RECV_SPEC() OPDEF(ZEND_RECV, M_ANY, M_ANY) #if HAVE_OP(ZEND_RECV) ZEND_VM_HANDLER(ZEND_RECV) { zend_op *opline = EX(opline); zval **param; zend_uint arg_num = opline->op1.u.constant.value.lval; if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { char *space; char *class_name = get_active_class_name(&space TSRMLS_CC); zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC); zend_error(E_WARNING, "Missing argument %ld for %s%s%s()", opline->op1.u.constant.value.lval, class_name, space, get_active_function_name(TSRMLS_C)); if (opline->result.op_type == IS_VAR) { PZVAL_UNLOCK_FREE(*EX_T(opline->result.u.var).var.ptr_ptr); } } else { zend_free_op free_res; zval **var_ptr; zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param TSRMLS_CC); var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W); if (PZVAL_IS_REF(*param)) { zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC); } else { zend_receive(var_ptr, *param TSRMLS_CC); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_RECV_INIT_SPEC() OPDEF(ZEND_RECV_INIT, M_ANY, M_CONST) #if HAVE_OP(ZEND_RECV_INIT) ZEND_VM_HANDLER(ZEND_RECV_INIT) { zend_op *opline = EX(opline); zval **param, *assignment_value; zend_uint arg_num = opline->op1.u.constant.value.lval; zend_free_op free_res; zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W); if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { zval *default_value; ALLOC_ZVAL(default_value); *default_value = opline->op2.u.constant; if (opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { zval_copy_ctor(default_value); } default_value->refcount=1; zval_update_constant(&default_value, 0 TSRMLS_CC); default_value->refcount=0; default_value->is_ref=0; param = &default_value; assignment_value = default_value; } else { param = NULL; assignment_value = &opline->op2.u.constant; } zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); zend_receive(var_ptr, assignment_value TSRMLS_CC); } else { assignment_value = *param; zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); if (PZVAL_IS_REF(assignment_value)) { zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC); } else { zend_receive(var_ptr, assignment_value TSRMLS_CC); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BOOL_SPEC() OPDEF(ZEND_BOOL, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_BOOL) ZEND_VM_HANDLER(ZEND_BOOL) { zend_op *opline = EX(opline); zend_free_op free_op1; /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ EX_T(opline->result.u.var).tmp_var.value.lval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BRK_SPEC() OPDEF(ZEND_BRK, M_ANY, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BRK) ZEND_VM_HANDLER(ZEND_BRK) { zend_op *opline = EX(opline); zend_free_op free_op2; ZEND_VM_SET_OPCODE(EX(op_array)->opcodes + zend_brk_cont(GET_OP2_ZVAL_PTR(BP_VAR_R), opline->op1.u.opline_num, EX(op_array), EX(Ts) TSRMLS_CC)->brk); FREE_OP2(); ZEND_VM_CONTINUE(); /* CHECK_ME */ } #endif #define ZEND_CONT_SPEC() OPDEF(ZEND_CONT, M_ANY, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_CONT) ZEND_VM_HANDLER(ZEND_CONT) { zend_op *opline = EX(opline); zend_free_op free_op2; ZEND_VM_SET_OPCODE(EX(op_array)->opcodes + zend_brk_cont(GET_OP2_ZVAL_PTR(BP_VAR_R), opline->op1.u.opline_num, EX(op_array), EX(Ts) TSRMLS_CC)->cont); FREE_OP2(); ZEND_VM_CONTINUE(); /* CHECK_ME */ } #endif #define ZEND_CASE_SPEC() OPDEF(ZEND_CASE, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_CASE) ZEND_VM_HANDLER(ZEND_CASE) { zend_op *opline = EX(opline); int switch_expr_is_overloaded=0; zend_free_op free_op1, free_op2; if (OP1_TYPE==IS_VAR) { if (EX_T(opline->op1.u.var).var.ptr_ptr) { PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; EX_T(opline->op1.u.var).str_offset.str->refcount++; } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP2(); if (switch_expr_is_overloaded) { /* We only free op1 if this is a string offset, * Since if it is a TMP_VAR, it'll be reused by * other CASE opcodes (whereas string offsets * are allocated at each get_zval_ptr()) */ FREE_OP1(); EX_T(opline->op1.u.var).var.ptr_ptr = NULL; AI_USE_PTR(EX_T(opline->op1.u.var).var); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SWITCH_FREE_SPEC() OPDEF(ZEND_SWITCH_FREE, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_SWITCH_FREE) ZEND_VM_HANDLER(ZEND_SWITCH_FREE) { zend_switch_free(EX(opline), EX(Ts) TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_NEW_SPEC() OPDEF(ZEND_NEW, M_ANY, M_ANY) #if HAVE_OP(ZEND_NEW) ZEND_VM_HANDLER(ZEND_NEW) { zend_op *opline = EX(opline); if (EX_T(opline->op1.u.var).class_entry->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { char *class_type; if (EX_T(opline->op1.u.var).class_entry->ce_flags & ZEND_ACC_INTERFACE) { class_type = "interface"; } else { class_type = "abstract class"; } zend_error_noreturn(E_ERROR, "Cannot instantiate %s %s", class_type, EX_T(opline->op1.u.var).class_entry->name); } EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); object_init_ex(EX_T(opline->result.u.var).var.ptr, EX_T(opline->op1.u.var).class_entry); EX_T(opline->result.u.var).var.ptr->refcount=1; EX_T(opline->result.u.var).var.ptr->is_ref=0; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_CLONE_SPEC() OPDEF(ZEND_CLONE, M_CONST_TMP_VAR_UNUSED, M_ANY) #if HAVE_OP(ZEND_CLONE) ZEND_VM_HANDLER(ZEND_CLONE) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *obj = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R); zend_class_entry *ce; zend_function *clone; zend_object_clone_obj_t clone_call; if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error(E_WARNING, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); EX_T(opline->result.u.var).var.ptr->refcount++; FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } ce = Z_OBJCE_P(obj); clone = ce ? ce->clone : NULL; clone_call = Z_OBJ_HT_P(obj)->clone_obj; if (!clone_call) { zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); EX_T(opline->result.u.var).var.ptr->refcount++; } if (ce && clone) { if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) { /* Ensure that if we're calling a private function, we're allowed to do so. */ if (ce != EG(scope)) { zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); } } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) { /* Ensure that if we're calling a protected function, we're allowed to do so. */ if (!zend_check_protected(clone->common.scope, EG(scope))) { zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); } } } EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr->value.obj = clone_call(obj TSRMLS_CC); if (EG(exception)) { FREE_ZVAL(EX_T(opline->result.u.var).var.ptr); } else { EX_T(opline->result.u.var).var.ptr->type = IS_OBJECT; EX_T(opline->result.u.var).var.ptr->refcount=1; EX_T(opline->result.u.var).var.ptr->is_ref=1; } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_CONSTANT_SPEC() OPDEF(ZEND_FETCH_CONSTANT, M_CONST_UNUSED, M_CONST) #if HAVE_OP(ZEND_FETCH_CONSTANT) ZEND_VM_HANDLER(ZEND_FETCH_CONSTANT) { zend_op *opline = EX(opline); zend_class_entry *ce = NULL; zval **value; if (OP1_TYPE == IS_UNUSED) { /* This seems to be a reminant of namespaces if (EG(scope)) { ce = EG(scope); if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { zval_update_constant(value, (void *) 1 TSRMLS_CC); EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); ZEND_VM_NEXT_OPCODE(); } } */ if (!zend_get_constant(opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len, &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) { zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.val); EX_T(opline->result.u.var).tmp_var = opline->op2.u.constant; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } ZEND_VM_NEXT_OPCODE(); } ce = EX_T(opline->op1.u.var).class_entry; if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { zval_update_constant(value, (void *) 1 TSRMLS_CC); EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } else { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", opline->op2.u.constant.value.str.val); } ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_CONST_TMP_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) ZEND_VM_HELPER(zend_init_add_array_helper) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval *array_ptr = &EX_T(opline->result.u.var).tmp_var; zval *expr_ptr, **expr_ptr_ptr = NULL; zval *offset=GET_OP2_ZVAL_PTR(BP_VAR_R); if (opline->extended_value) { expr_ptr_ptr=GET_OP1_ZVAL_PTR_PTR(BP_VAR_R); expr_ptr = *expr_ptr_ptr; } else { expr_ptr=GET_OP1_ZVAL_PTR(BP_VAR_R); } if (opline->opcode == ZEND_INIT_ARRAY) { array_init(array_ptr); if (!expr_ptr) { ZEND_VM_NEXT_OPCODE(); } } if (!opline->extended_value && IS_OP1_TMP_FREE()) { /* temporary variable */ zval *new_expr; ALLOC_ZVAL(new_expr); INIT_PZVAL_COPY(new_expr, expr_ptr); expr_ptr = new_expr; } else { if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; expr_ptr->refcount++; } else if (PZVAL_IS_REF(expr_ptr)) { zval *new_expr; ALLOC_ZVAL(new_expr); INIT_PZVAL_COPY(new_expr, expr_ptr); expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { expr_ptr->refcount++; } } if (offset) { switch (offset->type) { case IS_DOUBLE: zend_hash_index_update(array_ptr->value.ht, (long) offset->value.dval, &expr_ptr, sizeof(zval *), NULL); break; case IS_LONG: case IS_BOOL: zend_hash_index_update(array_ptr->value.ht, offset->value.lval, &expr_ptr, sizeof(zval *), NULL); break; case IS_STRING: zend_symtable_update(array_ptr->value.ht, offset->value.str.val, offset->value.str.len+1, &expr_ptr, sizeof(zval *), NULL); break; case IS_NULL: zend_hash_update(array_ptr->value.ht, "", sizeof(""), &expr_ptr, sizeof(zval *), NULL); break; default: zend_error(E_WARNING, "Illegal offset type"); zval_ptr_dtor(&expr_ptr); /* do nothing */ break; } FREE_OP2(); } else { zend_hash_next_index_insert(array_ptr->value.ht, &expr_ptr, sizeof(zval *), NULL); } if (opline->extended_value) { FREE_OP1_VAR_PTR(); } else { FREE_OP1_IF_VAR(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_ARRAY_SPEC() OPDEF(ZEND_INIT_ARRAY, M_CONST_TMP_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_INIT_ARRAY) ZEND_VM_HANDLER(ZEND_INIT_ARRAY) { ZEND_VM_DISPATCH_TO_HELPER(zend_init_add_array_helper); } #endif #define ZEND_ADD_ARRAY_ELEMENT_SPEC() OPDEF(ZEND_ADD_ARRAY_ELEMENT, M_CONST_TMP_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_ADD_ARRAY_ELEMENT) ZEND_VM_HANDLER(ZEND_ADD_ARRAY_ELEMENT) { ZEND_VM_DISPATCH_TO_HELPER(zend_init_add_array_helper); } #endif #define ZEND_CAST_SPEC() OPDEF(ZEND_CAST, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_CAST) ZEND_VM_HANDLER(ZEND_CAST) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *expr = GET_OP1_ZVAL_PTR(BP_VAR_R); zval *result = &EX_T(opline->result.u.var).tmp_var; *result = *expr; if (!IS_OP1_TMP_FREE()) { zendi_zval_copy_ctor(*result); } switch (opline->extended_value) { case IS_NULL: convert_to_null(result); break; case IS_BOOL: convert_to_boolean(result); break; case IS_LONG: convert_to_long(result); break; case IS_DOUBLE: convert_to_double(result); break; case IS_STRING: { zval var_copy; int use_copy; zend_make_printable_zval(result, &var_copy, &use_copy); if (use_copy) { zval_dtor(result); *result = var_copy; } break; } case IS_ARRAY: convert_to_array(result); break; case IS_OBJECT: convert_to_object(result); break; } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INCLUDE_OR_EVAL_SPEC() OPDEF(ZEND_INCLUDE_OR_EVAL, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_INCLUDE_OR_EVAL) ZEND_VM_HANDLER(ZEND_INCLUDE_OR_EVAL) { zend_op *opline = EX(opline); zend_op_array *new_op_array=NULL; zval **original_return_value = EG(return_value_ptr_ptr); int return_value_used; zend_free_op free_op1; zval *inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R); zval tmp_inc_filename; zend_bool failure_retval=0; if (inc_filename->type!=IS_STRING) { tmp_inc_filename = *inc_filename; zval_copy_ctor(&tmp_inc_filename); convert_to_string(&tmp_inc_filename); inc_filename = &tmp_inc_filename; } return_value_used = RETURN_VALUE_USED(opline); switch (opline->op2.u.constant.value.lval) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { int dummy = 1; zend_file_handle file_handle; if (SUCCESS == zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); } if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { zend_file_handle_dtor(&file_handle); failure_retval=1; } } else { if (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, inc_filename->value.str.val); } else { zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, inc_filename->value.str.val); } } break; } break; case ZEND_INCLUDE: case ZEND_REQUIRE: new_op_array = compile_filename(opline->op2.u.constant.value.lval, inc_filename TSRMLS_CC); break; case ZEND_EVAL: { char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC); new_op_array = compile_string(inc_filename, eval_desc TSRMLS_CC); efree(eval_desc); } break; EMPTY_SWITCH_DEFAULT_CASE() } if (inc_filename==&tmp_inc_filename) { zval_dtor(&tmp_inc_filename); } FREE_OP1(); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; if (new_op_array) { zval *saved_object; zend_function *saved_function; EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; EG(active_op_array) = new_op_array; EX_T(opline->result.u.var).var.ptr = NULL; saved_object = EX(object); saved_function = EX(function_state).function; EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; zend_execute(new_op_array TSRMLS_CC); EX(function_state).function = saved_function; EX(object) = saved_object; if (!return_value_used) { if (EX_T(opline->result.u.var).var.ptr) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } } else { /* return value is used */ if (!EX_T(opline->result.u.var).var.ptr) { /* there was no return statement */ ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_PZVAL(EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr->value.lval = 1; EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; } } EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); EG(function_state_ptr) = &EX(function_state); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (EG(exception)) { zend_throw_exception_internal(NULL TSRMLS_CC); } } else { if (return_value_used) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr->value.lval = failure_retval; EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; } } EG(return_value_ptr_ptr) = original_return_value; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_UNSET_VAR_SPEC() OPDEF(ZEND_UNSET_VAR, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_UNSET_VAR) ZEND_VM_HANDLER(ZEND_UNSET_VAR) { zend_op *opline = EX(opline); zval tmp, *varname; HashTable *target_symbol_table; zend_free_op free_op1; varname = GET_OP1_ZVAL_PTR(BP_VAR_R); if (varname->type != IS_STRING) { tmp = *varname; zval_copy_ctor(&tmp); convert_to_string(&tmp); varname = &tmp; } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { zend_std_unset_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); zend_hash_del(target_symbol_table, varname->value.str.val, varname->value.str.len+1); } if (varname == &tmp) { zval_dtor(&tmp); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_UNSET_DIM_OBJ_SPEC() OPDEF(ZEND_UNSET_DIM_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_UNSET_DIM_OBJ) ZEND_VM_HANDLER(ZEND_UNSET_DIM_OBJ) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R); zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); long index; if (container) { HashTable *ht; if (opline->extended_value == ZEND_UNSET_DIM) { switch (Z_TYPE_PP(container)) { case IS_ARRAY: ht = Z_ARRVAL_PP(container); break; case IS_OBJECT: ht = NULL; if (!Z_OBJ_HT_P(*container)->unset_dimension) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); } Z_OBJ_HT_P(*container)->unset_dimension(*container, offset TSRMLS_CC); break; case IS_STRING: zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ default: ht = NULL; break; } } else { /* ZEND_UNSET_OBJ */ ht = NULL; if (Z_TYPE_PP(container) == IS_OBJECT) { Z_OBJ_HT_P(*container)->unset_property(*container, offset TSRMLS_CC); } } if (ht) { switch (offset->type) { case IS_DOUBLE: case IS_RESOURCE: case IS_BOOL: case IS_LONG: if (offset->type == IS_DOUBLE) { index = (long) offset->value.dval; } else { index = offset->value.lval; } zend_hash_index_del(ht, index); break; case IS_STRING: zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1); break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; default: zend_error(E_WARNING, "Illegal offset type in unset"); break; } } } else { /* overloaded element */ } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FE_RESET_SPEC() OPDEF(ZEND_FE_RESET, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FE_RESET) ZEND_VM_HANDLER(ZEND_FE_RESET) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *array_ptr, **array_ptr_ptr; HashTable *fe_ht; zend_object_iterator *iter = NULL; zend_class_entry *ce = NULL; if (opline->extended_value) { array_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R); if (array_ptr_ptr == NULL) { MAKE_STD_ZVAL(array_ptr); } else if (Z_TYPE_PP(array_ptr_ptr) == IS_OBJECT) { ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); (*array_ptr_ptr)->refcount++; } array_ptr = *array_ptr_ptr; } else { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); array_ptr = *array_ptr_ptr; array_ptr->refcount++; } } else { array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (IS_OP1_TMP_FREE()) { /* IS_TMP_VAR */ zval *tmp; ALLOC_ZVAL(tmp); INIT_PZVAL_COPY(tmp, array_ptr); array_ptr = tmp; } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); } else { array_ptr->refcount++; } } if (ce && ce->get_iterator) { iter = ce->get_iterator(ce, array_ptr TSRMLS_CC); if (iter) { array_ptr = zend_iterator_wrap(iter TSRMLS_CC); } else { array_ptr->refcount++; } } PZVAL_LOCK(array_ptr); EX_T(opline->result.u.var).var.ptr = array_ptr; EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; if (iter) { iter->index = 0; if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); } } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) { /* probably redundant */ zend_hash_internal_pointer_reset(fe_ht); } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); opline++; ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); if (opline->extended_value) { FREE_OP1_VAR_PTR(); } else { FREE_OP1_IF_VAR(); } ZEND_VM_CONTINUE_JMP(); } if (opline->extended_value) { FREE_OP1_VAR_PTR(); } else { FREE_OP1_IF_VAR(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FE_FETCH_SPEC() OPDEF(ZEND_FE_FETCH, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FE_FETCH) ZEND_VM_HANDLER(ZEND_FE_FETCH) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *array = GET_OP1_ZVAL_PTR(BP_VAR_R); zval **value, *key; char *str_key; uint str_key_len; ulong int_key; HashTable *fe_ht; zend_object_iterator *iter = NULL; int key_type; zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY; PZVAL_LOCK(array); switch (zend_iterator_unwrap(array, &iter TSRMLS_CC)) { default: case ZEND_ITER_INVALID: zend_error(E_WARNING, "Invalid argument supplied for foreach()"); ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); case ZEND_ITER_PLAIN_OBJECT: { char *class_name, *prop_name; zend_object *zobj = zend_objects_get_address(array TSRMLS_CC); fe_ht = HASH_OF(array); do { if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { /* reached end of iteration */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); zend_hash_move_forward(fe_ht); } while (key_type != HASH_KEY_IS_STRING || zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS); if (use_key) { zend_unmangle_property_name(str_key, &class_name, &prop_name); str_key_len = strlen(prop_name); str_key = estrndup(prop_name, str_key_len); str_key_len++; } break; } case ZEND_ITER_PLAIN_ARRAY: fe_ht = HASH_OF(array); if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { /* reached end of iteration */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } if (use_key) { key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 1, NULL); } zend_hash_move_forward(fe_ht); break; case ZEND_ITER_OBJECT: /* !iter happens from exception */ if (iter && iter->index++) { /* This could cause an endless loop if index becomes zero again. * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter TSRMLS_CC); } if (!iter || iter->funcs->valid(iter TSRMLS_CC) == FAILURE) { /* reached end of iteration */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } iter->funcs->get_current_data(iter, &value TSRMLS_CC); if (!value) { /* failure in get_current_data */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } if (use_key) { if (iter->funcs->get_current_key) { key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); } else { key_type = HASH_KEY_IS_LONG; int_key = iter->index; } } break; } if (opline->extended_value & ZEND_FE_FETCH_BYREF) { SEPARATE_ZVAL_IF_NOT_REF(value); (*value)->is_ref = 1; } if (!use_key) { if (opline->extended_value & ZEND_FE_FETCH_BYREF) { EX_T(opline->result.u.var).var.ptr_ptr = value; (*value)->refcount++; } else { zval *result = &EX_T(opline->result.u.var).tmp_var; *result = **value; zval_copy_ctor(result); } } else { zval *result = &EX_T(opline->result.u.var).tmp_var; (*value)->refcount++; array_init(result); zend_hash_index_update(result->value.ht, 0, value, sizeof(zval *), NULL); ALLOC_ZVAL(key); INIT_PZVAL(key); switch (key_type) { case HASH_KEY_IS_STRING: key->value.str.val = str_key; key->value.str.len = str_key_len-1; key->type = IS_STRING; break; case HASH_KEY_IS_LONG: key->value.lval = int_key; key->type = IS_LONG; break; EMPTY_SWITCH_DEFAULT_CASE() } zend_hash_index_update(result->value.ht, 1, &key, sizeof(zval *), NULL); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMP_NO_CTOR_SPEC() OPDEF(ZEND_JMP_NO_CTOR, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMP_NO_CTOR) ZEND_VM_HANDLER(ZEND_JMP_NO_CTOR) { zend_op *opline = EX(opline); zval *object_zval; zend_function *constructor; zend_free_op free_op1; if (OP1_TYPE == IS_VAR) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); } object_zval = GET_OP1_ZVAL_PTR(BP_VAR_R); constructor = Z_OBJ_HT_P(object_zval)->get_constructor(object_zval TSRMLS_CC); EX(fbc_constructor) = NULL; if (constructor == NULL) { if(opline->op1.u.EA.type & EXT_TYPE_UNUSED) { zval_ptr_dtor(EX_T(opline->op1.u.var).var.ptr_ptr); } ZEND_VM_SET_OPCODE(EX(op_array)->opcodes + opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } else { EX(fbc_constructor) = constructor; } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ISSET_ISEMPTY_VAR_SPEC() OPDEF(ZEND_ISSET_ISEMPTY_VAR, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_ISSET_ISEMPTY_VAR) ZEND_VM_HANDLER(ZEND_ISSET_ISEMPTY_VAR) { zend_op *opline = EX(opline); zend_free_op free_op1; zval tmp, *varname = GET_OP1_ZVAL_PTR(BP_VAR_R); zval **value; zend_bool isset = 1; HashTable *target_symbol_table; if (varname->type != IS_STRING) { tmp = *varname; zval_copy_ctor(&tmp); convert_to_string(&tmp); varname = &tmp; } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { value = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 1 TSRMLS_CC); if (!value) { isset = 0; } } else { target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &value) == FAILURE) { isset = 0; } } EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; switch (opline->extended_value) { case ZEND_ISSET: if (isset && Z_TYPE_PP(value) == IS_NULL) { EX_T(opline->result.u.var).tmp_var.value.lval = 0; } else { EX_T(opline->result.u.var).tmp_var.value.lval = isset; } break; case ZEND_ISEMPTY: if (!isset || !i_zend_is_true(*value)) { EX_T(opline->result.u.var).tmp_var.value.lval = 1; } else { EX_T(opline->result.u.var).tmp_var.value.lval = 0; } break; } if (varname == &tmp) { zval_dtor(&tmp); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, int prop_dim) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R); zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); zval **value = NULL; int result = 0; long index; if (container) { if ((*container)->type == IS_ARRAY) { HashTable *ht; int isset = 0; ht = (*container)->value.ht; switch (offset->type) { case IS_DOUBLE: case IS_RESOURCE: case IS_BOOL: case IS_LONG: if (offset->type == IS_DOUBLE) { index = (long) offset->value.dval; } else { index = offset->value.lval; } if (zend_hash_index_find(ht, index, (void **) &value) == SUCCESS) { isset = 1; } break; case IS_STRING: if (zend_symtable_find(ht, offset->value.str.val, offset->value.str.len+1, (void **) &value) == SUCCESS) { isset = 1; } break; case IS_NULL: if (zend_hash_find(ht, "", sizeof(""), (void **) &value) == SUCCESS) { isset = 1; } break; default: zend_error(E_WARNING, "Illegal offset type in unset"); break; } switch (opline->extended_value) { case ZEND_ISSET: if (isset && Z_TYPE_PP(value) == IS_NULL) { result = 0; } else { result = isset; } break; case ZEND_ISEMPTY: if (!isset || !i_zend_is_true(*value)) { result = 0; } else { result = 1; } break; } } else if ((*container)->type == IS_OBJECT) { if (prop_dim) { result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); } else { result = Z_OBJ_HT_P(*container)->has_dimension(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); } } else if ((*container)->type == IS_STRING) { /* string offsets */ switch (opline->extended_value) { case ZEND_ISSET: if (offset->value.lval < Z_STRLEN_PP(container)) { result = 1; } break; case ZEND_ISEMPTY: if (offset->value.lval < Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] != '0') { result = 1; } break; } } } EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; switch (opline->extended_value) { case ZEND_ISSET: EX_T(opline->result.u.var).tmp_var.value.lval = result; break; case ZEND_ISEMPTY: EX_T(opline->result.u.var).tmp_var.value.lval = !result; break; } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC() OPDEF(ZEND_ISSET_ISEMPTY_DIM_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ISSET_ISEMPTY_DIM_OBJ) ZEND_VM_HANDLER(ZEND_ISSET_ISEMPTY_DIM_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, prop_dim, 0); } #endif #define ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC() OPDEF(ZEND_ISSET_ISEMPTY_PROP_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ISSET_ISEMPTY_PROP_OBJ) ZEND_VM_HANDLER(ZEND_ISSET_ISEMPTY_PROP_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, prop_dim, 1); } #endif #define ZEND_EXIT_SPEC() OPDEF(ZEND_EXIT, M_CONST_TMP_VAR_UNUSED, M_ANY) #if HAVE_OP(ZEND_EXIT) ZEND_VM_HANDLER(ZEND_EXIT) { zend_op *opline = EX(opline); if (OP1_TYPE != IS_UNUSED) { zval *ptr; zend_free_op free_op1; ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); } else { zend_print_variable(ptr); } FREE_OP1(); } zend_bailout(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BEGIN_SILENCE_SPEC() OPDEF(ZEND_BEGIN_SILENCE, M_ANY, M_ANY) #if HAVE_OP(ZEND_BEGIN_SILENCE) ZEND_VM_HANDLER(ZEND_BEGIN_SILENCE) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_RAISE_ABSTRACT_ERROR_SPEC() OPDEF(ZEND_RAISE_ABSTRACT_ERROR, M_ANY, M_ANY) #if HAVE_OP(ZEND_RAISE_ABSTRACT_ERROR) ZEND_VM_HANDLER(ZEND_RAISE_ABSTRACT_ERROR) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EG(scope)->name, EX(op_array)->function_name); ZEND_VM_NEXT_OPCODE(); /* Never reached */ } #endif #define ZEND_END_SILENCE_SPEC() OPDEF(ZEND_END_SILENCE, M_TMP, M_ANY) #if HAVE_OP(ZEND_END_SILENCE) ZEND_VM_HANDLER(ZEND_END_SILENCE) { zend_op *opline = EX(opline); zval restored_error_reporting; if (!EG(error_reporting)) { restored_error_reporting.type = IS_LONG; restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; convert_to_string(&restored_error_reporting); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zendi_zval_dtor(restored_error_reporting); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_QM_ASSIGN_SPEC() OPDEF(ZEND_QM_ASSIGN, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_QM_ASSIGN) ZEND_VM_HANDLER(ZEND_QM_ASSIGN) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *value = GET_OP1_ZVAL_PTR(BP_VAR_R); EX_T(opline->result.u.var).tmp_var = *value; if (!IS_OP1_TMP_FREE()) { zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_STMT_SPEC() OPDEF(ZEND_EXT_STMT, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_STMT) ZEND_VM_HANDLER(ZEND_EXT_STMT) { if (!EG(no_extensions)) { zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_statement_handler, EX(op_array) TSRMLS_CC); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_FCALL_BEGIN_SPEC() OPDEF(ZEND_EXT_FCALL_BEGIN, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_FCALL_BEGIN) ZEND_VM_HANDLER(ZEND_EXT_FCALL_BEGIN) { if (!EG(no_extensions)) { zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_begin_handler, EX(op_array) TSRMLS_CC); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_FCALL_END_SPEC() OPDEF(ZEND_EXT_FCALL_END, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_FCALL_END) ZEND_VM_HANDLER(ZEND_EXT_FCALL_END) { if (!EG(no_extensions)) { zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_end_handler, EX(op_array) TSRMLS_CC); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DECLARE_CLASS_SPEC() OPDEF(ZEND_DECLARE_CLASS, M_ANY, M_ANY) #if HAVE_OP(ZEND_DECLARE_CLASS) ZEND_VM_HANDLER(ZEND_DECLARE_CLASS) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).class_entry = do_bind_class(opline, EG(class_table), 0 TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DECLARE_INHERITED_CLASS_SPEC() OPDEF(ZEND_DECLARE_INHERITED_CLASS, M_ANY, M_ANY) #if HAVE_OP(ZEND_DECLARE_INHERITED_CLASS) ZEND_VM_HANDLER(ZEND_DECLARE_INHERITED_CLASS) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).class_entry = do_bind_inherited_class(opline, EG(class_table), EX_T(opline->extended_value).class_entry, 0 TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DECLARE_FUNCTION_SPEC() OPDEF(ZEND_DECLARE_FUNCTION, M_ANY, M_ANY) #if HAVE_OP(ZEND_DECLARE_FUNCTION) ZEND_VM_HANDLER(ZEND_DECLARE_FUNCTION) { do_bind_function(EX(opline), EG(function_table), 0); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_TICKS_SPEC() OPDEF(ZEND_TICKS, M_CONST, M_ANY) #if HAVE_OP(ZEND_TICKS) ZEND_VM_HANDLER(ZEND_TICKS) { zend_op *opline = EX(opline); if (++EG(ticks_count)>=opline->op1.u.constant.value.lval) { EG(ticks_count)=0; if (zend_ticks_function) { zend_ticks_function(opline->op1.u.constant.value.lval); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INSTANCEOF_SPEC() OPDEF(ZEND_INSTANCEOF, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_INSTANCEOF) ZEND_VM_HANDLER(ZEND_INSTANCEOF) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *expr = GET_OP1_ZVAL_PTR(BP_VAR_R); zend_bool result; if (Z_TYPE_P(expr) == IS_OBJECT) { result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.u.var).class_entry TSRMLS_CC); } else { result = 0; } ZVAL_BOOL(&EX_T(opline->result.u.var).tmp_var, result); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_NOP_SPEC() OPDEF(ZEND_EXT_NOP, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_NOP) ZEND_VM_HANDLER(ZEND_EXT_NOP) { ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_NOP_SPEC() OPDEF(ZEND_NOP, M_ANY, M_ANY) #if HAVE_OP(ZEND_NOP) ZEND_VM_HANDLER(ZEND_NOP) { ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_INTERFACE_SPEC() OPDEF(ZEND_ADD_INTERFACE, M_ANY, M_ANY) #if HAVE_OP(ZEND_ADD_INTERFACE) ZEND_VM_HANDLER(ZEND_ADD_INTERFACE) { zend_op *opline = EX(opline); zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry; zend_class_entry *iface = EX_T(opline->op2.u.var).class_entry; if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) { zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name); } ce->interfaces[opline->extended_value] = iface; zend_do_implement_interface(ce, iface TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_HANDLE_EXCEPTION_SPEC() OPDEF(ZEND_HANDLE_EXCEPTION, M_ANY, M_ANY) #if HAVE_OP(ZEND_HANDLE_EXCEPTION) ZEND_VM_HANDLER(ZEND_HANDLE_EXCEPTION) { zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes; int i; int encapsulating_block=-1; zval **stack_zval_pp; stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; while (*stack_zval_pp != NULL) { zval_ptr_dtor(stack_zval_pp); EG(argument_stack).top_element--; stack_zval_pp--; } for (i=0; i<EG(active_op_array)->last_try_catch; i++) { if (EG(active_op_array)->try_catch_array[i].try_op > op_num) { /* further blocks will not be relevant... */ break; } if (op_num >= EG(active_op_array)->try_catch_array[i].try_op && op_num < EG(active_op_array)->try_catch_array[i].catch_op) { encapsulating_block = i; } } if (encapsulating_block == -1) { ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } else { ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[EG(active_op_array)->try_catch_array[encapsulating_block].catch_op]); ZEND_VM_CONTINUE(); } } #endif #define ZEND_VERIFY_ABSTRACT_CLASS_SPEC() OPDEF(ZEND_VERIFY_ABSTRACT_CLASS, M_ANY, M_ANY) #if HAVE_OP(ZEND_VERIFY_ABSTRACT_CLASS) ZEND_VM_HANDLER(ZEND_VERIFY_ABSTRACT_CLASS) { zend_verify_abstract_class(EX_T(EX(opline)->op1.u.var).class_entry TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif http://cvs.php.net/co.php/ZendEngine2/zend_vm_spec.h?r=1.1&p=1 Index: ZendEngine2/zend_vm_spec.h +++ ZendEngine2/zend_vm_spec.h /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ | Copyright (c) 1998-2004 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 | | 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 | | obtain it through the world-wide-web, please send a note to | | license@zend.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ /* $Id: zend_vm_spec.h,v 1.1 2004/09/08 22:14:12 andi Exp $ */ /* Don't edit this file. It produces the specialized version of executor's opcode handlers and helpers, those are defined in zend_vm_handlers.h */ #define IS_ANY (1<<7) #define _ANY_CODE 0 #define SPEC2(X,Y) SPEC_##X##Y #define SPEC(X,Y) SPEC2(X,Y) #define SPEC2_0(X,Y) SPEC_##X##Y() #define SPEC_0(X,Y) SPEC2_0(X,Y) #define SPEC2_1(X,Y,Z) SPEC_##X##Y(Z) #define SPEC_1(X,Y,Z) SPEC2_1(X,Y,Z) #define OP1_TYPE \ SPEC(OP1_TYPE, OP1_TYPE_PREFIX) #define OP1_TYPE_CODE \ SPEC(OP1_TYPE_PREFIX, _CODE) #define GET_OP1_ZVAL_PTR(T) \ SPEC_1(GET_OP1_ZVAL_PTR, OP1_TYPE_PREFIX, T) #define GET_OP1_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP1_ZVAL_PTR_PTR, OP1_TYPE_PREFIX, T) #define GET_OP1_OBJ_ZVAL_PTR(T) \ SPEC_1(GET_OP1_OBJ_ZVAL_PTR, OP1_TYPE_PREFIX, T) #define GET_OP1_OBJ_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP1_OBJ_ZVAL_PTR_PTR, OP1_TYPE_PREFIX, T) #define IS_OP1_TMP_FREE() \ SPEC_0(IS_OP1_TMP_FREE, OP1_TYPE_PREFIX) #define FREE_OP1() \ SPEC_0(FREE_OP1, OP1_TYPE_PREFIX) #define FREE_OP1_IF_VAR() \ SPEC_0(FREE_OP1_IF_VAR, OP1_TYPE_PREFIX) #define FREE_OP1_VAR_PTR() \ SPEC_0(FREE_OP1_VAR_PTR, OP1_TYPE_PREFIX) #define OP2_TYPE \ SPEC(OP2_TYPE, OP2_TYPE_PREFIX) #define OP2_TYPE_CODE \ SPEC(OP2_TYPE_PREFIX, _CODE) #define GET_OP2_ZVAL_PTR(T) \ SPEC_1(GET_OP2_ZVAL_PTR, OP2_TYPE_PREFIX, T) #define GET_OP2_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP2_ZVAL_PTR_PTR, OP2_TYPE_PREFIX, T) #define GET_OP2_OBJ_ZVAL_PTR(T) \ SPEC_1(GET_OP2_OBJ_ZVAL_PTR, OP2_TYPE_PREFIX, T) #define GET_OP2_OBJ_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP2_OBJ_ZVAL_PTR_PTR, OP2_TYPE_PREFIX, T) #define IS_OP2_TMP_FREE() \ SPEC_0(IS_OP2_TMP_FREE, OP2_TYPE_PREFIX) #define FREE_OP2() \ SPEC_0(FREE_OP2, OP2_TYPE_PREFIX) #define FREE_OP2_IF_VAR() \ SPEC_0(FREE_OP2_IF_VAR, OP2_TYPE_PREFIX) #define FREE_OP2_VAR_PTR() \ SPEC_0(FREE_OP2_VAR_PTR, OP2_TYPE_PREFIX) #define SPEC__ANY_CODE _ANY_CODE #define SPEC__CONST_CODE _CONST_CODE #define SPEC__TMP_CODE _TMP_CODE #define SPEC__VAR_CODE _VAR_CODE #define SPEC__UNUSED_CODE _UNUSED_CODE #define SPEC_OP1_TYPE_ANY opline->op1.op_type #define SPEC_OP1_TYPE_CONST IS_CONST #define SPEC_OP1_TYPE_TMP IS_TMP_VAR #define SPEC_OP1_TYPE_VAR IS_VAR #define SPEC_OP1_TYPE_UNUSED IS_UNUSED #define SPEC_GET_OP1_ZVAL_PTR_ANY(T) _get_zval_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_CONST(T) _get_zval_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_TMP(T) _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_VAR(T) _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_UNUSED(T) _get_zval_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_ANY(T) _get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_CONST(T) _get_zval_ptr_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_TMP(T) _get_zval_ptr_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_VAR(T) _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_UNUSED(T) _get_zval_ptr_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_ANY(T) _get_obj_zval_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_CONST(T) _get_obj_zval_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_TMP(T) _get_obj_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_VAR(T) _get_obj_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_UNUSED(T) _get_obj_zval_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_ANY(T) _get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_CONST(T) _get_obj_zval_ptr_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_TMP(T) _get_obj_zval_ptr_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_VAR(T) _get_obj_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_UNUSED(T) _get_obj_zval_ptr_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_IS_OP1_TMP_FREE_ANY() IS_TMP_FREE(free_op1) #define SPEC_IS_OP1_TMP_FREE_CONST() 0 #define SPEC_IS_OP1_TMP_FREE_TMP() 1 #define SPEC_IS_OP1_TMP_FREE_VAR() IS_TMP_FREE(free_op1) #define SPEC_IS_OP1_TMP_FREE_UNUSED() 0 #define SPEC_FREE_OP1_ANY() FREE_OP(free_op1); #define SPEC_FREE_OP1_CONST() #define SPEC_FREE_OP1_TMP() zval_dtor(free_op1.var) #define SPEC_FREE_OP1_VAR() FREE_OP(free_op1); #define SPEC_FREE_OP1_UNUSED() #define SPEC_FREE_OP1_IF_VAR_ANY() FREE_OP_IF_VAR(free_op1); #define SPEC_FREE_OP1_IF_VAR_CONST() #define SPEC_FREE_OP1_IF_VAR_TMP() #define SPEC_FREE_OP1_IF_VAR_VAR() FREE_OP_IF_VAR(free_op1); #define SPEC_FREE_OP1_IF_VAR_UNUSED() #define SPEC_FREE_OP1_VAR_PTR_ANY() FREE_OP_VAR_PTR(free_op1); #define SPEC_FREE_OP1_VAR_PTR_CONST() #define SPEC_FREE_OP1_VAR_PTR_TMP() #define SPEC_FREE_OP1_VAR_PTR_VAR() FREE_OP_VAR_PTR(free_op1); #define SPEC_FREE_OP1_VAR_PTR_UNUSED() #define SPEC_OP2_TYPE_ANY opline->op2.op_type #define SPEC_OP2_TYPE_CONST IS_CONST #define SPEC_OP2_TYPE_TMP IS_TMP_VAR #define SPEC_OP2_TYPE_VAR IS_VAR #define SPEC_OP2_TYPE_UNUSED IS_UNUSED #define SPEC_GET_OP2_ZVAL_PTR_ANY(T) _get_zval_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_CONST(T) _get_zval_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_TMP(T) _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_VAR(T) _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_UNUSED(T) _get_zval_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_ANY(T) _get_zval_ptr_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_CONST(T) _get_zval_ptr_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_TMP(T) _get_zval_ptr_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_VAR(T) _get_zval_ptr_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_UNUSED(T) _get_zval_ptr_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_ANY(T) _get_obj_zval_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_CONST(T) _get_obj_zval_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_TMP(T) _get_obj_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_VAR(T) _get_obj_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_UNUSED(T) _get_obj_zval_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_ANY(T) _get_obj_zval_ptr_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_CONST(T) _get_obj_zval_ptr_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_TMP(T) _get_obj_zval_ptr_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_VAR(T) _get_obj_zval_ptr_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_UNUSED(T) _get_obj_zval_ptr_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_IS_OP2_TMP_FREE_ANY() IS_TMP_FREE(free_op2) #define SPEC_IS_OP2_TMP_FREE_CONST() 0 #define SPEC_IS_OP2_TMP_FREE_TMP() 1 #define SPEC_IS_OP2_TMP_FREE_VAR() IS_TMP_FREE(free_op2) #define SPEC_IS_OP2_TMP_FREE_UNUSED() 0 #define SPEC_FREE_OP2_ANY() FREE_OP(free_op2); #define SPEC_FREE_OP2_CONST() #define SPEC_FREE_OP2_TMP() zval_dtor(free_op2.var) #define SPEC_FREE_OP2_VAR() FREE_OP(free_op2); #define SPEC_FREE_OP2_UNUSED() #define SPEC_FREE_OP2_IF_VAR_ANY() FREE_OP_IF_VAR(free_op2); #define SPEC_FREE_OP2_IF_VAR_CONST() #define SPEC_FREE_OP2_IF_VAR_TMP() #define SPEC_FREE_OP2_IF_VAR_VAR() FREE_OP_IF_VAR(free_op2); #define SPEC_FREE_OP2_IF_VAR_UNUSED() #define SPEC_FREE_OP2_VAR_PTR_ANY() FREE_OP_VAR_PTR(free_op2); #define SPEC_FREE_OP2_VAR_PTR_CONST() #define SPEC_FREE_OP2_VAR_PTR_TMP() #define SPEC_FREE_OP2_VAR_PTR_VAR() FREE_OP_VAR_PTR(free_op2); #define SPEC_FREE_OP2_VAR_PTR_UNUSED() #ifndef ZEND_VM_SPEC # define OP1_OP2_MASK(OP1T, OP2T) 1 # define HAVE_OP(OP) 1 # define ZEND_VM_C_GOTO(LABEL) goto LABEL # define ZEND_VM_C_LABEL(LABEL) LABEL # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_ANY # include "zend_vm_handlers.h" #else # define M_ANY (IS_ANY) # define M_CONST (IS_CONST) # define M_TMP (IS_TMP_VAR) # define M_VAR (IS_VAR) # define M_UNUSED (IS_UNUSED) # define M_CONST_TMP (IS_CONST|IS_TMP_VAR) # define M_CONST_VAR (IS_CONST|IS_VAR) # define M_CONST_UNUSED (IS_CONST|IS_UNUSED) # define M_CONST_TMP_VAR (IS_CONST|IS_TMP_VAR|IS_VAR) # define M_CONST_TMP_UNUSED (IS_CONST|IS_TMP_VAR|IS_UNUSED) # define M_CONST_VAR_UNUSED (IS_CONST|IS_VAR|IS_UNUSED) # define M_CONST_TMP_VAR_UNUSED (IS_CONST|IS_TMP_VAR|IS_VAR|IS_UNUSED) # define M_TMP_VAR (IS_TMP_VAR|IS_VAR) # define M_TMP_UNUSED (IS_TMP_VAR|IS_UNUSED) # define M_TMP_VAR_UNUSED (IS_TMP_VAR|IS_VAR|IS_UNUSED) # define M_VAR_UNUSED (IS_VAR|IS_UNUSED) # define OP1_OP2_MASK(OP1T, OP2T) \ ((OP1 & (OP1T)) && (OP2 & (OP2T))) # define OPDEF(OP,OP1M,OP2M) \ ((OP1 & (OP1M)) && (OP2 & (OP2M))) # define HAVE_OP(OP) \ OP##_SPEC() # define ZEND_VM_SPEC_C_GOTO2(LABEL, OP1T, OP2T) \ goto LABEL##OP1T##OP2T # define ZEND_VM_SPEC_C_GOTO1(LABEL, OP1T, OP2T) \ ZEND_VM_SPEC_C_GOTO2(LABEL, OP1T, OP2T) # define ZEND_VM_C_GOTO(LABEL) \ ZEND_VM_SPEC_C_GOTO1(LABEL, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_C_LABEL2(LABEL, OP1T, OP2T) \ LABEL##OP1T##OP2T # define ZEND_VM_SPEC_C_LABEL1(LABEL, OP1T, OP2T) \ ZEND_VM_SPEC_C_LABEL2(LABEL, OP1T, OP2T) # define ZEND_VM_C_LABEL(LABEL) \ ZEND_VM_SPEC_C_LABEL1(LABEL, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_HANDLER2(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER(OP##OP1T##OP2T, CODE) # define ZEND_VM_SPEC_HANDLER1(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER2(OP, OP1T, OP2T, CODE) # undef ZEND_VM_HANDLER # define ZEND_VM_HANDLER(OP) \ ZEND_VM_SPEC_HANDLER1(OP##_SPEC, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, ZEND_VM_CODE(OP,OP1_TYPE_CODE,OP2_TYPE_CODE)) # define ZEND_VM_SPEC_HANDLER_EX2(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER_EX(OP##OP1T##OP2T, CODE) # define ZEND_VM_SPEC_HANDLER_EX1(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER_EX2(OP, OP1T, OP2T, CODE) # undef ZEND_VM_HANDLER_EX # define ZEND_VM_HANDLER_EX(OP) \ ZEND_VM_SPEC_HANDLER_EX1(OP##_SPEC, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, ZEND_VM_CODE(OP,OP1_TYPE_CODE,OP2_TYPE_CODE)) # define ZEND_VM_SPEC_HELPER2(OP, OP1T, OP2T) \ ZEND_VM_SPEC_HELPER(OP##OP1T##OP2T) # define ZEND_VM_SPEC_HELPER1(OP, OP1T, OP2T) \ ZEND_VM_SPEC_HELPER2(OP, OP1T, OP2T) # undef ZEND_VM_HELPER # define ZEND_VM_HELPER(OP) \ ZEND_VM_SPEC_HELPER1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_HELPER_EX2(OP, OP1T, OP2T, PARAM) \ ZEND_VM_SPEC_HELPER_EX(OP##OP1T##OP2T, PARAM) # define ZEND_VM_SPEC_HELPER_EX1(OP, OP1T, OP2T, PARAM) \ ZEND_VM_SPEC_HELPER_EX2(OP, OP1T, OP2T, PARAM) # undef ZEND_VM_HELPER_EX # define ZEND_VM_HELPER_EX(OP, PARAM) \ ZEND_VM_SPEC_HELPER_EX1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, PARAM) # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER2(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP##OP1T##OP2T) # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER1(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HANDLER2(OP, OP1T, OP2T) # undef ZEND_VM_DISPATCH_TO_HANDLER # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ ZEND_VM_SPEC_DISPATCH_TO_HANDLER1(OP##_SPEC, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER2(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER(OP##OP1T##OP2T) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER1(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER2(OP, OP1T, OP2T) # undef ZEND_VM_DISPATCH_TO_HELPER # define ZEND_VM_DISPATCH_TO_HELPER(OP) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX2(OP, OP1T, OP2T, VAR, VAL) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(OP##OP1T##OP2T, VAR, VAL) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX1(OP, OP1T, OP2T, VAR, VAL) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX2(OP, OP1T, OP2T, VAR, VAL) # undef ZEND_VM_DISPATCH_TO_HELPER_EX # define ZEND_VM_DISPATCH_TO_HELPER_EX(OP, VAR, VAL) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, VAR, VAL) # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_VAR # include "zend_vm_handlers.h" /* LABELS */ # undef M_ANY # undef M_CONST # undef M_TMP # undef M_VAR # undef M_UNUSED # undef M_CONST_TMP # undef M_CONST_VAR # undef M_CONST_UNUSED # undef M_CONST_TMP_VAR # undef M_CONST_TMP_UNUSED # undef M_CONST_VAR_UNUSED # undef M_CONST_TMP_VAR_UNUSED # undef M_TMP_VAR # undef M_TMP_UNUSED # undef M_TMP_VAR_UNUSED # undef M_VAR_UNUSED # undef OPDEF # define OPDEF(OP, OP1M, OP2M) \ SPEC_LABELS1_##OP1M(OP##_SPEC, OP, OP2M) # define SPEC_LABELS1_M_ANY(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _ANY, _ANY, _ANY, _ANY) # define SPEC_LABELS1_M_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _NULL, _NULL, _UNUSED) # define SPEC_LABELS1_M_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _NULL, _VAR, _NULL) # define SPEC_LABELS1_M_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _NULL, _VAR, _UNUSED) # define SPEC_LABELS1_M_TMP(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _NULL, _NULL) # define SPEC_LABELS1_M_TMP_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _NULL, _UNUSED) # define SPEC_LABELS1_M_TMP_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _VAR, _NULL) # define SPEC_LABELS1_M_TMP_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _VAR, _UNUSED) # define SPEC_LABELS1_M_CONST(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _NULL, _NULL) # define SPEC_LABELS1_M_CONST_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _NULL, _UNUSED) # define SPEC_LABELS1_M_CONST_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _VAR, _NULL) # define SPEC_LABELS1_M_CONST_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _VAR, _UNUSED) # define SPEC_LABELS1_M_CONST_TMP(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _NULL, _NULL) # define SPEC_LABELS1_M_CONST_TMP_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _NULL, _UNUSED) # define SPEC_LABELS1_M_CONST_TMP_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _VAR, _NULL) # define SPEC_LABELS1_M_CONST_TMP_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _VAR, _UNUSED) # define SPEC_LABELS2_M_ANY(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _ANY, _ANY, _ANY, _ANY) # define SPEC_LABELS2_M_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _NULL, _NULL, _UNUSED) # define SPEC_LABELS2_M_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _NULL, _VAR, _NULL) # define SPEC_LABELS2_M_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _NULL, _VAR, _UNUSED) # define SPEC_LABELS2_M_TMP(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _NULL, _NULL) # define SPEC_LABELS2_M_TMP_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _NULL, _UNUSED) # define SPEC_LABELS2_M_TMP_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _VAR, _NULL) # define SPEC_LABELS2_M_TMP_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _VAR, _UNUSED) # define SPEC_LABELS2_M_CONST(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _NULL, _NULL) # define SPEC_LABELS2_M_CONST_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _NULL, _UNUSED) # define SPEC_LABELS2_M_CONST_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _VAR, _NULL) # define SPEC_LABELS2_M_CONST_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _VAR, _UNUSED) # define SPEC_LABELS2_M_CONST_TMP(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _NULL, _NULL) # define SPEC_LABELS2_M_CONST_TMP_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _NULL, _UNUSED) # define SPEC_LABELS2_M_CONST_TMP_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _VAR, _NULL) # define SPEC_LABELS2_M_CONST_TMP_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _VAR, _UNUSED) # define LABELS_1(OP,CODE,OP1,OP2C,OP2T,OP2V,OP2U) \ OP1##OP2C(OP,CODE), \ OP1##OP2T(OP,CODE), \ OP1##OP2V(OP,CODE), \ OP1##OP2U(OP,CODE) # define SPEC_LABELS(OP,CODE,OP1C,OP1T,OP1V,OP1U,OP2C,OP2T,OP2V,OP2U) \ LABELS_1(OP,CODE,SPEC_LABEL##OP1C,OP2C,OP2T,OP2V,OP2U), \ LABELS_1(OP,CODE,SPEC_LABEL##OP1T,OP2C,OP2T,OP2V,OP2U), \ LABELS_1(OP,CODE,SPEC_LABEL##OP1V,OP2C,OP2T,OP2V,OP2U), \ LABELS_1(OP,CODE,SPEC_LABEL##OP1U,OP2C,OP2T,OP2V,OP2U) # define SPEC_LABEL_CONST_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_TMP_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_VAR_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_UNUSED_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_ANY_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_CONST(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_TMP(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_VAR(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_UNUSED(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_ANY(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_ANY_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_ANY, ZEND_VM_CODE(CODE, _ANY_CODE, _ANY_CODE)) # define SPEC_LABEL_ANY_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_CONST, ZEND_VM_CODE(CODE, _ANY_CODE, _CONST_CODE)) # define SPEC_LABEL_ANY_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_TMP, ZEND_VM_CODE(CODE, _ANY_CODE, _TMP_CODE)) # define SPEC_LABEL_ANY_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_VAR, ZEND_VM_CODE(CODE, _ANY_CODE, _VAR_CODE)) # define SPEC_LABEL_ANY_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_UNUSED, ZEND_VM_CODE(CODE, _ANY_CODE, _UNUSED_CODE)) # define SPEC_LABEL_CONST_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_ANY, ZEND_VM_CODE(CODE, _CONST_CODE, _ANY_CODE)) # define SPEC_LABEL_CONST_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_CONST, ZEND_VM_CODE(CODE, _CONST_CODE, _CONST_CODE)) # define SPEC_LABEL_CONST_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_TMP, ZEND_VM_CODE(CODE, _CONST_CODE, _TMP_CODE)) # define SPEC_LABEL_CONST_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_VAR, ZEND_VM_CODE(CODE, _CONST_CODE, _VAR_CODE)) # define SPEC_LABEL_CONST_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_UNUSED, ZEND_VM_CODE(CODE, _CONST_CODE, _UNUSED_CODE)) # define SPEC_LABEL_TMP_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_ANY, ZEND_VM_CODE(CODE, _TMP_CODE, _ANY_CODE)) # define SPEC_LABEL_TMP_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_CONST, ZEND_VM_CODE(CODE, _TMP_CODE, _CONST_CODE)) # define SPEC_LABEL_TMP_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_TMP, ZEND_VM_CODE(CODE, _TMP_CODE, _TMP_CODE)) # define SPEC_LABEL_TMP_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_VAR, ZEND_VM_CODE(CODE, _TMP_CODE, _VAR_CODE)) # define SPEC_LABEL_TMP_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_UNUSED, ZEND_VM_CODE(CODE, _TMP_CODE, _UNUSED_CODE)) # define SPEC_LABEL_VAR_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_ANY, ZEND_VM_CODE(CODE, _VAR_CODE, _ANY_CODE)) # define SPEC_LABEL_VAR_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_CONST, ZEND_VM_CODE(CODE, _VAR_CODE, _CONST_CODE)) # define SPEC_LABEL_VAR_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_TMP, ZEND_VM_CODE(CODE, _VAR_CODE, _TMP_CODE)) # define SPEC_LABEL_VAR_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_VAR, ZEND_VM_CODE(CODE, _VAR_CODE, _VAR_CODE)) # define SPEC_LABEL_VAR_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_UNUSED, ZEND_VM_CODE(CODE, _VAR_CODE, _UNUSED_CODE)) # define SPEC_LABEL_UNUSED_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_ANY, ZEND_VM_CODE(CODE, _UNUSED_CODE, _ANY_CODE)) # define SPEC_LABEL_UNUSED_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_CONST, ZEND_VM_CODE(CODE, _UNUSED_CODE, _CONST_CODE)) # define SPEC_LABEL_UNUSED_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_TMP, ZEND_VM_CODE(CODE, _UNUSED_CODE, _TMP_CODE)) # define SPEC_LABEL_UNUSED_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_VAR, ZEND_VM_CODE(CODE, _UNUSED_CODE, _VAR_CODE)) # define SPEC_LABEL_UNUSED_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_UNUSED, ZEND_VM_CODE(CODE, _UNUSED_CODE, _UNUSED_CODE)) # undef ZEND_VM_NULL_LABEL # define ZEND_VM_NULL_LABEL \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL # undef ZEND_VM_LABEL # define ZEND_VM_LABEL(OP) \ OP##_SPEC() #endif ZEND_VM_NULL_HANDLER() { zend_error_noreturn(E_ERROR, "Invalid opcode %d/%d/%d.", EX(opline)->opcode, EX(opline)->op1.op_type, EX(opline)->op2.op_type); ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); }
http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.289&r2=1.290&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.289 ZendEngine2/zend_compile.h:1.290 --- ZendEngine2/zend_compile.h:1.289 Thu Aug 19 16:03:06 2004 +++ ZendEngine2/zend_compile.h Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.289 2004/08/19 20:03:06 andi Exp $ */ +/* $Id: zend_compile.h,v 1.290 2004/09/08 22:14:12 andi Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -72,7 +72,7 @@ typedef int (*opcode_handler_t) (ZEND_OPCODE_HANDLER_ARGS); -extern ZEND_API opcode_handler_t zend_opcode_handlers[512]; +extern ZEND_API opcode_handler_t *zend_opcode_handlers; struct _zend_op { opcode_handler_t handler; http://cvs.php.net/diff.php/ZendEngine2/zend_exceptions.c?r1=1.70&r2=1.71&ty=u Index: ZendEngine2/zend_exceptions.c diff -u ZendEngine2/zend_exceptions.c:1.70 ZendEngine2/zend_exceptions.c:1.71 --- ZendEngine2/zend_exceptions.c:1.70 Tue Jul 27 12:21:56 2004 +++ ZendEngine2/zend_exceptions.c Wed Sep 8 18:14:12 2004 @@ -19,7 +19,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_exceptions.c,v 1.70 2004/07/27 16:21:56 helly Exp $ */ +/* $Id: zend_exceptions.c,v 1.71 2004/09/08 22:14:12 andi Exp $ */ #include "zend.h" #include "zend_API.h" @@ -175,7 +175,7 @@ if (argc >= 4) { zend_update_property_string(default_exception_ce, object, "file", sizeof("file")-1, filename TSRMLS_CC); if (argc < 5) { - lineno = 0; // invalidate lineno + lineno = 0; /* invalidate lineno */ } zend_update_property_long(default_exception_ce, object, "line", sizeof("line")-1, lineno TSRMLS_CC); } http://cvs.php.net/diff.php/ZendEngine2/zend_execute.c?r1=1.671&r2=1.672&ty=u Index: ZendEngine2/zend_execute.c diff -u ZendEngine2/zend_execute.c:1.671 ZendEngine2/zend_execute.c:1.672 --- ZendEngine2/zend_execute.c:1.671 Mon Aug 30 04:57:40 2004 +++ ZendEngine2/zend_execute.c Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.c,v 1.671 2004/08/30 08:57:40 stas Exp $ */ +/* $Id: zend_execute.c,v 1.672 2004/09/08 22:14:12 andi Exp $ */ #define ZEND_INTENSIVE_DEBUGGING 0 @@ -34,6 +34,9 @@ #include "zend_fast_cache.h" #include "zend_ini.h" #include "zend_exceptions.h" +#include "zend_vm.h" + +typedef int (*incdec_t)(zval *); #define get_zval_ptr(node, Ts, should_free, type) _get_zval_ptr(node, Ts, should_free TSRMLS_CC) #define get_zval_ptr_ptr(node, Ts, should_free, type) _get_zval_ptr_ptr(node, Ts, should_free TSRMLS_CC) @@ -41,10 +44,6 @@ #define get_obj_zval_ptr_ptr(node, Ts, should_free, type) _get_obj_zval_ptr_ptr(node, Ts, should_free TSRMLS_CC) /* Prototypes */ -static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type TSRMLS_DC); -static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC); -static void zend_fetch_property_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC); -static void zend_fetch_dimension_address_from_tmp_var(znode *result, znode *op1, znode *op2, temp_variable *Ts TSRMLS_DC); static void zend_extension_statement_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_fcall_begin_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC); static void zend_extension_fcall_end_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC); @@ -59,7 +58,7 @@ /* former zend_execute_locks.h */ typedef struct _zend_free_op { zval* var; - int is_var; +/* int is_var; */ } zend_free_op; static inline void zend_pzval_unlock_func(zval *z, zend_free_op *should_free) @@ -68,7 +67,7 @@ z->refcount = 1; z->is_ref = 0; should_free->var = z; - should_free->is_var = 1; +/* should_free->is_var = 1; */ } else { should_free->var = 0; } @@ -98,15 +97,15 @@ #define FREE_OP(should_free) \ if (should_free.var) { \ - if (!should_free.is_var) { \ - zval_dtor(should_free.var); \ + if ((long)should_free.var & 1L) { \ + zval_dtor((zval*)((long)should_free.var & ~1L)); \ } else { \ zval_ptr_dtor(&should_free.var); \ } \ } -#define FREE_OP_VAR(should_free) \ - if (should_free.var && should_free.is_var) { \ +#define FREE_OP_IF_VAR(should_free) \ + if (should_free.var != NULL && (((long)should_free.var & 1L) == 0)) { \ zval_ptr_dtor(&should_free.var); \ } @@ -115,20 +114,29 @@ zval_ptr_dtor(&should_free.var); \ } -#define IS_TMP_FREE(should_free) (should_free.var && !should_free.is_var) +#define TMP_FREE(z) (zval*)(((long)(z)) | 1L) + +#define IS_TMP_FREE(should_free) ((long)should_free.var & 1L) + +#define INIT_PZVAL_COPY(z,v) \ + (z)->value = (v)->value; \ + (z)->type = (v)->type; \ + (z)->refcount = 1; \ + (z)->is_ref = 0; /* End of zend_execute_locks.h */ static inline zval *_get_zval_ptr(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) { - should_free->is_var = 0; +/* should_free->is_var = 0; */ switch (node->op_type) { case IS_CONST: should_free->var = 0; return &node->u.constant; break; case IS_TMP_VAR: - return should_free->var = &T(node->u.var).tmp_var; + should_free->var = TMP_FREE(&T(node->u.var).tmp_var); + return &T(node->u.var).tmp_var; break; case IS_VAR: if (T(node->u.var).var.ptr) { @@ -139,7 +147,7 @@ zval *str = T->str_offset.str; /* string offset */ - should_free->var = &T(node->u.var).tmp_var; + should_free->var = TMP_FREE(&T(node->u.var).tmp_var); if (T->str_offset.str->type != IS_STRING || ((int)T->str_offset.offset<0) @@ -185,49 +193,131 @@ } } -static inline void zend_fetch_property_address_inner(zval *object, znode *op2, znode *result, temp_variable *Ts, int type TSRMLS_DC) +#ifdef ZEND_VM_SPEC + +static inline zval *_get_zval_ptr_const(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) { - zend_free_op free_op2; - zval *prop_ptr = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - zval tmp; + return &node->u.constant; +} +static inline zval *_get_zval_ptr_tmp(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return should_free->var = &T(node->u.var).tmp_var; +} - switch (op2->op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *prop_ptr; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - prop_ptr = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(prop_ptr); - break; - } +static inline zval *_get_zval_ptr_var(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (T(node->u.var).var.ptr) { + PZVAL_UNLOCK(T(node->u.var).var.ptr, should_free); + return T(node->u.var).var.ptr; + } else { + temp_variable *T = &T(node->u.var); + zval *str = T->str_offset.str; - if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **ptr_ptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, prop_ptr TSRMLS_CC); - if(NULL == ptr_ptr) { - zend_error(E_ERROR, "Cannot access undefined property %s::$%s for object with overloaded property access", Z_OBJCE_P(object)->name, Z_STRVAL_P(prop_ptr)); + /* string offset */ + should_free->var = TMP_FREE(&T(node->u.var).tmp_var); + + if (T->str_offset.str->type != IS_STRING + || ((int)T->str_offset.offset<0) + || (T->str_offset.str->value.str.len <= T->str_offset.offset)) { + zend_error(E_NOTICE, "Uninitialized string offset: %d", T->str_offset.offset); + T->tmp_var.value.str.val = STR_EMPTY_ALLOC(); + T->tmp_var.value.str.len = 0; + } else { + char c = str->value.str.val[T->str_offset.offset]; + + T->tmp_var.value.str.val = estrndup(&c, 1); + T->tmp_var.value.str.len = 1; } - T(result->u.var).var.ptr_ptr = ptr_ptr; - } else if (Z_OBJ_HT_P(object)->read_property) { - T(result->u.var).var.ptr = Z_OBJ_HT_P(object)->read_property(object, prop_ptr, BP_VAR_W TSRMLS_CC); - T(result->u.var).var.ptr_ptr = &T(result->u.var).var.ptr; + PZVAL_UNLOCK_FREE(str); + T->tmp_var.refcount=1; + T->tmp_var.is_ref=1; + T->tmp_var.type = IS_STRING; + return &T->tmp_var; + } +} + +static inline zval *_get_zval_ptr_unused(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval **_get_zval_ptr_ptr_const(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval **_get_zval_ptr_ptr_tmp(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval **_get_zval_ptr_ptr_var(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (T(node->u.var).var.ptr_ptr) { + PZVAL_UNLOCK(*T(node->u.var).var.ptr_ptr, should_free); } else { - zend_error(E_WARNING, "This object doesn't support property references"); - T(result->u.var).var.ptr_ptr = &EG(error_zval_ptr); + /* string offset */ + PZVAL_UNLOCK(T(node->u.var).str_offset.str, should_free); } - - if (prop_ptr == &tmp) { - zval_dtor(prop_ptr); + return T(node->u.var).var.ptr_ptr; +} + +static inline zval **_get_zval_ptr_ptr_unused(znode *node, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return NULL; +} + +static inline zval *_get_obj_zval_ptr_const(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_const(op, Ts, should_free TSRMLS_CC); +} + +static inline zval *_get_obj_zval_ptr_tmp(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_tmp(op, Ts, should_free TSRMLS_CC); +} + +static inline zval *_get_obj_zval_ptr_var(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_var(op, Ts, should_free TSRMLS_CC); +} + +static inline zval *_get_obj_zval_ptr_unused(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (EG(This)) { + return EG(This); + } else { + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); + return NULL; } - FREE_OP(free_op2); } +static inline zval **_get_obj_zval_ptr_ptr_const(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_ptr_const(op, Ts, should_free TSRMLS_CC); +} + +static inline zval **_get_obj_zval_ptr_ptr_tmp(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_ptr_tmp(op, Ts, should_free TSRMLS_CC); +} + +static inline zval **_get_obj_zval_ptr_ptr_var(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + return _get_zval_ptr_ptr_var(op, Ts, should_free TSRMLS_CC); +} +static inline zval **_get_obj_zval_ptr_ptr_unused(znode *op, temp_variable *Ts, zend_free_op *should_free TSRMLS_DC) +{ + if (EG(This)) { + return &EG(This); + } else { + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); + return NULL; + } +} +#endif static inline void zend_switch_free(zend_op *opline, temp_variable *Ts TSRMLS_DC) { @@ -253,13 +343,13 @@ } } -void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC) +static void zend_assign_to_variable_reference(zval **variable_ptr_ptr, zval **value_ptr_ptr TSRMLS_DC) { zval *variable_ptr; zval *value_ptr; if (!value_ptr_ptr || !variable_ptr_ptr) { - zend_error(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); + zend_error_noreturn(E_ERROR, "Cannot create references to/from string offsets nor overloaded objects"); return; } @@ -305,12 +395,6 @@ } (*variable_ptr_ptr)->is_ref = 1; } - - if (result && !RETURN_VALUE_UNUSED(result)) { - T(result->u.var).var.ptr_ptr = variable_ptr_ptr; - PZVAL_LOCK(*variable_ptr_ptr); - AI_USE_PTR(T(result->u.var).var); - } } static inline void make_real_object(zval **object_ptr TSRMLS_DC) @@ -336,7 +420,7 @@ should_free->var = 0; return &EG(This); } else { - zend_error(E_ERROR, "Using $this when not in object context"); + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); } } return _get_zval_ptr_ptr(op, Ts, should_free TSRMLS_CC); @@ -349,7 +433,7 @@ should_free->var = 0; return EG(This); } else { - zend_error(E_ERROR, "Using $this when not in object context"); + zend_error_noreturn(E_ERROR, "Using $this when not in object context"); } } return _get_zval_ptr(op, Ts, should_free TSRMLS_CC); @@ -369,12 +453,12 @@ if (cur_arg_info->class_name) { if (!arg) { - zend_error(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); + zend_error_noreturn(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); } switch (Z_TYPE_P(arg)) { case IS_NULL: if (!cur_arg_info->allow_null) { - zend_error(E_ERROR, "Argument %d must not be null", arg_num); + zend_error_noreturn(E_ERROR, "Argument %d must not be null", arg_num); } break; case IS_OBJECT: { @@ -387,17 +471,18 @@ } else { error_msg = "be an instance of"; } - zend_error(E_ERROR, "Argument %d must %s %s", arg_num, error_msg, ce->name); + zend_error_noreturn(E_ERROR, "Argument %d must %s %s", arg_num, error_msg, ce->name); } } break; default: - zend_error(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); + zend_error_noreturn(E_ERROR, "Argument %d must be an object of class %s", arg_num, cur_arg_info->class_name); break; } } } + static inline void zend_assign_to_object(znode *result, zval **object_ptr, znode *op2, znode *value_op, temp_variable *Ts, int opcode TSRMLS_DC) { zval *object; @@ -431,7 +516,7 @@ value->is_ref = 0; value->refcount = 0; if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(orig_value)->name); + zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(orig_value)->name); } zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(orig_value)->name); value->value.obj = Z_OBJ_HANDLER_P(orig_value, clone_obj)(orig_value TSRMLS_CC); @@ -478,7 +563,7 @@ } else { /* Note: property_name in this case is really the array index! */ if (!Z_OBJ_HT_P(object)->write_dimension) { - zend_error(E_ERROR, "Cannot use object as array"); + zend_error_noreturn(E_ERROR, "Cannot use object as array"); } Z_OBJ_HT_P(object)->write_dimension(object, property_name, value TSRMLS_CC); } @@ -490,7 +575,7 @@ PZVAL_LOCK(value); } zval_ptr_dtor(&value); - FREE_OP_VAR(free_value); + FREE_OP_IF_VAR(free_value); } @@ -529,7 +614,7 @@ if (value->type!=IS_STRING) { tmp = *value; - if (op2 && op2->op_type == IS_VAR) { + if (op2->op_type == IS_VAR) { zval_copy_ctor(&tmp); } convert_to_string(&tmp); @@ -538,28 +623,26 @@ T->str_offset.str->value.str.val[T->str_offset.offset] = final_value->value.str.val[0]; - if (op2) { - if (op2->op_type == IS_VAR) { - if (value == &T(op2->u.var).tmp_var) { - if (result->u.EA.type & EXT_TYPE_UNUSED) { - /* We are not going to use return value, drop it */ - STR_FREE(value->value.str.val); - } else { - /* We are going to use return value, make it real zval */ - ALLOC_ZVAL(value); - *value = T(op2->u.var).tmp_var; - value->is_ref = 0; - value->refcount = 0; /* LOCK will increase it */ - } - } - } else { - if (final_value == &T(op2->u.var).tmp_var) { - /* we can safely free final_value here - * because separation is done only - * in case op2->op_type == IS_VAR */ - STR_FREE(final_value->value.str.val); + if (op2->op_type == IS_VAR) { + if (value == &T(op2->u.var).tmp_var) { + if (result->u.EA.type & EXT_TYPE_UNUSED) { + /* We are not going to use return value, drop it */ + STR_FREE(value->value.str.val); + } else { + /* We are going to use return value, make it real zval */ + ALLOC_ZVAL(value); + *value = T(op2->u.var).tmp_var; + value->is_ref = 0; + value->refcount = 0; /* LOCK will increase it */ } } + } else { + if (final_value == &T(op2->u.var).tmp_var) { + /* we can safely free final_value here + * because separation is done only + * in case op2->op_type == IS_VAR */ + STR_FREE(final_value->value.str.val); + } } if (final_value == &tmp) { zval_dtor(final_value); @@ -605,7 +688,7 @@ if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) { if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(value)->name); + zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(value)->name); } else if (PZVAL_IS_REF(variable_ptr)) { if (variable_ptr != value) { zend_uint refcount = variable_ptr->refcount; @@ -724,6 +807,29 @@ } +static inline void zend_receive(zval **variable_ptr_ptr, zval *value TSRMLS_DC) +{ + zval *variable_ptr = *variable_ptr_ptr; + + if (EG(ze1_compatibility_mode) && Z_TYPE_P(value) == IS_OBJECT) { + if (Z_OBJ_HANDLER_P(value, clone_obj) == NULL) { + zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(value)->name); + } else { + variable_ptr->refcount--; + ALLOC_ZVAL(variable_ptr); + *variable_ptr_ptr = variable_ptr; + *variable_ptr = *value; + INIT_PZVAL(variable_ptr); + zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(value)->name); + variable_ptr->value.obj = Z_OBJ_HANDLER_P(value, clone_obj)(value TSRMLS_CC); + } + } else { + variable_ptr->refcount--; + *variable_ptr_ptr = value; + value->refcount++; + } +} + /* Utility Functions for Extensions */ static void zend_extension_statement_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) { @@ -749,12 +855,6 @@ } -static void print_refcount(zval *p, char *str) -{ - print_refcount(NULL, NULL); -} - - static inline HashTable *zend_get_target_symbol_table(zend_op *opline, temp_variable *Ts, int type, zval *variable TSRMLS_DC) { switch (opline->op2.u.EA.type) { @@ -776,81 +876,8 @@ return NULL; } - -static void zend_fetch_var_address(zend_op *opline, temp_variable *Ts, int type TSRMLS_DC) -{ - zend_free_op free_op1; - zval *varname = get_zval_ptr(&opline->op1, Ts, &free_op1, BP_VAR_R); - zval **retval; - zval tmp_varname; - HashTable *target_symbol_table; - zend_bool free_tmp = 0; - - if (varname->type != IS_STRING) { - tmp_varname = *varname; - zval_copy_ctor(&tmp_varname); - convert_to_string(&tmp_varname); - varname = &tmp_varname; - free_tmp = 1; - } - - if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { - target_symbol_table = NULL; - retval = zend_std_get_static_property(T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 0 TSRMLS_CC); - } else { - if (opline->op2.u.EA.type == ZEND_FETCH_GLOBAL && opline->op1.op_type == IS_VAR) { - varname->refcount++; - } - target_symbol_table = zend_get_target_symbol_table(opline, Ts, type, varname TSRMLS_CC); - if (!target_symbol_table) { - return; - } - if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &retval) == FAILURE) { - switch (type) { - case BP_VAR_R: - zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); - /* break missing intentionally */ - case BP_VAR_IS: - retval = &EG(uninitialized_zval_ptr); - break; - case BP_VAR_RW: - zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); - /* break missing intentionally */ - case BP_VAR_W: { - zval *new_zval = &EG(uninitialized_zval); - - new_zval->refcount++; - zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); - } - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - } - switch (opline->op2.u.EA.type) { - case ZEND_FETCH_LOCAL: - FREE_OP(free_op1); - break; - case ZEND_FETCH_STATIC: - zval_update_constant(retval, (void*) 1 TSRMLS_CC); - break; - } - } - - - if (free_tmp) { - zval_dtor(varname); - } - if (!RETURN_VALUE_UNUSED(&opline->result)) { - T(opline->result.u.var).var.ptr_ptr = retval; - PZVAL_LOCK(*retval); - } -} - - -static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, znode *op2, temp_variable *Ts, int type TSRMLS_DC) +static inline zval **zend_fetch_dimension_address_inner(HashTable *ht, zval *dim, int type TSRMLS_DC) { - zend_free_op free_op2; - zval *dim = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); zval **retval; char *offset_key; int offset_key_length; @@ -938,32 +965,27 @@ } break; } - FREE_OP(free_op2); return retval; } -static void zend_fetch_dimension_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) +static void zend_fetch_dimension_address(temp_variable *result, zval **container_ptr, zval *dim, int type TSRMLS_DC) { - zend_free_op free_op1; - zval **container_ptr = get_zval_ptr_ptr(op1, Ts, &free_op1, type); zval *container; - zval ***retval = &T(result->u.var).var.ptr_ptr; if (!container_ptr) { - zend_error(E_ERROR, "Cannot use string offset as an array"); + zend_error_noreturn(E_ERROR, "Cannot use string offset as an array"); } container = *container_ptr; if (container == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(result)) { - *retval = &EG(error_zval_ptr); - PZVAL_LOCK(**retval); + if (result) { + result->var.ptr_ptr = &EG(error_zval_ptr); + PZVAL_LOCK(*result->var.ptr_ptr); if (type == BP_VAR_R || type == BP_VAR_IS) { - AI_USE_PTR(T(result->u.var).var); + AI_USE_PTR(result->var); } } - FREE_OP_VAR_PTR(free_op1); return; } @@ -983,54 +1005,59 @@ } switch (container->type) { + zval **retval; + case IS_ARRAY: if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) { SEPARATE_ZVAL(container_ptr); container = *container_ptr; } + if (dim == NULL) { +/* if (op2->op_type == IS_UNUSED) { +*/ zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; - if (zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) retval) == FAILURE) { + if (zend_hash_next_index_insert(container->value.ht, &new_zval, sizeof(zval *), (void **) &retval) == FAILURE) { zend_error(E_WARNING, "Cannot add element to the array as the next element is already occupied"); - *retval = &EG(uninitialized_zval_ptr); + retval = &EG(uninitialized_zval_ptr); new_zval->refcount--; } } else { - *retval = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, type TSRMLS_CC); + retval = zend_fetch_dimension_address_inner(container->value.ht, dim, type TSRMLS_CC); + } + if (result) { + result->var.ptr_ptr = retval; + PZVAL_LOCK(*result->var.ptr_ptr); } - SELECTIVE_PZVAL_LOCK(**retval, result); break; case IS_NULL: { /* for read-mode only */ - zend_free_op free_op2; - - get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - *retval = &EG(uninitialized_zval_ptr); - SELECTIVE_PZVAL_LOCK(**retval, result); - FREE_OP(free_op2); + if (result) { + result->var.ptr_ptr = &EG(uninitialized_zval_ptr); + PZVAL_LOCK(*result->var.ptr_ptr); + } if (type==BP_VAR_W || type==BP_VAR_RW) { zend_error(E_WARNING, "Cannot use a NULL value as an array"); } break; } case IS_STRING: { - zend_free_op free_op2; - zval *offset; zval tmp; + if (dim == NULL) { +/* if (op2->op_type==IS_UNUSED) { - zend_error(E_ERROR, "[] operator not supported for strings"); +*/ + zend_error_noreturn(E_ERROR, "[] operator not supported for strings"); } - offset = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - - if (offset->type != IS_LONG) { - tmp = *offset; + if (dim->type != IS_LONG) { + tmp = *dim; zval_copy_ctor(&tmp); convert_to_long(&tmp); - offset = &tmp; + dim = &tmp; } switch (type) { case BP_VAR_R: @@ -1042,25 +1069,23 @@ SEPARATE_ZVAL_IF_NOT_REF(container_ptr); break; } - container = *container_ptr; - T(result->u.var).str_offset.str = container; - PZVAL_LOCK(container); - T(result->u.var).str_offset.offset = offset->value.lval; - FREE_OP(free_op2); - *retval = NULL; - if (type == BP_VAR_R || type == BP_VAR_IS) { - AI_USE_PTR(T(result->u.var).var); + if (result) { + container = *container_ptr; + result->str_offset.str = container; + PZVAL_LOCK(container); + result->str_offset.offset = dim->value.lval; + result->var.ptr_ptr = NULL; + if (type == BP_VAR_R || type == BP_VAR_IS) { + AI_USE_PTR(result->var); + } } - FREE_OP_VAR_PTR(free_op1); return; } break; case IS_OBJECT: if (!Z_OBJ_HT_P(container)->read_dimension) { - zend_error(E_ERROR, "Cannot use object as array"); + zend_error_noreturn(E_ERROR, "Cannot use object as array"); } else { - zend_free_op free_op2; - zval *dim = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); zval *overloaded_result = Z_OBJ_HT_P(container)->read_dimension(container, dim, type TSRMLS_CC); if (overloaded_result) { @@ -1069,83 +1094,62 @@ case BP_VAR_W: if (overloaded_result->type != IS_OBJECT && !overloaded_result->is_ref) { - zend_error(E_ERROR, "Objects used as arrays in post/pre increment/decrement must return values by reference"); + zend_error_noreturn(E_ERROR, "Objects used as arrays in post/pre increment/decrement must return values by reference"); } break; } - *retval = &overloaded_result; + retval = &overloaded_result; } else { - *retval = &EG(error_zval_ptr); + retval = &EG(error_zval_ptr); + } + if (result) { + result->var.ptr_ptr = retval; + AI_USE_PTR(result->var); + PZVAL_LOCK(*result->var.ptr_ptr); } - AI_USE_PTR(T(result->u.var).var); - FREE_OP(free_op2); - SELECTIVE_PZVAL_LOCK(**retval, result); + return; } break; - default: { - zend_free_op free_op2; - - get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - + default: { switch (type) { case BP_VAR_UNSET: zend_error(E_WARNING, "Cannot unset offset in a non-array variable"); /* break missing intentionally */ case BP_VAR_R: case BP_VAR_IS: - *retval = &EG(uninitialized_zval_ptr); + retval = &EG(uninitialized_zval_ptr); break; default: - *retval = &EG(error_zval_ptr); + retval = &EG(error_zval_ptr); break; } - FREE_OP(free_op2); - SELECTIVE_PZVAL_LOCK(**retval, result); + if (result) { + result->var.ptr_ptr = retval; + PZVAL_LOCK(*result->var.ptr_ptr); + } if (type==BP_VAR_W || type==BP_VAR_RW) { zend_error(E_WARNING, "Cannot use a scalar value as an array"); } } break; } - if (type == BP_VAR_R || type == BP_VAR_IS) { - AI_USE_PTR(T(result->u.var).var); - } - FREE_OP_VAR_PTR(free_op1); -} - - -static void zend_fetch_dimension_address_from_tmp_var(znode *result, znode *op1, znode *op2, temp_variable *Ts TSRMLS_DC) -{ - zend_free_op free_op1; - zval *container = get_zval_ptr(op1, Ts, &free_op1, BP_VAR_R); - - if (container->type != IS_ARRAY) { - if (!RETURN_VALUE_UNUSED(result)) { - T(result->u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); - PZVAL_LOCK(*T(result->u.var).var.ptr_ptr); - } - return; + if (result && (type == BP_VAR_R || type == BP_VAR_IS)) { + AI_USE_PTR(result->var); } - - T(result->u.var).var.ptr_ptr = zend_fetch_dimension_address_inner(container->value.ht, op2, Ts, BP_VAR_R TSRMLS_CC); - SELECTIVE_PZVAL_LOCK(*T(result->u.var).var.ptr_ptr, result); } -static void zend_fetch_property_address(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) +static void zend_fetch_property_address(temp_variable *result, zval **container_ptr, zval *prop_ptr, int op2_type, int type TSRMLS_DC) { - zend_free_op free_op1; - zval **container_ptr = get_obj_zval_ptr_ptr(op1, Ts, &free_op1, type); zval *container; - zval ***retval = &T(result->u.var).var.ptr_ptr; + zval tmp; container = *container_ptr; if (container == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(result)) { - *retval = &EG(error_zval_ptr); - PZVAL_LOCK(**retval); + if (result) { + result->var.ptr_ptr = &EG(error_zval_ptr); + PZVAL_LOCK(*result->var.ptr_ptr); } - FREE_OP_VAR_PTR(free_op1); return; } /* this should modify object only if it's empty */ @@ -1165,227 +1169,103 @@ } if (container->type != IS_OBJECT) { - zend_free_op free_op2; - - get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - FREE_OP(free_op2); - if (!RETURN_VALUE_UNUSED(result)) { + if (result) { if (type == BP_VAR_R || type == BP_VAR_IS) { - *retval = &EG(uninitialized_zval_ptr); + result->var.ptr_ptr = &EG(uninitialized_zval_ptr); } else { - *retval = &EG(error_zval_ptr); + result->var.ptr_ptr = &EG(error_zval_ptr); } - PZVAL_LOCK(**retval); + PZVAL_LOCK(*result->var.ptr_ptr); } - FREE_OP_VAR_PTR(free_op1); return; } - - + if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) { SEPARATE_ZVAL(container_ptr); container = *container_ptr; } - zend_fetch_property_address_inner(container, op2, result, Ts, type TSRMLS_CC); - SELECTIVE_PZVAL_LOCK(**retval, result); - FREE_OP_VAR_PTR(free_op1); -} - -static void zend_fetch_property_address_read(znode *result, znode *op1, znode *op2, temp_variable *Ts, int type TSRMLS_DC) -{ - zval *container; - zval **retval; - zend_free_op free_op1; - - retval = &T(result->u.var).var.ptr; - T(result->u.var).var.ptr_ptr = retval; - - container = get_obj_zval_ptr(op1, Ts, &free_op1, type); - if (container == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(result)) { - *retval = EG(error_zval_ptr); - PZVAL_LOCK(*retval); - AI_USE_PTR(T(result->u.var).var); - } - FREE_OP(free_op1); - return; + switch (op2_type) { + case IS_CONST: + /* already a constant string */ + break; + case IS_VAR: + tmp = *prop_ptr; + zval_copy_ctor(&tmp); + convert_to_string(&tmp); + prop_ptr = &tmp; + break; + case IS_TMP_VAR: + convert_to_string(prop_ptr); + break; } - - if (container->type != IS_OBJECT) { - zend_error(E_NOTICE, "Trying to get property of non-object"); - - if (type==BP_VAR_R || type==BP_VAR_IS) { - *retval = EG(uninitialized_zval_ptr); - } else { - *retval = EG(error_zval_ptr); + if (Z_OBJ_HT_P(container)->get_property_ptr_ptr) { + zval **ptr_ptr = Z_OBJ_HT_P(container)->get_property_ptr_ptr(container, prop_ptr TSRMLS_CC); + if(NULL == ptr_ptr) { + zend_error_noreturn(E_ERROR, "Cannot access undefined property %s::$%s for object with overloaded property access", Z_OBJCE_P(container)->name, Z_STRVAL_P(prop_ptr)); } - } else { - zend_free_op free_op2; - zval *offset; - zval tmp; - - offset = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - switch (op2->op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *offset; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - offset = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(offset); - break; + if (result) { + result->var.ptr_ptr = ptr_ptr; } - - /* here we are sure we are dealing with an object */ - *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); - if (offset == &tmp) { - zval_dtor(offset); + } else if (Z_OBJ_HT_P(container)->read_property) { + if (result) { + result->var.ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, BP_VAR_W TSRMLS_CC); + result->var.ptr_ptr = &result->var.ptr; } - FREE_OP(free_op2); - - if (RETURN_VALUE_UNUSED(result) && ((*retval)->refcount == 0)) { - zval_dtor(*retval); - FREE_ZVAL(*retval); - return; /* no need for locking */ + } else { + zend_error(E_WARNING, "This object doesn't support property references"); + if (result) { + result->var.ptr_ptr = &EG(error_zval_ptr); } } - SELECTIVE_PZVAL_LOCK(*retval, result); - AI_USE_PTR(T(result->u.var).var); - FREE_OP(free_op1); + if (prop_ptr == &tmp) { + zval_dtor(prop_ptr); + } + + if (result) { + PZVAL_LOCK(*result->var.ptr_ptr); + } } -static void zend_pre_incdec_property(znode *result, znode *op1, znode *op2, temp_variable * Ts, int (*incdec_op)(zval *) TSRMLS_DC) +static inline zend_brk_cont_element* zend_brk_cont(zval *nest_levels_zval, int array_offset, zend_op_array *op_array, temp_variable *Ts TSRMLS_DC) { - zend_free_op free_op1, free_op2; - zval **object_ptr = get_obj_zval_ptr_ptr(op1, Ts, &free_op1, BP_VAR_W); - zval *object; - zval *property = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - zval **retval = &T(result->u.var).var.ptr; - int have_get_ptr = 0; - - make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ - object = *object_ptr; - - if (object->type != IS_OBJECT) { - zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - FREE_OP(free_op2); - if (!RETURN_VALUE_UNUSED(result)) { - *retval = EG(uninitialized_zval_ptr); - PZVAL_LOCK(*retval); - } - FREE_OP_VAR_PTR(free_op1); - return; - } - - /* here we are sure we are dealing with an object */ - - if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - SEPARATE_ZVAL_IF_NOT_REF(zptr); - - have_get_ptr = 1; - incdec_op(*zptr); - if (!RETURN_VALUE_UNUSED(result)) { - *retval = *zptr; - PZVAL_LOCK(*retval); - } - } - } - - if (!have_get_ptr) { - zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); - - if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - - if (z->refcount == 0) { - zval_dtor(z); - FREE_ZVAL(z); - } - z = value; - } - z->refcount++; - SEPARATE_ZVAL_IF_NOT_REF(&z); - incdec_op(z); - *retval = z; - Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); - SELECTIVE_PZVAL_LOCK(*retval, result); - zval_ptr_dtor(&z); - } - - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); -} - -static void zend_post_incdec_property(znode *result, znode *op1, znode *op2, temp_variable * Ts, int (*incdec_op)(zval *) TSRMLS_DC) -{ - zend_free_op free_op1, free_op2; - zval **object_ptr = get_obj_zval_ptr_ptr(op1, Ts, &free_op1, BP_VAR_W); - zval *object; - zval *property = get_zval_ptr(op2, Ts, &free_op2, BP_VAR_R); - zval *retval = &T(result->u.var).tmp_var; - int have_get_ptr = 0; + zval tmp; + int nest_levels, original_nest_levels; + zend_brk_cont_element *jmp_to; - make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ - object = *object_ptr; - - if (object->type != IS_OBJECT) { - zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); - FREE_OP(free_op2); - *retval = *EG(uninitialized_zval_ptr); - FREE_OP_VAR_PTR(free_op1); - return; + if (nest_levels_zval->type != IS_LONG) { + tmp = *nest_levels_zval; + zval_copy_ctor(&tmp); + convert_to_long(&tmp); + nest_levels = tmp.value.lval; + } else { + nest_levels = nest_levels_zval->value.lval; } - - /* here we are sure we are dealing with an object */ - - if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - have_get_ptr = 1; - SEPARATE_ZVAL_IF_NOT_REF(zptr); - - *retval = **zptr; - zendi_zval_copy_ctor(*retval); - - incdec_op(*zptr); - + original_nest_levels = nest_levels; + do { + if (array_offset==-1) { + zend_error_noreturn(E_ERROR, "Cannot break/continue %d level%s", original_nest_levels, (original_nest_levels == 1) ? "" : "s"); } - } - - if (!have_get_ptr) { - zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); - - if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); + jmp_to = &op_array->brk_cont_array[array_offset]; + if (nest_levels>1) { + zend_op *brk_opline = &op_array->opcodes[jmp_to->brk]; - if (z->refcount == 0) { - zval_dtor(z); - FREE_ZVAL(z); + switch (brk_opline->opcode) { + case ZEND_SWITCH_FREE: + zend_switch_free(brk_opline, Ts TSRMLS_CC); + break; + case ZEND_FREE: + zendi_zval_dtor(T(brk_opline->op1.u.var).tmp_var); + break; } - z = value; } - *retval = *z; - zendi_zval_copy_ctor(*retval); - incdec_op(z); - z->refcount++; - Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); - zval_ptr_dtor(&z); - } - - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); + array_offset = jmp_to->parent; + } while (--nest_levels > 0); + return jmp_to; } - #if ZEND_INTENSIVE_DEBUGGING #define CHECK_SYMBOL_TABLES() \ @@ -1414,32 +1294,7 @@ #define CHECK_SYMBOL_TABLES() #endif -#define NEXT_OPCODE() \ - CHECK_SYMBOL_TABLES() \ - EX(opline)++; \ - return 0; /* CHECK_ME */ - -#define SET_OPCODE(new_op) \ - CHECK_SYMBOL_TABLES() \ - EX(opline) = new_op; - -#define INC_OPCODE() \ - if (!EG(exception)) { \ - CHECK_SYMBOL_TABLES() \ - EX(opline)++; \ - } - -#define RETURN_FROM_EXECUTE_LOOP(execute_data) \ - if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ - free_alloca(EX(Ts)); \ - } else { \ - efree(EX(Ts)); \ - } \ - EG(in_execution) = EX(original_in_execution); \ - EG(current_execute_data) = EX(prev_execute_data); \ - return 1; /* CHECK_ME */ - -ZEND_API opcode_handler_t zend_opcode_handlers[512]; +ZEND_API opcode_handler_t *zend_opcode_handlers; ZEND_API void execute_internal(zend_execute_data *execute_data_ptr, int return_value_used TSRMLS_DC) { @@ -1449,6 +1304,16 @@ ZEND_API void execute(zend_op_array *op_array TSRMLS_DC) { zend_execute_data execute_data; + ZEND_VM_HELPER_VAR(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC)) + ZEND_VM_HELPER_VAR(incdec_t incdec_op) + ZEND_VM_HELPER_VAR(int prop_dim) + ZEND_VM_HELPER_VAR(int type) + +#if ZEND_VM_KIND == ZEND_VM_KIND_GOTO + if (op_array == NULL) { + goto init_labels; + } +#endif /* Initialize execute_data */ EX(fbc) = NULL; @@ -1465,9 +1330,9 @@ EG(in_execution) = 1; if (op_array->start_op) { - SET_OPCODE(op_array->start_op); + ZEND_VM_SET_OPCODE(op_array->start_op); } else { - SET_OPCODE(op_array->opcodes); + ZEND_VM_SET_OPCODE(op_array->opcodes); } if (op_array->uses_this && EG(This)) { @@ -1489,3364 +1354,50 @@ #endif while (1) { +ZEND_VM_CONTINUE_LABEL #ifdef ZEND_WIN32 if (EG(timed_out)) { zend_timeout(0); } #endif - if (EX(opline)->handler(&execute_data TSRMLS_CC)) { + ZEND_VM_DISPATCH() { +#if ZEND_VM_KIND == ZEND_VM_KIND_CALL return; - } - } - zend_error(E_ERROR, "Arrived at end of main loop which shouldn't happen"); -} - -/* CHECK_ME */ -#undef EX -#define EX(element) execute_data->element - -int zend_add_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - add_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_sub_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - sub_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_mul_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - mul_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_div_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - div_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_mod_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - mod_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_sl_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - shift_left_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_sr_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - shift_right_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_concat_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - concat_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_identical_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_identical_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_not_identical_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_not_identical_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_equal_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_not_equal_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_not_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_smaller_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_smaller_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_is_smaller_or_equal_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - is_smaller_or_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_or_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - bitwise_or_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_and_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - bitwise_and_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_xor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - bitwise_xor_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bool_xor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - - boolean_xor_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_bw_not_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - bitwise_not_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -int zend_bool_not_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - boolean_not_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R) TSRMLS_CC); - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -static inline int zend_binary_assign_op_obj_helper(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op *op_data = opline+1; - zend_free_op free_op1, free_op2, free_op_data1; - zval **object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - zval *object; - zval *property = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval *value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); - zval tmp; - znode *result = &opline->result; - zval **retval = &EX_T(result->u.var).var.ptr; - int have_get_ptr = 0; - - EX_T(result->u.var).var.ptr_ptr = NULL; - make_real_object(object_ptr TSRMLS_CC); - object = *object_ptr; - - if (object->type != IS_OBJECT) { - zend_error(E_WARNING, "Attempt to assign property of non-object"); - FREE_OP(free_op2); - FREE_OP(free_op_data1); - - if (!RETURN_VALUE_UNUSED(result)) { - *retval = EG(uninitialized_zval_ptr); - PZVAL_LOCK(*retval); - } - } else { - /* here we are sure we are dealing with an object */ - switch (opline->op2.op_type) { - case IS_CONST: - /* already a constant string */ - break; - case IS_VAR: - tmp = *property; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - property = &tmp; - break; - case IS_TMP_VAR: - convert_to_string(property); - break; - } - - /* here property is a string */ - if (opline->extended_value == ZEND_ASSIGN_OBJ - && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { - zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); - if (zptr != NULL) { /* NULL means no success in getting PTR */ - SEPARATE_ZVAL_IF_NOT_REF(zptr); - - have_get_ptr = 1; - binary_op(*zptr, *zptr, value TSRMLS_CC); - if (!RETURN_VALUE_UNUSED(result)) { - *retval = *zptr; - PZVAL_LOCK(*retval); - } - } - } - - if (!have_get_ptr) { - zval *z; - - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); - break; - case ZEND_ASSIGN_DIM: - z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_RW TSRMLS_CC); - break; - } - if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { - zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); - - if (z->refcount == 0) { - zval_dtor(z); - FREE_ZVAL(z); - } - z = value; - } - z->refcount++; - SEPARATE_ZVAL_IF_NOT_REF(&z); - binary_op(z, z, value TSRMLS_CC); - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); - break; - case ZEND_ASSIGN_DIM: - Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); - break; - } - if (!RETURN_VALUE_UNUSED(result)) { - *retval = z; - PZVAL_LOCK(*retval); - } - zval_ptr_dtor(&z); +#else +# include "zend_vm_spec.h" +#endif } - if (property == &tmp) { - zval_dtor(property); - } - - FREE_OP(free_op2); - FREE_OP(free_op_data1); } + zend_error_noreturn(E_ERROR, "Arrived at end of main loop which shouldn't happen"); +#if ZEND_VM_KIND == ZEND_VM_KIND_GOTO + { + static const opcode_handler_t labels[] = {ZEND_VM_LABELS}; - FREE_OP_VAR_PTR(free_op1); - /* assign_obj has two opcodes! */ - INC_OPCODE(); - NEXT_OPCODE(); + init_labels: + zend_opcode_handlers = (opcode_handler_t*)labels; + return; + } +#endif } +#if ZEND_VM_KIND == ZEND_VM_KIND_CALL +# undef EX +# define EX(element) execute_data->element +# include"zend_vm_spec.h" +#endif -static inline int zend_binary_assign_op_helper(int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC), ZEND_OPCODE_HANDLER_ARGS) +void zend_init_opcodes_handlers() { - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2, free_op_data2; - zval **var_ptr; - zval *value; - zend_bool increment_opline = 0; - - switch (opline->extended_value) { - case ZEND_ASSIGN_OBJ: - return zend_binary_assign_op_obj_helper(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - break; - case ZEND_ASSIGN_DIM: { - zval **object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ - - if ((*object_ptr)->type == IS_OBJECT) { - return zend_binary_assign_op_obj_helper(binary_op, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } else { - zend_op *op_data = opline+1; - - zend_fetch_dimension_address(&op_data->op2, &opline->op1, &opline->op2, EX(Ts), BP_VAR_RW TSRMLS_CC); - value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op2, BP_VAR_R); - var_ptr = get_zval_ptr_ptr(&op_data->op2, EX(Ts), &free_op_data2, BP_VAR_RW); - increment_opline = 1; - } - } - break; - default: - value = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - var_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_RW); - /* do nothing */ - break; - } - - if (!var_ptr) { - zend_error(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); - } - - if (*var_ptr == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - FREE_OP_VAR_PTR(free_op1); - if (increment_opline) { - INC_OPCODE(); - } - NEXT_OPCODE(); - } - - SEPARATE_ZVAL_IF_NOT_REF(var_ptr); - - if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) - && Z_OBJ_HANDLER_PP(var_ptr, set)) { - /* proxy object */ - zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - objval->refcount++; - binary_op(objval, objval, value TSRMLS_CC); - Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); - zval_ptr_dtor(&objval); - } else { - binary_op(*var_ptr, *var_ptr, value TSRMLS_CC); - } - - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; - PZVAL_LOCK(*var_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - FREE_OP(free_op2); - - if (increment_opline) { - INC_OPCODE(); - FREE_OP_VAR_PTR(free_op_data2); - } - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); -} - - -int zend_assign_add_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(add_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_sub_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(sub_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_mul_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(mul_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_div_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(div_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_mod_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(mod_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_sl_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(shift_left_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_sr_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(shift_right_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_concat_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(concat_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_bw_or_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(bitwise_or_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_bw_and_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(bitwise_and_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_assign_bw_xor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_binary_assign_op_helper(bitwise_xor_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -int zend_pre_inc_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_pre_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), increment_function TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_pre_dec_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_pre_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), decrement_function TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_post_inc_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_post_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), increment_function TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_post_dec_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_post_incdec_property(&opline->result, &opline->op1, &opline->op2, EX(Ts), decrement_function TSRMLS_CC); - NEXT_OPCODE(); -} - -typedef int (*incdec_t)(zval *); - -static inline int zend_incdec_op_helper(incdec_t incdec_op_arg, ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval **var_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_RW); - int (*incdec_op)(zval *op1) = incdec_op_arg; - - if (!var_ptr) { - zend_error(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); - } - if (*var_ptr == EG(error_zval_ptr)) { - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); - } - - switch (opline->opcode) { - case ZEND_POST_INC: - case ZEND_POST_DEC: - EX_T(opline->result.u.var).tmp_var = **var_ptr; - zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); - break; - } - - SEPARATE_ZVAL_IF_NOT_REF(var_ptr); - - if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) - && Z_OBJ_HANDLER_PP(var_ptr, set)) { - /* proxy object */ - zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); - val->refcount++; - incdec_op(val); - Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); - zval_ptr_dtor(&val); - } else { - incdec_op(*var_ptr); - } - - switch (opline->opcode) { - case ZEND_PRE_INC: - case ZEND_PRE_DEC: - if (!RETURN_VALUE_UNUSED(&opline->result)) { - EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; - PZVAL_LOCK(*var_ptr); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - break; - } - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); -} - - -int zend_pre_inc_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(increment_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_pre_dec_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(decrement_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_post_inc_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(increment_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_post_dec_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_incdec_op_helper(decrement_function, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_echo_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval z_copy; - zval *z = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && - zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { - zend_print_variable(&z_copy); - zval_dtor(&z_copy); - } else { - zend_print_variable(z); - } - - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -int zend_print_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).tmp_var.value.lval = 1; - EX_T(opline->result.u.var).tmp_var.type = IS_LONG; - - return zend_echo_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_fetch_r_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_R TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - NEXT_OPCODE(); -} - - -int zend_fetch_w_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_W TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_rw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_RW TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_func_arg_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { - /* Behave like FETCH_W */ - zend_fetch_var_address(opline, EX(Ts), BP_VAR_W TSRMLS_CC); - } else { - /* Behave like FETCH_R */ - zend_fetch_var_address(opline, EX(Ts), BP_VAR_R TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - } - NEXT_OPCODE(); -} - - -int zend_fetch_unset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_res; - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_R TSRMLS_CC); - PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); - if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); - } - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - FREE_OP_VAR_PTR(free_res); - NEXT_OPCODE(); -} - - -int zend_fetch_is_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_var_address(opline, EX(Ts), BP_VAR_IS TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_r_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - } - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_w_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_rw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_RW TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_is_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_IS TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_func_arg_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { - /* Behave like FETCH_DIM_W */ - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - } else { - /* Behave like FETCH_DIM_R, except for locking used for list() */ - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_fetch_dim_unset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - /* Not needed in DIM_UNSET - if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - } - */ - zend_fetch_dimension_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_UNSET TSRMLS_CC); - if (EX_T(opline->result.u.var).var.ptr_ptr == NULL) { - zend_error(E_ERROR, "Cannot unset string offsets"); - } else { - zend_free_op free_res; - - PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); - if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); - } - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - FREE_OP_VAR_PTR(free_res); - } - NEXT_OPCODE(); -} - - -int zend_fetch_obj_r_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_property_address_read(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_w_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - EX_T(opline->op1.u.var).var.ptr = *EX_T(opline->op1.u.var).var.ptr_ptr; - } - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_rw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_RW TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_is_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_property_address_read(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_IS TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_fetch_obj_func_arg_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { - /* Behave like FETCH_OBJ_W */ - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - } else { - zend_fetch_property_address_read(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_fetch_obj_unset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_res; - - zend_fetch_property_address(&opline->result, &opline->op1, &opline->op2, EX(Ts), BP_VAR_R TSRMLS_CC); - - PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); - if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { - SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); - } - PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); - FREE_OP_VAR_PTR(free_res); - NEXT_OPCODE(); -} - - -int zend_fetch_dim_tmp_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - zend_fetch_dimension_address_from_tmp_var(&opline->result, &opline->op1, &opline->op2, EX(Ts) TSRMLS_CC); - AI_USE_PTR(EX_T(opline->result.u.var).var); - NEXT_OPCODE(); -} - - -int zend_assign_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op *op_data = opline+1; - zend_free_op free_op1; - zval **object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_OBJ TSRMLS_CC); - FREE_OP_VAR_PTR(free_op1); - /* assign_obj has two opcodes! */ - INC_OPCODE(); - NEXT_OPCODE(); -} - - -int zend_assign_dim_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op *op_data = opline+1; - zend_free_op free_op1; - zval **object_ptr; - - if (EX_T(opline->op1.u.var).var.ptr_ptr) { - /* not an array offset */ - object_ptr = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - } else { - object_ptr = NULL; - free_op1.var = NULL; - } - - if (object_ptr && (*object_ptr)->type == IS_OBJECT) { - zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_DIM TSRMLS_CC); - } else { - zend_free_op free_op_data1; - zval *value; - - if (object_ptr) { - (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ - } - zend_fetch_dimension_address(&op_data->op2, &opline->op1, &opline->op2, EX(Ts), BP_VAR_W TSRMLS_CC); - - value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); - zend_assign_to_variable(&opline->result, &op_data->op2, &op_data->op1, value, (IS_TMP_FREE(free_op_data1)?IS_TMP_VAR:op_data->op1.op_type), EX(Ts) TSRMLS_CC); - FREE_OP_VAR(free_op_data1); - } - FREE_OP_VAR_PTR(free_op1); - /* assign_dim has two opcodes! */ - INC_OPCODE(); - NEXT_OPCODE(); -} - - -int zend_assign_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op2; - zval *value = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - zend_assign_to_variable(&opline->result, &opline->op1, &opline->op2, value, (IS_TMP_FREE(free_op2)?IS_TMP_VAR:opline->op2.op_type), EX(Ts) TSRMLS_CC); - /* zend_assign_to_variable() always takes care of op2, never free it! */ - FREE_OP_VAR(free_op2); - - NEXT_OPCODE(); -} - - -int zend_assign_ref_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval **value_ptr_ptr = get_zval_ptr_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_W); - - zend_assign_to_variable_reference(&opline->result, get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W), value_ptr_ptr, EX(Ts) TSRMLS_CC); - - FREE_OP_VAR_PTR(free_op1); - FREE_OP_VAR_PTR(free_op2); - - NEXT_OPCODE(); -} - - -int zend_jmp_handler(ZEND_OPCODE_HANDLER_ARGS) -{ -#if DEBUG_ZEND>=2 - printf("Jumping to %d\n", opline->op1.u.opline_num); -#endif - SET_OPCODE(EX(opline)->op1.u.jmp_addr); - return 0; /* CHECK_ME */ -} - - -int zend_jmpz_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - znode *op1 = &opline->op1; - zend_free_op free_op1; - - if (!i_zend_is_true(get_zval_ptr(op1, EX(Ts), &free_op1, BP_VAR_R))) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - FREE_OP(free_op1); - return 0; /* CHECK_ME */ - } - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -int zend_jmpnz_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - znode *op1 = &opline->op1; - zend_free_op free_op1; - - if (zend_is_true(get_zval_ptr(op1, EX(Ts), &free_op1, BP_VAR_R))) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - FREE_OP(free_op1); - return 0; /* CHECK_ME */ - } - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -int zend_jmpznz_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - znode *res = &opline->op1; - zend_free_op free_op1; - - if (zend_is_true(get_zval_ptr(res, EX(Ts), &free_op1, BP_VAR_R))) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp on true to %d\n", opline->extended_value); -#endif - SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); - } else { -#if DEBUG_ZEND>=2 - printf("Conditional jmp on false to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(&EX(op_array)->opcodes[opline->op2.u.opline_num]); - } - FREE_OP(free_op1); - - return 0; /* CHECK_ME */ -} - - -int zend_jmpz_ex_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - int retval = zend_is_true(get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R)); - - FREE_OP(free_op1); - EX_T(opline->result.u.var).tmp_var.value.lval = retval; - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - if (!retval) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - return 0; /* CHECK_ME */ - } - NEXT_OPCODE(); -} - - -int zend_jmpnz_ex_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - int retval = zend_is_true(get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R)); - - FREE_OP(free_op1); - EX_T(opline->result.u.var).tmp_var.value.lval = retval; - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - if (retval) { -#if DEBUG_ZEND>=2 - printf("Conditional jmp to %d\n", opline->op2.u.opline_num); -#endif - SET_OPCODE(opline->op2.u.jmp_addr); - return 0; /* CHECK_ME */ - } - NEXT_OPCODE(); -} - - -int zend_free_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zendi_zval_dtor(EX_T(EX(opline)->op1.u.var).tmp_var); - NEXT_OPCODE(); -} - - -int zend_init_string_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zval *tmp = &EX_T(EX(opline)->result.u.var).tmp_var; - - tmp->value.str.val = emalloc(1); - tmp->value.str.val[0] = 0; - tmp->value.str.len = 0; - tmp->refcount = 1; - tmp->type = IS_STRING; - tmp->is_ref = 0; - NEXT_OPCODE(); -} - - -int zend_add_char_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - add_char_to_string(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_NA), - &opline->op2.u.constant); - /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ - NEXT_OPCODE(); -} - - -int zend_add_string_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - add_string_to_string(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_NA), - &opline->op2.u.constant); - /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ - NEXT_OPCODE(); -} - - -int zend_add_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval *var = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval var_copy; - int use_copy; - - zend_make_printable_zval(var, &var_copy, &use_copy); - if (use_copy) { - var = &var_copy; - } - add_string_to_string( &EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_NA), - var); - if (use_copy) { - zval_dtor(var); - } - /* original comment, possibly problematic: - * FREE_OP is missing intentionally here - we're always working on the same temporary variable - * (Zeev): I don't think it's problematic, we only use variables - * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're - * string offsets or overloaded objects - */ - FREE_OP(free_op2); - - NEXT_OPCODE(); -} - - -int zend_fetch_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *class_name; - zend_free_op free_op2; - - - if (opline->op2.op_type == IS_UNUSED) { - EX_T(opline->result.u.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); - NEXT_OPCODE(); - } - - class_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - switch (class_name->type) { - case IS_OBJECT: - EX_T(opline->result.u.var).class_entry = Z_OBJCE_P(class_name); - break; - case IS_STRING: - EX_T(opline->result.u.var).class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); - break; - default: - zend_error(E_ERROR, "Class name must be a valid object or a string"); - break; - } - - FREE_OP(free_op2); - NEXT_OPCODE(); -} - - -int zend_init_ctor_call_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - if (opline->op1.op_type == IS_VAR) { - SELECTIVE_PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr, &opline->op1); - } - - /* We are not handling overloaded classes right now */ - EX(object) = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - /* New always returns the object as is_ref=0, therefore, we can just increment the reference count */ - EX(object)->refcount++; /* For $this pointer */ - - EX(fbc) = EX(fbc_constructor); - - if (EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */ - EX(calling_scope) = EX(fbc)->common.scope; - } else { - EX(calling_scope) = NULL; - } - - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_init_method_call_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *function_name; - char *function_name_strval; - int function_name_strlen; - zend_free_op free_op1, free_op2; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - function_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (Z_TYPE_P(function_name)!=IS_STRING) { - zend_error(E_ERROR, "Method name must be a string"); - } - - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - - EX(calling_scope) = EG(scope); - - EX(object) = get_obj_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (EX(object) && EX(object)->type == IS_OBJECT) { - if (Z_OBJ_HT_P(EX(object))->get_method == NULL) { - zend_error(E_ERROR, "Object does not support method calls"); - } - - /* First, locate the function. */ - EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(EX(object), function_name_strval, function_name_strlen TSRMLS_CC); - if (!EX(fbc)) { - zend_error(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); - } - } else { - zend_error(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); - } - - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; - } else { - if (!PZVAL_IS_REF(EX(object))) { - EX(object)->refcount++; /* For $this pointer */ - } else { - zval *this_ptr; - ALLOC_ZVAL(this_ptr); - *this_ptr = *EX(object); - INIT_PZVAL(this_ptr); - zval_copy_ctor(this_ptr); - EX(object) = this_ptr; - } - } - - if (EX(fbc)->type == ZEND_USER_FUNCTION) { - EX(calling_scope) = EX(fbc)->common.scope; - } else { - EX(calling_scope) = NULL; - } - - FREE_OP(free_op2); - FREE_OP_VAR(free_op1); - - NEXT_OPCODE(); -} - - -int zend_init_static_method_call_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *function_name; - zend_class_entry *ce; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - ce = EX_T(opline->op1.u.var).class_entry; - if(opline->op2.op_type != IS_UNUSED) { - char *function_name_strval; - int function_name_strlen; - zend_bool is_const = (opline->op2.op_type == IS_CONST); - zend_free_op free_op2; - - if (is_const) { - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; - } else { - function_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (Z_TYPE_P(function_name) != IS_STRING) { - zend_error(E_ERROR, "Function name must be a string"); - } - function_name_strval = zend_str_tolower_dup(function_name->value.str.val, function_name->value.str.len); - function_name_strlen = function_name->value.str.len; - } - - EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); - - if (!is_const) { - efree(function_name_strval); - FREE_OP(free_op2); - } - } else { - if(!ce->constructor) { - zend_error(E_ERROR, "Can not call constructor"); - } - EX(fbc) = ce->constructor; - } - - EX(calling_scope) = EX(fbc)->common.scope; - - if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { - EX(object) = NULL; - } else { - if ((EX(object) = EG(This))) { - EX(object)->refcount++; - } - } - - NEXT_OPCODE(); -} - -int zend_init_fcall_by_name_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *function_name; - zend_function *function; - char *function_name_strval, *lcname; - int function_name_strlen; - zend_free_op free_op2; - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - if (opline->op2.op_type == IS_CONST) { - free_op2.var = 0; - function_name_strval = opline->op2.u.constant.value.str.val; - function_name_strlen = opline->op2.u.constant.value.str.len; - } else { - function_name = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (Z_TYPE_P(function_name) != IS_STRING) { - zend_error(E_ERROR, "Function name must be a string"); - } - function_name_strval = function_name->value.str.val; - function_name_strlen = function_name->value.str.len; - } - - lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); - if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { - efree(lcname); - zend_error(E_ERROR, "Call to undefined function %s()", function_name_strval); - } - - efree(lcname); - FREE_OP(free_op2); - - EX(calling_scope) = function->common.scope; - EX(object) = NULL; - - EX(fbc) = function; - - NEXT_OPCODE(); -} - -int zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval **original_return_value; - zend_class_entry *current_scope; - zval *current_this; - int return_value_used = RETURN_VALUE_USED(opline); - zend_bool should_change_scope; - - if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) { - zend_error(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); - NEXT_OPCODE(); /* Never reached */ - } - - zend_ptr_stack_2_push(&EG(argument_stack), (void *) opline->extended_value, NULL); - - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - - if (EX(function_state).function->type == ZEND_USER_FUNCTION - || EX(function_state).function->common.scope) { - should_change_scope = 1; - current_this = EG(This); - EG(This) = EX(object); - current_scope = EG(scope); - EG(scope) = EX(calling_scope); - } else { - should_change_scope = 0; - } - - EX_T(opline->result.u.var).var.fcall_returned_reference = 0; - - if (EX(function_state).function->common.scope) { - if (!EG(This) && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { - int severity; - char *severity_word; - if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { - severity = E_STRICT; - severity_word = "should not"; - } else { - severity = E_ERROR; - severity_word = "cannot"; - } - zend_error(severity, "Non-static method %s::%s() %s be called statically", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name, severity_word); - } - } - if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); - - if (EX(function_state).function->common.arg_info) { - zend_uint i=0; - zval **p; - ulong arg_count; - - p = (zval **) EG(argument_stack).top_element-2; - arg_count = (ulong) *p; - - while (arg_count>0) { - zend_verify_arg_type(EX(function_state).function, ++i, *(p-arg_count) TSRMLS_CC); - arg_count--; - } - } - if (!zend_execute_internal) { - /* saves one function call if zend_execute_internal is not used */ - ((zend_internal_function *) EX(function_state).function)->handler(opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); - } else { - zend_execute_internal(execute_data, return_value_used TSRMLS_CC); - } - - EG(current_execute_data) = execute_data; - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; - if (!return_value_used) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - } else if (EX(function_state).function->type == ZEND_USER_FUNCTION) { - HashTable *calling_symbol_table; - - EX_T(opline->result.u.var).var.ptr = NULL; - if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { - /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ - EX(function_state).function_symbol_table = *(EG(symtable_cache_ptr)--); - } else { - ALLOC_HASHTABLE(EX(function_state).function_symbol_table); - zend_hash_init(EX(function_state).function_symbol_table, 0, NULL, ZVAL_PTR_DTOR, 0); - /*printf("Cache miss! Initialized %x\n", function_state.function_symbol_table);*/ - } - calling_symbol_table = EG(active_symbol_table); - EG(active_symbol_table) = EX(function_state).function_symbol_table; - original_return_value = EG(return_value_ptr_ptr); - EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; - EG(active_op_array) = (zend_op_array *) EX(function_state).function; - - zend_execute(EG(active_op_array) TSRMLS_CC); - EX_T(opline->result.u.var).var.fcall_returned_reference = EG(active_op_array)->return_reference; - - if (return_value_used && !EX_T(opline->result.u.var).var.ptr) { - if (!EG(exception)) { - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); - } - } else if (!return_value_used && EX_T(opline->result.u.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(return_value_ptr_ptr)=original_return_value; - if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { - zend_hash_destroy(EX(function_state).function_symbol_table); - FREE_HASHTABLE(EX(function_state).function_symbol_table); - } else { - /* clean before putting into the cache, since clean - could call dtors, which could use cached hash */ - zend_hash_clean(EX(function_state).function_symbol_table); - *(++EG(symtable_cache_ptr)) = EX(function_state).function_symbol_table; - } - EG(active_symbol_table) = calling_symbol_table; - } else { /* ZEND_OVERLOADED_FUNCTION */ - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); - - /* Not sure what should be done here if it's a static method */ - if (EX(object)) { - Z_OBJ_HT_P(EX(object))->call_method(EX(fbc)->common.function_name, opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); - } else { - zend_error(E_ERROR, "Cannot call overloaded function for non-object"); - } - - if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { - efree(EX(function_state).function->common.function_name); - } - efree(EX(fbc)); - - if (!return_value_used) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } else { - EX_T(opline->result.u.var).var.ptr->is_ref = 0; - EX_T(opline->result.u.var).var.ptr->refcount = 1; - } - } - - if (EG(This)) { - if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) { - EG(This)->refcount--; - if (EG(This)->refcount == 1) { - zend_object_store_ctor_failed(EG(This) TSRMLS_CC); - } - zval_ptr_dtor(&EG(This)); - } else if (should_change_scope) { - zval_ptr_dtor(&EG(This)); - } - } - - if (should_change_scope) { - EG(This) = current_this; - EG(scope) = current_scope; - } - zend_ptr_stack_3_pop(&EG(arg_types_stack), (void**)&EX(calling_scope), (void**)&EX(object), (void**)&EX(fbc)); - - EX(function_state).function = (zend_function *) EX(op_array); - EG(function_state_ptr) = &EX(function_state); - zend_ptr_stack_clear_multiple(TSRMLS_C); - - if (EG(exception)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - if (return_value_used && EX_T(opline->result.u.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - } - - NEXT_OPCODE(); -} - - -int zend_do_fcall_by_name_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - EX(function_state).function = EX(fbc); - return zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_do_fcall_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *fname = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); - - if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { - zend_error(E_ERROR, "Unknown function: %s()\n", fname->value.str.val); - } - EX(object) = NULL; - EX(calling_scope) = EX(function_state).function->common.scope; - - FREE_OP(free_op1); - - return zend_do_fcall_common_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_return_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *retval_ptr; - zval **retval_ptr_ptr; - zend_free_op free_op1; - - if (EG(active_op_array)->return_reference == ZEND_RETURN_REF) { - - if (opline->op1.op_type == IS_CONST || opline->op1.op_type == IS_TMP_VAR) { - /* Not supposed to happen, but we'll allow it */ - zend_error(E_STRICT, "Only variable references should be returned by reference"); - goto return_by_value; - } - - retval_ptr_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - if (!retval_ptr_ptr) { - zend_error(E_ERROR, "Cannot return string offsets by reference"); - } - - if (!(*retval_ptr_ptr)->is_ref) { - if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr - || (opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op1.u.var).var.fcall_returned_reference)) { - zend_error(E_STRICT, "Only variable references should be returned by reference"); - PZVAL_LOCK(*retval_ptr_ptr); /* undo the effect of get_zval_ptr_ptr() */ - goto return_by_value; - } - } - - SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); - (*retval_ptr_ptr)->refcount++; - - (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); - FREE_OP_VAR_PTR(free_op1); - } else { -return_by_value: - - retval_ptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) { - ALLOC_ZVAL(*(EG(return_value_ptr_ptr))); - **EG(return_value_ptr_ptr) = *retval_ptr; - INIT_PZVAL(*EG(return_value_ptr_ptr)); - if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(retval_ptr)->name); - } - zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name); - (*EG(return_value_ptr_ptr))->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC); - } else if (!IS_TMP_FREE(free_op1)) { /* Not a temp var */ - if (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0) { - ALLOC_ZVAL(*(EG(return_value_ptr_ptr))); - **EG(return_value_ptr_ptr) = *retval_ptr; - (*EG(return_value_ptr_ptr))->is_ref = 0; - (*EG(return_value_ptr_ptr))->refcount = 1; - zval_copy_ctor(*EG(return_value_ptr_ptr)); - } else { - *EG(return_value_ptr_ptr) = retval_ptr; - retval_ptr->refcount++; - } - } else { - ALLOC_ZVAL(*(EG(return_value_ptr_ptr))); - **EG(return_value_ptr_ptr) = *retval_ptr; - (*EG(return_value_ptr_ptr))->refcount = 1; - (*EG(return_value_ptr_ptr))->is_ref = 0; - } - FREE_OP_VAR(free_op1); - } - RETURN_FROM_EXECUTE_LOOP(execute_data); -} - - -int zend_throw_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *value; - zval *exception; - zend_free_op free_op1; - - value = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (value->type != IS_OBJECT) { - zend_error(E_ERROR, "Can only throw objects"); - } - /* Not sure if a complete copy is what we want here */ - MAKE_STD_ZVAL(exception); - *exception = *value; - if (!IS_TMP_FREE(free_op1)) { - zval_copy_ctor(exception); - } - INIT_PZVAL(exception); - - zend_throw_exception_object(exception TSRMLS_CC); - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_catch_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_class_entry *ce; - - /* Check whether an exception has been thrown, if not, jump over code */ - if (EG(exception) == NULL) { - SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); - return 0; /* CHECK_ME */ - } - ce = Z_OBJCE_P(EG(exception)); - if (ce != EX_T(opline->op1.u.var).class_entry) { - if (!instanceof_function(ce, EX_T(opline->op1.u.var).class_entry TSRMLS_CC)) { - if (opline->op1.u.EA.type) { - zend_throw_exception_internal(NULL TSRMLS_CC); - NEXT_OPCODE(); - } - SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); - return 0; /* CHECK_ME */ - } - } - - zend_hash_update(EG(active_symbol_table), opline->op2.u.constant.value.str.val, - opline->op2.u.constant.value.str.len+1, &EG(exception), sizeof(zval *), (void **) NULL); - EG(exception) = NULL; - NEXT_OPCODE(); -} - - -int zend_send_val_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - if (opline->extended_value==ZEND_DO_FCALL_BY_NAME - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { - zend_error(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); - } - { - zval *valptr; - zval *value; - zend_free_op free_op1; - - value = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - ALLOC_ZVAL(valptr); - *valptr = *value; - if (!IS_TMP_FREE(free_op1)) { - zval_copy_ctor(valptr); - } - INIT_PZVAL(valptr); - zend_ptr_stack_push(&EG(argument_stack), valptr); - FREE_OP_VAR(free_op1); - } - NEXT_OPCODE(); -} - - -static inline int zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *varptr; - zend_free_op free_op1; - varptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (varptr == &EG(uninitialized_zval)) { - ALLOC_ZVAL(varptr); - INIT_ZVAL(*varptr); - varptr->refcount = 0; - } else if (PZVAL_IS_REF(varptr)) { - zval *original_var = varptr; - - ALLOC_ZVAL(varptr); - *varptr = *original_var; - varptr->is_ref = 0; - varptr->refcount = 0; - zval_copy_ctor(varptr); - } - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - FREE_OP(free_op1); /* for string offsets */ - - NEXT_OPCODE(); -} - - -int zend_send_var_no_ref_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ - if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { - return zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { - return zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - { - zval *varptr; - zend_free_op free_op1; - varptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { - varptr->is_ref = 1; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); - } - zend_error(E_ERROR, "Only variables can be passed by reference"); - } - NEXT_OPCODE(); -} - - -int zend_send_ref_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval **varptr_ptr; - zval *varptr; - varptr_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_W); - - if (!varptr_ptr) { - zend_error(E_ERROR, "Only variables can be passed by reference"); - } - - SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); - varptr = *varptr_ptr; - varptr->refcount++; - zend_ptr_stack_push(&EG(argument_stack), varptr); - - FREE_OP_VAR_PTR(free_op1); - NEXT_OPCODE(); -} - - -int zend_send_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) - && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { - return zend_send_ref_handler(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); - } - return zend_send_by_var_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_recv_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval **param; - zend_uint arg_num = opline->op1.u.constant.value.lval; - - if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { - char *space; - char *class_name = get_active_class_name(&space TSRMLS_CC); - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC); - zend_error(E_WARNING, "Missing argument %ld for %s%s%s()", opline->op1.u.constant.value.lval, class_name, space, get_active_function_name(TSRMLS_C)); - if (opline->result.op_type == IS_VAR) { - PZVAL_UNLOCK_FREE(*EX_T(opline->result.u.var).var.ptr_ptr); - } - } else { - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param TSRMLS_CC); - if (PZVAL_IS_REF(*param)) { - zend_free_op free_res; - - zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W), param, NULL TSRMLS_CC); - FREE_OP_VAR_PTR(free_res); - } else { - zend_assign_to_variable(NULL, &opline->result, NULL, *param, IS_VAR, EX(Ts) TSRMLS_CC); - } - } - - NEXT_OPCODE(); -} - - -int zend_recv_init_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval **param, *assignment_value; - zend_uint arg_num = opline->op1.u.constant.value.lval; - - if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { - if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { - zval *default_value; - - ALLOC_ZVAL(default_value); - *default_value = opline->op2.u.constant; - if (opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { - zval_copy_ctor(default_value); - } - default_value->refcount=1; - zval_update_constant(&default_value, 0 TSRMLS_CC); - default_value->refcount=0; - default_value->is_ref=0; - param = &default_value; - assignment_value = default_value; - } else { - param = NULL; - assignment_value = &opline->op2.u.constant; - } - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); - zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC); - } else { - assignment_value = *param; - zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); - if (PZVAL_IS_REF(assignment_value)) { - zend_free_op free_res; - - zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W), param, NULL TSRMLS_CC); - FREE_OP_VAR_PTR(free_res); - } else { - zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, EX(Ts) TSRMLS_CC); - } - } - - NEXT_OPCODE(); -} - - -int zend_bool_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - - /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ - EX_T(opline->result.u.var).tmp_var.value.lval = zend_is_true(get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R)); - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -static inline int zend_brk_cont_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op2; - zval *nest_levels_zval = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval tmp; - int array_offset, nest_levels, original_nest_levels; - zend_brk_cont_element *jmp_to; - - if (nest_levels_zval->type != IS_LONG) { - tmp = *nest_levels_zval; - zval_copy_ctor(&tmp); - convert_to_long(&tmp); - nest_levels = tmp.value.lval; - } else { - nest_levels = nest_levels_zval->value.lval; - } - original_nest_levels = nest_levels; - array_offset = opline->op1.u.opline_num; - do { - if (array_offset==-1) { - zend_error(E_ERROR, "Cannot break/continue %d level%s", original_nest_levels, (original_nest_levels == 1) ? "" : "s"); - } - jmp_to = &EX(op_array)->brk_cont_array[array_offset]; - if (nest_levels>1) { - zend_op *brk_opline = &EX(op_array)->opcodes[jmp_to->brk]; - - switch (brk_opline->opcode) { - case ZEND_SWITCH_FREE: - zend_switch_free(brk_opline, EX(Ts) TSRMLS_CC); - break; - case ZEND_FREE: - zendi_zval_dtor(EX_T(brk_opline->op1.u.var).tmp_var); - break; - } - } - array_offset = jmp_to->parent; - } while (--nest_levels > 0); - - if (opline->opcode == ZEND_BRK) { - SET_OPCODE(EX(op_array)->opcodes+jmp_to->brk); - } else { - SET_OPCODE(EX(op_array)->opcodes+jmp_to->cont); - } - FREE_OP(free_op2); - return 0; /* CHECK_ME */ -} - - -int zend_brk_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_brk_cont_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_cont_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_brk_cont_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_case_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - int switch_expr_is_overloaded=0; - zend_free_op free_op1, free_op2; - - if (opline->op1.op_type==IS_VAR) { - if (EX_T(opline->op1.u.var).var.ptr_ptr) { - PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); - } else { - switch_expr_is_overloaded = 1; - EX_T(opline->op1.u.var).str_offset.str->refcount++; - } - } - is_equal_function(&EX_T(opline->result.u.var).tmp_var, - get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R), - get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R) TSRMLS_CC); - - FREE_OP(free_op2); - if (switch_expr_is_overloaded) { - /* We only free op1 if this is a string offset, - * Since if it is a TMP_VAR, it'll be reused by - * other CASE opcodes (whereas string offsets - * are allocated at each get_zval_ptr()) - */ - FREE_OP(free_op1); - EX_T(opline->op1.u.var).var.ptr_ptr = NULL; - AI_USE_PTR(EX_T(opline->op1.u.var).var); - } - NEXT_OPCODE(); -} - - -int zend_switch_free_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_switch_free(EX(opline), EX(Ts) TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_new_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (EX_T(opline->op1.u.var).class_entry->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { - char *class_type; - - if (EX_T(opline->op1.u.var).class_entry->ce_flags & ZEND_ACC_INTERFACE) { - class_type = "interface"; - } else { - class_type = "abstract class"; - } - zend_error(E_ERROR, "Cannot instantiate %s %s", class_type, EX_T(opline->op1.u.var).class_entry->name); - } - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - object_init_ex(EX_T(opline->result.u.var).var.ptr, EX_T(opline->op1.u.var).class_entry); - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=0; - - NEXT_OPCODE(); -} - - -int zend_clone_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *obj = get_obj_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zend_class_entry *ce; - zend_function *clone; - zend_object_clone_obj_t clone_call; - - if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { - zend_error(E_WARNING, "__clone method called on non-object"); - EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); - } - - ce = Z_OBJCE_P(obj); - clone = ce ? ce->clone : NULL; - clone_call = Z_OBJ_HT_P(obj)->clone_obj; - if (!clone_call) { - zend_error(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name); - EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); - EX_T(opline->result.u.var).var.ptr->refcount++; - } - - if (ce && clone) { - if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) { - /* Ensure that if we're calling a private function, we're allowed to do so. - */ - if (ce != EG(scope)) { - zend_error(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); - } - } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) { - /* Ensure that if we're calling a protected function, we're allowed to do so. - */ - if (!zend_check_protected(clone->common.scope, EG(scope))) { - zend_error(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); - } - } - } - - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - EX_T(opline->result.u.var).var.ptr->value.obj = clone_call(obj TSRMLS_CC); - if (EG(exception)) { - FREE_ZVAL(EX_T(opline->result.u.var).var.ptr); - } else { - EX_T(opline->result.u.var).var.ptr->type = IS_OBJECT; - EX_T(opline->result.u.var).var.ptr->refcount=1; - EX_T(opline->result.u.var).var.ptr->is_ref=1; - } - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_fetch_constant_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_class_entry *ce = NULL; - zval **value; - - if (opline->op1.op_type == IS_UNUSED) { -/* This seems to be a reminant of namespaces - if (EG(scope)) { - ce = EG(scope); - if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { - zval_update_constant(value, (void *) 1 TSRMLS_CC); - EX_T(opline->result.u.var).tmp_var = **value; - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - NEXT_OPCODE(); - } - } -*/ - if (!zend_get_constant(opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len, &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) { - zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", - opline->op2.u.constant.value.str.val, - opline->op2.u.constant.value.str.val); - EX_T(opline->result.u.var).tmp_var = opline->op2.u.constant; - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - } - NEXT_OPCODE(); - } - - ce = EX_T(opline->op1.u.var).class_entry; - - if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { - zval_update_constant(value, (void *) 1 TSRMLS_CC); - EX_T(opline->result.u.var).tmp_var = **value; - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - } else { - zend_error(E_ERROR, "Undefined class constant '%s'", opline->op2.u.constant.value.str.val); - } - - NEXT_OPCODE(); -} - - -static inline int zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval *array_ptr = &EX_T(opline->result.u.var).tmp_var; - zval *expr_ptr, **expr_ptr_ptr = NULL; - zval *offset=get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - - if (opline->extended_value) { - expr_ptr_ptr=get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - expr_ptr = *expr_ptr_ptr; - } else { - expr_ptr=get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - } - - if (opline->opcode == ZEND_INIT_ARRAY) { - array_init(array_ptr); - if (!expr_ptr) { - NEXT_OPCODE(); - } - } - if (!opline->extended_value && IS_TMP_FREE(free_op1)) { /* temporary variable */ - zval *new_expr; - - ALLOC_ZVAL(new_expr); - *new_expr = *expr_ptr; - expr_ptr = new_expr; - INIT_PZVAL(expr_ptr); - } else { - if (opline->extended_value) { - SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); - expr_ptr = *expr_ptr_ptr; - expr_ptr->refcount++; - } else if (PZVAL_IS_REF(expr_ptr)) { - zval *new_expr; - - ALLOC_ZVAL(new_expr); - *new_expr = *expr_ptr; - expr_ptr = new_expr; - zendi_zval_copy_ctor(*expr_ptr); - INIT_PZVAL(expr_ptr); - } else { - expr_ptr->refcount++; - } - } - if (offset) { - switch (offset->type) { - case IS_DOUBLE: - zend_hash_index_update(array_ptr->value.ht, (long) offset->value.dval, &expr_ptr, sizeof(zval *), NULL); - break; - case IS_LONG: - case IS_BOOL: - zend_hash_index_update(array_ptr->value.ht, offset->value.lval, &expr_ptr, sizeof(zval *), NULL); - break; - case IS_STRING: - zend_symtable_update(array_ptr->value.ht, offset->value.str.val, offset->value.str.len+1, &expr_ptr, sizeof(zval *), NULL); - break; - case IS_NULL: - zend_hash_update(array_ptr->value.ht, "", sizeof(""), &expr_ptr, sizeof(zval *), NULL); - break; - default: - zend_error(E_WARNING, "Illegal offset type"); - zval_ptr_dtor(&expr_ptr); - /* do nothing */ - break; - } - FREE_OP(free_op2); - } else { - zend_hash_next_index_insert(array_ptr->value.ht, &expr_ptr, sizeof(zval *), NULL); - } - if (opline->extended_value) { - FREE_OP_VAR_PTR(free_op1); - } else { - FREE_OP_VAR(free_op1); - } - NEXT_OPCODE(); -} - - -int zend_init_array_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_add_array_element_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_init_add_array_helper(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_cast_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *expr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval *result = &EX_T(opline->result.u.var).tmp_var; - - *result = *expr; - if (!IS_TMP_FREE(free_op1)) { - zendi_zval_copy_ctor(*result); - } - switch (opline->extended_value) { - case IS_NULL: - convert_to_null(result); - break; - case IS_BOOL: - convert_to_boolean(result); - break; - case IS_LONG: - convert_to_long(result); - break; - case IS_DOUBLE: - convert_to_double(result); - break; - case IS_STRING: { - zval var_copy; - int use_copy; - - zend_make_printable_zval(result, &var_copy, &use_copy); - if (use_copy) { - zval_dtor(result); - *result = var_copy; - } - break; - } - case IS_ARRAY: - convert_to_array(result); - break; - case IS_OBJECT: - convert_to_object(result); - break; - } - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_include_or_eval_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_op_array *new_op_array=NULL; - zval **original_return_value = EG(return_value_ptr_ptr); - int return_value_used; - zend_free_op free_op1; - zval *inc_filename = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval tmp_inc_filename; - zend_bool failure_retval=0; - - if (inc_filename->type!=IS_STRING) { - tmp_inc_filename = *inc_filename; - zval_copy_ctor(&tmp_inc_filename); - convert_to_string(&tmp_inc_filename); - inc_filename = &tmp_inc_filename; - } - - return_value_used = RETURN_VALUE_USED(opline); - - switch (opline->op2.u.constant.value.lval) { - case ZEND_INCLUDE_ONCE: - case ZEND_REQUIRE_ONCE: { - int dummy = 1; - zend_file_handle file_handle; - - if (SUCCESS == zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC)) { - - if (!file_handle.opened_path) { - file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); - } - - if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { - new_op_array = zend_compile_file(&file_handle, (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); - zend_destroy_file_handle(&file_handle TSRMLS_CC); - } else { - zend_file_handle_dtor(&file_handle); - failure_retval=1; - } - } else { - if (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE) { - zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, inc_filename->value.str.val); - } else { - zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, inc_filename->value.str.val); - } - } - break; - } - break; - case ZEND_INCLUDE: - case ZEND_REQUIRE: - new_op_array = compile_filename(opline->op2.u.constant.value.lval, inc_filename TSRMLS_CC); - break; - case ZEND_EVAL: { - char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC); - - new_op_array = compile_string(inc_filename, eval_desc TSRMLS_CC); - efree(eval_desc); - } - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - if (inc_filename==&tmp_inc_filename) { - zval_dtor(&tmp_inc_filename); - } - FREE_OP(free_op1); - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - if (new_op_array) { - zval *saved_object; - zend_function *saved_function; - - EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; - EG(active_op_array) = new_op_array; - EX_T(opline->result.u.var).var.ptr = NULL; - - saved_object = EX(object); - saved_function = EX(function_state).function; - - EX(function_state).function = (zend_function *) new_op_array; - EX(object) = NULL; - - zend_execute(new_op_array TSRMLS_CC); - - EX(function_state).function = saved_function; - EX(object) = saved_object; - - if (!return_value_used) { - if (EX_T(opline->result.u.var).var.ptr) { - zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); - } - } else { /* return value is used */ - if (!EX_T(opline->result.u.var).var.ptr) { /* there was no return statement */ - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_PZVAL(EX_T(opline->result.u.var).var.ptr); - EX_T(opline->result.u.var).var.ptr->value.lval = 1; - EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; - } - } - - EG(opline_ptr) = &EX(opline); - EG(active_op_array) = EX(op_array); - EG(function_state_ptr) = &EX(function_state); - destroy_op_array(new_op_array TSRMLS_CC); - efree(new_op_array); - if (EG(exception)) { - zend_throw_exception_internal(NULL TSRMLS_CC); - } - } else { - if (return_value_used) { - ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); - INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); - EX_T(opline->result.u.var).var.ptr->value.lval = failure_retval; - EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; - } - } - EG(return_value_ptr_ptr) = original_return_value; - NEXT_OPCODE(); -} - - -int zend_unset_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval tmp, *varname; - HashTable *target_symbol_table; - zend_free_op free_op1; - - varname = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - if (varname->type != IS_STRING) { - tmp = *varname; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - varname = &tmp; - } - - if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { - zend_std_unset_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname) TSRMLS_CC); - } else { - target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); - zend_hash_del(target_symbol_table, varname->value.str.val, varname->value.str.len+1); - } - - if (varname == &tmp) { - zval_dtor(&tmp); - } - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - - -int zend_unset_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval **container = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval *offset = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - long index; - - if (container) { - HashTable *ht; - - if (opline->extended_value == ZEND_UNSET_DIM) { - switch (Z_TYPE_PP(container)) { - case IS_ARRAY: - ht = Z_ARRVAL_PP(container); - break; - case IS_OBJECT: - ht = NULL; - if (!Z_OBJ_HT_P(*container)->unset_dimension) { - zend_error(E_ERROR, "Cannot use object as array"); - } - Z_OBJ_HT_P(*container)->unset_dimension(*container, offset TSRMLS_CC); - break; - case IS_STRING: - zend_error(E_ERROR, "Cannot unset string offsets"); - return 0; /* bailed out before */ - default: - ht = NULL; - break; - } - } else { /* ZEND_UNSET_OBJ */ - ht = NULL; - if (Z_TYPE_PP(container) == IS_OBJECT) { - Z_OBJ_HT_P(*container)->unset_property(*container, offset TSRMLS_CC); - } - } - if (ht) { - switch (offset->type) { - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long) offset->value.dval; - } else { - index = offset->value.lval; - } - - zend_hash_index_del(ht, index); - break; - case IS_STRING: - zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1); - break; - case IS_NULL: - zend_hash_del(ht, "", sizeof("")); - break; - default: - zend_error(E_WARNING, "Illegal offset type in unset"); - break; - } - } - } else { - /* overloaded element */ - } - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); - - NEXT_OPCODE(); -} - - -int zend_fe_reset_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *array_ptr, **array_ptr_ptr; - HashTable *fe_ht; - zend_object_iterator *iter = NULL; - zend_class_entry *ce = NULL; - - if (opline->extended_value) { - array_ptr_ptr = get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - if (array_ptr_ptr == NULL) { - MAKE_STD_ZVAL(array_ptr); - } else if (Z_TYPE_PP(array_ptr_ptr) == IS_OBJECT) { - ce = Z_OBJCE_PP(array_ptr_ptr); - if (!ce || ce->get_iterator == NULL) { - SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - (*array_ptr_ptr)->refcount++; - } - array_ptr = *array_ptr_ptr; - } else { - SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); - array_ptr = *array_ptr_ptr; - array_ptr->refcount++; - } - } else { - array_ptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - if (IS_TMP_FREE(free_op1)) { /* IS_TMP_VAR */ - zval *tmp; - - ALLOC_ZVAL(tmp); - *tmp = *array_ptr; - INIT_PZVAL(tmp); - array_ptr = tmp; - } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { - ce = Z_OBJCE_P(array_ptr); - } else { - array_ptr->refcount++; - } - } - - if (ce && ce->get_iterator) { - iter = ce->get_iterator(ce, array_ptr TSRMLS_CC); - - if (iter) { - array_ptr = zend_iterator_wrap(iter TSRMLS_CC); - } else { - array_ptr->refcount++; - } - } - - PZVAL_LOCK(array_ptr); - EX_T(opline->result.u.var).var.ptr = array_ptr; - EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; - - if (iter) { - iter->index = 0; - if (iter->funcs->rewind) { - iter->funcs->rewind(iter TSRMLS_CC); - } - } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) { - /* probably redundant */ - zend_hash_internal_pointer_reset(fe_ht); - } else { - zend_error(E_WARNING, "Invalid argument supplied for foreach()"); - - opline++; - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - if (opline->extended_value) { - FREE_OP_VAR_PTR(free_op1); - } else { - FREE_OP_VAR(free_op1); - } - return 0; - } - - if (opline->extended_value) { - FREE_OP_VAR_PTR(free_op1); - } else { - FREE_OP_VAR(free_op1); - } - NEXT_OPCODE(); -} - - -int zend_fe_fetch_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *array = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval **value, *key; - char *str_key; - uint str_key_len; - ulong int_key; - HashTable *fe_ht; - zend_object_iterator *iter = NULL; - int key_type; - zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY; - - PZVAL_LOCK(array); - - switch (zend_iterator_unwrap(array, &iter TSRMLS_CC)) { - default: - case ZEND_ITER_INVALID: - zend_error(E_WARNING, "Invalid argument supplied for foreach()"); - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - - case ZEND_ITER_PLAIN_OBJECT: { - char *class_name, *prop_name; - zend_object *zobj = zend_objects_get_address(array TSRMLS_CC); - - fe_ht = HASH_OF(array); - do { - if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { - /* reached end of iteration */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); - - zend_hash_move_forward(fe_ht); - } while (key_type != HASH_KEY_IS_STRING || zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS); - if (use_key) { - zend_unmangle_property_name(str_key, &class_name, &prop_name); - str_key_len = strlen(prop_name); - str_key = estrndup(prop_name, str_key_len); - str_key_len++; - } - break; - } - - case ZEND_ITER_PLAIN_ARRAY: - fe_ht = HASH_OF(array); - if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { - /* reached end of iteration */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - if (use_key) { - key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 1, NULL); - } - zend_hash_move_forward(fe_ht); - break; - - case ZEND_ITER_OBJECT: - /* !iter happens from exception */ - if (iter && iter->index++) { - /* This could cause an endless loop if index becomes zero again. - * In case that ever happens we need an additional flag. */ - iter->funcs->move_forward(iter TSRMLS_CC); - } - if (!iter || iter->funcs->valid(iter TSRMLS_CC) == FAILURE) { - /* reached end of iteration */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - iter->funcs->get_current_data(iter, &value TSRMLS_CC); - if (!value) { - /* failure in get_current_data */ - SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } - if (use_key) { - if (iter->funcs->get_current_key) { - key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); - } else { - key_type = HASH_KEY_IS_LONG; - int_key = iter->index; - } - } - - break; - } - - if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - SEPARATE_ZVAL_IF_NOT_REF(value); - (*value)->is_ref = 1; - } - - if (!use_key) { - if (opline->extended_value & ZEND_FE_FETCH_BYREF) { - EX_T(opline->result.u.var).var.ptr_ptr = value; - (*value)->refcount++; - } else { - zval *result = &EX_T(opline->result.u.var).tmp_var; - - *result = **value; - zval_copy_ctor(result); - } - } else { - zval *result = &EX_T(opline->result.u.var).tmp_var; - - (*value)->refcount++; - - array_init(result); - - zend_hash_index_update(result->value.ht, 0, value, sizeof(zval *), NULL); - - ALLOC_ZVAL(key); - INIT_PZVAL(key); - - switch (key_type) { - case HASH_KEY_IS_STRING: - key->value.str.val = str_key; - key->value.str.len = str_key_len-1; - key->type = IS_STRING; - break; - case HASH_KEY_IS_LONG: - key->value.lval = int_key; - key->type = IS_LONG; - break; - EMPTY_SWITCH_DEFAULT_CASE() - } - zend_hash_index_update(result->value.ht, 1, &key, sizeof(zval *), NULL); - } - - NEXT_OPCODE(); -} - - -int zend_jmp_no_ctor_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval *object_zval; - zend_function *constructor; - zend_free_op free_op1; - - if (opline->op1.op_type == IS_VAR) { - PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); - } - - object_zval = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - constructor = Z_OBJ_HT_P(object_zval)->get_constructor(object_zval TSRMLS_CC); - - EX(fbc_constructor) = NULL; - if (constructor == NULL) { - if(opline->op1.u.EA.type & EXT_TYPE_UNUSED) { - zval_ptr_dtor(EX_T(opline->op1.u.var).var.ptr_ptr); - } - SET_OPCODE(EX(op_array)->opcodes + opline->op2.u.opline_num); - return 0; /* CHECK_ME */ - } else { - EX(fbc_constructor) = constructor; - } - - NEXT_OPCODE(); -} - - -int zend_isset_isempty_var_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval tmp, *varname = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval **value; - zend_bool isset = 1; - HashTable *target_symbol_table; - - if (varname->type != IS_STRING) { - tmp = *varname; - zval_copy_ctor(&tmp); - convert_to_string(&tmp); - varname = &tmp; - } - - if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { - value = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 1 TSRMLS_CC); - if (!value) { - isset = 0; - } - } else { - target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); - if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &value) == FAILURE) { - isset = 0; - } - } - - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - - switch (opline->extended_value) { - case ZEND_ISSET: - if (isset && Z_TYPE_PP(value) == IS_NULL) { - EX_T(opline->result.u.var).tmp_var.value.lval = 0; - } else { - EX_T(opline->result.u.var).tmp_var.value.lval = isset; - } - break; - case ZEND_ISEMPTY: - if (!isset || !zend_is_true(*value)) { - EX_T(opline->result.u.var).tmp_var.value.lval = 1; - } else { - EX_T(opline->result.u.var).tmp_var.value.lval = 0; - } - break; - } - - if (varname == &tmp) { - zval_dtor(&tmp); - } - FREE_OP(free_op1); - - NEXT_OPCODE(); -} - - -static int zend_isset_isempty_dim_prop_obj_handler(int prop_dim, ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1, free_op2; - zval **container = get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zval *offset = get_zval_ptr(&opline->op2, EX(Ts), &free_op2, BP_VAR_R); - zval **value = NULL; - int result = 0; - long index; - - if (container) { - if ((*container)->type == IS_ARRAY) { - HashTable *ht; - int isset = 0; - - ht = (*container)->value.ht; - - switch (offset->type) { - case IS_DOUBLE: - case IS_RESOURCE: - case IS_BOOL: - case IS_LONG: - if (offset->type == IS_DOUBLE) { - index = (long) offset->value.dval; - } else { - index = offset->value.lval; - } - if (zend_hash_index_find(ht, index, (void **) &value) == SUCCESS) { - isset = 1; - } - break; - case IS_STRING: - if (zend_symtable_find(ht, offset->value.str.val, offset->value.str.len+1, (void **) &value) == SUCCESS) { - isset = 1; - } - break; - case IS_NULL: - if (zend_hash_find(ht, "", sizeof(""), (void **) &value) == SUCCESS) { - isset = 1; - } - break; - default: - zend_error(E_WARNING, "Illegal offset type in unset"); - - break; - } - - switch (opline->extended_value) { - case ZEND_ISSET: - if (isset && Z_TYPE_PP(value) == IS_NULL) { - result = 0; - } else { - result = isset; - } - break; - case ZEND_ISEMPTY: - if (!isset || !zend_is_true(*value)) { - result = 0; - } else { - result = 1; - } - break; - } - } else if ((*container)->type == IS_OBJECT) { - if (prop_dim) { - result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); - } else { - result = Z_OBJ_HT_P(*container)->has_dimension(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); - } - } else if ((*container)->type == IS_STRING) { /* string offsets */ - switch (opline->extended_value) { - case ZEND_ISSET: - if (offset->value.lval < Z_STRLEN_PP(container)) { - result = 1; - } - break; - case ZEND_ISEMPTY: - if (offset->value.lval < Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] != '0') { - result = 1; - } - break; - } - } - } - - EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; - - switch (opline->extended_value) { - case ZEND_ISSET: - EX_T(opline->result.u.var).tmp_var.value.lval = result; - break; - case ZEND_ISEMPTY: - EX_T(opline->result.u.var).tmp_var.value.lval = !result; - break; - } - - FREE_OP(free_op2); - FREE_OP_VAR_PTR(free_op1); - - NEXT_OPCODE(); -} - - -int zend_isset_isempty_dim_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_isset_isempty_dim_prop_obj_handler(0, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - - -int zend_isset_isempty_prop_obj_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - return zend_isset_isempty_dim_prop_obj_handler(1, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU); -} - -int zend_exit_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (opline->op1.op_type != IS_UNUSED) { - zval *ptr; - zend_free_op free_op1; - - ptr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - if (Z_TYPE_P(ptr) == IS_LONG) { - EG(exit_status) = Z_LVAL_P(ptr); - } else { - zend_print_variable(ptr); - } - FREE_OP(free_op1); - } - zend_bailout(); - NEXT_OPCODE(); -} - - -int zend_begin_silence_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); - EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); - NEXT_OPCODE(); -} - - -int zend_raise_abstract_error_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_error(E_ERROR, "Cannot call abstract method %s::%s()", EG(scope)->name, EX(op_array)->function_name); - NEXT_OPCODE(); /* Never reached */ -} - - -int zend_end_silence_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zval restored_error_reporting; - - if (!EG(error_reporting)) { - restored_error_reporting.type = IS_LONG; - restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; - convert_to_string(&restored_error_reporting); - zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); - zendi_zval_dtor(restored_error_reporting); - } - NEXT_OPCODE(); -} - - -int zend_qm_assign_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *value = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - - EX_T(opline->result.u.var).tmp_var = *value; - if (!IS_TMP_FREE(free_op1)) { - zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); - } - FREE_OP_VAR(free_op1); - NEXT_OPCODE(); -} - - -int zend_ext_stmt_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - if (!EG(no_extensions)) { - zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_statement_handler, EX(op_array) TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_ext_fcall_begin_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - if (!EG(no_extensions)) { - zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_begin_handler, EX(op_array) TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_ext_fcall_end_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - if (!EG(no_extensions)) { - zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_end_handler, EX(op_array) TSRMLS_CC); - } - NEXT_OPCODE(); -} - - -int zend_declare_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).class_entry = do_bind_class(opline, EG(class_table), 0 TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_declare_inherited_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - EX_T(opline->result.u.var).class_entry = do_bind_inherited_class(opline, EG(class_table), EX_T(opline->extended_value).class_entry, 0 TSRMLS_CC); - NEXT_OPCODE(); -} - - -int zend_declare_function_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - do_bind_function(EX(opline), EG(function_table), 0); - NEXT_OPCODE(); -} - - -int zend_ticks_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - - if (++EG(ticks_count)>=opline->op1.u.constant.value.lval) { - EG(ticks_count)=0; - if (zend_ticks_function) { - zend_ticks_function(opline->op1.u.constant.value.lval); - } - } - NEXT_OPCODE(); -} - - -int zend_instanceof_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_free_op free_op1; - zval *expr = get_zval_ptr(&opline->op1, EX(Ts), &free_op1, BP_VAR_R); - zend_bool result; - - if (Z_TYPE_P(expr) == IS_OBJECT) { - result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.u.var).class_entry TSRMLS_CC); - } else { - result = 0; - } - ZVAL_BOOL(&EX_T(opline->result.u.var).tmp_var, result); - FREE_OP(free_op1); - NEXT_OPCODE(); -} - - -int zend_ext_nop_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - NEXT_OPCODE(); -} - - -int zend_nop_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - NEXT_OPCODE(); -} - -int zend_add_interface_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_op *opline = EX(opline); - zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry; - zend_class_entry *iface = EX_T(opline->op2.u.var).class_entry; - - if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) { - zend_error(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name); - } - - ce->interfaces[opline->extended_value] = iface; - - zend_do_implement_interface(ce, iface TSRMLS_CC); - - NEXT_OPCODE(); -} - - -int zend_handle_exception_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes; - int i; - int encapsulating_block=-1; - zval **stack_zval_pp; - - stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; - while (*stack_zval_pp != NULL) { - zval_ptr_dtor(stack_zval_pp); - EG(argument_stack).top_element--; - stack_zval_pp--; - } - - for (i=0; i<EG(active_op_array)->last_try_catch; i++) { - if (EG(active_op_array)->try_catch_array[i].try_op > op_num) { - /* further blocks will not be relevant... */ - break; - } - if (op_num >= EG(active_op_array)->try_catch_array[i].try_op - && op_num < EG(active_op_array)->try_catch_array[i].catch_op) { - encapsulating_block = i; - } - } - - if (encapsulating_block == -1) { - RETURN_FROM_EXECUTE_LOOP(execute_data); - } else { - SET_OPCODE(&EX(op_array)->opcodes[EG(active_op_array)->try_catch_array[encapsulating_block].catch_op]); - return 0; - } -} - - -int zend_verify_abstract_class_handler(ZEND_OPCODE_HANDLER_ARGS) -{ - zend_verify_abstract_class(EX_T(EX(opline)->op1.u.var).class_entry TSRMLS_CC); - NEXT_OPCODE(); -} - - -void zend_init_opcodes_handlers() -{ - memset(zend_opcode_handlers, sizeof(zend_opcode_handlers), 0); - zend_opcode_handlers[ZEND_NOP] = zend_nop_handler; - zend_opcode_handlers[ZEND_ADD] = zend_add_handler; - zend_opcode_handlers[ZEND_SUB] = zend_sub_handler; - zend_opcode_handlers[ZEND_MUL] = zend_mul_handler; - zend_opcode_handlers[ZEND_DIV] = zend_div_handler; - zend_opcode_handlers[ZEND_MOD] = zend_mod_handler; - zend_opcode_handlers[ZEND_SL] = zend_sl_handler; - zend_opcode_handlers[ZEND_SR] = zend_sr_handler; - zend_opcode_handlers[ZEND_CONCAT] = zend_concat_handler; - zend_opcode_handlers[ZEND_BW_OR] = zend_bw_or_handler; - zend_opcode_handlers[ZEND_BW_AND] = zend_bw_and_handler; - zend_opcode_handlers[ZEND_BW_XOR] = zend_bw_xor_handler; - zend_opcode_handlers[ZEND_BW_NOT] = zend_bw_not_handler; - zend_opcode_handlers[ZEND_BOOL_NOT] = zend_bool_not_handler; - zend_opcode_handlers[ZEND_BOOL_XOR] = zend_bool_xor_handler; - zend_opcode_handlers[ZEND_IS_IDENTICAL] = zend_is_identical_handler; - zend_opcode_handlers[ZEND_IS_NOT_IDENTICAL] = zend_is_not_identical_handler; - zend_opcode_handlers[ZEND_IS_EQUAL] = zend_is_equal_handler; - zend_opcode_handlers[ZEND_IS_NOT_EQUAL] = zend_is_not_equal_handler; - zend_opcode_handlers[ZEND_IS_SMALLER] = zend_is_smaller_handler; - zend_opcode_handlers[ZEND_IS_SMALLER_OR_EQUAL] = zend_is_smaller_or_equal_handler; - zend_opcode_handlers[ZEND_CAST] = zend_cast_handler; - zend_opcode_handlers[ZEND_QM_ASSIGN] = zend_qm_assign_handler; - - zend_opcode_handlers[ZEND_ASSIGN_ADD] = zend_assign_add_handler; - zend_opcode_handlers[ZEND_ASSIGN_SUB] = zend_assign_sub_handler; - zend_opcode_handlers[ZEND_ASSIGN_MUL] = zend_assign_mul_handler; - zend_opcode_handlers[ZEND_ASSIGN_DIV] = zend_assign_div_handler; - zend_opcode_handlers[ZEND_ASSIGN_MOD] = zend_assign_mod_handler; - zend_opcode_handlers[ZEND_ASSIGN_SL] = zend_assign_sl_handler; - zend_opcode_handlers[ZEND_ASSIGN_SR] = zend_assign_sr_handler; - zend_opcode_handlers[ZEND_ASSIGN_CONCAT] = zend_assign_concat_handler; - zend_opcode_handlers[ZEND_ASSIGN_BW_OR] = zend_assign_bw_or_handler; - zend_opcode_handlers[ZEND_ASSIGN_BW_AND] = zend_assign_bw_and_handler; - zend_opcode_handlers[ZEND_ASSIGN_BW_XOR] = zend_assign_bw_xor_handler; - - zend_opcode_handlers[ZEND_PRE_INC] = zend_pre_inc_handler; - zend_opcode_handlers[ZEND_PRE_DEC] = zend_pre_dec_handler; - zend_opcode_handlers[ZEND_POST_INC] = zend_post_inc_handler; - zend_opcode_handlers[ZEND_POST_DEC] = zend_post_dec_handler; - - zend_opcode_handlers[ZEND_ASSIGN] = zend_assign_handler; - zend_opcode_handlers[ZEND_ASSIGN_REF] = zend_assign_ref_handler; - - zend_opcode_handlers[ZEND_ECHO] = zend_echo_handler; - zend_opcode_handlers[ZEND_PRINT] = zend_print_handler; - - zend_opcode_handlers[ZEND_JMP] = zend_jmp_handler; - zend_opcode_handlers[ZEND_JMPZ] = zend_jmpz_handler; - zend_opcode_handlers[ZEND_JMPNZ] = zend_jmpnz_handler; - zend_opcode_handlers[ZEND_JMPZNZ] = zend_jmpznz_handler; - zend_opcode_handlers[ZEND_JMPZ_EX] = zend_jmpz_ex_handler; - zend_opcode_handlers[ZEND_JMPNZ_EX] = zend_jmpnz_ex_handler; - zend_opcode_handlers[ZEND_CASE] = zend_case_handler; - zend_opcode_handlers[ZEND_SWITCH_FREE] = zend_switch_free_handler; - zend_opcode_handlers[ZEND_BRK] = zend_brk_handler; - zend_opcode_handlers[ZEND_CONT] = zend_cont_handler; - zend_opcode_handlers[ZEND_BOOL] = zend_bool_handler; - - zend_opcode_handlers[ZEND_INIT_STRING] = zend_init_string_handler; - zend_opcode_handlers[ZEND_ADD_CHAR] = zend_add_char_handler; - zend_opcode_handlers[ZEND_ADD_STRING] = zend_add_string_handler; - zend_opcode_handlers[ZEND_ADD_VAR] = zend_add_var_handler; - - zend_opcode_handlers[ZEND_BEGIN_SILENCE] = zend_begin_silence_handler; - zend_opcode_handlers[ZEND_END_SILENCE] = zend_end_silence_handler; - - zend_opcode_handlers[ZEND_INIT_FCALL_BY_NAME] = zend_init_fcall_by_name_handler; - zend_opcode_handlers[ZEND_DO_FCALL] = zend_do_fcall_handler; - zend_opcode_handlers[ZEND_DO_FCALL_BY_NAME] = zend_do_fcall_by_name_handler; - zend_opcode_handlers[ZEND_RETURN] = zend_return_handler; - - zend_opcode_handlers[ZEND_RECV] = zend_recv_handler; - zend_opcode_handlers[ZEND_RECV_INIT] = zend_recv_init_handler; - - zend_opcode_handlers[ZEND_SEND_VAL] = zend_send_val_handler; - zend_opcode_handlers[ZEND_SEND_VAR] = zend_send_var_handler; - zend_opcode_handlers[ZEND_SEND_REF] = zend_send_ref_handler; - - zend_opcode_handlers[ZEND_NEW] = zend_new_handler; - zend_opcode_handlers[ZEND_JMP_NO_CTOR] = zend_jmp_no_ctor_handler; - zend_opcode_handlers[ZEND_FREE] = zend_free_handler; - - zend_opcode_handlers[ZEND_INIT_ARRAY] = zend_init_array_handler; - zend_opcode_handlers[ZEND_ADD_ARRAY_ELEMENT] = zend_add_array_element_handler; - - zend_opcode_handlers[ZEND_INCLUDE_OR_EVAL] = zend_include_or_eval_handler; - - zend_opcode_handlers[ZEND_UNSET_VAR] = zend_unset_var_handler; - zend_opcode_handlers[ZEND_UNSET_DIM_OBJ] = zend_unset_dim_obj_handler; - - zend_opcode_handlers[ZEND_FE_RESET] = zend_fe_reset_handler; - zend_opcode_handlers[ZEND_FE_FETCH] = zend_fe_fetch_handler; - - zend_opcode_handlers[ZEND_EXIT] = zend_exit_handler; - - zend_opcode_handlers[ZEND_FETCH_R] = zend_fetch_r_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_R] = zend_fetch_dim_r_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_R] = zend_fetch_obj_r_handler; - zend_opcode_handlers[ZEND_FETCH_W] = zend_fetch_w_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_W] = zend_fetch_dim_w_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_W] = zend_fetch_obj_w_handler; - zend_opcode_handlers[ZEND_FETCH_RW] = zend_fetch_rw_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_RW] = zend_fetch_dim_rw_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_RW] = zend_fetch_obj_rw_handler; - zend_opcode_handlers[ZEND_FETCH_IS] = zend_fetch_is_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_IS] = zend_fetch_dim_is_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_IS] = zend_fetch_obj_is_handler; - zend_opcode_handlers[ZEND_FETCH_FUNC_ARG] = zend_fetch_func_arg_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_FUNC_ARG] = zend_fetch_dim_func_arg_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_FUNC_ARG] = zend_fetch_obj_func_arg_handler; - zend_opcode_handlers[ZEND_FETCH_UNSET] = zend_fetch_unset_handler; - zend_opcode_handlers[ZEND_FETCH_DIM_UNSET] = zend_fetch_dim_unset_handler; - zend_opcode_handlers[ZEND_FETCH_OBJ_UNSET] = zend_fetch_obj_unset_handler; - - zend_opcode_handlers[ZEND_FETCH_DIM_TMP_VAR] = zend_fetch_dim_tmp_var_handler; - zend_opcode_handlers[ZEND_FETCH_CONSTANT] = zend_fetch_constant_handler; - - zend_opcode_handlers[ZEND_EXT_STMT] = zend_ext_stmt_handler; - zend_opcode_handlers[ZEND_EXT_FCALL_BEGIN] = zend_ext_fcall_begin_handler; - zend_opcode_handlers[ZEND_EXT_FCALL_END] = zend_ext_fcall_end_handler; - zend_opcode_handlers[ZEND_EXT_NOP] = zend_ext_nop_handler; - - zend_opcode_handlers[ZEND_TICKS] = zend_ticks_handler; - - zend_opcode_handlers[ZEND_SEND_VAR_NO_REF] = zend_send_var_no_ref_handler; - - zend_opcode_handlers[ZEND_CATCH] = zend_catch_handler; - zend_opcode_handlers[ZEND_THROW] = zend_throw_handler; - - zend_opcode_handlers[ZEND_FETCH_CLASS] = zend_fetch_class_handler; - - zend_opcode_handlers[ZEND_CLONE] = zend_clone_handler; - - zend_opcode_handlers[ZEND_INIT_CTOR_CALL] = zend_init_ctor_call_handler; - zend_opcode_handlers[ZEND_INIT_METHOD_CALL] = zend_init_method_call_handler; - zend_opcode_handlers[ZEND_INIT_STATIC_METHOD_CALL] = zend_init_static_method_call_handler; - - zend_opcode_handlers[ZEND_ISSET_ISEMPTY_VAR] = zend_isset_isempty_var_handler; - zend_opcode_handlers[ZEND_ISSET_ISEMPTY_DIM_OBJ] = zend_isset_isempty_dim_obj_handler; - zend_opcode_handlers[ZEND_ISSET_ISEMPTY_PROP_OBJ] = zend_isset_isempty_prop_obj_handler; - - zend_opcode_handlers[ZEND_PRE_INC_OBJ] = zend_pre_inc_obj_handler; - zend_opcode_handlers[ZEND_PRE_DEC_OBJ] = zend_pre_dec_obj_handler; - zend_opcode_handlers[ZEND_POST_INC_OBJ] = zend_post_inc_obj_handler; - zend_opcode_handlers[ZEND_POST_DEC_OBJ] = zend_post_dec_obj_handler; - - zend_opcode_handlers[ZEND_ASSIGN_OBJ] = zend_assign_obj_handler; - zend_opcode_handlers[ZEND_OP_DATA] = NULL; - - zend_opcode_handlers[ZEND_INSTANCEOF] = zend_instanceof_handler; - - zend_opcode_handlers[ZEND_DECLARE_CLASS] = zend_declare_class_handler; - zend_opcode_handlers[ZEND_DECLARE_INHERITED_CLASS] = zend_declare_inherited_class_handler; - zend_opcode_handlers[ZEND_DECLARE_FUNCTION] = zend_declare_function_handler; - - zend_opcode_handlers[ZEND_RAISE_ABSTRACT_ERROR] = zend_raise_abstract_error_handler; - - zend_opcode_handlers[ZEND_ADD_INTERFACE] = zend_add_interface_handler; - zend_opcode_handlers[ZEND_VERIFY_ABSTRACT_CLASS] = zend_verify_abstract_class_handler; - - zend_opcode_handlers[ZEND_ASSIGN_DIM] = zend_assign_dim_handler; - - zend_opcode_handlers[ZEND_HANDLE_EXCEPTION] = zend_handle_exception_handler; +#if ZEND_VM_KIND == ZEND_VM_KIND_GOTO + TSRMLS_FETCH(); + zend_execute(NULL TSRMLS_CC); +#else + static const opcode_handler_t labels[] = {ZEND_VM_LABELS}; + zend_opcode_handlers = (opcode_handler_t*)labels; +#endif } /* http://cvs.php.net/diff.php/ZendEngine2/zend_execute.h?r1=1.73&r2=1.74&ty=u Index: ZendEngine2/zend_execute.h diff -u ZendEngine2/zend_execute.h:1.73 ZendEngine2/zend_execute.h:1.74 --- ZendEngine2/zend_execute.h:1.73 Sun Jul 25 03:14:25 2004 +++ ZendEngine2/zend_execute.h Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute.h,v 1.73 2004/07/25 07:14:25 helly Exp $ */ +/* $Id: zend_execute.h,v 1.74 2004/09/08 22:14:12 andi Exp $ */ #ifndef ZEND_EXECUTE_H #define ZEND_EXECUTE_H @@ -166,8 +166,6 @@ #define zendi_zval_dtor(p) zval_dtor(&(p)) #define active_opline (*EG(opline_ptr)) - -void zend_assign_to_variable_reference(znode *result, zval **variable_ptr_ptr, zval **value_ptr_ptr, temp_variable *Ts TSRMLS_DC); /* The following tries to resolve the classname of a zval of type object. * Since it is slow it should be only used in error messages. http://cvs.php.net/diff.php/ZendEngine2/zend_execute_API.c?r1=1.293&r2=1.294&ty=u Index: ZendEngine2/zend_execute_API.c diff -u ZendEngine2/zend_execute_API.c:1.293 ZendEngine2/zend_execute_API.c:1.294 --- ZendEngine2/zend_execute_API.c:1.293 Mon Aug 23 16:57:40 2004 +++ ZendEngine2/zend_execute_API.c Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_execute_API.c,v 1.293 2004/08/23 20:57:40 helly Exp $ */ +/* $Id: zend_execute_API.c,v 1.294 2004/09/08 22:14:12 andi Exp $ */ #include <stdio.h> #include <signal.h> @@ -30,6 +30,7 @@ #include "zend_constants.h" #include "zend_extensions.h" #include "zend_exceptions.h" +#include "zend_vm.h" #ifdef HAVE_SYS_TIME_H #include <sys/time.h> #endif @@ -1073,7 +1074,7 @@ opline->op2.u.constant.is_ref = 1; opline->op2.u.constant.refcount = 2; } - opline->handler = zend_opcode_handlers[opline->opcode]; + ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; } http://cvs.php.net/diff.php/ZendEngine2/zend_opcode.c?r1=1.105&r2=1.106&ty=u Index: ZendEngine2/zend_opcode.c diff -u ZendEngine2/zend_opcode.c:1.105 ZendEngine2/zend_opcode.c:1.106 --- ZendEngine2/zend_opcode.c:1.105 Thu Jul 29 13:45:31 2004 +++ ZendEngine2/zend_opcode.c Wed Sep 8 18:14:12 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_opcode.c,v 1.105 2004/07/29 17:45:31 pollita Exp $ */ +/* $Id: zend_opcode.c,v 1.106 2004/09/08 22:14:12 andi Exp $ */ #include <stdio.h> @@ -27,6 +27,8 @@ #include "zend_extensions.h" #include "zend_API.h" +#include "zend_vm.h" + static void zend_extension_op_array_ctor_handler(zend_extension *extension, zend_op_array *op_array TSRMLS_DC) { if (extension->op_array_ctor) { @@ -361,7 +363,7 @@ opline->op2.u.jmp_addr = &op_array->opcodes[opline->op2.u.opline_num]; break; } - opline->handler = zend_opcode_handlers[opline->opcode]; + ZEND_VM_SET_OPCODE_HANDLER(opline); opline++; } http://cvs.php.net/co.php/ZendEngine2/zend_vm.h?r=1.1&p=1 Index: ZendEngine2/zend_vm.h +++ ZendEngine2/zend_vm.h /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ | Copyright (c) 1998-2004 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 | | 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 | | obtain it through the world-wide-web, please send a note to | | license@zend.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ /* $Id: zend_vm.h,v 1.1 2004/09/08 22:14:12 andi Exp $ */ #ifndef ZEND_VM_H #define ZEND_VM_H #define ZEND_VM_KIND_CALL 1 #define ZEND_VM_KIND_SWITCH 2 #define ZEND_VM_KIND_GOTO 3 /* #define ZEND_VM_KIND ZEND_VM_KIND_CALL */ #define ZEND_VM_SPEC /* don't edit the rest of the file */ #define _CONST_CODE 0 #define _TMP_CODE 1 #define _VAR_CODE 2 #define _UNUSED_CODE 3 #ifndef ZEND_VM_KIND # ifdef __GNUC__ # define ZEND_VM_KIND ZEND_VM_KIND_GOTO # else # define ZEND_VM_KIND ZEND_VM_KIND_SWITCH # endif #endif #if defined(__GNUC__) && !defined(__INTEL_COMPILER) # define ZEND_VM_ALWAYS_INLINE __attribute__ ((always_inline)) void zend_error_noreturn(int type, const char *format, ...) __attribute__ ((alias("zend_error"),noreturn)); /*extern void zend_error_noreturn(int type, const char *format, ...) __asm__("zend_error") __attribute__ ((noreturn));*/ #else # define ZEND_VM_ALWAYS_INLINE # define zend_error_noreturn zend_error #endif #ifndef ZEND_VM_SPEC # define ZEND_VM_CODE(opcode, op1, op2) opcode # define ZEND_VM_SPEC_OPCODE(opcode, op1, op2) opcode # define ZEND_VM_SET_OPCODE_HANDLER(opline) \ opline->handler = zend_opcode_handlers[opline->opcode]; #else static const int zend_vm_decode[] = { _UNUSED_CODE, /* 0 */ _CONST_CODE, /* 1 = IS_CONST */ _TMP_CODE, /* 2 = IS_TMP_VAR */ _UNUSED_CODE, /* 3 */ _VAR_CODE, /* 4 = IS_VAR */ _UNUSED_CODE, /* 5 */ _UNUSED_CODE, /* 6 */ _UNUSED_CODE, /* 7 */ _UNUSED_CODE /* 8 = IS_UNUSED */ }; # define ZEND_VM_CODE(opcode, op1, op2) \ opcode * 16 + op1 * 4 + op2 # define ZEND_VM_SPEC_OPCODE(opcode, op1, op2) \ ZEND_VM_CODE(opcode, zend_vm_decode[op1], zend_vm_decode[op2]) # define ZEND_VM_SET_OPCODE_HANDLER(opline) \ opline->handler = zend_opcode_handlers[ZEND_VM_SPEC_OPCODE(opline->opcode, opline->op1.op_type, opline->op2.op_type)] #endif #if ZEND_VM_KIND == ZEND_VM_KIND_CALL # define EXECUTE_DATA execute_data # define ZEND_VM_HELPER_VAR(X) # define ZEND_VM_DISPATCH() \ if (EX(opline)->handler(&execute_data TSRMLS_CC) > 0) # define ZEND_VM_CONTINUE_LABEL # define ZEND_VM_HANDLER(OP) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_HANDLER_EX(OP) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_HELPER(NAME) \ static int NAME(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_HELPER_EX(NAME,PARAM) \ static int NAME(PARAM, ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HANDLER(OP, CODE) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \ static int OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HELPER(NAME) \ static int NAME(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \ static int NAME(PARAM, ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_NULL_HANDLER() \ int ZEND_VM_NULL(ZEND_OPCODE_HANDLER_ARGS) # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ return OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_DISPATCH_TO_HELPER(NAME) \ return NAME(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ return NAME(VAL, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \ return OP##_HANDLER(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \ return NAME(ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ return NAME(VAL, ZEND_OPCODE_HANDLER_ARGS_PASSTHRU) # define ZEND_VM_CONTINUE() \ return 0 # define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ return 0 # define ZEND_VM_SET_OPCODE(new_op) \ CHECK_SYMBOL_TABLES() \ EX(opline) = new_op # define ZEND_VM_INC_OPCODE() \ if (!EG(exception)) { \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ } # define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ free_alloca(EX(Ts)); \ } else { \ efree(EX(Ts)); \ } \ EG(in_execution) = EX(original_in_execution); \ EG(current_execute_data) = EX(prev_execute_data); \ return 1; # define ZEND_VM_LABEL(OP) OP##_HANDLER # define ZEND_VM_NULL_LABEL ZEND_VM_NULL # define ZEND_VM_SPEC_LABEL(OP,CODE) OP##_HANDLER # define ZEND_VM_SPEC_NULL_LABEL ZEND_VM_NULL #elif ZEND_VM_KIND == ZEND_VM_KIND_SWITCH # define EXECUTE_DATA &execute_data # define ZEND_VM_HELPER_VAR(X) X; # define ZEND_VM_DISPATCH() \ switch ((int)EX(opline)->handler) # define ZEND_VM_CONTINUE_LABEL \ zend_vm_continue: # define ZEND_VM_HANDLER(OP) \ case OP: # define ZEND_VM_HANDLER_EX(OP) \ case OP: \ OP##_LABEL: # define ZEND_VM_HELPER(NAME) \ NAME: # define ZEND_VM_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_SPEC_HANDLER(OP, CODE) \ case CODE: # define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \ case CODE: \ OP##_LABEL: # define ZEND_VM_SPEC_HELPER(NAME) \ NAME: # define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_NULL_HANDLER() \ default: # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ goto OP##_LABEL # define ZEND_VM_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \ goto OP##_LABEL # define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_CONTINUE() \ goto zend_vm_continue # define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ ZEND_VM_CONTINUE() # define ZEND_VM_SET_OPCODE(new_op) \ CHECK_SYMBOL_TABLES() \ EX(opline) = new_op # define ZEND_VM_INC_OPCODE() \ if (!EG(exception)) { \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ } # define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ free_alloca(EX(Ts)); \ } else { \ efree(EX(Ts)); \ } \ EG(in_execution) = EX(original_in_execution); \ EG(current_execute_data) = EX(prev_execute_data); \ return; # define ZEND_VM_LABEL(OP) (opcode_handler_t)OP # define ZEND_VM_NULL_LABEL (opcode_handler_t)-1 # define ZEND_VM_SPEC_LABEL(OP,CODE) (opcode_handler_t)(CODE) # define ZEND_VM_SPEC_NULL_LABEL (opcode_handler_t)-1 #elif ZEND_VM_KIND == ZEND_VM_KIND_GOTO # define EXECUTE_DATA &execute_data # define ZEND_VM_HELPER_VAR(X) X; # define ZEND_VM_DISPATCH() \ goto *(void**)(EX(opline)->handler); # define ZEND_VM_CONTINUE_LABEL # define ZEND_VM_HANDLER(OP) \ OP##_HANDLER: # define ZEND_VM_HANDLER_EX(OP) \ OP##_HANDLER: # define ZEND_VM_HELPER(NAME) \ NAME: # define ZEND_VM_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_SPEC_HANDLER(OP, CODE) \ OP##_HANDLER: # define ZEND_VM_SPEC_HANDLER_EX(OP, CODE) \ OP##_HANDLER: # define ZEND_VM_SPEC_HELPER(NAME) \ NAME: # define ZEND_VM_SPEC_HELPER_EX(NAME,PARAM) \ NAME: # define ZEND_VM_NULL_HANDLER() \ ZEND_VM_NULL: # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ goto OP##_HANDLER # define ZEND_VM_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP) \ goto OP##_HANDLER # define ZEND_VM_SPEC_DISPATCH_TO_HELPER(NAME) \ goto NAME # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(NAME,VAR,VAL) \ VAR = VAL; \ goto NAME # define ZEND_VM_CONTINUE() \ goto *(void**)(EX(opline)->handler) # define ZEND_VM_NEXT_OPCODE() \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ ZEND_VM_CONTINUE() # define ZEND_VM_SET_OPCODE(new_op) \ CHECK_SYMBOL_TABLES() \ EX(opline) = new_op # define ZEND_VM_INC_OPCODE() \ if (!EG(exception)) { \ CHECK_SYMBOL_TABLES() \ EX(opline)++; \ } # define ZEND_VM_RETURN_FROM_EXECUTE_LOOP() \ if (EX(op_array)->T < TEMP_VAR_STACK_LIMIT) { \ free_alloca(EX(Ts)); \ } else { \ efree(EX(Ts)); \ } \ EG(in_execution) = EX(original_in_execution); \ EG(current_execute_data) = EX(prev_execute_data); \ return; # define ZEND_VM_LABEL(OP) (opcode_handler_t)&&OP##_HANDLER # define ZEND_VM_NULL_LABEL &&ZEND_VM_NULL # define ZEND_VM_SPEC_LABEL(OP,CODE) (opcode_handler_t)&&OP##_HANDLER # define ZEND_VM_SPEC_NULL_LABEL &&ZEND_VM_NULL #else # error "Unknown ZEND_VM_KIND" #endif #define ZEND_VM_CONTINUE_JMP() ZEND_VM_CONTINUE() #endif http://cvs.php.net/co.php/ZendEngine2/zend_vm_handlers.h?r=1.1&p=1 Index: ZendEngine2/zend_vm_handlers.h +++ ZendEngine2/zend_vm_handlers.h /* Don't edit the following defines. They are the part of opcode specializer */ #undef OP1_TYPE_PREFIX #if OP1 == IS_CONST # define OP1_TYPE_PREFIX _CONST #elif OP1 == IS_TMP_VAR # define OP1_TYPE_PREFIX _TMP #elif OP1 == IS_VAR # define OP1_TYPE_PREFIX _VAR #elif OP1 == IS_UNUSED # define OP1_TYPE_PREFIX _UNUSED #elif OP1 == IS_ANY # define OP1_TYPE_PREFIX _ANY #else # error "Wrong OP1_TYPE!" #endif #undef OP2_TYPE_PREFIX #if OP2 == IS_CONST # define OP2_TYPE_PREFIX _CONST #elif OP2 == IS_TMP_VAR # define OP2_TYPE_PREFIX _TMP #elif OP2 == IS_VAR # define OP2_TYPE_PREFIX _VAR #elif OP2 == IS_UNUSED # define OP2_TYPE_PREFIX _UNUSED #elif OP2 == IS_ANY # define OP2_TYPE_PREFIX _ANY #else # error "Wrong OP2_TYPE!" #endif /* ordered list of opcode handlers */ #define ZEND_VM_LABELS \ ZEND_VM_LABEL(ZEND_NOP), /* 0 */ \ ZEND_VM_LABEL(ZEND_ADD), /* 1 */ \ ZEND_VM_LABEL(ZEND_SUB), /* 2 */ \ ZEND_VM_LABEL(ZEND_MUL), /* 3 */ \ ZEND_VM_LABEL(ZEND_DIV), /* 4 */ \ ZEND_VM_LABEL(ZEND_MOD), /* 5 */ \ ZEND_VM_LABEL(ZEND_SL), /* 6 */ \ ZEND_VM_LABEL(ZEND_SR), /* 7 */ \ ZEND_VM_LABEL(ZEND_CONCAT), /* 8 */ \ ZEND_VM_LABEL(ZEND_BW_OR), /* 9 */ \ ZEND_VM_LABEL(ZEND_BW_AND), /* 10 */ \ ZEND_VM_LABEL(ZEND_BW_XOR), /* 11 */ \ ZEND_VM_LABEL(ZEND_BW_NOT), /* 12 */ \ ZEND_VM_LABEL(ZEND_BOOL_NOT), /* 13 */ \ ZEND_VM_LABEL(ZEND_BOOL_XOR), /* 14 */ \ ZEND_VM_LABEL(ZEND_IS_IDENTICAL), /* 15 */ \ ZEND_VM_LABEL(ZEND_IS_NOT_IDENTICAL), /* 16 */ \ ZEND_VM_LABEL(ZEND_IS_EQUAL), /* 17 */ \ ZEND_VM_LABEL(ZEND_IS_NOT_EQUAL), /* 18 */ \ ZEND_VM_LABEL(ZEND_IS_SMALLER), /* 19 */ \ ZEND_VM_LABEL(ZEND_IS_SMALLER_OR_EQUAL), /* 20 */ \ ZEND_VM_LABEL(ZEND_CAST), /* 21 */ \ ZEND_VM_LABEL(ZEND_QM_ASSIGN), /* 22 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_ADD), /* 23 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_SUB), /* 24 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_MUL), /* 25 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_DIV), /* 26 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_MOD), /* 27 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_SL), /* 28 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_SR), /* 29 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_CONCAT), /* 30 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_BW_OR), /* 31 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_BW_AND), /* 32 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_BW_XOR), /* 33 */ \ ZEND_VM_LABEL(ZEND_PRE_INC), /* 34 */ \ ZEND_VM_LABEL(ZEND_PRE_DEC), /* 35 */ \ ZEND_VM_LABEL(ZEND_POST_INC), /* 36 */ \ ZEND_VM_LABEL(ZEND_POST_DEC), /* 37 */ \ ZEND_VM_LABEL(ZEND_ASSIGN), /* 38 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_REF), /* 39 */ \ ZEND_VM_LABEL(ZEND_ECHO), /* 40 */ \ ZEND_VM_LABEL(ZEND_PRINT), /* 41 */ \ ZEND_VM_LABEL(ZEND_JMP), /* 42 */ \ ZEND_VM_LABEL(ZEND_JMPZ), /* 43 */ \ ZEND_VM_LABEL(ZEND_JMPNZ), /* 44 */ \ ZEND_VM_LABEL(ZEND_JMPZNZ), /* 45 */ \ ZEND_VM_LABEL(ZEND_JMPZ_EX), /* 46 */ \ ZEND_VM_LABEL(ZEND_JMPNZ_EX), /* 47 */ \ ZEND_VM_LABEL(ZEND_CASE), /* 48 */ \ ZEND_VM_LABEL(ZEND_SWITCH_FREE), /* 49 */ \ ZEND_VM_LABEL(ZEND_BRK), /* 50 */ \ ZEND_VM_LABEL(ZEND_CONT), /* 51 */ \ ZEND_VM_LABEL(ZEND_BOOL), /* 52 */ \ ZEND_VM_LABEL(ZEND_INIT_STRING), /* 53 */ \ ZEND_VM_LABEL(ZEND_ADD_CHAR), /* 54 */ \ ZEND_VM_LABEL(ZEND_ADD_STRING), /* 55 */ \ ZEND_VM_LABEL(ZEND_ADD_VAR), /* 56 */ \ ZEND_VM_LABEL(ZEND_BEGIN_SILENCE), /* 57 */ \ ZEND_VM_LABEL(ZEND_END_SILENCE), /* 58 */ \ ZEND_VM_LABEL(ZEND_INIT_FCALL_BY_NAME), /* 59 */ \ ZEND_VM_LABEL(ZEND_DO_FCALL), /* 60 */ \ ZEND_VM_LABEL(ZEND_DO_FCALL_BY_NAME), /* 61 */ \ ZEND_VM_LABEL(ZEND_RETURN), /* 62 */ \ ZEND_VM_LABEL(ZEND_RECV), /* 63 */ \ ZEND_VM_LABEL(ZEND_RECV_INIT), /* 64 */ \ ZEND_VM_LABEL(ZEND_SEND_VAL), /* 65 */ \ ZEND_VM_LABEL(ZEND_SEND_VAR), /* 66 */ \ ZEND_VM_LABEL(ZEND_SEND_REF), /* 67 */ \ ZEND_VM_LABEL(ZEND_NEW), /* 68 */ \ ZEND_VM_LABEL(ZEND_JMP_NO_CTOR), /* 69 */ \ ZEND_VM_LABEL(ZEND_FREE), /* 70 */ \ ZEND_VM_LABEL(ZEND_INIT_ARRAY), /* 71 */ \ ZEND_VM_LABEL(ZEND_ADD_ARRAY_ELEMENT), /* 72 */ \ ZEND_VM_LABEL(ZEND_INCLUDE_OR_EVAL), /* 73 */ \ ZEND_VM_LABEL(ZEND_UNSET_VAR), /* 74 */ \ ZEND_VM_LABEL(ZEND_UNSET_DIM_OBJ), /* 75 */ \ ZEND_VM_NULL_LABEL, /* 76 */ \ ZEND_VM_LABEL(ZEND_FE_RESET), /* 77 */ \ ZEND_VM_LABEL(ZEND_FE_FETCH), /* 78 */ \ ZEND_VM_LABEL(ZEND_EXIT), /* 79 */ \ ZEND_VM_LABEL(ZEND_FETCH_R), /* 80 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_R), /* 81 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_R), /* 82 */ \ ZEND_VM_LABEL(ZEND_FETCH_W), /* 83 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_W), /* 84 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_W), /* 85 */ \ ZEND_VM_LABEL(ZEND_FETCH_RW), /* 86 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_RW), /* 87 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_RW), /* 88 */ \ ZEND_VM_LABEL(ZEND_FETCH_IS), /* 89 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_IS), /* 90 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_IS), /* 91 */ \ ZEND_VM_LABEL(ZEND_FETCH_FUNC_ARG), /* 92 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_FUNC_ARG), /* 93 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_FUNC_ARG), /* 94 */ \ ZEND_VM_LABEL(ZEND_FETCH_UNSET), /* 95 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_UNSET), /* 96 */ \ ZEND_VM_LABEL(ZEND_FETCH_OBJ_UNSET), /* 97 */ \ ZEND_VM_LABEL(ZEND_FETCH_DIM_TMP_VAR), /* 98 */ \ ZEND_VM_LABEL(ZEND_FETCH_CONSTANT), /* 99 */ \ ZEND_VM_NULL_LABEL, /* 100 */ \ ZEND_VM_LABEL(ZEND_EXT_STMT), /* 101 */ \ ZEND_VM_LABEL(ZEND_EXT_FCALL_BEGIN), /* 102 */ \ ZEND_VM_LABEL(ZEND_EXT_FCALL_END), /* 103 */ \ ZEND_VM_LABEL(ZEND_EXT_NOP), /* 104 */ \ ZEND_VM_LABEL(ZEND_TICKS), /* 105 */ \ ZEND_VM_LABEL(ZEND_SEND_VAR_NO_REF), /* 106 */ \ ZEND_VM_LABEL(ZEND_CATCH), /* 107 */ \ ZEND_VM_LABEL(ZEND_THROW), /* 108 */ \ ZEND_VM_LABEL(ZEND_FETCH_CLASS), /* 109 */ \ ZEND_VM_LABEL(ZEND_CLONE), /* 110 */ \ ZEND_VM_LABEL(ZEND_INIT_CTOR_CALL), /* 111 */ \ ZEND_VM_LABEL(ZEND_INIT_METHOD_CALL), /* 112 */ \ ZEND_VM_LABEL(ZEND_INIT_STATIC_METHOD_CALL), /* 113 */ \ ZEND_VM_LABEL(ZEND_ISSET_ISEMPTY_VAR), /* 114 */ \ ZEND_VM_LABEL(ZEND_ISSET_ISEMPTY_DIM_OBJ), /* 115 */ \ ZEND_VM_NULL_LABEL, /* 116 */ \ ZEND_VM_NULL_LABEL, /* 117 */ \ ZEND_VM_NULL_LABEL, /* 118 */ \ ZEND_VM_NULL_LABEL, /* 119 */ \ ZEND_VM_NULL_LABEL, /* 120 */ \ ZEND_VM_NULL_LABEL, /* 121 */ \ ZEND_VM_NULL_LABEL, /* 122 */ \ ZEND_VM_NULL_LABEL, /* 123 */ \ ZEND_VM_NULL_LABEL, /* 124 */ \ ZEND_VM_NULL_LABEL, /* 125 */ \ ZEND_VM_NULL_LABEL, /* 126 */ \ ZEND_VM_NULL_LABEL, /* 127 */ \ ZEND_VM_NULL_LABEL, /* 128 */ \ ZEND_VM_NULL_LABEL, /* 129 */ \ ZEND_VM_NULL_LABEL, /* 130 */ \ ZEND_VM_NULL_LABEL, /* 131 */ \ ZEND_VM_LABEL(ZEND_PRE_INC_OBJ), /* 132 */ \ ZEND_VM_LABEL(ZEND_PRE_DEC_OBJ), /* 133 */ \ ZEND_VM_LABEL(ZEND_POST_INC_OBJ), /* 134 */ \ ZEND_VM_LABEL(ZEND_POST_DEC_OBJ), /* 135 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_OBJ), /* 136 */ \ ZEND_VM_NULL_LABEL, /* 137 */ \ ZEND_VM_LABEL(ZEND_INSTANCEOF), /* 138 */ \ ZEND_VM_LABEL(ZEND_DECLARE_CLASS), /* 139 */ \ ZEND_VM_LABEL(ZEND_DECLARE_INHERITED_CLASS), /* 140 */ \ ZEND_VM_LABEL(ZEND_DECLARE_FUNCTION), /* 141 */ \ ZEND_VM_LABEL(ZEND_RAISE_ABSTRACT_ERROR), /* 142 */ \ ZEND_VM_NULL_LABEL, /* 143 */ \ ZEND_VM_LABEL(ZEND_ADD_INTERFACE), /* 144 */ \ ZEND_VM_NULL_LABEL, /* 145 */ \ ZEND_VM_LABEL(ZEND_VERIFY_ABSTRACT_CLASS), /* 146 */ \ ZEND_VM_LABEL(ZEND_ASSIGN_DIM), /* 147 */ \ ZEND_VM_LABEL(ZEND_ISSET_ISEMPTY_PROP_OBJ), /* 148 */ \ ZEND_VM_LABEL(ZEND_HANDLE_EXCEPTION), /* 149 */ \ ZEND_VM_NULL_LABEL /* opcode handlers and helpers */ #define ZEND_ADD_SPEC() OPDEF(ZEND_ADD, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ADD) ZEND_VM_HANDLER(ZEND_ADD) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; add_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SUB_SPEC() OPDEF(ZEND_SUB, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_SUB) ZEND_VM_HANDLER(ZEND_SUB) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; sub_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_MUL_SPEC() OPDEF(ZEND_MUL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_MUL) ZEND_VM_HANDLER(ZEND_MUL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; mul_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DIV_SPEC() OPDEF(ZEND_DIV, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_DIV) ZEND_VM_HANDLER(ZEND_DIV) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; div_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_MOD_SPEC() OPDEF(ZEND_MOD, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_MOD) ZEND_VM_HANDLER(ZEND_MOD) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; mod_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SL_SPEC() OPDEF(ZEND_SL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_SL) ZEND_VM_HANDLER(ZEND_SL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; shift_left_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SR_SPEC() OPDEF(ZEND_SR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_SR) ZEND_VM_HANDLER(ZEND_SR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; shift_right_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_CONCAT_SPEC() OPDEF(ZEND_CONCAT, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_CONCAT) ZEND_VM_HANDLER(ZEND_CONCAT) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; concat_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_IDENTICAL_SPEC() OPDEF(ZEND_IS_IDENTICAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_IDENTICAL) ZEND_VM_HANDLER(ZEND_IS_IDENTICAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_identical_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_NOT_IDENTICAL_SPEC() OPDEF(ZEND_IS_NOT_IDENTICAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_NOT_IDENTICAL) ZEND_VM_HANDLER(ZEND_IS_NOT_IDENTICAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_not_identical_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_EQUAL_SPEC() OPDEF(ZEND_IS_EQUAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_EQUAL) ZEND_VM_HANDLER(ZEND_IS_EQUAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_NOT_EQUAL_SPEC() OPDEF(ZEND_IS_NOT_EQUAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_NOT_EQUAL) ZEND_VM_HANDLER(ZEND_IS_NOT_EQUAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_not_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_SMALLER_SPEC() OPDEF(ZEND_IS_SMALLER, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_SMALLER) ZEND_VM_HANDLER(ZEND_IS_SMALLER) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_smaller_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_IS_SMALLER_OR_EQUAL_SPEC() OPDEF(ZEND_IS_SMALLER_OR_EQUAL, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_IS_SMALLER_OR_EQUAL) ZEND_VM_HANDLER(ZEND_IS_SMALLER_OR_EQUAL) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; is_smaller_or_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_OR_SPEC() OPDEF(ZEND_BW_OR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BW_OR) ZEND_VM_HANDLER(ZEND_BW_OR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; bitwise_or_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_AND_SPEC() OPDEF(ZEND_BW_AND, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BW_AND) ZEND_VM_HANDLER(ZEND_BW_AND) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; bitwise_and_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_XOR_SPEC() OPDEF(ZEND_BW_XOR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BW_XOR) ZEND_VM_HANDLER(ZEND_BW_XOR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; bitwise_xor_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BOOL_XOR_SPEC() OPDEF(ZEND_BOOL_XOR, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BOOL_XOR) ZEND_VM_HANDLER(ZEND_BOOL_XOR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; boolean_xor_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BW_NOT_SPEC() OPDEF(ZEND_BW_NOT, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_BW_NOT) ZEND_VM_HANDLER(ZEND_BW_NOT) { zend_op *opline = EX(opline); zend_free_op free_op1; bitwise_not_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BOOL_NOT_SPEC() OPDEF(ZEND_BOOL_NOT, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_BOOL_NOT) ZEND_VM_HANDLER(ZEND_BOOL_NOT) { zend_op *opline = EX(opline); zend_free_op free_op1; boolean_not_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_binary_assign_op_obj_helper, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC)) { zend_op *opline = EX(opline); zend_op *op_data = opline+1; zend_free_op free_op1, free_op2, free_op_data1; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); zval *value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); zval tmp; znode *result = &opline->result; zval **retval = &EX_T(result->u.var).var.ptr; int have_get_ptr = 0; EX_T(result->u.var).var.ptr_ptr = NULL; make_real_object(object_ptr TSRMLS_CC); object = *object_ptr; if (object->type != IS_OBJECT) { zend_error(E_WARNING, "Attempt to assign property of non-object"); FREE_OP2(); FREE_OP(free_op_data1); if (!RETURN_VALUE_UNUSED(result)) { *retval = EG(uninitialized_zval_ptr); PZVAL_LOCK(*retval); } } else { /* here we are sure we are dealing with an object */ switch (OP2_TYPE) { case IS_CONST: /* already a constant string */ break; case IS_VAR: tmp = *property; zval_copy_ctor(&tmp); convert_to_string(&tmp); property = &tmp; break; case IS_TMP_VAR: convert_to_string(property); break; } /* here property is a string */ if (opline->extended_value == ZEND_ASSIGN_OBJ && Z_OBJ_HT_P(object)->get_property_ptr_ptr) { zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ SEPARATE_ZVAL_IF_NOT_REF(zptr); have_get_ptr = 1; binary_op(*zptr, *zptr, value TSRMLS_CC); if (!RETURN_VALUE_UNUSED(result)) { *retval = *zptr; PZVAL_LOCK(*retval); } } } if (!have_get_ptr) { zval *z; switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); break; case ZEND_ASSIGN_DIM: z = Z_OBJ_HT_P(object)->read_dimension(object, property, BP_VAR_RW TSRMLS_CC); break; } if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); if (z->refcount == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } z->refcount++; SEPARATE_ZVAL_IF_NOT_REF(&z); binary_op(z, z, value TSRMLS_CC); switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); break; case ZEND_ASSIGN_DIM: Z_OBJ_HT_P(object)->write_dimension(object, property, z TSRMLS_CC); break; } if (!RETURN_VALUE_UNUSED(result)) { *retval = z; PZVAL_LOCK(*retval); } zval_ptr_dtor(&z); } if (property == &tmp) { zval_dtor(property); } FREE_OP2(); FREE_OP(free_op_data1); } FREE_OP1_VAR_PTR(); /* assign_obj has two opcodes! */ ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } ZEND_VM_HELPER_EX(zend_binary_assign_op_helper, int (*binary_op)(zval *result, zval *op1, zval *op2 TSRMLS_DC)) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2, free_op_data2, free_op_data1; zval **var_ptr; zval *value; zend_bool increment_opline = 0; switch (opline->extended_value) { case ZEND_ASSIGN_OBJ: ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_obj_helper, binary_op, binary_op); break; case ZEND_ASSIGN_DIM: { zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ if ((*object_ptr)->type == IS_OBJECT) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_obj_helper, binary_op, binary_op); } else { zend_op *op_data = opline+1; zend_fetch_dimension_address(&EX_T(op_data->op2.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_RW TSRMLS_CC); value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); var_ptr = get_zval_ptr_ptr(&op_data->op2, EX(Ts), &free_op_data2, BP_VAR_RW); increment_opline = 1; } } break; default: value = GET_OP2_ZVAL_PTR(BP_VAR_R); var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); /* do nothing */ break; } if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot use assign-op operators with overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP2(); FREE_OP1_VAR_PTR(); if (increment_opline) { ZEND_VM_INC_OPCODE(); } ZEND_VM_NEXT_OPCODE(); } SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *objval = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); objval->refcount++; binary_op(objval, objval, value TSRMLS_CC); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, objval TSRMLS_CC); zval_ptr_dtor(&objval); } else { binary_op(*var_ptr, *var_ptr, value TSRMLS_CC); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; PZVAL_LOCK(*var_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP2(); if (increment_opline) { ZEND_VM_INC_OPCODE(); FREE_OP_VAR_PTR(free_op_data2); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_ADD_SPEC() OPDEF(ZEND_ASSIGN_ADD, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_ADD) ZEND_VM_HANDLER(ZEND_ASSIGN_ADD) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, add_function); } #endif #define ZEND_ASSIGN_SUB_SPEC() OPDEF(ZEND_ASSIGN_SUB, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_SUB) ZEND_VM_HANDLER(ZEND_ASSIGN_SUB) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, sub_function); } #endif #define ZEND_ASSIGN_MUL_SPEC() OPDEF(ZEND_ASSIGN_MUL, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_MUL) ZEND_VM_HANDLER(ZEND_ASSIGN_MUL) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, mul_function); } #endif #define ZEND_ASSIGN_DIV_SPEC() OPDEF(ZEND_ASSIGN_DIV, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_DIV) ZEND_VM_HANDLER(ZEND_ASSIGN_DIV) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, div_function); } #endif #define ZEND_ASSIGN_MOD_SPEC() OPDEF(ZEND_ASSIGN_MOD, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_MOD) ZEND_VM_HANDLER(ZEND_ASSIGN_MOD) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, mod_function); } #endif #define ZEND_ASSIGN_SL_SPEC() OPDEF(ZEND_ASSIGN_SL, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_SL) ZEND_VM_HANDLER(ZEND_ASSIGN_SL) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, shift_left_function); } #endif #define ZEND_ASSIGN_SR_SPEC() OPDEF(ZEND_ASSIGN_SR, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_SR) ZEND_VM_HANDLER(ZEND_ASSIGN_SR) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, shift_right_function); } #endif #define ZEND_ASSIGN_CONCAT_SPEC() OPDEF(ZEND_ASSIGN_CONCAT, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_CONCAT) ZEND_VM_HANDLER(ZEND_ASSIGN_CONCAT) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, concat_function); } #endif #define ZEND_ASSIGN_BW_OR_SPEC() OPDEF(ZEND_ASSIGN_BW_OR, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_BW_OR) ZEND_VM_HANDLER(ZEND_ASSIGN_BW_OR) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, bitwise_or_function); } #endif #define ZEND_ASSIGN_BW_AND_SPEC() OPDEF(ZEND_ASSIGN_BW_AND, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_BW_AND) ZEND_VM_HANDLER(ZEND_ASSIGN_BW_AND) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, bitwise_and_function); } #endif #define ZEND_ASSIGN_BW_XOR_SPEC() OPDEF(ZEND_ASSIGN_BW_XOR, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_BW_XOR) ZEND_VM_HANDLER(ZEND_ASSIGN_BW_XOR) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_binary_assign_op_helper, binary_op, bitwise_xor_function); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_pre_incdec_property_helper, incdec_t incdec_op) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); zval **retval = &EX_T(opline->result.u.var).var.ptr; int have_get_ptr = 0; make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ object = *object_ptr; if (object->type != IS_OBJECT) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); FREE_OP2(); if (!RETURN_VALUE_UNUSED(&opline->result)) { *retval = EG(uninitialized_zval_ptr); PZVAL_LOCK(*retval); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } /* here we are sure we are dealing with an object */ if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ SEPARATE_ZVAL_IF_NOT_REF(zptr); have_get_ptr = 1; incdec_op(*zptr); if (!RETURN_VALUE_UNUSED(&opline->result)) { *retval = *zptr; PZVAL_LOCK(*retval); } } } if (!have_get_ptr) { zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); if (z->refcount == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } z->refcount++; SEPARATE_ZVAL_IF_NOT_REF(&z); incdec_op(z); *retval = z; Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); SELECTIVE_PZVAL_LOCK(*retval, &opline->result); zval_ptr_dtor(&z); } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_PRE_INC_OBJ_SPEC() OPDEF(ZEND_PRE_INC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_PRE_INC_OBJ) ZEND_VM_HANDLER(ZEND_PRE_INC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_pre_incdec_property_helper, incdec_op, increment_function); } #endif #define ZEND_PRE_DEC_OBJ_SPEC() OPDEF(ZEND_PRE_DEC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_PRE_DEC_OBJ) ZEND_VM_HANDLER(ZEND_PRE_DEC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_pre_incdec_property_helper, incdec_op, decrement_function); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_post_incdec_property_helper, incdec_t incdec_op) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zval *object; zval *property = GET_OP2_ZVAL_PTR(BP_VAR_R); zval *retval = &EX_T(opline->result.u.var).tmp_var; int have_get_ptr = 0; make_real_object(object_ptr TSRMLS_CC); /* this should modify object only if it's empty */ object = *object_ptr; if (object->type != IS_OBJECT) { zend_error(E_WARNING, "Attempt to increment/decrement property of non-object"); FREE_OP2(); *retval = *EG(uninitialized_zval_ptr); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } /* here we are sure we are dealing with an object */ if (Z_OBJ_HT_P(object)->get_property_ptr_ptr) { zval **zptr = Z_OBJ_HT_P(object)->get_property_ptr_ptr(object, property TSRMLS_CC); if (zptr != NULL) { /* NULL means no success in getting PTR */ have_get_ptr = 1; SEPARATE_ZVAL_IF_NOT_REF(zptr); *retval = **zptr; zendi_zval_copy_ctor(*retval); incdec_op(*zptr); } } if (!have_get_ptr) { zval *z = Z_OBJ_HT_P(object)->read_property(object, property, BP_VAR_RW TSRMLS_CC); if (z->type == IS_OBJECT && Z_OBJ_HT_P(z)->get) { zval *value = Z_OBJ_HT_P(z)->get(z TSRMLS_CC); if (z->refcount == 0) { zval_dtor(z); FREE_ZVAL(z); } z = value; } *retval = *z; zendi_zval_copy_ctor(*retval); incdec_op(z); z->refcount++; Z_OBJ_HT_P(object)->write_property(object, property, z TSRMLS_CC); zval_ptr_dtor(&z); } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_POST_INC_OBJ_SPEC() OPDEF(ZEND_POST_INC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_POST_INC_OBJ) ZEND_VM_HANDLER(ZEND_POST_INC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_post_incdec_property_helper, incdec_op, increment_function); } #endif #define ZEND_POST_DEC_OBJ_SPEC() OPDEF(ZEND_POST_DEC_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_POST_DEC_OBJ) ZEND_VM_HANDLER(ZEND_POST_DEC_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_post_incdec_property_helper, incdec_op, decrement_function); } #endif #define ZEND_PRE_INC_SPEC() OPDEF(ZEND_PRE_INC, M_VAR, M_ANY) #if HAVE_OP(ZEND_PRE_INC) ZEND_VM_HANDLER(ZEND_PRE_INC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { increment_function(*var_ptr); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; PZVAL_LOCK(*var_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_PRE_DEC_SPEC() OPDEF(ZEND_PRE_DEC, M_VAR, M_ANY) #if HAVE_OP(ZEND_PRE_DEC) ZEND_VM_HANDLER(ZEND_PRE_DEC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { decrement_function(*var_ptr); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = var_ptr; PZVAL_LOCK(*var_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_POST_INC_SPEC() OPDEF(ZEND_POST_INC, M_VAR, M_ANY) #if HAVE_OP(ZEND_POST_INC) ZEND_VM_HANDLER(ZEND_POST_INC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } EX_T(opline->result.u.var).tmp_var = **var_ptr; zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; increment_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { increment_function(*var_ptr); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_POST_DEC_SPEC() OPDEF(ZEND_POST_DEC, M_VAR, M_ANY) #if HAVE_OP(ZEND_POST_DEC) ZEND_VM_HANDLER(ZEND_POST_DEC) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **var_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW); if (!var_ptr) { zend_error_noreturn(E_ERROR, "Cannot increment/decrement overloaded objects nor string offsets"); } if (*var_ptr == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } EX_T(opline->result.u.var).tmp_var = **var_ptr; zendi_zval_copy_ctor(EX_T(opline->result.u.var).tmp_var); SEPARATE_ZVAL_IF_NOT_REF(var_ptr); if(Z_TYPE_PP(var_ptr) == IS_OBJECT && Z_OBJ_HANDLER_PP(var_ptr, get) && Z_OBJ_HANDLER_PP(var_ptr, set)) { /* proxy object */ zval *val = Z_OBJ_HANDLER_PP(var_ptr, get)(*var_ptr TSRMLS_CC); val->refcount++; decrement_function(val); Z_OBJ_HANDLER_PP(var_ptr, set)(var_ptr, val TSRMLS_CC); zval_ptr_dtor(&val); } else { decrement_function(*var_ptr); } FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ECHO_SPEC() OPDEF(ZEND_ECHO, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_ECHO) ZEND_VM_HANDLER_EX(ZEND_ECHO) { zend_op *opline = EX(opline); zend_free_op free_op1; zval z_copy; zval *z = GET_OP1_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(z) == IS_OBJECT && Z_OBJ_HT_P(z)->get_method != NULL && zend_std_cast_object_tostring(z, &z_copy, IS_STRING, 0 TSRMLS_CC) == SUCCESS) { zend_print_variable(&z_copy); zval_dtor(&z_copy); } else { zend_print_variable(z); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_PRINT_SPEC() OPDEF(ZEND_PRINT, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_PRINT) ZEND_VM_HANDLER(ZEND_PRINT) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).tmp_var.value.lval = 1; EX_T(opline->result.u.var).tmp_var.type = IS_LONG; ZEND_VM_DISPATCH_TO_HANDLER(ZEND_ECHO); } #endif #if OP1_OP2_MASK(M_CONST_TMP_VAR, M_ANY) ZEND_VM_HELPER_EX(zend_fetch_var_address_helper, int type) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *varname = GET_OP1_ZVAL_PTR(BP_VAR_R); zval **retval; zval tmp_varname; HashTable *target_symbol_table; if (varname->type != IS_STRING) { tmp_varname = *varname; zval_copy_ctor(&tmp_varname); convert_to_string(&tmp_varname); varname = &tmp_varname; } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { retval = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 0 TSRMLS_CC); } else { if (opline->op2.u.EA.type == ZEND_FETCH_GLOBAL && opline->op1.op_type == IS_VAR) { varname->refcount++; } target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), type, varname TSRMLS_CC); /* if (!target_symbol_table) { ZEND_VM_NEXT_OPCODE(); } */ if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &retval) == FAILURE) { switch (type) { case BP_VAR_R: case BP_VAR_UNSET: zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); /* break missing intentionally */ case BP_VAR_IS: retval = &EG(uninitialized_zval_ptr); break; case BP_VAR_RW: zend_error(E_NOTICE,"Undefined variable: %s", varname->value.str.val); /* break missing intentionally */ case BP_VAR_W: { zval *new_zval = &EG(uninitialized_zval); new_zval->refcount++; zend_hash_update(target_symbol_table, varname->value.str.val, varname->value.str.len+1, &new_zval, sizeof(zval *), (void **) &retval); } break; EMPTY_SWITCH_DEFAULT_CASE() } } switch (opline->op2.u.EA.type) { case ZEND_FETCH_LOCAL: FREE_OP1(); break; case ZEND_FETCH_STATIC: zval_update_constant(retval, (void*) 1 TSRMLS_CC); break; } } if (varname == &tmp_varname) { zval_dtor(varname); } if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = retval; PZVAL_LOCK(*retval); switch (type) { case BP_VAR_R: case BP_VAR_IS: AI_USE_PTR(EX_T(opline->result.u.var).var); break; case BP_VAR_UNSET: { zend_free_op free_res; PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); } PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); FREE_OP_VAR_PTR(free_res); break; } } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_R_SPEC() OPDEF(ZEND_FETCH_R, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_R) ZEND_VM_HANDLER(ZEND_FETCH_R) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_R); } #endif #define ZEND_FETCH_W_SPEC() OPDEF(ZEND_FETCH_W, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_W) ZEND_VM_HANDLER(ZEND_FETCH_W) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_W); } #endif #define ZEND_FETCH_RW_SPEC() OPDEF(ZEND_FETCH_RW, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_RW) ZEND_VM_HANDLER(ZEND_FETCH_RW) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_RW); } #endif #define ZEND_FETCH_FUNC_ARG_SPEC() OPDEF(ZEND_FETCH_FUNC_ARG, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_FUNC_ARG) ZEND_VM_HANDLER(ZEND_FETCH_FUNC_ARG) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), EX(opline)->extended_value)?BP_VAR_W:BP_VAR_R); } #endif #define ZEND_FETCH_UNSET_SPEC() OPDEF(ZEND_FETCH_UNSET, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_UNSET) ZEND_VM_HANDLER(ZEND_FETCH_UNSET) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_UNSET); } #endif #define ZEND_FETCH_IS_SPEC() OPDEF(ZEND_FETCH_IS, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FETCH_IS) ZEND_VM_HANDLER(ZEND_FETCH_IS) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_var_address_helper, type, BP_VAR_IS); } #endif #define ZEND_FETCH_DIM_R_SPEC() OPDEF(ZEND_FETCH_DIM_R, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_R) ZEND_VM_HANDLER(ZEND_FETCH_DIM_R) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); } zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_R TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_W_SPEC() OPDEF(ZEND_FETCH_DIM_W, M_VAR, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_FETCH_DIM_W) ZEND_VM_HANDLER(ZEND_FETCH_DIM_W) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_W TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_RW_SPEC() OPDEF(ZEND_FETCH_DIM_RW, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_RW) ZEND_VM_HANDLER(ZEND_FETCH_DIM_RW) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_RW TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_IS_SPEC() OPDEF(ZEND_FETCH_DIM_IS, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_IS) ZEND_VM_HANDLER(ZEND_FETCH_DIM_IS) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_IS TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_FUNC_ARG_SPEC() OPDEF(ZEND_FETCH_DIM_FUNC_ARG, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_FUNC_ARG) ZEND_VM_HANDLER(ZEND_FETCH_DIM_FUNC_ARG) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; int type = ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)?BP_VAR_W:BP_VAR_R; zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(type), GET_OP2_ZVAL_PTR(BP_VAR_R), type TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_UNSET_SPEC() OPDEF(ZEND_FETCH_DIM_UNSET, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_DIM_UNSET) ZEND_VM_HANDLER(ZEND_FETCH_DIM_UNSET) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; /* Not needed in DIM_UNSET if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); } */ zend_fetch_dimension_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_UNSET), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_UNSET TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); if (EX_T(opline->result.u.var).var.ptr_ptr == NULL) { zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); } else { zend_free_op free_res; PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); } PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); FREE_OP_VAR_PTR(free_res); } ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_fetch_property_address_read_helper, int type) { zend_op *opline = EX(opline); zval *container; zval **retval; zend_free_op free_op1; retval = &EX_T(opline->result.u.var).var.ptr; EX_T(opline->result.u.var).var.ptr_ptr = retval; container = GET_OP1_OBJ_ZVAL_PTR(type); if (container == EG(error_zval_ptr)) { if (!RETURN_VALUE_UNUSED(&opline->result)) { *retval = EG(error_zval_ptr); PZVAL_LOCK(*retval); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } if (container->type != IS_OBJECT) { zend_error(E_NOTICE, "Trying to get property of non-object"); *retval = EG(uninitialized_zval_ptr); } else { zend_free_op free_op2; zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); zval tmp; switch (OP2_TYPE) { case IS_CONST: /* already a constant string */ break; case IS_VAR: tmp = *offset; zval_copy_ctor(&tmp); convert_to_string(&tmp); offset = &tmp; break; case IS_TMP_VAR: convert_to_string(offset); break; } /* here we are sure we are dealing with an object */ *retval = Z_OBJ_HT_P(container)->read_property(container, offset, type TSRMLS_CC); if (offset == &tmp) { zval_dtor(offset); } FREE_OP2(); if (RETURN_VALUE_UNUSED(&opline->result) && ((*retval)->refcount == 0)) { zval_dtor(*retval); FREE_ZVAL(*retval); ZEND_VM_NEXT_OPCODE(); } } SELECTIVE_PZVAL_LOCK(*retval, &opline->result); AI_USE_PTR(EX_T(opline->result.u.var).var); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_OBJ_R_SPEC() OPDEF(ZEND_FETCH_OBJ_R, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_R) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_R) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_property_address_read_helper, type, BP_VAR_R); } #endif #define ZEND_FETCH_OBJ_W_SPEC() OPDEF(ZEND_FETCH_OBJ_W, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_W) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_W) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; if (opline->extended_value == ZEND_FETCH_ADD_LOCK) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); EX_T(opline->op1.u.var).var.ptr = *EX_T(opline->op1.u.var).var.ptr_ptr; } zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_W TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_OBJ_RW_SPEC() OPDEF(ZEND_FETCH_OBJ_RW, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_RW) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_RW) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_RW), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_RW TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_OBJ_IS_SPEC() OPDEF(ZEND_FETCH_OBJ_IS, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_IS) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_IS) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_property_address_read_helper, type, BP_VAR_IS); } #endif #define ZEND_FETCH_OBJ_FUNC_ARG_SPEC() OPDEF(ZEND_FETCH_OBJ_FUNC_ARG, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_FUNC_ARG) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_FUNC_ARG) { zend_op *opline = EX(opline); if (ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->extended_value)) { /* Behave like FETCH_OBJ_W */ zend_free_op free_op1, free_op2; zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_W TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } else { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_fetch_property_address_read_helper, type, BP_VAR_R); } } #endif #define ZEND_FETCH_OBJ_UNSET_SPEC() OPDEF(ZEND_FETCH_OBJ_UNSET, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_FETCH_OBJ_UNSET) ZEND_VM_HANDLER(ZEND_FETCH_OBJ_UNSET) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2, free_res; zend_fetch_property_address(RETURN_VALUE_UNUSED(&opline->result)?NULL:&EX_T(opline->result.u.var), GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R), OP2_TYPE, BP_VAR_R TSRMLS_CC); FREE_OP2(); FREE_OP1_VAR_PTR(); PZVAL_UNLOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &free_res); if (EX_T(opline->result.u.var).var.ptr_ptr != &EG(uninitialized_zval_ptr)) { SEPARATE_ZVAL_IF_NOT_REF(EX_T(opline->result.u.var).var.ptr_ptr); } PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); FREE_OP_VAR_PTR(free_res); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_DIM_TMP_VAR_SPEC() OPDEF(ZEND_FETCH_DIM_TMP_VAR, M_TMP, M_CONST) #if HAVE_OP(ZEND_FETCH_DIM_TMP_VAR) ZEND_VM_HANDLER(ZEND_FETCH_DIM_TMP_VAR) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *container = GET_OP1_ZVAL_PTR(BP_VAR_R); if (container->type != IS_ARRAY) { if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = &EG(uninitialized_zval_ptr); PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr); } } else { zend_free_op free_op2; zval *dim = GET_OP2_ZVAL_PTR(BP_VAR_R); EX_T(opline->result.u.var).var.ptr_ptr = zend_fetch_dimension_address_inner(container->value.ht, dim, BP_VAR_R TSRMLS_CC); SELECTIVE_PZVAL_LOCK(*EX_T(opline->result.u.var).var.ptr_ptr, &opline->result); FREE_OP2(); } AI_USE_PTR(EX_T(opline->result.u.var).var); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_OBJ_SPEC() OPDEF(ZEND_ASSIGN_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN_OBJ) ZEND_VM_HANDLER(ZEND_ASSIGN_OBJ) { zend_op *opline = EX(opline); zend_op *op_data = opline+1; zend_free_op free_op1; zval **object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_OBJ TSRMLS_CC); FREE_OP1_VAR_PTR(); /* assign_obj has two opcodes! */ ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_DIM_SPEC() OPDEF(ZEND_ASSIGN_DIM, M_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_ASSIGN_DIM) ZEND_VM_HANDLER(ZEND_ASSIGN_DIM) { zend_op *opline = EX(opline); zend_op *op_data = opline+1; zend_free_op free_op1; zval **object_ptr; if (EX_T(opline->op1.u.var).var.ptr_ptr) { /* not an array offset */ object_ptr = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_W); } else { object_ptr = NULL; } if (object_ptr && (*object_ptr)->type == IS_OBJECT) { zend_assign_to_object(&opline->result, object_ptr, &opline->op2, &op_data->op1, EX(Ts), ZEND_ASSIGN_DIM TSRMLS_CC); } else { zend_free_op free_op2, free_op_data1; zval *value; if (object_ptr) { (*object_ptr)->refcount++; /* undo the effect of get_obj_zval_ptr_ptr() */ } zend_fetch_dimension_address(&EX_T(op_data->op2.u.var), GET_OP1_ZVAL_PTR_PTR(BP_VAR_W), GET_OP2_ZVAL_PTR(BP_VAR_R), BP_VAR_W TSRMLS_CC); FREE_OP2(); value = get_zval_ptr(&op_data->op1, EX(Ts), &free_op_data1, BP_VAR_R); zend_assign_to_variable(&opline->result, &op_data->op2, &op_data->op1, value, (IS_TMP_FREE(free_op_data1)?IS_TMP_VAR:op_data->op1.op_type), EX(Ts) TSRMLS_CC); FREE_OP_IF_VAR(free_op_data1); } FREE_OP1_VAR_PTR(); /* assign_dim has two opcodes! */ ZEND_VM_INC_OPCODE(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_SPEC() OPDEF(ZEND_ASSIGN, M_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ASSIGN) ZEND_VM_HANDLER(ZEND_ASSIGN) { zend_op *opline = EX(opline); zend_free_op free_op2; zval *value = GET_OP2_ZVAL_PTR(BP_VAR_R); zend_assign_to_variable(&opline->result, &opline->op1, &opline->op2, value, (IS_OP2_TMP_FREE()?IS_TMP_VAR:OP2_TYPE), EX(Ts) TSRMLS_CC); /* zend_assign_to_variable() always takes care of op2, never free it! */ FREE_OP2_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ASSIGN_REF_SPEC() OPDEF(ZEND_ASSIGN_REF, M_VAR, M_VAR) #if HAVE_OP(ZEND_ASSIGN_REF) ZEND_VM_HANDLER(ZEND_ASSIGN_REF) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **variable_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); zval **value_ptr_ptr = GET_OP2_ZVAL_PTR_PTR(BP_VAR_W); zend_assign_to_variable_reference(variable_ptr_ptr, value_ptr_ptr TSRMLS_CC); if (!RETURN_VALUE_UNUSED(&opline->result)) { EX_T(opline->result.u.var).var.ptr_ptr = variable_ptr_ptr; PZVAL_LOCK(*variable_ptr_ptr); AI_USE_PTR(EX_T(opline->result.u.var).var); } FREE_OP1_VAR_PTR(); FREE_OP2_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMP_SPEC() OPDEF(ZEND_JMP, M_ANY, M_ANY) #if HAVE_OP(ZEND_JMP) ZEND_VM_HANDLER(ZEND_JMP) { #if DEBUG_ZEND>=2 printf("Jumping to %d\n", opline->op1.u.opline_num); #endif ZEND_VM_SET_OPCODE(EX(opline)->op1.u.jmp_addr); ZEND_VM_CONTINUE(); /* CHECK_ME */ } #endif #define ZEND_JMPZ_SPEC() OPDEF(ZEND_JMPZ, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPZ) ZEND_VM_HANDLER(ZEND_JMPZ) { zend_op *opline = EX(opline); zend_free_op free_op1; int ret = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); if (!ret) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMPNZ_SPEC() OPDEF(ZEND_JMPNZ, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPNZ) ZEND_VM_HANDLER(ZEND_JMPNZ) { zend_op *opline = EX(opline); zend_free_op free_op1; int ret = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); if (ret) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMPZNZ_SPEC() OPDEF(ZEND_JMPZNZ, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPZNZ) ZEND_VM_HANDLER(ZEND_JMPZNZ) { zend_op *opline = EX(opline); zend_free_op free_op1; int retval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); if (retval) { #if DEBUG_ZEND>=2 printf("Conditional jmp on true to %d\n", opline->extended_value); #endif ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); ZEND_VM_CONTINUE(); /* CHECK_ME */ } else { #if DEBUG_ZEND>=2 printf("Conditional jmp on false to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->op2.u.opline_num]); ZEND_VM_CONTINUE_JMP(); } } #endif #define ZEND_JMPZ_EX_SPEC() OPDEF(ZEND_JMPZ_EX, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPZ_EX) ZEND_VM_HANDLER(ZEND_JMPZ_EX) { zend_op *opline = EX(opline); zend_free_op free_op1; int retval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); EX_T(opline->result.u.var).tmp_var.value.lval = retval; EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; if (!retval) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMPNZ_EX_SPEC() OPDEF(ZEND_JMPNZ_EX, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMPNZ_EX) ZEND_VM_HANDLER(ZEND_JMPNZ_EX) { zend_op *opline = EX(opline); zend_free_op free_op1; int retval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); FREE_OP1(); EX_T(opline->result.u.var).tmp_var.value.lval = retval; EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; if (retval) { #if DEBUG_ZEND>=2 printf("Conditional jmp to %d\n", opline->op2.u.opline_num); #endif ZEND_VM_SET_OPCODE(opline->op2.u.jmp_addr); ZEND_VM_CONTINUE_JMP(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FREE_SPEC() OPDEF(ZEND_FREE, M_TMP, M_ANY) #if HAVE_OP(ZEND_FREE) ZEND_VM_HANDLER(ZEND_FREE) { zendi_zval_dtor(EX_T(EX(opline)->op1.u.var).tmp_var); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_STRING_SPEC() OPDEF(ZEND_INIT_STRING, M_ANY, M_ANY) #if HAVE_OP(ZEND_INIT_STRING) ZEND_VM_HANDLER(ZEND_INIT_STRING) { zval *tmp = &EX_T(EX(opline)->result.u.var).tmp_var; tmp->value.str.val = emalloc(1); tmp->value.str.val[0] = 0; tmp->value.str.len = 0; tmp->refcount = 1; tmp->type = IS_STRING; tmp->is_ref = 0; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_CHAR_SPEC() OPDEF(ZEND_ADD_CHAR, M_TMP, M_CONST) #if HAVE_OP(ZEND_ADD_CHAR) ZEND_VM_HANDLER(ZEND_ADD_CHAR) { zend_op *opline = EX(opline); zend_free_op free_op1; add_char_to_string(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_NA), &opline->op2.u.constant); /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_STRING_SPEC() OPDEF(ZEND_ADD_STRING, M_TMP, M_CONST) #if HAVE_OP(ZEND_ADD_STRING) ZEND_VM_HANDLER(ZEND_ADD_STRING) { zend_op *opline = EX(opline); zend_free_op free_op1; add_string_to_string(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_NA), &opline->op2.u.constant); /* FREE_OP is missing intentionally here - we're always working on the same temporary variable */ ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_VAR_SPEC() OPDEF(ZEND_ADD_VAR, M_TMP, M_TMP_VAR) #if HAVE_OP(ZEND_ADD_VAR) ZEND_VM_HANDLER(ZEND_ADD_VAR) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval *var = GET_OP2_ZVAL_PTR(BP_VAR_R); zval var_copy; int use_copy; zend_make_printable_zval(var, &var_copy, &use_copy); if (use_copy) { var = &var_copy; } add_string_to_string( &EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_NA), var); if (use_copy) { zval_dtor(var); } /* original comment, possibly problematic: * FREE_OP is missing intentionally here - we're always working on the same temporary variable * (Zeev): I don't think it's problematic, we only use variables * which aren't affected by FREE_OP(Ts, )'s anyway, unless they're * string offsets or overloaded objects */ FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_CLASS_SPEC() OPDEF(ZEND_FETCH_CLASS, M_ANY, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_FETCH_CLASS) ZEND_VM_HANDLER(ZEND_FETCH_CLASS) { zend_op *opline = EX(opline); zval *class_name; zend_free_op free_op2; if (OP2_TYPE == IS_UNUSED) { EX_T(opline->result.u.var).class_entry = zend_fetch_class(NULL, 0, opline->extended_value TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } class_name = GET_OP2_ZVAL_PTR(BP_VAR_R); switch (class_name->type) { case IS_OBJECT: EX_T(opline->result.u.var).class_entry = Z_OBJCE_P(class_name); break; case IS_STRING: EX_T(opline->result.u.var).class_entry = zend_fetch_class(Z_STRVAL_P(class_name), Z_STRLEN_P(class_name), ZEND_FETCH_CLASS_DEFAULT TSRMLS_CC); break; default: zend_error_noreturn(E_ERROR, "Class name must be a valid object or a string"); break; } FREE_OP2(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_CTOR_CALL_SPEC() OPDEF(ZEND_INIT_CTOR_CALL, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_INIT_CTOR_CALL) ZEND_VM_HANDLER(ZEND_INIT_CTOR_CALL) { zend_op *opline = EX(opline); zend_free_op free_op1; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); if (OP1_TYPE == IS_VAR) { SELECTIVE_PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr, &opline->op1); } /* We are not handling overloaded classes right now */ EX(object) = GET_OP1_ZVAL_PTR(BP_VAR_R); /* New always returns the object as is_ref=0, therefore, we can just increment the reference count */ EX(object)->refcount++; /* For $this pointer */ EX(fbc) = EX(fbc_constructor); if (EX(fbc)->type == ZEND_USER_FUNCTION) { /* HACK!! */ EX(calling_scope) = EX(fbc)->common.scope; } else { EX(calling_scope) = NULL; } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_METHOD_CALL_SPEC() OPDEF(ZEND_INIT_METHOD_CALL, M_TMP_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_INIT_METHOD_CALL) ZEND_VM_HANDLER(ZEND_INIT_METHOD_CALL) { zend_op *opline = EX(opline); zval *function_name; char *function_name_strval; int function_name_strlen; zend_free_op free_op1, free_op2; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name)!=IS_STRING) { zend_error_noreturn(E_ERROR, "Method name must be a string"); } function_name_strval = function_name->value.str.val; function_name_strlen = function_name->value.str.len; EX(calling_scope) = EG(scope); EX(object) = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R); if (EX(object) && EX(object)->type == IS_OBJECT) { if (Z_OBJ_HT_P(EX(object))->get_method == NULL) { zend_error_noreturn(E_ERROR, "Object does not support method calls"); } /* First, locate the function. */ EX(fbc) = Z_OBJ_HT_P(EX(object))->get_method(EX(object), function_name_strval, function_name_strlen TSRMLS_CC); if (!EX(fbc)) { zend_error_noreturn(E_ERROR, "Call to undefined method %s::%s()", Z_OBJ_CLASS_NAME_P(EX(object)), function_name_strval); } } else { zend_error_noreturn(E_ERROR, "Call to a member function %s() on a non-object", function_name_strval); } if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { if (!PZVAL_IS_REF(EX(object))) { EX(object)->refcount++; /* For $this pointer */ } else { zval *this_ptr; ALLOC_ZVAL(this_ptr); INIT_PZVAL_COPY(this_ptr, EX(object)); zval_copy_ctor(this_ptr); EX(object) = this_ptr; } } if (EX(fbc)->type == ZEND_USER_FUNCTION) { EX(calling_scope) = EX(fbc)->common.scope; } else { EX(calling_scope) = NULL; } FREE_OP2(); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_STATIC_METHOD_CALL_SPEC() OPDEF(ZEND_INIT_STATIC_METHOD_CALL, M_ANY, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_INIT_STATIC_METHOD_CALL) ZEND_VM_HANDLER(ZEND_INIT_STATIC_METHOD_CALL) { zend_op *opline = EX(opline); zval *function_name; zend_class_entry *ce; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); ce = EX_T(opline->op1.u.var).class_entry; if(OP2_TYPE != IS_UNUSED) { char *function_name_strval; int function_name_strlen; zend_bool is_const = (OP2_TYPE == IS_CONST); zend_free_op free_op2; if (is_const) { function_name_strval = opline->op2.u.constant.value.str.val; function_name_strlen = opline->op2.u.constant.value.str.len; } else { function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } function_name_strval = zend_str_tolower_dup(function_name->value.str.val, function_name->value.str.len); function_name_strlen = function_name->value.str.len; } EX(fbc) = zend_std_get_static_method(ce, function_name_strval, function_name_strlen TSRMLS_CC); if (!is_const) { efree(function_name_strval); FREE_OP2(); } } else { if(!ce->constructor) { zend_error_noreturn(E_ERROR, "Can not call constructor"); } EX(fbc) = ce->constructor; } EX(calling_scope) = EX(fbc)->common.scope; if (EX(fbc)->common.fn_flags & ZEND_ACC_STATIC) { EX(object) = NULL; } else { if ((EX(object) = EG(This))) { EX(object)->refcount++; } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_FCALL_BY_NAME_SPEC() OPDEF(ZEND_INIT_FCALL_BY_NAME, M_ANY, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_INIT_FCALL_BY_NAME) ZEND_VM_HANDLER(ZEND_INIT_FCALL_BY_NAME) { zend_op *opline = EX(opline); zval *function_name; zend_function *function; char *function_name_strval, *lcname; int function_name_strlen; zend_free_op free_op2; zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); if (OP2_TYPE == IS_CONST) { #ifndef ZEND_VM_SPEC free_op2.var = NULL; #endif function_name_strval = opline->op2.u.constant.value.str.val; function_name_strlen = opline->op2.u.constant.value.str.len; } else { function_name = GET_OP2_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(function_name) != IS_STRING) { zend_error_noreturn(E_ERROR, "Function name must be a string"); } function_name_strval = function_name->value.str.val; function_name_strlen = function_name->value.str.len; } lcname = zend_str_tolower_dup(function_name_strval, function_name_strlen); if (zend_hash_find(EG(function_table), lcname, function_name_strlen+1, (void **) &function)==FAILURE) { efree(lcname); zend_error_noreturn(E_ERROR, "Call to undefined function %s()", function_name_strval); } efree(lcname); FREE_OP2(); EX(calling_scope) = function->common.scope; EX(object) = NULL; EX(fbc) = function; ZEND_VM_NEXT_OPCODE(); } #endif #define zend_do_fcall_common_helper_CONST_ANY zend_do_fcall_common_helper_ANY_ANY #if OP1_OP2_MASK(M_ANY, M_ANY) ZEND_VM_HELPER(zend_do_fcall_common_helper) { zend_op *opline = EX(opline); zval **original_return_value; zend_class_entry *current_scope; zval *current_this; int return_value_used = RETURN_VALUE_USED(opline); zend_bool should_change_scope; if (EX(function_state).function->common.fn_flags & ZEND_ACC_ABSTRACT) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name); ZEND_VM_NEXT_OPCODE(); /* Never reached */ } zend_ptr_stack_2_push(&EG(argument_stack), (void *) opline->extended_value, NULL); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; if (EX(function_state).function->type == ZEND_USER_FUNCTION || EX(function_state).function->common.scope) { should_change_scope = 1; current_this = EG(This); EG(This) = EX(object); current_scope = EG(scope); EG(scope) = EX(calling_scope); } else { should_change_scope = 0; } EX_T(opline->result.u.var).var.fcall_returned_reference = 0; if (EX(function_state).function->common.scope) { if (!EG(This) && !(EX(function_state).function->common.fn_flags & ZEND_ACC_STATIC)) { int severity; char *severity_word; if (EX(function_state).function->common.fn_flags & ZEND_ACC_ALLOW_STATIC) { severity = E_STRICT; severity_word = "should not"; } else { severity = E_ERROR; severity_word = "cannot"; } zend_error(severity, "Non-static method %s::%s() %s be called statically", EX(function_state).function->common.scope->name, EX(function_state).function->common.function_name, severity_word); } } if (EX(function_state).function->type == ZEND_INTERNAL_FUNCTION) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); if (EX(function_state).function->common.arg_info) { zend_uint i=0; zval **p; ulong arg_count; p = (zval **) EG(argument_stack).top_element-2; arg_count = (ulong) *p; while (arg_count>0) { zend_verify_arg_type(EX(function_state).function, ++i, *(p-arg_count) TSRMLS_CC); arg_count--; } } if (!zend_execute_internal) { /* saves one function call if zend_execute_internal is not used */ ((zend_internal_function *) EX(function_state).function)->handler(opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); } else { zend_execute_internal(EXECUTE_DATA, return_value_used TSRMLS_CC); } EG(current_execute_data) = EXECUTE_DATA; EX_T(opline->result.u.var).var.ptr->is_ref = 0; EX_T(opline->result.u.var).var.ptr->refcount = 1; if (!return_value_used) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } } else if (EX(function_state).function->type == ZEND_USER_FUNCTION) { HashTable *calling_symbol_table; EX_T(opline->result.u.var).var.ptr = NULL; if (EG(symtable_cache_ptr)>=EG(symtable_cache)) { /*printf("Cache hit! Reusing %x\n", symtable_cache[symtable_cache_ptr]);*/ EX(function_state).function_symbol_table = *(EG(symtable_cache_ptr)--); } else { ALLOC_HASHTABLE(EX(function_state).function_symbol_table); zend_hash_init(EX(function_state).function_symbol_table, 0, NULL, ZVAL_PTR_DTOR, 0); /*printf("Cache miss! Initialized %x\n", function_state.function_symbol_table);*/ } calling_symbol_table = EG(active_symbol_table); EG(active_symbol_table) = EX(function_state).function_symbol_table; original_return_value = EG(return_value_ptr_ptr); EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; EG(active_op_array) = (zend_op_array *) EX(function_state).function; zend_execute(EG(active_op_array) TSRMLS_CC); EX_T(opline->result.u.var).var.fcall_returned_reference = EG(active_op_array)->return_reference; if (return_value_used && !EX_T(opline->result.u.var).var.ptr) { if (!EG(exception)) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); } } else if (!return_value_used && EX_T(opline->result.u.var).var.ptr) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); EG(return_value_ptr_ptr)=original_return_value; if (EG(symtable_cache_ptr)>=EG(symtable_cache_limit)) { zend_hash_destroy(EX(function_state).function_symbol_table); FREE_HASHTABLE(EX(function_state).function_symbol_table); } else { /* clean before putting into the cache, since clean could call dtors, which could use cached hash */ zend_hash_clean(EX(function_state).function_symbol_table); *(++EG(symtable_cache_ptr)) = EX(function_state).function_symbol_table; } EG(active_symbol_table) = calling_symbol_table; } else { /* ZEND_OVERLOADED_FUNCTION */ ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*(EX_T(opline->result.u.var).var.ptr)); /* Not sure what should be done here if it's a static method */ if (EX(object)) { Z_OBJ_HT_P(EX(object))->call_method(EX(fbc)->common.function_name, opline->extended_value, EX_T(opline->result.u.var).var.ptr, EX(object), return_value_used TSRMLS_CC); } else { zend_error_noreturn(E_ERROR, "Cannot call overloaded function for non-object"); } if (EX(function_state).function->type == ZEND_OVERLOADED_FUNCTION_TEMPORARY) { efree(EX(function_state).function->common.function_name); } efree(EX(fbc)); if (!return_value_used) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } else { EX_T(opline->result.u.var).var.ptr->is_ref = 0; EX_T(opline->result.u.var).var.ptr->refcount = 1; } } if (EG(This)) { if (EG(exception) && EX(fbc) && EX(fbc)->common.fn_flags&ZEND_ACC_CTOR) { EG(This)->refcount--; if (EG(This)->refcount == 1) { zend_object_store_ctor_failed(EG(This) TSRMLS_CC); } zval_ptr_dtor(&EG(This)); } else if (should_change_scope) { zval_ptr_dtor(&EG(This)); } } if (should_change_scope) { EG(This) = current_this; EG(scope) = current_scope; } zend_ptr_stack_3_pop(&EG(arg_types_stack), (void**)&EX(calling_scope), (void**)&EX(object), (void**)&EX(fbc)); EX(function_state).function = (zend_function *) EX(op_array); EG(function_state_ptr) = &EX(function_state); zend_ptr_stack_clear_multiple(TSRMLS_C); if (EG(exception)) { zend_throw_exception_internal(NULL TSRMLS_CC); if (return_value_used && EX_T(opline->result.u.var).var.ptr) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DO_FCALL_BY_NAME_SPEC() OPDEF(ZEND_DO_FCALL_BY_NAME, M_ANY, M_ANY) #if HAVE_OP(ZEND_DO_FCALL_BY_NAME) ZEND_VM_HANDLER(ZEND_DO_FCALL_BY_NAME) { EX(function_state).function = EX(fbc); ZEND_VM_DISPATCH_TO_HELPER(zend_do_fcall_common_helper); } #endif #define ZEND_DO_FCALL_SPEC() OPDEF(ZEND_DO_FCALL, M_CONST, M_ANY) #if HAVE_OP(ZEND_DO_FCALL) ZEND_VM_HANDLER(ZEND_DO_FCALL) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *fname = GET_OP1_ZVAL_PTR(BP_VAR_R); zend_ptr_stack_3_push(&EG(arg_types_stack), EX(fbc), EX(object), EX(calling_scope)); if (zend_hash_find(EG(function_table), fname->value.str.val, fname->value.str.len+1, (void **) &EX(function_state).function)==FAILURE) { zend_error_noreturn(E_ERROR, "Unknown function: %s()\n", fname->value.str.val); } EX(object) = NULL; EX(calling_scope) = EX(function_state).function->common.scope; FREE_OP1(); ZEND_VM_DISPATCH_TO_HELPER(zend_do_fcall_common_helper); } #endif #define ZEND_RETURN_SPEC() OPDEF(ZEND_RETURN, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_RETURN) ZEND_VM_HANDLER(ZEND_RETURN) { zend_op *opline = EX(opline); zval *retval_ptr; zval **retval_ptr_ptr; zend_free_op free_op1; if (EG(active_op_array)->return_reference == ZEND_RETURN_REF) { if (OP1_TYPE == IS_CONST || OP1_TYPE == IS_TMP_VAR) { /* Not supposed to happen, but we'll allow it */ zend_error(E_STRICT, "Only variable references should be returned by reference"); ZEND_VM_C_GOTO(return_by_value); } retval_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); if (!retval_ptr_ptr) { zend_error_noreturn(E_ERROR, "Cannot return string offsets by reference"); } if (!(*retval_ptr_ptr)->is_ref) { if (EX_T(opline->op1.u.var).var.ptr_ptr == &EX_T(opline->op1.u.var).var.ptr || (opline->extended_value == ZEND_RETURNS_FUNCTION && !EX_T(opline->op1.u.var).var.fcall_returned_reference)) { zend_error(E_STRICT, "Only variable references should be returned by reference"); PZVAL_LOCK(*retval_ptr_ptr); /* undo the effect of get_zval_ptr_ptr() */ ZEND_VM_C_GOTO(return_by_value); } } SEPARATE_ZVAL_TO_MAKE_IS_REF(retval_ptr_ptr); (*retval_ptr_ptr)->refcount++; (*EG(return_value_ptr_ptr)) = (*retval_ptr_ptr); } else { ZEND_VM_C_LABEL(return_by_value): retval_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (EG(ze1_compatibility_mode) && Z_TYPE_P(retval_ptr) == IS_OBJECT) { zval *ret; ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); if (Z_OBJ_HT_P(retval_ptr)->clone_obj == NULL) { zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", Z_OBJCE_P(retval_ptr)->name); } zend_error(E_STRICT, "Implicit cloning object of class '%s' because of 'zend.ze1_compatibility_mode'", Z_OBJCE_P(retval_ptr)->name); ret->value.obj = Z_OBJ_HT_P(retval_ptr)->clone_obj(retval_ptr TSRMLS_CC); *EG(return_value_ptr_ptr) = ret; } else if (!IS_OP1_TMP_FREE()) { /* Not a temp var */ if (PZVAL_IS_REF(retval_ptr) && retval_ptr->refcount > 0) { zval *ret; ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); zval_copy_ctor(ret); *EG(return_value_ptr_ptr) = ret; } else { *EG(return_value_ptr_ptr) = retval_ptr; retval_ptr->refcount++; } } else { zval *ret; ALLOC_ZVAL(ret); INIT_PZVAL_COPY(ret, retval_ptr); *EG(return_value_ptr_ptr) = ret; } } FREE_OP1_IF_VAR(); ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } #endif #define ZEND_THROW_SPEC() OPDEF(ZEND_THROW, M_VAR, M_ANY) #if HAVE_OP(ZEND_THROW) ZEND_VM_HANDLER(ZEND_THROW) { zend_op *opline = EX(opline); zval *value; zval *exception; zend_free_op free_op1; value = GET_OP1_ZVAL_PTR(BP_VAR_R); if (value->type != IS_OBJECT) { zend_error_noreturn(E_ERROR, "Can only throw objects"); } /* Not sure if a complete copy is what we want here */ ALLOC_ZVAL(exception); INIT_PZVAL_COPY(exception, value); if (!IS_OP1_TMP_FREE()) { zval_copy_ctor(exception); } zend_throw_exception_object(exception TSRMLS_CC); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_CATCH_SPEC() OPDEF(ZEND_CATCH, M_ANY, M_ANY) #if HAVE_OP(ZEND_CATCH) ZEND_VM_HANDLER(ZEND_CATCH) { zend_op *opline = EX(opline); zend_class_entry *ce; /* Check whether an exception has been thrown, if not, jump over code */ if (EG(exception) == NULL) { ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); ZEND_VM_CONTINUE(); /* CHECK_ME */ } ce = Z_OBJCE_P(EG(exception)); if (ce != EX_T(opline->op1.u.var).class_entry) { if (!instanceof_function(ce, EX_T(opline->op1.u.var).class_entry TSRMLS_CC)) { if (opline->op1.u.EA.type) { zend_throw_exception_internal(NULL TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[opline->extended_value]); ZEND_VM_CONTINUE(); /* CHECK_ME */ } } zend_hash_update(EG(active_symbol_table), opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, &EG(exception), sizeof(zval *), (void **) NULL); EG(exception) = NULL; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_VAL_SPEC() OPDEF(ZEND_SEND_VAL, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_VAL) ZEND_VM_HANDLER(ZEND_SEND_VAL) { zend_op *opline = EX(opline); if (opline->extended_value==ZEND_DO_FCALL_BY_NAME && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { zend_error_noreturn(E_ERROR, "Cannot pass parameter %d by reference", opline->op2.u.opline_num); } { zval *valptr; zval *value; zend_free_op free_op1; value = GET_OP1_ZVAL_PTR(BP_VAR_R); ALLOC_ZVAL(valptr); INIT_PZVAL_COPY(valptr, value); if (!IS_OP1_TMP_FREE()) { zval_copy_ctor(valptr); } zend_ptr_stack_push(&EG(argument_stack), valptr); FREE_OP1_IF_VAR(); } ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR, M_ANY) ZEND_VM_HELPER(zend_send_by_var_helper) { zend_op *opline = EX(opline); zval *varptr; zend_free_op free_op1; varptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (varptr == &EG(uninitialized_zval)) { ALLOC_ZVAL(varptr); INIT_ZVAL(*varptr); varptr->refcount = 0; } else if (PZVAL_IS_REF(varptr)) { zval *original_var = varptr; ALLOC_ZVAL(varptr); *varptr = *original_var; varptr->is_ref = 0; varptr->refcount = 0; zval_copy_ctor(varptr); } varptr->refcount++; zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1(); /* for string offsets */ ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_VAR_NO_REF_SPEC() OPDEF(ZEND_SEND_VAR_NO_REF, M_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_VAR_NO_REF) ZEND_VM_HANDLER(ZEND_SEND_VAR_NO_REF) { zend_op *opline = EX(opline); if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } { zval *varptr; zend_free_op free_op1; varptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (varptr != &EG(uninitialized_zval) && (PZVAL_IS_REF(varptr) || varptr->refcount == 1)) { varptr->is_ref = 1; varptr->refcount++; zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_REF_SPEC() OPDEF(ZEND_SEND_REF, M_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_REF) ZEND_VM_HANDLER_EX(ZEND_SEND_REF) { zend_op *opline = EX(opline); zend_free_op free_op1; zval **varptr_ptr; zval *varptr; varptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_W); if (!varptr_ptr) { zend_error_noreturn(E_ERROR, "Only variables can be passed by reference"); } SEPARATE_ZVAL_TO_MAKE_IS_REF(varptr_ptr); varptr = *varptr_ptr; varptr->refcount++; zend_ptr_stack_push(&EG(argument_stack), varptr); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SEND_VAR_SPEC() OPDEF(ZEND_SEND_VAR, M_VAR, M_ANY) #if HAVE_OP(ZEND_SEND_VAR) ZEND_VM_HANDLER(ZEND_SEND_VAR) { zend_op *opline = EX(opline); if ((opline->extended_value == ZEND_DO_FCALL_BY_NAME) && ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) { ZEND_VM_DISPATCH_TO_HANDLER(ZEND_SEND_REF); } ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } #endif #define ZEND_RECV_SPEC() OPDEF(ZEND_RECV, M_ANY, M_ANY) #if HAVE_OP(ZEND_RECV) ZEND_VM_HANDLER(ZEND_RECV) { zend_op *opline = EX(opline); zval **param; zend_uint arg_num = opline->op1.u.constant.value.lval; if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { char *space; char *class_name = get_active_class_name(&space TSRMLS_CC); zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, NULL TSRMLS_CC); zend_error(E_WARNING, "Missing argument %ld for %s%s%s()", opline->op1.u.constant.value.lval, class_name, space, get_active_function_name(TSRMLS_C)); if (opline->result.op_type == IS_VAR) { PZVAL_UNLOCK_FREE(*EX_T(opline->result.u.var).var.ptr_ptr); } } else { zend_free_op free_res; zval **var_ptr; zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, *param TSRMLS_CC); var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W); if (PZVAL_IS_REF(*param)) { zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC); } else { zend_receive(var_ptr, *param TSRMLS_CC); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_RECV_INIT_SPEC() OPDEF(ZEND_RECV_INIT, M_ANY, M_CONST) #if HAVE_OP(ZEND_RECV_INIT) ZEND_VM_HANDLER(ZEND_RECV_INIT) { zend_op *opline = EX(opline); zval **param, *assignment_value; zend_uint arg_num = opline->op1.u.constant.value.lval; zend_free_op free_res; zval **var_ptr = get_zval_ptr_ptr(&opline->result, EX(Ts), &free_res, BP_VAR_W); if (zend_ptr_stack_get_arg(arg_num, (void **) ¶m TSRMLS_CC)==FAILURE) { if (opline->op2.u.constant.type == IS_CONSTANT || opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { zval *default_value; ALLOC_ZVAL(default_value); *default_value = opline->op2.u.constant; if (opline->op2.u.constant.type==IS_CONSTANT_ARRAY) { zval_copy_ctor(default_value); } default_value->refcount=1; zval_update_constant(&default_value, 0 TSRMLS_CC); default_value->refcount=0; default_value->is_ref=0; param = &default_value; assignment_value = default_value; } else { param = NULL; assignment_value = &opline->op2.u.constant; } zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); zend_receive(var_ptr, assignment_value TSRMLS_CC); } else { assignment_value = *param; zend_verify_arg_type((zend_function *) EG(active_op_array), arg_num, assignment_value TSRMLS_CC); if (PZVAL_IS_REF(assignment_value)) { zend_assign_to_variable_reference(var_ptr, param TSRMLS_CC); } else { zend_receive(var_ptr, assignment_value TSRMLS_CC); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BOOL_SPEC() OPDEF(ZEND_BOOL, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_BOOL) ZEND_VM_HANDLER(ZEND_BOOL) { zend_op *opline = EX(opline); zend_free_op free_op1; /* PHP 3.0 returned "" for false and 1 for true, here we use 0 and 1 for now */ EX_T(opline->result.u.var).tmp_var.value.lval = i_zend_is_true(GET_OP1_ZVAL_PTR(BP_VAR_R)); EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BRK_SPEC() OPDEF(ZEND_BRK, M_ANY, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_BRK) ZEND_VM_HANDLER(ZEND_BRK) { zend_op *opline = EX(opline); zend_free_op free_op2; ZEND_VM_SET_OPCODE(EX(op_array)->opcodes + zend_brk_cont(GET_OP2_ZVAL_PTR(BP_VAR_R), opline->op1.u.opline_num, EX(op_array), EX(Ts) TSRMLS_CC)->brk); FREE_OP2(); ZEND_VM_CONTINUE(); /* CHECK_ME */ } #endif #define ZEND_CONT_SPEC() OPDEF(ZEND_CONT, M_ANY, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_CONT) ZEND_VM_HANDLER(ZEND_CONT) { zend_op *opline = EX(opline); zend_free_op free_op2; ZEND_VM_SET_OPCODE(EX(op_array)->opcodes + zend_brk_cont(GET_OP2_ZVAL_PTR(BP_VAR_R), opline->op1.u.opline_num, EX(op_array), EX(Ts) TSRMLS_CC)->cont); FREE_OP2(); ZEND_VM_CONTINUE(); /* CHECK_ME */ } #endif #define ZEND_CASE_SPEC() OPDEF(ZEND_CASE, M_CONST_TMP_VAR, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_CASE) ZEND_VM_HANDLER(ZEND_CASE) { zend_op *opline = EX(opline); int switch_expr_is_overloaded=0; zend_free_op free_op1, free_op2; if (OP1_TYPE==IS_VAR) { if (EX_T(opline->op1.u.var).var.ptr_ptr) { PZVAL_LOCK(EX_T(opline->op1.u.var).var.ptr); } else { switch_expr_is_overloaded = 1; EX_T(opline->op1.u.var).str_offset.str->refcount++; } } is_equal_function(&EX_T(opline->result.u.var).tmp_var, GET_OP1_ZVAL_PTR(BP_VAR_R), GET_OP2_ZVAL_PTR(BP_VAR_R) TSRMLS_CC); FREE_OP2(); if (switch_expr_is_overloaded) { /* We only free op1 if this is a string offset, * Since if it is a TMP_VAR, it'll be reused by * other CASE opcodes (whereas string offsets * are allocated at each get_zval_ptr()) */ FREE_OP1(); EX_T(opline->op1.u.var).var.ptr_ptr = NULL; AI_USE_PTR(EX_T(opline->op1.u.var).var); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_SWITCH_FREE_SPEC() OPDEF(ZEND_SWITCH_FREE, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_SWITCH_FREE) ZEND_VM_HANDLER(ZEND_SWITCH_FREE) { zend_switch_free(EX(opline), EX(Ts) TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_NEW_SPEC() OPDEF(ZEND_NEW, M_ANY, M_ANY) #if HAVE_OP(ZEND_NEW) ZEND_VM_HANDLER(ZEND_NEW) { zend_op *opline = EX(opline); if (EX_T(opline->op1.u.var).class_entry->ce_flags & (ZEND_ACC_INTERFACE|ZEND_ACC_IMPLICIT_ABSTRACT_CLASS|ZEND_ACC_EXPLICIT_ABSTRACT_CLASS)) { char *class_type; if (EX_T(opline->op1.u.var).class_entry->ce_flags & ZEND_ACC_INTERFACE) { class_type = "interface"; } else { class_type = "abstract class"; } zend_error_noreturn(E_ERROR, "Cannot instantiate %s %s", class_type, EX_T(opline->op1.u.var).class_entry->name); } EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); object_init_ex(EX_T(opline->result.u.var).var.ptr, EX_T(opline->op1.u.var).class_entry); EX_T(opline->result.u.var).var.ptr->refcount=1; EX_T(opline->result.u.var).var.ptr->is_ref=0; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_CLONE_SPEC() OPDEF(ZEND_CLONE, M_CONST_TMP_VAR_UNUSED, M_ANY) #if HAVE_OP(ZEND_CLONE) ZEND_VM_HANDLER(ZEND_CLONE) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *obj = GET_OP1_OBJ_ZVAL_PTR(BP_VAR_R); zend_class_entry *ce; zend_function *clone; zend_object_clone_obj_t clone_call; if (!obj || Z_TYPE_P(obj) != IS_OBJECT) { zend_error(E_WARNING, "__clone method called on non-object"); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); EX_T(opline->result.u.var).var.ptr->refcount++; FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } ce = Z_OBJCE_P(obj); clone = ce ? ce->clone : NULL; clone_call = Z_OBJ_HT_P(obj)->clone_obj; if (!clone_call) { zend_error_noreturn(E_ERROR, "Trying to clone an uncloneable object of class %s", ce->name); EX_T(opline->result.u.var).var.ptr = EG(error_zval_ptr); EX_T(opline->result.u.var).var.ptr->refcount++; } if (ce && clone) { if (clone->op_array.fn_flags & ZEND_ACC_PRIVATE) { /* Ensure that if we're calling a private function, we're allowed to do so. */ if (ce != EG(scope)) { zend_error_noreturn(E_ERROR, "Call to private %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); } } else if ((clone->common.fn_flags & ZEND_ACC_PROTECTED)) { /* Ensure that if we're calling a protected function, we're allowed to do so. */ if (!zend_check_protected(clone->common.scope, EG(scope))) { zend_error_noreturn(E_ERROR, "Call to protected %s::__clone() from context '%s'", ce->name, EG(scope) ? EG(scope)->name : ""); } } } EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr->value.obj = clone_call(obj TSRMLS_CC); if (EG(exception)) { FREE_ZVAL(EX_T(opline->result.u.var).var.ptr); } else { EX_T(opline->result.u.var).var.ptr->type = IS_OBJECT; EX_T(opline->result.u.var).var.ptr->refcount=1; EX_T(opline->result.u.var).var.ptr->is_ref=1; } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FETCH_CONSTANT_SPEC() OPDEF(ZEND_FETCH_CONSTANT, M_CONST_UNUSED, M_CONST) #if HAVE_OP(ZEND_FETCH_CONSTANT) ZEND_VM_HANDLER(ZEND_FETCH_CONSTANT) { zend_op *opline = EX(opline); zend_class_entry *ce = NULL; zval **value; if (OP1_TYPE == IS_UNUSED) { /* This seems to be a reminant of namespaces if (EG(scope)) { ce = EG(scope); if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { zval_update_constant(value, (void *) 1 TSRMLS_CC); EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); ZEND_VM_NEXT_OPCODE(); } } */ if (!zend_get_constant(opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len, &EX_T(opline->result.u.var).tmp_var TSRMLS_CC)) { zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.val); EX_T(opline->result.u.var).tmp_var = opline->op2.u.constant; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } ZEND_VM_NEXT_OPCODE(); } ce = EX_T(opline->op1.u.var).class_entry; if (zend_hash_find(&ce->constants_table, opline->op2.u.constant.value.str.val, opline->op2.u.constant.value.str.len+1, (void **) &value) == SUCCESS) { zval_update_constant(value, (void *) 1 TSRMLS_CC); EX_T(opline->result.u.var).tmp_var = **value; zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } else { zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", opline->op2.u.constant.value.str.val); } ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_CONST_TMP_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) ZEND_VM_HELPER(zend_init_add_array_helper) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval *array_ptr = &EX_T(opline->result.u.var).tmp_var; zval *expr_ptr, **expr_ptr_ptr = NULL; zval *offset=GET_OP2_ZVAL_PTR(BP_VAR_R); if (opline->extended_value) { expr_ptr_ptr=GET_OP1_ZVAL_PTR_PTR(BP_VAR_R); expr_ptr = *expr_ptr_ptr; } else { expr_ptr=GET_OP1_ZVAL_PTR(BP_VAR_R); } if (opline->opcode == ZEND_INIT_ARRAY) { array_init(array_ptr); if (!expr_ptr) { ZEND_VM_NEXT_OPCODE(); } } if (!opline->extended_value && IS_OP1_TMP_FREE()) { /* temporary variable */ zval *new_expr; ALLOC_ZVAL(new_expr); INIT_PZVAL_COPY(new_expr, expr_ptr); expr_ptr = new_expr; } else { if (opline->extended_value) { SEPARATE_ZVAL_TO_MAKE_IS_REF(expr_ptr_ptr); expr_ptr = *expr_ptr_ptr; expr_ptr->refcount++; } else if (PZVAL_IS_REF(expr_ptr)) { zval *new_expr; ALLOC_ZVAL(new_expr); INIT_PZVAL_COPY(new_expr, expr_ptr); expr_ptr = new_expr; zendi_zval_copy_ctor(*expr_ptr); } else { expr_ptr->refcount++; } } if (offset) { switch (offset->type) { case IS_DOUBLE: zend_hash_index_update(array_ptr->value.ht, (long) offset->value.dval, &expr_ptr, sizeof(zval *), NULL); break; case IS_LONG: case IS_BOOL: zend_hash_index_update(array_ptr->value.ht, offset->value.lval, &expr_ptr, sizeof(zval *), NULL); break; case IS_STRING: zend_symtable_update(array_ptr->value.ht, offset->value.str.val, offset->value.str.len+1, &expr_ptr, sizeof(zval *), NULL); break; case IS_NULL: zend_hash_update(array_ptr->value.ht, "", sizeof(""), &expr_ptr, sizeof(zval *), NULL); break; default: zend_error(E_WARNING, "Illegal offset type"); zval_ptr_dtor(&expr_ptr); /* do nothing */ break; } FREE_OP2(); } else { zend_hash_next_index_insert(array_ptr->value.ht, &expr_ptr, sizeof(zval *), NULL); } if (opline->extended_value) { FREE_OP1_VAR_PTR(); } else { FREE_OP1_IF_VAR(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INIT_ARRAY_SPEC() OPDEF(ZEND_INIT_ARRAY, M_CONST_TMP_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_INIT_ARRAY) ZEND_VM_HANDLER(ZEND_INIT_ARRAY) { ZEND_VM_DISPATCH_TO_HELPER(zend_init_add_array_helper); } #endif #define ZEND_ADD_ARRAY_ELEMENT_SPEC() OPDEF(ZEND_ADD_ARRAY_ELEMENT, M_CONST_TMP_VAR_UNUSED, M_CONST_TMP_VAR_UNUSED) #if HAVE_OP(ZEND_ADD_ARRAY_ELEMENT) ZEND_VM_HANDLER(ZEND_ADD_ARRAY_ELEMENT) { ZEND_VM_DISPATCH_TO_HELPER(zend_init_add_array_helper); } #endif #define ZEND_CAST_SPEC() OPDEF(ZEND_CAST, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_CAST) ZEND_VM_HANDLER(ZEND_CAST) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *expr = GET_OP1_ZVAL_PTR(BP_VAR_R); zval *result = &EX_T(opline->result.u.var).tmp_var; *result = *expr; if (!IS_OP1_TMP_FREE()) { zendi_zval_copy_ctor(*result); } switch (opline->extended_value) { case IS_NULL: convert_to_null(result); break; case IS_BOOL: convert_to_boolean(result); break; case IS_LONG: convert_to_long(result); break; case IS_DOUBLE: convert_to_double(result); break; case IS_STRING: { zval var_copy; int use_copy; zend_make_printable_zval(result, &var_copy, &use_copy); if (use_copy) { zval_dtor(result); *result = var_copy; } break; } case IS_ARRAY: convert_to_array(result); break; case IS_OBJECT: convert_to_object(result); break; } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INCLUDE_OR_EVAL_SPEC() OPDEF(ZEND_INCLUDE_OR_EVAL, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_INCLUDE_OR_EVAL) ZEND_VM_HANDLER(ZEND_INCLUDE_OR_EVAL) { zend_op *opline = EX(opline); zend_op_array *new_op_array=NULL; zval **original_return_value = EG(return_value_ptr_ptr); int return_value_used; zend_free_op free_op1; zval *inc_filename = GET_OP1_ZVAL_PTR(BP_VAR_R); zval tmp_inc_filename; zend_bool failure_retval=0; if (inc_filename->type!=IS_STRING) { tmp_inc_filename = *inc_filename; zval_copy_ctor(&tmp_inc_filename); convert_to_string(&tmp_inc_filename); inc_filename = &tmp_inc_filename; } return_value_used = RETURN_VALUE_USED(opline); switch (opline->op2.u.constant.value.lval) { case ZEND_INCLUDE_ONCE: case ZEND_REQUIRE_ONCE: { int dummy = 1; zend_file_handle file_handle; if (SUCCESS == zend_stream_open(inc_filename->value.str.val, &file_handle TSRMLS_CC)) { if (!file_handle.opened_path) { file_handle.opened_path = estrndup(inc_filename->value.str.val, inc_filename->value.str.len); } if (zend_hash_add(&EG(included_files), file_handle.opened_path, strlen(file_handle.opened_path)+1, (void *)&dummy, sizeof(int), NULL)==SUCCESS) { new_op_array = zend_compile_file(&file_handle, (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE?ZEND_INCLUDE:ZEND_REQUIRE) TSRMLS_CC); zend_destroy_file_handle(&file_handle TSRMLS_CC); } else { zend_file_handle_dtor(&file_handle); failure_retval=1; } } else { if (opline->op2.u.constant.value.lval==ZEND_INCLUDE_ONCE) { zend_message_dispatcher(ZMSG_FAILED_INCLUDE_FOPEN, inc_filename->value.str.val); } else { zend_message_dispatcher(ZMSG_FAILED_REQUIRE_FOPEN, inc_filename->value.str.val); } } break; } break; case ZEND_INCLUDE: case ZEND_REQUIRE: new_op_array = compile_filename(opline->op2.u.constant.value.lval, inc_filename TSRMLS_CC); break; case ZEND_EVAL: { char *eval_desc = zend_make_compiled_string_description("eval()'d code" TSRMLS_CC); new_op_array = compile_string(inc_filename, eval_desc TSRMLS_CC); efree(eval_desc); } break; EMPTY_SWITCH_DEFAULT_CASE() } if (inc_filename==&tmp_inc_filename) { zval_dtor(&tmp_inc_filename); } FREE_OP1(); EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; if (new_op_array) { zval *saved_object; zend_function *saved_function; EG(return_value_ptr_ptr) = EX_T(opline->result.u.var).var.ptr_ptr; EG(active_op_array) = new_op_array; EX_T(opline->result.u.var).var.ptr = NULL; saved_object = EX(object); saved_function = EX(function_state).function; EX(function_state).function = (zend_function *) new_op_array; EX(object) = NULL; zend_execute(new_op_array TSRMLS_CC); EX(function_state).function = saved_function; EX(object) = saved_object; if (!return_value_used) { if (EX_T(opline->result.u.var).var.ptr) { zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); } } else { /* return value is used */ if (!EX_T(opline->result.u.var).var.ptr) { /* there was no return statement */ ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_PZVAL(EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr->value.lval = 1; EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; } } EG(opline_ptr) = &EX(opline); EG(active_op_array) = EX(op_array); EG(function_state_ptr) = &EX(function_state); destroy_op_array(new_op_array TSRMLS_CC); efree(new_op_array); if (EG(exception)) { zend_throw_exception_internal(NULL TSRMLS_CC); } } else { if (return_value_used) { ALLOC_ZVAL(EX_T(opline->result.u.var).var.ptr); INIT_ZVAL(*EX_T(opline->result.u.var).var.ptr); EX_T(opline->result.u.var).var.ptr->value.lval = failure_retval; EX_T(opline->result.u.var).var.ptr->type = IS_BOOL; } } EG(return_value_ptr_ptr) = original_return_value; ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_UNSET_VAR_SPEC() OPDEF(ZEND_UNSET_VAR, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_UNSET_VAR) ZEND_VM_HANDLER(ZEND_UNSET_VAR) { zend_op *opline = EX(opline); zval tmp, *varname; HashTable *target_symbol_table; zend_free_op free_op1; varname = GET_OP1_ZVAL_PTR(BP_VAR_R); if (varname->type != IS_STRING) { tmp = *varname; zval_copy_ctor(&tmp); convert_to_string(&tmp); varname = &tmp; } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { zend_std_unset_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname) TSRMLS_CC); } else { target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); zend_hash_del(target_symbol_table, varname->value.str.val, varname->value.str.len+1); } if (varname == &tmp) { zval_dtor(&tmp); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_UNSET_DIM_OBJ_SPEC() OPDEF(ZEND_UNSET_DIM_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_UNSET_DIM_OBJ) ZEND_VM_HANDLER(ZEND_UNSET_DIM_OBJ) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R); zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); long index; if (container) { HashTable *ht; if (opline->extended_value == ZEND_UNSET_DIM) { switch (Z_TYPE_PP(container)) { case IS_ARRAY: ht = Z_ARRVAL_PP(container); break; case IS_OBJECT: ht = NULL; if (!Z_OBJ_HT_P(*container)->unset_dimension) { zend_error_noreturn(E_ERROR, "Cannot use object as array"); } Z_OBJ_HT_P(*container)->unset_dimension(*container, offset TSRMLS_CC); break; case IS_STRING: zend_error_noreturn(E_ERROR, "Cannot unset string offsets"); ZEND_VM_CONTINUE(); /* bailed out before */ default: ht = NULL; break; } } else { /* ZEND_UNSET_OBJ */ ht = NULL; if (Z_TYPE_PP(container) == IS_OBJECT) { Z_OBJ_HT_P(*container)->unset_property(*container, offset TSRMLS_CC); } } if (ht) { switch (offset->type) { case IS_DOUBLE: case IS_RESOURCE: case IS_BOOL: case IS_LONG: if (offset->type == IS_DOUBLE) { index = (long) offset->value.dval; } else { index = offset->value.lval; } zend_hash_index_del(ht, index); break; case IS_STRING: zend_symtable_del(ht, offset->value.str.val, offset->value.str.len+1); break; case IS_NULL: zend_hash_del(ht, "", sizeof("")); break; default: zend_error(E_WARNING, "Illegal offset type in unset"); break; } } } else { /* overloaded element */ } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FE_RESET_SPEC() OPDEF(ZEND_FE_RESET, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FE_RESET) ZEND_VM_HANDLER(ZEND_FE_RESET) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *array_ptr, **array_ptr_ptr; HashTable *fe_ht; zend_object_iterator *iter = NULL; zend_class_entry *ce = NULL; if (opline->extended_value) { array_ptr_ptr = GET_OP1_ZVAL_PTR_PTR(BP_VAR_R); if (array_ptr_ptr == NULL) { MAKE_STD_ZVAL(array_ptr); } else if (Z_TYPE_PP(array_ptr_ptr) == IS_OBJECT) { ce = Z_OBJCE_PP(array_ptr_ptr); if (!ce || ce->get_iterator == NULL) { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); (*array_ptr_ptr)->refcount++; } array_ptr = *array_ptr_ptr; } else { SEPARATE_ZVAL_IF_NOT_REF(array_ptr_ptr); array_ptr = *array_ptr_ptr; array_ptr->refcount++; } } else { array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (IS_OP1_TMP_FREE()) { /* IS_TMP_VAR */ zval *tmp; ALLOC_ZVAL(tmp); INIT_PZVAL_COPY(tmp, array_ptr); array_ptr = tmp; } else if (Z_TYPE_P(array_ptr) == IS_OBJECT) { ce = Z_OBJCE_P(array_ptr); } else { array_ptr->refcount++; } } if (ce && ce->get_iterator) { iter = ce->get_iterator(ce, array_ptr TSRMLS_CC); if (iter) { array_ptr = zend_iterator_wrap(iter TSRMLS_CC); } else { array_ptr->refcount++; } } PZVAL_LOCK(array_ptr); EX_T(opline->result.u.var).var.ptr = array_ptr; EX_T(opline->result.u.var).var.ptr_ptr = &EX_T(opline->result.u.var).var.ptr; if (iter) { iter->index = 0; if (iter->funcs->rewind) { iter->funcs->rewind(iter TSRMLS_CC); } } else if ((fe_ht = HASH_OF(array_ptr)) != NULL) { /* probably redundant */ zend_hash_internal_pointer_reset(fe_ht); } else { zend_error(E_WARNING, "Invalid argument supplied for foreach()"); opline++; ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); if (opline->extended_value) { FREE_OP1_VAR_PTR(); } else { FREE_OP1_IF_VAR(); } ZEND_VM_CONTINUE_JMP(); } if (opline->extended_value) { FREE_OP1_VAR_PTR(); } else { FREE_OP1_IF_VAR(); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_FE_FETCH_SPEC() OPDEF(ZEND_FE_FETCH, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_FE_FETCH) ZEND_VM_HANDLER(ZEND_FE_FETCH) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *array = GET_OP1_ZVAL_PTR(BP_VAR_R); zval **value, *key; char *str_key; uint str_key_len; ulong int_key; HashTable *fe_ht; zend_object_iterator *iter = NULL; int key_type; zend_bool use_key = opline->extended_value & ZEND_FE_FETCH_WITH_KEY; PZVAL_LOCK(array); switch (zend_iterator_unwrap(array, &iter TSRMLS_CC)) { default: case ZEND_ITER_INVALID: zend_error(E_WARNING, "Invalid argument supplied for foreach()"); ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); case ZEND_ITER_PLAIN_OBJECT: { char *class_name, *prop_name; zend_object *zobj = zend_objects_get_address(array TSRMLS_CC); fe_ht = HASH_OF(array); do { if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { /* reached end of iteration */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 0, NULL); zend_hash_move_forward(fe_ht); } while (key_type != HASH_KEY_IS_STRING || zend_check_property_access(zobj, str_key TSRMLS_CC) != SUCCESS); if (use_key) { zend_unmangle_property_name(str_key, &class_name, &prop_name); str_key_len = strlen(prop_name); str_key = estrndup(prop_name, str_key_len); str_key_len++; } break; } case ZEND_ITER_PLAIN_ARRAY: fe_ht = HASH_OF(array); if (zend_hash_get_current_data(fe_ht, (void **) &value)==FAILURE) { /* reached end of iteration */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } if (use_key) { key_type = zend_hash_get_current_key_ex(fe_ht, &str_key, &str_key_len, &int_key, 1, NULL); } zend_hash_move_forward(fe_ht); break; case ZEND_ITER_OBJECT: /* !iter happens from exception */ if (iter && iter->index++) { /* This could cause an endless loop if index becomes zero again. * In case that ever happens we need an additional flag. */ iter->funcs->move_forward(iter TSRMLS_CC); } if (!iter || iter->funcs->valid(iter TSRMLS_CC) == FAILURE) { /* reached end of iteration */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } iter->funcs->get_current_data(iter, &value TSRMLS_CC); if (!value) { /* failure in get_current_data */ ZEND_VM_SET_OPCODE(EX(op_array)->opcodes+opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } if (use_key) { if (iter->funcs->get_current_key) { key_type = iter->funcs->get_current_key(iter, &str_key, &str_key_len, &int_key TSRMLS_CC); } else { key_type = HASH_KEY_IS_LONG; int_key = iter->index; } } break; } if (opline->extended_value & ZEND_FE_FETCH_BYREF) { SEPARATE_ZVAL_IF_NOT_REF(value); (*value)->is_ref = 1; } if (!use_key) { if (opline->extended_value & ZEND_FE_FETCH_BYREF) { EX_T(opline->result.u.var).var.ptr_ptr = value; (*value)->refcount++; } else { zval *result = &EX_T(opline->result.u.var).tmp_var; *result = **value; zval_copy_ctor(result); } } else { zval *result = &EX_T(opline->result.u.var).tmp_var; (*value)->refcount++; array_init(result); zend_hash_index_update(result->value.ht, 0, value, sizeof(zval *), NULL); ALLOC_ZVAL(key); INIT_PZVAL(key); switch (key_type) { case HASH_KEY_IS_STRING: key->value.str.val = str_key; key->value.str.len = str_key_len-1; key->type = IS_STRING; break; case HASH_KEY_IS_LONG: key->value.lval = int_key; key->type = IS_LONG; break; EMPTY_SWITCH_DEFAULT_CASE() } zend_hash_index_update(result->value.ht, 1, &key, sizeof(zval *), NULL); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_JMP_NO_CTOR_SPEC() OPDEF(ZEND_JMP_NO_CTOR, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_JMP_NO_CTOR) ZEND_VM_HANDLER(ZEND_JMP_NO_CTOR) { zend_op *opline = EX(opline); zval *object_zval; zend_function *constructor; zend_free_op free_op1; if (OP1_TYPE == IS_VAR) { PZVAL_LOCK(*EX_T(opline->op1.u.var).var.ptr_ptr); } object_zval = GET_OP1_ZVAL_PTR(BP_VAR_R); constructor = Z_OBJ_HT_P(object_zval)->get_constructor(object_zval TSRMLS_CC); EX(fbc_constructor) = NULL; if (constructor == NULL) { if(opline->op1.u.EA.type & EXT_TYPE_UNUSED) { zval_ptr_dtor(EX_T(opline->op1.u.var).var.ptr_ptr); } ZEND_VM_SET_OPCODE(EX(op_array)->opcodes + opline->op2.u.opline_num); ZEND_VM_CONTINUE_JMP(); } else { EX(fbc_constructor) = constructor; } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ISSET_ISEMPTY_VAR_SPEC() OPDEF(ZEND_ISSET_ISEMPTY_VAR, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_ISSET_ISEMPTY_VAR) ZEND_VM_HANDLER(ZEND_ISSET_ISEMPTY_VAR) { zend_op *opline = EX(opline); zend_free_op free_op1; zval tmp, *varname = GET_OP1_ZVAL_PTR(BP_VAR_R); zval **value; zend_bool isset = 1; HashTable *target_symbol_table; if (varname->type != IS_STRING) { tmp = *varname; zval_copy_ctor(&tmp); convert_to_string(&tmp); varname = &tmp; } if (opline->op2.u.EA.type == ZEND_FETCH_STATIC_MEMBER) { value = zend_std_get_static_property(EX_T(opline->op2.u.var).class_entry, Z_STRVAL_P(varname), Z_STRLEN_P(varname), 1 TSRMLS_CC); if (!value) { isset = 0; } } else { target_symbol_table = zend_get_target_symbol_table(opline, EX(Ts), BP_VAR_IS, varname TSRMLS_CC); if (zend_hash_find(target_symbol_table, varname->value.str.val, varname->value.str.len+1, (void **) &value) == FAILURE) { isset = 0; } } EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; switch (opline->extended_value) { case ZEND_ISSET: if (isset && Z_TYPE_PP(value) == IS_NULL) { EX_T(opline->result.u.var).tmp_var.value.lval = 0; } else { EX_T(opline->result.u.var).tmp_var.value.lval = isset; } break; case ZEND_ISEMPTY: if (!isset || !i_zend_is_true(*value)) { EX_T(opline->result.u.var).tmp_var.value.lval = 1; } else { EX_T(opline->result.u.var).tmp_var.value.lval = 0; } break; } if (varname == &tmp) { zval_dtor(&tmp); } FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #if OP1_OP2_MASK(M_VAR_UNUSED, M_CONST_TMP_VAR) ZEND_VM_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, int prop_dim) { zend_op *opline = EX(opline); zend_free_op free_op1, free_op2; zval **container = GET_OP1_OBJ_ZVAL_PTR_PTR(BP_VAR_R); zval *offset = GET_OP2_ZVAL_PTR(BP_VAR_R); zval **value = NULL; int result = 0; long index; if (container) { if ((*container)->type == IS_ARRAY) { HashTable *ht; int isset = 0; ht = (*container)->value.ht; switch (offset->type) { case IS_DOUBLE: case IS_RESOURCE: case IS_BOOL: case IS_LONG: if (offset->type == IS_DOUBLE) { index = (long) offset->value.dval; } else { index = offset->value.lval; } if (zend_hash_index_find(ht, index, (void **) &value) == SUCCESS) { isset = 1; } break; case IS_STRING: if (zend_symtable_find(ht, offset->value.str.val, offset->value.str.len+1, (void **) &value) == SUCCESS) { isset = 1; } break; case IS_NULL: if (zend_hash_find(ht, "", sizeof(""), (void **) &value) == SUCCESS) { isset = 1; } break; default: zend_error(E_WARNING, "Illegal offset type in unset"); break; } switch (opline->extended_value) { case ZEND_ISSET: if (isset && Z_TYPE_PP(value) == IS_NULL) { result = 0; } else { result = isset; } break; case ZEND_ISEMPTY: if (!isset || !i_zend_is_true(*value)) { result = 0; } else { result = 1; } break; } } else if ((*container)->type == IS_OBJECT) { if (prop_dim) { result = Z_OBJ_HT_P(*container)->has_property(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); } else { result = Z_OBJ_HT_P(*container)->has_dimension(*container, offset, (opline->extended_value == ZEND_ISEMPTY) TSRMLS_CC); } } else if ((*container)->type == IS_STRING) { /* string offsets */ switch (opline->extended_value) { case ZEND_ISSET: if (offset->value.lval < Z_STRLEN_PP(container)) { result = 1; } break; case ZEND_ISEMPTY: if (offset->value.lval < Z_STRLEN_PP(container) && Z_STRVAL_PP(container)[offset->value.lval] != '0') { result = 1; } break; } } } EX_T(opline->result.u.var).tmp_var.type = IS_BOOL; switch (opline->extended_value) { case ZEND_ISSET: EX_T(opline->result.u.var).tmp_var.value.lval = result; break; case ZEND_ISEMPTY: EX_T(opline->result.u.var).tmp_var.value.lval = !result; break; } FREE_OP2(); FREE_OP1_VAR_PTR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ISSET_ISEMPTY_DIM_OBJ_SPEC() OPDEF(ZEND_ISSET_ISEMPTY_DIM_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ISSET_ISEMPTY_DIM_OBJ) ZEND_VM_HANDLER(ZEND_ISSET_ISEMPTY_DIM_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, prop_dim, 0); } #endif #define ZEND_ISSET_ISEMPTY_PROP_OBJ_SPEC() OPDEF(ZEND_ISSET_ISEMPTY_PROP_OBJ, M_VAR_UNUSED, M_CONST_TMP_VAR) #if HAVE_OP(ZEND_ISSET_ISEMPTY_PROP_OBJ) ZEND_VM_HANDLER(ZEND_ISSET_ISEMPTY_PROP_OBJ) { ZEND_VM_DISPATCH_TO_HELPER_EX(zend_isset_isempty_dim_prop_obj_handler, prop_dim, 1); } #endif #define ZEND_EXIT_SPEC() OPDEF(ZEND_EXIT, M_CONST_TMP_VAR_UNUSED, M_ANY) #if HAVE_OP(ZEND_EXIT) ZEND_VM_HANDLER(ZEND_EXIT) { zend_op *opline = EX(opline); if (OP1_TYPE != IS_UNUSED) { zval *ptr; zend_free_op free_op1; ptr = GET_OP1_ZVAL_PTR(BP_VAR_R); if (Z_TYPE_P(ptr) == IS_LONG) { EG(exit_status) = Z_LVAL_P(ptr); } else { zend_print_variable(ptr); } FREE_OP1(); } zend_bailout(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_BEGIN_SILENCE_SPEC() OPDEF(ZEND_BEGIN_SILENCE, M_ANY, M_ANY) #if HAVE_OP(ZEND_BEGIN_SILENCE) ZEND_VM_HANDLER(ZEND_BEGIN_SILENCE) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).tmp_var.value.lval = EG(error_reporting); EX_T(opline->result.u.var).tmp_var.type = IS_LONG; /* shouldn't be necessary */ zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), "0", 1, ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_RAISE_ABSTRACT_ERROR_SPEC() OPDEF(ZEND_RAISE_ABSTRACT_ERROR, M_ANY, M_ANY) #if HAVE_OP(ZEND_RAISE_ABSTRACT_ERROR) ZEND_VM_HANDLER(ZEND_RAISE_ABSTRACT_ERROR) { zend_error_noreturn(E_ERROR, "Cannot call abstract method %s::%s()", EG(scope)->name, EX(op_array)->function_name); ZEND_VM_NEXT_OPCODE(); /* Never reached */ } #endif #define ZEND_END_SILENCE_SPEC() OPDEF(ZEND_END_SILENCE, M_TMP, M_ANY) #if HAVE_OP(ZEND_END_SILENCE) ZEND_VM_HANDLER(ZEND_END_SILENCE) { zend_op *opline = EX(opline); zval restored_error_reporting; if (!EG(error_reporting)) { restored_error_reporting.type = IS_LONG; restored_error_reporting.value.lval = EX_T(opline->op1.u.var).tmp_var.value.lval; convert_to_string(&restored_error_reporting); zend_alter_ini_entry("error_reporting", sizeof("error_reporting"), Z_STRVAL(restored_error_reporting), Z_STRLEN(restored_error_reporting), ZEND_INI_USER, ZEND_INI_STAGE_RUNTIME); zendi_zval_dtor(restored_error_reporting); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_QM_ASSIGN_SPEC() OPDEF(ZEND_QM_ASSIGN, M_CONST_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_QM_ASSIGN) ZEND_VM_HANDLER(ZEND_QM_ASSIGN) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *value = GET_OP1_ZVAL_PTR(BP_VAR_R); EX_T(opline->result.u.var).tmp_var = *value; if (!IS_OP1_TMP_FREE()) { zval_copy_ctor(&EX_T(opline->result.u.var).tmp_var); } FREE_OP1_IF_VAR(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_STMT_SPEC() OPDEF(ZEND_EXT_STMT, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_STMT) ZEND_VM_HANDLER(ZEND_EXT_STMT) { if (!EG(no_extensions)) { zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_statement_handler, EX(op_array) TSRMLS_CC); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_FCALL_BEGIN_SPEC() OPDEF(ZEND_EXT_FCALL_BEGIN, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_FCALL_BEGIN) ZEND_VM_HANDLER(ZEND_EXT_FCALL_BEGIN) { if (!EG(no_extensions)) { zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_begin_handler, EX(op_array) TSRMLS_CC); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_FCALL_END_SPEC() OPDEF(ZEND_EXT_FCALL_END, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_FCALL_END) ZEND_VM_HANDLER(ZEND_EXT_FCALL_END) { if (!EG(no_extensions)) { zend_llist_apply_with_argument(&zend_extensions, (llist_apply_with_arg_func_t) zend_extension_fcall_end_handler, EX(op_array) TSRMLS_CC); } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DECLARE_CLASS_SPEC() OPDEF(ZEND_DECLARE_CLASS, M_ANY, M_ANY) #if HAVE_OP(ZEND_DECLARE_CLASS) ZEND_VM_HANDLER(ZEND_DECLARE_CLASS) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).class_entry = do_bind_class(opline, EG(class_table), 0 TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DECLARE_INHERITED_CLASS_SPEC() OPDEF(ZEND_DECLARE_INHERITED_CLASS, M_ANY, M_ANY) #if HAVE_OP(ZEND_DECLARE_INHERITED_CLASS) ZEND_VM_HANDLER(ZEND_DECLARE_INHERITED_CLASS) { zend_op *opline = EX(opline); EX_T(opline->result.u.var).class_entry = do_bind_inherited_class(opline, EG(class_table), EX_T(opline->extended_value).class_entry, 0 TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_DECLARE_FUNCTION_SPEC() OPDEF(ZEND_DECLARE_FUNCTION, M_ANY, M_ANY) #if HAVE_OP(ZEND_DECLARE_FUNCTION) ZEND_VM_HANDLER(ZEND_DECLARE_FUNCTION) { do_bind_function(EX(opline), EG(function_table), 0); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_TICKS_SPEC() OPDEF(ZEND_TICKS, M_CONST, M_ANY) #if HAVE_OP(ZEND_TICKS) ZEND_VM_HANDLER(ZEND_TICKS) { zend_op *opline = EX(opline); if (++EG(ticks_count)>=opline->op1.u.constant.value.lval) { EG(ticks_count)=0; if (zend_ticks_function) { zend_ticks_function(opline->op1.u.constant.value.lval); } } ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_INSTANCEOF_SPEC() OPDEF(ZEND_INSTANCEOF, M_TMP_VAR, M_ANY) #if HAVE_OP(ZEND_INSTANCEOF) ZEND_VM_HANDLER(ZEND_INSTANCEOF) { zend_op *opline = EX(opline); zend_free_op free_op1; zval *expr = GET_OP1_ZVAL_PTR(BP_VAR_R); zend_bool result; if (Z_TYPE_P(expr) == IS_OBJECT) { result = instanceof_function(Z_OBJCE_P(expr), EX_T(opline->op2.u.var).class_entry TSRMLS_CC); } else { result = 0; } ZVAL_BOOL(&EX_T(opline->result.u.var).tmp_var, result); FREE_OP1(); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_EXT_NOP_SPEC() OPDEF(ZEND_EXT_NOP, M_ANY, M_ANY) #if HAVE_OP(ZEND_EXT_NOP) ZEND_VM_HANDLER(ZEND_EXT_NOP) { ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_NOP_SPEC() OPDEF(ZEND_NOP, M_ANY, M_ANY) #if HAVE_OP(ZEND_NOP) ZEND_VM_HANDLER(ZEND_NOP) { ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_ADD_INTERFACE_SPEC() OPDEF(ZEND_ADD_INTERFACE, M_ANY, M_ANY) #if HAVE_OP(ZEND_ADD_INTERFACE) ZEND_VM_HANDLER(ZEND_ADD_INTERFACE) { zend_op *opline = EX(opline); zend_class_entry *ce = EX_T(opline->op1.u.var).class_entry; zend_class_entry *iface = EX_T(opline->op2.u.var).class_entry; if (!(iface->ce_flags & ZEND_ACC_INTERFACE)) { zend_error_noreturn(E_ERROR, "%s cannot implement %s - it is not an interface", ce->name, iface->name); } ce->interfaces[opline->extended_value] = iface; zend_do_implement_interface(ce, iface TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif #define ZEND_HANDLE_EXCEPTION_SPEC() OPDEF(ZEND_HANDLE_EXCEPTION, M_ANY, M_ANY) #if HAVE_OP(ZEND_HANDLE_EXCEPTION) ZEND_VM_HANDLER(ZEND_HANDLE_EXCEPTION) { zend_uint op_num = EG(opline_before_exception)-EG(active_op_array)->opcodes; int i; int encapsulating_block=-1; zval **stack_zval_pp; stack_zval_pp = (zval **) EG(argument_stack).top_element - 1; while (*stack_zval_pp != NULL) { zval_ptr_dtor(stack_zval_pp); EG(argument_stack).top_element--; stack_zval_pp--; } for (i=0; i<EG(active_op_array)->last_try_catch; i++) { if (EG(active_op_array)->try_catch_array[i].try_op > op_num) { /* further blocks will not be relevant... */ break; } if (op_num >= EG(active_op_array)->try_catch_array[i].try_op && op_num < EG(active_op_array)->try_catch_array[i].catch_op) { encapsulating_block = i; } } if (encapsulating_block == -1) { ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); } else { ZEND_VM_SET_OPCODE(&EX(op_array)->opcodes[EG(active_op_array)->try_catch_array[encapsulating_block].catch_op]); ZEND_VM_CONTINUE(); } } #endif #define ZEND_VERIFY_ABSTRACT_CLASS_SPEC() OPDEF(ZEND_VERIFY_ABSTRACT_CLASS, M_ANY, M_ANY) #if HAVE_OP(ZEND_VERIFY_ABSTRACT_CLASS) ZEND_VM_HANDLER(ZEND_VERIFY_ABSTRACT_CLASS) { zend_verify_abstract_class(EX_T(EX(opline)->op1.u.var).class_entry TSRMLS_CC); ZEND_VM_NEXT_OPCODE(); } #endif http://cvs.php.net/co.php/ZendEngine2/zend_vm_spec.h?r=1.1&p=1 Index: ZendEngine2/zend_vm_spec.h +++ ZendEngine2/zend_vm_spec.h /* +----------------------------------------------------------------------+ | Zend Engine | +----------------------------------------------------------------------+ | Copyright (c) 1998-2004 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 | | 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 | | obtain it through the world-wide-web, please send a note to | | license@zend.com so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Dmitry Stogov <dmitry@zend.com> | +----------------------------------------------------------------------+ */ /* $Id: zend_vm_spec.h,v 1.1 2004/09/08 22:14:12 andi Exp $ */ /* Don't edit this file. It produces the specialized version of executor's opcode handlers and helpers, those are defined in zend_vm_handlers.h */ #define IS_ANY (1<<7) #define _ANY_CODE 0 #define SPEC2(X,Y) SPEC_##X##Y #define SPEC(X,Y) SPEC2(X,Y) #define SPEC2_0(X,Y) SPEC_##X##Y() #define SPEC_0(X,Y) SPEC2_0(X,Y) #define SPEC2_1(X,Y,Z) SPEC_##X##Y(Z) #define SPEC_1(X,Y,Z) SPEC2_1(X,Y,Z) #define OP1_TYPE \ SPEC(OP1_TYPE, OP1_TYPE_PREFIX) #define OP1_TYPE_CODE \ SPEC(OP1_TYPE_PREFIX, _CODE) #define GET_OP1_ZVAL_PTR(T) \ SPEC_1(GET_OP1_ZVAL_PTR, OP1_TYPE_PREFIX, T) #define GET_OP1_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP1_ZVAL_PTR_PTR, OP1_TYPE_PREFIX, T) #define GET_OP1_OBJ_ZVAL_PTR(T) \ SPEC_1(GET_OP1_OBJ_ZVAL_PTR, OP1_TYPE_PREFIX, T) #define GET_OP1_OBJ_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP1_OBJ_ZVAL_PTR_PTR, OP1_TYPE_PREFIX, T) #define IS_OP1_TMP_FREE() \ SPEC_0(IS_OP1_TMP_FREE, OP1_TYPE_PREFIX) #define FREE_OP1() \ SPEC_0(FREE_OP1, OP1_TYPE_PREFIX) #define FREE_OP1_IF_VAR() \ SPEC_0(FREE_OP1_IF_VAR, OP1_TYPE_PREFIX) #define FREE_OP1_VAR_PTR() \ SPEC_0(FREE_OP1_VAR_PTR, OP1_TYPE_PREFIX) #define OP2_TYPE \ SPEC(OP2_TYPE, OP2_TYPE_PREFIX) #define OP2_TYPE_CODE \ SPEC(OP2_TYPE_PREFIX, _CODE) #define GET_OP2_ZVAL_PTR(T) \ SPEC_1(GET_OP2_ZVAL_PTR, OP2_TYPE_PREFIX, T) #define GET_OP2_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP2_ZVAL_PTR_PTR, OP2_TYPE_PREFIX, T) #define GET_OP2_OBJ_ZVAL_PTR(T) \ SPEC_1(GET_OP2_OBJ_ZVAL_PTR, OP2_TYPE_PREFIX, T) #define GET_OP2_OBJ_ZVAL_PTR_PTR(T) \ SPEC_1(GET_OP2_OBJ_ZVAL_PTR_PTR, OP2_TYPE_PREFIX, T) #define IS_OP2_TMP_FREE() \ SPEC_0(IS_OP2_TMP_FREE, OP2_TYPE_PREFIX) #define FREE_OP2() \ SPEC_0(FREE_OP2, OP2_TYPE_PREFIX) #define FREE_OP2_IF_VAR() \ SPEC_0(FREE_OP2_IF_VAR, OP2_TYPE_PREFIX) #define FREE_OP2_VAR_PTR() \ SPEC_0(FREE_OP2_VAR_PTR, OP2_TYPE_PREFIX) #define SPEC__ANY_CODE _ANY_CODE #define SPEC__CONST_CODE _CONST_CODE #define SPEC__TMP_CODE _TMP_CODE #define SPEC__VAR_CODE _VAR_CODE #define SPEC__UNUSED_CODE _UNUSED_CODE #define SPEC_OP1_TYPE_ANY opline->op1.op_type #define SPEC_OP1_TYPE_CONST IS_CONST #define SPEC_OP1_TYPE_TMP IS_TMP_VAR #define SPEC_OP1_TYPE_VAR IS_VAR #define SPEC_OP1_TYPE_UNUSED IS_UNUSED #define SPEC_GET_OP1_ZVAL_PTR_ANY(T) _get_zval_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_CONST(T) _get_zval_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_TMP(T) _get_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_VAR(T) _get_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_UNUSED(T) _get_zval_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_ANY(T) _get_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_CONST(T) _get_zval_ptr_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_TMP(T) _get_zval_ptr_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_VAR(T) _get_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_ZVAL_PTR_PTR_UNUSED(T) _get_zval_ptr_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_ANY(T) _get_obj_zval_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_CONST(T) _get_obj_zval_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_TMP(T) _get_obj_zval_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_VAR(T) _get_obj_zval_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_UNUSED(T) _get_obj_zval_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_ANY(T) _get_obj_zval_ptr_ptr(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_CONST(T) _get_obj_zval_ptr_ptr_const(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_TMP(T) _get_obj_zval_ptr_ptr_tmp(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_VAR(T) _get_obj_zval_ptr_ptr_var(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_GET_OP1_OBJ_ZVAL_PTR_PTR_UNUSED(T) _get_obj_zval_ptr_ptr_unused(&opline->op1, EX(Ts), &free_op1 TSRMLS_CC) #define SPEC_IS_OP1_TMP_FREE_ANY() IS_TMP_FREE(free_op1) #define SPEC_IS_OP1_TMP_FREE_CONST() 0 #define SPEC_IS_OP1_TMP_FREE_TMP() 1 #define SPEC_IS_OP1_TMP_FREE_VAR() IS_TMP_FREE(free_op1) #define SPEC_IS_OP1_TMP_FREE_UNUSED() 0 #define SPEC_FREE_OP1_ANY() FREE_OP(free_op1); #define SPEC_FREE_OP1_CONST() #define SPEC_FREE_OP1_TMP() zval_dtor(free_op1.var) #define SPEC_FREE_OP1_VAR() FREE_OP(free_op1); #define SPEC_FREE_OP1_UNUSED() #define SPEC_FREE_OP1_IF_VAR_ANY() FREE_OP_IF_VAR(free_op1); #define SPEC_FREE_OP1_IF_VAR_CONST() #define SPEC_FREE_OP1_IF_VAR_TMP() #define SPEC_FREE_OP1_IF_VAR_VAR() FREE_OP_IF_VAR(free_op1); #define SPEC_FREE_OP1_IF_VAR_UNUSED() #define SPEC_FREE_OP1_VAR_PTR_ANY() FREE_OP_VAR_PTR(free_op1); #define SPEC_FREE_OP1_VAR_PTR_CONST() #define SPEC_FREE_OP1_VAR_PTR_TMP() #define SPEC_FREE_OP1_VAR_PTR_VAR() FREE_OP_VAR_PTR(free_op1); #define SPEC_FREE_OP1_VAR_PTR_UNUSED() #define SPEC_OP2_TYPE_ANY opline->op2.op_type #define SPEC_OP2_TYPE_CONST IS_CONST #define SPEC_OP2_TYPE_TMP IS_TMP_VAR #define SPEC_OP2_TYPE_VAR IS_VAR #define SPEC_OP2_TYPE_UNUSED IS_UNUSED #define SPEC_GET_OP2_ZVAL_PTR_ANY(T) _get_zval_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_CONST(T) _get_zval_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_TMP(T) _get_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_VAR(T) _get_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_UNUSED(T) _get_zval_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_ANY(T) _get_zval_ptr_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_CONST(T) _get_zval_ptr_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_TMP(T) _get_zval_ptr_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_VAR(T) _get_zval_ptr_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_ZVAL_PTR_PTR_UNUSED(T) _get_zval_ptr_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_ANY(T) _get_obj_zval_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_CONST(T) _get_obj_zval_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_TMP(T) _get_obj_zval_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_VAR(T) _get_obj_zval_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_UNUSED(T) _get_obj_zval_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_ANY(T) _get_obj_zval_ptr_ptr(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_CONST(T) _get_obj_zval_ptr_ptr_const(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_TMP(T) _get_obj_zval_ptr_ptr_tmp(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_VAR(T) _get_obj_zval_ptr_ptr_var(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_GET_OP2_OBJ_ZVAL_PTR_PTR_UNUSED(T) _get_obj_zval_ptr_ptr_unused(&opline->op2, EX(Ts), &free_op2 TSRMLS_CC) #define SPEC_IS_OP2_TMP_FREE_ANY() IS_TMP_FREE(free_op2) #define SPEC_IS_OP2_TMP_FREE_CONST() 0 #define SPEC_IS_OP2_TMP_FREE_TMP() 1 #define SPEC_IS_OP2_TMP_FREE_VAR() IS_TMP_FREE(free_op2) #define SPEC_IS_OP2_TMP_FREE_UNUSED() 0 #define SPEC_FREE_OP2_ANY() FREE_OP(free_op2); #define SPEC_FREE_OP2_CONST() #define SPEC_FREE_OP2_TMP() zval_dtor(free_op2.var) #define SPEC_FREE_OP2_VAR() FREE_OP(free_op2); #define SPEC_FREE_OP2_UNUSED() #define SPEC_FREE_OP2_IF_VAR_ANY() FREE_OP_IF_VAR(free_op2); #define SPEC_FREE_OP2_IF_VAR_CONST() #define SPEC_FREE_OP2_IF_VAR_TMP() #define SPEC_FREE_OP2_IF_VAR_VAR() FREE_OP_IF_VAR(free_op2); #define SPEC_FREE_OP2_IF_VAR_UNUSED() #define SPEC_FREE_OP2_VAR_PTR_ANY() FREE_OP_VAR_PTR(free_op2); #define SPEC_FREE_OP2_VAR_PTR_CONST() #define SPEC_FREE_OP2_VAR_PTR_TMP() #define SPEC_FREE_OP2_VAR_PTR_VAR() FREE_OP_VAR_PTR(free_op2); #define SPEC_FREE_OP2_VAR_PTR_UNUSED() #ifndef ZEND_VM_SPEC # define OP1_OP2_MASK(OP1T, OP2T) 1 # define HAVE_OP(OP) 1 # define ZEND_VM_C_GOTO(LABEL) goto LABEL # define ZEND_VM_C_LABEL(LABEL) LABEL # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_ANY # include "zend_vm_handlers.h" #else # define M_ANY (IS_ANY) # define M_CONST (IS_CONST) # define M_TMP (IS_TMP_VAR) # define M_VAR (IS_VAR) # define M_UNUSED (IS_UNUSED) # define M_CONST_TMP (IS_CONST|IS_TMP_VAR) # define M_CONST_VAR (IS_CONST|IS_VAR) # define M_CONST_UNUSED (IS_CONST|IS_UNUSED) # define M_CONST_TMP_VAR (IS_CONST|IS_TMP_VAR|IS_VAR) # define M_CONST_TMP_UNUSED (IS_CONST|IS_TMP_VAR|IS_UNUSED) # define M_CONST_VAR_UNUSED (IS_CONST|IS_VAR|IS_UNUSED) # define M_CONST_TMP_VAR_UNUSED (IS_CONST|IS_TMP_VAR|IS_VAR|IS_UNUSED) # define M_TMP_VAR (IS_TMP_VAR|IS_VAR) # define M_TMP_UNUSED (IS_TMP_VAR|IS_UNUSED) # define M_TMP_VAR_UNUSED (IS_TMP_VAR|IS_VAR|IS_UNUSED) # define M_VAR_UNUSED (IS_VAR|IS_UNUSED) # define OP1_OP2_MASK(OP1T, OP2T) \ ((OP1 & (OP1T)) && (OP2 & (OP2T))) # define OPDEF(OP,OP1M,OP2M) \ ((OP1 & (OP1M)) && (OP2 & (OP2M))) # define HAVE_OP(OP) \ OP##_SPEC() # define ZEND_VM_SPEC_C_GOTO2(LABEL, OP1T, OP2T) \ goto LABEL##OP1T##OP2T # define ZEND_VM_SPEC_C_GOTO1(LABEL, OP1T, OP2T) \ ZEND_VM_SPEC_C_GOTO2(LABEL, OP1T, OP2T) # define ZEND_VM_C_GOTO(LABEL) \ ZEND_VM_SPEC_C_GOTO1(LABEL, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_C_LABEL2(LABEL, OP1T, OP2T) \ LABEL##OP1T##OP2T # define ZEND_VM_SPEC_C_LABEL1(LABEL, OP1T, OP2T) \ ZEND_VM_SPEC_C_LABEL2(LABEL, OP1T, OP2T) # define ZEND_VM_C_LABEL(LABEL) \ ZEND_VM_SPEC_C_LABEL1(LABEL, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_HANDLER2(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER(OP##OP1T##OP2T, CODE) # define ZEND_VM_SPEC_HANDLER1(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER2(OP, OP1T, OP2T, CODE) # undef ZEND_VM_HANDLER # define ZEND_VM_HANDLER(OP) \ ZEND_VM_SPEC_HANDLER1(OP##_SPEC, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, ZEND_VM_CODE(OP,OP1_TYPE_CODE,OP2_TYPE_CODE)) # define ZEND_VM_SPEC_HANDLER_EX2(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER_EX(OP##OP1T##OP2T, CODE) # define ZEND_VM_SPEC_HANDLER_EX1(OP, OP1T, OP2T, CODE) \ ZEND_VM_SPEC_HANDLER_EX2(OP, OP1T, OP2T, CODE) # undef ZEND_VM_HANDLER_EX # define ZEND_VM_HANDLER_EX(OP) \ ZEND_VM_SPEC_HANDLER_EX1(OP##_SPEC, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, ZEND_VM_CODE(OP,OP1_TYPE_CODE,OP2_TYPE_CODE)) # define ZEND_VM_SPEC_HELPER2(OP, OP1T, OP2T) \ ZEND_VM_SPEC_HELPER(OP##OP1T##OP2T) # define ZEND_VM_SPEC_HELPER1(OP, OP1T, OP2T) \ ZEND_VM_SPEC_HELPER2(OP, OP1T, OP2T) # undef ZEND_VM_HELPER # define ZEND_VM_HELPER(OP) \ ZEND_VM_SPEC_HELPER1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_HELPER_EX2(OP, OP1T, OP2T, PARAM) \ ZEND_VM_SPEC_HELPER_EX(OP##OP1T##OP2T, PARAM) # define ZEND_VM_SPEC_HELPER_EX1(OP, OP1T, OP2T, PARAM) \ ZEND_VM_SPEC_HELPER_EX2(OP, OP1T, OP2T, PARAM) # undef ZEND_VM_HELPER_EX # define ZEND_VM_HELPER_EX(OP, PARAM) \ ZEND_VM_SPEC_HELPER_EX1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, PARAM) # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER2(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HANDLER(OP##OP1T##OP2T) # define ZEND_VM_SPEC_DISPATCH_TO_HANDLER1(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HANDLER2(OP, OP1T, OP2T) # undef ZEND_VM_DISPATCH_TO_HANDLER # define ZEND_VM_DISPATCH_TO_HANDLER(OP) \ ZEND_VM_SPEC_DISPATCH_TO_HANDLER1(OP##_SPEC, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER2(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER(OP##OP1T##OP2T) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER1(OP, OP1T, OP2T) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER2(OP, OP1T, OP2T) # undef ZEND_VM_DISPATCH_TO_HELPER # define ZEND_VM_DISPATCH_TO_HELPER(OP) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX2(OP, OP1T, OP2T, VAR, VAL) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX(OP##OP1T##OP2T, VAR, VAL) # define ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX1(OP, OP1T, OP2T, VAR, VAL) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX2(OP, OP1T, OP2T, VAR, VAL) # undef ZEND_VM_DISPATCH_TO_HELPER_EX # define ZEND_VM_DISPATCH_TO_HELPER_EX(OP, VAR, VAL) \ ZEND_VM_SPEC_DISPATCH_TO_HELPER_EX1(OP, OP1_TYPE_PREFIX, OP2_TYPE_PREFIX, VAR, VAL) # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_ANY # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_ANY # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_UNUSED # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_UNUSED # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_CONST # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_TMP_VAR # define OP2 IS_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_CONST # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_TMP_VAR # include "zend_vm_handlers.h" # undef OP1 # undef OP2 # define OP1 IS_VAR # define OP2 IS_VAR # include "zend_vm_handlers.h" /* LABELS */ # undef M_ANY # undef M_CONST # undef M_TMP # undef M_VAR # undef M_UNUSED # undef M_CONST_TMP # undef M_CONST_VAR # undef M_CONST_UNUSED # undef M_CONST_TMP_VAR # undef M_CONST_TMP_UNUSED # undef M_CONST_VAR_UNUSED # undef M_CONST_TMP_VAR_UNUSED # undef M_TMP_VAR # undef M_TMP_UNUSED # undef M_TMP_VAR_UNUSED # undef M_VAR_UNUSED # undef OPDEF # define OPDEF(OP, OP1M, OP2M) \ SPEC_LABELS1_##OP1M(OP##_SPEC, OP, OP2M) # define SPEC_LABELS1_M_ANY(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _ANY, _ANY, _ANY, _ANY) # define SPEC_LABELS1_M_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _NULL, _NULL, _UNUSED) # define SPEC_LABELS1_M_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _NULL, _VAR, _NULL) # define SPEC_LABELS1_M_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _NULL, _VAR, _UNUSED) # define SPEC_LABELS1_M_TMP(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _NULL, _NULL) # define SPEC_LABELS1_M_TMP_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _NULL, _UNUSED) # define SPEC_LABELS1_M_TMP_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _VAR, _NULL) # define SPEC_LABELS1_M_TMP_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _NULL, _TMP, _VAR, _UNUSED) # define SPEC_LABELS1_M_CONST(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _NULL, _NULL) # define SPEC_LABELS1_M_CONST_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _NULL, _UNUSED) # define SPEC_LABELS1_M_CONST_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _VAR, _NULL) # define SPEC_LABELS1_M_CONST_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _NULL, _VAR, _UNUSED) # define SPEC_LABELS1_M_CONST_TMP(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _NULL, _NULL) # define SPEC_LABELS1_M_CONST_TMP_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _NULL, _UNUSED) # define SPEC_LABELS1_M_CONST_TMP_VAR(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _VAR, _NULL) # define SPEC_LABELS1_M_CONST_TMP_VAR_UNUSED(OP, CODE, OP2M) \ SPEC_LABELS2_##OP2M(OP, CODE, _CONST, _TMP, _VAR, _UNUSED) # define SPEC_LABELS2_M_ANY(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _ANY, _ANY, _ANY, _ANY) # define SPEC_LABELS2_M_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _NULL, _NULL, _UNUSED) # define SPEC_LABELS2_M_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _NULL, _VAR, _NULL) # define SPEC_LABELS2_M_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _NULL, _VAR, _UNUSED) # define SPEC_LABELS2_M_TMP(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _NULL, _NULL) # define SPEC_LABELS2_M_TMP_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _NULL, _UNUSED) # define SPEC_LABELS2_M_TMP_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _VAR, _NULL) # define SPEC_LABELS2_M_TMP_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _NULL, _TMP, _VAR, _UNUSED) # define SPEC_LABELS2_M_CONST(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _NULL, _NULL) # define SPEC_LABELS2_M_CONST_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _NULL, _UNUSED) # define SPEC_LABELS2_M_CONST_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _VAR, _NULL) # define SPEC_LABELS2_M_CONST_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _NULL, _VAR, _UNUSED) # define SPEC_LABELS2_M_CONST_TMP(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _NULL, _NULL) # define SPEC_LABELS2_M_CONST_TMP_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _NULL, _UNUSED) # define SPEC_LABELS2_M_CONST_TMP_VAR(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _VAR, _NULL) # define SPEC_LABELS2_M_CONST_TMP_VAR_UNUSED(OP, CODE, OP1C, OP1T, OP1V, OP1U) \ SPEC_LABELS(OP, CODE, OP1C, OP1T, OP1V, OP1U, _CONST, _TMP, _VAR, _UNUSED) # define LABELS_1(OP,CODE,OP1,OP2C,OP2T,OP2V,OP2U) \ OP1##OP2C(OP,CODE), \ OP1##OP2T(OP,CODE), \ OP1##OP2V(OP,CODE), \ OP1##OP2U(OP,CODE) # define SPEC_LABELS(OP,CODE,OP1C,OP1T,OP1V,OP1U,OP2C,OP2T,OP2V,OP2U) \ LABELS_1(OP,CODE,SPEC_LABEL##OP1C,OP2C,OP2T,OP2V,OP2U), \ LABELS_1(OP,CODE,SPEC_LABEL##OP1T,OP2C,OP2T,OP2V,OP2U), \ LABELS_1(OP,CODE,SPEC_LABEL##OP1V,OP2C,OP2T,OP2V,OP2U), \ LABELS_1(OP,CODE,SPEC_LABEL##OP1U,OP2C,OP2T,OP2V,OP2U) # define SPEC_LABEL_CONST_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_TMP_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_VAR_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_UNUSED_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_ANY_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_CONST(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_TMP(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_VAR(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_UNUSED(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_ANY(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_NULL_NULL(OP,CODE) ZEND_VM_SPEC_NULL_LABEL # define SPEC_LABEL_ANY_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_ANY, ZEND_VM_CODE(CODE, _ANY_CODE, _ANY_CODE)) # define SPEC_LABEL_ANY_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_CONST, ZEND_VM_CODE(CODE, _ANY_CODE, _CONST_CODE)) # define SPEC_LABEL_ANY_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_TMP, ZEND_VM_CODE(CODE, _ANY_CODE, _TMP_CODE)) # define SPEC_LABEL_ANY_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_VAR, ZEND_VM_CODE(CODE, _ANY_CODE, _VAR_CODE)) # define SPEC_LABEL_ANY_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_ANY_UNUSED, ZEND_VM_CODE(CODE, _ANY_CODE, _UNUSED_CODE)) # define SPEC_LABEL_CONST_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_ANY, ZEND_VM_CODE(CODE, _CONST_CODE, _ANY_CODE)) # define SPEC_LABEL_CONST_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_CONST, ZEND_VM_CODE(CODE, _CONST_CODE, _CONST_CODE)) # define SPEC_LABEL_CONST_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_TMP, ZEND_VM_CODE(CODE, _CONST_CODE, _TMP_CODE)) # define SPEC_LABEL_CONST_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_VAR, ZEND_VM_CODE(CODE, _CONST_CODE, _VAR_CODE)) # define SPEC_LABEL_CONST_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_CONST_UNUSED, ZEND_VM_CODE(CODE, _CONST_CODE, _UNUSED_CODE)) # define SPEC_LABEL_TMP_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_ANY, ZEND_VM_CODE(CODE, _TMP_CODE, _ANY_CODE)) # define SPEC_LABEL_TMP_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_CONST, ZEND_VM_CODE(CODE, _TMP_CODE, _CONST_CODE)) # define SPEC_LABEL_TMP_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_TMP, ZEND_VM_CODE(CODE, _TMP_CODE, _TMP_CODE)) # define SPEC_LABEL_TMP_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_VAR, ZEND_VM_CODE(CODE, _TMP_CODE, _VAR_CODE)) # define SPEC_LABEL_TMP_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_TMP_UNUSED, ZEND_VM_CODE(CODE, _TMP_CODE, _UNUSED_CODE)) # define SPEC_LABEL_VAR_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_ANY, ZEND_VM_CODE(CODE, _VAR_CODE, _ANY_CODE)) # define SPEC_LABEL_VAR_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_CONST, ZEND_VM_CODE(CODE, _VAR_CODE, _CONST_CODE)) # define SPEC_LABEL_VAR_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_TMP, ZEND_VM_CODE(CODE, _VAR_CODE, _TMP_CODE)) # define SPEC_LABEL_VAR_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_VAR, ZEND_VM_CODE(CODE, _VAR_CODE, _VAR_CODE)) # define SPEC_LABEL_VAR_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_VAR_UNUSED, ZEND_VM_CODE(CODE, _VAR_CODE, _UNUSED_CODE)) # define SPEC_LABEL_UNUSED_ANY(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_ANY, ZEND_VM_CODE(CODE, _UNUSED_CODE, _ANY_CODE)) # define SPEC_LABEL_UNUSED_CONST(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_CONST, ZEND_VM_CODE(CODE, _UNUSED_CODE, _CONST_CODE)) # define SPEC_LABEL_UNUSED_TMP(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_TMP, ZEND_VM_CODE(CODE, _UNUSED_CODE, _TMP_CODE)) # define SPEC_LABEL_UNUSED_VAR(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_VAR, ZEND_VM_CODE(CODE, _UNUSED_CODE, _VAR_CODE)) # define SPEC_LABEL_UNUSED_UNUSED(OP,CODE) \ ZEND_VM_SPEC_LABEL(OP##_UNUSED_UNUSED, ZEND_VM_CODE(CODE, _UNUSED_CODE, _UNUSED_CODE)) # undef ZEND_VM_NULL_LABEL # define ZEND_VM_NULL_LABEL \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL, \ ZEND_VM_SPEC_NULL_LABEL # undef ZEND_VM_LABEL # define ZEND_VM_LABEL(OP) \ OP##_SPEC() #endif ZEND_VM_NULL_HANDLER() { zend_error_noreturn(E_ERROR, "Invalid opcode %d/%d/%d.", EX(opline)->opcode, EX(opline)->op1.op_type, EX(opline)->op2.op_type); ZEND_VM_RETURN_FROM_EXECUTE_LOOP(); }