Change return value to ecma_value_t for getting internal properties.
Removing a lot of ECMA_PROPERTY_VALUE_PTR macro calls. The only drawback is free callbacks for native objects cannot be deleted anymore. Redefining a free callback is a rare case, so this trade-of is acceptable. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -374,7 +374,8 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
|
||||
bool is_retrieved = ecma_get_external_pointer_value (object_p,
|
||||
ECMA_INTERNAL_PROPERTY_FREE_CALLBACK,
|
||||
&freecb_p);
|
||||
if (is_retrieved)
|
||||
|
||||
if (is_retrieved && ((jerry_object_free_callback_t) freecb_p) != NULL)
|
||||
{
|
||||
is_retrieved = ecma_get_external_pointer_value (object_p,
|
||||
ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE,
|
||||
|
||||
@@ -45,18 +45,12 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
JERRY_ASSERT (id == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| id == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
bool is_new;
|
||||
ecma_property_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
ecma_value_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
bool is_new = (prop_p == NULL);
|
||||
|
||||
if (prop_p == NULL)
|
||||
if (is_new)
|
||||
{
|
||||
prop_p = ecma_create_internal_property (obj_p, id);
|
||||
|
||||
is_new = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
is_new = false;
|
||||
}
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uint32_t) <= sizeof (ECMA_PROPERTY_VALUE_PTR (prop_p)->value),
|
||||
@@ -64,7 +58,7 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value = (ecma_value_t) ptr_value;
|
||||
*prop_p = (ecma_value_t) ptr_value;
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
@@ -74,12 +68,11 @@ ecma_create_external_pointer_property (ecma_object_t *obj_p, /**< object to crea
|
||||
{
|
||||
handler_p = ecma_alloc_external_pointer ();
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->value, handler_p);
|
||||
ECMA_SET_NON_NULL_POINTER (*prop_p, handler_p);
|
||||
}
|
||||
else
|
||||
{
|
||||
handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t, *prop_p);
|
||||
}
|
||||
|
||||
*handler_p = ptr_value;
|
||||
@@ -109,7 +102,7 @@ ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get proper
|
||||
JERRY_ASSERT (id == ECMA_INTERNAL_PROPERTY_NATIVE_HANDLE
|
||||
|| id == ECMA_INTERNAL_PROPERTY_FREE_CALLBACK);
|
||||
|
||||
ecma_property_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
ecma_value_t *prop_p = ecma_find_internal_property (obj_p, id);
|
||||
|
||||
if (prop_p == NULL)
|
||||
{
|
||||
@@ -120,13 +113,11 @@ ecma_get_external_pointer_value (ecma_object_t *obj_p, /**< object to get proper
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
*out_pointer_p = ECMA_PROPERTY_VALUE_PTR (prop_p)->value;
|
||||
*out_pointer_p = *prop_p;
|
||||
|
||||
#else /* !ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
ecma_external_pointer_t *handler_p = ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->value);
|
||||
*out_pointer_p = *handler_p;
|
||||
*out_pointer_p = *ECMA_GET_NON_NULL_POINTER (ecma_external_pointer_t, *prop_p);
|
||||
|
||||
#endif /* ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY */
|
||||
|
||||
|
||||
@@ -486,7 +486,7 @@ ecma_create_property (ecma_object_t *object_p, /**< the object */
|
||||
*
|
||||
* @return pointer to newly created property
|
||||
*/
|
||||
ecma_property_t *
|
||||
ecma_value_t *
|
||||
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
@@ -498,7 +498,8 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||
ecma_property_value_t value;
|
||||
value.value = ECMA_NULL_POINTER;
|
||||
|
||||
return ecma_create_property (object_p, NULL, type_and_flags, value);
|
||||
ecma_property_t *property_p = ecma_create_property (object_p, NULL, type_and_flags, value);
|
||||
return &ECMA_PROPERTY_VALUE_PTR (property_p)->value;
|
||||
} /* ecma_create_internal_property */
|
||||
|
||||
/**
|
||||
@@ -507,7 +508,7 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
|
||||
* @return pointer to the property, if it is found,
|
||||
* NULL - otherwise.
|
||||
*/
|
||||
ecma_property_t *
|
||||
ecma_value_t *
|
||||
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
@@ -529,13 +530,15 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
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 prop_iter_p->types + 0;
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
return &prop_pair_p->values[0].value;
|
||||
}
|
||||
|
||||
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;
|
||||
ecma_property_pair_t *prop_pair_p = (ecma_property_pair_t *) prop_iter_p;
|
||||
return &prop_pair_p->values[1].value;
|
||||
}
|
||||
|
||||
prop_iter_p = ECMA_GET_POINTER (ecma_property_header_t,
|
||||
@@ -553,11 +556,11 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
*
|
||||
* @return pointer to the property
|
||||
*/
|
||||
ecma_property_t *
|
||||
inline ecma_value_t * __attr_always_inline___
|
||||
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
|
||||
ecma_internal_property_id_t property_id) /**< internal property identifier */
|
||||
{
|
||||
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
|
||||
ecma_value_t *property_p = ecma_find_internal_property (object_p, property_id);
|
||||
|
||||
JERRY_ASSERT (property_p != NULL);
|
||||
|
||||
@@ -1051,31 +1054,6 @@ ecma_set_named_data_property_value (ecma_property_t *prop_p, /**< property */
|
||||
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
|
||||
*
|
||||
|
||||
@@ -266,9 +266,9 @@ extern ecma_property_header_t *ecma_get_property_list (const ecma_object_t *) __
|
||||
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___;
|
||||
|
||||
extern ecma_property_t *ecma_create_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_property_t *ecma_find_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_property_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_value_t *ecma_create_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_value_t *ecma_find_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
extern ecma_value_t *ecma_get_internal_property (ecma_object_t *, ecma_internal_property_id_t);
|
||||
|
||||
extern ecma_property_t *
|
||||
ecma_create_named_data_property (ecma_object_t *, ecma_string_t *, uint8_t);
|
||||
@@ -289,9 +289,6 @@ 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 *);
|
||||
|
||||
Reference in New Issue
Block a user