Skip to content

Commit 37ebd20

Browse files
committed
Remove LIST_LAZY_PROPERTY_NAMES_ROUTINE_NAME macro function.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent bb07151 commit 37ebd20

File tree

3 files changed

+74
-188
lines changed

3 files changed

+74
-188
lines changed

jerry-core/ecma/builtin-objects/ecma-builtin-internal-routines-template.inc.h

Lines changed: 0 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@
3030

3131
#define PROPERTY_DESCRIPTOR_LIST_NAME \
3232
PASTE (PASTE (ecma_builtin_, BUILTIN_UNDERSCORED_ID), _property_descriptor_list)
33-
#define LIST_LAZY_PROPERTY_NAMES_ROUTINE_NAME \
34-
PASTE (PASTE (ecma_builtin_, BUILTIN_UNDERSCORED_ID), _list_lazy_property_names)
3533
#define DISPATCH_ROUTINE_ROUTINE_NAME \
3634
PASTE (PASTE (ecma_builtin_, BUILTIN_UNDERSCORED_ID), _dispatch_routine)
3735

@@ -52,19 +50,6 @@
5250
#undef ROUTINE_ARG_LIST_0
5351
#undef ROUTINE_ARG
5452

55-
#define ECMA_BUILTIN_PROPERTY_NAMES \
56-
PASTE (PASTE (ecma_builtin_property_names, _), BUILTIN_UNDERSCORED_ID)
57-
58-
static const lit_magic_string_id_t ECMA_BUILTIN_PROPERTY_NAMES[] =
59-
{
60-
#define SIMPLE_VALUE(name, simple_value, prop_attributes) name,
61-
#define NUMBER_VALUE(name, number_value, prop_attributes) name,
62-
#define STRING_VALUE(name, magic_string_id, prop_attributes) name,
63-
#define OBJECT_VALUE(name, obj_builtin_id, prop_attributes) name,
64-
#define ROUTINE(name, c_function_name, args_number, length_prop_value) name,
65-
#include BUILTIN_INC_HEADER_NAME
66-
};
67-
6853
#define ECMA_BUILTIN_PROPERTY_NAME_INDEX(name) \
6954
PASTE (PASTE (PASTE (PASTE (ecma_builtin_property_names, _), BUILTIN_UNDERSCORED_ID), _), name)
7055

@@ -132,114 +117,6 @@ const ecma_builtin_property_descriptor_t PROPERTY_DESCRIPTOR_LIST_NAME[] =
132117
}
133118
};
134119

