Refactor object property chain to use property pairs. The patch
itself seems a step back, but the primary aim is opening future optimization opportunities. The list of changes follows: - Property is changed to be an abstract type, which has type, flags, and a value. It does not have a name anymore and property pointers cannot be compressed. - Full (32 bit) ecma values can be property values. This allows using non-compressed pointers for ecma values in the future. - The property chain is not restricted to the same item anymore, it can contain hash maps, arrays in the future. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -21,8 +21,12 @@
|
||||
#include "jrt.h"
|
||||
#include "mem-poolman.h"
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_property_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_value_t) == sizeof (ecma_value_t),
|
||||
size_of_ecma_property_value_t_must_be_equal_to_size_of_ecma_value_t);
|
||||
JERRY_STATIC_ASSERT (((sizeof (ecma_property_value_t) - 1) & sizeof (ecma_property_value_t)) == 0,
|
||||
size_of_ecma_property_value_t_must_be_power_of_2);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_property_pair_t) == sizeof (uint64_t) * 2,
|
||||
size_of_ecma_property_pair_t_must_be_equal_to_16_bytes);
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_object_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_object_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
@@ -85,7 +89,6 @@ JERRY_STATIC_ASSERT (sizeof (ecma_getter_setter_pointers_t) <= sizeof (uint64_t)
|
||||
DEALLOC (ecma_type)
|
||||
|
||||
DECLARE_ROUTINES_FOR (object)
|
||||
DECLARE_ROUTINES_FOR (property)
|
||||
DECLARE_ROUTINES_FOR (number)
|
||||
DECLARE_ROUTINES_FOR (collection_header)
|
||||
DECLARE_ROUTINES_FOR (collection_chunk)
|
||||
@@ -93,6 +96,26 @@ DECLARE_ROUTINES_FOR (string)
|
||||
DECLARE_ROUTINES_FOR (getter_setter_pointers)
|
||||
DECLARE_ROUTINES_FOR (external_pointer)
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property pair
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
ecma_property_pair_t *
|
||||
ecma_alloc_property_pair (void)
|
||||
{
|
||||
return mem_heap_alloc_block (sizeof (ecma_property_pair_t));
|
||||
} /* ecma_alloc_property_pair */
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-property
|
||||
*/
|
||||
extern void
|
||||
ecma_dealloc_property_pair (ecma_property_pair_t *property_pair_p) /**< property pair to be freed */
|
||||
{
|
||||
mem_heap_free_block (property_pair_p, sizeof (ecma_property_pair_t));
|
||||
} /* ecma_dealloc_property_pair */
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
@@ -37,18 +37,6 @@ extern ecma_object_t *ecma_alloc_object (void);
|
||||
*/
|
||||
extern void ecma_dealloc_object (ecma_object_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_property_t *ecma_alloc_property (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-property
|
||||
*/
|
||||
extern void ecma_dealloc_property (ecma_property_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-number
|
||||
*
|
||||
@@ -121,6 +109,18 @@ extern ecma_external_pointer_t *ecma_alloc_external_pointer (void);
|
||||
*/
|
||||
extern void ecma_dealloc_external_pointer (ecma_external_pointer_t *);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-property pair
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_property_pair_t *ecma_alloc_property_pair (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from an ecma-property pair
|
||||
*/
|
||||
extern void ecma_dealloc_property_pair (ecma_property_pair_t *);
|
||||
|
||||
/**
|
||||
* @}
|
||||
* @}
|
||||
|
||||
+178
-124
@@ -199,6 +199,139 @@ ecma_gc_init (void)
|
||||
ecma_gc_new_objects_since_last_gc = 0;
|
||||
} /* ecma_gc_init */
|
||||
|
||||
/**
|
||||
* Mark referenced object from property
|
||||
*/
|
||||
static void
|
||||
ecma_gc_mark_property (ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
switch (ECMA_PROPERTY_GET_TYPE (property_p))
|
||||
{
|
||||
case ECMA_PROPERTY_TYPE_NAMEDDATA:
|
||||
{
|
||||
ecma_value_t value = ecma_get_named_data_property_value (property_p);
|
||||
|
||||
if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_object_t *value_obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
ecma_gc_set_object_visited (value_obj_p, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_NAMEDACCESSOR:
|
||||
{
|
||||
ecma_object_t *getter_obj_p = ecma_get_named_accessor_property_getter (property_p);
|
||||
ecma_object_t *setter_obj_p = ecma_get_named_accessor_property_setter (property_p);
|
||||
|
||||
if (getter_obj_p != NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (getter_obj_p, true);
|
||||
}
|
||||
|
||||
if (setter_obj_p != NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (setter_obj_p, true);
|
||||
}
|
||||
break;
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_INTERNAL:
|
||||
{
|
||||
uint32_t property_value = ECMA_PROPERTY_VALUE_PTR (property_p)->value;
|
||||
|
||||
switch (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (property_p))
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* a collection of ecma values */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* a collection of ecma values */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED ("Indexed array storage is not implemented yet.");
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_PROTOTYPE: /* the property's value is located in ecma_object_t
|
||||
* (see above in the routine) */
|
||||
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t
|
||||
* (see above in the routine) */
|
||||
case ECMA_INTERNAL_PROPERTY__COUNT: /* not a real internal property type,
|
||||
* but number of the real internal property types */
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE: /* compressed pointer to a ecma_string_t */
|
||||
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE: /* compressed pointer to a ecma_number_t */
|
||||
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_BOOLEAN_VALUE: /* a simple boolean value */
|
||||
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
||||
case ECMA_INTERNAL_PROPERTY_CODE_BYTECODE: /* compressed pointer to a bytecode array */
|
||||
case ECMA_INTERNAL_PROPERTY_NATIVE_CODE: /* an external pointer */
|
||||
case ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE: /* an external pointer */
|
||||
case ECMA_INTERNAL_PROPERTY_FREE_CALLBACK: /* an object's native free callback */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ROUTINE_DESC: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_EXTENSION_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31: /* an integer (bit-mask) */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63: /* an integer (bit-mask) */
|
||||
case ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_BOUND_THIS: /* an ecma value */
|
||||
{
|
||||
if (ecma_is_value_object (property_value))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (property_value);
|
||||
|
||||
ecma_gc_set_object_visited (obj_p, true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_BOUND_ARGS: /* a collection of ecma values */
|
||||
{
|
||||
ecma_collection_header_t *bound_arg_list_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
|
||||
property_value);
|
||||
|
||||
ecma_collection_iterator_t bound_args_iterator;
|
||||
ecma_collection_iterator_init (&bound_args_iterator, bound_arg_list_p);
|
||||
|
||||
for (ecma_length_t i = 0; i < bound_arg_list_p->unit_number; i++)
|
||||
{
|
||||
bool is_moved = ecma_collection_iterator_next (&bound_args_iterator);
|
||||
JERRY_ASSERT (is_moved);
|
||||
|
||||
if (ecma_is_value_object (*bound_args_iterator.current_value_p))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (*bound_args_iterator.current_value_p);
|
||||
|
||||
ecma_gc_set_object_visited (obj_p, true);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_TARGET_FUNCTION: /* an object */
|
||||
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
||||
case ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP: /* an object */
|
||||
{
|
||||
ecma_object_t *obj_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, property_value);
|
||||
|
||||
ecma_gc_set_object_visited (obj_p, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
} /* ecma_gc_mark_property */
|
||||
|
||||
/**
|
||||
* Mark objects as visited starting from specified object as root
|
||||
*/
|
||||
@@ -237,130 +370,24 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
|
||||
|
||||
if (traverse_properties)
|
||||
{
|
||||
for (ecma_property_t *property_p = ecma_get_property_list (object_p), *next_property_p;
|
||||
property_p != NULL;
|
||||
property_p = next_property_p)
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
next_property_p = ECMA_GET_POINTER (ecma_property_t,
|
||||
property_p->next_property_p);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
if (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA)
|
||||
if (prop_iter_p->types[0].type_and_flags != ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
ecma_value_t value = ecma_get_named_data_property_value (property_p);
|
||||
|
||||
if (ecma_is_value_object (value))
|
||||
{
|
||||
ecma_object_t *value_obj_p = ecma_get_object_from_value (value);
|
||||
|
||||
ecma_gc_set_object_visited (value_obj_p, true);
|
||||
}
|
||||
ecma_gc_mark_property (prop_iter_p->types + 0);
|
||||
}
|
||||
else if (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR)
|
||||
|
||||
if (prop_iter_p->types[1].type_and_flags != ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
ecma_object_t *getter_obj_p = ecma_get_named_accessor_property_getter (property_p);
|
||||
ecma_object_t *setter_obj_p = ecma_get_named_accessor_property_setter (property_p);
|
||||
|
||||
if (getter_obj_p != NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (getter_obj_p, true);
|
||||
}
|
||||
|
||||
if (setter_obj_p != NULL)
|
||||
{
|
||||
ecma_gc_set_object_visited (setter_obj_p, true);
|
||||
}
|
||||
ecma_gc_mark_property (prop_iter_p->types + 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (property_p->flags & ECMA_PROPERTY_FLAG_INTERNAL);
|
||||
|
||||
ecma_internal_property_id_t property_id = (ecma_internal_property_id_t) property_p->h.internal_property_type;
|
||||
uint32_t property_value = property_p->v.internal_property.value;
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* a collection of ecma values */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* a collection of ecma values */
|
||||
{
|
||||
JERRY_UNIMPLEMENTED ("Indexed array storage is not implemented yet.");
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_PROTOTYPE: /* the property's value is located in ecma_object_t
|
||||
(see above in the routine) */
|
||||
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t
|
||||
(see above in the routine) */
|
||||
case ECMA_INTERNAL_PROPERTY__COUNT: /* not a real internal property type,
|
||||
* but number of the real internal property types */
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_STRING_VALUE: /* compressed pointer to a ecma_string_t */
|
||||
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_NUMBER_VALUE: /* compressed pointer to a ecma_number_t */
|
||||
case ECMA_INTERNAL_PROPERTY_PRIMITIVE_BOOLEAN_VALUE: /* a simple boolean value */
|
||||
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
||||
case ECMA_INTERNAL_PROPERTY_CODE_BYTECODE: /* compressed pointer to a bytecode array */
|
||||
case ECMA_INTERNAL_PROPERTY_NATIVE_CODE: /* an external pointer */
|
||||
case ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE: /* an external pointer */
|
||||
case ECMA_INTERNAL_PROPERTY_FREE_CALLBACK: /* an object's native free callback */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_BUILT_IN_ROUTINE_DESC: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_EXTENSION_ID: /* an integer */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_0_31: /* an integer (bit-mask) */
|
||||
case ECMA_INTERNAL_PROPERTY_NON_INSTANTIATED_BUILT_IN_MASK_32_63: /* an integer (bit-mask) */
|
||||
case ECMA_INTERNAL_PROPERTY_REGEXP_BYTECODE:
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_BOUND_THIS: /* an ecma value */
|
||||
{
|
||||
if (ecma_is_value_object (property_value))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (property_value);
|
||||
|
||||
ecma_gc_set_object_visited (obj_p, true);
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_BOUND_ARGS: /* a collection of ecma values */
|
||||
{
|
||||
ecma_collection_header_t *bound_arg_list_p = ECMA_GET_NON_NULL_POINTER (ecma_collection_header_t,
|
||||
property_value);
|
||||
|
||||
ecma_collection_iterator_t bound_args_iterator;
|
||||
ecma_collection_iterator_init (&bound_args_iterator, bound_arg_list_p);
|
||||
|
||||
for (ecma_length_t i = 0; i < bound_arg_list_p->unit_number; i++)
|
||||
{
|
||||
bool is_moved = ecma_collection_iterator_next (&bound_args_iterator);
|
||||
JERRY_ASSERT (is_moved);
|
||||
|
||||
if (ecma_is_value_object (*bound_args_iterator.current_value_p))
|
||||
{
|
||||
ecma_object_t *obj_p = ecma_get_object_from_value (*bound_args_iterator.current_value_p);
|
||||
|
||||
ecma_gc_set_object_visited (obj_p, true);
|
||||
}
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_BOUND_FUNCTION_TARGET_FUNCTION: /* an object */
|
||||
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
|
||||
case ECMA_INTERNAL_PROPERTY_PARAMETERS_MAP: /* an object */
|
||||
{
|
||||
ecma_object_t *obj_p = ECMA_GET_NON_NULL_POINTER (ecma_object_t, property_value);
|
||||
|
||||
ecma_gc_set_object_visited (obj_p, true);
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
}
|
||||
} /* ecma_gc_mark */
|
||||
@@ -399,14 +426,41 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||
if (!ecma_is_lexical_environment (object_p)
|
||||
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
|
||||
{
|
||||
for (ecma_property_t *property = ecma_get_property_list (object_p), *next_property_p;
|
||||
property != NULL;
|
||||
property = next_property_p)
|
||||
{
|
||||
next_property_p = ECMA_GET_POINTER (ecma_property_t,
|
||||
property->next_property_p);
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
|
||||
|
||||
ecma_free_property (object_p, property);
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
/* Both cannot be deleted. */
|
||||
JERRY_ASSERT (prop_iter_p->types[0].type_and_flags != ECMA_PROPERTY_TYPE_DELETED
|
||||
|| prop_iter_p->types[1].type_and_flags != ECMA_PROPERTY_TYPE_DELETED);
|
||||
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
if (prop_iter_p->types[i].type_and_flags != ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
ecma_string_t *name_p = ECMA_GET_POINTER (ecma_string_t, prop_pair_p->names_cp[i]);
|
||||
|
||||
ecma_free_property (object_p, name_p, prop_iter_p->types + i);
|
||||
|
||||
if (name_p != NULL)
|
||||
{
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/* Both must be deleted. */
|
||||
JERRY_ASSERT (prop_iter_p->types[0].type_and_flags == ECMA_PROPERTY_TYPE_DELETED
|
||||
&& prop_iter_p->types[1].type_and_flags == ECMA_PROPERTY_TYPE_DELETED);
|
||||
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
|
||||
ecma_dealloc_property_pair (prop_pair_p);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -203,19 +203,101 @@ typedef enum
|
||||
} ecma_property_configurable_value_t;
|
||||
|
||||
/**
|
||||
* Property's flag list.
|
||||
* Property list:
|
||||
* The property list of an object is a chain list of various items.
|
||||
* The type of each item is stored in the first byte of the item.
|
||||
*
|
||||
* The most common item is the property pair, which contains two
|
||||
* ecmascript properties. It is also important, that after the
|
||||
* first property pair, only property pair items are allowed.
|
||||
*
|
||||
* Example for other items is property name hash map, or array of items.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Property type list.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_PROPERTY_FLAG_NAMEDDATA = 1u << 0, /**< property is named data */
|
||||
ECMA_PROPERTY_FLAG_NAMEDACCESSOR = 1u << 1, /**< property is named accessor */
|
||||
ECMA_PROPERTY_FLAG_INTERNAL = 1u << 2, /**< property is internal property */
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE = 1u << 3, /**< property is configurable */
|
||||
ECMA_PROPERTY_FLAG_ENUMERABLE = 1u << 4, /**< property is enumerable */
|
||||
ECMA_PROPERTY_FLAG_WRITABLE = 1u << 5, /**< property is writable */
|
||||
ECMA_PROPERTY_FLAG_LCACHED = 1u << 6, /**< property is lcached */
|
||||
ECMA_PROPERTY_TYPE_DELETED, /**< deleted property */
|
||||
ECMA_PROPERTY_TYPE_INTERNAL, /**< internal property */
|
||||
ECMA_PROPERTY_TYPE_NAMEDDATA, /**< property is named data */
|
||||
ECMA_PROPERTY_TYPE_NAMEDACCESSOR, /**< property is named accessor */
|
||||
|
||||
ECMA_PROPERTY_TYPE_PROPERTY_PAIR__MAX = ECMA_PROPERTY_TYPE_NAMEDACCESSOR, /**< highest value for
|
||||
* property pair types. */
|
||||
ECMA_PROPERTY_TYPE__MAX = ECMA_PROPERTY_TYPE_NAMEDACCESSOR, /**< highest value for property types. */
|
||||
} ecma_property_types_t;
|
||||
|
||||
/**
|
||||
* Property type mask.
|
||||
*/
|
||||
#define ECMA_PROPERTY_TYPE_MASK 0x7
|
||||
|
||||
/**
|
||||
* Property flags base shift.
|
||||
*/
|
||||
#define ECMA_PROPERTY_FLAG_SHIFT 3
|
||||
|
||||
/**
|
||||
* Property flag list (for ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
* and ECMA_PROPERTY_TYPE_NAMEDACCESSOR).
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
ECMA_PROPERTY_FLAG_CONFIGURABLE = 1u << (ECMA_PROPERTY_FLAG_SHIFT + 0), /**< property is configurable */
|
||||
ECMA_PROPERTY_FLAG_ENUMERABLE = 1u << (ECMA_PROPERTY_FLAG_SHIFT + 1), /**< property is enumerable */
|
||||
ECMA_PROPERTY_FLAG_WRITABLE = 1u << (ECMA_PROPERTY_FLAG_SHIFT + 2), /**< property is writable */
|
||||
ECMA_PROPERTY_FLAG_LCACHED = 1u << (ECMA_PROPERTY_FLAG_SHIFT + 3), /**< property is lcached */
|
||||
} ecma_property_flags_t;
|
||||
|
||||
/**
|
||||
* Abstract property representation.
|
||||
*
|
||||
* A property is a type_and_flags byte and an ecma_value_t value pair.
|
||||
* This pair is represented by a single pointer in JerryScript. Although
|
||||
* a packed struct would only consume sizeof(ecma_value_t)+1 memory
|
||||
* bytes, accessing such structure is inefficient from the CPU viewpoint
|
||||
* because the value is not naturally aligned. To improve performance,
|
||||
* multiple type bytes and values are packed together. The maximum
|
||||
* number of packed items is sizeof(ecma_value_t). The memory layout is
|
||||
* the following when the maximum number of items is present:
|
||||
*
|
||||
* [type 1, type 2, type 3, type 4][value 1][value 2][value 3][value 4]
|
||||
*
|
||||
* This way no memory is wasted and values are naturally aligned.
|
||||
*
|
||||
* For property pairs, only two values are used:
|
||||
*
|
||||
* [type 1, type 2, unused 1, unused 2][value 1][value 2]
|
||||
*
|
||||
* The unused two bytes are used to store a compressed pointer for the
|
||||
* next property pair.
|
||||
*
|
||||
* The advantage of this layout is that the value reference can be computed
|
||||
* from the property address. However, property pointers cannot be compressed
|
||||
* anymore.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uint8_t type_and_flags; /**< ecma_property_types_t (3 bit) and ecma_property_flags_t */
|
||||
} ecma_property_t;
|
||||
|
||||
/**
|
||||
* Number of items in a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_PAIR_ITEM_COUNT 2
|
||||
|
||||
/**
|
||||
* Property header for all items in a property list.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_property_t types[ECMA_PROPERTY_PAIR_ITEM_COUNT]; /**< two property type slot. The first represent
|
||||
* the type of this property (e.g. property pair) */
|
||||
mem_cpointer_t next_property_cp; /**< next cpointer */
|
||||
} ecma_property_header_t;
|
||||
|
||||
/**
|
||||
* Pair of pointers - to property's getter and setter
|
||||
*/
|
||||
@@ -226,56 +308,59 @@ typedef struct
|
||||
} ecma_getter_setter_pointers_t;
|
||||
|
||||
/**
|
||||
* Description of ecma-property
|
||||
* Property data.
|
||||
*/
|
||||
typedef struct ecma_property_t
|
||||
typedef union
|
||||
{
|
||||
/** Compressed pointer to next property */
|
||||
mem_cpointer_t next_property_p;
|
||||
ecma_value_t value; /**< value of a property */
|
||||
ecma_getter_setter_pointers_t getter_setter_pair; /**< getter setter pair */
|
||||
} ecma_property_value_t;
|
||||
|
||||
/** Property's flags (ecma_property_flags_t) */
|
||||
uint8_t flags;
|
||||
/**
|
||||
* Property pair.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
ecma_property_header_t header; /**< header of the property */
|
||||
ecma_property_value_t values[ECMA_PROPERTY_PAIR_ITEM_COUNT]; /**< property value slots */
|
||||
mem_cpointer_t names_cp[ECMA_PROPERTY_PAIR_ITEM_COUNT]; /**< property name slots */
|
||||
} ecma_property_pair_t;
|
||||
|
||||
/** Property's header part (depending on Type) */
|
||||
union
|
||||
{
|
||||
/** Named data property value upper bits */
|
||||
uint8_t named_data_property_value_high;
|
||||
/** Internal property type */
|
||||
uint8_t internal_property_type;
|
||||
} h;
|
||||
/**
|
||||
* Get property type.
|
||||
*/
|
||||
#define ECMA_PROPERTY_GET_TYPE(property_p) \
|
||||
((ecma_property_types_t) ((property_p)->type_and_flags & ECMA_PROPERTY_TYPE_MASK))
|
||||
|
||||
/** Property's value part (depending on Type) */
|
||||
union
|
||||
{
|
||||
/** Description of named data property (second part) */
|
||||
struct
|
||||
{
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
mem_cpointer_t name_p;
|
||||
/**
|
||||
* Returns true if the property pointer is a property pair.
|
||||
*/
|
||||
#define ECMA_PROPERTY_IS_PROPERTY_PAIR(property_header_p) \
|
||||
(ECMA_PROPERTY_GET_TYPE ((property_header_p)->types + 0) <= ECMA_PROPERTY_TYPE_PROPERTY_PAIR__MAX)
|
||||
|
||||
/** Lower 16 bits of value */
|
||||
uint16_t value_low;
|
||||
} named_data_property;
|
||||
/**
|
||||
* Returns the internal property type
|
||||
*/
|
||||
#define ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE(property_p) \
|
||||
((ecma_internal_property_id_t) ((property_p)->type_and_flags >> ECMA_PROPERTY_FLAG_SHIFT))
|
||||
|
||||
/** Description of named accessor property (second part) */
|
||||
struct
|
||||
{
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
mem_cpointer_t name_p;
|
||||
/**
|
||||
* Computing the data offset of a property.
|
||||
*/
|
||||
#define ECMA_PROPERTY_VALUE_OFFSET(property_p) \
|
||||
((((uintptr_t) (property_p)) & (sizeof (ecma_property_value_t) - 1)) + 1)
|
||||
|
||||
/** Compressed pointer to pair of pointers - to property's getter and setter */
|
||||
mem_cpointer_t getter_setter_pair_cp;
|
||||
} named_accessor_property;
|
||||
/**
|
||||
* Computing the base address of property data list.
|
||||
*/
|
||||
#define ECMA_PROPERTY_VALUE_BASE_PTR(property_p) \
|
||||
((ecma_property_value_t *) (((uintptr_t) (property_p)) & ~(sizeof (ecma_property_value_t) - 1)))
|
||||
|
||||
/** Description of internal property (second part) */
|
||||
struct
|
||||
{
|
||||
/** Value (may be a compressed pointer) */
|
||||
uint32_t value;
|
||||
} internal_property;
|
||||
} v;
|
||||
} ecma_property_t;
|
||||
/**
|
||||
* Pointer to property data.
|
||||
*/
|
||||
#define ECMA_PROPERTY_VALUE_PTR(property_p) \
|
||||
(ECMA_PROPERTY_VALUE_BASE_PTR (property_p) + ECMA_PROPERTY_VALUE_OFFSET (property_p))
|
||||
|
||||
/**
|
||||
* Internal object types
|
||||
@@ -395,12 +480,21 @@ typedef struct
|
||||
/** Is [[Writable]] defined? */
|
||||
unsigned int is_writable_defined : 1;
|
||||
|
||||
/** [[Writable]] */
|
||||
unsigned int is_writable : 1;
|
||||
|
||||
/** Is [[Enumerable]] defined? */
|
||||
unsigned int is_enumerable_defined : 1;
|
||||
|
||||
/** [[Enumerable]] */
|
||||
unsigned int is_enumerable : 1;
|
||||
|
||||
/** Is [[Configurable]] defined? */
|
||||
unsigned int is_configurable_defined : 1;
|
||||
|
||||
/** [[Configurable]] */
|
||||
unsigned int is_configurable : 1;
|
||||
|
||||
/** [[Value]] */
|
||||
ecma_value_t value;
|
||||
|
||||
@@ -409,15 +503,6 @@ typedef struct
|
||||
|
||||
/** [[Set]] */
|
||||
ecma_object_t *set_p;
|
||||
|
||||
/** [[Writable]] */
|
||||
bool is_writable;
|
||||
|
||||
/** [[Enumerable]] */
|
||||
bool is_enumerable;
|
||||
|
||||
/** [[Configurable]] */
|
||||
bool is_configurable;
|
||||
} ecma_property_descriptor_t;
|
||||
|
||||
#if CONFIG_ECMA_NUMBER_TYPE == CONFIG_ECMA_NUMBER_FLOAT32
|
||||
|
||||
@@ -61,12 +61,12 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
is_new = false;
|
||||
}
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uint32_t) <= sizeof (prop_p->v.internal_property.value),
|
||||
JERRY_STATIC_ASSERT (sizeof (uint32_t) <= sizeof (ECMA_PROPERTY_VALUE_PTR (prop_p)->value),
|
||||
size_of_internal_property_value_must_be_greater_than_or_equal_to_4_bytes);
|
||||
|
||||
if (sizeof (ecma_external_pointer_t) == sizeof (uint32_t))
|
||||
{
|
||||
prop_p->v.internal_property.value = (uint32_t) ptr_value;
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = (uint32_t) ptr_value;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -76,12 +76,12 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
{
|
||||
handler_p = ecma_alloc_external_pointer ();
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (prop_p->v.internal_property.value, handler_p);
|
||||
ECMA_SET_NON_NULL_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->value, handler_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
prop_p->v.internal_property.value);
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
}
|
||||
|
||||
*handler_p = ptr_value;
|
||||
@@ -123,12 +123,12 @@ ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get proper
|
||||
|
||||
if (sizeof (ecma_external_pointer_t) == sizeof (uint32_t))
|
||||
{
|
||||
*out_pointer_p = (ecma_external_pointer_t) prop_p->v.internal_property.value;
|
||||
*out_pointer_p = ECMA_PROPERTY_VALUE_PTR (prop_p)->value;
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_external_pointer_t *handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
prop_p->v.internal_property.value);
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
*out_pointer_p = *handler_p;
|
||||
}
|
||||
|
||||
@@ -147,9 +147,9 @@ ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get proper
|
||||
void
|
||||
ecma_free_external_pointer_in_property (ecma_property_t *prop_p) /**< internal property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->h.internal_property_type == ECMA_INTERNAL_PROPERTY_NATIVE_CODE
|
||||
|| prop_p->h.internal_property_type == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| prop_p->h.internal_property_type == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_NATIVE_CODE
|
||||
|| ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_p) == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
if (sizeof (ecma_external_pointer_t) == sizeof (uint32_t))
|
||||
{
|
||||
@@ -158,7 +158,7 @@ ecma_free_external_pointer_in_property (ecma_property_t *prop_p) /**< internal p
|
||||
else
|
||||
{
|
||||
ecma_external_pointer_t *handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
prop_p->v.internal_property.value);
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
|
||||
ecma_dealloc_external_pointer (handler_p);
|
||||
}
|
||||
|
||||
+308
-222
@@ -30,6 +30,12 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
/**
|
||||
* The ecma property types must be lower than the container mask.
|
||||
*/
|
||||
JERRY_STATIC_ASSERT (ECMA_PROPERTY_TYPE_MASK >= ECMA_PROPERTY_TYPE__MAX,
|
||||
ecma_property_types_must_be_lower_than_the_container_mask);
|
||||
|
||||
/**
|
||||
* The ecma object types must be lower than the container mask.
|
||||
*/
|
||||
@@ -320,14 +326,14 @@ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical en
|
||||
* See also:
|
||||
* ecma_op_object_get_property_names
|
||||
*/
|
||||
inline ecma_property_t *__attr_pure___
|
||||
inline ecma_property_header_t *__attr_pure___
|
||||
ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical environment */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)
|
||||
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
return ECMA_GET_POINTER (ecma_property_t,
|
||||
return ECMA_GET_POINTER (ecma_property_header_t,
|
||||
object_p->property_list_or_bound_object_cp);
|
||||
} /* ecma_get_property_list */
|
||||
|
||||
@@ -339,14 +345,13 @@ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical en
|
||||
*/
|
||||
static inline void
|
||||
ecma_set_property_list (ecma_object_t *object_p, /**< object or lexical environment */
|
||||
ecma_property_t *property_list_p) /**< properties' list */
|
||||
ecma_property_header_t *property_list_p) /**< properties' list */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)
|
||||
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
ECMA_SET_POINTER (object_p->property_list_or_bound_object_cp,
|
||||
property_list_p);
|
||||
ECMA_SET_POINTER (object_p->property_list_or_bound_object_cp, property_list_p);
|
||||
} /* ecma_set_property_list */
|
||||
|
||||
/**
|
||||
@@ -378,6 +383,61 @@ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-boun
|
||||
object_p->property_list_or_bound_object_cp);
|
||||
} /* ecma_get_lex_env_binding_object */
|
||||
|
||||
/**
|
||||
* Create a property in an object and link it into
|
||||
* the object's properties' linked-list (at start of the list).
|
||||
*
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
static ecma_property_t *
|
||||
ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
uint8_t type_and_flags) /**< type and flags, see ecma_property_info_t */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_PAIR_ITEM_COUNT == 2);
|
||||
|
||||
if (object_p->property_list_or_bound_object_cp != ECMA_NULL_POINTER)
|
||||
{
|
||||
/* If the first entry is free (deleted), we simply use its value. */
|
||||
ecma_property_header_t *first_property_p = ECMA_GET_NON_NULL_POINTER (ecma_property_header_t,
|
||||
object_p->property_list_or_bound_object_cp);
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (first_property_p));
|
||||
|
||||
if (first_property_p->types[0].type_and_flags == ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
first_property_p->types[0].type_and_flags = type_and_flags;
|
||||
|
||||
ecma_property_pair_t *first_property_pair_p = (ecma_property_pair_t *) first_property_p;
|
||||
ECMA_SET_POINTER (first_property_pair_p->names_cp[0], name_p);
|
||||
|
||||
ecma_property_t *property_p = first_property_p->types + 0;
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_VALUE_PTR (property_p) == first_property_pair_p->values + 0);
|
||||
|
||||
return property_p;
|
||||
}
|
||||
}
|
||||
|
||||
/* Otherwise we create a new property pair and use its second value. */
|
||||
ecma_property_pair_t *first_property_pair_p = ecma_alloc_property_pair ();
|
||||
|
||||
/* Just copy the previous value (no need to decompress, compress). */
|
||||
first_property_pair_p->header.next_property_cp = object_p->property_list_or_bound_object_cp;
|
||||
first_property_pair_p->header.types[0].type_and_flags = ECMA_PROPERTY_TYPE_DELETED;
|
||||
first_property_pair_p->header.types[1].type_and_flags = type_and_flags;
|
||||
first_property_pair_p->names_cp[0] = ECMA_NULL_POINTER;
|
||||
ECMA_SET_POINTER (first_property_pair_p->names_cp[1], name_p);
|
||||
|
||||
ecma_set_property_list (object_p, &first_property_pair_p->header);
|
||||
|
||||
ecma_property_t *property_p = first_property_pair_p->header.types + 1;
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_VALUE_PTR (property_p) == first_property_pair_p->values + 1);
|
||||
|
||||
return property_p;
|
||||
} /* ecma_create_property */
|
||||
|
||||
/**
|
||||
* Create internal property in an object and link it into
|
||||
* the object's properties' linked-list (at start of the list).
|
||||
@@ -390,20 +450,14 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||
{
|
||||
JERRY_ASSERT (ecma_find_internal_property (object_p, property_id) == NULL);
|
||||
|
||||
ecma_property_t *new_property_p = ecma_alloc_property ();
|
||||
uint8_t id_byte = (uint8_t) (property_id << ECMA_PROPERTY_FLAG_SHIFT);
|
||||
uint8_t type_and_flags = (uint8_t) (ECMA_PROPERTY_TYPE_INTERNAL | id_byte);
|
||||
|
||||
new_property_p->flags = ECMA_PROPERTY_FLAG_INTERNAL;
|
||||
ecma_property_t *property_p = ecma_create_property (object_p, NULL, type_and_flags);
|
||||
|
||||
ecma_property_t *list_head_p = ecma_get_property_list (object_p);
|
||||
ECMA_SET_POINTER (new_property_p->next_property_p, list_head_p);
|
||||
ecma_set_property_list (object_p, new_property_p);
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p)->value = ECMA_NULL_POINTER;
|
||||
|
||||
JERRY_ASSERT (property_id < ECMA_INTERNAL_PROPERTY__COUNT);
|
||||
|
||||
new_property_p->h.internal_property_type = (uint8_t) property_id;
|
||||
new_property_p->v.internal_property.value = ECMA_NULL_POINTER;
|
||||
|
||||
return new_property_p;
|
||||
return property_p;
|
||||
} /* ecma_create_internal_property */
|
||||
|
||||
/**
|
||||
@@ -421,15 +475,26 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
JERRY_ASSERT (property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
|
||||
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE);
|
||||
|
||||
for (ecma_property_t *property_p = ecma_get_property_list (object_p);
|
||||
property_p != NULL;
|
||||
property_p = ECMA_GET_POINTER (ecma_property_t, property_p->next_property_p))
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
if ((property_p->flags & ECMA_PROPERTY_FLAG_INTERNAL)
|
||||
&& property_p->h.internal_property_type == property_id)
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
if (ECMA_PROPERTY_GET_TYPE (&prop_iter_p->types[0]) == ECMA_PROPERTY_TYPE_INTERNAL
|
||||
&& ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_iter_p->types + 0) == property_id)
|
||||
{
|
||||
return property_p;
|
||||
return prop_iter_p->types + 0;
|
||||
}
|
||||
|
||||
if (ECMA_PROPERTY_GET_TYPE (&prop_iter_p->types[1]) == ECMA_PROPERTY_TYPE_INTERNAL
|
||||
&& ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (prop_iter_p->types + 1) == property_id)
|
||||
{
|
||||
return prop_iter_p->types + 1;
|
||||
}
|
||||
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
|
||||
return NULL;
|
||||
@@ -461,48 +526,38 @@ ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
ecma_property_t *
|
||||
ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_create_named_data_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
bool is_writable, /**< 'Writable' attribute */
|
||||
bool is_enumerable, /**< 'Enumerable' attribute */
|
||||
bool is_configurable) /**< 'Configurable' attribute */
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_find_named_property (obj_p, name_p) == NULL);
|
||||
|
||||
ecma_property_t *prop_p = ecma_alloc_property ();
|
||||
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||
|
||||
prop_p->flags = ECMA_PROPERTY_FLAG_NAMEDDATA;
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (prop_p->v.named_data_property.name_p, name_p);
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
|
||||
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDDATA;
|
||||
if (is_configurable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
}
|
||||
if (is_enumerable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
}
|
||||
if (is_writable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_WRITABLE);
|
||||
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_WRITABLE);
|
||||
}
|
||||
|
||||
ecma_set_named_data_property_value (prop_p, ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
|
||||
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||
|
||||
/*
|
||||
* See also:
|
||||
* ecma_op_object_get_property_names
|
||||
*/
|
||||
ecma_property_t *list_head_p = ecma_get_property_list (obj_p);
|
||||
ECMA_SET_POINTER (prop_p->next_property_p, list_head_p);
|
||||
ecma_set_property_list (obj_p, prop_p);
|
||||
ecma_property_t *property_p = ecma_create_property (object_p, name_p, type_and_flags);
|
||||
|
||||
ecma_lcache_invalidate (obj_p, name_p, NULL);
|
||||
ecma_set_named_data_property_value (property_p, ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
|
||||
|
||||
return prop_p;
|
||||
ecma_lcache_invalidate (object_p, name_p, NULL);
|
||||
|
||||
return property_p;
|
||||
} /* ecma_create_named_data_property */
|
||||
|
||||
/**
|
||||
@@ -511,52 +566,39 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
ecma_property_t *
|
||||
ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *name_p, /**< property name */
|
||||
ecma_object_t *get_p, /**< getter */
|
||||
ecma_object_t *set_p, /**< setter */
|
||||
bool is_enumerable, /**< 'enumerable' attribute */
|
||||
bool is_configurable) /**< 'configurable' attribute */
|
||||
{
|
||||
JERRY_ASSERT (obj_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_find_named_property (obj_p, name_p) == NULL);
|
||||
|
||||
ecma_property_t *prop_p = ecma_alloc_property ();
|
||||
ecma_getter_setter_pointers_t *getter_setter_pointers_p = ecma_alloc_getter_setter_pointers ();
|
||||
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||
|
||||
prop_p->flags = ECMA_PROPERTY_FLAG_NAMEDACCESSOR;
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (prop_p->v.named_accessor_property.name_p, name_p);
|
||||
JERRY_ASSERT (object_p != NULL && name_p != NULL);
|
||||
JERRY_ASSERT (ecma_find_named_property (object_p, name_p) == NULL);
|
||||
|
||||
uint8_t type_and_flags = ECMA_PROPERTY_TYPE_NAMEDACCESSOR;
|
||||
if (is_configurable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
}
|
||||
if (is_enumerable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
type_and_flags = (uint8_t) (type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
}
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (prop_p->v.named_accessor_property.getter_setter_pair_cp, getter_setter_pointers_p);
|
||||
name_p = ecma_copy_or_ref_ecma_string (name_p);
|
||||
|
||||
/*
|
||||
* See also:
|
||||
* ecma_op_object_get_property_names
|
||||
*/
|
||||
ecma_property_t *list_head_p = ecma_get_property_list (obj_p);
|
||||
ECMA_SET_POINTER (prop_p->next_property_p, list_head_p);
|
||||
ecma_set_property_list (obj_p, prop_p);
|
||||
ecma_property_t *property_p = ecma_create_property (object_p, name_p, type_and_flags);
|
||||
|
||||
/*
|
||||
* Should be performed after linking the property into object's property list, because the setters assert that.
|
||||
*/
|
||||
ecma_set_named_accessor_property_getter (obj_p, prop_p, get_p);
|
||||
ecma_set_named_accessor_property_setter (obj_p, prop_p, set_p);
|
||||
ecma_set_named_accessor_property_getter (object_p, property_p, get_p);
|
||||
ecma_set_named_accessor_property_setter (object_p, property_p, set_p);
|
||||
|
||||
ecma_lcache_invalidate (obj_p, name_p, NULL);
|
||||
ecma_lcache_invalidate (object_p, name_p, NULL);
|
||||
|
||||
return prop_p;
|
||||
return property_p;
|
||||
} /* ecma_create_named_accessor_property */
|
||||
|
||||
/**
|
||||
@@ -579,33 +621,44 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
|
||||
return property_p;
|
||||
}
|
||||
|
||||
for (property_p = ecma_get_property_list (obj_p);
|
||||
property_p != NULL;
|
||||
property_p = ECMA_GET_POINTER (ecma_property_t, property_p->next_property_p))
|
||||
property_p = NULL;
|
||||
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (obj_p);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
ecma_string_t *property_name_p;
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
if (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA)
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_PAIR_ITEM_COUNT == 2);
|
||||
|
||||
if (prop_pair_p->names_cp[0] != ECMA_NULL_POINTER)
|
||||
{
|
||||
property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_p->v.named_data_property.name_p);
|
||||
}
|
||||
else if (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR)
|
||||
{
|
||||
property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_p->v.named_accessor_property.name_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
continue;
|
||||
ecma_string_t *property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
prop_pair_p->names_cp[0]);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, property_name_p))
|
||||
{
|
||||
property_p = prop_iter_p->types + 0;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_ASSERT (property_name_p != NULL);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, property_name_p))
|
||||
if (prop_pair_p->names_cp[1] != ECMA_NULL_POINTER)
|
||||
{
|
||||
break;
|
||||
ecma_string_t *property_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
prop_pair_p->names_cp[1]);
|
||||
|
||||
if (ecma_compare_ecma_strings (name_p, property_name_p))
|
||||
{
|
||||
property_p = prop_iter_p->types + 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
|
||||
ecma_lcache_insert (obj_p, name_p, property_p);
|
||||
@@ -654,7 +707,7 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
|
||||
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
|
||||
|
||||
JERRY_ASSERT (property_p != NULL && (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA));
|
||||
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_GET_TYPE (property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
|
||||
return property_p;
|
||||
} /* ecma_get_named_data_property */
|
||||
@@ -667,53 +720,23 @@ ecma_free_named_data_property (ecma_object_t *object_p, /**< object the property
|
||||
ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (property_p != NULL && (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA));
|
||||
|
||||
ecma_lcache_invalidate (object_p, NULL, property_p);
|
||||
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_p->v.named_data_property.name_p));
|
||||
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_GET_TYPE (property_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
|
||||
ecma_value_t v = ecma_get_named_data_property_value (property_p);
|
||||
ecma_free_value_if_not_object (v);
|
||||
|
||||
ecma_dealloc_property (property_p);
|
||||
} /* ecma_free_named_data_property */
|
||||
|
||||
/**
|
||||
* Free the named accessor property and values it references.
|
||||
*/
|
||||
static void
|
||||
ecma_free_named_accessor_property (ecma_object_t *object_p, /**< object the property belongs to */
|
||||
ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (property_p != NULL && (property_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
|
||||
ecma_lcache_invalidate (object_p, NULL, property_p);
|
||||
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
property_p->v.named_accessor_property.name_p));
|
||||
|
||||
ecma_getter_setter_pointers_t *getter_setter_pointers_p;
|
||||
getter_setter_pointers_p = ECMA_GET_NON_NULL_POINTER (ecma_getter_setter_pointers_t,
|
||||
property_p->v.named_accessor_property.getter_setter_pair_cp);
|
||||
ecma_dealloc_getter_setter_pointers (getter_setter_pointers_p);
|
||||
ecma_dealloc_property (property_p);
|
||||
} /* ecma_free_named_accessor_property */
|
||||
|
||||
/**
|
||||
* Free the internal property and values it references.
|
||||
*/
|
||||
static void
|
||||
ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
||||
{
|
||||
JERRY_ASSERT (property_p != NULL && (property_p->flags & ECMA_PROPERTY_FLAG_INTERNAL));
|
||||
JERRY_ASSERT (property_p != NULL && ECMA_PROPERTY_GET_TYPE (property_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
|
||||
ecma_internal_property_id_t property_id = (ecma_internal_property_id_t) property_p->h.internal_property_type;
|
||||
uint32_t property_value = property_p->v.internal_property.value;
|
||||
uint32_t property_value = ECMA_PROPERTY_VALUE_PTR (property_p)->value;
|
||||
|
||||
switch (property_id)
|
||||
switch (ECMA_PROPERTY_GET_INTERNAL_PROPERTY_TYPE (property_p))
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* a collection */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* a collection */
|
||||
@@ -809,31 +832,45 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
ecma_dealloc_property (property_p);
|
||||
} /* ecma_free_internal_property */
|
||||
|
||||
/**
|
||||
* Free the property and values it references.
|
||||
* Free property values and change their type to deleted.
|
||||
*/
|
||||
void
|
||||
ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
ecma_string_t *name_p, /**< name of the property or NULL */
|
||||
ecma_property_t *property_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL && prop_p != NULL);
|
||||
JERRY_ASSERT (object_p != NULL && property_p != NULL);
|
||||
|
||||
if (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA)
|
||||
switch (ECMA_PROPERTY_GET_TYPE (property_p))
|
||||
{
|
||||
ecma_free_named_data_property (object_p, prop_p);
|
||||
}
|
||||
else if (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR)
|
||||
{
|
||||
ecma_free_named_accessor_property (object_p, prop_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ecma_free_internal_property (prop_p);
|
||||
case ECMA_PROPERTY_TYPE_NAMEDDATA:
|
||||
{
|
||||
ecma_free_named_data_property (object_p, property_p);
|
||||
ecma_lcache_invalidate (object_p, name_p, property_p);
|
||||
break;
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_NAMEDACCESSOR:
|
||||
{
|
||||
ecma_lcache_invalidate (object_p, name_p, property_p);
|
||||
break;
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_INTERNAL:
|
||||
{
|
||||
JERRY_ASSERT (name_p == NULL);
|
||||
ecma_free_internal_property (property_p);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
{
|
||||
JERRY_UNREACHABLE ();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
property_p->type_and_flags = ECMA_PROPERTY_TYPE_DELETED;
|
||||
} /* ecma_free_property */
|
||||
|
||||
/**
|
||||
@@ -842,34 +879,62 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
* Warning: specified property must be owned by specified object.
|
||||
*/
|
||||
void
|
||||
ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
||||
ecma_delete_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
for (ecma_property_t *cur_prop_p = ecma_get_property_list (obj_p), *prev_prop_p = NULL, *next_prop_p;
|
||||
cur_prop_p != NULL;
|
||||
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
|
||||
ecma_property_header_t *cur_prop_p = ecma_get_property_list (object_p);
|
||||
ecma_property_header_t *prev_prop_p = NULL;
|
||||
|
||||
while (true)
|
||||
{
|
||||
next_prop_p = ECMA_GET_POINTER (ecma_property_t,
|
||||
cur_prop_p->next_property_p);
|
||||
JERRY_ASSERT (cur_prop_p != NULL);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (cur_prop_p));
|
||||
|
||||
if (cur_prop_p == prop_p)
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) cur_prop_p;
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
ecma_free_property (obj_p, prop_p);
|
||||
|
||||
if (prev_prop_p == NULL)
|
||||
if ((cur_prop_p->types + i) == prop_p)
|
||||
{
|
||||
ecma_set_property_list (obj_p, next_prop_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
ECMA_SET_POINTER (prev_prop_p->next_property_p, next_prop_p);
|
||||
}
|
||||
ecma_string_t *name_p = ECMA_GET_POINTER (ecma_string_t, prop_pair_p->names_cp[i]);
|
||||
|
||||
return;
|
||||
ecma_free_property (object_p, name_p, cur_prop_p->types + i);
|
||||
|
||||
prop_pair_p->names_cp[i] = ECMA_NULL_POINTER;
|
||||
|
||||
if (name_p != NULL)
|
||||
{
|
||||
ecma_deref_ecma_string (name_p);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (ECMA_PROPERTY_PAIR_ITEM_COUNT == 2);
|
||||
|
||||
if (cur_prop_p->types[1 - i].type_and_flags != ECMA_PROPERTY_TYPE_DELETED)
|
||||
{
|
||||
/* The other property is still valid. */
|
||||
return;
|
||||
}
|
||||
|
||||
JERRY_ASSERT (cur_prop_p->types[i].type_and_flags == ECMA_PROPERTY_TYPE_DELETED);
|
||||
|
||||
if (prev_prop_p == NULL)
|
||||
{
|
||||
object_p->property_list_or_bound_object_cp = cur_prop_p->next_property_cp;
|
||||
}
|
||||
else
|
||||
{
|
||||
prev_prop_p->next_property_cp = cur_prop_p->next_property_cp;
|
||||
}
|
||||
|
||||
ecma_dealloc_property_pair ((ecma_property_pair_t *) cur_prop_p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
JERRY_UNREACHABLE ();
|
||||
prev_prop_p = cur_prop_p;
|
||||
cur_prop_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
cur_prop_p->next_property_cp);
|
||||
}
|
||||
} /* ecma_delete_property */
|
||||
|
||||
/**
|
||||
@@ -880,27 +945,34 @@ ecma_assert_object_contains_the_property (const ecma_object_t *object_p, /**< ec
|
||||
const ecma_property_t *prop_p) /**< ecma-property */
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
ecma_property_t *prop_iter_p;
|
||||
for (prop_iter_p = ecma_get_property_list (object_p);
|
||||
prop_iter_p != NULL;
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_t, prop_iter_p->next_property_p))
|
||||
ecma_property_header_t *prop_iter_p = ecma_get_property_list (object_p);
|
||||
|
||||
while (prop_iter_p != NULL)
|
||||
{
|
||||
if (prop_iter_p == prop_p)
|
||||
JERRY_ASSERT (ECMA_PROPERTY_IS_PROPERTY_PAIR (prop_iter_p));
|
||||
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
|
||||
for (int i = 0; i < ECMA_PROPERTY_PAIR_ITEM_COUNT; i++)
|
||||
{
|
||||
break;
|
||||
if ((prop_pair_p->header.types + i) == prop_p)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
prop_iter_p->next_property_cp);
|
||||
}
|
||||
|
||||
JERRY_ASSERT (prop_iter_p != NULL);
|
||||
JERRY_UNREACHABLE ();
|
||||
|
||||
#else /* JERRY_NDEBUG */
|
||||
(void) object_p;
|
||||
(void) prop_p;
|
||||
#endif /* JERRY_NDEBUG */
|
||||
} /* ecma_assert_object_contains_the_property */
|
||||
|
||||
JERRY_STATIC_ASSERT (ECMA_VALUE_SIZE <= 24,
|
||||
maximum_ECMA_VALUE_SIZE_must_be_less_than_or_equal_to_24);
|
||||
|
||||
/**
|
||||
* Get value field of named data property
|
||||
*
|
||||
@@ -909,10 +981,9 @@ JERRY_STATIC_ASSERT (ECMA_VALUE_SIZE <= 24,
|
||||
inline ecma_value_t __attr_always_inline___
|
||||
ecma_get_named_data_property_value (const ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
|
||||
ecma_value_t upper_bits = prop_p->h.named_data_property_value_high;
|
||||
return (upper_bits << 16) | (prop_p->v.named_data_property.value_low);
|
||||
return ECMA_PROPERTY_VALUE_PTR (prop_p)->value;
|
||||
} /* ecma_get_named_data_property_value */
|
||||
|
||||
/**
|
||||
@@ -922,12 +993,36 @@ inline void __attr_always_inline___
|
||||
ecma_set_named_data_property_value (ecma_property_t *prop_p, /**< property */
|
||||
ecma_value_t value) /**< value to set */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
|
||||
prop_p->h.named_data_property_value_high = (uint8_t) (value >> 16);
|
||||
prop_p->v.named_data_property.value_low = (uint16_t) value;
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = value;
|
||||
} /* ecma_set_named_data_property_value */
|
||||
|
||||
/**
|
||||
* Get value field of an internal property
|
||||
*
|
||||
* @return ecma value
|
||||
*/
|
||||
inline ecma_value_t __attr_always_inline___
|
||||
ecma_get_internal_property_value (const ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
|
||||
return ECMA_PROPERTY_VALUE_PTR (prop_p)->value;
|
||||
} /* ecma_get_internal_property_value */
|
||||
|
||||
/**
|
||||
* Set value field of named data property
|
||||
*/
|
||||
inline void __attr_always_inline___
|
||||
ecma_set_internal_property_value (ecma_property_t *prop_p, /**< property */
|
||||
ecma_value_t value) /**< value to set */
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_INTERNAL);
|
||||
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = value;
|
||||
} /* ecma_set_internal_property_value */
|
||||
|
||||
/**
|
||||
* Assign value to named data property
|
||||
*
|
||||
@@ -939,7 +1034,7 @@ ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
|
||||
ecma_property_t *prop_p, /**< property */
|
||||
ecma_value_t value) /**< value to assign */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
ecma_assert_object_contains_the_property (obj_p, prop_p);
|
||||
|
||||
if (ecma_is_value_number (value)
|
||||
@@ -967,13 +1062,9 @@ ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
|
||||
ecma_object_t *
|
||||
ecma_get_named_accessor_property_getter (const ecma_property_t *prop_p) /**< named accessor property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
ecma_getter_setter_pointers_t *getter_setter_pointers_p;
|
||||
getter_setter_pointers_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_p->v.named_accessor_property.getter_setter_pair_cp);
|
||||
|
||||
return ECMA_GET_POINTER (ecma_object_t, getter_setter_pointers_p->getter_p);
|
||||
return ECMA_GET_POINTER (ecma_object_t, ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.getter_p);
|
||||
} /* ecma_get_named_accessor_property_getter */
|
||||
|
||||
/**
|
||||
@@ -984,13 +1075,9 @@ ecma_get_named_accessor_property_getter (const ecma_property_t *prop_p) /**< nam
|
||||
ecma_object_t *
|
||||
ecma_get_named_accessor_property_setter (const ecma_property_t *prop_p) /**< named accessor property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
ecma_getter_setter_pointers_t *getter_setter_pointers_p;
|
||||
getter_setter_pointers_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_p->v.named_accessor_property.getter_setter_pair_cp);
|
||||
|
||||
return ECMA_GET_POINTER (ecma_object_t, getter_setter_pointers_p->setter_p);
|
||||
return ECMA_GET_POINTER (ecma_object_t, ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.setter_p);
|
||||
} /* ecma_get_named_accessor_property_setter */
|
||||
|
||||
/**
|
||||
@@ -1001,14 +1088,10 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
|
||||
ecma_property_t *prop_p, /**< named accessor property */
|
||||
ecma_object_t *getter_p) /**< getter object */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
ecma_assert_object_contains_the_property (object_p, prop_p);
|
||||
|
||||
ecma_getter_setter_pointers_t *getter_setter_pointers_p;
|
||||
getter_setter_pointers_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_p->v.named_accessor_property.getter_setter_pair_cp);
|
||||
|
||||
ECMA_SET_POINTER (getter_setter_pointers_p->getter_p, getter_p);
|
||||
ECMA_SET_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.getter_p, getter_p);
|
||||
} /* ecma_set_named_accessor_property_getter */
|
||||
|
||||
/**
|
||||
@@ -1019,14 +1102,10 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
ecma_property_t *prop_p, /**< named accessor property */
|
||||
ecma_object_t *setter_p) /**< setter object */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
ecma_assert_object_contains_the_property (object_p, prop_p);
|
||||
|
||||
ecma_getter_setter_pointers_t *getter_setter_pointers_p;
|
||||
getter_setter_pointers_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
prop_p->v.named_accessor_property.getter_setter_pair_cp);
|
||||
|
||||
ECMA_SET_POINTER (getter_setter_pointers_p->setter_p, setter_p);
|
||||
ECMA_SET_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.setter_p, setter_p);
|
||||
} /* ecma_set_named_accessor_property_setter */
|
||||
|
||||
/**
|
||||
@@ -1038,9 +1117,9 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
inline bool __attr_always_inline___
|
||||
ecma_is_property_writable (ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
|
||||
return (prop_p->flags & ECMA_PROPERTY_FLAG_WRITABLE) != 0;
|
||||
return (prop_p->type_and_flags & ECMA_PROPERTY_FLAG_WRITABLE) != 0;
|
||||
} /* ecma_is_property_writable */
|
||||
|
||||
/**
|
||||
@@ -1051,15 +1130,15 @@ ecma_set_property_writable_attr (ecma_property_t *prop_p, /**< property */
|
||||
bool is_writable) /**< should the property
|
||||
* be writable? */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA);
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA);
|
||||
|
||||
if (is_writable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_WRITABLE);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags | ECMA_PROPERTY_FLAG_WRITABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags & ~ECMA_PROPERTY_FLAG_WRITABLE);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags & ~ECMA_PROPERTY_FLAG_WRITABLE);
|
||||
}
|
||||
} /* ecma_set_property_writable_attr */
|
||||
|
||||
@@ -1072,9 +1151,10 @@ ecma_set_property_writable_attr (ecma_property_t *prop_p, /**< property */
|
||||
inline bool __attr_always_inline___
|
||||
ecma_is_property_enumerable (ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
return (prop_p->flags & ECMA_PROPERTY_FLAG_ENUMERABLE) != 0;
|
||||
return (prop_p->type_and_flags & ECMA_PROPERTY_FLAG_ENUMERABLE) != 0;
|
||||
} /* ecma_is_property_enumerable */
|
||||
|
||||
/**
|
||||
@@ -1085,15 +1165,16 @@ ecma_set_property_enumerable_attr (ecma_property_t *prop_p, /**< property */
|
||||
bool is_enumerable) /**< should the property
|
||||
* be enumerable? */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
if (is_enumerable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags | ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags & ~ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags & ~ECMA_PROPERTY_FLAG_ENUMERABLE);
|
||||
}
|
||||
} /* ecma_set_property_enumerable_attr */
|
||||
|
||||
@@ -1106,9 +1187,10 @@ ecma_set_property_enumerable_attr (ecma_property_t *prop_p, /**< property */
|
||||
inline bool __attr_always_inline___
|
||||
ecma_is_property_configurable (ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
return (prop_p->flags & ECMA_PROPERTY_FLAG_CONFIGURABLE) != 0;
|
||||
return (prop_p->type_and_flags & ECMA_PROPERTY_FLAG_CONFIGURABLE) != 0;
|
||||
} /* ecma_is_property_configurable */
|
||||
|
||||
/**
|
||||
@@ -1119,15 +1201,16 @@ ecma_set_property_configurable_attr (ecma_property_t *prop_p, /**< property */
|
||||
bool is_configurable) /**< should the property
|
||||
* be configurable? */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
if (is_configurable)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags | ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags & ~ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags & ~ECMA_PROPERTY_FLAG_CONFIGURABLE);
|
||||
}
|
||||
} /* ecma_set_property_configurable_attr */
|
||||
|
||||
@@ -1139,9 +1222,10 @@ ecma_set_property_configurable_attr (ecma_property_t *prop_p, /**< property */
|
||||
inline bool __attr_always_inline___
|
||||
ecma_is_property_lcached (ecma_property_t *prop_p) /**< property */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
return (prop_p->flags & ECMA_PROPERTY_FLAG_LCACHED) != 0;
|
||||
return (prop_p->type_and_flags & ECMA_PROPERTY_FLAG_LCACHED) != 0;
|
||||
} /* ecma_is_property_lcached */
|
||||
|
||||
/**
|
||||
@@ -1151,15 +1235,16 @@ void
|
||||
ecma_set_property_lcached (ecma_property_t *prop_p, /**< property */
|
||||
bool is_lcached) /**< contained (true) or not (false) */
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
if (is_lcached)
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags | ECMA_PROPERTY_FLAG_LCACHED);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags | ECMA_PROPERTY_FLAG_LCACHED);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_p->flags = (uint8_t) (prop_p->flags & ~ECMA_PROPERTY_FLAG_LCACHED);
|
||||
prop_p->type_and_flags = (uint8_t) (prop_p->type_and_flags & ~ECMA_PROPERTY_FLAG_LCACHED);
|
||||
}
|
||||
} /* ecma_set_property_lcached */
|
||||
|
||||
@@ -1235,15 +1320,16 @@ ecma_get_property_descriptor_from_property (ecma_property_t *prop_p) /**< proper
|
||||
prop_desc.is_configurable = ecma_is_property_configurable (prop_p);
|
||||
prop_desc.is_configurable_defined = true;
|
||||
|
||||
if (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA)
|
||||
if (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA)
|
||||
{
|
||||
prop_desc.value = ecma_copy_value (ecma_get_named_data_property_value (prop_p));
|
||||
prop_desc.is_value_defined = true;
|
||||
prop_desc.is_writable = ecma_is_property_writable (prop_p);
|
||||
prop_desc.is_writable_defined = true;
|
||||
}
|
||||
else if (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDACCESSOR)
|
||||
else
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
prop_desc.get_p = ecma_get_named_accessor_property_getter (prop_p);
|
||||
prop_desc.is_get_defined = true;
|
||||
if (prop_desc.get_p != NULL)
|
||||
|
||||
@@ -213,7 +213,7 @@ extern bool ecma_get_object_is_builtin (const ecma_object_t *) __attr_pure___;
|
||||
extern void ecma_set_object_is_builtin (ecma_object_t *);
|
||||
extern ecma_lexical_environment_type_t ecma_get_lex_env_type (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_object_t *ecma_get_lex_env_outer_reference (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_property_t *ecma_get_property_list (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_property_header_t *ecma_get_property_list (const ecma_object_t *) __attr_pure___;
|
||||
extern ecma_object_t *ecma_get_lex_env_binding_object (const ecma_object_t *) __attr_pure___;
|
||||
extern bool ecma_get_lex_env_provide_this (const ecma_object_t *) __attr_pure___;
|
||||
|
||||
@@ -232,7 +232,7 @@ ecma_get_named_property (ecma_object_t *, ecma_string_t *);
|
||||
extern ecma_property_t *
|
||||
ecma_get_named_data_property (ecma_object_t *, ecma_string_t *);
|
||||
|
||||
extern void ecma_free_property (ecma_object_t *, ecma_property_t *);
|
||||
extern void ecma_free_property (ecma_object_t *, ecma_string_t *, ecma_property_t *);
|
||||
|
||||
extern void ecma_delete_property (ecma_object_t *, ecma_property_t *);
|
||||
|
||||
@@ -240,6 +240,9 @@ extern ecma_value_t ecma_get_named_data_property_value (const ecma_property_t *)
|
||||
extern void ecma_set_named_data_property_value (ecma_property_t *, ecma_value_t);
|
||||
extern void ecma_named_data_property_assign_value (ecma_object_t *, ecma_property_t *, ecma_value_t);
|
||||
|
||||
extern ecma_value_t ecma_get_internal_property_value (const ecma_property_t *);
|
||||
extern void ecma_set_internal_property_value (ecma_property_t *, ecma_value_t);
|
||||
|
||||
extern ecma_object_t *ecma_get_named_accessor_property_getter (const ecma_property_t *);
|
||||
extern ecma_object_t *ecma_get_named_accessor_property_setter (const ecma_property_t *);
|
||||
extern void ecma_set_named_accessor_property_getter (ecma_object_t *, ecma_property_t *, ecma_object_t *);
|
||||
@@ -258,6 +261,8 @@ extern ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
|
||||
extern void ecma_free_property_descriptor (ecma_property_descriptor_t *);
|
||||
extern ecma_property_descriptor_t ecma_get_property_descriptor_from_property (ecma_property_t *);
|
||||
|
||||
extern ecma_property_t *ecma_get_next_property_pair (ecma_property_pair_t *);
|
||||
|
||||
extern void ecma_bytecode_ref (ecma_compiled_code_t *);
|
||||
extern void ecma_bytecode_deref (ecma_compiled_code_t *);
|
||||
|
||||
|
||||
@@ -33,22 +33,16 @@
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** Pointer to a property of the object */
|
||||
ecma_property_t *prop_p;
|
||||
|
||||
/** Compressed pointer to object (ECMA_NULL_POINTER marks record empty) */
|
||||
mem_cpointer_t object_cp;
|
||||
|
||||
/** Compressed pointer to property's name */
|
||||
mem_cpointer_t prop_name_cp;
|
||||
|
||||
/** Compressed pointer to a property of the object */
|
||||
mem_cpointer_t prop_cp;
|
||||
|
||||
/** Padding structure to 8 bytes size */
|
||||
uint16_t padding;
|
||||
} ecma_lcache_hash_entry_t;
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_lcache_hash_entry_t) == sizeof (uint64_t),
|
||||
size_of_ecma_lcache_hash_entry_t_must_be_equal_to_8_bytes);
|
||||
|
||||
/**
|
||||
* LCache hash value length, in bits
|
||||
*/
|
||||
@@ -98,11 +92,9 @@ ecma_lcache_invalidate_entry (ecma_lcache_hash_entry_t *entry_p) /**< entry to i
|
||||
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
entry_p->prop_name_cp));
|
||||
|
||||
if (entry_p->prop_cp != ECMA_NULL_POINTER)
|
||||
if (entry_p->prop_p != NULL)
|
||||
{
|
||||
ecma_set_property_lcached (ECMA_GET_NON_NULL_POINTER (ecma_property_t,
|
||||
entry_p->prop_cp),
|
||||
false);
|
||||
ecma_set_property_lcached (entry_p->prop_p, false);
|
||||
}
|
||||
} /* ecma_lcache_invalidate_entry */
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
@@ -135,14 +127,13 @@ static void
|
||||
ecma_lcache_invalidate_row_for_object_property_pair (uint32_t row_index, /**< index of the row */
|
||||
unsigned int object_cp, /**< compressed pointer
|
||||
* to an object */
|
||||
unsigned property_cp) /**< compressed pointer
|
||||
* to the object's
|
||||
* property */
|
||||
ecma_property_t *property_p) /**< pointer to the
|
||||
* object's property */
|
||||
{
|
||||
for (uint32_t entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
|
||||
{
|
||||
if (ecma_lcache_hash_table[ row_index ][ entry_index ].object_cp == object_cp
|
||||
&& ecma_lcache_hash_table[ row_index ][ entry_index ].prop_cp == property_cp)
|
||||
&& ecma_lcache_hash_table[ row_index ][ entry_index ].prop_p == property_p)
|
||||
{
|
||||
ecma_lcache_invalidate_entry (&ecma_lcache_hash_table[ row_index ][ entry_index ]);
|
||||
}
|
||||
@@ -172,14 +163,11 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
if (unlikely (ecma_is_property_lcached (prop_p)))
|
||||
{
|
||||
mem_cpointer_t prop_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (prop_cp, prop_p);
|
||||
|
||||
int32_t entry_index;
|
||||
for (entry_index = 0; entry_index < ECMA_LCACHE_HASH_ROW_LENGTH; entry_index++)
|
||||
{
|
||||
if (ecma_lcache_hash_table[hash_key][entry_index].object_cp != ECMA_NULL_POINTER
|
||||
&& ecma_lcache_hash_table[hash_key][entry_index].prop_cp == prop_cp)
|
||||
&& ecma_lcache_hash_table[hash_key][entry_index].prop_p == prop_p)
|
||||
{
|
||||
#ifndef JERRY_NDEBUG
|
||||
ecma_object_t *obj_in_entry_p;
|
||||
@@ -222,7 +210,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
|
||||
ecma_ref_object (object_p);
|
||||
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].object_cp, object_p);
|
||||
ECMA_SET_NON_NULL_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_name_cp, prop_name_p);
|
||||
ECMA_SET_POINTER (ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_cp, prop_p);
|
||||
ecma_lcache_hash_table[ hash_key ][ entry_index ].prop_p = prop_p;
|
||||
#else /* CONFIG_ECMA_LCACHE_DISABLE */
|
||||
(void) prop_p;
|
||||
#endif /* CONFIG_ECMA_LCACHE_DISABLE */
|
||||
@@ -262,7 +250,7 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
|
||||
if (ECMA_STRING_GET_CONTAINER (prop_name_p) == ECMA_STRING_GET_CONTAINER (entry_prop_name_p)
|
||||
&& prop_name_p->u.common_field == entry_prop_name_p->u.common_field)
|
||||
{
|
||||
ecma_property_t *prop_p = ECMA_GET_POINTER (ecma_property_t, ecma_lcache_hash_table[hash_key][i].prop_cp);
|
||||
ecma_property_t *prop_p = ecma_lcache_hash_table[hash_key][i].prop_p;
|
||||
JERRY_ASSERT (prop_p == NULL || ecma_is_property_lcached (prop_p));
|
||||
|
||||
*prop_p_p = prop_p;
|
||||
@@ -295,18 +283,17 @@ ecma_lcache_lookup (ecma_object_t *object_p, /**< object */
|
||||
*/
|
||||
void
|
||||
ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
|
||||
ecma_string_t *prop_name_arg_p, /**< property's name (See also: Note) */
|
||||
ecma_string_t *prop_name_p, /**< property's name (See also: Note) */
|
||||
ecma_property_t *prop_p) /**< property (See also: Note) */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (prop_p != NULL || prop_name_arg_p != NULL);
|
||||
JERRY_ASSERT (prop_name_p != NULL);
|
||||
|
||||
#ifndef CONFIG_ECMA_LCACHE_DISABLE
|
||||
ecma_string_t *prop_name_p = NULL;
|
||||
|
||||
if (prop_p != NULL)
|
||||
{
|
||||
JERRY_ASSERT (prop_p->flags & (ECMA_PROPERTY_FLAG_NAMEDDATA | ECMA_PROPERTY_FLAG_NAMEDACCESSOR));
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDDATA
|
||||
|| ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
bool is_cached = ecma_is_property_lcached (prop_p);
|
||||
|
||||
@@ -316,33 +303,17 @@ ecma_lcache_invalidate (ecma_object_t *object_p, /**< object */
|
||||
}
|
||||
|
||||
ecma_set_property_lcached (prop_p, false);
|
||||
|
||||
if (prop_p->flags & ECMA_PROPERTY_FLAG_NAMEDDATA)
|
||||
{
|
||||
prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
prop_p->v.named_data_property.name_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_name_p = ECMA_GET_NON_NULL_POINTER (ecma_string_t,
|
||||
prop_p->v.named_accessor_property.name_p);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
prop_name_p = prop_name_arg_p;
|
||||
}
|
||||
|
||||
unsigned int object_cp, prop_cp;
|
||||
unsigned int object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
ECMA_SET_POINTER (prop_cp, prop_p);
|
||||
|
||||
lit_string_hash_t hash_key = ecma_string_hash (prop_name_p);
|
||||
|
||||
/* Property's name has was computed.
|
||||
* Given (object, property name) pair should be in the row corresponding to computed hash.
|
||||
*/
|
||||
ecma_lcache_invalidate_row_for_object_property_pair (hash_key, object_cp, prop_cp);
|
||||
ecma_lcache_invalidate_row_for_object_property_pair (hash_key, object_cp, prop_p);
|
||||
#endif /* !CONFIG_ECMA_LCACHE_DISABLE */
|
||||
} /* ecma_lcache_invalidate */
|
||||
|
||||
|
||||
Reference in New Issue
Block a user