@@ -972,7 +972,7 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object
972
972
ecma_value_t new_value , /**< new length value */
973
973
uint32_t flags ) /**< configuration options */
974
974
{
975
- bool is_throw = (flags & ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW ) ;
975
+ bool is_throw = (flags & ECMA_PROP_IS_THROW ) != 0 ;
976
976
ecma_number_t new_len_num ;
977
977
ecma_value_t completion = ecma_op_to_number (new_value , & new_len_num );
978
978
@@ -1000,7 +1000,11 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object
1000
1000
return ecma_raise_range_error (ECMA_ERR_MSG ("Invalid Array length" ));
1001
1001
}
1002
1002
1003
- if (flags & ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT )
1003
+ /* Only the writable and data properties can be modified. */
1004
+ if (flags & (ECMA_PROP_IS_CONFIGURABLE
1005
+ | ECMA_PROP_IS_ENUMERABLE
1006
+ | ECMA_PROP_IS_GET_DEFINED
1007
+ | ECMA_PROP_IS_SET_DEFINED ))
1004
1008
{
1005
1009
return ecma_reject (is_throw );
1006
1010
}
@@ -1012,10 +1016,15 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object
1012
1016
if (new_len_num == old_len_uint32 )
1013
1017
{
1014
1018
/* Only the writable flag must be updated. */
1015
- if (flags & ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED )
1019
+ if (flags & ECMA_PROP_IS_WRITABLE_DEFINED )
1016
1020
{
1017
- if (!(flags & ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE ))
1021
+ if (!(flags & ECMA_PROP_IS_WRITABLE ))
1018
1022
{
1023
+ if (ecma_op_array_is_fast_array (ext_object_p ))
1024
+ {
1025
+ ecma_fast_array_convert_to_normal (object_p );
1026
+ }
1027
+
1019
1028
ext_object_p -> u .array .length_prop_and_hole_count &= (uint32_t ) ~ECMA_PROPERTY_FLAG_WRITABLE ;
1020
1029
}
1021
1030
else if (!ecma_is_property_writable ((ecma_property_t ) ext_object_p -> u .array .length_prop_and_hole_count ))
@@ -1043,9 +1052,14 @@ ecma_op_array_object_set_length (ecma_object_t *object_p, /**< the array object
1043
1052
1044
1053
ext_object_p -> u .array .length = current_len_uint32 ;
1045
1054
1046
- if ((flags & ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED )
1047
- && !(flags & ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE ))
1055
+ if ((flags & ECMA_PROP_IS_WRITABLE_DEFINED )
1056
+ && !(flags & ECMA_PROP_IS_WRITABLE ))
1048
1057
{
1058
+ if (ecma_op_array_is_fast_array (ext_object_p ))
1059
+ {
1060
+ ecma_fast_array_convert_to_normal (object_p );
1061
+ }
1062
+
1049
1063
ext_object_p -> u .array .length_prop_and_hole_count &= (uint32_t ) ~ECMA_PROPERTY_FLAG_WRITABLE ;
1050
1064
}
1051
1065
@@ -1093,41 +1107,15 @@ ecma_op_array_object_define_own_property (ecma_object_t *object_p, /**< the arra
1093
1107
JERRY_ASSERT ((property_desc_p -> flags & ECMA_PROP_IS_WRITABLE_DEFINED )
1094
1108
|| !(property_desc_p -> flags & ECMA_PROP_IS_WRITABLE ));
1095
1109
1096
- uint32_t flags = 0 ;
1097
-
1098
- if (property_desc_p -> flags & ECMA_PROP_IS_THROW )
1099
- {
1100
- flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_IS_THROW ;
1101
- }
1102
-
1103
- /* Only the writable and data properties can be modified. */
1104
- if (property_desc_p -> flags & (ECMA_PROP_IS_CONFIGURABLE
1105
- | ECMA_PROP_IS_ENUMERABLE
1106
- | ECMA_PROP_IS_GET_DEFINED
1107
- | ECMA_PROP_IS_SET_DEFINED ))
1108
- {
1109
- flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_REJECT ;
1110
- }
1111
-
1112
- if (property_desc_p -> flags & ECMA_PROP_IS_WRITABLE_DEFINED )
1113
- {
1114
- flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE_DEFINED ;
1115
- }
1116
-
1117
- if (property_desc_p -> flags & ECMA_PROP_IS_WRITABLE )
1118
- {
1119
- flags |= ECMA_ARRAY_OBJECT_SET_LENGTH_FLAG_WRITABLE ;
1120
- }
1121
-
1122
1110
if (property_desc_p -> flags & ECMA_PROP_IS_VALUE_DEFINED )
1123
1111
{
1124
- return ecma_op_array_object_set_length (object_p , property_desc_p -> value , flags );
1112
+ return ecma_op_array_object_set_length (object_p , property_desc_p -> value , property_desc_p -> flags );
1125
1113
}
1126
1114
1127
1115
ecma_extended_object_t * ext_object_p = (ecma_extended_object_t * ) object_p ;
1128
1116
ecma_value_t length_value = ecma_make_uint32_value (ext_object_p -> u .array .length );
1129
1117
1130
- ecma_value_t result = ecma_op_array_object_set_length (object_p , length_value , flags );
1118
+ ecma_value_t result = ecma_op_array_object_set_length (object_p , length_value , property_desc_p -> flags );
1131
1119
1132
1120
ecma_fast_free_value (length_value );
1133
1121
return result ;
0 commit comments