Optimize ecma_builtin_helper_def_prop. (#3007)

This patch removes the ecma_property_descriptor_t structure bitfields and substitutes it with an uint16_t flag field
to reduce the cost of the transformation from/into the ecma_property_flags_t.
Also the is_throw last arguments is embedded to the property descriptor structure during the property defining process to reduce the number of arguments of the function.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2019-08-27 18:28:03 +02:00
committed by Dániel Bátyai
parent d0435e1db0
commit ee1da14577
23 changed files with 291 additions and 354 deletions
+33 -24
View File
@@ -2204,16 +2204,22 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor (); ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
prop_desc.is_enumerable_defined = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_enumerable_defined); uint32_t flags = ECMA_PROP_NO_OPTS;
prop_desc.is_enumerable = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_enumerable_defined ? prop_desc_p->is_enumerable
: false);
prop_desc.is_configurable_defined = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_configurable_defined); if (prop_desc_p->is_enumerable_defined)
prop_desc.is_configurable = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_configurable_defined ? prop_desc_p->is_configurable {
: false); flags |= (uint32_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | (prop_desc_p->is_enumerable ? ECMA_PROP_IS_ENUMERABLE
: ECMA_PROP_NO_OPTS));
}
if (prop_desc_p->is_configurable_defined)
{
flags |= (uint32_t) (ECMA_PROP_IS_CONFIGURABLE_DEFINED | (prop_desc_p->is_enumerable ? ECMA_PROP_IS_CONFIGURABLE
: ECMA_PROP_NO_OPTS));
}
/* Copy data property info. */ /* Copy data property info. */
prop_desc.is_value_defined = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_value_defined); flags |= (prop_desc_p->is_value_defined ? ECMA_PROP_IS_VALUE_DEFINED : ECMA_PROP_NO_OPTS);
if (prop_desc_p->is_value_defined) if (prop_desc_p->is_value_defined)
{ {
@@ -2225,15 +2231,17 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
prop_desc.value = prop_desc_p->value; prop_desc.value = prop_desc_p->value;
} }
prop_desc.is_writable_defined = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_writable_defined); if (prop_desc_p->is_writable_defined)
prop_desc.is_writable = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_writable_defined ? prop_desc_p->is_writable {
: false); flags |= (uint32_t) (ECMA_PROP_IS_WRITABLE_DEFINED | (prop_desc_p->is_writable ? ECMA_PROP_IS_WRITABLE
: ECMA_PROP_NO_OPTS));
}
/* Copy accessor property info. */ /* Copy accessor property info. */
if (prop_desc_p->is_get_defined) if (prop_desc_p->is_get_defined)
{ {
ecma_value_t getter = prop_desc_p->getter; ecma_value_t getter = prop_desc_p->getter;
prop_desc.is_get_defined = true; flags |= ECMA_PROP_IS_GET_DEFINED;
if (ecma_is_value_error_reference (getter)) if (ecma_is_value_error_reference (getter))
{ {
@@ -2253,7 +2261,7 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
if (prop_desc_p->is_set_defined) if (prop_desc_p->is_set_defined)
{ {
ecma_value_t setter = prop_desc_p->setter; ecma_value_t setter = prop_desc_p->setter;
prop_desc.is_set_defined = true; flags |= ECMA_PROP_IS_SET_DEFINED;
if (ecma_is_value_error_reference (setter)) if (ecma_is_value_error_reference (setter))
{ {
@@ -2270,10 +2278,11 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */
} }
} }
prop_desc.flags |= (uint16_t) (flags | ECMA_PROP_IS_THROW);
return ecma_op_object_define_own_property (ecma_get_object_from_value (obj_val), return ecma_op_object_define_own_property (ecma_get_object_from_value (obj_val),
ecma_get_prop_name_from_value (prop_name_val), ecma_get_prop_name_from_value (prop_name_val),
&prop_desc, &prop_desc);
true);
} /* jerry_define_own_property */ } /* jerry_define_own_property */
/** /**
@@ -2305,27 +2314,27 @@ jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object val
} }
prop_desc_p->is_configurable_defined = true; prop_desc_p->is_configurable_defined = true;
prop_desc_p->is_configurable = prop_desc.is_configurable; prop_desc_p->is_configurable = (prop_desc.flags & ECMA_PROP_IS_CONFIGURABLE) != 0;
prop_desc_p->is_enumerable_defined = true; prop_desc_p->is_enumerable_defined = true;
prop_desc_p->is_enumerable = prop_desc.is_enumerable; prop_desc_p->is_enumerable = (prop_desc.flags & ECMA_PROP_IS_ENUMERABLE) != 0;
prop_desc_p->is_writable_defined = prop_desc.is_writable_defined; prop_desc_p->is_writable_defined = (prop_desc.flags & ECMA_PROP_IS_WRITABLE_DEFINED) != 0;
prop_desc_p->is_writable = prop_desc.is_writable_defined ? prop_desc.is_writable : false; prop_desc_p->is_writable = prop_desc_p->is_writable_defined ? (prop_desc.flags & ECMA_PROP_IS_WRITABLE) != 0 : false;
prop_desc_p->is_value_defined = prop_desc.is_value_defined; prop_desc_p->is_value_defined = (prop_desc.flags & ECMA_PROP_IS_VALUE_DEFINED) != 0;
prop_desc_p->is_get_defined = prop_desc.is_get_defined; prop_desc_p->is_get_defined = (prop_desc.flags & ECMA_PROP_IS_GET_DEFINED) != 0;
prop_desc_p->is_set_defined = prop_desc.is_set_defined; prop_desc_p->is_set_defined = (prop_desc.flags & ECMA_PROP_IS_SET_DEFINED) != 0;
prop_desc_p->value = ECMA_VALUE_UNDEFINED; prop_desc_p->value = ECMA_VALUE_UNDEFINED;
prop_desc_p->getter = ECMA_VALUE_UNDEFINED; prop_desc_p->getter = ECMA_VALUE_UNDEFINED;
prop_desc_p->setter = ECMA_VALUE_UNDEFINED; prop_desc_p->setter = ECMA_VALUE_UNDEFINED;
if (prop_desc.is_value_defined) if (prop_desc_p->is_value_defined)
{ {
prop_desc_p->value = prop_desc.value; prop_desc_p->value = prop_desc.value;
} }
if (prop_desc.is_get_defined) if (prop_desc_p->is_get_defined)
{ {
if (prop_desc.get_p != NULL) if (prop_desc.get_p != NULL)
{ {
@@ -2337,7 +2346,7 @@ jerry_get_own_property_descriptor (const jerry_value_t obj_val, /**< object val
} }
} }
if (prop_desc.is_set_defined) if (prop_desc_p->is_set_defined)
{ {
if (prop_desc.set_p != NULL) if (prop_desc.set_p != NULL)
{ {
+43 -25
View File
@@ -935,6 +935,23 @@ typedef struct
} ecma_map_object_t; } ecma_map_object_t;
#endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_MAP) || ENABLED (JERRY_ES2015_BUILTIN_SET) */
typedef enum
{
ECMA_PROP_NO_OPTS = (0), /** empty property descriptor */
ECMA_PROP_IS_GET_DEFINED = (1 << 0), /** Is [[Get]] defined? */
ECMA_PROP_IS_SET_DEFINED = (1 << 1), /** Is [[Set]] defined? */
ECMA_PROP_IS_CONFIGURABLE = (1 << 2), /** [[Configurable]] */
ECMA_PROP_IS_ENUMERABLE = (1 << 3), /** [[Enumerable]] */
ECMA_PROP_IS_WRITABLE = (1 << 4), /** [[Writable]] */
ECMA_PROP_IS_THROW = (1 << 5), /** Flag that controls failure handling */
ECMA_PROP_IS_VALUE_DEFINED = (1 << 6), /** Is [[Value]] defined? */
ECMA_PROP_IS_CONFIGURABLE_DEFINED = (1 << 7), /** Is [[Configurable]] defined? */
ECMA_PROP_IS_ENUMERABLE_DEFINED = (1 << 8), /** Is [[Enumerable]] defined? */
ECMA_PROP_IS_WRITABLE_DEFINED = (1 << 9), /** Is [[Writable]] defined? */
} ecma_property_descriptor_status_flags_t;
/** /**
* Description of ECMA property descriptor * Description of ECMA property descriptor
* *
@@ -943,35 +960,13 @@ typedef struct
* Note: * Note:
* If a component of descriptor is undefined then corresponding * If a component of descriptor is undefined then corresponding
* field should contain it's default value. * field should contain it's default value.
* The struct members must be in this order or keep in sync with ecma_property_flags_t and ECMA_IS_THROW flag.
*/ */
typedef struct typedef struct
{ {
/** Is [[Value]] defined? */
unsigned int is_value_defined : 1;
/** Is [[Get]] defined? */ /** any combination of ecma_property_descriptor_status_flags_t bits */
unsigned int is_get_defined : 1; uint16_t flags;
/** Is [[Set]] defined? */
unsigned int is_set_defined : 1;
/** Is [[Writable]] defined? */
unsigned int is_writable_defined : 1;
/** [[Writable]] */
unsigned int is_writable : 1;
/** Is [[Enumerable]] defined? */
unsigned int is_enumerable_defined : 1;
/** [[Enumerable]] */
unsigned int is_enumerable : 1;
/** Is [[Configurable]] defined? */
unsigned int is_configurable_defined : 1;
/** [[Configurable]] */
unsigned int is_configurable : 1;
/** [[Value]] */ /** [[Value]] */
ecma_value_t value; ecma_value_t value;
@@ -983,6 +978,29 @@ typedef struct
ecma_object_t *set_p; ecma_object_t *set_p;
} ecma_property_descriptor_t; } ecma_property_descriptor_t;
/**
* Bitfield which represents a namedata property options in an ecma_property_descriptor_t
* Attributes:
* - is_get_defined, is_set_defined : false
* - is_configurable, is_writable, is_enumberable : undefined (false)
* - is_throw : undefined (false)
* - is_value_defined : true
* - is_configurable_defined, is_writable_defined, is_enumberable_defined : true
*/
#define ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS 0x3c0
/**
* Bitmask to get a the physical property flags from an ecma_property_descriptor
*/
#define ECMA_PROPERTY_FLAGS_MASK 0x1c
/**
* Flag that controls failure handling during defining property
*
* Note: This flags represents the [[DefineOwnProperty]] (P, Desc, Throw) 3rd argument
*/
#define ECMA_IS_THROW (1 << 5)
#if !ENABLED (JERRY_NUMBER_TYPE_FLOAT64) #if !ENABLED (JERRY_NUMBER_TYPE_FLOAT64)
/** /**
* Description of an ecma-number * Description of an ecma-number
+4 -12
View File
@@ -1275,17 +1275,9 @@ ecma_make_empty_property_descriptor (void)
{ {
ecma_property_descriptor_t prop_desc; ecma_property_descriptor_t prop_desc;
prop_desc.is_value_defined = false; prop_desc.flags = 0;
prop_desc.value = ECMA_VALUE_UNDEFINED; prop_desc.value = ECMA_VALUE_UNDEFINED;
prop_desc.is_writable_defined = false;
prop_desc.is_writable = false;
prop_desc.is_enumerable_defined = false;
prop_desc.is_enumerable = false;
prop_desc.is_configurable_defined = false;
prop_desc.is_configurable = false;
prop_desc.is_get_defined = false;
prop_desc.get_p = NULL; prop_desc.get_p = NULL;
prop_desc.is_set_defined = false;
prop_desc.set_p = NULL; prop_desc.set_p = NULL;
return prop_desc; return prop_desc;
@@ -1298,18 +1290,18 @@ ecma_make_empty_property_descriptor (void)
void void
ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< property descriptor */ ecma_free_property_descriptor (ecma_property_descriptor_t *prop_desc_p) /**< property descriptor */
{ {
if (prop_desc_p->is_value_defined) if (prop_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{ {
ecma_free_value (prop_desc_p->value); ecma_free_value (prop_desc_p->value);
} }
if (prop_desc_p->is_get_defined if ((prop_desc_p->flags & ECMA_PROP_IS_GET_DEFINED)
&& prop_desc_p->get_p != NULL) && prop_desc_p->get_p != NULL)
{ {
ecma_deref_object (prop_desc_p->get_p); ecma_deref_object (prop_desc_p->get_p);
} }
if (prop_desc_p->is_set_defined if ((prop_desc_p->flags & ECMA_PROP_IS_SET_DEFINED)
&& prop_desc_p->set_p != NULL) && prop_desc_p->set_p != NULL)
{ {
ecma_deref_object (prop_desc_p->set_p); ecma_deref_object (prop_desc_p->set_p);
@@ -804,12 +804,10 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */
if (ecma_is_value_found (get_value)) if (ecma_is_value_found (get_value))
{ {
/* 10.c.ii */ /* 10.c.ii */
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
n, n,
get_value, get_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
ecma_free_value (get_value); ecma_free_value (get_value);
} }
@@ -1187,12 +1185,10 @@ ecma_builtin_array_prototype_object_splice (const ecma_value_t args[], /**< argu
if (ecma_is_value_found (get_value)) if (ecma_is_value_found (get_value))
{ {
/* 9.c.ii */ /* 9.c.ii */
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
k, k,
get_value, get_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
ecma_free_value (get_value); ecma_free_value (get_value);
@@ -1748,12 +1744,11 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */
} }
/* 8.c.iii */ /* 8.c.iii */
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
index, index,
mapped_value, mapped_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
ecma_free_value (mapped_value); ecma_free_value (mapped_value);
@@ -1848,12 +1843,10 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn *
/* 9.c.iii */ /* 9.c.iii */
if (ecma_op_to_boolean (call_value)) if (ecma_op_to_boolean (call_value))
{ {
/* This will always be a simple value since 'is_throw' is false, so no need to free. */
ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop_by_index (new_array_p,
new_array_index, new_array_index,
get_value, get_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
new_array_index++; new_array_index++;
} }
@@ -291,8 +291,7 @@ ecma_builtin_helper_object_get_properties (ecma_object_t *obj_p, /**< object */
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p, ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p,
index_string_p, index_string_p,
*ecma_value_p, *ecma_value_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
@@ -438,8 +437,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
ecma_value_t put_comp = ecma_builtin_helper_def_prop (obj_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (obj_p,
new_array_index_string_p, new_array_index_string_p,
get_value, get_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
ecma_deref_ecma_string (new_array_index_string_p); ecma_deref_ecma_string (new_array_index_string_p);
@@ -464,9 +462,7 @@ ecma_builtin_helper_array_concat_value (ecma_object_t *obj_p, /**< array */
ecma_value_t put_comp = ecma_builtin_helper_def_prop (obj_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (obj_p,
new_array_index_string_p, new_array_index_string_p,
value, value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
ecma_deref_ecma_string (new_array_index_string_p); ecma_deref_ecma_string (new_array_index_string_p);
@@ -802,24 +798,21 @@ ecma_value_t
ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, /**< object */ ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, /**< object */
uint32_t index, /**< property index */ uint32_t index, /**< property index */
ecma_value_t value, /**< value */ ecma_value_t value, /**< value */
uint32_t opts, /**< any combination of ecma_property_flag_t bits */ uint32_t opts) /**< any combination of ecma_property_flag_t bits */
bool is_throw) /**< is_throw */
{ {
if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM)) if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM))
{ {
return ecma_builtin_helper_def_prop (obj_p, return ecma_builtin_helper_def_prop (obj_p,
ECMA_CREATE_DIRECT_UINT32_STRING (index), ECMA_CREATE_DIRECT_UINT32_STRING (index),
value, value,
opts, opts);
is_throw);
} }
ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index); ecma_string_t *index_str_p = ecma_new_non_direct_string_from_uint32 (index);
ecma_value_t ret_value = ecma_builtin_helper_def_prop (obj_p, ecma_value_t ret_value = ecma_builtin_helper_def_prop (obj_p,
index_str_p, index_str_p,
value, value,
opts, opts);
is_throw);
ecma_deref_ecma_string (index_str_p); ecma_deref_ecma_string (index_str_p);
return ret_value; return ret_value;
@@ -839,27 +832,18 @@ ecma_value_t
ecma_builtin_helper_def_prop (ecma_object_t *obj_p, /**< object */ ecma_builtin_helper_def_prop (ecma_object_t *obj_p, /**< object */
ecma_string_t *index_p, /**< index string */ ecma_string_t *index_p, /**< index string */
ecma_value_t value, /**< value */ ecma_value_t value, /**< value */
uint32_t opts, /**< any combination of ecma_property_flag_t bits */ uint32_t opts) /**< any combination of ecma_property_flag_t bits
bool is_throw) /**< is_throw */ * with the optional ECMA_IS_THROW flag */
{ {
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor (); ecma_property_descriptor_t prop_desc;
prop_desc.flags = (uint16_t) (ECMA_NAME_DATA_PROPERTY_DESCRIPTOR_BITS | opts);
prop_desc.is_value_defined = true;
prop_desc.value = value; prop_desc.value = value;
prop_desc.is_writable_defined = true;
prop_desc.is_writable = (opts & ECMA_PROPERTY_FLAG_WRITABLE) != 0;
prop_desc.is_enumerable_defined = true;
prop_desc.is_enumerable = (opts & ECMA_PROPERTY_FLAG_ENUMERABLE) != 0;
prop_desc.is_configurable_defined = true;
prop_desc.is_configurable = (opts & ECMA_PROPERTY_FLAG_CONFIGURABLE) != 0;
return ecma_op_object_define_own_property (obj_p, return ecma_op_object_define_own_property (obj_p,
index_p, index_p,
&prop_desc, &prop_desc);
is_throw);
} /* ecma_builtin_helper_def_prop */ } /* ecma_builtin_helper_def_prop */
/** /**
@@ -58,11 +58,10 @@ bool
ecma_builtin_helper_string_find_index (ecma_string_t *original_str_p, ecma_string_t *search_str_p, bool first_index, ecma_builtin_helper_string_find_index (ecma_string_t *original_str_p, ecma_string_t *search_str_p, bool first_index,
ecma_length_t start_pos, ecma_length_t *ret_index_p); ecma_length_t start_pos, ecma_length_t *ret_index_p);
ecma_value_t ecma_value_t
ecma_builtin_helper_def_prop (ecma_object_t *obj_p, ecma_string_t *index_p, ecma_value_t value, ecma_builtin_helper_def_prop (ecma_object_t *obj_p, ecma_string_t *index_p, ecma_value_t value, uint32_t opts);
uint32_t opts, bool is_throw);
ecma_value_t ecma_value_t
ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, uint32_t index, ecma_value_t value, ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, uint32_t index, ecma_value_t value, uint32_t opts);
uint32_t opts, bool is_throw);
#if ENABLED (JERRY_BUILTIN_DATE) #if ENABLED (JERRY_BUILTIN_DATE)
@@ -543,8 +543,7 @@ ecma_builtin_json_define_value_property (ecma_object_t *obj_p, /**< this object
ecma_value_t completion_value = ecma_builtin_helper_def_prop (obj_p, ecma_value_t completion_value = ecma_builtin_helper_def_prop (obj_p,
property_name_p, property_name_p,
value, value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_boolean (completion_value)); JERRY_ASSERT (ecma_is_value_boolean (completion_value));
} /* ecma_builtin_json_define_value_property */ } /* ecma_builtin_json_define_value_property */
@@ -683,8 +682,7 @@ ecma_builtin_json_parse_value (ecma_json_token_t *token_p) /**< token argument *
ecma_value_t completion = ecma_builtin_helper_def_prop (array_p, ecma_value_t completion = ecma_builtin_helper_def_prop (array_p,
index_str_p, index_str_p,
value, value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
@@ -918,8 +916,7 @@ static ecma_value_t ecma_builtin_json_str_helper (const ecma_value_t arg1, /**<
ecma_value_t put_comp_val = ecma_builtin_helper_def_prop (obj_wrapper_p, ecma_value_t put_comp_val = ecma_builtin_helper_def_prop (obj_wrapper_p,
empty_str_p, empty_str_p,
arg1, arg1,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false);
JERRY_ASSERT (ecma_is_value_true (put_comp_val)); JERRY_ASSERT (ecma_is_value_true (put_comp_val));
@@ -339,13 +339,13 @@ ecma_builtin_object_object_seal (ecma_object_t *obj_p) /**< routine's argument *
} }
/* 2.b */ /* 2.b */
prop_desc.is_configurable = false; prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE;
prop_desc.flags |= ECMA_PROP_IS_THROW;
/* 2.c */ /* 2.c */
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p, ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
property_name_p, property_name_p,
&prop_desc, &prop_desc);
true);
ecma_free_property_descriptor (&prop_desc); ecma_free_property_descriptor (&prop_desc);
@@ -398,19 +398,20 @@ ecma_builtin_object_object_freeze (ecma_object_t *obj_p) /**< routine's argument
} }
/* 2.b */ /* 2.b */
if (prop_desc.is_writable_defined && prop_desc.is_writable) if ((prop_desc.flags & (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE))
== (ECMA_PROP_IS_WRITABLE_DEFINED | ECMA_PROP_IS_WRITABLE))
{ {
prop_desc.is_writable = false; prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_WRITABLE;
} }
/* 2.c */ /* 2.c */
prop_desc.is_configurable = false; prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE;
prop_desc.flags |= ECMA_PROP_IS_THROW;
/* 2.d */ /* 2.d */
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p, ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
property_name_p, property_name_p,
&prop_desc, &prop_desc);
true);
ecma_free_property_descriptor (&prop_desc); ecma_free_property_descriptor (&prop_desc);
@@ -620,6 +621,8 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
ecma_value_t conv_result = ecma_op_to_property_descriptor (desc_obj, ecma_value_t conv_result = ecma_op_to_property_descriptor (desc_obj,
&property_descriptors[property_descriptor_number]); &property_descriptors[property_descriptor_number]);
property_descriptors[property_descriptor_number].flags |= ECMA_PROP_IS_THROW;
ecma_free_value (desc_obj); ecma_free_value (desc_obj);
if (ECMA_IS_VALUE_ERROR (conv_result)) if (ECMA_IS_VALUE_ERROR (conv_result))
@@ -641,8 +644,7 @@ ecma_builtin_object_object_define_properties (ecma_object_t *obj_p, /**< routine
{ {
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p, ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
ecma_get_string_from_value (*ecma_value_p), ecma_get_string_from_value (*ecma_value_p),
&property_descriptors[index], &property_descriptors[index]);
true);
if (ECMA_IS_VALUE_ERROR (define_own_prop_ret)) if (ECMA_IS_VALUE_ERROR (define_own_prop_ret))
{ {
goto cleanup; goto cleanup;
@@ -743,10 +745,11 @@ ecma_builtin_object_object_define_property (ecma_object_t *obj_p, /**< routine's
return conv_result; return conv_result;
} }
prop_desc.flags |= ECMA_PROP_IS_THROW;
ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p, ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p,
name_str_p, name_str_p,
&prop_desc, &prop_desc);
true);
ecma_free_property_descriptor (&prop_desc); ecma_free_property_descriptor (&prop_desc);
ecma_free_value (conv_result); ecma_free_value (conv_result);
@@ -834,9 +837,9 @@ ecma_builtin_object_object_assign (const ecma_value_t arguments_list_p[], /**< a
} }
/* 5.c.iii */ /* 5.c.iii */
if (prop_desc.is_enumerable if ((prop_desc.flags & ECMA_PROP_IS_ENUMERABLE)
&& ((prop_desc.is_value_defined && !ecma_is_value_undefined (prop_desc.value)) && (((prop_desc.flags & ECMA_PROP_IS_VALUE_DEFINED) && !ecma_is_value_undefined (prop_desc.value))
|| prop_desc.is_get_defined)) || (prop_desc.flags & ECMA_PROP_IS_GET_DEFINED)))
{ {
/* 5.c.iii.1 */ /* 5.c.iii.1 */
ecma_value_t prop_value = ecma_op_object_get (from_obj_p, property_name_p); ecma_value_t prop_value = ecma_op_object_get (from_obj_p, property_name_p);
@@ -482,8 +482,7 @@ ecma_builtin_promise_do_all (ecma_value_t array, /**< the array for all */
ecma_value_t put_ret = ecma_builtin_helper_def_prop (ecma_get_object_from_value (value_array), ecma_value_t put_ret = ecma_builtin_helper_def_prop (ecma_get_object_from_value (value_array),
index_to_str_p, index_to_str_p,
undefined_val, undefined_val,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false);
ecma_deref_ecma_string (index_to_str_p); ecma_deref_ecma_string (index_to_str_p);
if (ECMA_IS_VALUE_ERROR (put_ret)) if (ECMA_IS_VALUE_ERROR (put_ret))
@@ -462,8 +462,7 @@ ecma_builtin_string_prototype_object_match (ecma_value_t this_to_string_value, /
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_obj_p, ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_obj_p,
current_index_str_p, current_index_str_p,
match_string_value, match_string_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
@@ -1358,8 +1357,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
zero_str_p, zero_str_p,
this_to_string_val, this_to_string_val,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
@@ -1435,8 +1433,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
zero_str_p, zero_str_p,
this_to_string_val, this_to_string_val,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
ecma_deref_ecma_string (zero_str_p); ecma_deref_ecma_string (zero_str_p);
@@ -1520,13 +1517,13 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
} }
else else
{ {
const uint32_t opts = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
ecma_string_t *separator_str_p = ecma_get_string_from_value (separator); ecma_string_t *separator_str_p = ecma_get_string_from_value (separator);
ecma_value_t put_comp = ecma_builtin_helper_def_prop (match_obj_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (match_obj_p,
zero_str_p, zero_str_p,
ecma_make_string_value (separator_str_p), ecma_make_string_value (separator_str_p),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, opts);
true); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
@@ -1571,8 +1568,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
array_length_str_p, array_length_str_p,
ecma_make_string_value (substr_str_p), ecma_make_string_value (substr_str_p),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
@@ -1616,8 +1612,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
put_comp = ecma_builtin_helper_def_prop (new_array_p, put_comp = ecma_builtin_helper_def_prop (new_array_p,
new_array_idx_str_p, new_array_idx_str_p,
match_comp_value, match_comp_value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
@@ -1662,8 +1657,7 @@ ecma_builtin_string_prototype_object_split (ecma_value_t this_to_string_val, /**
ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p, ecma_value_t put_comp = ecma_builtin_helper_def_prop (new_array_p,
array_length_string_p, array_length_string_p,
ecma_make_string_value (substr_str_p), ecma_make_string_value (substr_str_p),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
JERRY_ASSERT (ecma_is_value_true (put_comp)); JERRY_ASSERT (ecma_is_value_true (put_comp));
+25 -20
View File
@@ -119,8 +119,7 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of
ecma_builtin_helper_def_prop (object_p, ecma_builtin_helper_def_prop (object_p,
item_name_string_p, item_name_string_p,
array_items_p[index], array_items_p[index],
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
ecma_deref_ecma_string (item_name_string_p); ecma_deref_ecma_string (item_name_string_p);
} }
@@ -275,42 +274,44 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object
ecma_value_t ecma_value_t
ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the array object */ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the array object */
ecma_string_t *property_name_p, /**< property name */ ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property descriptor */ const ecma_property_descriptor_t *property_desc_p) /**< property descriptor */
bool is_throw) /**< flag that controls failure handling */
{ {
if (ecma_string_is_length (property_name_p)) if (ecma_string_is_length (property_name_p))
{ {
JERRY_ASSERT (property_desc_p->is_configurable_defined || !property_desc_p->is_configurable); JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED)
JERRY_ASSERT (property_desc_p->is_enumerable_defined || !property_desc_p->is_enumerable); || !(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE));
JERRY_ASSERT (property_desc_p->is_writable_defined || !property_desc_p->is_writable); JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE));
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE));
uint32_t flags = 0; uint32_t flags = 0;
if (is_throw) if (property_desc_p->flags & ECMA_PROP_IS_THROW)
{ {
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW; flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW;
} }
/* Only the writable and data properties can be modified. */ /* Only the writable and data properties can be modified. */
if (property_desc_p->is_configurable if (property_desc_p->flags & (ECMA_PROP_IS_CONFIGURABLE
|| property_desc_p->is_enumerable | ECMA_PROP_IS_ENUMERABLE
|| property_desc_p->is_get_defined | ECMA_PROP_IS_GET_DEFINED
|| property_desc_p->is_set_defined) | ECMA_PROP_IS_SET_DEFINED))
{ {
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT; flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT;
} }
if (property_desc_p->is_writable_defined) if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
{ {
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED; flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED;
} }
if (property_desc_p->is_writable) if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
{ {
flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE; flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE;
} }
if (property_desc_p->is_value_defined) if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{ {
return ecma_op_array_object_set_length (object_p, property_desc_p->value, flags); return ecma_op_array_object_set_length (object_p, property_desc_p->value, flags);
} }
@@ -328,7 +329,7 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra
if (index == ECMA_STRING_NOT_ARRAY_INDEX) if (index == ECMA_STRING_NOT_ARRAY_INDEX)
{ {
return ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p, is_throw); return ecma_op_general_object_define_own_property (object_p, property_name_p, property_desc_p);
} }
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
@@ -337,18 +338,22 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra
if (update_length && !ecma_is_property_writable (ext_object_p->u.array.length_prop)) if (update_length && !ecma_is_property_writable (ext_object_p->u.array.length_prop))
{ {
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
ecma_property_descriptor_t prop_desc;
prop_desc = *property_desc_p;
prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_THROW;
ecma_value_t completition = ecma_op_general_object_define_own_property (object_p, ecma_value_t completition = ecma_op_general_object_define_own_property (object_p,
property_name_p, property_name_p,
property_desc_p, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_boolean (completition)); JERRY_ASSERT (ecma_is_value_boolean (completition));
if (ecma_is_value_false (completition)) if (ecma_is_value_false (completition))
{ {
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
if (update_length) if (update_length)
@@ -54,7 +54,7 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value
ecma_value_t ecma_value_t
ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_op_array_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, bool is_throw); const ecma_property_descriptor_t *property_desc_p);
void void
ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, bool separate_enumerable, ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, bool separate_enumerable,
+37 -44
View File
@@ -613,48 +613,41 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
ecma_value_t completion; ecma_value_t completion;
ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor (); ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor ();
{ {
prop_desc.is_value_defined = true; prop_desc.flags = (ECMA_PROP_IS_VALUE_DEFINED
| ECMA_PROP_IS_WRITABLE_DEFINED
prop_desc.is_writable_defined = true; | ECMA_PROP_IS_WRITABLE
prop_desc.is_writable = true; | ECMA_PROP_IS_ENUMERABLE_DEFINED
| ECMA_PROP_IS_ENUMERABLE
prop_desc.is_enumerable_defined = true; | ECMA_PROP_IS_CONFIGURABLE_DEFINED
prop_desc.is_enumerable = true; | ECMA_PROP_IS_CONFIGURABLE);
prop_desc.is_configurable_defined = true;
prop_desc.is_configurable = true;
} }
/* 3. */ /* 3. */
if (src_prop_desc_p->is_value_defined if (src_prop_desc_p->flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
|| src_prop_desc_p->is_writable_defined)
{ {
JERRY_ASSERT (prop_desc.is_value_defined && prop_desc.is_writable_defined); JERRY_ASSERT ((prop_desc.flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
== (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED));
/* a. */ /* a. */
prop_desc.value = src_prop_desc_p->value; prop_desc.value = src_prop_desc_p->value;
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_VALUE), ecma_get_magic_string (LIT_MAGIC_STRING_VALUE),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
/* b. */ /* b. */
const bool is_writable = (src_prop_desc_p->is_writable); prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_WRITABLE);
prop_desc.value = ecma_make_boolean_value (is_writable);
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE), ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
} }
else else
{ {
/* 4. */ /* 4. */
JERRY_ASSERT (src_prop_desc_p->is_get_defined JERRY_ASSERT (src_prop_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED));
|| src_prop_desc_p->is_set_defined);
/* a. */ /* a. */
if (src_prop_desc_p->get_p == NULL) if (src_prop_desc_p->get_p == NULL)
@@ -668,8 +661,7 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_GET), ecma_get_magic_string (LIT_MAGIC_STRING_GET),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
/* b. */ /* b. */
@@ -684,27 +676,22 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_SET), ecma_get_magic_string (LIT_MAGIC_STRING_SET),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
} }
const bool is_enumerable = src_prop_desc_p->is_enumerable; prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_ENUMERABLE);
prop_desc.value = ecma_make_boolean_value (is_enumerable);
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE), ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
const bool is_configurable = src_prop_desc_p->is_configurable; prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE);
prop_desc.value = ecma_make_boolean_value (is_configurable);
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE), ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
return obj_p; return obj_p;
@@ -746,8 +733,10 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (enumerable_prop_value)) if (ecma_is_value_found (enumerable_prop_value))
{ {
prop_desc.is_enumerable_defined = true; uint32_t is_enumerable = (ecma_op_to_boolean (enumerable_prop_value) ? ECMA_PROP_IS_ENUMERABLE
prop_desc.is_enumerable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (enumerable_prop_value)); : ECMA_PROP_NO_OPTS);
prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | is_enumerable);
} }
ECMA_FINALIZE (enumerable_prop_value); ECMA_FINALIZE (enumerable_prop_value);
@@ -763,8 +752,10 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (configurable_prop_value)) if (ecma_is_value_found (configurable_prop_value))
{ {
prop_desc.is_configurable_defined = true; uint32_t is_configurable = (ecma_op_to_boolean (configurable_prop_value) ? ECMA_PROP_IS_CONFIGURABLE
prop_desc.is_configurable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (configurable_prop_value)); : ECMA_PROP_NO_OPTS);
prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_CONFIGURABLE_DEFINED | is_configurable);
} }
ECMA_FINALIZE (configurable_prop_value); ECMA_FINALIZE (configurable_prop_value);
@@ -781,7 +772,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (value_prop_value)) if (ecma_is_value_found (value_prop_value))
{ {
prop_desc.is_value_defined = true; prop_desc.flags |= ECMA_PROP_IS_VALUE_DEFINED;
prop_desc.value = ecma_copy_value (value_prop_value); prop_desc.value = ecma_copy_value (value_prop_value);
} }
@@ -799,8 +790,10 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
if (ecma_is_value_found (writable_prop_value)) if (ecma_is_value_found (writable_prop_value))
{ {
prop_desc.is_writable_defined = true; uint32_t is_writable = (ecma_op_to_boolean (writable_prop_value) ? ECMA_PROP_IS_WRITABLE
prop_desc.is_writable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (writable_prop_value)); : ECMA_PROP_NO_OPTS);
prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_WRITABLE_DEFINED | is_writable);
} }
ECMA_FINALIZE (writable_prop_value); ECMA_FINALIZE (writable_prop_value);
@@ -824,7 +817,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
} }
else else
{ {
prop_desc.is_get_defined = true; prop_desc.flags |= ECMA_PROP_IS_GET_DEFINED;
if (ecma_is_value_undefined (get_prop_value)) if (ecma_is_value_undefined (get_prop_value))
{ {
@@ -863,7 +856,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
} }
else else
{ {
prop_desc.is_set_defined = true; prop_desc.flags |= ECMA_PROP_IS_SET_DEFINED;
if (ecma_is_value_undefined (set_prop_value)) if (ecma_is_value_undefined (set_prop_value))
{ {
@@ -889,8 +882,8 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */
JERRY_ASSERT (ecma_is_value_empty (ret_value)); JERRY_ASSERT (ecma_is_value_empty (ret_value));
/* 9. */ /* 9. */
if ((prop_desc.is_get_defined || prop_desc.is_set_defined) if ((prop_desc.flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
&& (prop_desc.is_value_defined || prop_desc.is_writable_defined)) && (prop_desc.flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)))
{ {
ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable.")); ret_value = ecma_raise_type_error (ECMA_ERR_MSG ("Accessors cannot be writable."));
} }
@@ -64,8 +64,7 @@ ecma_create_array_from_iter_element (ecma_value_t value, /**< value */
ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p, ecma_value_t completion = ecma_builtin_helper_def_prop (new_array_p,
index_string_p, index_string_p,
(index == 0) ? index_value : value, (index == 0) ? index_value : value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
false); /* Failure handling */
/* 4.b */ /* 4.b */
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
+5 -5
View File
@@ -143,18 +143,18 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
ecma_value_t completion;
if (!ecma_get_object_extensible (binding_obj_p)) if (!ecma_get_object_extensible (binding_obj_p))
{ {
return ECMA_VALUE_EMPTY; return ECMA_VALUE_EMPTY;
} }
completion = ecma_builtin_helper_def_prop (binding_obj_p, const uint32_t flags = ECMA_PROPERTY_ENUMERABLE_WRITABLE | ECMA_IS_THROW;
ecma_value_t completion = ecma_builtin_helper_def_prop (binding_obj_p,
name_p, name_p,
ECMA_VALUE_UNDEFINED, ECMA_VALUE_UNDEFINED,
is_deletable ? ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE is_deletable ? flags | ECMA_PROPERTY_FLAG_CONFIGURABLE
: ECMA_PROPERTY_ENUMERABLE_WRITABLE, : flags);
true); /* Failure handling */
if (ECMA_IS_VALUE_ERROR (completion)) if (ECMA_IS_VALUE_ERROR (completion))
{ {
@@ -155,30 +155,23 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
/* 14. */ /* 14. */
prop_desc = ecma_make_empty_property_descriptor (); prop_desc = ecma_make_empty_property_descriptor ();
{ {
prop_desc.is_get_defined = true; prop_desc.flags = (ECMA_PROP_IS_GET_DEFINED
prop_desc.get_p = thrower_p; | ECMA_PROP_IS_SET_DEFINED
| ECMA_PROP_IS_ENUMERABLE_DEFINED
prop_desc.is_set_defined = true; | ECMA_PROP_IS_CONFIGURABLE_DEFINED);
prop_desc.set_p = thrower_p;
prop_desc.is_enumerable_defined = true;
prop_desc.is_enumerable = false;
prop_desc.is_configurable_defined = true;
prop_desc.is_configurable = false;
} }
prop_desc.set_p = thrower_p;
prop_desc.get_p = thrower_p;
ecma_value_t completion = ecma_op_object_define_own_property (obj_p, ecma_value_t completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE), ecma_get_magic_string (LIT_MAGIC_STRING_CALLEE),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
completion = ecma_op_object_define_own_property (obj_p, completion = ecma_op_object_define_own_property (obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_CALLER), ecma_get_magic_string (LIT_MAGIC_STRING_CALLER),
&prop_desc, &prop_desc);
false);
JERRY_ASSERT (ecma_is_value_true (completion)); JERRY_ASSERT (ecma_is_value_true (completion));
} }
@@ -221,15 +214,13 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function
ecma_value_t ecma_value_t
ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the object */ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p, /**< property name */ ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property const ecma_property_descriptor_t *property_desc_p) /**< property
* descriptor */ * descriptor */
bool is_throw) /**< flag that controls failure handling */
{ {
/* 3. */ /* 3. */
ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p, ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p,
property_name_p, property_name_p,
property_desc_p, property_desc_p);
is_throw);
if (ECMA_IS_VALUE_ERROR (ret_value)) if (ECMA_IS_VALUE_ERROR (ret_value))
{ {
@@ -259,15 +250,14 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[index]); ecma_string_t *name_p = ecma_get_string_from_value (arg_Literal_p[index]);
if (property_desc_p->is_get_defined if (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
|| property_desc_p->is_set_defined)
{ {
ecma_deref_ecma_string (name_p); ecma_deref_ecma_string (name_p);
arg_Literal_p[index] = ECMA_VALUE_EMPTY; arg_Literal_p[index] = ECMA_VALUE_EMPTY;
} }
else else
{ {
if (property_desc_p->is_value_defined) if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{ {
/* emulating execution of function described by MakeArgSetter */ /* emulating execution of function described by MakeArgSetter */
ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t, ecma_object_t *lex_env_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_object_t,
@@ -281,8 +271,8 @@ ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the
JERRY_ASSERT (ecma_is_value_empty (completion)); JERRY_ASSERT (ecma_is_value_empty (completion));
} }
if (property_desc_p->is_writable_defined if ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
&& !property_desc_p->is_writable) && !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE))
{ {
ecma_deref_ecma_string (name_p); ecma_deref_ecma_string (name_p);
arg_Literal_p[index] = ECMA_VALUE_EMPTY; arg_Literal_p[index] = ECMA_VALUE_EMPTY;
@@ -28,6 +28,6 @@ ecma_value_t
ecma_op_arguments_object_delete (ecma_object_t *object_p, ecma_string_t *property_name_p, bool is_throw); ecma_op_arguments_object_delete (ecma_object_t *object_p, ecma_string_t *property_name_p, bool is_throw);
ecma_value_t ecma_value_t
ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_op_arguments_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, bool is_throw); const ecma_property_descriptor_t *property_desc_p);
#endif /* !ECMA_OBJECTS_ARGUMENTS_H */ #endif /* !ECMA_OBJECTS_ARGUMENTS_H */
@@ -271,9 +271,8 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */
ecma_value_t ecma_value_t
ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the object */ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p, /**< property name */ ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property const ecma_property_descriptor_t *property_desc_p) /**< property
* descriptor */ * descriptor */
bool is_throw) /**< flag that controls failure handling */
{ {
JERRY_ASSERT (object_p != NULL JERRY_ASSERT (object_p != NULL
&& !ecma_is_lexical_environment (object_p)); && !ecma_is_lexical_environment (object_p));
@@ -281,25 +280,27 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
ecma_property_types_t property_desc_type = ECMA_PROPERTY_TYPE_GENERIC; ecma_property_types_t property_desc_type = ECMA_PROPERTY_TYPE_GENERIC;
if (property_desc_p->is_value_defined if (property_desc_p->flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED))
|| property_desc_p->is_writable_defined)
{ {
/* A property descriptor cannot be both named data and named accessor. */ /* A property descriptor cannot be both named data and named accessor. */
JERRY_ASSERT (!property_desc_p->is_get_defined JERRY_ASSERT ((property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
&& !property_desc_p->is_set_defined); != (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED));
property_desc_type = ECMA_PROPERTY_TYPE_NAMEDDATA; property_desc_type = ECMA_PROPERTY_TYPE_NAMEDDATA;
} }
else if (property_desc_p->is_get_defined else if (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
|| property_desc_p->is_set_defined)
{ {
JERRY_ASSERT (!(property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED));
property_desc_type = ECMA_PROPERTY_TYPE_NAMEDACCESSOR; property_desc_type = ECMA_PROPERTY_TYPE_NAMEDACCESSOR;
} }
/* These three asserts ensures that a new property is created with the appropriate default flags. /* These three asserts ensures that a new property is created with the appropriate default flags.
* E.g. if is_configurable_defined is false, the newly created property must be non-configurable. */ * E.g. if ECMA_PROP_IS_CONFIGURABLE_DEFINED is false, the newly created property must be non-configurable. */
JERRY_ASSERT (property_desc_p->is_configurable_defined || !property_desc_p->is_configurable); JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED)
JERRY_ASSERT (property_desc_p->is_enumerable_defined || !property_desc_p->is_enumerable); || !(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE));
JERRY_ASSERT (property_desc_p->is_writable_defined || !property_desc_p->is_writable); JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE));
JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
|| !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE));
/* 1. */ /* 1. */
ecma_extended_property_ref_t ext_property_ref = { .property_ref.value_p = NULL, .property_p = NULL }; ecma_extended_property_ref_t ext_property_ref = { .property_ref.value_p = NULL, .property_p = NULL };
@@ -316,39 +317,25 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (!ecma_get_object_extensible (object_p)) if (!ecma_get_object_extensible (object_p))
{ {
/* 2. */ /* 2. */
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
/* 4. */ /* 4. */
uint8_t prop_attributes = (uint8_t) (property_desc_p->flags & ECMA_PROPERTY_FLAGS_MASK);
if (property_desc_type != ECMA_PROPERTY_TYPE_NAMEDACCESSOR) if (property_desc_type != ECMA_PROPERTY_TYPE_NAMEDACCESSOR)
{ {
/* a. */ /* a. */
JERRY_ASSERT (property_desc_type == ECMA_PROPERTY_TYPE_GENERIC JERRY_ASSERT (property_desc_type == ECMA_PROPERTY_TYPE_GENERIC
|| property_desc_type == ECMA_PROPERTY_TYPE_NAMEDDATA); || property_desc_type == ECMA_PROPERTY_TYPE_NAMEDDATA);
uint8_t prop_attributes = 0;
if (property_desc_p->is_configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (property_desc_p->is_enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
if (property_desc_p->is_writable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_WRITABLE);
}
ecma_property_value_t *new_prop_value_p = ecma_create_named_data_property (object_p, ecma_property_value_t *new_prop_value_p = ecma_create_named_data_property (object_p,
property_name_p, property_name_p,
prop_attributes, prop_attributes,
NULL); NULL);
JERRY_ASSERT (property_desc_p->is_value_defined JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
|| ecma_is_value_undefined (property_desc_p->value)); || ecma_is_value_undefined (property_desc_p->value));
new_prop_value_p->value = ecma_copy_value_if_not_object (property_desc_p->value); new_prop_value_p->value = ecma_copy_value_if_not_object (property_desc_p->value);
@@ -357,17 +344,6 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{ {
/* b. */ /* b. */
uint8_t prop_attributes = 0;
if (property_desc_p->is_configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (property_desc_p->is_enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
ecma_create_named_accessor_property (object_p, ecma_create_named_accessor_property (object_p,
property_name_p, property_name_p,
property_desc_p->get_p, property_desc_p->get_p,
@@ -388,16 +364,17 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
|| current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL); || current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL);
/* 7. a., b. */ /* 7. a., b. */
bool is_enumberable = (property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE) != 0;
if (!is_current_configurable if (!is_current_configurable
&& (property_desc_p->is_configurable && ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE)
|| (property_desc_p->is_enumerable_defined || ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
&& (property_desc_p->is_enumerable != ecma_is_property_enumerable (current_prop))))) && (is_enumberable != ecma_is_property_enumerable (current_prop)))))
{ {
if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL) if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL)
{ {
ecma_free_value (ext_property_ref.property_ref.virtual_value); ecma_free_value (ext_property_ref.property_ref.virtual_value);
} }
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL) if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL)
@@ -407,12 +384,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
ecma_value_t result = ECMA_VALUE_TRUE; ecma_value_t result = ECMA_VALUE_TRUE;
if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR
|| property_desc_p->is_writable || (property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
|| (property_desc_p->is_value_defined || ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
&& !ecma_op_same_value (property_desc_p->value, && !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.virtual_value))) ext_property_ref.property_ref.virtual_value)))
{ {
result = ecma_reject (is_throw); result = ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
ecma_free_value (ext_property_ref.property_ref.virtual_value); ecma_free_value (ext_property_ref.property_ref.virtual_value);
@@ -433,12 +410,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{ {
/* 10. a. i. & ii. */ /* 10. a. i. & ii. */
if (!ecma_is_property_writable (current_prop) if (!ecma_is_property_writable (current_prop)
&& (property_desc_p->is_writable && ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE)
|| (property_desc_p->is_value_defined || ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
&& !ecma_op_same_value (property_desc_p->value, && !ecma_op_same_value (property_desc_p->value,
ext_property_ref.property_ref.value_p->value)))) ext_property_ref.property_ref.value_p->value))))
{ {
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
} }
else else
@@ -453,13 +430,13 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
ECMA_SET_POINTER (prop_desc_getter_cp, property_desc_p->get_p); ECMA_SET_POINTER (prop_desc_getter_cp, property_desc_p->get_p);
ECMA_SET_POINTER (prop_desc_setter_cp, property_desc_p->set_p); ECMA_SET_POINTER (prop_desc_setter_cp, property_desc_p->set_p);
if ((property_desc_p->is_get_defined if (((property_desc_p->flags & ECMA_PROP_IS_GET_DEFINED)
&& prop_desc_getter_cp != get_set_pair_p->getter_cp) && prop_desc_getter_cp != get_set_pair_p->getter_cp)
|| (property_desc_p->is_set_defined || ((property_desc_p->flags & ECMA_PROP_IS_SET_DEFINED)
&& prop_desc_setter_cp != get_set_pair_p->setter_cp)) && prop_desc_setter_cp != get_set_pair_p->setter_cp))
{ {
/* i., ii. */ /* i., ii. */
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
} }
} }
@@ -470,7 +447,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
if (!is_current_configurable) if (!is_current_configurable)
{ {
/* a. */ /* a. */
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
ecma_property_value_t *value_p = ext_property_ref.property_ref.value_p; ecma_property_value_t *value_p = ext_property_ref.property_ref.value_p;
@@ -515,30 +492,30 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{ {
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*ext_property_ref.property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA); JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*ext_property_ref.property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
if (property_desc_p->is_value_defined) if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
{ {
ecma_named_data_property_assign_value (object_p, ecma_named_data_property_assign_value (object_p,
ext_property_ref.property_ref.value_p, ext_property_ref.property_ref.value_p,
property_desc_p->value); property_desc_p->value);
} }
if (property_desc_p->is_writable_defined) if (property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
{ {
ecma_set_property_writable_attr (ext_property_ref.property_p, property_desc_p->is_writable); ecma_set_property_writable_attr (ext_property_ref.property_p, (property_desc_p->flags & ECMA_PROP_IS_WRITABLE));
} }
} }
else if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR) else if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR)
{ {
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*ext_property_ref.property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR); JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (*ext_property_ref.property_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
if (property_desc_p->is_get_defined) if (property_desc_p->flags & ECMA_PROP_IS_GET_DEFINED)
{ {
ecma_set_named_accessor_property_getter (object_p, ecma_set_named_accessor_property_getter (object_p,
ext_property_ref.property_ref.value_p, ext_property_ref.property_ref.value_p,
property_desc_p->get_p); property_desc_p->get_p);
} }
if (property_desc_p->is_set_defined) if (property_desc_p->flags & ECMA_PROP_IS_SET_DEFINED)
{ {
ecma_set_named_accessor_property_setter (object_p, ecma_set_named_accessor_property_setter (object_p,
ext_property_ref.property_ref.value_p, ext_property_ref.property_ref.value_p,
@@ -546,14 +523,16 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
} }
} }
if (property_desc_p->is_enumerable_defined) if (property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
{ {
ecma_set_property_enumerable_attr (ext_property_ref.property_p, property_desc_p->is_enumerable); ecma_set_property_enumerable_attr (ext_property_ref.property_p,
(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE));
} }
if (property_desc_p->is_configurable_defined) if (property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED)
{ {
ecma_set_property_configurable_attr (ext_property_ref.property_p, property_desc_p->is_configurable); ecma_set_property_configurable_attr (ext_property_ref.property_p,
(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE));
} }
return ECMA_VALUE_TRUE; return ECMA_VALUE_TRUE;
@@ -34,8 +34,7 @@ ecma_object_t *ecma_op_create_object_object_noarg_and_set_prototype (ecma_object
ecma_value_t ecma_op_general_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw); ecma_value_t ecma_op_general_object_delete (ecma_object_t *obj_p, ecma_string_t *property_name_p, bool is_throw);
ecma_value_t ecma_op_general_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint); ecma_value_t ecma_op_general_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint);
ecma_value_t ecma_op_general_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p, ecma_value_t ecma_op_general_object_define_own_property (ecma_object_t *object_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, const ecma_property_descriptor_t *property_desc_p);
bool is_throw);
/** /**
* @} * @}
+18 -25
View File
@@ -1137,8 +1137,7 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */
return ecma_builtin_helper_def_prop (object_p, return ecma_builtin_helper_def_prop (object_p,
property_name_p, property_name_p,
value, value,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW);
true); /* Failure handling */
} }
} }
@@ -1329,9 +1328,8 @@ ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */
ecma_value_t ecma_value_t
ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
ecma_string_t *property_name_p, /**< property name */ ecma_string_t *property_name_p, /**< property name */
const ecma_property_descriptor_t *property_desc_p, /**< property const ecma_property_descriptor_t *property_desc_p) /**< property
* descriptor */ * descriptor */
bool is_throw) /**< flag that controls failure handling */
{ {
JERRY_ASSERT (obj_p != NULL JERRY_ASSERT (obj_p != NULL
&& !ecma_is_lexical_environment (obj_p)); && !ecma_is_lexical_environment (obj_p));
@@ -1352,16 +1350,14 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
{ {
return ecma_op_general_object_define_own_property (obj_p, return ecma_op_general_object_define_own_property (obj_p,
property_name_p, property_name_p,
property_desc_p, property_desc_p);
is_throw);
} }
case ECMA_OBJECT_TYPE_ARRAY: case ECMA_OBJECT_TYPE_ARRAY:
{ {
return ecma_op_array_object_define_own_property (obj_p, return ecma_op_array_object_define_own_property (obj_p,
property_name_p, property_name_p,
property_desc_p, property_desc_p);
is_throw);
} }
default: default:
@@ -1378,8 +1374,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
return ecma_op_arguments_object_define_own_property (obj_p, return ecma_op_arguments_object_define_own_property (obj_p,
property_name_p, property_name_p,
property_desc_p, property_desc_p);
is_throw);
#if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) #if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY)
} }
/* ES2015 9.4.5.3 */ /* ES2015 9.4.5.3 */
@@ -1390,8 +1385,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
{ {
return ecma_op_general_object_define_own_property (obj_p, return ecma_op_general_object_define_own_property (obj_p,
property_name_p, property_name_p,
property_desc_p, property_desc_p);
is_throw);
} }
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */
uint32_t array_index = ecma_string_get_array_index (property_name_p); uint32_t array_index = ecma_string_get_array_index (property_name_p);
@@ -1407,7 +1401,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
return ECMA_VALUE_TRUE; return ECMA_VALUE_TRUE;
} }
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
ecma_number_t num = ecma_string_to_number (property_name_p); ecma_number_t num = ecma_string_to_number (property_name_p);
@@ -1417,7 +1411,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
{ {
ecma_deref_ecma_string (num_to_str); ecma_deref_ecma_string (num_to_str);
return ecma_reject (is_throw); return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW);
} }
ecma_deref_ecma_string (num_to_str); ecma_deref_ecma_string (num_to_str);
@@ -1425,8 +1419,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */
return ecma_op_general_object_define_own_property (obj_p, return ecma_op_general_object_define_own_property (obj_p,
property_name_p, property_name_p,
property_desc_p, property_desc_p);
is_throw);
#else /* !ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #else /* !ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
break; break;
#endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */
@@ -1466,10 +1459,10 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
*prop_desc_p = ecma_make_empty_property_descriptor (); *prop_desc_p = ecma_make_empty_property_descriptor ();
prop_desc_p->is_enumerable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_enumerable (property)); uint32_t flags = ecma_is_property_enumerable (property) ? ECMA_PROP_IS_ENUMERABLE : ECMA_PROP_NO_OPTS;
prop_desc_p->is_enumerable_defined = true; flags |= ecma_is_property_configurable (property) ? ECMA_PROP_IS_CONFIGURABLE: ECMA_PROP_NO_OPTS;
prop_desc_p->is_configurable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_configurable (property));
prop_desc_p->is_configurable_defined = true; prop_desc_p->flags = (uint16_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | ECMA_PROP_IS_CONFIGURABLE_DEFINED | flags);
ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (property); ecma_property_types_t type = ECMA_PROPERTY_GET_TYPE (property);
@@ -1485,15 +1478,15 @@ ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, /**< the ob
prop_desc_p->value = property_ref.virtual_value; prop_desc_p->value = property_ref.virtual_value;
} }
prop_desc_p->is_value_defined = true; prop_desc_p->flags |= (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED);
prop_desc_p->is_writable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_writable (property)); prop_desc_p->flags = (uint16_t) (prop_desc_p->flags | (ecma_is_property_writable (property) ? ECMA_PROP_IS_WRITABLE
prop_desc_p->is_writable_defined = true; : ECMA_PROP_NO_OPTS));
} }
else else
{ {
prop_desc_p->is_get_defined = true;
prop_desc_p->is_set_defined = true;
ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (property_ref.value_p); ecma_getter_setter_pointers_t *get_set_pair_p = ecma_get_named_accessor_property (property_ref.value_p);
prop_desc_p->flags |= (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED);
if (get_set_pair_p->getter_cp == JMEM_CP_NULL) if (get_set_pair_p->getter_cp == JMEM_CP_NULL)
{ {
+1 -1
View File
@@ -52,7 +52,7 @@ ecma_value_t ecma_op_object_delete_by_uint32_index (ecma_object_t *obj_p, uint32
ecma_value_t ecma_op_object_delete_by_number_index (ecma_object_t *obj_p, ecma_number_t index, bool is_throw); ecma_value_t ecma_op_object_delete_by_number_index (ecma_object_t *obj_p, ecma_number_t index, bool is_throw);
ecma_value_t ecma_op_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint); ecma_value_t ecma_op_object_default_value (ecma_object_t *obj_p, ecma_preferred_type_hint_t hint);
ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, ecma_string_t *property_name_p, ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, ecma_string_t *property_name_p,
const ecma_property_descriptor_t *property_desc_p, bool is_throw); const ecma_property_descriptor_t *property_desc_p);
bool ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, ecma_string_t *property_name_p, bool ecma_op_object_get_own_property_descriptor (ecma_object_t *object_p, ecma_string_t *property_name_p,
ecma_property_descriptor_t *prop_desc_p); ecma_property_descriptor_t *prop_desc_p);
ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, ecma_value_t value); ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, ecma_value_t value);
@@ -1141,27 +1141,24 @@ re_set_result_array_properties (ecma_object_t *array_obj_p, /**< result array */
ecma_builtin_helper_def_prop (array_obj_p, ecma_builtin_helper_def_prop (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_INDEX), ecma_get_magic_string (LIT_MAGIC_STRING_INDEX),
ecma_make_int32_value (index), ecma_make_int32_value (index),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW);
true); /* Failure handling */
/* Set input property of the result array */ /* Set input property of the result array */
ecma_builtin_helper_def_prop (array_obj_p, ecma_builtin_helper_def_prop (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_INPUT), ecma_get_magic_string (LIT_MAGIC_STRING_INPUT),
ecma_make_string_value (input_str_p), ecma_make_string_value (input_str_p),
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW);
true); /* Failure handling */
/* Set length property of the result array */ /* Set length property of the result array */
{ {
ecma_property_descriptor_t array_item_prop_desc = ecma_make_empty_property_descriptor (); ecma_property_descriptor_t array_item_prop_desc = ecma_make_empty_property_descriptor ();
array_item_prop_desc.is_value_defined = true; array_item_prop_desc.flags |= (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_THROW);
array_item_prop_desc.value = ecma_make_uint32_value (num_of_elements); array_item_prop_desc.value = ecma_make_uint32_value (num_of_elements);
ecma_op_object_define_own_property (array_obj_p, ecma_op_object_define_own_property (array_obj_p,
ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH),
&array_item_prop_desc, &array_item_prop_desc);
true);
} }
} /* re_set_result_array_properties */ } /* re_set_result_array_properties */
@@ -831,25 +831,19 @@ ecma_op_typedarray_define_index_prop (ecma_object_t *obj_p, /**< a TypedArray ob
ecma_length_t array_length = ecma_typedarray_get_length (obj_p); ecma_length_t array_length = ecma_typedarray_get_length (obj_p);
if (index >= array_length) if ((index >= array_length)
|| (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED))
|| ((property_desc_p->flags & (ECMA_PROP_IS_CONFIGURABLE_DEFINED | ECMA_PROP_IS_CONFIGURABLE))
== (ECMA_PROP_IS_CONFIGURABLE_DEFINED | ECMA_PROP_IS_CONFIGURABLE))
|| ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED)
&& !(property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE))
|| ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)
&& !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE)))
{ {
return false; return false;
} }
if (property_desc_p->is_get_defined if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED)
|| property_desc_p->is_set_defined)
{
return false;
}
if ((property_desc_p->is_configurable_defined && property_desc_p->is_configurable)
|| (property_desc_p->is_enumerable_defined && !property_desc_p->is_enumerable)
|| (property_desc_p->is_writable_defined && !property_desc_p->is_writable))
{
return false;
}
if (property_desc_p->is_value_defined)
{ {
return ecma_op_typedarray_set_index_prop (obj_p, index, property_desc_p->value); return ecma_op_typedarray_set_index_prop (obj_p, index, property_desc_p->value);
} }