Add fast path to ecma_op_object_get with magic string. (#2078)

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2017-12-05 17:17:56 +01:00
committed by Dániel Bátyai
parent a8dffe023e
commit e964393abe
19 changed files with 133 additions and 208 deletions
@@ -94,11 +94,9 @@ ecma_builtin_array_prototype_object_to_string (ecma_value_t this_arg) /**< this
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this_value);
ecma_string_t *join_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_JOIN);
/* 2. */
ECMA_TRY_CATCH (join_value,
ecma_op_object_get (obj_p, join_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_JOIN),
ret_value);
if (!ecma_op_is_callable (join_value))
@@ -115,9 +113,6 @@ ecma_builtin_array_prototype_object_to_string (ecma_value_t this_arg) /**< this
}
ECMA_FINALIZE (join_value);
ecma_deref_ecma_string (join_magic_string_p);
ECMA_FINALIZE (obj_this_value);
return ret_value;
@@ -144,11 +139,9 @@ ecma_builtin_array_prototype_object_to_locale_string (const ecma_value_t this_ar
ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
ecma_string_t *length_magic_string_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (length_value,
ecma_op_object_get (obj_p, length_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
/* 3. */
@@ -214,9 +207,6 @@ ecma_builtin_array_prototype_object_to_locale_string (const ecma_value_t this_ar
ECMA_OP_TO_NUMBER_FINALIZE (length_number);
ECMA_FINALIZE (length_value);
ecma_deref_ecma_string (length_magic_string_p);
ECMA_FINALIZE (obj_value);
return ret_value;
@@ -368,11 +358,9 @@ ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argume
ecma_object_t *obj_p = ecma_get_object_from_value (obj_value);
ecma_string_t *length_magic_string_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (length_value,
ecma_op_object_get (obj_p, length_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (length_number,
@@ -445,9 +433,6 @@ ecma_builtin_array_prototype_join (const ecma_value_t this_arg, /**< this argume
ECMA_OP_TO_NUMBER_FINALIZE (length_number);
ECMA_FINALIZE (length_value);
ecma_deref_ecma_string (length_magic_string_p);
ECMA_FINALIZE (obj_value);
return ret_value;
@@ -473,11 +458,10 @@ ecma_builtin_array_prototype_object_pop (ecma_value_t this_arg) /**< this argume
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -526,7 +510,6 @@ ecma_builtin_array_prototype_object_pop (ecma_value_t this_arg) /**< this argume
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -554,9 +537,9 @@ ecma_builtin_array_prototype_object_push (ecma_value_t this_arg, /**< this argum
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this_value);
/* 2. */
ecma_string_t *length_str_p = ecma_new_ecma_length_string ();
ECMA_TRY_CATCH (length_value, ecma_op_object_get (obj_p, length_str_p), ret_value);
ECMA_TRY_CATCH (length_value,
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
/* 3. */
ECMA_OP_TO_NUMBER_TRY_CATCH (length_var, length_value, ret_value);
@@ -595,9 +578,6 @@ ecma_builtin_array_prototype_object_push (ecma_value_t this_arg, /**< this argum
ECMA_OP_TO_NUMBER_FINALIZE (length_var);
ECMA_FINALIZE (length_value);
ecma_deref_ecma_string (length_str_p);
ECMA_FINALIZE (obj_this_value);
return ret_value;
@@ -623,11 +603,10 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg) /**< this ar
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
/* 3. */
@@ -693,7 +672,6 @@ ecma_builtin_array_prototype_object_reverse (ecma_value_t this_arg) /**< this ar
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -719,11 +697,10 @@ ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argu
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -806,7 +783,6 @@ ecma_builtin_array_prototype_object_shift (ecma_value_t this_arg) /**< this argu
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -834,10 +810,9 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t this_arg, /**< 'this' ar
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *length_magic_string_p = ecma_new_ecma_length_string ();
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, length_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
/* 3. */
@@ -922,7 +897,6 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t this_arg, /**< 'this' ar
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (length_magic_string_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -1204,10 +1178,9 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -1325,7 +1298,6 @@ ecma_builtin_array_prototype_object_sort (ecma_value_t this_arg, /**< this argum
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -1355,10 +1327,8 @@ ecma_builtin_array_prototype_object_splice (ecma_value_t this_arg, /**< this arg
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
/* 3. */
ecma_string_t *length_magic_string_p = ecma_new_ecma_length_string ();
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, length_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
/* 4. */
@@ -1610,7 +1580,6 @@ ecma_builtin_array_prototype_object_splice (ecma_value_t this_arg, /**< this arg
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (length_magic_string_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -1638,11 +1607,10 @@ ecma_builtin_array_prototype_object_unshift (ecma_value_t this_arg, /**< this ar
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -1707,7 +1675,6 @@ ecma_builtin_array_prototype_object_unshift (ecma_value_t this_arg, /**< this ar
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -1735,11 +1702,10 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -1799,9 +1765,6 @@ ecma_builtin_array_prototype_object_index_of (ecma_value_t this_arg, /**< this a
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -1830,11 +1793,10 @@ ecma_builtin_array_prototype_object_last_index_of (ecma_value_t this_arg, /**< t
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -1946,7 +1908,6 @@ ecma_builtin_array_prototype_object_last_index_of (ecma_value_t this_arg, /**< t
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -1974,11 +1935,10 @@ ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argu
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -2045,7 +2005,6 @@ ecma_builtin_array_prototype_object_every (ecma_value_t this_arg, /**< this argu
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -2073,11 +2032,10 @@ ecma_builtin_array_prototype_object_some (ecma_value_t this_arg, /**< this argum
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -2145,7 +2103,6 @@ ecma_builtin_array_prototype_object_some (ecma_value_t this_arg, /**< this argum
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -2172,11 +2129,10 @@ ecma_builtin_array_prototype_object_for_each (ecma_value_t this_arg, /**< this a
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -2237,7 +2193,6 @@ ecma_builtin_array_prototype_object_for_each (ecma_value_t this_arg, /**< this a
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -2265,11 +2220,10 @@ ecma_builtin_array_prototype_object_map (ecma_value_t this_arg, /**< this argume
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -2349,7 +2303,6 @@ ecma_builtin_array_prototype_object_map (ecma_value_t this_arg, /**< this argume
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -2377,11 +2330,10 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t this_arg, /**< this arg
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
/* 3. */
@@ -2469,7 +2421,6 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t this_arg, /**< this arg
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -2499,11 +2450,10 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -2624,7 +2574,6 @@ ecma_builtin_array_prototype_object_reduce (ecma_value_t this_arg, /**< this arg
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -2654,11 +2603,10 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
ret_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_this);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 2. */
ECMA_TRY_CATCH (len_value,
ecma_op_object_get (obj_p, magic_string_length_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (len_number, len_value, ret_value);
@@ -2780,7 +2728,6 @@ ecma_builtin_array_prototype_object_reduce_right (ecma_value_t this_arg, /**< th
ECMA_OP_TO_NUMBER_FINALIZE (len_number);
ECMA_FINALIZE (len_value);
ecma_deref_ecma_string (magic_string_length_p);
ECMA_FINALIZE (obj_this);
return ret_value;
@@ -151,12 +151,11 @@ ecma_builtin_date_prototype_to_json (ecma_value_t this_arg) /**< this argument *
if (ecma_is_value_empty (ret_value))
{
ecma_string_t *to_iso_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_ISO_STRING_UL);
ecma_object_t *value_obj_p = ecma_get_object_from_value (obj);
/* 4. */
ECMA_TRY_CATCH (to_iso,
ecma_op_object_get (value_obj_p, to_iso_str_p),
ecma_op_object_get_by_magic_id (value_obj_p, LIT_MAGIC_STRING_TO_ISO_STRING_UL),
ret_value);
/* 5. */
@@ -172,8 +171,6 @@ ecma_builtin_date_prototype_to_json (ecma_value_t this_arg) /**< this argument *
}
ECMA_FINALIZE (to_iso);
ecma_deref_ecma_string (to_iso_str_p);
}
ECMA_FINALIZE (tv);
@@ -65,10 +65,9 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
else
{
ecma_object_t *obj_p = ecma_get_object_from_value (this_arg);
ecma_string_t *name_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_NAME);
ECMA_TRY_CATCH (name_get_ret_value,
ecma_op_object_get (obj_p, name_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_NAME),
ret_value);
ecma_value_t name_to_str_completion;
@@ -90,10 +89,8 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
}
else
{
ecma_string_t *message_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE);
ECMA_TRY_CATCH (msg_get_ret_value,
ecma_op_object_get (obj_p, message_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_MESSAGE),
ret_value);
ecma_value_t msg_to_str_completion;
@@ -173,15 +170,11 @@ ecma_builtin_error_prototype_object_to_string (ecma_value_t this_arg) /**< this
ecma_free_value (msg_to_str_completion);
ECMA_FINALIZE (msg_get_ret_value);
ecma_deref_ecma_string (message_magic_string_p);
}
ecma_free_value (name_to_str_completion);
ECMA_FINALIZE (name_get_ret_value);
ecma_deref_ecma_string (name_magic_string_p);
}
return ret_value;
@@ -109,11 +109,10 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this a
else
{
ecma_object_t *obj_p = ecma_get_object_from_value (arg2);
ecma_string_t *length_magic_string_p = ecma_new_ecma_length_string ();
/* 4. */
ECMA_TRY_CATCH (length_value,
ecma_op_object_get (obj_p, length_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (length_number,
@@ -163,7 +162,6 @@ ecma_builtin_function_prototype_object_apply (ecma_value_t this_arg, /**< this a
ECMA_OP_TO_NUMBER_FINALIZE (length_number);
ECMA_FINALIZE (length_value);
ecma_deref_ecma_string (length_magic_string_p);
}
}
}
@@ -141,10 +141,9 @@ ecma_builtin_helper_get_to_locale_string_at_index (ecma_object_t *obj_p, /**< th
ret_value);
ecma_object_t *index_obj_p = ecma_get_object_from_value (index_obj_value);
ecma_string_t *locale_string_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_LOCALE_STRING_UL);
ECMA_TRY_CATCH (to_locale_value,
ecma_op_object_get (index_obj_p, locale_string_magic_string_p),
ecma_op_object_get_by_magic_id (index_obj_p, LIT_MAGIC_STRING_TO_LOCALE_STRING_UL),
ret_value);
if (ecma_op_is_callable (to_locale_value))
@@ -166,9 +165,6 @@ ecma_builtin_helper_get_to_locale_string_at_index (ecma_object_t *obj_p, /**< th
}
ECMA_FINALIZE (to_locale_value);
ecma_deref_ecma_string (locale_string_magic_string_p);
ECMA_FINALIZE (index_obj_value);
}
@@ -332,11 +328,10 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
if (ecma_is_value_object (value)
&& (ecma_object_get_class_name (ecma_get_object_from_value (value)) == LIT_MAGIC_STRING_ARRAY_UL))
{
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
/* 5.b.ii */
ECMA_TRY_CATCH (arg_len_value,
ecma_op_object_get (ecma_get_object_from_value (value),
magic_string_length_p),
ecma_op_object_get_by_magic_id (ecma_get_object_from_value (value),
LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (arg_len_number, arg_len_value, ret_value);
@@ -383,7 +378,6 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
ECMA_OP_TO_NUMBER_FINALIZE (arg_len_number);
ECMA_FINALIZE (arg_len_value);
ecma_deref_ecma_string (magic_string_length_p);
}
else
{
@@ -924,10 +924,8 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
/* 4.b */
else if (ecma_object_get_class_name (obj_p) == LIT_MAGIC_STRING_ARRAY_UL)
{
ecma_string_t *length_str_p = ecma_new_ecma_length_string ();
ECMA_TRY_CATCH (array_length,
ecma_op_object_get (obj_p, length_str_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (array_length_num,
@@ -1007,8 +1005,6 @@ ecma_builtin_json_stringify (ecma_value_t this_arg, /**< 'this' argument */
ECMA_OP_TO_NUMBER_FINALIZE (array_length_num);
ECMA_FINALIZE (array_length);
ecma_deref_ecma_string (length_str_p);
}
}
@@ -1328,11 +1324,10 @@ ecma_builtin_json_str (ecma_string_t *key_p, /**< property key*/
if (ecma_is_value_object (my_val))
{
ecma_object_t *value_obj_p = ecma_get_object_from_value (my_val);
ecma_string_t *to_json_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_JSON_UL);
/* 2.a */
ECMA_TRY_CATCH (toJSON,
ecma_op_object_get (value_obj_p, to_json_str_p),
ecma_op_object_get_by_magic_id (value_obj_p, LIT_MAGIC_STRING_TO_JSON_UL),
ret_value);
/* 2.b */
@@ -1353,8 +1348,6 @@ ecma_builtin_json_str (ecma_string_t *key_p, /**< property key*/
}
ECMA_FINALIZE (toJSON);
ecma_deref_ecma_string (to_json_str_p);
}
/* 3. */
@@ -1727,11 +1720,9 @@ ecma_builtin_json_array (ecma_object_t *obj_p, /**< the array object*/
/* 5. */
ecma_collection_header_t *partial_p = ecma_new_values_collection (NULL, 0, true);
ecma_string_t *length_str_p = ecma_new_ecma_length_string ();
/* 6. */
ECMA_TRY_CATCH (array_length,
ecma_op_object_get (obj_p, length_str_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (array_length_num,
@@ -1819,7 +1810,6 @@ ecma_builtin_json_array (ecma_object_t *obj_p, /**< the array object*/
ECMA_OP_TO_NUMBER_FINALIZE (array_length_num);
ECMA_FINALIZE (array_length);
ecma_deref_ecma_string (length_str_p);
ecma_free_values_collection (partial_p, true);
/* 11. */
@@ -93,11 +93,10 @@ ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /*
return_value);
ecma_object_t *obj_p = ecma_get_object_from_value (obj_val);
ecma_string_t *to_string_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_TO_STRING_UL);
/* 2. */
ECMA_TRY_CATCH (to_string_val,
ecma_op_object_get (obj_p, to_string_magic_string_p),
ecma_op_object_get_by_magic_id (obj_p, LIT_MAGIC_STRING_TO_STRING_UL),
return_value);
/* 3. */
@@ -111,10 +110,8 @@ ecma_builtin_object_prototype_object_to_locale_string (ecma_value_t this_arg) /*
ecma_object_t *to_string_func_obj_p = ecma_get_object_from_value (to_string_val);
return_value = ecma_op_function_call (to_string_func_obj_p, this_arg, NULL, 0);
}
ECMA_FINALIZE (to_string_val);
ecma_deref_ecma_string (to_string_magic_string_p);
ECMA_FINALIZE (obj_val);
return return_value;
@@ -205,10 +205,8 @@ ecma_builtin_promise_do_race (ecma_value_t array, /**< the array for race */
JERRY_ASSERT (ecma_get_object_type (ecma_get_object_from_value (array)) == ECMA_OBJECT_TYPE_ARRAY);
ecma_value_t ret = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
ecma_object_t *array_p = ecma_get_object_from_value (array);
ecma_value_t len_value = ecma_op_object_get (array_p, magic_string_length_p);
ecma_deref_ecma_string (magic_string_length_p);
ecma_value_t len_value = ecma_op_object_get_by_magic_id (array_p, LIT_MAGIC_STRING_LENGTH);
ecma_length_t len = (ecma_length_t) ecma_get_integer_from_value (len_value);
ecma_fast_free_value (len_value);
@@ -416,10 +414,8 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
JERRY_ASSERT (ecma_get_object_type (ecma_get_object_from_value (array)) == ECMA_OBJECT_TYPE_ARRAY);
ecma_value_t ret = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ecma_string_t *magic_string_length_p = ecma_new_ecma_length_string ();
ecma_object_t *array_p = ecma_get_object_from_value (array);
ecma_value_t len_value = ecma_op_object_get (array_p, magic_string_length_p);
ecma_deref_ecma_string (magic_string_length_p);
ecma_value_t len_value = ecma_op_object_get_by_magic_id (array_p, LIT_MAGIC_STRING_LENGTH);
ecma_length_t len = (ecma_length_t) ecma_get_integer_from_value (len_value);
ecma_fast_free_value (len_value);
@@ -430,11 +430,10 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this arg
{
JERRY_ASSERT (!ecma_is_value_empty (regexp_value));
ecma_object_t *regexp_obj_p = ecma_get_object_from_value (regexp_value);
ecma_string_t *global_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
/* 5. */
ECMA_TRY_CATCH (global_value,
ecma_op_object_get (regexp_obj_p, global_string_p),
ecma_op_object_get_by_magic_id (regexp_obj_p, LIT_MAGIC_STRING_GLOBAL),
ret_value);
JERRY_ASSERT (ecma_is_value_boolean (global_value));
@@ -489,7 +488,7 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this arg
{
/* 8.f.iii. */
ECMA_TRY_CATCH (this_index_value,
ecma_op_object_get (regexp_obj_p, last_index_string_p),
ecma_op_object_get_by_magic_id (regexp_obj_p, LIT_MAGIC_STRING_LASTINDEX_UL),
ret_value);
ECMA_TRY_CATCH (this_index_number,
@@ -583,8 +582,6 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_arg, /**< this arg
ECMA_FINALIZE (global_value);
ecma_deref_ecma_string (global_string_p);
ecma_free_value (regexp_value);
}
@@ -691,11 +688,10 @@ ecma_builtin_string_prototype_object_replace_match (ecma_builtin_replace_search_
JERRY_ASSERT (ecma_is_value_object (match_value));
ecma_object_t *match_object_p = ecma_get_object_from_value (match_value);
ecma_string_t *index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
ecma_string_t *zero_string_p = ecma_new_ecma_string_from_uint32 (0);
ECMA_TRY_CATCH (index_value,
ecma_op_object_get (match_object_p, index_string_p),
ecma_op_object_get_by_magic_id (match_object_p, LIT_MAGIC_STRING_INDEX),
ret_value);
ECMA_TRY_CATCH (result_string_value,
@@ -722,7 +718,7 @@ ecma_builtin_string_prototype_object_replace_match (ecma_builtin_replace_search_
ECMA_FINALIZE (result_string_value);
ECMA_FINALIZE (index_value);
ecma_deref_ecma_string (index_string_p);
ecma_deref_ecma_string (zero_string_p);
}
else
@@ -775,11 +771,10 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
ecma_value_t match_value) /**< returned match value */
{
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY);
ecma_string_t *length_string_p = ecma_new_ecma_length_string ();
ecma_object_t *match_object_p = ecma_get_object_from_value (match_value);
ECMA_TRY_CATCH (match_length_value,
ecma_op_object_get (match_object_p, length_string_p),
ecma_op_object_get_by_magic_id (match_object_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
JERRY_ASSERT (ecma_is_value_number (match_length_value));
@@ -1049,7 +1044,6 @@ ecma_builtin_string_prototype_object_replace_get_string (ecma_builtin_replace_se
}
ECMA_FINALIZE (match_length_value);
ecma_deref_ecma_string (length_string_p);
return ret_value;
} /* ecma_builtin_string_prototype_object_replace_get_string */
@@ -1260,10 +1254,9 @@ ecma_builtin_string_prototype_object_replace (ecma_value_t this_arg, /**< this a
&& ecma_object_class_is (ecma_get_object_from_value (search_value), LIT_MAGIC_STRING_REGEXP_UL))
{
ecma_object_t *regexp_obj_p = ecma_get_object_from_value (search_value);
ecma_string_t *global_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GLOBAL);
ECMA_TRY_CATCH (global_value,
ecma_op_object_get (regexp_obj_p, global_string_p),
ecma_op_object_get_by_magic_id (regexp_obj_p, LIT_MAGIC_STRING_GLOBAL),
ret_value);
JERRY_ASSERT (ecma_is_value_boolean (global_value));
@@ -1295,7 +1288,6 @@ ecma_builtin_string_prototype_object_replace (ecma_value_t this_arg, /**< this a
}
ECMA_FINALIZE (global_value);
ecma_deref_ecma_string (global_string_p);
}
else
{
@@ -1381,10 +1373,9 @@ ecma_builtin_string_prototype_object_search (ecma_value_t this_arg, /**< this ar
JERRY_ASSERT (ecma_is_value_object (match_result));
ecma_object_t *match_object_p = ecma_get_object_from_value (match_result);
ecma_string_t *index_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
ECMA_TRY_CATCH (index_value,
ecma_op_object_get (match_object_p, index_string_p),
ecma_op_object_get_by_magic_id (match_object_p, LIT_MAGIC_STRING_INDEX),
ret_value);
JERRY_ASSERT (ecma_is_value_number (index_value));
@@ -1392,7 +1383,6 @@ ecma_builtin_string_prototype_object_search (ecma_value_t this_arg, /**< this ar
offset = ecma_get_number_from_value (index_value);
ECMA_FINALIZE (index_value);
ecma_deref_ecma_string (index_string_p);
}
if (ecma_is_value_empty (ret_value))
@@ -1698,7 +1688,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
else
{
ecma_object_t *match_obj_p = ecma_get_object_from_value (match_result);
ecma_string_t *zero_str_p = ecma_new_ecma_string_from_number (ECMA_NUMBER_ZERO);
ecma_string_t *zero_str_p = ecma_new_ecma_string_from_uint32 (0);
ecma_string_t *magic_index_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
ecma_property_value_t *index_prop_value_p;
@@ -1786,10 +1776,9 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
/* 13.c.iii.5 */
start_pos = end_pos + match_str_length;
ecma_string_t *magic_length_str_p = ecma_new_ecma_length_string ();
ECMA_TRY_CATCH (array_length_val,
ecma_op_object_get (match_obj_p, magic_length_str_p),
ecma_op_object_get_by_magic_id (match_obj_p, LIT_MAGIC_STRING_LENGTH),
ret_value);
ECMA_OP_TO_NUMBER_TRY_CATCH (array_length_num, array_length_val, ret_value);
@@ -1842,7 +1831,6 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_arg, /**< this arg
ECMA_OP_TO_NUMBER_FINALIZE (array_length_num);
ECMA_FINALIZE (array_length_val);
ecma_deref_ecma_string (magic_length_str_p);
ecma_deref_ecma_string (array_length_str_p);
ecma_deref_ecma_string (substr_str_p);
}
@@ -704,18 +704,21 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument
ECMA_TRY_CATCH (source_obj, ecma_op_to_object (arr_val), ret_val);
/* 18.~ 19. */
ecma_string_t length_str;
ecma_init_ecma_length_string (&length_str);
ecma_object_t *source_obj_p = ecma_get_object_from_value (source_obj);
ECMA_TRY_CATCH (source_length,
ecma_op_object_get (source_obj_p, &length_str),
ecma_op_object_get_by_magic_id (source_obj_p, LIT_MAGIC_STRING_LENGTH),
ret_val);
ECMA_OP_TO_NUMBER_TRY_CATCH (source_length_num, source_length, ret_val);
if (ecma_number_is_nan (source_length_num) || source_length_num <= 0)
{
source_length_num = 0;
}
uint32_t source_length_uint32 = ecma_number_to_uint32 (source_length_num);
if ((ecma_number_t) source_length_uint32 != source_length_num)
{
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid source length"));
@@ -730,17 +733,23 @@ ecma_builtin_typedarray_prototype_set (ecma_value_t this_arg, /**< this argument
/* 21.~ 25. */
uint32_t target_byte_index = target_offset_uint32 * element_size;
uint32_t k = 0;
while (k < source_length_uint32 && ecma_is_value_empty (ret_val))
{
ecma_string_t k_str;
ecma_init_ecma_string_from_uint32 (&k_str, k);
ECMA_TRY_CATCH (elem,
ecma_op_object_get (source_obj_p, &k_str),
ret_val);
ECMA_OP_TO_NUMBER_TRY_CATCH (elem_num, elem, ret_val);
ecma_set_typedarray_element (target_buffer_p + target_byte_index, elem_num, target_class_id);
ECMA_OP_TO_NUMBER_FINALIZE (elem_num);
ECMA_FINALIZE (elem);
k++;
target_byte_index += element_size;
}