summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Zend/zend_builtin_functions.c8
-rw-r--r--Zend/zend_compile.c12
-rw-r--r--Zend/zend_exceptions.c23
-rw-r--r--Zend/zend_execute.c6
-rw-r--r--Zend/zend_execute_API.c10
-rw-r--r--Zend/zend_interfaces.c8
-rw-r--r--Zend/zend_object_handlers.c18
-rw-r--r--Zend/zend_vm_def.h1
-rw-r--r--Zend/zend_vm_execute.h4
9 files changed, 51 insertions, 39 deletions
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 53780784fd..8daa7cdda4 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -1968,10 +1968,10 @@ static void debug_backtrace_get_args(zval *curpos, zval *arg_array TSRMLS_DC)
while (--arg_count >= 0) {
arg = p++;
if (arg) {
- if (Z_TYPE_P(arg) != IS_OBJECT) {
- SEPARATE_ZVAL_TO_MAKE_IS_REF(arg);
- }
- Z_ADDREF_P(arg);
+//??? if (Z_TYPE_P(arg) != IS_OBJECT) {
+//??? SEPARATE_ZVAL_TO_MAKE_IS_REF(arg);
+//??? }
+ if (IS_REFCOUNTED(Z_TYPE_P(arg))) Z_ADDREF_P(arg);
add_next_index_zval(arg_array, arg);
} else {
add_next_index_null(arg_array);
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 809f05f243..327d4ce083 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -889,7 +889,7 @@ void zend_do_abstract_method(const znode *function_name, znode *modifiers, const
if (Z_LVAL(modifiers->u.constant) & ZEND_ACC_ABSTRACT) {
if(Z_LVAL(modifiers->u.constant) & ZEND_ACC_PRIVATE) {
- zend_error_noreturn(E_COMPILE_ERROR, "%s function %s::%s() cannot be declared private", method_type, CG(active_class_entry)->name, Z_STRVAL(function_name->u.constant));
+ zend_error_noreturn(E_COMPILE_ERROR, "%s function %s::%s() cannot be declared private", method_type, CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant));
}
if (Z_LVAL(body->u.constant) == ZEND_ACC_ABSTRACT) {
zend_op *opline = get_next_op(CG(active_op_array) TSRMLS_CC);
@@ -899,11 +899,11 @@ void zend_do_abstract_method(const znode *function_name, znode *modifiers, const
SET_UNUSED(opline->op2);
} else {
/* we had code in the function body */
- zend_error_noreturn(E_COMPILE_ERROR, "%s function %s::%s() cannot contain body", method_type, CG(active_class_entry)->name, Z_STRVAL(function_name->u.constant));
+ zend_error_noreturn(E_COMPILE_ERROR, "%s function %s::%s() cannot contain body", method_type, CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant));
}
} else {
if (Z_LVAL(body->u.constant) == ZEND_ACC_ABSTRACT) {
- zend_error_noreturn(E_COMPILE_ERROR, "Non-abstract method %s::%s() must contain body", CG(active_class_entry)->name, Z_STRVAL(function_name->u.constant));
+ zend_error_noreturn(E_COMPILE_ERROR, "Non-abstract method %s::%s() must contain body", CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant));
}
}
}
@@ -1540,7 +1540,7 @@ void zend_do_begin_function_declaration(znode *function_token, znode *function_n
if (is_method) {
if (CG(active_class_entry)->ce_flags & ZEND_ACC_INTERFACE) {
if ((Z_LVAL(fn_flags_znode->u.constant) & ~(ZEND_ACC_STATIC|ZEND_ACC_PUBLIC))) {
- zend_error_noreturn(E_COMPILE_ERROR, "Access type for interface method %s::%s() must be omitted", CG(active_class_entry)->name, Z_STRVAL(function_name->u.constant));
+ zend_error_noreturn(E_COMPILE_ERROR, "Access type for interface method %s::%s() must be omitted", CG(active_class_entry)->name->val, Z_STRVAL(function_name->u.constant));
}
Z_LVAL(fn_flags_znode->u.constant) |= ZEND_ACC_ABSTRACT; /* propagates to the rest of the parser */
}
@@ -5118,7 +5118,7 @@ void zend_do_begin_class_declaration(const znode *class_token, znode *class_name
zend_do_build_namespace_name(&tmp, &tmp, class_name TSRMLS_CC);
*class_name = tmp;
STR_FREE(lcname);
- STR_ALLOC(Z_STRLEN(class_name->u.constant), 0);
+ lcname = STR_ALLOC(Z_STRLEN(class_name->u.constant), 0);
zend_str_tolower_copy(lcname->val, Z_STRVAL(class_name->u.constant), Z_STRLEN(class_name->u.constant));
}
@@ -5407,7 +5407,7 @@ void zend_do_declare_property(znode *var_name, const znode *value, zend_uint acc
if (access_type & ZEND_ACC_FINAL) {
zend_error_noreturn(E_COMPILE_ERROR, "Cannot declare property %s::$%s final, the final modifier is allowed only for methods and classes",
- CG(active_class_entry)->name, Z_STRVAL(var_name->u.constant));
+ CG(active_class_entry)->name->val, Z_STRVAL(var_name->u.constant));
}
if ((existing_property_info = zend_hash_find_ptr(&CG(active_class_entry)->properties_info, Z_STR(var_name->u.constant))) != NULL) {
diff --git a/Zend/zend_exceptions.c b/Zend/zend_exceptions.c
index 196b9aa320..9473751ae4 100644
--- a/Zend/zend_exceptions.c
+++ b/Zend/zend_exceptions.c
@@ -363,9 +363,10 @@ ZEND_METHOD(error_exception, getSeverity)
static int _build_trace_args(zval *arg TSRMLS_DC, int num_args, va_list args, zend_hash_key *hash_key) /* {{{ */
{
- zend_string *str;
+ zend_string *str, **str_ptr;
- str = va_arg(args, zend_string*);
+ str_ptr = va_arg(args, zend_string**);
+ str = *str_ptr;
/* the trivial way would be to do:
* conver_to_string_ex(arg);
@@ -373,6 +374,9 @@ static int _build_trace_args(zval *arg TSRMLS_DC, int num_args, va_list args, ze
* but that could cause some E_NOTICE and also damn long lines.
*/
+ if (Z_TYPE_P(arg) == IS_REFERENCE) {
+ arg = Z_REFVAL_P(arg);
+ }
switch (Z_TYPE_P(arg)) {
case IS_NULL:
TRACE_APPEND_STR("NULL, ");
@@ -449,6 +453,7 @@ static int _build_trace_args(zval *arg TSRMLS_DC, int num_args, va_list args, ze
default:
break;
}
+ *str_ptr = str;
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
@@ -460,14 +465,15 @@ static int _build_trace_string(zval *frame TSRMLS_DC, int num_args, va_list args
long line;
HashTable *ht = Z_ARRVAL_P(frame);
zval *file, *tmp;
- zend_string *str;
+ zend_string *str, **str_ptr;
if (Z_TYPE_P(frame) != IS_ARRAY) {
zend_error(E_WARNING, "Expected array for frame %lu", hash_key->h);
return ZEND_HASH_APPLY_KEEP;
}
- str = va_arg(args, zend_string*);
+ str_ptr = va_arg(args, zend_string**);
+ str = *str_ptr;
num = va_arg(args, int*);
s_tmp = emalloc(1 + MAX_LENGTH_OF_LONG + 1 + 1);
@@ -507,7 +513,7 @@ static int _build_trace_string(zval *frame TSRMLS_DC, int num_args, va_list args
if (tmp) {
if (Z_TYPE_P(tmp) == IS_ARRAY) {
int last_len = str->len;
- zend_hash_apply_with_arguments(Z_ARRVAL_P(tmp) TSRMLS_CC, (apply_func_args_t)_build_trace_args, 1, str);
+ zend_hash_apply_with_arguments(Z_ARRVAL_P(tmp) TSRMLS_CC, (apply_func_args_t)_build_trace_args, 1, &str);
if (last_len != str->len) {
str->len -= 2; /* remove last ', ' */
}
@@ -516,6 +522,7 @@ static int _build_trace_string(zval *frame TSRMLS_DC, int num_args, va_list args
}
}
TRACE_APPEND_STR(")\n");
+ *str_ptr = str;
return ZEND_HASH_APPLY_KEEP;
}
/* }}} */
@@ -534,7 +541,7 @@ ZEND_METHOD(exception, getTraceAsString)
str = STR_ALLOC(0, 0);
trace = zend_read_property(default_exception_ce, getThis(), "trace", sizeof("trace")-1, 1 TSRMLS_CC);
- zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)_build_trace_string, 2, str, &num);
+ zend_hash_apply_with_arguments(Z_ARRVAL_P(trace) TSRMLS_CC, (apply_func_args_t)_build_trace_string, 2, &str, &num);
len = sprintf(s_tmp, "#%d {main}", num);
TRACE_APPEND_STRL(s_tmp, len);
@@ -615,12 +622,12 @@ ZEND_METHOD(exception, __toString)
if (Z_STRLEN(message) > 0) {
len = zend_spprintf(&str, 0, "exception '%s' with message '%s' in %s:%ld\nStack trace:\n%s%s%s",
- Z_OBJCE_P(exception)->name, Z_STRVAL(message), Z_STRVAL(file), Z_LVAL(line),
+ Z_OBJCE_P(exception)->name->val, Z_STRVAL(message), Z_STRVAL(file), Z_LVAL(line),
(Z_TYPE(trace) == IS_STRING && Z_STRLEN(trace)) ? Z_STRVAL(trace) : "#0 {main}\n",
len ? "\n\nNext " : "", prev_str);
} else {
len = zend_spprintf(&str, 0, "exception '%s' in %s:%ld\nStack trace:\n%s%s%s",
- Z_OBJCE_P(exception)->name, Z_STRVAL(file), Z_LVAL(line),
+ Z_OBJCE_P(exception)->name->val, Z_STRVAL(file), Z_LVAL(line),
(Z_TYPE(trace) == IS_STRING && Z_STRLEN(trace)) ? Z_STRVAL(trace) : "#0 {main}\n",
len ? "\n\nNext " : "", prev_str);
}
diff --git a/Zend/zend_execute.c b/Zend/zend_execute.c
index d61cd0586d..3299c1f682 100644
--- a/Zend/zend_execute.c
+++ b/Zend/zend_execute.c
@@ -1143,7 +1143,8 @@ fetch_from_array:
} else {
retval = zend_fetch_dimension_address_inner(Z_ARRVAL_P(container), dim, dim_type, type TSRMLS_CC);
}
- ZVAL_COPY(result, retval);
+//??? ZVAL_COPY(result, retval);
+ ZVAL_INDIRECT(result, retval);
return;
break;
@@ -1240,7 +1241,8 @@ convert_to_array:
//??? }
//??? AI_SET_PTR(result, overloaded_result);
//??? PZVAL_LOCK(overloaded_result);
- ZVAL_COPY(result, overloaded_result);
+//??? ZVAL_COPY(result, overloaded_result);
+ ZVAL_INDIRECT(result, overloaded_result);
} else {
result = &EG(error_zval);
}
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index bf43338546..bbed28d783 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -511,7 +511,7 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
actual_len -= (actual - Z_STRVAL_P(p));
if (inline_change) {
zend_string *s = STR_INIT(actual, actual_len, 0);
- STR_RELEASE(Z_STR_P(p));
+//??? STR_RELEASE(Z_STR_P(p));
Z_STR_P(p) = s;
}
}
@@ -531,12 +531,12 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
zend_error(E_ERROR, "Undefined constant '%s'", save->val);
}
if (inline_change) {
- STR_RELEASE(save);
+//??? STR_RELEASE(save);
}
save = NULL;
}
if (inline_change && save && save->val != actual) {
- STR_RELEASE(save);
+//??? STR_RELEASE(save);
}
zend_error(E_NOTICE, "Use of undefined constant %s - assumed '%s'", actual, actual);
p->type = IS_STRING;
@@ -546,12 +546,12 @@ ZEND_API int zval_update_constant_ex(zval *p, void *arg, zend_class_entry *scope
}
} else {
if (inline_change) {
- STR_RELEASE(Z_STR_P(p));
+//??? STR_RELEASE(Z_STR_P(p));
}
*p = const_value;
}
- Z_SET_REFCOUNT_P(p, refcount);
+ if (IS_REFCOUNTED(Z_TYPE_P(p))) Z_SET_REFCOUNT_P(p, refcount);
//??? Z_SET_ISREF_TO_P(p, is_ref);
} else if (Z_TYPE_P(p) == IS_CONSTANT_ARRAY) {
zval *element, new_val;
diff --git a/Zend/zend_interfaces.c b/Zend/zend_interfaces.c
index c8898e1694..75f6165c3b 100644
--- a/Zend/zend_interfaces.c
+++ b/Zend/zend_interfaces.c
@@ -40,8 +40,12 @@ ZEND_API zval* zend_call_method(zval *object, zend_class_entry *obj_ce, zend_fun
zval params[2];
- ZVAL_COPY_VALUE(&params[0], arg1);
- ZVAL_COPY_VALUE(&params[1], arg2);
+ if (param_count > 0) {
+ ZVAL_COPY_VALUE(&params[0], arg1);
+ }
+ if (param_count > 1) {
+ ZVAL_COPY_VALUE(&params[1], arg2);
+ }
fci.size = sizeof(fci);
/*fci.function_table = NULL; will be read form zend_class_entry of object if needed */
diff --git a/Zend/zend_object_handlers.c b/Zend/zend_object_handlers.c
index 6d58cb7d26..7cb16e18bd 100644
--- a/Zend/zend_object_handlers.c
+++ b/Zend/zend_object_handlers.c
@@ -566,12 +566,14 @@ found:
} else {
zval garbage;
- ZVAL_COPY_VALUE(&garbage, Z_REFVAL_P(variable_ptr));
+ ZVAL_COPY_VALUE(&garbage, variable_ptr);
/* if we assign referenced variable, we should separate it */
- Z_ADDREF_P(value);
- if (Z_ISREF_P(value)) {
- SEPARATE_ZVAL(value);
+ if (IS_REFCOUNTED(Z_TYPE_P(value))) {
+ Z_ADDREF_P(value);
+ if (Z_ISREF_P(value)) {
+ SEPARATE_ZVAL(value);
+ }
}
ZVAL_COPY_VALUE(variable_ptr, value);
zval_ptr_dtor(&garbage);
@@ -605,9 +607,11 @@ found:
}
} else if (EXPECTED(property_info != NULL)) {
/* if we assign referenced variable, we should separate it */
- Z_ADDREF_P(value);
- if (Z_ISREF_P(value)) {
- SEPARATE_ZVAL(value);
+ if (IS_REFCOUNTED(Z_TYPE_P(value))) {
+ Z_ADDREF_P(value);
+ if (Z_ISREF_P(value)) {
+ SEPARATE_ZVAL(value);
+ }
}
if (EXPECTED((property_info->flags & ZEND_ACC_STATIC) == 0) &&
property_info->offset >= 0) {
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index 29ec699242..58dcb48ce8 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -4727,7 +4727,6 @@ ZEND_VM_HANDLER(158, ZEND_JMP_SET_VAR, CONST|TMP|VAR|CV, ANY)
if (i_zend_is_true(value TSRMLS_CC)) {
if (OP1_TYPE == IS_VAR || OP1_TYPE == IS_CV) {
ZVAL_COPY(EX_VAR(opline->result.var), value);
- Z_ADDREF_P(value);
} else {
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
if (!IS_OP1_TMP_FREE()) {
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index 6bc43bf750..cd0395c6c6 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -3155,7 +3155,6 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLE
if (i_zend_is_true(value TSRMLS_CC)) {
if (IS_CONST == IS_VAR || IS_CONST == IS_CV) {
ZVAL_COPY(EX_VAR(opline->result.var), value);
- Z_ADDREF_P(value);
} else {
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
if (!0) {
@@ -8152,7 +8151,6 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_
if (i_zend_is_true(value TSRMLS_CC)) {
if (IS_TMP_VAR == IS_VAR || IS_TMP_VAR == IS_CV) {
ZVAL_COPY(EX_VAR(opline->result.var), value);
- Z_ADDREF_P(value);
} else {
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
if (!1) {
@@ -13240,7 +13238,6 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_
if (i_zend_is_true(value TSRMLS_CC)) {
if (IS_VAR == IS_VAR || IS_VAR == IS_CV) {
ZVAL_COPY(EX_VAR(opline->result.var), value);
- Z_ADDREF_P(value);
} else {
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
if (!0) {
@@ -29691,7 +29688,6 @@ static int ZEND_FASTCALL ZEND_JMP_SET_VAR_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_A
if (i_zend_is_true(value TSRMLS_CC)) {
if (IS_CV == IS_VAR || IS_CV == IS_CV) {
ZVAL_COPY(EX_VAR(opline->result.var), value);
- Z_ADDREF_P(value);
} else {
ZVAL_COPY_VALUE(EX_VAR(opline->result.var), value);
if (!0) {