summaryrefslogtreecommitdiff
path: root/Zend
diff options
context:
space:
mode:
Diffstat (limited to 'Zend')
-rw-r--r--Zend/zend.c2
-rw-r--r--Zend/zend_builtin_functions.c8
-rw-r--r--Zend/zend_compile.c18
-rw-r--r--Zend/zend_constants.c2
-rw-r--r--Zend/zend_execute_API.c4
-rw-r--r--Zend/zend_hash.c3
-rw-r--r--Zend/zend_types.h14
-rw-r--r--Zend/zend_vm_def.h15
-rw-r--r--Zend/zend_vm_execute.h21
9 files changed, 39 insertions, 48 deletions
diff --git a/Zend/zend.c b/Zend/zend.c
index 78b18dbbc6..f7b6ceb70e 100644
--- a/Zend/zend.c
+++ b/Zend/zend.c
@@ -278,7 +278,7 @@ again:
case IS_REFERENCE:
expr = Z_REFVAL_P(expr);
if (Z_TYPE_P(expr) == IS_STRING) {
- ZVAL_STR(expr_copy, zend_string_copy(Z_STR_P(expr)));
+ ZVAL_STR_COPY(expr_copy, Z_STR_P(expr));
return 1;
}
goto again;
diff --git a/Zend/zend_builtin_functions.c b/Zend/zend_builtin_functions.c
index 1bb02ef2eb..7885a45528 100644
--- a/Zend/zend_builtin_functions.c
+++ b/Zend/zend_builtin_functions.c
@@ -660,7 +660,7 @@ ZEND_FUNCTION(each)
/* add the key elements */
if (zend_hash_get_current_key(target_hash, &key, &num_key, 0) == HASH_KEY_IS_STRING) {
- ZVAL_STR(&tmp, zend_string_copy(key));
+ ZVAL_STR_COPY(&tmp, key);
if (Z_REFCOUNTED(tmp)) Z_ADDREF(tmp);
} else {
ZVAL_LONG(&tmp, num_key);
@@ -1131,7 +1131,7 @@ ZEND_FUNCTION(get_class_methods)
/* Do not display old-style inherited constructors */
if (!key) {
- ZVAL_STR(&method_name, zend_string_copy(mptr->common.function_name));
+ ZVAL_STR_COPY(&method_name, mptr->common.function_name);
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
} else if ((mptr->common.fn_flags & ZEND_ACC_CTOR) == 0 ||
mptr->common.scope == ce ||
@@ -1141,10 +1141,10 @@ ZEND_FUNCTION(get_class_methods)
*mptr->op_array.refcount > 1 &&
(len != key->len ||
!same_name(key->val, mptr->common.function_name->val, len))) {
- ZVAL_STR(&method_name, zend_string_copy(zend_find_alias_name(mptr->common.scope, key)));
+ ZVAL_STR_COPY(&method_name, zend_find_alias_name(mptr->common.scope, key));
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
} else {
- ZVAL_STR(&method_name, zend_string_copy(mptr->common.function_name));
+ ZVAL_STR_COPY(&method_name, mptr->common.function_name);
zend_hash_next_index_insert_new(Z_ARRVAL_P(return_value), &method_name);
}
}
diff --git a/Zend/zend_compile.c b/Zend/zend_compile.c
index 8748dc0c98..4205a942e0 100644
--- a/Zend/zend_compile.c
+++ b/Zend/zend_compile.c
@@ -6528,7 +6528,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
ZVAL_LONG(zv, CG(zend_lineno));
break;
case T_FILE:
- ZVAL_STR(zv, zend_string_copy(CG(compiled_filename)));
+ ZVAL_STR_COPY(zv, CG(compiled_filename));
break;
case T_DIR:
{
@@ -6551,7 +6551,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
}
case T_FUNC_C:
if (op_array && op_array->function_name) {
- ZVAL_STR(zv, zend_string_copy(op_array->function_name));
+ ZVAL_STR_COPY(zv, op_array->function_name);
} else {
ZVAL_EMPTY_STRING(zv);
}
@@ -6562,10 +6562,10 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
ZVAL_NEW_STR(zv, zend_concat3(ce->name->val, ce->name->len, "::", 2,
op_array->function_name->val, op_array->function_name->len));
} else {
- ZVAL_STR(zv, zend_string_copy(ce->name));
+ ZVAL_STR_COPY(zv, ce->name);
}
} else if (op_array && op_array->function_name) {
- ZVAL_STR(zv, zend_string_copy(op_array->function_name));
+ ZVAL_STR_COPY(zv, op_array->function_name);
} else {
ZVAL_EMPTY_STRING(zv);
}
@@ -6575,7 +6575,7 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
if (ZEND_CE_IS_TRAIT(ce)) {
return 0;
} else {
- ZVAL_STR(zv, zend_string_copy(ce->name));
+ ZVAL_STR_COPY(zv, ce->name);
}
} else {
ZVAL_EMPTY_STRING(zv);
@@ -6583,14 +6583,14 @@ static zend_bool zend_try_ct_eval_magic_const(zval *zv, zend_ast *ast TSRMLS_DC)
break;
case T_TRAIT_C:
if (ce && ZEND_CE_IS_TRAIT(ce)) {
- ZVAL_STR(zv, zend_string_copy(ce->name));
+ ZVAL_STR_COPY(zv, ce->name);
} else {
ZVAL_EMPTY_STRING(zv);
}
break;
case T_NS_C:
if (CG(current_namespace)) {
- ZVAL_STR(zv, zend_string_copy(CG(current_namespace)));
+ ZVAL_STR_COPY(zv, CG(current_namespace));
} else {
ZVAL_EMPTY_STRING(zv);
}
@@ -7265,7 +7265,7 @@ void zend_compile_resolve_class_name(znode *result, zend_ast *ast TSRMLS_DC) /*
"Cannot access self::class when no class scope is active");
}
result->op_type = IS_CONST;
- ZVAL_STR(&result->u.constant, zend_string_copy(CG(active_class_entry)->name));
+ ZVAL_STR_COPY(&result->u.constant, CG(active_class_entry)->name);
break;
case ZEND_FETCH_CLASS_STATIC:
case ZEND_FETCH_CLASS_PARENT:
@@ -7469,7 +7469,7 @@ void zend_compile_const_expr_resolve_class_name(zend_ast **ast_ptr TSRMLS_DC) /*
zend_error_noreturn(E_COMPILE_ERROR,
"Cannot access self::class when no class scope is active");
}
- ZVAL_STR(&result, zend_string_copy(CG(active_class_entry)->name));
+ ZVAL_STR_COPY(&result, CG(active_class_entry)->name);
break;
case ZEND_FETCH_CLASS_STATIC:
case ZEND_FETCH_CLASS_PARENT:
diff --git a/Zend/zend_constants.c b/Zend/zend_constants.c
index bca35cf591..164901f898 100644
--- a/Zend/zend_constants.c
+++ b/Zend/zend_constants.c
@@ -246,7 +246,7 @@ static zend_constant *zend_get_special_constant(const char *name, uint name_len
if ((c = zend_hash_find_ptr(EG(zend_constants), const_name)) == NULL) {
c = emalloc(sizeof(zend_constant));
memset(c, 0, sizeof(zend_constant));
- ZVAL_STR(&c->value, zend_string_copy(EG(scope)->name));
+ ZVAL_STR_COPY(&c->value, EG(scope)->name);
zend_hash_add_ptr(EG(zend_constants), const_name, c);
}
zend_string_release(const_name);
diff --git a/Zend/zend_execute_API.c b/Zend/zend_execute_API.c
index 5b3d597112..f59a10179b 100644
--- a/Zend/zend_execute_API.c
+++ b/Zend/zend_execute_API.c
@@ -1011,12 +1011,12 @@ ZEND_API zend_class_entry *zend_lookup_class_ex(zend_string *name, const zval *k
if (name->val[0] == '\\') {
ZVAL_STRINGL(&args[0], name->val + 1, name->len - 1);
} else {
- ZVAL_STR(&args[0], zend_string_copy(name));
+ ZVAL_STR_COPY(&args[0], name);
}
fcall_info.size = sizeof(fcall_info);
fcall_info.function_table = EG(function_table);
- ZVAL_STR(&fcall_info.function_name, zend_string_copy(EG(autoload_func)->common.function_name));
+ ZVAL_STR_COPY(&fcall_info.function_name, EG(autoload_func)->common.function_name);
fcall_info.symbol_table = NULL;
fcall_info.retval = &local_retval;
fcall_info.param_count = 1;
diff --git a/Zend/zend_hash.c b/Zend/zend_hash.c
index d541b3168f..6304737f04 100644
--- a/Zend/zend_hash.c
+++ b/Zend/zend_hash.c
@@ -1599,8 +1599,7 @@ ZEND_API void zend_hash_get_current_key_zval_ex(const HashTable *ht, zval *key,
} else {
p = ht->arData + idx;
if (p->key) {
- ZVAL_STR(key, p->key);
- zend_string_addref(p->key);
+ ZVAL_STR_COPY(key, p->key);
} else {
ZVAL_LONG(key, p->h);
}
diff --git a/Zend/zend_types.h b/Zend/zend_types.h
index e23842c679..c654106192 100644
--- a/Zend/zend_types.h
+++ b/Zend/zend_types.h
@@ -537,10 +537,22 @@ static zend_always_inline zend_uchar zval_get_type(const zval* pz) {
zval *__z = (z); \
zend_string *__s = (s); \
Z_STR_P(__z) = __s; \
- /* interned strings support */ \
Z_TYPE_INFO_P(__z) = IS_STRING_EX; \
} while (0)
+#define ZVAL_STR_COPY(z, s) do { \
+ zval *__z = (z); \
+ zend_string *__s = (s); \
+ Z_STR_P(__z) = __s; \
+ /* interned strings support */ \
+ if (IS_INTERNED(__s)) { \
+ Z_TYPE_INFO_P(__z) = IS_INTERNED_STRING_EX; \
+ } else { \
+ GC_REFCOUNT(__s)++; \
+ Z_TYPE_INFO_P(__z) = IS_STRING_EX; \
+ } \
+ } while (0)
+
#define ZVAL_ARR(z, a) do { \
zval *__z = (z); \
Z_ARR_P(__z) = (a); \
diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h
index ac015aea52..b4f8c83f1b 100644
--- a/Zend/zend_vm_def.h
+++ b/Zend/zend_vm_def.h
@@ -3883,8 +3883,7 @@ ZEND_VM_HANDLER(99, ZEND_FETCH_CONSTANT, VAR|CONST|UNUSED, CONST)
ZVAL_DUP(EX_VAR(opline->result.var), value);
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
- ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- zend_string_addref(ce->name);
+ ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -4716,11 +4715,8 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
if (!p->key) {
ZVAL_LONG(EX_VAR((opline+1)->result.var), p->h);
- } else if (IS_INTERNED(p->key)) {
- ZVAL_INTERNED_STR(EX_VAR((opline+1)->result.var), p->key);
} else {
- ZVAL_NEW_STR(EX_VAR((opline+1)->result.var), p->key);
- GC_REFCOUNT(p->key)++;
+ ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
}
}
break;
@@ -4796,12 +4792,7 @@ ZEND_VM_HANDLER(78, ZEND_FE_FETCH, VAR, ANY)
} else if (zend_check_property_access(zobj, p->key TSRMLS_CC) == SUCCESS) {
if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
if (p->key->val[0]) {
- if (IS_INTERNED(p->key)) {
- ZVAL_INTERNED_STR(EX_VAR((opline+1)->result.var), p->key);
- } else {
- ZVAL_NEW_STR(EX_VAR((opline+1)->result.var), p->key);
- GC_REFCOUNT(p->key)++;
- }
+ ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
} else {
const char *class_name, *prop_name;
size_t prop_name_len;
diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h
index d2afba6272..d575db0018 100644
--- a/Zend/zend_vm_execute.h
+++ b/Zend/zend_vm_execute.h
@@ -4311,8 +4311,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_CONST_CONST_HANDLER(ZEND_OPCO
ZVAL_DUP(EX_VAR(opline->result.var), value);
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
- ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- zend_string_addref(ce->name);
+ ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -16676,11 +16675,8 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
if (!p->key) {
ZVAL_LONG(EX_VAR((opline+1)->result.var), p->h);
- } else if (IS_INTERNED(p->key)) {
- ZVAL_INTERNED_STR(EX_VAR((opline+1)->result.var), p->key);
} else {
- ZVAL_NEW_STR(EX_VAR((opline+1)->result.var), p->key);
- GC_REFCOUNT(p->key)++;
+ ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
}
}
break;
@@ -16756,12 +16752,7 @@ static int ZEND_FASTCALL ZEND_FE_FETCH_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARG
} else if (zend_check_property_access(zobj, p->key TSRMLS_CC) == SUCCESS) {
if (opline->extended_value & ZEND_FE_FETCH_WITH_KEY) {
if (p->key->val[0]) {
- if (IS_INTERNED(p->key)) {
- ZVAL_INTERNED_STR(EX_VAR((opline+1)->result.var), p->key);
- } else {
- ZVAL_NEW_STR(EX_VAR((opline+1)->result.var), p->key);
- GC_REFCOUNT(p->key)++;
- }
+ ZVAL_STR_COPY(EX_VAR((opline+1)->result.var), p->key);
} else {
const char *class_name, *prop_name;
size_t prop_name_len;
@@ -18714,8 +18705,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_VAR_CONST_HANDLER(ZEND_OPCODE
ZVAL_DUP(EX_VAR(opline->result.var), value);
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
- ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- zend_string_addref(ce->name);
+ ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}
@@ -27977,8 +27967,7 @@ static int ZEND_FASTCALL ZEND_FETCH_CONSTANT_SPEC_UNUSED_CONST_HANDLER(ZEND_OPC
ZVAL_DUP(EX_VAR(opline->result.var), value);
} else if (Z_STRLEN_P(opline->op2.zv) == sizeof("class")-1 && memcmp(Z_STRVAL_P(opline->op2.zv), "class", sizeof("class") - 1) == 0) {
/* "class" is assigned as a case-sensitive keyword from zend_do_resolve_class_name */
- ZVAL_STR(EX_VAR(opline->result.var), ce->name);
- zend_string_addref(ce->name);
+ ZVAL_STR_COPY(EX_VAR(opline->result.var), ce->name);
} else {
zend_error_noreturn(E_ERROR, "Undefined class constant '%s'", Z_STRVAL_P(opline->op2.zv));
}