Skip to content

Commit 73807c6

Browse files
committed
Passing less number of arguments to a function is generally faster. So
the three boolean arguments of ecma_create_named_data_property and the two boolean arguments of ecma_create_named_accessor_property are combined into one uint8_t argument. On ARM-32 it is preferred to have less than four arguments, since these arguments can be passed in registers. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 3796987 commit 73807c6

17 files changed

+128
-86
lines changed

jerry-core/ecma/base/ecma-globals.h

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,29 @@ typedef enum
291291
ECMA_PROPERTY_FLAG_LCACHED = 1u << (ECMA_PROPERTY_FLAG_SHIFT + 3), /**< property is lcached */
292292
} ecma_property_flags_t;
293293

294+
/**
295+
* Property flags configurable, enumerable, writable.
296+
*/
297+
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE \
298+
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
299+
300+
/**
301+
* Property flags configurable, enumerable.
302+
*/
303+
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE \
304+
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
305+
306+
/**
307+
* Property flags configurable, enumerable.
308+
*/
309+
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE \
310+
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
311+
312+
/**
313+
* No attributes can be changed for this property.
314+
*/
315+
#define ECMA_PROPERTY_FIXED 0
316+
294317
/**
295318
* Abstract property representation.
296319
*

jerry-core/ecma/base/ecma-helpers.c

Lines changed: 6 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -576,26 +576,13 @@ ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
576576
ecma_property_t *
577577
ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
578578
ecma_string_t *name_p, /**< property name */
579-
bool is_writable, /**< 'Writable' attribute */
580-
bool is_enumerable, /**< 'Enumerable' attribute */
581-
bool is_configurable) /**< 'Configurable' attribute */
579+
uint8_t prop_attributes) /**< property attributes */
582580
{
583581
JERRY_ASSERT (object_p != NULL && name_p != NULL);
584582
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
583+
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
585584

586-
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA;
587-
if (is_configurable)
588-
{
589-
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
590-
}
591-
if (is_enumerable)
592-
{
593-
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
594-
}
595-
if (is_writable)
596-
{
597-
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_WRITABLE);
598-
}
585+
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA | prop_attributes;
599586

600587
name_p = ecma_copy_or_ref_ecma_string (name_p);
601588

@@ -617,21 +604,13 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
617604
ecma_string_t *name_p, /**< property name */
618605
ecma_object_t *get_p, /**< getter */
619606
ecma_object_t *set_p, /**< setter */
620-
bool is_enumerable, /**< 'enumerable' attribute */
621-
bool is_configurable) /**< 'configurable' attribute */
607+
uint8_t prop_attributes) /**< property attributes */
622608
{
623609
JERRY_ASSERT (object_p != NULL && name_p != NULL);
624610
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
611+
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE) == 0);
625612

626-
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR;
627-
if (is_configurable)
628-
{
629-
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
630-
}
631-
if (is_enumerable)
632-
{
633-
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
634-
}
613+
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR | prop_attributes;
635614

636615
name_p = ecma_copy_or_ref_ecma_string (name_p);
637616

jerry-core/ecma/base/ecma-helpers.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -263,9 +263,9 @@ extern ecma_property_t *ecma_find_internal_property (ecma_object_t *, ecma_inter
263263
extern ecma_property_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_property_id_t);
264264

265265
extern ecma_property_t *
266-
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, bool, bool, bool);
266+
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, uint8_t);
267267
extern ecma_property_t *
268-
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *, ecma_object_t *, bool, bool);
268+
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *, ecma_object_t *, uint8_t);
269269
extern ecma_property_t *
270270
ecma_find_named_property (ecma_object_t *, ecma_string_t *);
271271
extern ecma_property_t *

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

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -300,11 +300,24 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (ecma_object_t *obj_p, /**< object */
300300
}
301301
}
302302

303+
uint8_t prop_attributes = 0;
304+
305+
if (configurable)
306+
{
307+
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
308+
}
309+
if (enumerable)
310+
{
311+
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
312+
}
313+
if (writable)
314+
{
315+
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_WRITABLE);
316+
}
317+
303318
ecma_property_t *prop_p = ecma_create_named_data_property (obj_p,
304319
prop_name_p,
305-
writable,
306-
enumerable,
307-
configurable);
320+
prop_attributes);
308321

