@@ -244,7 +244,7 @@ ecma_fast_array_set_property (ecma_object_t *object_p, /**< fast access mode arr
244
244
245
245
if (ecma_is_value_array_hole (values_p [index ]))
246
246
{
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 ) ;
248
248
}
249
249
else
250
250
{
@@ -269,21 +269,25 @@ ecma_fast_array_set_property (ecma_object_t *object_p, /**< fast access mode arr
269
269
values_p = ECMA_GET_NON_NULL_POINTER (ecma_value_t , object_p -> u1 .property_list_cp );
270
270
JERRY_ASSERT (ecma_is_value_array_hole (values_p [index ]));
271
271
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 );
272
274
}
273
275
else
274
276
{
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 ))
276
280
{
277
281
ecma_fast_array_convert_to_normal (object_p );
278
282
279
283
return false;
280
284
}
281
285
282
286
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 );
283
288
}
284
289
285
290
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 );
287
291
288
292
return true;
289
293
} /* ecma_fast_array_set_property */
@@ -372,7 +376,11 @@ ecma_array_object_delete_property (ecma_object_t *object_p, /**< object */
372
376
ecma_free_value_if_not_object (values_p [index ]);
373
377
374
378
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
+ }
376
384
} /* ecma_array_object_delete_property */
377
385
378
386
/**
@@ -416,7 +424,7 @@ ecma_delete_fast_array_properties (ecma_object_t *object_p, /**< fast access mod
416
424
{
417
425
if (ecma_is_value_array_hole (values_p [i ]))
418
426
{
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 ) ;
420
428
}
421
429
else
422
430
{
@@ -469,7 +477,9 @@ ecma_fast_array_set_length (ecma_object_t *object_p, /**< fast access mode array
469
477
470
478
uint32_t new_holes = new_length - old_length - 1 ;
471
479
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 ))
473
483
{
474
484
ecma_fast_array_convert_to_normal (object_p );
475
485
return ;
0 commit comments