Compiled code should hold strong reference for the object in the tagged template literal collection (#3876)

This patch fixes #3866.

JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik frobert@inf.u-szeged.hu
This commit is contained in:
Robert Fancsik
2020-06-09 08:20:30 +02:00
committed by GitHub
parent 70383255fc
commit dba9533af1
4 changed files with 40 additions and 33 deletions
-24
View File
@@ -115,8 +115,6 @@ ecma_init_gc_info (ecma_object_t *object_p) /**< object */
JERRY_CONTEXT (ecma_gc_objects_number)++;
JERRY_CONTEXT (ecma_gc_new_objects)++;
JERRY_ASSERT (JERRY_CONTEXT (ecma_gc_new_objects) <= JERRY_CONTEXT (ecma_gc_objects_number));
JERRY_ASSERT (object_p->type_flags_refs < ECMA_OBJECT_REF_ONE);
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_REF_ONE);
@@ -398,23 +396,6 @@ ecma_gc_mark_set_object (ecma_object_t *object_p) /**< object */
#endif /* ENABLED (JERRY_ES2015_BUILTIN_SET) */
#if ENABLED (JERRY_ES2015)
/**
* Mark tagged template literals of the compiled code.
*/
static void
ecma_gc_mark_tagged_template_literals (const ecma_compiled_code_t *byte_code_p)
{
JERRY_ASSERT (byte_code_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS);
ecma_collection_t *collection_p = ecma_compiled_code_get_tagged_template_collection (byte_code_p);
for (uint32_t i = 0; i < collection_p->item_count; i++)
{
ecma_gc_set_object_visited (ecma_get_object_from_value (collection_p->buffer_p[i]));
}
} /* ecma_gc_mark_tagged_template_literals */
/**
* Mark objects referenced by inactive generator functions, async functions, etc.
*/
@@ -702,11 +683,6 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
#if ENABLED (JERRY_ES2015)
const ecma_compiled_code_t *byte_code_p = ecma_op_function_get_compiled_code (ext_func_p);
if (byte_code_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS)
{
ecma_gc_mark_tagged_template_literals (byte_code_p);
}
if (byte_code_p->status_flags & CBC_CODE_FLAGS_ARROW_FUNCTION)
{
ecma_arrow_function_t *arrow_func_p = (ecma_arrow_function_t *) object_p;
+6 -1
View File
@@ -1441,7 +1441,12 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
#if ENABLED (JERRY_ES2015)
if (bytecode_p->status_flags & CBC_CODE_FLAG_HAS_TAGGED_LITERALS)
{
ecma_collection_destroy (ecma_compiled_code_get_tagged_template_collection (bytecode_p));
ecma_collection_t *collection_p = ecma_compiled_code_get_tagged_template_collection (bytecode_p);
/* Since the objects in the tagged template collection are not strong referenced anymore by the compiled code
we can treat them as 'new' objects. */
JERRY_CONTEXT (ecma_gc_new_objects) += collection_p->item_count;
ecma_collection_free (collection_p);
}
#endif /* ENABLED (JERRY_ES2015) */
-8
View File
@@ -1658,14 +1658,6 @@ parser_post_processing (parser_context_t *context_p) /**< context */
if (context_p->tagged_template_literal_cp != JMEM_CP_NULL)
{
base_p[-1] = (ecma_value_t) context_p->tagged_template_literal_cp;
ecma_collection_t *collection_p = ECMA_GET_INTERNAL_VALUE_POINTER (ecma_collection_t,
context_p->tagged_template_literal_cp);
for (uint32_t i = 0; i < collection_p->item_count; i++)
{
ecma_free_value (collection_p->buffer_p[i]);
}
}
#endif /* ENABLED (JERRY_ES2015) */