135-
/**
136-
* List names of the built-in object's lazy instantiated properties
137-
*
138-
* See also:
139-
* TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME
140-
*
141-
* @return string values collection
142-
*/
143-
void
144-
LIST_LAZY_PROPERTY_NAMES_ROUTINE_NAME (ecma_object_t *object_p, /**< a built-in object */
145-
bool separate_enumerable, /**< true - list enumerable properties
146-
into main collection,
147-
and non-enumerable to
148-
collection of 'skipped
149-
non-enumerable'
150-
properties,
151-
false - list all properties into
152-
main collection. */
153-
ecma_collection_header_t *main_collection_p, /**< 'main' collection */
154-
ecma_collection_header_t *non_enum_collection_p) /**< skipped 'non-enumerable'
155-
collection */
156-
{
157-
ecma_collection_header_t *for_enumerable_p = main_collection_p;
158-
(void) for_enumerable_p;
159-
160-
ecma_collection_header_t *for_non_enumerable_p = separate_enumerable ? non_enum_collection_p : main_collection_p;
161-
162-
#define OBJECT_ID(builtin_id) const ecma_builtin_id_t builtin_object_id = builtin_id;
163-
#include BUILTIN_INC_HEADER_NAME
164-
165-
JERRY_ASSERT (ecma_builtin_is (object_p, builtin_object_id));
166-
167-
const ecma_length_t properties_number = (ecma_length_t) (sizeof (ECMA_BUILTIN_PROPERTY_NAMES) /
168-
sizeof (ECMA_BUILTIN_PROPERTY_NAMES[0]));
169-
170-
for (ecma_length_t index = 0;
171-
index < properties_number;
172-
index++)
173-
{
174-
lit_magic_string_id_t name = ECMA_BUILTIN_PROPERTY_NAMES[index];
175-
176-
uint32_t bit;
177-
ecma_internal_property_id_t mask_prop_id;
178-
179-
if (index >= 32)
180-
{
181-
mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63;
182-
bit = (uint32_t) 1u << (index - 32);
183-
}
184-
else
185-
{
186-
mask_prop_id = ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31;
187-
bit = (uint32_t) 1u << index;
188-
}
189-
190-
ecma_property_t *mask_prop_p = ecma_find_internal_property (object_p, mask_prop_id);
191-
bool is_instantiated = false;
192-
if (mask_prop_p == NULL)
193-
{
194-
is_instantiated = true;
195-
}
196-
else
197-
{
198-
uint32_t bit_mask = ecma_get_internal_property_value (mask_prop_p);
199-
200-
if (bit_mask & bit)
201-
{
202-
is_instantiated = true;
203-
}
204-
else
205-
{
206-
is_instantiated = false;
207-
}
208-
}
209-
210-
bool is_existing;
211-
212-
ecma_string_t *name_p = ecma_get_magic_string (name);
213-
214-
if (!is_instantiated)
215-
{
216-
/* will be instantiated upon first request */
217-
is_existing = true;
218-
}
219-
else
220-
{
221-
if (ecma_op_object_get_own_property (object_p, name_p) == NULL)
222-
{
223-
is_existing = false;
224-
}
225-
else
226-
{
227-
is_existing = true;
228-
}
229-
}
230-
231-
if (is_existing)
232-
{
233-
ecma_append_to_values_collection (for_non_enumerable_p,
234-
ecma_make_string_value (name_p),
235-
true);
236-
}
237-
238-
ecma_deref_ecma_string (name_p);
239-
}
240-
} /* LIST_LAZY_PROPERTY_NAMES_ROUTINE_NAME */
241-
242-
243120
/**
244121
* Dispatcher of the built-in's routines
245122
*
@@ -294,9 +171,7 @@ DISPATCH_ROUTINE_ROUTINE_NAME (uint16_t builtin_routine_id, /**< built-in wide r
294171
#undef PASTE_
295172
#undef PASTE
296173
#undef PROPERTY_DESCRIPTOR_LIST_NAME
297-
#undef LIST_LAZY_PROPERTY_NAMES_ROUTINE_NAME
298174
#undef DISPATCH_ROUTINE_ROUTINE_NAME
299175
#undef BUILTIN_UNDERSCORED_ID
300176
#undef BUILTIN_INC_HEADER_NAME
301-
#undef ECMA_BUILTIN_PROPERTY_NAMES
302177
#undef ECMA_BUILTIN_PROPERTY_NAME_INDEX

jerry-core/ecma/builtin-objects/ecma-builtins-internal.h

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -123,12 +123,7 @@ extern ecma_value_t \
123123
ecma_builtin_ ## lowercase_name ## _dispatch_routine (uint16_t builtin_routine_id, \
124124
ecma_value_t this_arg_value, \
125125
const ecma_value_t [], \
126-
ecma_length_t); \
127-
extern void \
128-
ecma_builtin_ ## lowercase_name ## _list_lazy_property_names (ecma_object_t *, \
129-
bool, \
130-
ecma_collection_header_t *, \
131-
ecma_collection_header_t *);
126+
ecma_length_t);
132127
#include "ecma-builtins.inc.h"
133128

134129
#endif /* !ECMA_BUILTINS_INTERNAL_H */

jerry-core/ecma/builtin-objects/ecma-builtins.c

Lines changed: 73 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)