309322
ecma_named_data_property_assign_value (obj_p, prop_p, value);
310323

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -737,11 +737,11 @@ ecma_builtin_json_parse (ecma_value_t this_arg __attr_unused___, /**< 'this' arg
737737
{
738738
ecma_object_t *object_p = ecma_op_create_object_object_noarg ();
739739
ecma_string_t *name_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
740-
ecma_property_t *property_p = ecma_create_named_data_property (object_p,
741-
name_p,
742-
true,
743-
true,
744-
true);
740+
741+
ecma_property_t *property_p;
742+
property_p = ecma_create_named_data_property (object_p,
743+
name_p,
744+
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
745745

746746
ecma_named_data_property_assign_value (object_p, property_p, final_result);
747747
ecma_free_value (final_result);

jerry-core/ecma/builtin-objects/ecma-builtin-string-prototype.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1572,7 +1572,7 @@ ecma_builtin_helper_split_match (ecma_value_t input_string, /**< first argument
15721572
ecma_string_t *magic_index_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
15731573
ecma_property_t *index_prop_p = ecma_create_named_data_property (match_array_p,
15741574
magic_index_str_p,
1575-
true, false, false);
1575+
ECMA_PROPERTY_FLAG_WRITABLE);
15761576
ecma_deref_ecma_string (magic_index_str_p);
15771577

15781578
ecma_named_data_property_assign_value (match_array_p,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -316,7 +316,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
316316

317317
ecma_property_t *len_prop_p = ecma_create_named_data_property (object_p,
318318
string_p,
319-
false, false, false);
319+
ECMA_PROPERTY_FIXED);
320320

321321
ecma_set_named_data_property_value (len_prop_p, ecma_make_uint32_value (length_prop_value));
322322

jerry-core/ecma/operations/ecma-array-object.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of
103103

104104
ecma_property_t *length_prop_p = ecma_create_named_data_property (obj_p,
105105
length_magic_string_p,
106-
true, false, false);
106+
ECMA_PROPERTY_FLAG_WRITABLE);
107+
107108
ecma_set_named_data_property_value (length_prop_p, ecma_make_number_value ((ecma_number_t) length));
108109

109110
ecma_deref_ecma_string (length_magic_string_p);

jerry-core/ecma/operations/ecma-exceptions.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ ecma_new_standard_error_with_message (ecma_standard_error_t error_type, /**< nat
120120
ecma_string_t *message_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE);
121121
ecma_property_t *prop_p = ecma_create_named_data_property (new_error_obj_p,
122122
message_magic_string_p,
123-
true, false, true);
123+
ECMA_PROPERTY_CONFIGURABLE_WRITABLE);
124124

125125
ecma_set_named_data_property_value (prop_p,
126126
ecma_make_string_value (ecma_copy_or_ref_ecma_string (message_string_p)));

jerry-core/ecma/operations/ecma-function-object.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,7 @@ ecma_op_function_try_lazy_instantiate_property (ecma_object_t *obj_p, /**< the f
311311
// 15
312312
ecma_property_t *length_prop_p = ecma_create_named_data_property (obj_p,
313313
property_name_p,
314-
false,
315-
false,
316-
false);
314+
ECMA_PROPERTY_FIXED);
317315

318316
ecma_named_data_property_assign_value (obj_p, length_prop_p, ecma_make_uint32_value (len));
319317

@@ -349,9 +347,7 @@ ecma_op_function_try_lazy_instantiate_property (ecma_object_t *obj_p, /**< the f
349347
// 18.
350348
ecma_property_t *prototype_prop_p = ecma_create_named_data_property (obj_p,
351349
property_name_p,
352-
true,
353-
false,
354-
false);
350+
ECMA_PROPERTY_FLAG_WRITABLE);
355351

356352
ecma_named_data_property_assign_value (obj_p, prototype_prop_p, ecma_make_object_value (proto_p));
357353

0 commit comments

Comments
 (0)