From e11c499b4b74a7eeceb30052380ec997062ea829 Mon Sep 17 00:00:00 2001 From: Robert Fancsik Date: Wed, 28 Nov 2018 20:23:21 +0100 Subject: [PATCH] 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 --- jerry-core/api/jerry.c | 7 ++--- .../ecma/builtin-objects/ecma-builtin-date.c | 2 -- .../ecma-builtin-function-prototype.c | 2 -- .../ecma/builtin-objects/ecma-builtins.c | 25 +++++++---------- .../ecma-builtin-typedarray-helpers.c | 2 -- .../typedarray/ecma-builtin-typedarray.c | 1 - .../typedarray/ecma-builtin-uint32array.c | 2 -- .../ecma-builtin-uint8clampedarray.c | 1 - .../ecma/operations/ecma-array-object.c | 2 -- .../ecma/operations/ecma-arraybuffer-object.c | 4 +-- .../ecma/operations/ecma-boolean-object.c | 2 -- jerry-core/ecma/operations/ecma-exceptions.c | 2 -- .../ecma/operations/ecma-function-object.c | 13 --------- .../ecma/operations/ecma-get-put-value.c | 4 +-- jerry-core/ecma/operations/ecma-lex-env.c | 2 -- jerry-core/ecma/operations/ecma-map-object.c | 2 -- .../ecma/operations/ecma-number-object.c | 2 -- .../ecma/operations/ecma-objects-arguments.c | 4 --- .../ecma/operations/ecma-objects-general.c | 6 +--- .../ecma/operations/ecma-promise-object.c | 1 - .../ecma/operations/ecma-regexp-object.c | 5 ---- .../ecma/operations/ecma-string-object.c | 2 -- .../ecma/operations/ecma-typedarray-object.c | 4 --- jerry-core/vm/vm.c | 28 ++++++++----------- 24 files changed, 28 insertions(+), 97 deletions(-) diff --git a/jerry-core/api/jerry.c b/jerry-core/api/jerry.c index 09e75b13a..f2fb00385 100644 --- a/jerry-core/api/jerry.c +++ b/jerry-core/api/jerry.c @@ -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 */ diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-date.c b/jerry-core/ecma/builtin-objects/ecma-builtin-date.c index c15fb048a..080f751cb 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-date.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-date.c @@ -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, diff --git a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c index 32b8cb345..e9a78075a 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtin-function-prototype.c @@ -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. * diff --git a/jerry-core/ecma/builtin-objects/ecma-builtins.c b/jerry-core/ecma/builtin-objects/ecma-builtins.c index 0fd75f9ae..a7091a02c 100644 --- a/jerry-core/ecma/builtin-objects/ecma-builtins.c +++ b/jerry-core/ecma/builtin-objects/ecma-builtins.c @@ -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: diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c index e6660ba5e..cc623488f 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray-helpers.c @@ -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 */ diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c index 77c00c626..0b1c7e96e 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-typedarray.c @@ -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, diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c index f8f702d3e..ee2e398a0 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint32array.c @@ -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 */ diff --git a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c index e5f7a8b3d..a199b430a 100644 --- a/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c +++ b/jerry-core/ecma/builtin-objects/typedarray/ecma-builtin-uint8clampedarray.c @@ -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 */ diff --git a/jerry-core/ecma/operations/ecma-array-object.c b/jerry-core/ecma/operations/ecma-array-object.c index 89ff69619..abc7acd44 100644 --- a/jerry-core/ecma/operations/ecma-array-object.c +++ b/jerry-core/ecma/operations/ecma-array-object.c @@ -95,8 +95,6 @@ ecma_op_create_array_object (const ecma_value_t *arguments_list_p, /**< list of sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_ARRAY); - ecma_deref_object (array_prototype_object_p); - /* * [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_ARRAY type. * diff --git a/jerry-core/ecma/operations/ecma-arraybuffer-object.c b/jerry-core/ecma/operations/ecma-arraybuffer-object.c index ad0f26962..c828ded3f 100644 --- a/jerry-core/ecma/operations/ecma-arraybuffer-object.c +++ b/jerry-core/ecma/operations/ecma-arraybuffer-object.c @@ -49,7 +49,7 @@ ecma_arraybuffer_new_object (ecma_length_t length) /**< length of the arraybuffe ecma_object_t *object_p = ecma_create_object (prototype_obj_p, sizeof (ecma_extended_object_t) + length, ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); + ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.class_prop.extra_info = ECMA_ARRAYBUFFER_INTERNAL_MEMORY; ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL; @@ -80,7 +80,7 @@ ecma_arraybuffer_new_object_external (ecma_length_t length, /**< length of the b ecma_object_t *object_p = ecma_create_object (prototype_obj_p, sizeof (ecma_arraybuffer_external_info), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); + ecma_arraybuffer_external_info *array_object_p = (ecma_arraybuffer_external_info *) object_p; array_object_p->extended_object.u.class_prop.extra_info = ECMA_ARRAYBUFFER_EXTERNAL_MEMORY; array_object_p->extended_object.u.class_prop.class_id = LIT_MAGIC_STRING_ARRAY_BUFFER_UL; diff --git a/jerry-core/ecma/operations/ecma-boolean-object.c b/jerry-core/ecma/operations/ecma-boolean-object.c index fdadfbcf8..f8a8c26b7 100644 --- a/jerry-core/ecma/operations/ecma-boolean-object.c +++ b/jerry-core/ecma/operations/ecma-boolean-object.c @@ -53,8 +53,6 @@ ecma_op_create_boolean_object (ecma_value_t arg) /**< argument passed to the Boo sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); - ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_BOOLEAN_UL; ext_object_p->u.class_prop.u.value = ecma_make_boolean_value (boolean_value); diff --git a/jerry-core/ecma/operations/ecma-exceptions.c b/jerry-core/ecma/operations/ecma-exceptions.c index 1200e4dc6..33d04cd0d 100644 --- a/jerry-core/ecma/operations/ecma-exceptions.c +++ b/jerry-core/ecma/operations/ecma-exceptions.c @@ -137,8 +137,6 @@ ecma_new_standard_error (ecma_standard_error_t error_type) /**< native error typ sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); - ((ecma_extended_object_t *) new_error_obj_p)->u.class_prop.class_id = LIT_MAGIC_STRING_ERROR_UL; #ifdef JERRY_ENABLE_LINE_INFO diff --git a/jerry-core/ecma/operations/ecma-function-object.c b/jerry-core/ecma/operations/ecma-function-object.c index f9071c332..83abc4ccb 100644 --- a/jerry-core/ecma/operations/ecma-function-object.c +++ b/jerry-core/ecma/operations/ecma-function-object.c @@ -137,8 +137,6 @@ ecma_op_create_function_object (ecma_object_t *scope_p, /**< function's scope */ function_object_size, ECMA_OBJECT_TYPE_FUNCTION); - ecma_deref_object (prototype_obj_p); - /* 2., 6., 7., 8. */ /* * We don't setup [[Get]], [[Call]], [[Construct]], [[HasInstance]] for each function object. @@ -215,9 +213,6 @@ ecma_op_create_arrow_function_object (ecma_object_t *scope_p, /**< function's sc arrow_function_object_size, ECMA_OBJECT_TYPE_ARROW_FUNCTION); - ecma_deref_object (prototype_obj_p); - - ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) func_p; ECMA_SET_NON_NULL_POINTER (arrow_func_p->scope_cp, scope_p); @@ -263,8 +258,6 @@ ecma_op_create_external_function_object (ecma_external_handler_t handler_cb) /** sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION); - ecma_deref_object (prototype_obj_p); - /* * [[Class]] property is not stored explicitly for objects of ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION type. * @@ -1019,8 +1012,6 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */ ecma_object_t *prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE); new_this_obj_p = ecma_create_object (prototype_p, 0, ECMA_OBJECT_TYPE_GENERAL); - - ecma_deref_object (prototype_p); } ecma_free_value (prototype_prop_value); @@ -1179,8 +1170,6 @@ ecma_op_function_try_to_lazy_instantiate_property (ecma_object_t *object_p, /**< thrower_p, ECMA_PROPERTY_FIXED, &caller_prop_p); - - ecma_deref_object (thrower_p); return caller_prop_p; } } @@ -1290,8 +1279,6 @@ ecma_op_bound_function_try_to_lazy_instantiate_property (ecma_object_t *object_p thrower_p, ECMA_PROPERTY_FIXED, &caller_prop_p); - - ecma_deref_object (thrower_p); return caller_prop_p; } diff --git a/jerry-core/ecma/operations/ecma-get-put-value.c b/jerry-core/ecma/operations/ecma-get-put-value.c index e6efbcab1..4f4604d75 100644 --- a/jerry-core/ecma/operations/ecma-get-put-value.c +++ b/jerry-core/ecma/operations/ecma-get-put-value.c @@ -169,15 +169,13 @@ ecma_op_put_value_lex_env_base (ecma_object_t *ref_base_lex_env_p, /**< referenc else { /* 3.b. */ - ecma_object_t *global_object_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL); + ecma_object_t *global_object_p = ecma_builtin_get_global (); ecma_value_t completion = ecma_op_object_put (global_object_p, var_name_string_p, value, false); - ecma_deref_object (global_object_p); - JERRY_ASSERT (ecma_is_value_boolean (completion)); return ECMA_VALUE_EMPTY; diff --git a/jerry-core/ecma/operations/ecma-lex-env.c b/jerry-core/ecma/operations/ecma-lex-env.c index eee9adc25..d000fa4f2 100644 --- a/jerry-core/ecma/operations/ecma-lex-env.c +++ b/jerry-core/ecma/operations/ecma-lex-env.c @@ -44,8 +44,6 @@ ecma_init_global_lex_env (void) JERRY_CONTEXT (ecma_global_lex_env_p) = ecma_create_object_lex_env (NULL, glob_obj_p, ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND); - - ecma_deref_object (glob_obj_p); } /* ecma_init_global_lex_env */ /** diff --git a/jerry-core/ecma/operations/ecma-map-object.c b/jerry-core/ecma/operations/ecma-map-object.c index f1a1d25b5..403e86733 100644 --- a/jerry-core/ecma/operations/ecma-map-object.c +++ b/jerry-core/ecma/operations/ecma-map-object.c @@ -48,8 +48,6 @@ ecma_op_map_create (const ecma_value_t *arguments_list_p, /**< arguments list */ sizeof (ecma_map_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); - ecma_map_object_t *map_object_p = (ecma_map_object_t *) object_p; map_object_p->header.u.class_prop.class_id = LIT_MAGIC_STRING_MAP_UL; map_object_p->header.u.class_prop.extra_info = 0; diff --git a/jerry-core/ecma/operations/ecma-number-object.c b/jerry-core/ecma/operations/ecma-number-object.c index bb09f0f15..346f69f30 100644 --- a/jerry-core/ecma/operations/ecma-number-object.c +++ b/jerry-core/ecma/operations/ecma-number-object.c @@ -58,8 +58,6 @@ ecma_op_create_number_object (ecma_value_t arg) /**< argument passed to the Numb sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); - ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_NUMBER_UL; diff --git a/jerry-core/ecma/operations/ecma-objects-arguments.c b/jerry-core/ecma/operations/ecma-objects-arguments.c index 70b03cca9..b87724c78 100644 --- a/jerry-core/ecma/operations/ecma-objects-arguments.c +++ b/jerry-core/ecma/operations/ecma-objects-arguments.c @@ -109,8 +109,6 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_ARGUMENTS_UL; } - ecma_deref_object (prototype_p); - ecma_property_value_t *prop_value_p; /* 11.a, 11.b */ @@ -182,8 +180,6 @@ ecma_op_create_arguments_object (ecma_object_t *func_obj_p, /**< callee function &prop_desc, false); JERRY_ASSERT (ecma_is_value_true (completion)); - - ecma_deref_object (thrower_p); } ecma_string_t *arguments_string_p = ecma_get_magic_string (LIT_MAGIC_STRING_ARGUMENTS); diff --git a/jerry-core/ecma/operations/ecma-objects-general.c b/jerry-core/ecma/operations/ecma-objects-general.c index 839130d3b..7ebe6b2fd 100644 --- a/jerry-core/ecma/operations/ecma-objects-general.c +++ b/jerry-core/ecma/operations/ecma-objects-general.c @@ -62,11 +62,7 @@ ecma_op_create_object_object_noarg (void) ecma_object_t *object_prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE); /* 3., 4., 6., 7. */ - ecma_object_t *obj_p = ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p); - - ecma_deref_object (object_prototype_p); - - return obj_p; + return ecma_op_create_object_object_noarg_and_set_prototype (object_prototype_p); } /* ecma_op_create_object_object_noarg */ /** diff --git a/jerry-core/ecma/operations/ecma-promise-object.c b/jerry-core/ecma/operations/ecma-promise-object.c index c5ab27ae0..4c4581446 100644 --- a/jerry-core/ecma/operations/ecma-promise-object.c +++ b/jerry-core/ecma/operations/ecma-promise-object.c @@ -492,7 +492,6 @@ ecma_op_create_promise_object (ecma_value_t executor, /**< the executor function ecma_object_t *object_p = ecma_create_object (prototype_obj_p, sizeof (ecma_promise_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_PROMISE_UL; ext_object_p->u.class_prop.u.value = ECMA_VALUE_UNDEFINED; diff --git a/jerry-core/ecma/operations/ecma-regexp-object.c b/jerry-core/ecma/operations/ecma-regexp-object.c index 275b6264e..225837987 100644 --- a/jerry-core/ecma/operations/ecma-regexp-object.c +++ b/jerry-core/ecma/operations/ecma-regexp-object.c @@ -218,8 +218,6 @@ ecma_op_create_regexp_object_from_bytecode (re_compiled_code_t *bytecode_p) /**< sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (re_prototype_obj_p); - ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; /* Set the internal [[Class]] property */ @@ -259,9 +257,6 @@ ecma_op_create_regexp_object (ecma_string_t *pattern_p, /**< input pattern */ ecma_object_t *object_p = ecma_create_object (re_prototype_obj_p, sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); - - ecma_deref_object (re_prototype_obj_p); - ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_UNDEFINED; diff --git a/jerry-core/ecma/operations/ecma-string-object.c b/jerry-core/ecma/operations/ecma-string-object.c index a4a18df18..2384d8a69 100644 --- a/jerry-core/ecma/operations/ecma-string-object.c +++ b/jerry-core/ecma/operations/ecma-string-object.c @@ -70,8 +70,6 @@ ecma_op_create_string_object (const ecma_value_t *arguments_list_p, /**< list of sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_CLASS); - ecma_deref_object (prototype_obj_p); - ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p; ext_object_p->u.class_prop.class_id = LIT_MAGIC_STRING_STRING_UL; ext_object_p->u.class_prop.u.value = prim_value; diff --git a/jerry-core/ecma/operations/ecma-typedarray-object.c b/jerry-core/ecma/operations/ecma-typedarray-object.c index b28cecb82..6062555a8 100644 --- a/jerry-core/ecma/operations/ecma-typedarray-object.c +++ b/jerry-core/ecma/operations/ecma-typedarray-object.c @@ -991,7 +991,6 @@ ecma_op_create_typedarray_with_type_and_length (ecma_object_t *obj_p, /**< Typed || !ecma_is_value_object (constructor_value) || !ecma_is_constructor (constructor_value)) { - ecma_deref_object (proto_p); ecma_free_value (constructor_value); return ecma_raise_type_error (ECMA_ERR_MSG ("object.constructor is not a constructor.")); } @@ -1004,7 +1003,6 @@ ecma_op_create_typedarray_with_type_and_length (ecma_object_t *obj_p, /**< Typed if (ECMA_IS_VALUE_ERROR (constructor_prototype)) { - ecma_deref_object (proto_p); return constructor_prototype; } #endif /* !CONFIG_DISABLE_ES2015_CLASS */ @@ -1014,8 +1012,6 @@ ecma_op_create_typedarray_with_type_and_length (ecma_object_t *obj_p, /**< Typed element_size_shift, class_id); - ecma_deref_object (proto_p); - #ifndef CONFIG_DISABLE_ES2015_CLASS ecma_object_t *constructor_prototype_object_p = ecma_get_object_from_value (constructor_prototype); ecma_object_t *new_obj_p = ecma_get_object_from_value (new_obj); diff --git a/jerry-core/vm/vm.c b/jerry-core/vm/vm.c index 71a5dfaf6..c0d8e313e 100644 --- a/jerry-core/vm/vm.c +++ b/jerry-core/vm/vm.c @@ -222,17 +222,14 @@ static const uint16_t vm_decode_table[] JERRY_CONST_DATA = ecma_value_t vm_run_global (const ecma_compiled_code_t *bytecode_p) /**< pointer to bytecode to run */ { - ecma_object_t *glob_obj_p = ecma_builtin_get (ECMA_BUILTIN_ID_GLOBAL); + ecma_object_t *glob_obj_p = ecma_builtin_get_global (); - ecma_value_t ret_value = vm_run (bytecode_p, - ecma_make_object_value (glob_obj_p), - ecma_get_global_environment (), - false, - NULL, - 0); - - ecma_deref_object (glob_obj_p); - return ret_value; + return vm_run (bytecode_p, + ecma_make_object_value (glob_obj_p), + ecma_get_global_environment (), + false, + NULL, + 0); } /* vm_run_global */ /** @@ -275,7 +272,9 @@ vm_run_eval (ecma_compiled_code_t *bytecode_data_p, /**< byte-code data */ } else { - this_binding = 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); + this_binding = ecma_make_object_value (global_obj_p); lex_env_p = ecma_get_global_environment (); } @@ -1107,12 +1106,10 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ } case VM_OC_PUSH_OBJECT: { - ecma_object_t *prototype_p = ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE); - ecma_object_t *obj_p = ecma_create_object (prototype_p, + ecma_object_t *obj_p = ecma_create_object (ecma_builtin_get (ECMA_BUILTIN_ID_OBJECT_PROTOTYPE), 0, ECMA_OBJECT_TYPE_GENERAL); - ecma_deref_object (prototype_p); *stack_top_p++ = ecma_make_object_value (obj_p); continue; } @@ -1399,9 +1396,6 @@ vm_loop (vm_frame_ctx_t *frame_ctx_p) /**< frame context */ sizeof (ecma_extended_object_t), ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION); - - ecma_deref_object (prototype_obj_p); - ecma_extended_object_t *ext_func_obj_p = (ecma_extended_object_t *) function_obj_p; ext_func_obj_p->u.external_handler_cb = ecma_op_function_implicit_constructor_handler_cb;