@@ -270,6 +270,20 @@ ecma_finalize_builtins (void)
270270 }
271271} /* ecma_finalize_builtins */
272272
273+ typedef const ecma_builtin_property_descriptor_t * ecma_builtin_property_list_reference_t ;
274+
275+ static const ecma_builtin_property_list_reference_t ecma_builtin_property_list_references [] =
276+ {
277+ #define BUILTIN (builtin_id , \
278+ object_type , \
279+ object_prototype_builtin_id , \
280+ is_extensible , \
281+ is_static , \
282+ lowercase_name ) \
283+ ecma_builtin_ ## lowercase_name ## _property_descriptor_list ,
284+ #include "ecma-builtins.inc.h"
285+ };
286+
273287/**
274288 * If the property's name is one of built-in properties of the object
275289 * that is not instantiated yet, instantiate the property and
@@ -338,31 +352,11 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
338352 ECMA_INTERNAL_PROPERTY_BUILT_IN_ID );
339353
340354 ecma_builtin_id_t builtin_id = (ecma_builtin_id_t ) ecma_get_internal_property_value (built_in_id_prop_p );
341- const ecma_builtin_property_descriptor_t * property_list_p = NULL ;
342355
356+ JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT );
343357 JERRY_ASSERT (ecma_builtin_is (object_p , builtin_id ));
344358
345- switch (builtin_id )
346- {
347- #define BUILTIN (builtin_id , \
348- object_type , \
349- object_prototype_builtin_id , \
350- is_extensible , \
351- is_static , \
352- lowercase_name ) \
353- case builtin_id: \
354- { \
355- property_list_p = ecma_builtin_ ## lowercase_name ## _property_descriptor_list; \
356- break; \
357- }
358- #include "ecma-builtins.inc.h"
359-
360- default :
361- {
362- JERRY_UNREACHABLE ();
363- break ;
364- }
365- }
359+ const ecma_builtin_property_descriptor_t * property_list_p = ecma_builtin_property_list_references [builtin_id ];
366360
367361 const ecma_builtin_property_descriptor_t * curr_property_p = property_list_p ;
368362
@@ -379,42 +373,42 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
379373
380374 JERRY_ASSERT (index < 64 );
381375
382- uint32_t bit ;
376+ uint32_t bit_for_index ;
383377 ecma_internal_property_id_t mask_prop_id ;
384378
385379 if (likely (index < 32 ))
386380 {
387381 mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31 ;
388- bit = (uint32_t ) 1u << index ;
382+ bit_for_index = (uint32_t ) 1u << index ;
389383 }
390384 else
391385 {
392386 mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63 ;
393- bit = (uint32_t ) 1u << (index - 32 );
387+ bit_for_index = (uint32_t ) 1u << (index - 32 );
394388 }
395389
396390 ecma_property_t * mask_prop_p = ecma_find_internal_property (object_p , mask_prop_id );
397- uint32_t bit_mask ;
391+ uint32_t instantiated_bitset ;
398392
399393 if (mask_prop_p == NULL )
400394 {
401395 mask_prop_p = ecma_create_internal_property (object_p , mask_prop_id );
402- bit_mask = 0 ;
396+ instantiated_bitset = 0 ;
403397 }
404398 else
405399 {
406- bit_mask = ecma_get_internal_property_value (mask_prop_p );
400+ instantiated_bitset = ecma_get_internal_property_value (mask_prop_p );
407401
408- if (bit_mask & bit )
402+ if (instantiated_bitset & bit_for_index )
409403 {
410404 /* This property was instantiated before. */
411405 return NULL ;
412406 }
413407 }
414408
415- bit_mask |= bit ;
409+ instantiated_bitset |= bit_for_index ;
416410
417- ecma_set_internal_property_value (mask_prop_p , bit_mask );
411+ ecma_set_internal_property_value (mask_prop_p , instantiated_bitset );
418412
419413 ecma_value_t value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY );
420414
@@ -559,42 +553,64 @@ ecma_builtin_list_lazy_property_names (ecma_object_t *object_p, /**< a built-in
559553 ECMA_INTERNAL_PROPERTY_BUILT_IN_ID );
560554 ecma_builtin_id_t builtin_id = (ecma_builtin_id_t ) ecma_get_internal_property_value (built_in_id_prop_p );
561555
556+ JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT );
562557 JERRY_ASSERT (ecma_builtin_is (object_p , builtin_id ));
563558
564- switch (builtin_id )
559+ const ecma_builtin_property_descriptor_t * curr_property_p = ecma_builtin_property_list_references [builtin_id ];
560+
561+ ecma_length_t index = 0 ;
562+ ecma_internal_property_id_t mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31 ;
563+ ecma_property_t * mask_prop_p = ecma_find_internal_property (object_p , mask_prop_id );
564+
565+ ecma_collection_header_t * for_non_enumerable_p = (separate_enumerable ? non_enum_collection_p
566+ : main_collection_p );
567+
568+ while (curr_property_p -> magic_string_id != LIT_MAGIC_STRING__COUNT )
565569 {
566- #define BUILTIN (builtin_id , \
567- object_type , \
568- object_prototype_builtin_id , \
569- is_extensible , \
570- is_static , \
571- lowercase_name ) \
572- case builtin_id: \
573- { \
574- ecma_builtin_ ## lowercase_name ## _list_lazy_property_names (object_p, \
575- separate_enumerable, \
576- main_collection_p, \
577- non_enum_collection_p); \
578- return; \
579- }
580- #include "ecma-builtins.inc.h"
570+ JERRY_ASSERT (index < 64 );
581571
582- case ECMA_BUILTIN_ID__COUNT :
572+ if ( index == 32 )
583573 {
584- JERRY_UNREACHABLE ();
574+ ecma_internal_property_id_t mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63 ;
575+ mask_prop_p = ecma_find_internal_property (object_p , mask_prop_id );
585576 }
586577
587- default :
578+ uint32_t bit_for_index ;
579+ if (index >= 32 )
588580 {
589- #ifdef CONFIG_ECMA_COMPACT_PROFILE
590- JERRY_UNREACHABLE ();
591- #else /* !CONFIG_ECMA_COMPACT_PROFILE */
592- JERRY_UNIMPLEMENTED ("The built-in is not implemented." );
593- #endif /* CONFIG_ECMA_COMPACT_PROFILE */
581+ bit_for_index = (uint32_t ) 1u << (index - 32 );
594582 }
595- }
583+ else
584+ {
585+ bit_for_index = (uint32_t ) 1u << index ;
586+ }
587+
588+ bool was_instantiated = true;
596589
597- JERRY_UNREACHABLE ();
590+ if (mask_prop_p != NULL )
591+ {
592+ uint32_t instantiated_bitset = ecma_get_internal_property_value (mask_prop_p );
593+
594+ if (!(instantiated_bitset & bit_for_index ))
595+ {
596+ was_instantiated = false;
597+ }
598+ }
599+
600+ ecma_string_t * name_p = ecma_get_magic_string (curr_property_p -> magic_string_id );
601+
602+ if (!was_instantiated || ecma_op_object_get_own_property (object_p , name_p ) != NULL )
603+ {
604+ ecma_append_to_values_collection (for_non_enumerable_p ,
605+ ecma_make_string_value (name_p ),
606+ true);
607+ }
608+
609+ ecma_deref_ecma_string (name_p );
610+
611+ curr_property_p ++ ;
612+ index ++ ;
613+ }
598614 }
599615} /* ecma_builtin_list_lazy_property_names */
600616
0 commit comments