Remove string copy

Changed 'ecma_copy_or_ref_ecma_string' to 'ecma_ref_ecma_string'. It does
not copy the string if the maximum number of reference counter is reached,
but bails out with an error like the 'ecma_ref_object' function does.

JerryScript-DCO-1.0-Signed-off-by: László Langó llango.u-szeged@partner.samsung.com
This commit is contained in:
László Langó
2016-06-14 13:51:44 +02:00
parent 7a3ed2650d
commit 0daeb2f942
18 changed files with 36 additions and 117 deletions
@@ -175,7 +175,7 @@ ecma_builtin_array_prototype_object_to_locale_string (const ecma_value_t this_ar
ecma_builtin_helper_get_to_locale_string_at_index (obj_p, 0),
ret_value);
ecma_string_t *return_string_p = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (first_value));
ecma_string_t *return_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (first_value));
/* 9-10. */
for (uint32_t k = 1; ecma_is_value_empty (ret_value) && (k < length); k++)
@@ -402,7 +402,7 @@ ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argume
ecma_op_array_get_to_string_at_index (obj_p, 0),
ret_value);
ecma_string_t *return_string_p = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (first_value));
ecma_string_t *return_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (first_value));
/* 9-10. */
for (uint32_t k = 1; ecma_is_value_empty (ret_value) && (k < length); k++)
@@ -125,11 +125,11 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
if (ecma_string_get_length (name_string_p) == 0)
{
ret_str_p = ecma_copy_or_ref_ecma_string (msg_string_p);
ret_str_p = ecma_ref_ecma_string (msg_string_p);
}
else if (ecma_string_get_length (msg_string_p) == 0)
{
ret_str_p = ecma_copy_or_ref_ecma_string (name_string_p);
ret_str_p = ecma_ref_ecma_string (name_string_p);
}
else
{
@@ -992,7 +992,7 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
if (num_of_chars < 10)
{
context.gap_str_p = ecma_copy_or_ref_ecma_string (space_str_p);
context.gap_str_p = ecma_ref_ecma_string (space_str_p);
}
else
{
@@ -1061,7 +1061,7 @@ ecma_builtin_json_quote (ecma_string_t *string_p) /**< string that should be quo
{
/* 1. */
ecma_string_t *quote_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_DOUBLE_QUOTE_CHAR);
ecma_string_t *product_str_p = ecma_copy_or_ref_ecma_string (quote_str_p);
ecma_string_t *product_str_p = ecma_ref_ecma_string (quote_str_p);
ecma_string_t *tmp_str_p;
ECMA_STRING_TO_UTF8_STRING (string_p, string_buff, string_buff_size);
@@ -168,7 +168,7 @@ ecma_builtin_regexp_prototype_compile (ecma_value_t this_arg, /**< this argument
}
else
{
pattern_string_p = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (regexp_str_value));
pattern_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (regexp_str_value));
}
ECMA_FINALIZE (regexp_str_value);
@@ -380,7 +380,7 @@ ecma_builtin_regexp_prototype_to_string (ecma_value_t this_arg) /**< this argume
ecma_string_t *src_sep_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_SLASH_CHAR);
ecma_string_t *source_str_p = ecma_get_string_from_value (ecma_get_named_data_property_value (source_prop_p));
ecma_string_t *output_str_p = ecma_concat_ecma_strings (src_sep_str_p, ecma_copy_or_ref_ecma_string (source_str_p));
ecma_string_t *output_str_p = ecma_concat_ecma_strings (src_sep_str_p, ecma_ref_ecma_string (source_str_p));
ecma_deref_ecma_string (source_str_p);
ecma_string_t *concat_p = ecma_concat_ecma_strings (output_str_p, src_sep_str_p);
@@ -109,7 +109,7 @@ ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /*
}
else
{
pattern_string_p = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (regexp_str_value));
pattern_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (regexp_str_value));
}
ECMA_FINALIZE (regexp_str_value);
@@ -125,7 +125,7 @@ ecma_builtin_regexp_dispatch_construct (const ecma_value_t *arguments_list_p, /*
ecma_op_to_string (flags_value),
ret_value);
flags_string_p = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (flags_str_value));
flags_string_p = ecma_ref_ecma_string (ecma_get_string_from_value (flags_str_value));
ECMA_FINALIZE (flags_str_value);
}
@@ -82,7 +82,7 @@ ecma_builtin_string_prototype_object_to_string (ecma_value_t this_arg) /**< this
ecma_string_t *prim_value_str_p;
prim_value_str_p = ecma_get_string_from_value (ecma_get_internal_property_value (prim_value_prop_p));
prim_value_str_p = ecma_copy_or_ref_ecma_string (prim_value_str_p);
prim_value_str_p = ecma_ref_ecma_string (prim_value_str_p);
return ecma_make_string_value (prim_value_str_p);
}
@@ -253,7 +253,7 @@ ecma_builtin_string_prototype_object_concat (ecma_value_t this_arg, /**< this ar
// No copy performed
/* 4 */
ecma_string_t *string_to_return = ecma_copy_or_ref_ecma_string (ecma_get_string_from_value (to_string_val));
ecma_string_t *string_to_return = ecma_ref_ecma_string (ecma_get_string_from_value (to_string_val));
/* 5 */
for (uint32_t arg_index = 0;
@@ -659,7 +659,7 @@ ecma_builtin_string_prototype_object_replace_append_substr (ecma_string_t *base_
}
else
{
ret_string_p = ecma_copy_or_ref_ecma_string (base_string_p);
ret_string_p = ecma_ref_ecma_string (base_string_p);
}
return ret_string_p;