summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend_API.c6
-rw-r--r--Zend/zend_compile.h8
-rw-r--r--Zend/zend_execute.c34
-rw-r--r--Zend/zend_execute_API.c6
-rw-r--r--Zend/zend_opcode.c4
-rw-r--r--Zend/zend_variables.c5
6 files changed, 36 insertions, 27 deletions
diff --git a/Zend/zend_API.c b/Zend/zend_API.c
index 6e6426c83f..c348497f40 100644
--- a/Zend/zend_API.c
+++ b/Zend/zend_API.c
@@ -52,7 +52,7 @@ ZEND_API int getParameters(int ht, int param_count,...)
while (param_count>0) {
param = va_arg(ptr, zval **);
param_ptr = *(p-param_count);
- if (!param_ptr->EA && param_ptr->refcount>1) {
+ if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) {
zval *new_tmp;
new_tmp = (zval *) emalloc(sizeof(zval));
@@ -90,7 +90,7 @@ ZEND_API int getParametersArray(int ht, int param_count, zval **argument_array)
while (param_count>0) {
param_ptr = *(p-param_count);
- if (!param_ptr->EA && param_ptr->refcount>1) {
+ if (!PZVAL_IS_REF(param_ptr) && param_ptr->refcount>1) {
zval *new_tmp;
new_tmp = (zval *) emalloc(sizeof(zval));
@@ -175,7 +175,7 @@ ZEND_API int ParameterPassedByReference(int ht, uint n)
return FAILURE;
}
arg = (zval *) *(p-arg_count+n-1);
- return arg->EA;
+ return PZVAL_IS_REF(arg);
}
diff --git a/Zend/zend_compile.h b/Zend/zend_compile.h
index 2568c7662e..806ce24fac 100644
--- a/Zend/zend_compile.h
+++ b/Zend/zend_compile.h
@@ -544,4 +544,12 @@ int zendlex(znode *zendlval CLS_DC);
#define ZEND_MEMBER_FUNC_CALL 1<<0
#define ZEND_CTOR_CALL 1<<1
+
+/* Extended attributes for zval */
+#define ZEND_EA_IS_REF (0<<1L)
+#define ZEND_EA_LOCKED (0<<2L)
+
+#define PZVAL_IS_REF(z) ((z)->EA & ZEND_EA_IS_REF)
+#define PZVAL_IS_LOCKED(z) ((z)->EA & ZEND_EA_LOCKED)
+
#endif /* _COMPILE_H */
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 366226b8a6..b53cb5621a 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -264,14 +264,14 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
return;
}
- if (variable_ptr->EA) {
+ if (PZVAL_IS_REF(variable_ptr)) {
if (variable_ptr!=value) {
short refcount=variable_ptr->refcount;
zendi_zval_dtor(*variable_ptr);
*variable_ptr = *value;
variable_ptr->refcount = refcount;
- variable_ptr->EA=1;
+ variable_ptr->EA = ZEND_EA_IS_REF;
if (type!=IS_TMP_VAR) {
zendi_zval_copy_ctor(*variable_ptr);
}
@@ -284,7 +284,7 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
case IS_CONST:
if (variable_ptr==value) {
variable_ptr->refcount++;
- } else if (value->EA) {
+ } else if (PZVAL_IS_REF(value)) {
zval tmp = *value;
tmp = *value;
@@ -309,7 +309,7 @@ static inline void zend_assign_to_variable(znode *result, znode *op1, znode *op2
switch (type) {
case IS_VAR:
case IS_CONST:
- if (value->EA) {
+ if (PZVAL_IS_REF(value)) {
variable_ptr = *variable_ptr_ptr = (zval *) emalloc(sizeof(zval));
*variable_ptr = *value;
zval_copy_ctor(variable_ptr);
@@ -558,7 +558,7 @@ static inline void zend_fetch_dimension_address(znode *result, znode *op1, znode
switch (type) {
case BP_VAR_RW:
case BP_VAR_W:
- if (!container->EA) {
+ if (!PZVAL_IS_REF(container)) {
container->refcount--;
if (container->refcount>0) {
container = *container_ptr = (zval *) emalloc(sizeof(zval));
@@ -573,7 +573,7 @@ static inline void zend_fetch_dimension_address(znode *result, znode *op1, znode
switch (container->type) {
case IS_ARRAY:
- if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !container->EA) {
+ if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) {
container->refcount--;
*container_ptr = (zval *) emalloc(sizeof(zval));
**container_ptr = *container;
@@ -725,7 +725,7 @@ static inline void zend_fetch_property_address(znode *result, znode *op1, znode
switch (type) {
case BP_VAR_RW:
case BP_VAR_W:
- if (!container->EA) {
+ if (!PZVAL_IS_REF(container)) {
container->refcount--;
if (container->refcount>0) {
container = *container_ptr = (zval *) emalloc(sizeof(zval));
@@ -754,7 +754,7 @@ static inline void zend_fetch_property_address(znode *result, znode *op1, znode
}
- if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !container->EA) {
+ if ((type==BP_VAR_W || type==BP_VAR_RW) && container->refcount>1 && !PZVAL_IS_REF(container)) {
container->refcount--;
*container_ptr = (zval *) emalloc(sizeof(zval));
**container_ptr = *container;
@@ -856,7 +856,7 @@ void execute(zend_op_array *op_array ELS_DC)
zval *globals = (zval *) emalloc(sizeof(zval));
globals->refcount=1;
- globals->EA=1;
+ globals->EA=ZEND_EA_IS_REF;
globals->type = IS_ARRAY;
globals->value.ht = &EG(symbol_table);
if (zend_hash_add(EG(active_symbol_table), "GLOBALS", sizeof("GLOBALS"), &globals, sizeof(zval *), NULL)==FAILURE) {
@@ -974,7 +974,7 @@ binary_assign_op_addr: {
opline++;
continue;
}
- if (!(*var_ptr)->EA) {
+ if (!PZVAL_IS_REF(*var_ptr)) {
if ((*var_ptr)->refcount>1) {
zval *orig_var=*var_ptr;
@@ -1017,7 +1017,7 @@ binary_assign_op_addr: {
zendi_zval_copy_ctor(Ts[opline->result.u.var].tmp_var);
break;
}
- if (!(*var_ptr)->EA) {
+ if (!PZVAL_IS_REF(*var_ptr)) {
if ((*var_ptr)->refcount>1) {
zval *orig_var = *var_ptr;
@@ -1440,7 +1440,7 @@ do_fcall_common:
var_uninit(varptr);
varptr->refcount=0;
varptr->EA=0;
- } else if (varptr->EA) {
+ } else if (PZVAL_IS_REF(varptr)) {
zval *original_var = varptr;
varptr = (zval *) emalloc(sizeof(zval));
@@ -1459,7 +1459,7 @@ send_by_ref:
zval **varptr_ptr = get_zval_ptr_ptr(&opline->op1, Ts, BP_VAR_W);
zval *varptr = *varptr_ptr;
- if (!varptr->EA) {
+ if (!PZVAL_IS_REF(varptr)) {
/* code to break away this variable */
if (varptr->refcount>1) {
varptr->refcount--;
@@ -1469,7 +1469,7 @@ send_by_ref:
varptr->refcount = 1;
zval_copy_ctor(varptr);
}
- varptr->EA = 1;
+ varptr->EA = ZEND_EA_IS_REF;
/* at the end of this code refcount is always 1 */
}
varptr->refcount++;
@@ -1482,7 +1482,7 @@ send_by_ref:
if (zend_ptr_stack_get_arg(opline->op1.u.constant.value.lval, (void **) &param ELS_CC)==FAILURE) {
zend_error(E_NOTICE, "Missing argument %d for %s()\n", opline->op1.u.constant.value.lval, get_active_function_name());
DEC_AI_COUNT();
- } else if ((*param)->EA) {
+ } else if (PZVAL_IS_REF(*param)) {
zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, Ts, BP_VAR_W), param, NULL ELS_CC);
} else {
zend_assign_to_variable(NULL, &opline->result, NULL, *param, IS_VAR, Ts ELS_CC);
@@ -1520,7 +1520,7 @@ send_by_ref:
assignment_value = *param;
}
- if (assignment_value->EA) {
+ if (PZVAL_IS_REF(assignment_value)) {
zend_assign_to_variable_reference(NULL, get_zval_ptr_ptr(&opline->result, Ts, BP_VAR_W), param, NULL ELS_CC);
} else {
zend_assign_to_variable(NULL, &opline->result, NULL, assignment_value, IS_VAR, Ts ELS_CC);
@@ -1624,7 +1624,7 @@ send_by_ref:
expr->refcount=1;
expr->EA=0;
} else {
- if (expr->EA) {
+ if (PZVAL_IS_REF(expr)) {
zval *new_expr = (zval *) emalloc(sizeof(zval));
*new_expr = *expr;
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 2ef18a263d..c07ba96c9e 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -419,7 +419,7 @@ ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **var
efree(variable_ptr);
}
- if (!value_ptr->EA) {
+ if (!PZVAL_IS_REF(value_ptr)) {
/* break it away */
value_ptr->refcount--;
if (value_ptr->refcount>0) {
@@ -428,8 +428,8 @@ ZEND_API inline void zend_assign_to_variable_reference(znode *result, zval **var
value_ptr = *value_ptr_ptr;
zendi_zval_copy_ctor(*value_ptr);
}
- value_ptr->refcount=1;
- value_ptr->EA=1;
+ value_ptr->refcount = 1;
+ value_ptr->EA = ZEND_EA_IS_REF;
}
*variable_ptr_ptr = value_ptr;
diff --git a/Zend/zend_opcode.c b/Zend/zend_opcode.c
index 188df4c913..fe3e7171ea 100644
--- a/Zend/zend_opcode.c
+++ b/Zend/zend_opcode.c
@@ -294,10 +294,10 @@ void pass_include_eval(zend_op_array *op_array)
while (opline<end) {
if (opline->op1.op_type==IS_CONST) {
- opline->op1.u.constant.EA = 1;
+ opline->op1.u.constant.EA = ZEND_EA_IS_REF;
}
if (opline->op2.op_type==IS_CONST) {
- opline->op2.u.constant.EA = 1;
+ opline->op2.u.constant.EA = ZEND_EA_IS_REF;
}
opline++;
}
diff --git a/Zend/zend_variables.c b/Zend/zend_variables.c
index 26ba3dbbaf..713c4a469b 100644
--- a/Zend/zend_variables.c
+++ b/Zend/zend_variables.c
@@ -50,7 +50,7 @@ ZEND_API inline void var_uninit(zval *var)
ZEND_API int zval_dtor(zval *zvalue)
{
if (zvalue->type==IS_LONG) {
- return;
+ return 1;
}
switch(zvalue->type) {
case IS_STRING:
@@ -89,9 +89,10 @@ ZEND_API int zval_dtor(zval *zvalue)
case IS_DOUBLE:
case IS_BOOL:
default:
- return;
+ return 1;
break;
}
+ return 1;
}