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
@@ -596,8 +596,9 @@ jerry_value_t
|
||||
jerry_get_global_object (void)
|
||||
{
|
||||
jerry_assert_api_available ();
|
||||
|
||||
return ecma_make_object_value (ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL));
|
||||
ecma_object_t *global_obj_p = ecma_builtin_get_global ();
|
||||
ecma_ref_object (global_obj_p);
|
||||
return ecma_make_object_value (global_obj_p);
|
||||
} /* jerry_get_global_object */
|
||||
|
||||
/**
|
||||
@@ -3177,7 +3178,6 @@ jerry_create_typedarray (jerry_typedarray_type_t type_name, /**< type of TypedAr
|
||||
prototype_obj_p,
|
||||
element_size_shift,
|
||||
lit_id);
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
JERRY_ASSERT (!ECMA_IS_VALUE_ERROR (array_value));
|
||||
|
||||
@@ -3232,7 +3232,6 @@ jerry_create_typedarray_for_arraybuffer_sz (jerry_typedarray_type_t type_name, /
|
||||
ecma_value_t array_value = ecma_op_create_typedarray (arguments_p, 3, prototype_obj_p, element_size_shift, lit_id);
|
||||
ecma_free_value (arguments_p[1]);
|
||||
ecma_free_value (arguments_p[2]);
|
||||
ecma_deref_object (prototype_obj_p);
|
||||
|
||||
return jerry_return (array_value);
|
||||
#else /* CONFIG_DISABLE_ES2015_TYPEDARRAY_BUILTIN */
|
||||
|
||||
Reference in New Issue
Block a user