ecma_ref_ecma_string -> ecma_copy_or_ref_ecma_string: copying ecma-string when the string's reference counter reaches maximum value.
This commit is contained in:
@@ -174,7 +174,7 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this) /**< this arg
|
|||||||
|
|
||||||
ecma_string_t *prim_value_str_p = ECMA_GET_POINTER (prim_value_prop_p->u.internal_property.value);
|
ecma_string_t *prim_value_str_p = ECMA_GET_POINTER (prim_value_prop_p->u.internal_property.value);
|
||||||
|
|
||||||
ecma_ref_ecma_string (prim_value_str_p);
|
prim_value_str_p = ecma_copy_or_ref_ecma_string (prim_value_str_p);
|
||||||
|
|
||||||
return ecma_make_normal_completion_value (ecma_make_string_value (prim_value_str_p));
|
return ecma_make_normal_completion_value (ecma_make_string_value (prim_value_str_p));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -265,8 +265,8 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
|
|||||||
string_desc_p->length = (ecma_length_t) length;
|
string_desc_p->length = (ecma_length_t) length;
|
||||||
}
|
}
|
||||||
|
|
||||||
ecma_ref_ecma_string (string1_p);
|
string1_p = ecma_copy_or_ref_ecma_string (string1_p);
|
||||||
ecma_ref_ecma_string (string2_p);
|
string2_p = ecma_copy_or_ref_ecma_string (string2_p);
|
||||||
|
|
||||||
ECMA_SET_NON_NULL_POINTER (string_desc_p->u.concatenation.string1_cp, string1_p);
|
ECMA_SET_NON_NULL_POINTER (string_desc_p->u.concatenation.string1_cp, string1_p);
|
||||||
ECMA_SET_NON_NULL_POINTER (string_desc_p->u.concatenation.string2_cp, string2_p);
|
ECMA_SET_NON_NULL_POINTER (string_desc_p->u.concatenation.string2_cp, string2_p);
|
||||||
@@ -278,18 +278,40 @@ ecma_concat_ecma_strings (ecma_string_t *string1_p, /**< first ecma-string */
|
|||||||
* Increase reference counter of ecma-string.
|
* Increase reference counter of ecma-string.
|
||||||
*
|
*
|
||||||
* @return pointer to same ecma-string descriptor with increased reference counter
|
* @return pointer to same ecma-string descriptor with increased reference counter
|
||||||
|
* or the ecma-string's copy with reference counter set to 1
|
||||||
*/
|
*/
|
||||||
void
|
ecma_string_t*
|
||||||
ecma_ref_ecma_string (ecma_string_t *string_desc_p) /**< string descriptor */
|
ecma_copy_or_ref_ecma_string (ecma_string_t *string_desc_p) /**< string descriptor */
|
||||||
{
|
{
|
||||||
JERRY_ASSERT (string_desc_p != NULL);
|
JERRY_ASSERT (string_desc_p != NULL);
|
||||||
JERRY_ASSERT (string_desc_p->refs > 0);
|
JERRY_ASSERT (string_desc_p->refs > 0);
|
||||||
|
|
||||||
string_desc_p->refs++;
|
string_desc_p->refs++;
|
||||||
|
|
||||||
/* Check for overflow */
|
if (unlikely (string_desc_p->refs == 0))
|
||||||
JERRY_ASSERT (string_desc_p->refs > 0);
|
{
|
||||||
} /* ecma_ref_ecma_string */
|
string_desc_p->refs--;
|
||||||
|
|
||||||
|
if (string_desc_p->container == ECMA_STRING_CONTAINER_CHARS_IN_DESC
|
||||||
|
|| string_desc_p->container == ECMA_STRING_CONTAINER_LIT_TABLE
|
||||||
|
|| string_desc_p->container == ECMA_STRING_CONTAINER_UINT32_IN_DESC)
|
||||||
|
{
|
||||||
|
ecma_string_t *new_str_p = ecma_alloc_string ();
|
||||||
|
|
||||||
|
*new_str_p = *string_desc_p;
|
||||||
|
|
||||||
|
new_str_p->refs = 1;
|
||||||
|
|
||||||
|
return new_str_p;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
JERRY_UNIMPLEMENTED ();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return string_desc_p;
|
||||||
|
} /* ecma_copy_or_ref_ecma_string */
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Decrease reference counter and deallocate ecma-string if
|
* Decrease reference counter and deallocate ecma-string if
|
||||||
|
|||||||
@@ -212,9 +212,13 @@ ecma_copy_value (const ecma_value_t value, /**< ecma-value */
|
|||||||
ecma_string_t *string_p = ECMA_GET_POINTER(value.value);
|
ecma_string_t *string_p = ECMA_GET_POINTER(value.value);
|
||||||
JERRY_ASSERT(string_p != NULL);
|
JERRY_ASSERT(string_p != NULL);
|
||||||
|
|
||||||
ecma_ref_ecma_string (string_p);
|
string_p = ecma_copy_or_ref_ecma_string (string_p);
|
||||||
|
|
||||||
value_copy = value;
|
value_copy = (ecma_value_t)
|
||||||
|
{
|
||||||
|
.value_type = ECMA_TYPE_STRING
|
||||||
|
};
|
||||||
|
ECMA_SET_NON_NULL_POINTER(value_copy.value, string_p);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -454,7 +454,7 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
|||||||
|
|
||||||
prop_p->type = ECMA_PROPERTY_NAMEDDATA;
|
prop_p->type = ECMA_PROPERTY_NAMEDDATA;
|
||||||
|
|
||||||
ecma_ref_ecma_string (name_p);
|
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_data_property.name_p, name_p);
|
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_data_property.name_p, name_p);
|
||||||
|
|
||||||
prop_p->u.named_data_property.writable = writable;
|
prop_p->u.named_data_property.writable = writable;
|
||||||
@@ -490,7 +490,7 @@ ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
|||||||
|
|
||||||
prop_p->type = ECMA_PROPERTY_NAMEDACCESSOR;
|
prop_p->type = ECMA_PROPERTY_NAMEDACCESSOR;
|
||||||
|
|
||||||
ecma_ref_ecma_string (name_p);
|
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||||
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_accessor_property.name_p, name_p);
|
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_accessor_property.name_p, name_p);
|
||||||
|
|
||||||
ECMA_SET_POINTER(prop_p->u.named_accessor_property.get_p, get_p);
|
ECMA_SET_POINTER(prop_p->u.named_accessor_property.get_p, get_p);
|
||||||
|
|||||||
@@ -102,7 +102,7 @@ extern ecma_string_t* ecma_new_ecma_string_from_number (ecma_number_t number);
|
|||||||
extern ecma_string_t* ecma_new_ecma_string_from_lit_index (literal_index_t lit_index);
|
extern ecma_string_t* ecma_new_ecma_string_from_lit_index (literal_index_t lit_index);
|
||||||
extern ecma_string_t* ecma_new_ecma_string_from_magic_string_id (ecma_magic_string_id_t id);
|
extern ecma_string_t* ecma_new_ecma_string_from_magic_string_id (ecma_magic_string_id_t id);
|
||||||
extern ecma_string_t* ecma_concat_ecma_strings (ecma_string_t *string1_p, ecma_string_t *string2_p);
|
extern ecma_string_t* ecma_concat_ecma_strings (ecma_string_t *string1_p, ecma_string_t *string2_p);
|
||||||
extern void ecma_ref_ecma_string (ecma_string_t *string_desc_p);
|
extern ecma_string_t* ecma_copy_or_ref_ecma_string (ecma_string_t *string_desc_p);
|
||||||
extern void ecma_deref_ecma_string (ecma_string_t *string_p);
|
extern void ecma_deref_ecma_string (ecma_string_t *string_p);
|
||||||
extern ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
extern ecma_number_t ecma_string_to_number (const ecma_string_t *str_p);
|
||||||
extern ssize_t ecma_string_to_zt_string (const ecma_string_t *string_desc_p,
|
extern ssize_t ecma_string_to_zt_string (const ecma_string_t *string_desc_p,
|
||||||
|
|||||||
@@ -421,7 +421,7 @@ ecma_op_to_string (ecma_value_t value) /**< ecma-value */
|
|||||||
case ECMA_TYPE_STRING:
|
case ECMA_TYPE_STRING:
|
||||||
{
|
{
|
||||||
res_p = ECMA_GET_POINTER (value.value);
|
res_p = ECMA_GET_POINTER (value.value);
|
||||||
ecma_ref_ecma_string (res_p);
|
res_p = ecma_copy_or_ref_ecma_string (res_p);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ ecma_make_reference (ecma_value_t base, /**< base value */
|
|||||||
ecma_string_t *name_p, /**< referenced name */
|
ecma_string_t *name_p, /**< referenced name */
|
||||||
bool is_strict) /**< strict reference flag */
|
bool is_strict) /**< strict reference flag */
|
||||||
{
|
{
|
||||||
ecma_ref_ecma_string (name_p);
|
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||||
|
|
||||||
ecma_reference_t ref = (ecma_reference_t)
|
ecma_reference_t ref = (ecma_reference_t)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -118,8 +118,7 @@ ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< the array obj
|
|||||||
{
|
{
|
||||||
uint32_index = property_name_p->u.uint32_number;
|
uint32_index = property_name_p->u.uint32_number;
|
||||||
|
|
||||||
ecma_ref_ecma_string (property_name_p);
|
new_prop_name_p = ecma_copy_or_ref_ecma_string (property_name_p);
|
||||||
new_prop_name_p = property_name_p;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user