summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
authorXinchen Hui <laruence@gmail.com>2014-02-26 12:52:43 +0800
committerXinchen Hui <laruence@gmail.com>2014-02-26 12:52:43 +0800
commit66b7f6722d16a261243390ed2afdc97de15b5f93 (patch)
treed59b5611b79c442e471094e9c3e2951965a4d397 /Zend
parent80a178015d6b162ff0ba7a8e8f5a08c88829cc3c (diff)
parent4a1ecf0e8b04363901c92aea55a203fc73a24b95 (diff)
downloadphp-git-66b7f6722d16a261243390ed2afdc97de15b5f93.tar.gz
Merge branch 'refactoring2' of github.com:zendtech/php into refactoring2
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend.c2
-rw-r--r--Zend/zend_compile.c4
-rw-r--r--Zend/zend_execute.c12
-rw-r--r--Zend/zend_execute_API.c2
-rw-r--r--Zend/zend_vm_def.h25
-rw-r--r--Zend/zend_vm_execute.h100
6 files changed, 106 insertions, 39 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index f7713102e8..19401d2e03 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -228,7 +228,7 @@ ZEND_API void zend_make_printable_zval(zval *expr, zval *expr_copy, int *use_cop
if (Z_TYPE_P(expr) == IS_REFERENCE) {
expr = Z_REFVAL_P(expr);
if (Z_TYPE_P(expr) == IS_STRING) {
- ZVAL_STR(expr_copy, Z_STR_P(expr));
+ ZVAL_STR(expr_copy, STR_COPY(Z_STR_P(expr)));
*use_copy = 1;
return;
}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index aff6cad01c..66410d41d3 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -4594,8 +4594,8 @@ ZEND_API int do_bind_function(const zend_op_array *op_array, zend_op *opline, Ha
}
return FAILURE;
} else {
- (*new_function->op_array.refcount)++;
- new_function->op_array.static_variables = NULL; /* NULL out the unbound function */
+ (*function->op_array.refcount)++;
+ function->op_array.static_variables = NULL; /* NULL out the unbound function */
return SUCCESS;
}
}
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index 322fe46799..9bdee5c2c1 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1383,7 +1383,7 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
{
if (Z_TYPE_P(container) != IS_OBJECT) {
if (container == &EG(error_zval)) {
- result = &EG(error_zval);
+ ZVAL_INDIRECT(result, &EG(error_zval));
return;
}
@@ -1398,7 +1398,7 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
object_init(container);
} else {
zend_error(E_WARNING, "Attempt to modify property of non-object");
- result = &EG(error_zval);
+ ZVAL_INDIRECT(result, &EG(error_zval));
return;
}
}
@@ -1408,7 +1408,8 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
if (NULL == ptr) {
if (Z_OBJ_HT_P(container)->read_property &&
(ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, key TSRMLS_CC)) != NULL) {
- ZVAL_COPY(result, ptr);
+//??? ZVAL_COPY(result, ptr);
+ ZVAL_INDIRECT(result, ptr);
} else {
zend_error_noreturn(E_ERROR, "Cannot access undefined property for object with overloaded property access");
}
@@ -1418,10 +1419,11 @@ static void zend_fetch_property_address(zval *result, zval *container, zval *pro
}
} else if (Z_OBJ_HT_P(container)->read_property) {
zval *ptr = Z_OBJ_HT_P(container)->read_property(container, prop_ptr, type, key TSRMLS_CC);
- ZVAL_COPY(result, ptr);
+//??? ZVAL_COPY(result, ptr);
+ ZVAL_INDIRECT(result, ptr);
} else {
zend_error(E_WARNING, "This object doesn't support property references");
- result = &EG(error_zval);
+ ZVAL_INDIRECT(result, &EG(error_zval));
}
}
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 863130bf29..c8679625c1 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -623,7 +623,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
}
}
- if (Z_REFCOUNT_P(element) > 1) {
+ if (Z_REFCOUNTED_P(element) && Z_REFCOUNT_P(element) > 1) {
ZVAL_DUP(&new_val, element);
/* preserve this bit for inheritance */
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index ef8817191f..b91e4894cf 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -4165,12 +4165,17 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((OP1_TYPE == IS_CV || OP1_TYPE == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -4180,20 +4185,28 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = GET_OP1_ZVAL_PTR(BP_VAR_R);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (IS_OP1_TMP_FREE()) { /* IS_TMP_VAR */
zval tmp;
@@ -4215,10 +4228,10 @@ ZEND_VM_HANDLER(77, ZEND_FE_RESET, CONST|TMP|VAR|CV, ANY)
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (OP1_TYPE == IS_CONST ||
(OP1_TYPE == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(OP1_TYPE == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 7087a4e4d3..f2ebf3f7ee 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -2956,12 +2956,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_CONST == IS_CV || IS_CONST == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = opline->op1.zv;
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -2971,20 +2976,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = opline->op1.zv;
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (0) { /* IS_TMP_VAR */
zval tmp;
@@ -3006,10 +3019,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_A
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_CONST == IS_CONST ||
(IS_CONST == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_CONST == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
@@ -7994,12 +8007,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_TMP_VAR == IS_CV || IS_TMP_VAR == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -8009,20 +8027,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = _get_zval_ptr_tmp(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (1) { /* IS_TMP_VAR */
zval tmp;
@@ -8044,10 +8070,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARG
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_TMP_VAR == IS_CONST ||
(IS_TMP_VAR == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_TMP_VAR == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
@@ -13084,12 +13110,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_VAR == IS_CV || IS_VAR == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -13099,20 +13130,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = _get_zval_ptr_var(opline->op1.var, execute_data, &free_op1 TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (0) { /* IS_TMP_VAR */
zval tmp;
@@ -13134,10 +13173,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_VAR == IS_CONST ||
(IS_VAR == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_VAR == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;
@@ -29962,12 +30001,17 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
zend_object_iterator *iter = NULL;
zend_class_entry *ce = NULL;
zend_bool is_empty = 0;
+ zval *array_ref = NULL;
SAVE_OPLINE();
if ((IS_CV == IS_CV || IS_CV == IS_VAR) &&
(opline->extended_value & ZEND_FE_RESET_VARIABLE)) {
array_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (Z_TYPE_P(array_ptr) == IS_NULL) {
} else if (Z_TYPE_P(array_ptr) == IS_OBJECT) {
if(Z_OBJ_HT_P(array_ptr)->get_class_entry == NULL) {
@@ -29977,20 +30021,28 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
ce = Z_OBJCE_P(array_ptr);
if (!ce || ce->get_iterator == NULL) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ }
Z_ADDREF_P(array_ptr);
}
} else {
if (Z_TYPE_P(array_ptr) == IS_ARRAY) {
- SEPARATE_ZVAL_IF_NOT_REF(array_ptr);
- if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
- ZVAL_NEW_REF(array_ptr, array_ptr);
+ if (!array_ref) {
+ SEPARATE_ZVAL(array_ptr);
+ if (opline->extended_value & ZEND_FE_FETCH_BYREF) {
+ ZVAL_NEW_REF(array_ptr, array_ptr);
+ }
}
}
if (Z_REFCOUNTED_P(array_ptr)) Z_ADDREF_P(array_ptr);
}
} else {
array_ptr = _get_zval_ptr_cv_BP_VAR_R(execute_data, opline->op1.var TSRMLS_CC);
+ if (Z_ISREF_P(array_ptr)) {
+ array_ref = array_ptr;
+ array_ptr = Z_REFVAL_P(array_ptr);
+ }
if (0) { /* IS_TMP_VAR */
zval tmp;
@@ -30012,10 +30064,10 @@ static int ZEND_FASTCALL ZEND_FE_RESET_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS
} else if (Z_REFCOUNTED_P(array_ptr)) {
if (IS_CV == IS_CONST ||
(IS_CV == IS_CV &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 1) ||
(IS_CV == IS_VAR &&
- !Z_ISREF_P(array_ptr) &&
+ (array_ref == NULL) &&
Z_REFCOUNT_P(array_ptr) > 2)) {
zval tmp;