@@ -244,7 +244,7 @@ ecma_fast_array_set_property (ecma_object_t *object_p, /**< fast access mode arr
244244
245245 if (ecma_is_value_array_hole (values_p [index ]))
246246 {
247- ext_obj_p -> u .array .hole_count -- ;
247+ ext_obj_p -> u .array .hole_count = ( uint8_t ) JERRY_MAX ( ext_obj_p -> u . array . hole_count - 1 , 0 ) ;
248248 }
249249 else
250250 {
@@ -269,21 +269,25 @@ ecma_fast_array_set_property (ecma_object_t *object_p, /**< fast access mode arr
269269 values_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t , object_p -> u1 .property_list_cp );
270270 JERRY_ASSERT (ecma_is_value_array_hole (values_p [index ]));
271271 ext_obj_p -> u .array .length = new_length ;
272+ ext_obj_p -> u .array .hole_count = (uint8_t ) JERRY_MIN (ext_obj_p -> u .array .hole_count + new_holes ,
273+ ECMA_FAST_ARRAY_MAX_HOLE_COUNT );
272274 }
273275 else
274276 {
275- if ((new_holes + ext_obj_p -> u .array .hole_count ) > ECMA_FAST_ARRAY_MAX_HOLE_COUNT )
277+ JERRY_ASSERT (ext_obj_p -> u .array .hole_count <= ECMA_FAST_ARRAY_MAX_HOLE_COUNT );
278+
279+ if (new_holes > (uint32_t ) (ECMA_FAST_ARRAY_MAX_HOLE_COUNT - ext_obj_p -> u .array .hole_count ))
276280 {
277281 ecma_fast_array_convert_to_normal (object_p );
278282
279283 return false;
280284 }
281285
282286 values_p = ecma_fast_array_extend (object_p , new_length );
287+ ext_obj_p -> u .array .hole_count = (uint8_t ) (ext_obj_p -> u .array .hole_count + new_holes );
283288 }
284289
285290 values_p [index ] = ecma_copy_value_if_not_object (value );
286- ext_obj_p -> u .array .hole_count = (uint8_t ) (ext_obj_p -> u .array .hole_count + new_holes );
287291
288292 return true;
289293} /* ecma_fast_array_set_property */
@@ -372,7 +376,11 @@ ecma_array_object_delete_property (ecma_object_t *object_p, /**< object */
372376 ecma_free_value_if_not_object (values_p [index ]);
373377
374378 values_p [index ] = ECMA_VALUE_ARRAY_HOLE ;
375- ext_obj_p -> u .array .hole_count ++ ;
379+
380+ if (++ ext_obj_p -> u .array .hole_count > ECMA_FAST_ARRAY_MAX_HOLE_COUNT )
381+ {
382+ ecma_fast_array_convert_to_normal (object_p );
383+ }
376384} /* ecma_array_object_delete_property */
377385
378386/**
@@ -416,7 +424,7 @@ ecma_delete_fast_array_properties (ecma_object_t *object_p, /**< fast access mod
416424 {
417425 if (ecma_is_value_array_hole (values_p [i ]))
418426 {
419- ext_obj_p -> u .array .hole_count -- ;
427+ ext_obj_p -> u .array .hole_count = ( uint8_t ) JERRY_MAX ( ext_obj_p -> u . array . hole_count - 1 , 0 ) ;
420428 }
421429 else
422430 {
@@ -469,7 +477,9 @@ ecma_fast_array_set_length (ecma_object_t *object_p, /**< fast access mode array
469477
470478 uint32_t new_holes = new_length - old_length - 1 ;
471479
472- if ((new_holes + ext_obj_p -> u .array .hole_count ) > ECMA_FAST_ARRAY_MAX_HOLE_COUNT )
480+ JERRY_ASSERT (ext_obj_p -> u .array .hole_count <= ECMA_FAST_ARRAY_MAX_HOLE_COUNT );
481+
482+ if (new_holes > (uint32_t ) (ECMA_FAST_ARRAY_MAX_HOLE_COUNT - ext_obj_p -> u .array .hole_count ))
473483 {
474484 ecma_fast_array_convert_to_normal (object_p );
475485 return ;
0 commit comments