diff --git a/jerry-core/api/jerry.c b/jerry-core/api/jerry.c index 78b80cee5..0d2bc391e 100644 --- a/jerry-core/api/jerry.c +++ b/jerry-core/api/jerry.c @@ -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 (); - prop_desc.is_enumerable_defined = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_enumerable_defined); - prop_desc.is_enumerable = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_enumerable_defined ? prop_desc_p->is_enumerable - : false); + uint32_t flags = ECMA_PROP_NO_OPTS; - prop_desc.is_configurable_defined = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_configurable_defined); - prop_desc.is_configurable = ECMA_BOOL_TO_BITFIELD (prop_desc_p->is_configurable_defined ? prop_desc_p->is_configurable - : false); + if (prop_desc_p->is_enumerable_defined) + { + 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. */ - 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) { @@ -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.is_writable_defined = ECMA_BOOL_TO_BITFIELD (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); + if (prop_desc_p->is_writable_defined) + { + 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. */ if (prop_desc_p->is_get_defined) { 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)) { @@ -2253,7 +2261,7 @@ jerry_define_own_property (const jerry_value_t obj_val, /**< object value */ if (prop_desc_p->is_set_defined) { 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)) { @@ -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), ecma_get_prop_name_from_value (prop_name_val), - &prop_desc, - true); + &prop_desc); } /* 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 = 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 = 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 = prop_desc.is_writable_defined ? prop_desc.is_writable : false; + prop_desc_p->is_writable_defined = (prop_desc.flags & ECMA_PROP_IS_WRITABLE_DEFINED) != 0; + 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_get_defined = prop_desc.is_get_defined; - prop_desc_p->is_set_defined = prop_desc.is_set_defined; + prop_desc_p->is_value_defined = (prop_desc.flags & ECMA_PROP_IS_VALUE_DEFINED) != 0; + prop_desc_p->is_get_defined = (prop_desc.flags & ECMA_PROP_IS_GET_DEFINED) != 0; + 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->getter = 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; } - if (prop_desc.is_get_defined) + if (prop_desc_p->is_get_defined) { 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) { diff --git a/jerry-core/ecma/base/ecma-globals.h b/jerry-core/ecma/base/ecma-globals.h index 9f7f57f8b..953bee465 100644 --- a/jerry-core/ecma/base/ecma-globals.h +++ b/jerry-core/ecma/base/ecma-globals.h @@ -935,6 +935,23 @@ typedef struct } ecma_map_object_t; #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 * @@ -943,35 +960,13 @@ typedef struct * Note: * If a component of descriptor is undefined then corresponding * 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 { - /** Is [[Value]] defined? */ - unsigned int is_value_defined : 1; - /** Is [[Get]] defined? */ - unsigned int is_get_defined : 1; - - /** 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; + /** any combination of ecma_property_descriptor_status_flags_t bits */ + uint16_t flags; /** [[Value]] */ ecma_value_t value; @@ -983,6 +978,29 @@ typedef struct ecma_object_t *set_p; } 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) /** * Description of an ecma-number diff --git a/jerry-core/ecma/base/ecma-helpers.c b/jerry-core/ecma/base/ecma-helpers.c index 5fb085679..9fe9ad40b 100644 --- a/jerry-core/ecma/base/ecma-helpers.c +++ b/jerry-core/ecma/base/ecma-helpers.c @@ -1275,17 +1275,9 @@ ecma_make_empty_property_descriptor (void) { ecma_property_descriptor_t prop_desc; - prop_desc.is_value_defined = false; + prop_desc.flags = 0; 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.is_set_defined = false; prop_desc.set_p = NULL; return prop_desc; @@ -1298,18 +1290,18 @@ ecma_make_empty_property_descriptor (void) void 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); } - if (prop_desc_p->is_get_defined + if ((prop_desc_p->flags & ECMA_PROP_IS_GET_DEFINED) && prop_desc_p->get_p != NULL) { 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) { ecma_deref_object (prop_desc_p->set_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c index cd455ccfa..aff483cdd 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-array-prototype.c @@ -804,12 +804,10 @@ ecma_builtin_array_prototype_object_slice (ecma_value_t arg1, /**< start */ if (ecma_is_value_found (get_value)) { /* 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, n, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); 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)) { /* 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, k, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); ecma_free_value (get_value); @@ -1748,12 +1744,11 @@ ecma_builtin_array_prototype_object_map (ecma_value_t arg1, /**< callbackfn */ } /* 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, index, mapped_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); + JERRY_ASSERT (ecma_is_value_true (put_comp)); ecma_free_value (mapped_value); @@ -1848,12 +1843,10 @@ ecma_builtin_array_prototype_object_filter (ecma_value_t arg1, /**< callbackfn * /* 9.c.iii */ 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, new_array_index, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); new_array_index++; } diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c index 7537b0620..fbd0c036b 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.c @@ -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, index_string_p, *ecma_value_p, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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, new_array_index_string_p, get_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); 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, new_array_index_string_p, value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ - + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); 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 */ uint32_t index, /**< property index */ ecma_value_t value, /**< value */ - uint32_t opts, /**< any combination of ecma_property_flag_t bits */ - bool is_throw) /**< is_throw */ + uint32_t opts) /**< any combination of ecma_property_flag_t bits */ { if (JERRY_LIKELY (index <= ECMA_DIRECT_STRING_MAX_IMM)) { return ecma_builtin_helper_def_prop (obj_p, ECMA_CREATE_DIRECT_UINT32_STRING (index), value, - opts, - is_throw); + opts); } 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, index_str_p, value, - opts, - is_throw); + opts); ecma_deref_ecma_string (index_str_p); return ret_value; @@ -839,27 +832,18 @@ ecma_value_t ecma_builtin_helper_def_prop (ecma_object_t *obj_p, /**< object */ ecma_string_t *index_p, /**< index string */ ecma_value_t value, /**< value */ - uint32_t opts, /**< any combination of ecma_property_flag_t bits */ - bool is_throw) /**< is_throw */ + uint32_t opts) /**< any combination of ecma_property_flag_t bits + * 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.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, index_p, - &prop_desc, - is_throw); + &prop_desc); } /* ecma_builtin_helper_def_prop */ /** diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h index 2cb1d45de..f0a23447a 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-helpers.h @@ -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_length_t start_pos, ecma_length_t *ret_index_p); ecma_value_t -ecma_builtin_helper_def_prop (ecma_object_t *obj_p, ecma_string_t *index_p, ecma_value_t value, - uint32_t opts, bool is_throw); +ecma_builtin_helper_def_prop (ecma_object_t *obj_p, ecma_string_t *index_p, ecma_value_t value, uint32_t opts); + ecma_value_t -ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, uint32_t index, ecma_value_t value, - uint32_t opts, bool is_throw); +ecma_builtin_helper_def_prop_by_index (ecma_object_t *obj_p, uint32_t index, ecma_value_t value, uint32_t opts); #if ENABLED (JERRY_BUILTIN_DATE) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-json.c b/jerry-core/ecma/builtin-objects/ecma-builtin-json.c index fe9224892..d3d9e719a 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-json.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-json.c @@ -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, property_name_p, value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_boolean (completion_value)); } /* 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, index_str_p, value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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, empty_str_p, arg1, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp_val)); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-object.c b/jerry-core/ecma/builtin-objects/ecma-builtin-object.c index f5260043e..1eb03fea9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-object.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-object.c @@ -339,13 +339,13 @@ ecma_builtin_object_object_seal (ecma_object_t *obj_p) /**< routine's argument * } /* 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 */ ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p, property_name_p, - &prop_desc, - true); + &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 */ - 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 */ - prop_desc.is_configurable = false; + prop_desc.flags &= (uint16_t) ~ECMA_PROP_IS_CONFIGURABLE; + prop_desc.flags |= ECMA_PROP_IS_THROW; /* 2.d */ ecma_value_t define_own_prop_ret = ecma_op_object_define_own_property (obj_p, property_name_p, - &prop_desc, - true); + &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, &property_descriptors[property_descriptor_number]); + property_descriptors[property_descriptor_number].flags |= ECMA_PROP_IS_THROW; + ecma_free_value (desc_obj); 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_get_string_from_value (*ecma_value_p), - &property_descriptors[index], - true); + &property_descriptors[index]); if (ECMA_IS_VALUE_ERROR (define_own_prop_ret)) { goto cleanup; @@ -743,10 +745,11 @@ ecma_builtin_object_object_define_property (ecma_object_t *obj_p, /**< routine's 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, name_str_p, - &prop_desc, - true); + &prop_desc); ecma_free_property_descriptor (&prop_desc); 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 */ - if (prop_desc.is_enumerable - && ((prop_desc.is_value_defined && !ecma_is_value_undefined (prop_desc.value)) - || prop_desc.is_get_defined)) + if ((prop_desc.flags & ECMA_PROP_IS_ENUMERABLE) + && (((prop_desc.flags & ECMA_PROP_IS_VALUE_DEFINED) && !ecma_is_value_undefined (prop_desc.value)) + || (prop_desc.flags & ECMA_PROP_IS_GET_DEFINED))) { /* 5.c.iii.1 */ ecma_value_t prop_value = ecma_op_object_get (from_obj_p, property_name_p); diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c index 4b094ff30..5d0bf04a5 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-promise.c @@ -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), index_to_str_p, undefined_val, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); ecma_deref_ecma_string (index_to_str_p); if (ECMA_IS_VALUE_ERROR (put_ret)) diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c index a69613fc3..eca64caf9 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c @@ -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, current_index_str_p, match_string_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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, zero_str_p, this_to_string_val, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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, zero_str_p, this_to_string_val, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); 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 { + 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_value_t put_comp = ecma_builtin_helper_def_prop (match_obj_p, zero_str_p, ecma_make_string_value (separator_str_p), - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - true); /* Failure handling */ + opts); 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, array_length_str_p, ecma_make_string_value (substr_str_p), - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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, new_array_idx_str_p, match_comp_value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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, array_length_string_p, ecma_make_string_value (substr_str_p), - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); JERRY_ASSERT (ecma_is_value_true (put_comp)); diff --git a/jerry-core/ecma/operations/ecma-array-object.c b/jerry-core/ecma/operations/ecma-array-object.c index 305b1d54a..38f17c80f 100644 --- a/jerry-core/ecma/operations/ecma-array-object.c +++ b/jerry-core/ecma/operations/ecma-array-object.c @@ -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, item_name_string_p, array_items_p[index], - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); 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_op_array_object_define_own_property (ecma_object_t *object_p, /**< the array object */ ecma_string_t *property_name_p, /**< property name */ - const ecma_property_descriptor_t *property_desc_p, /**< property descriptor */ - bool is_throw) /**< flag that controls failure handling */ + const ecma_property_descriptor_t *property_desc_p) /**< property descriptor */ { 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->is_enumerable_defined || !property_desc_p->is_enumerable); - JERRY_ASSERT (property_desc_p->is_writable_defined || !property_desc_p->is_writable); + JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED) + || !(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE)); + 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; - if (is_throw) + if (property_desc_p->flags & ECMA_PROP_IS_THROW) { flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW; } /* Only the writable and data properties can be modified. */ - if (property_desc_p->is_configurable - || property_desc_p->is_enumerable - || property_desc_p->is_get_defined - || property_desc_p->is_set_defined) + if (property_desc_p->flags & (ECMA_PROP_IS_CONFIGURABLE + | ECMA_PROP_IS_ENUMERABLE + | ECMA_PROP_IS_GET_DEFINED + | ECMA_PROP_IS_SET_DEFINED)) { 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; } - if (property_desc_p->is_writable) + if (property_desc_p->flags & ECMA_PROP_IS_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); } @@ -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) { - 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; @@ -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)) { - 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, property_name_p, - property_desc_p, - false); + &prop_desc); JERRY_ASSERT (ecma_is_value_boolean (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) diff --git a/jerry-core/ecma/operations/ecma-array-object.h b/jerry-core/ecma/operations/ecma-array-object.h index 445d0a495..a901c5d0e 100644 --- a/jerry-core/ecma/operations/ecma-array-object.h +++ b/jerry-core/ecma/operations/ecma-array-object.h @@ -54,7 +54,7 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, ecma_value_t new_value ecma_value_t 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 ecma_op_array_list_lazy_property_names (ecma_object_t *obj_p, bool separate_enumerable, diff --git a/jerry-core/ecma/operations/ecma-conversion.c b/jerry-core/ecma/operations/ecma-conversion.c index 0bafb5abb..442240a21 100644 --- a/jerry-core/ecma/operations/ecma-conversion.c +++ b/jerry-core/ecma/operations/ecma-conversion.c @@ -613,48 +613,41 @@ ecma_op_from_property_descriptor (const ecma_property_descriptor_t *src_prop_des ecma_value_t completion; ecma_property_descriptor_t prop_desc = ecma_make_empty_property_descriptor (); { - prop_desc.is_value_defined = true; - - prop_desc.is_writable_defined = true; - prop_desc.is_writable = true; - - prop_desc.is_enumerable_defined = true; - prop_desc.is_enumerable = true; - - prop_desc.is_configurable_defined = true; - prop_desc.is_configurable = true; + prop_desc.flags = (ECMA_PROP_IS_VALUE_DEFINED + | ECMA_PROP_IS_WRITABLE_DEFINED + | ECMA_PROP_IS_WRITABLE + | ECMA_PROP_IS_ENUMERABLE_DEFINED + | ECMA_PROP_IS_ENUMERABLE + | ECMA_PROP_IS_CONFIGURABLE_DEFINED + | ECMA_PROP_IS_CONFIGURABLE); } /* 3. */ - if (src_prop_desc_p->is_value_defined - || src_prop_desc_p->is_writable_defined) + if (src_prop_desc_p->flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_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. */ prop_desc.value = src_prop_desc_p->value; completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_VALUE), - &prop_desc, - false); + &prop_desc); 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); + prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_WRITABLE); completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_WRITABLE), - &prop_desc, - false); + &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); } else { /* 4. */ - JERRY_ASSERT (src_prop_desc_p->is_get_defined - || src_prop_desc_p->is_set_defined); + JERRY_ASSERT (src_prop_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)); /* a. */ 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, ecma_get_magic_string (LIT_MAGIC_STRING_GET), - &prop_desc, - false); + &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); /* 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, ecma_get_magic_string (LIT_MAGIC_STRING_SET), - &prop_desc, - false); + &prop_desc); 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); + prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_ENUMERABLE); completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_ENUMERABLE), - &prop_desc, - false); + &prop_desc); 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); + prop_desc.value = ecma_make_boolean_value (src_prop_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE); completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_CONFIGURABLE), - &prop_desc, - false); + &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); 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)) { - prop_desc.is_enumerable_defined = true; - prop_desc.is_enumerable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (enumerable_prop_value)); + uint32_t is_enumerable = (ecma_op_to_boolean (enumerable_prop_value) ? ECMA_PROP_IS_ENUMERABLE + : ECMA_PROP_NO_OPTS); + + prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_ENUMERABLE_DEFINED | is_enumerable); } 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)) { - prop_desc.is_configurable_defined = true; - prop_desc.is_configurable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (configurable_prop_value)); + uint32_t is_configurable = (ecma_op_to_boolean (configurable_prop_value) ? ECMA_PROP_IS_CONFIGURABLE + : ECMA_PROP_NO_OPTS); + + prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_CONFIGURABLE_DEFINED | is_configurable); } 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)) { - prop_desc.is_value_defined = true; + prop_desc.flags |= ECMA_PROP_IS_VALUE_DEFINED; 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)) { - prop_desc.is_writable_defined = true; - prop_desc.is_writable = ECMA_BOOL_TO_BITFIELD (ecma_op_to_boolean (writable_prop_value)); + uint32_t is_writable = (ecma_op_to_boolean (writable_prop_value) ? ECMA_PROP_IS_WRITABLE + : ECMA_PROP_NO_OPTS); + + prop_desc.flags |= (uint16_t) (ECMA_PROP_IS_WRITABLE_DEFINED | is_writable); } ECMA_FINALIZE (writable_prop_value); @@ -824,7 +817,7 @@ ecma_op_to_property_descriptor (ecma_value_t obj_value, /**< object value */ } else { - prop_desc.is_get_defined = true; + prop_desc.flags |= ECMA_PROP_IS_GET_DEFINED; 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 { - prop_desc.is_set_defined = true; + prop_desc.flags |= ECMA_PROP_IS_SET_DEFINED; 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)); /* 9. */ - if ((prop_desc.is_get_defined || prop_desc.is_set_defined) - && (prop_desc.is_value_defined || prop_desc.is_writable_defined)) + if ((prop_desc.flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_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.")); } diff --git a/jerry-core/ecma/operations/ecma-iterator-object.c b/jerry-core/ecma/operations/ecma-iterator-object.c index f6319d6eb..a2859c95f 100644 --- a/jerry-core/ecma/operations/ecma-iterator-object.c +++ b/jerry-core/ecma/operations/ecma-iterator-object.c @@ -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, index_string_p, (index == 0) ? index_value : value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - false); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE); /* 4.b */ JERRY_ASSERT (ecma_is_value_true (completion)); diff --git a/jerry-core/ecma/operations/ecma-lex-env.c b/jerry-core/ecma/operations/ecma-lex-env.c index 8845323f3..5ac38b035 100644 --- a/jerry-core/ecma/operations/ecma-lex-env.c +++ b/jerry-core/ecma/operations/ecma-lex-env.c @@ -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_value_t completion; if (!ecma_get_object_extensible (binding_obj_p)) { return ECMA_VALUE_EMPTY; } - completion = ecma_builtin_helper_def_prop (binding_obj_p, - name_p, - ECMA_VALUE_UNDEFINED, - is_deletable ? ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE - : ECMA_PROPERTY_ENUMERABLE_WRITABLE, - true); /* Failure handling */ + 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, + ECMA_VALUE_UNDEFINED, + is_deletable ? flags | ECMA_PROPERTY_FLAG_CONFIGURABLE + : flags); if (ECMA_IS_VALUE_ERROR (completion)) { diff --git a/jerry-core/ecma/operations/ecma-objects-arguments.c b/jerry-core/ecma/operations/ecma-objects-arguments.c index b87724c78..e6528fb7c 100644 --- a/jerry-core/ecma/operations/ecma-objects-arguments.c +++ b/jerry-core/ecma/operations/ecma-objects-arguments.c @@ -155,30 +155,23 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function /* 14. */ prop_desc = ecma_make_empty_property_descriptor (); { - prop_desc.is_get_defined = true; - prop_desc.get_p = thrower_p; - - prop_desc.is_set_defined = true; - 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.flags = (ECMA_PROP_IS_GET_DEFINED + | ECMA_PROP_IS_SET_DEFINED + | ECMA_PROP_IS_ENUMERABLE_DEFINED + | ECMA_PROP_IS_CONFIGURABLE_DEFINED); } + 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_get_magic_string (LIT_MAGIC_STRING_CALLEE), - &prop_desc, - false); + &prop_desc); JERRY_ASSERT (ecma_is_value_true (completion)); completion = ecma_op_object_define_own_property (obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_CALLER), - &prop_desc, - false); + &prop_desc); 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_op_arguments_object_define_own_property (ecma_object_t *object_p, /**< the object */ 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 */ - bool is_throw) /**< flag that controls failure handling */ { /* 3. */ ecma_value_t ret_value = ecma_op_general_object_define_own_property (object_p, property_name_p, - property_desc_p, - is_throw); + property_desc_p); 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]); - if (property_desc_p->is_get_defined - || property_desc_p->is_set_defined) + if (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)) { ecma_deref_ecma_string (name_p); arg_Literal_p[index] = ECMA_VALUE_EMPTY; } 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 */ 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)); } - if (property_desc_p->is_writable_defined - && !property_desc_p->is_writable) + if ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED) + && !(property_desc_p->flags & ECMA_PROP_IS_WRITABLE)) { ecma_deref_ecma_string (name_p); arg_Literal_p[index] = ECMA_VALUE_EMPTY; diff --git a/jerry-core/ecma/operations/ecma-objects-arguments.h b/jerry-core/ecma/operations/ecma-objects-arguments.h index dbd167e4f..8f7a0dc17 100644 --- a/jerry-core/ecma/operations/ecma-objects-arguments.h +++ b/jerry-core/ecma/operations/ecma-objects-arguments.h @@ -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_value_t 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 */ diff --git a/jerry-core/ecma/operations/ecma-objects-general.c b/jerry-core/ecma/operations/ecma-objects-general.c index d82042be5..fb23e5025 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.c +++ b/jerry-core/ecma/operations/ecma-objects-general.c @@ -271,9 +271,8 @@ ecma_op_general_object_default_value (ecma_object_t *obj_p, /**< the object */ ecma_value_t ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the object */ 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 */ - bool is_throw) /**< flag that controls failure handling */ { JERRY_ASSERT (object_p != NULL && !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; - if (property_desc_p->is_value_defined - || property_desc_p->is_writable_defined) + if (property_desc_p->flags & (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED)) { /* A property descriptor cannot be both named data and named accessor. */ - JERRY_ASSERT (!property_desc_p->is_get_defined - && !property_desc_p->is_set_defined); + JERRY_ASSERT ((property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)) + != (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)); property_desc_type = ECMA_PROPERTY_TYPE_NAMEDDATA; } - else if (property_desc_p->is_get_defined - || property_desc_p->is_set_defined) + else if (property_desc_p->flags & (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED)) { + JERRY_ASSERT (!(property_desc_p->flags & ECMA_PROP_IS_WRITABLE_DEFINED)); property_desc_type = ECMA_PROPERTY_TYPE_NAMEDACCESSOR; } /* 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. */ - JERRY_ASSERT (property_desc_p->is_configurable_defined || !property_desc_p->is_configurable); - JERRY_ASSERT (property_desc_p->is_enumerable_defined || !property_desc_p->is_enumerable); - JERRY_ASSERT (property_desc_p->is_writable_defined || !property_desc_p->is_writable); + * E.g. if ECMA_PROP_IS_CONFIGURABLE_DEFINED is false, the newly created property must be non-configurable. */ + JERRY_ASSERT ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE_DEFINED) + || !(property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE)); + 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. */ 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)) { /* 2. */ - return ecma_reject (is_throw); + return ecma_reject (property_desc_p->flags & ECMA_PROP_IS_THROW); } /* 4. */ + uint8_t prop_attributes = (uint8_t) (property_desc_p->flags & ECMA_PROPERTY_FLAGS_MASK); if (property_desc_type != ECMA_PROPERTY_TYPE_NAMEDACCESSOR) { /* a. */ - JERRY_ASSERT (property_desc_type == ECMA_PROPERTY_TYPE_GENERIC || 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, property_name_p, prop_attributes, 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)); 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. */ - 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, property_name_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); /* 7. a., b. */ + bool is_enumberable = (property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE) != 0; if (!is_current_configurable - && (property_desc_p->is_configurable - || (property_desc_p->is_enumerable_defined - && (property_desc_p->is_enumerable != ecma_is_property_enumerable (current_prop))))) + && ((property_desc_p->flags & ECMA_PROP_IS_CONFIGURABLE) + || ((property_desc_p->flags & ECMA_PROP_IS_ENUMERABLE_DEFINED) + && (is_enumberable != ecma_is_property_enumerable (current_prop))))) { if (current_property_type == ECMA_PROPERTY_TYPE_VIRTUAL) { 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) @@ -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; if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDACCESSOR - || property_desc_p->is_writable - || (property_desc_p->is_value_defined + || (property_desc_p->flags & ECMA_PROP_IS_WRITABLE) + || ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED) && !ecma_op_same_value (property_desc_p->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); @@ -433,12 +410,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob { /* 10. a. i. & ii. */ if (!ecma_is_property_writable (current_prop) - && (property_desc_p->is_writable - || (property_desc_p->is_value_defined + && ((property_desc_p->flags & ECMA_PROP_IS_WRITABLE) + || ((property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED) && !ecma_op_same_value (property_desc_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 @@ -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_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) - || (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)) { /* 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) { /* 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; @@ -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); - 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, ext_property_ref.property_ref.value_p, 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) { 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, ext_property_ref.property_ref.value_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, 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; diff --git a/jerry-core/ecma/operations/ecma-objects-general.h b/jerry-core/ecma/operations/ecma-objects-general.h index f9b343331..74c1f3a4e 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.h +++ b/jerry-core/ecma/operations/ecma-objects-general.h @@ -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_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, - const ecma_property_descriptor_t *property_desc_p, - bool is_throw); + const ecma_property_descriptor_t *property_desc_p); /** * @} diff --git a/jerry-core/ecma/operations/ecma-objects.c b/jerry-core/ecma/operations/ecma-objects.c index d040f5f55..662546414 100644 --- a/jerry-core/ecma/operations/ecma-objects.c +++ b/jerry-core/ecma/operations/ecma-objects.c @@ -1137,8 +1137,7 @@ ecma_op_object_put (ecma_object_t *object_p, /**< the object */ return ecma_builtin_helper_def_prop (object_p, property_name_p, value, - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - true); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW); } } @@ -1329,9 +1328,8 @@ ecma_op_object_default_value (ecma_object_t *obj_p, /**< the object */ ecma_value_t ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ 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 */ - bool is_throw) /**< flag that controls failure handling */ { JERRY_ASSERT (obj_p != NULL && !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, property_name_p, - property_desc_p, - is_throw); + property_desc_p); } case ECMA_OBJECT_TYPE_ARRAY: { return ecma_op_array_object_define_own_property (obj_p, property_name_p, - property_desc_p, - is_throw); + property_desc_p); } default: @@ -1378,8 +1374,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ #endif /* ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ return ecma_op_arguments_object_define_own_property (obj_p, property_name_p, - property_desc_p, - is_throw); + property_desc_p); #if ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) } /* 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, property_name_p, - property_desc_p, - is_throw); + property_desc_p); } #endif /* ENABLED (JERRY_ES2015_BUILTIN_SYMBOL) */ 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_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); @@ -1417,7 +1411,7 @@ ecma_op_object_define_own_property (ecma_object_t *obj_p, /**< the object */ { 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); @@ -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, property_name_p, - property_desc_p, - is_throw); + property_desc_p); #else /* !ENABLED (JERRY_ES2015_BUILTIN_TYPEDARRAY) */ break; #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->is_enumerable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_enumerable (property)); - prop_desc_p->is_enumerable_defined = true; - prop_desc_p->is_configurable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_configurable (property)); - prop_desc_p->is_configurable_defined = true; + uint32_t flags = ecma_is_property_enumerable (property) ? ECMA_PROP_IS_ENUMERABLE : ECMA_PROP_NO_OPTS; + flags |= ecma_is_property_configurable (property) ? ECMA_PROP_IS_CONFIGURABLE: ECMA_PROP_NO_OPTS; + + 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); @@ -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->is_value_defined = true; - prop_desc_p->is_writable = ECMA_BOOL_TO_BITFIELD (ecma_is_property_writable (property)); - prop_desc_p->is_writable_defined = true; + prop_desc_p->flags |= (ECMA_PROP_IS_VALUE_DEFINED | ECMA_PROP_IS_WRITABLE_DEFINED); + prop_desc_p->flags = (uint16_t) (prop_desc_p->flags | (ecma_is_property_writable (property) ? ECMA_PROP_IS_WRITABLE + : ECMA_PROP_NO_OPTS)); } 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); + prop_desc_p->flags |= (ECMA_PROP_IS_GET_DEFINED | ECMA_PROP_IS_SET_DEFINED); if (get_set_pair_p->getter_cp == JMEM_CP_NULL) { diff --git a/jerry-core/ecma/operations/ecma-objects.h b/jerry-core/ecma/operations/ecma-objects.h index 436a90b18..8802e4be1 100644 --- a/jerry-core/ecma/operations/ecma-objects.h +++ b/jerry-core/ecma/operations/ecma-objects.h @@ -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_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, - 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, ecma_property_descriptor_t *prop_desc_p); ecma_value_t ecma_op_object_has_instance (ecma_object_t *obj_p, ecma_value_t value); diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 9ae758c22..4fe2d5e89 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -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_get_magic_string (LIT_MAGIC_STRING_INDEX), ecma_make_int32_value (index), - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - true); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW); /* Set input property of the result array */ ecma_builtin_helper_def_prop (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_INPUT), ecma_make_string_value (input_str_p), - ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE, - true); /* Failure handling */ + ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE | ECMA_IS_THROW); /* Set length property of the result array */ { 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); ecma_op_object_define_own_property (array_obj_p, ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH), - &array_item_prop_desc, - true); + &array_item_prop_desc); } } /* re_set_result_array_properties */ diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index bb0d0e56b..e4b371c95 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -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); - 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; } - if (property_desc_p->is_get_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) + if (property_desc_p->flags & ECMA_PROP_IS_VALUE_DEFINED) { return ecma_op_typedarray_set_index_prop (obj_p, index, property_desc_p->value); }