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
This commit is contained in:
Zoltan Herczeg
2016-05-29 23:47:46 -07:00
parent 379698733a
commit 8c92972b2f
17 changed files with 128 additions and 86 deletions
+23
View File
@@ -291,6 +291,29 @@ typedef enum
ECMA_PROPERTY_FLAG_LCACHED = 1u << (ECMA_PROPERTY_FLAG_SHIFT + 3), /**< property is lcached */
} ecma_property_flags_t;
/**
* Property flags configurable, enumerable, writable.
*/
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE \
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE | ECMA_PROPERTY_FLAG_WRITABLE)
/**
* Property flags configurable, enumerable.
*/
#define ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE \
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_ENUMERABLE)
/**
* Property flags configurable, enumerable.
*/
#define ECMA_PROPERTY_CONFIGURABLE_WRITABLE \
(ECMA_PROPERTY_FLAG_CONFIGURABLE | ECMA_PROPERTY_FLAG_WRITABLE)
/**
* No attributes can be changed for this property.
*/
#define ECMA_PROPERTY_FIXED 0
/**
* Abstract property representation.
*
+6 -27
View File
@@ -576,26 +576,13 @@ ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
ecma_property_t *
ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
ecma_string_t *name_p, /**< property name */
bool is_writable, /**< 'Writable' attribute */
bool is_enumerable, /**< 'Enumerable' attribute */
bool is_configurable) /**< 'Configurable' attribute */
uint8_t prop_attributes) /**< property attributes (See: ecma_property_flags_t) */
{
JERRY_ASSERT (object_p != NULL && name_p != NULL);
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE) == 0);
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA;
if (is_configurable)
{
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (is_enumerable)
{
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
if (is_writable)
{
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_WRITABLE);
}
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA | prop_attributes;
name_p = ecma_copy_or_ref_ecma_string (name_p);
@@ -617,21 +604,13 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
ecma_string_t *name_p, /**< property name */
ecma_object_t *get_p, /**< getter */
ecma_object_t *set_p, /**< setter */
bool is_enumerable, /**< 'enumerable' attribute */
bool is_configurable) /**< 'configurable' attribute */
uint8_t prop_attributes) /**< property attributes */
{
JERRY_ASSERT (object_p != NULL && name_p != NULL);
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
JERRY_ASSERT ((prop_attributes & ~ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE) == 0);
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR;
if (is_configurable)
{
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (is_enumerable)
{
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR | prop_attributes;
name_p = ecma_copy_or_ref_ecma_string (name_p);
+2 -2
View File
@@ -263,9 +263,9 @@ extern ecma_property_t *ecma_find_internal_property (ecma_object_t *, ecma_inter
extern ecma_property_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_property_id_t);
extern ecma_property_t *
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, bool, bool, bool);
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, uint8_t);
extern ecma_property_t *
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *, ecma_object_t *, bool, bool);
ecma_create_named_accessor_property (ecma_object_t *, ecma_string_t *, ecma_object_t *, ecma_object_t *, uint8_t);
extern ecma_property_t *
ecma_find_named_property (ecma_object_t *, ecma_string_t *);
extern ecma_property_t *
@@ -300,11 +300,24 @@ TRY_TO_INSTANTIATE_PROPERTY_ROUTINE_NAME (ecma_object_t *obj_p, /**< object */
}
}
uint8_t prop_attributes = 0;
if (configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
if (writable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_WRITABLE);
}
ecma_property_t *prop_p = ecma_create_named_data_property (obj_p,
prop_name_p,
writable,
enumerable,
configurable);
prop_attributes);
ecma_named_data_property_assign_value (obj_p, prop_p, value);
@@ -737,11 +737,11 @@ ecma_builtin_json_parse (ecma_value_t this_arg __attr_unused___, /**< 'this' arg
{
ecma_object_t *object_p = ecma_op_create_object_object_noarg ();
ecma_string_t *name_p = ecma_get_magic_string (LIT_MAGIC_STRING__EMPTY);
ecma_property_t *property_p = ecma_create_named_data_property (object_p,
name_p,
true,
true,
true);
ecma_property_t *property_p;
property_p = ecma_create_named_data_property (object_p,
name_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
ecma_named_data_property_assign_value (object_p, property_p, final_result);
ecma_free_value (final_result);
@@ -1572,7 +1572,7 @@ ecma_builtin_helper_split_match (ecma_value_t input_string, /**< first argument
ecma_string_t *magic_index_str_p = ecma_get_magic_string (LIT_MAGIC_STRING_INDEX);
ecma_property_t *index_prop_p = ecma_create_named_data_property (match_array_p,
magic_index_str_p,
true, false, false);
ECMA_PROPERTY_FLAG_WRITABLE);
ecma_deref_ecma_string (magic_index_str_p);
ecma_named_data_property_assign_value (match_array_p,
@@ -316,7 +316,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
ecma_property_t *len_prop_p = ecma_create_named_data_property (object_p,
string_p,
false, false, false);
ECMA_PROPERTY_FIXED);
ecma_set_named_data_property_value (len_prop_p, ecma_make_uint32_value (length_prop_value));
@@ -103,7 +103,8 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of
ecma_property_t *length_prop_p = ecma_create_named_data_property (obj_p,
length_magic_string_p,
true, false, false);
ECMA_PROPERTY_FLAG_WRITABLE);
ecma_set_named_data_property_value (length_prop_p, ecma_make_number_value ((ecma_number_t) length));
ecma_deref_ecma_string (length_magic_string_p);
+1 -1
View File
@@ -120,7 +120,7 @@ ecma_new_standard_error_with_message (ecma_standard_error_t error_type, /**< nat
ecma_string_t *message_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_MESSAGE);
ecma_property_t *prop_p = ecma_create_named_data_property (new_error_obj_p,
message_magic_string_p,
true, false, true);
ECMA_PROPERTY_CONFIGURABLE_WRITABLE);
ecma_set_named_data_property_value (prop_p,
ecma_make_string_value (ecma_copy_or_ref_ecma_string (message_string_p)));
@@ -311,9 +311,7 @@ ecma_op_function_try_lazy_instantiate_property (ecma_object_t *obj_p, /**< the f
// 15
ecma_property_t *length_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
false,
false,
false);
ECMA_PROPERTY_FIXED);
ecma_named_data_property_assign_value (obj_p, length_prop_p, ecma_make_uint32_value (len));
@@ -349,9 +347,7 @@ ecma_op_function_try_lazy_instantiate_property (ecma_object_t *obj_p, /**< the f
// 18.
ecma_property_t *prototype_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
true,
false,
false);
ECMA_PROPERTY_FLAG_WRITABLE);
ecma_named_data_property_assign_value (obj_p, prototype_prop_p, ecma_make_object_value (proto_p));
+9 -2
View File
@@ -135,9 +135,16 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
if (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
{
uint8_t prop_attributes = ECMA_PROPERTY_FLAG_WRITABLE;
if (is_deletable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
ecma_create_named_data_property (lex_env_p,
name_p,
true, false, is_deletable);
prop_attributes);
}
else
{
@@ -399,7 +406,7 @@ ecma_op_create_immutable_binding (ecma_object_t *lex_env_p, /**< lexical environ
*/
ecma_property_t *prop_p = ecma_create_named_data_property (lex_env_p,
name_p,
false, false, false);
ECMA_PROPERTY_FIXED);
JERRY_ASSERT (ecma_is_value_undefined (ecma_get_named_data_property_value (prop_p)));
@@ -403,11 +403,10 @@ ecma_op_general_object_put (ecma_object_t *obj_p, /**< the object */
}
}
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
true, /* Writable */
true, /* Enumerable */
true); /* Configurable */
ecma_property_t *new_prop_p;
new_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
JERRY_ASSERT (ecma_is_value_undefined (ecma_get_named_data_property_value (new_prop_p)));
ecma_set_named_data_property_value (new_prop_p, ecma_copy_value_if_not_object (value));
@@ -635,12 +634,24 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
JERRY_ASSERT (property_desc_type == ECMA_PROPERTY_TYPE_GENERIC
|| property_desc_type == ECMA_PROPERTY_TYPE_NAMEDDATA);
uint8_t prop_attributes = 0;
if (property_desc_p->is_configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (property_desc_p->is_enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
if (property_desc_p->is_writable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_WRITABLE);
}
ecma_property_t *new_prop_p = ecma_create_named_data_property (obj_p,
property_name_p,
property_desc_p->is_writable,
property_desc_p->is_enumerable,
property_desc_p->is_configurable);
prop_attributes);
JERRY_ASSERT (property_desc_p->is_value_defined
|| ecma_is_value_undefined (property_desc_p->value));
@@ -651,12 +662,22 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
{
// b.
uint8_t prop_attributes = 0;
if (property_desc_p->is_configurable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_CONFIGURABLE);
}
if (property_desc_p->is_enumerable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
ecma_create_named_accessor_property (obj_p,
property_name_p,
property_desc_p->get_p,
property_desc_p->set_p,
property_desc_p->is_enumerable,
property_desc_p->is_configurable);
prop_attributes);
}
return ecma_make_simple_value (ECMA_SIMPLE_VALUE_TRUE);
@@ -727,8 +748,12 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
/* The following implementation can be optimized by directly overwriting
* the fields of current_p if this code path is performance critical. */
uint8_t prop_attributes = ECMA_PROPERTY_FLAG_CONFIGURABLE;
bool was_enumerable = ecma_is_property_enumerable (current_p);
if (ecma_is_property_enumerable (current_p))
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_ENUMERABLE);
}
ecma_delete_property (obj_p, current_p);
@@ -740,8 +765,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
property_name_p,
NULL,
NULL,
was_enumerable,
true);
prop_attributes);
}
else
{
@@ -749,9 +773,7 @@ ecma_op_general_object_define_own_property (ecma_object_t *obj_p, /**< the objec
current_p = ecma_create_named_data_property (obj_p,
property_name_p,
false,
was_enumerable,
true);
prop_attributes);
}
}
@@ -142,7 +142,7 @@ re_initialize_props (ecma_object_t *re_obj_p, /**< RegExp obejct */
{
prop_p = ecma_create_named_data_property (re_obj_p,
magic_string_p,
false, false, false);
ECMA_PROPERTY_FIXED);
}
ecma_deref_ecma_string (magic_string_p);
@@ -161,7 +161,7 @@ re_initialize_props (ecma_object_t *re_obj_p, /**< RegExp obejct */
{
prop_p = ecma_create_named_data_property (re_obj_p,
magic_string_p,
false, false, false);
ECMA_PROPERTY_FIXED);
}
ecma_deref_ecma_string (magic_string_p);
@@ -177,7 +177,7 @@ re_initialize_props (ecma_object_t *re_obj_p, /**< RegExp obejct */
{
prop_p = ecma_create_named_data_property (re_obj_p,
magic_string_p,
false, false, false);
ECMA_PROPERTY_FIXED);
}
ecma_deref_ecma_string (magic_string_p);
@@ -193,7 +193,7 @@ re_initialize_props (ecma_object_t *re_obj_p, /**< RegExp obejct */
{
prop_p = ecma_create_named_data_property (re_obj_p,
magic_string_p,
false, false, false);
ECMA_PROPERTY_FIXED);
}
ecma_deref_ecma_string (magic_string_p);
@@ -209,7 +209,7 @@ re_initialize_props (ecma_object_t *re_obj_p, /**< RegExp obejct */
{
prop_p = ecma_create_named_data_property (re_obj_p,
magic_string_p,
true, false, false);
ECMA_PROPERTY_FLAG_WRITABLE);
}
ecma_deref_ecma_string (magic_string_p);
@@ -101,7 +101,7 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of
ecma_string_t *length_magic_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_LENGTH);
ecma_property_t *length_prop_p = ecma_create_named_data_property (obj_p,
length_magic_string_p,
false, false, false);
ECMA_PROPERTY_FIXED);
ecma_set_named_data_property_value (length_prop_p, ecma_make_number_value (length_value));
ecma_deref_ecma_string (length_magic_string_p);
@@ -191,7 +191,7 @@ ecma_op_string_object_get_own_property (ecma_object_t *obj_p, /**< a String obje
new_prop_p = ecma_create_named_data_property (obj_p,
new_prop_name_p,
false, true, false);
ECMA_PROPERTY_FLAG_ENUMERABLE);
ecma_set_named_data_property_value (new_prop_p,
ecma_make_string_value (new_prop_str_value_p));
+8 -3
View File
@@ -1060,11 +1060,16 @@ jerry_api_add_object_field (jerry_api_object_t *object_p, /**< object to add fie
ecma_value_t value_to_put;
jerry_api_convert_api_value_to_ecma_value (&value_to_put, field_value_p);
uint8_t prop_attributes = ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE;
if (is_writable)
{
prop_attributes = (uint8_t) (prop_attributes | ECMA_PROPERTY_FLAG_WRITABLE);
}
prop_p = ecma_create_named_data_property (object_p,
field_name_str_p,
is_writable,
true,
true);
prop_attributes);
ecma_named_data_property_assign_value (object_p, prop_p, value_to_put);
ecma_free_value (value_to_put);
+1 -2
View File
@@ -181,8 +181,7 @@ opfunc_set_accessor (bool is_getter, /**< is getter accessor */
accessor_name_p,
getter_func_p,
setter_func_p,
true,
true);
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE);
}
else if (is_getter)
{
+5 -8
View File
@@ -973,9 +973,7 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
{
property_p = ecma_create_named_data_property (object_p,
prop_name_p,
true,
true,
true);
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
}
ecma_named_data_property_assign_value (object_p, property_p, left_value);
@@ -1038,11 +1036,10 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */
{
ecma_string_t *index_str_p = ecma_new_ecma_string_from_uint32 (length_num);
ecma_property_t *prop_p = ecma_create_named_data_property (array_obj_p,
index_str_p,
true, /* Writable */
true, /* Enumerable */
true); /* Configurable */
ecma_property_t *prop_p;
prop_p = ecma_create_named_data_property (array_obj_p,
index_str_p,
ECMA_PROPERTY_CONFIGURABLE_ENUMERABLE_WRITABLE);
JERRY_ASSERT (ecma_is_value_undefined (ecma_get_named_data_property_value (prop_p)));