Add 32 bit compressed pointer support.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -25,22 +25,9 @@ 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);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_extended_object_t) <= sizeof (uint64_t) * 2,
|
||||
size_of_ecma_extended_object_t_must_be_less_than_or_equal_to_16_bytes);
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_collection_header_t) == sizeof (uint64_t),
|
||||
size_of_ecma_collection_header_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_collection_chunk_t) == sizeof (uint64_t),
|
||||
size_of_ecma_collection_chunk_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_string_t) == sizeof (uint64_t),
|
||||
size_of_ecma_string_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_getter_setter_pointers_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_getter_setter_pointers_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
|
||||
/** \addtogroup ecma ECMA
|
||||
* @{
|
||||
@@ -67,20 +54,21 @@ JERRY_STATIC_ASSERT (sizeof (ecma_getter_setter_pointers_t) <= sizeof (uint64_t)
|
||||
#define ALLOC(ecma_type) ecma_ ## ecma_type ## _t * \
|
||||
ecma_alloc_ ## ecma_type (void) \
|
||||
{ \
|
||||
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) jmem_pools_alloc (); \
|
||||
ecma_ ## ecma_type ## _t *ecma_type ## _p; \
|
||||
ecma_type ## _p = (ecma_ ## ecma_type ## _t *) jmem_pools_alloc (sizeof (ecma_ ## ecma_type ## _t)); \
|
||||
\
|
||||
JERRY_ASSERT (p ## ecma_type != NULL); \
|
||||
JERRY_ASSERT (ecma_type ## _p != NULL); \
|
||||
\
|
||||
return p ## ecma_type; \
|
||||
return ecma_type ## _p; \
|
||||
}
|
||||
|
||||
/**
|
||||
* Deallocation routine template
|
||||
*/
|
||||
#define DEALLOC(ecma_type) void \
|
||||
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *p ## ecma_type) \
|
||||
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *ecma_type ## _p) \
|
||||
{ \
|
||||
jmem_pools_free ((uint8_t *) p ## ecma_type); \
|
||||
jmem_pools_free ((uint8_t *) ecma_type ## _p, sizeof (ecma_ ## ecma_type ## _t)); \
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -361,9 +361,16 @@ typedef struct
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
jmem_cpointer_t next_property_cp; /**< next cpointer */
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
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) */
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
uint16_t padding; /**< an unused value */
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
jmem_cpointer_t next_property_cp; /**< next cpointer */
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
} ecma_property_header_t;
|
||||
|
||||
/**
|
||||
@@ -381,7 +388,11 @@ typedef struct
|
||||
typedef union
|
||||
{
|
||||
ecma_value_t value; /**< value of a property */
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
jmem_cpointer_t getter_setter_pair_cp; /**< cpointer to getter setter pair */
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ecma_getter_setter_pointers_t getter_setter_pair; /**< getter setter pair */
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
} ecma_property_value_t;
|
||||
|
||||
/**
|
||||
|
||||
@@ -43,9 +43,8 @@ JERRY_STATIC_ASSERT ((ECMA_VALUE_FULL_MASK + 1) == (1 << ECMA_VALUE_SHIFT),
|
||||
JERRY_STATIC_ASSERT (ECMA_VALUE_SHIFT <= JMEM_ALIGNMENT_LOG,
|
||||
ecma_value_shift_must_be_less_than_or_equal_than_mem_alignment_log);
|
||||
|
||||
JERRY_STATIC_ASSERT ((sizeof (ecma_value_t) * JERRY_BITSINBYTE)
|
||||
>= (sizeof (jmem_cpointer_t) * JERRY_BITSINBYTE + ECMA_VALUE_SHIFT),
|
||||
ecma_value_must_be_large_enough_to_store_compressed_pointers);
|
||||
JERRY_STATIC_ASSERT (sizeof (jmem_cpointer_t) <= sizeof (ecma_value_t),
|
||||
size_of_jmem_cpointer_t_must_be_less_or_equal_to_the_size_of_ecma_value_t);
|
||||
|
||||
#ifdef ECMA_VALUE_CAN_STORE_UINTPTR_VALUE_DIRECTLY
|
||||
|
||||
|
||||
@@ -613,8 +613,16 @@ ecma_create_named_accessor_property (ecma_object_t *object_p, /**< object */
|
||||
ecma_ref_ecma_string (name_p);
|
||||
|
||||
ecma_property_value_t value;
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = jmem_pools_alloc (sizeof (ecma_getter_setter_pointers_t));
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->getter_p, get_p);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->setter_p, set_p);
|
||||
ECMA_SET_POINTER (value.getter_setter_pair_cp, getter_setter_pair_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (value.getter_setter_pair.getter_p, get_p);
|
||||
ECMA_SET_POINTER (value.getter_setter_pair.setter_p, set_p);
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
return ecma_create_property (object_p, name_p, type_and_flags, value);
|
||||
} /* ecma_create_named_accessor_property */
|
||||
@@ -763,20 +771,6 @@ ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property
|
||||
return property_p;
|
||||
} /* ecma_get_named_data_property */
|
||||
|
||||
/**
|
||||
* Free the named data property and values it references.
|
||||
*/
|
||||
static void
|
||||
ecma_free_named_data_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 && 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_free_named_data_property */
|
||||
|
||||
/**
|
||||
* Free the internal property and values it references.
|
||||
*/
|
||||
@@ -873,7 +867,8 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
{
|
||||
case ECMA_PROPERTY_TYPE_NAMEDDATA:
|
||||
{
|
||||
ecma_free_named_data_property (object_p, property_p);
|
||||
ecma_free_value_if_not_object (ecma_get_named_data_property_value (property_p));
|
||||
|
||||
if (ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_invalidate (object_p, name_p, property_p);
|
||||
@@ -882,6 +877,13 @@ ecma_free_property (ecma_object_t *object_p, /**< object the property belongs to
|
||||
}
|
||||
case ECMA_PROPERTY_TYPE_NAMEDACCESSOR:
|
||||
{
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (property_p)->getter_setter_pair_cp);
|
||||
jmem_pools_free (getter_setter_pair_p, sizeof (ecma_getter_setter_pointers_t));
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
|
||||
if (ecma_is_property_lcached (property_p))
|
||||
{
|
||||
ecma_lcache_invalidate (object_p, name_p, property_p);
|
||||
@@ -1083,7 +1085,14 @@ ecma_get_named_accessor_property_getter (const ecma_property_t *prop_p) /**< nam
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair_cp);
|
||||
return ECMA_GET_POINTER (ecma_object_t, getter_setter_pair_p->getter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
return ECMA_GET_POINTER (ecma_object_t, ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.getter_p);
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
} /* ecma_get_named_accessor_property_getter */
|
||||
|
||||
/**
|
||||
@@ -1096,7 +1105,14 @@ ecma_get_named_accessor_property_setter (const ecma_property_t *prop_p) /**< nam
|
||||
{
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair_cp);
|
||||
return ECMA_GET_POINTER (ecma_object_t, getter_setter_pair_p->setter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
return ECMA_GET_POINTER (ecma_object_t, ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.setter_p);
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
} /* ecma_get_named_accessor_property_setter */
|
||||
|
||||
/**
|
||||
@@ -1110,7 +1126,14 @@ ecma_set_named_accessor_property_getter (ecma_object_t *object_p, /**< the prope
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
ecma_assert_object_contains_the_property (object_p, prop_p);
|
||||
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->getter_p, getter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.getter_p, getter_p);
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
} /* ecma_set_named_accessor_property_getter */
|
||||
|
||||
/**
|
||||
@@ -1124,7 +1147,14 @@ ecma_set_named_accessor_property_setter (ecma_object_t *object_p, /**< the prope
|
||||
JERRY_ASSERT (ECMA_PROPERTY_GET_TYPE (prop_p) == ECMA_PROPERTY_TYPE_NAMEDACCESSOR);
|
||||
ecma_assert_object_contains_the_property (object_p, prop_p);
|
||||
|
||||
#ifdef JERRY_CPOINTER_32_BIT
|
||||
ecma_getter_setter_pointers_t *getter_setter_pair_p;
|
||||
getter_setter_pair_p = ECMA_GET_POINTER (ecma_getter_setter_pointers_t,
|
||||
ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair_cp);
|
||||
ECMA_SET_POINTER (getter_setter_pair_p->setter_p, setter_p);
|
||||
#else /* !JERRY_CPOINTER_32_BIT */
|
||||
ECMA_SET_POINTER (ECMA_PROPERTY_VALUE_PTR (prop_p)->getter_setter_pair.setter_p, setter_p);
|
||||
#endif /* JERRY_CPOINTER_32_BIT */
|
||||
} /* ecma_set_named_accessor_property_setter */
|
||||
|
||||
/**
|
||||
|
||||
@@ -25,9 +25,6 @@
|
||||
* @{
|
||||
*/
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (ecma_lit_storage_item_t) <= sizeof (uint64_t),
|
||||
size_of_ecma_lit_storage_item_t_must_be_less_than_or_equal_to_8_bytes);
|
||||
|
||||
/**
|
||||
* Free string list
|
||||
*/
|
||||
@@ -50,7 +47,7 @@ ecma_free_string_list (ecma_lit_storage_item_t *string_list_p) /**< string list
|
||||
|
||||
ecma_lit_storage_item_t *prev_item = string_list_p;
|
||||
string_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, string_list_p->next_cp);
|
||||
jmem_pools_free (prev_item);
|
||||
jmem_pools_free (prev_item, sizeof (ecma_lit_storage_item_t));
|
||||
}
|
||||
} /* ecma_free_string_list */
|
||||
|
||||
@@ -115,7 +112,8 @@ ecma_find_or_create_literal_string (const lit_utf8_byte_t *chars_p, /**< string
|
||||
return result;
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc ();
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
@@ -182,7 +180,7 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
number_list_p = JMEM_CP_GET_POINTER (ecma_lit_storage_item_t, number_list_p->next_cp);
|
||||
}
|
||||
|
||||
ecma_string_t *string_p = (ecma_string_t *) jmem_pools_alloc ();
|
||||
ecma_string_t *string_p = (ecma_string_t *) jmem_pools_alloc (sizeof (ecma_string_t));
|
||||
string_p->refs_and_container = ECMA_STRING_REF_ONE | ECMA_STRING_LITERAL_NUMBER;
|
||||
string_p->u.lit_number = num;
|
||||
|
||||
@@ -195,7 +193,8 @@ ecma_find_or_create_literal_number (ecma_number_t number_arg) /**< number to be
|
||||
return result;
|
||||
}
|
||||
|
||||
ecma_lit_storage_item_t *new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc ();
|
||||
ecma_lit_storage_item_t *new_item_p;
|
||||
new_item_p = (ecma_lit_storage_item_t *) jmem_pools_alloc (sizeof (ecma_lit_storage_item_t));
|
||||
|
||||
new_item_p->values[0] = result;
|
||||
for (int i = 1; i < ECMA_LIT_STORAGE_VALUE_COUNT; i++)
|
||||
|
||||
Reference in New Issue
Block a user