Reduce ecma_{ref, deref}_object calls while using ecma_builtin_get (#2616)
The following stucture was highly frequented in the code base: - Get a builtin object // This operation increases the reference count of the object - Use it for create a new object - Deref the builtin object After a builtin has been instantiated there is always at least one reference to "keep it alive", so increase/decrease the reference count for getting the value only is unnecessary. JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
committed by
Zoltan Herczeg
parent
8410570dd9
commit
e11c499b4b
@@ -492,8 +492,6 @@ ecma_builtin_date_dispatch_construct (const ecma_value_t *arguments_list_p, /**<
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) obj_p;
|
||||
ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_UNDEFINED;
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
if (arguments_list_len == 0)
|
||||
{
|
||||
ECMA_TRY_CATCH (parse_res_value,
|
||||
|
||||
@@ -303,8 +303,6 @@ ecma_builtin_function_prototype_object_bind (ecma_value_t this_arg, /**< this ar
|
||||
ext_function_p->u.bound_function.args_len_or_this = args_len_or_this;
|
||||
}
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
/*
|
||||
* [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_FUNCTION type.
|
||||
*
|
||||
|
||||
@@ -155,6 +155,7 @@ static const ecma_builtin_property_list_reference_t ecma_builtin_property_list_r
|
||||
static size_t
|
||||
ecma_builtin_get_property_count (ecma_builtin_id_t builtin_id) /**< built-in ID */
|
||||
{
|
||||
JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT);
|
||||
const ecma_builtin_property_descriptor_t *property_list_p = ecma_builtin_property_list_references[builtin_id];
|
||||
|
||||
const ecma_builtin_property_descriptor_t *curr_property_p = property_list_p;
|
||||
@@ -180,21 +181,17 @@ ecma_builtin_is (ecma_object_t *obj_p, /**< pointer to an object */
|
||||
JERRY_ASSERT (obj_p != NULL && !ecma_is_lexical_environment (obj_p));
|
||||
JERRY_ASSERT (builtin_id < ECMA_BUILTIN_ID__COUNT);
|
||||
|
||||
if (JERRY_CONTEXT (ecma_builtin_objects)[builtin_id] == NULL)
|
||||
{
|
||||
/* If a built-in object is not instantiated,
|
||||
* the specified object cannot be the built-in object */
|
||||
return false;
|
||||
}
|
||||
else
|
||||
{
|
||||
return (obj_p == JERRY_CONTEXT (ecma_builtin_objects)[builtin_id]);
|
||||
}
|
||||
/* If a built-in object is not instantiated, its value is NULL,
|
||||
hence it cannot be equal to a valid object. */
|
||||
return (obj_p == JERRY_CONTEXT (ecma_builtin_objects)[builtin_id]);
|
||||
} /* ecma_builtin_is */
|
||||
|
||||
/**
|
||||
* Get reference to specified built-in object
|
||||
*
|
||||
* Note:
|
||||
* Does not increase the reference counter.
|
||||
*
|
||||
* @return pointer to the object's instance
|
||||
*/
|
||||
ecma_object_t *
|
||||
@@ -207,8 +204,6 @@ ecma_builtin_get (ecma_builtin_id_t builtin_id) /**< id of built-in to check on
|
||||
ecma_instantiate_builtin (builtin_id);
|
||||
}
|
||||
|
||||
ecma_ref_object (JERRY_CONTEXT (ecma_builtin_objects)[builtin_id]);
|
||||
|
||||
return JERRY_CONTEXT (ecma_builtin_objects)[builtin_id];
|
||||
} /* ecma_builtin_get */
|
||||
|
||||
@@ -521,8 +516,6 @@ ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**
|
||||
ext_object_size,
|
||||
ECMA_OBJECT_TYPE_FUNCTION);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
ecma_set_object_is_builtin (func_obj_p);
|
||||
|
||||
JERRY_ASSERT (routine_id >= ECMA_BUILTIN_ID__COUNT);
|
||||
@@ -740,7 +733,9 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
}
|
||||
case ECMA_BUILTIN_PROPERTY_OBJECT:
|
||||
{
|
||||
value = ecma_make_object_value (ecma_builtin_get ((ecma_builtin_id_t) curr_property_p->value));
|
||||
ecma_object_t *builtin_object_p = ecma_builtin_get ((ecma_builtin_id_t) curr_property_p->value);
|
||||
ecma_ref_object (builtin_object_p);
|
||||
value = ecma_make_object_value (builtin_object_p);
|
||||
break;
|
||||
}
|
||||
case ECMA_BUILTIN_PROPERTY_ROUTINE:
|
||||
|
||||
@@ -222,8 +222,6 @@ ecma_typedarray_helper_dispatch_construct (const ecma_value_t *arguments_list_p,
|
||||
ecma_typedarray_helper_get_shift_size (builtin_id),
|
||||
ecma_typedarray_helper_get_magic_string (builtin_id));
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
return val;
|
||||
} /* ecma_typedarray_helper_dispatch_construct */
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ ecma_builtin_typedarray_from (ecma_value_t this_arg, /**< 'this' argument */
|
||||
const uint8_t element_size_shift = ecma_typedarray_helper_get_shift_size (builtin_id);
|
||||
const lit_magic_string_id_t class_id = ecma_typedarray_helper_get_magic_string (builtin_id);
|
||||
|
||||
ecma_deref_object (proto_p);
|
||||
|
||||
return ecma_op_typedarray_from (source,
|
||||
map_fn,
|
||||
|
||||
@@ -72,8 +72,6 @@ ecma_builtin_uint32array_dispatch_construct (const ecma_value_t *arguments_list_
|
||||
2,
|
||||
LIT_MAGIC_STRING_UINT32_ARRAY_UL);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
return val;
|
||||
} /* ecma_builtin_uint32array_dispatch_construct */
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ ecma_builtin_uint8clampedarray_dispatch_construct (const ecma_value_t *arguments
|
||||
0,
|
||||
LIT_MAGIC_STRING_UINT8_CLAMPED_ARRAY_UL);
|
||||
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
return val;
|
||||
} /* ecma_builtin_uint8clampedarray_dispatch_construct */
|
||||
|
||||
Reference in New Issue
Block a user