Template literal arrays should not be marked. (#4352)
Make array object big endian compatible. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -626,13 +626,6 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
}
|
||||
else
|
||||
{
|
||||
jmem_cpointer_t proto_cp = object_p->u2.prototype_cp;
|
||||
|
||||
if (proto_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, proto_cp));
|
||||
}
|
||||
|
||||
switch (ecma_get_object_type (object_p))
|
||||
{
|
||||
case ECMA_OBJECT_TYPE_CLASS:
|
||||
@@ -765,6 +758,15 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
{
|
||||
ecma_extended_object_t *ext_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
if (JERRY_UNLIKELY (ext_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL))
|
||||
{
|
||||
/* Template objects are never marked. */
|
||||
JERRY_ASSERT (object_p->type_flags_refs >= ECMA_OBJECT_REF_ONE);
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
if (ecma_op_array_is_fast_array (ext_object_p))
|
||||
{
|
||||
if (object_p->u1.property_list_cp != JMEM_CP_NULL)
|
||||
@@ -780,6 +782,12 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t proto_cp = object_p->u2.prototype_cp;
|
||||
|
||||
if (proto_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, proto_cp));
|
||||
}
|
||||
return;
|
||||
}
|
||||
break;
|
||||
@@ -792,6 +800,13 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
* Aside from the tag bits every other bit should be zero,
|
||||
*/
|
||||
JERRY_ASSERT ((object_p->u1.property_list_cp & ~JMEM_TAG_MASK) == 0);
|
||||
|
||||
jmem_cpointer_t proto_cp = object_p->u2.prototype_cp;
|
||||
|
||||
if (proto_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, proto_cp));
|
||||
}
|
||||
return;
|
||||
}
|
||||
#endif /* ENABLED (JERRY_BUILTIN_PROXY) */
|
||||
@@ -907,6 +922,13 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t proto_cp = object_p->u2.prototype_cp;
|
||||
|
||||
if (proto_cp != JMEM_CP_NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (ECMA_GET_NON_NULL_POINTER (ecma_object_t, proto_cp));
|
||||
}
|
||||
}
|
||||
|
||||
jmem_cpointer_t prop_iter_cp = object_p->u1.property_list_cp;
|
||||
|
||||
@@ -942,13 +942,8 @@ typedef struct
|
||||
struct
|
||||
{
|
||||
uint32_t length; /**< length property value */
|
||||
union
|
||||
{
|
||||
ecma_property_t length_prop; /**< length property */
|
||||
uint32_t hole_count; /**< number of array holes in a fast access mode array
|
||||
* multiplied ECMA_FAST_ACCESS_HOLE_ONE */
|
||||
} u;
|
||||
|
||||
uint32_t length_prop_and_hole_count; /**< length property attributes and number of array holes in
|
||||
* a fast access mode array multiplied ECMA_FAST_ACCESS_HOLE_ONE */
|
||||
} array;
|
||||
|
||||
/**
|
||||
@@ -997,6 +992,17 @@ typedef struct
|
||||
ecma_built_in_props_t built_in; /**< built-in object part */
|
||||
} ecma_extended_built_in_object_t;
|
||||
|
||||
/**
|
||||
* Flags for array.length_prop_and_hole_count
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_FAST_ARRAY_FLAG = 1u << (ECMA_PROPERTY_NAME_TYPE_SHIFT + 0),
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
ECMA_ARRAY_TEMPLATE_LITERAL = 1u << (ECMA_PROPERTY_NAME_TYPE_SHIFT + 1),
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
} ecma_array_length_prop_and_hole_count_flags_t;
|
||||
|
||||
/**
|
||||
* Alignment for the fast access mode array length.
|
||||
* The real length is aligned up for allocating the underlying buffer.
|
||||
|
||||
@@ -79,6 +79,46 @@ ecma_collection_free_objects (ecma_collection_t *collection_p) /**< value collec
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_objects */
|
||||
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
|
||||
/**
|
||||
* Free the template literal objects and deallocate the collection
|
||||
*/
|
||||
void
|
||||
ecma_collection_free_template_literal (ecma_collection_t *collection_p) /**< value collection */
|
||||
{
|
||||
for (uint32_t i = 0; i < collection_p->item_count; i++)
|
||||
{
|
||||
ecma_object_t *object_p = ecma_get_object_from_value (collection_p->buffer_p[i]);
|
||||
|
||||
JERRY_ASSERT (ecma_get_object_type (object_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
ecma_extended_object_t *array_object_p = (ecma_extended_object_t *) object_p;
|
||||
|
||||
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
|
||||
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ECMA_ARRAY_TEMPLATE_LITERAL;
|
||||
|
||||
ecma_property_value_t *property_value_p;
|
||||
|
||||
property_value_p = ecma_get_named_data_property (object_p, ecma_get_magic_string (LIT_MAGIC_STRING_RAW));
|
||||
ecma_object_t *raw_object_p = ecma_get_object_from_value (property_value_p->value);
|
||||
|
||||
JERRY_ASSERT (ecma_get_object_type (raw_object_p) == ECMA_OBJECT_TYPE_ARRAY);
|
||||
|
||||
array_object_p = (ecma_extended_object_t *) raw_object_p;
|
||||
|
||||
JERRY_ASSERT (array_object_p->u.array.length_prop_and_hole_count & ECMA_ARRAY_TEMPLATE_LITERAL);
|
||||
array_object_p->u.array.length_prop_and_hole_count &= (uint32_t) ECMA_ARRAY_TEMPLATE_LITERAL;
|
||||
|
||||
ecma_deref_object (raw_object_p);
|
||||
ecma_deref_object (object_p);
|
||||
}
|
||||
|
||||
ecma_collection_destroy (collection_p);
|
||||
} /* ecma_collection_free_template_literal */
|
||||
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
/**
|
||||
* Free the non-object collection elements and deallocate the collection
|
||||
*/
|
||||
|
||||
@@ -1476,8 +1476,8 @@ ecma_bytecode_deref (ecma_compiled_code_t *bytecode_p) /**< byte code pointer */
|
||||
|
||||
/* 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);
|
||||
JERRY_CONTEXT (ecma_gc_new_objects) += collection_p->item_count * 2;
|
||||
ecma_collection_free_template_literal (collection_p);
|
||||
}
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
|
||||
|
||||
@@ -439,6 +439,9 @@ void ecma_collection_destroy (ecma_collection_t *collection_p);
|
||||
void ecma_collection_free (ecma_collection_t *collection_p);
|
||||
void ecma_collection_free_if_not_object (ecma_collection_t *collection_p);
|
||||
void ecma_collection_free_objects (ecma_collection_t *collection_p);
|
||||
#if ENABLED (JERRY_ESNEXT)
|
||||
void ecma_collection_free_template_literal (ecma_collection_t *collection_p);
|
||||
#endif /* ENABLED (JERRY_ESNEXT) */
|
||||
bool ecma_collection_check_duplicated_entries (ecma_collection_t *collection_p);
|
||||
bool ecma_collection_has_string_value (ecma_collection_t *collection_p, ecma_string_t *string_p);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user