Improve magic string handling. (#2221)
Remove unnecessary ref / deref calls when magic strings are used. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -519,24 +519,20 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
|
||||
/* a. */
|
||||
prop_desc.value = src_prop_desc_p->value;
|
||||
|
||||
ecma_string_t *value_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_VALUE);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
value_magic_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_VALUE),
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (value_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
/* b. */
|
||||
const bool is_writable = (src_prop_desc_p->is_writable);
|
||||
prop_desc.value = ecma_make_boolean_value (is_writable);
|
||||
|
||||
ecma_string_t *writable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
writable_magic_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE),
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (writable_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
}
|
||||
else
|
||||
@@ -555,12 +551,10 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->get_p);
|
||||
}
|
||||
|
||||
ecma_string_t *get_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GET);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
get_magic_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_GET),
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (get_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
/* b. */
|
||||
@@ -573,35 +567,29 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
|
||||
prop_desc.value = ecma_make_object_value (src_prop_desc_p->set_p);
|
||||
}
|
||||
|
||||
ecma_string_t *set_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SET);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
set_magic_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_SET),
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (set_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
}
|
||||
|
||||
const bool is_enumerable = src_prop_desc_p->is_enumerable;
|
||||
prop_desc.value = ecma_make_boolean_value (is_enumerable);
|
||||
|
||||
ecma_string_t *enumerable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
enumerable_magic_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE),
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (enumerable_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
const bool is_configurable = src_prop_desc_p->is_configurable;
|
||||
prop_desc.value = ecma_make_boolean_value (is_configurable);
|
||||
|
||||
ecma_string_t *configurable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE);
|
||||
completion = ecma_op_object_define_own_property (obj_p,
|
||||
configurable_magic_string_p,
|
||||
ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE),
|
||||
&prop_desc,
|
||||
false);
|
||||
ecma_deref_ecma_string (configurable_magic_string_p);
|
||||
JERRY_ASSERT (ecma_is_value_true (completion));
|
||||
|
||||
return obj_p;
|
||||
@@ -637,10 +625,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
|
||||
|
||||
/* 3. */
|
||||
ecma_string_t *enumerable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE);
|
||||
|
||||
ECMA_TRY_CATCH (enumerable_prop_value,
|
||||
ecma_op_object_find (obj_p, enumerable_magic_string_p),
|
||||
ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE)),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_found (enumerable_prop_value))
|
||||
@@ -651,17 +637,13 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
|
||||
ECMA_FINALIZE (enumerable_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (enumerable_magic_string_p);
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
{
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
|
||||
/* 4. */
|
||||
ecma_string_t *configurable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE);
|
||||
|
||||
ECMA_TRY_CATCH (configurable_prop_value,
|
||||
ecma_op_object_find (obj_p, configurable_magic_string_p),
|
||||
ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE)),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_found (configurable_prop_value))
|
||||
@@ -671,8 +653,6 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (configurable_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (configurable_magic_string_p);
|
||||
}
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
@@ -680,10 +660,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
|
||||
/* 5. */
|
||||
ecma_string_t *value_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_VALUE);
|
||||
|
||||
ECMA_TRY_CATCH (value_prop_value,
|
||||
ecma_op_object_find (obj_p, value_magic_string_p),
|
||||
ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_VALUE)),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_found (value_prop_value))
|
||||
@@ -693,8 +671,6 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (value_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (value_magic_string_p);
|
||||
}
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
@@ -702,10 +678,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
|
||||
/* 6. */
|
||||
ecma_string_t *writable_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE);
|
||||
|
||||
ECMA_TRY_CATCH (writable_prop_value,
|
||||
ecma_op_object_find (obj_p, writable_magic_string_p),
|
||||
ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE)),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_found (writable_prop_value))
|
||||
@@ -715,8 +689,6 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (writable_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (writable_magic_string_p);
|
||||
}
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
@@ -724,10 +696,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
|
||||
/* 7. */
|
||||
ecma_string_t *get_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_GET);
|
||||
|
||||
ECMA_TRY_CATCH (get_prop_value,
|
||||
ecma_op_object_find (obj_p, get_magic_string_p),
|
||||
ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_GET)),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_found (get_prop_value))
|
||||
@@ -758,8 +728,6 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (get_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (get_magic_string_p);
|
||||
}
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
@@ -767,10 +735,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
JERRY_ASSERT (ecma_is_value_empty (ret_value));
|
||||
|
||||
/* 8. */
|
||||
ecma_string_t *set_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_SET);
|
||||
|
||||
ECMA_TRY_CATCH (set_prop_value,
|
||||
ecma_op_object_find (obj_p, set_magic_string_p),
|
||||
ecma_op_object_find (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_SET)),
|
||||
ret_value);
|
||||
|
||||
if (ecma_is_value_found (set_prop_value))
|
||||
@@ -801,8 +767,6 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
|
||||
}
|
||||
|
||||
ECMA_FINALIZE (set_prop_value);
|
||||
|
||||
ecma_deref_ecma_string (set_magic_string_p);
|
||||
}
|
||||
|
||||
if (!ECMA_IS_VALUE_ERROR (ret_value))
|
||||
|
||||
Reference in New Issue
Block a user