Renaming ecma_array_first_chunk_t -> ecma_collection_header_t; ecma_array_non_first_chunk_t -> ecma_collection_chunk_t.
This commit is contained in:
@@ -25,9 +25,8 @@ JERRY_STATIC_ASSERT(sizeof (ecma_property_t) <= sizeof (uint64_t));
|
||||
FIXME(Pack ecma_object_t)
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_object_t) <= 2 * sizeof (uint64_t));
|
||||
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_array_header_t) <= sizeof (uint32_t));
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_array_first_chunk_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_array_non_first_chunk_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_collection_header_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_collection_chunk_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_string_t) == sizeof (uint64_t));
|
||||
JERRY_STATIC_ASSERT(sizeof (ecma_completion_value_t) == sizeof (uint32_t));
|
||||
|
||||
@@ -98,8 +97,8 @@ JERRY_STATIC_ASSERT(sizeof (ecma_completion_value_t) == sizeof (uint32_t));
|
||||
DECLARE_ROUTINES_FOR (object)
|
||||
DECLARE_ROUTINES_FOR (property)
|
||||
DECLARE_ROUTINES_FOR (number)
|
||||
DECLARE_ROUTINES_FOR (array_first_chunk)
|
||||
DECLARE_ROUTINES_FOR (array_non_first_chunk)
|
||||
DECLARE_ROUTINES_FOR (collection_header)
|
||||
DECLARE_ROUTINES_FOR (collection_chunk)
|
||||
DECLARE_ROUTINES_FOR (string)
|
||||
|
||||
/**
|
||||
|
||||
@@ -62,28 +62,28 @@ extern ecma_number_t *ecma_alloc_number (void);
|
||||
extern void ecma_dealloc_number (ecma_number_t *number_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for first chunk of an ecma-array
|
||||
* Allocate memory for header of a collection
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_array_first_chunk_t *ecma_alloc_array_first_chunk (void);
|
||||
extern ecma_collection_header_t *ecma_alloc_collection_header (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from first chunk of an ecma-array
|
||||
* Dealloc memory from the collection's header
|
||||
*/
|
||||
extern void ecma_dealloc_array_first_chunk (ecma_array_first_chunk_t *first_chunk_p);
|
||||
extern void ecma_dealloc_collection_header (ecma_collection_header_t *collection_header_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for non-first chunk of an ecma-array
|
||||
* Allocate memory for non-first chunk of a collection
|
||||
*
|
||||
* @return pointer to allocated memory
|
||||
*/
|
||||
extern ecma_array_non_first_chunk_t *ecma_alloc_array_non_first_chunk (void);
|
||||
extern ecma_collection_chunk_t* ecma_alloc_collection_chunk (void);
|
||||
|
||||
/**
|
||||
* Dealloc memory from non-first chunk of an ecma-array
|
||||
* Dealloc memory from non-first chunk of a collection
|
||||
*/
|
||||
extern void ecma_dealloc_array_non_first_chunk (ecma_array_non_first_chunk_t *non_first_chunk_p);
|
||||
extern void ecma_dealloc_collection_chunk (ecma_collection_chunk_t *non_first_chunk_p);
|
||||
|
||||
/**
|
||||
* Allocate memory for ecma-string descriptor
|
||||
|
||||
@@ -250,8 +250,8 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array of ecma-values */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array of ecma-values */
|
||||
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();
|
||||
}
|
||||
@@ -264,7 +264,7 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
|
||||
JERRY_UNREACHABLE();
|
||||
}
|
||||
|
||||
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array of strings */
|
||||
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* a collection of strings */
|
||||
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
|
||||
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
|
||||
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
|
||||
|
||||
@@ -76,8 +76,8 @@ typedef enum
|
||||
ECMA_SIMPLE_VALUE_NULL, /**< null value */
|
||||
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
|
||||
ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */
|
||||
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exists,
|
||||
but is stored directly in the array's property list
|
||||
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exist,
|
||||
but are stored directly in the array's property list
|
||||
(used for array elements with non-default attribute values) */
|
||||
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
|
||||
} ecma_simple_value_t;
|
||||
@@ -481,36 +481,27 @@ typedef float ecma_number_t;
|
||||
#define ECMA_MAX_VALUE_OF_VALID_ARRAY_INDEX ((uint32_t) (-1))
|
||||
|
||||
/**
|
||||
* Description of arrays'/strings' length
|
||||
* Description of a collection's/string's length
|
||||
*/
|
||||
typedef uint16_t ecma_length_t;
|
||||
|
||||
/**
|
||||
* Description of an Array's header
|
||||
* Description of a collection's header.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** Compressed pointer to next chunk */
|
||||
/** Compressed pointer to next chunk with collection's data */
|
||||
uint16_t next_chunk_cp;
|
||||
|
||||
/** Number of elements in the Array */
|
||||
/** Number of elements in the collection */
|
||||
ecma_length_t unit_number;
|
||||
} ecma_array_header_t;
|
||||
|
||||
/** Place for the collection's data */
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (uint32_t) ];
|
||||
} ecma_collection_header_t;
|
||||
|
||||
/**
|
||||
* Description of first chunk in a chain of chunks that contains an Array.
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
/** Array's header */
|
||||
ecma_array_header_t header;
|
||||
|
||||
/** Elements */
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (ecma_array_header_t) ];
|
||||
} ecma_array_first_chunk_t;
|
||||
|
||||
/**
|
||||
* Description of non-first chunk in a chain of chunks that contains an Array
|
||||
* Description of non-first chunk in a collection's chain of chunks
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
@@ -519,7 +510,7 @@ typedef struct
|
||||
|
||||
/** Characters */
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
|
||||
} ecma_array_non_first_chunk_t;
|
||||
} ecma_collection_chunk_t;
|
||||
|
||||
/**
|
||||
* Identifier for ecma-string's actual data container
|
||||
@@ -527,7 +518,7 @@ typedef struct
|
||||
typedef enum
|
||||
{
|
||||
ECMA_STRING_CONTAINER_HEAP, /**< actual data is on the heap
|
||||
in ecma_array_non_first_chunk_t */
|
||||
in a ecma_collection_chunk_t chain */
|
||||
ECMA_STRING_CONTAINER_LIT_TABLE, /**< actual data is in literal table */
|
||||
ECMA_STRING_CONTAINER_IN_DESCRIPTOR /**< actual data is locally in the string's descriptor */
|
||||
} ecma_string_container_t;
|
||||
@@ -560,7 +551,7 @@ typedef struct
|
||||
/** Index of string in literal table */
|
||||
literal_index_t lit_index;
|
||||
|
||||
/** Compressed pointer to array_non_first_chunk_t */
|
||||
/** Compressed pointer to an ecma_collection_chunk_t */
|
||||
unsigned int chunk_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Actual data if placed locally in the descriptor */
|
||||
|
||||
@@ -67,7 +67,7 @@ ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string *
|
||||
ecma_length_t chars_left = length;
|
||||
JERRY_ASSERT (chars_left > 0);
|
||||
|
||||
ecma_array_non_first_chunk_t *string_chunk_p = ecma_alloc_array_non_first_chunk ();
|
||||
ecma_collection_chunk_t *string_chunk_p = ecma_alloc_collection_chunk ();
|
||||
|
||||
ECMA_SET_NON_NULL_POINTER (string_desc_p->u.chunk_cp, string_chunk_p);
|
||||
|
||||
@@ -80,7 +80,7 @@ ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string *
|
||||
chars_left = (ecma_length_t) (chars_left - chars_to_copy);
|
||||
src_p += chars_to_copy;
|
||||
|
||||
ecma_array_non_first_chunk_t* next_string_chunk_p = ecma_alloc_array_non_first_chunk ();
|
||||
ecma_collection_chunk_t* next_string_chunk_p = ecma_alloc_collection_chunk ();
|
||||
ECMA_SET_NON_NULL_POINTER (string_chunk_p->next_chunk_cp, next_string_chunk_p);
|
||||
string_chunk_p = next_string_chunk_p;
|
||||
}
|
||||
@@ -109,15 +109,15 @@ ecma_free_string (ecma_string_t *string_p) /**< ecma-string */
|
||||
|
||||
if (string_p->container == ECMA_STRING_CONTAINER_HEAP)
|
||||
{
|
||||
ecma_array_non_first_chunk_t *chunk_p = ECMA_GET_POINTER (string_p->u.chunk_cp);
|
||||
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (string_p->u.chunk_cp);
|
||||
|
||||
JERRY_ASSERT (chunk_p != NULL);
|
||||
|
||||
while (chunk_p != NULL)
|
||||
{
|
||||
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER (chunk_p->next_chunk_cp);
|
||||
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (chunk_p->next_chunk_cp);
|
||||
|
||||
ecma_dealloc_array_non_first_chunk (chunk_p);
|
||||
ecma_dealloc_collection_chunk (chunk_p);
|
||||
|
||||
chunk_p = next_chunk_p;
|
||||
}
|
||||
@@ -173,7 +173,7 @@ ecma_string_to_zt_string (ecma_string_t *string_desc_p, /**< ecma-string descrip
|
||||
}
|
||||
case ECMA_STRING_CONTAINER_HEAP:
|
||||
{
|
||||
ecma_array_non_first_chunk_t *string_chunk_p = ECMA_GET_POINTER(string_desc_p->u.chunk_cp);
|
||||
ecma_collection_chunk_t *string_chunk_p = ECMA_GET_POINTER (string_desc_p->u.chunk_cp);
|
||||
|
||||
const ecma_length_t max_chars_in_chunk = sizeof (string_chunk_p->data) / sizeof (ecma_char_t);
|
||||
|
||||
@@ -265,28 +265,28 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_string_t *string1_p, /* ecma
|
||||
}
|
||||
JERRY_ASSERT (string2_p->container == ECMA_STRING_CONTAINER_HEAP);
|
||||
|
||||
ecma_array_non_first_chunk_t *string1_chunk_p, *string2_chunk_p;
|
||||
const ecma_char_t *cur_char_array_1_p, *cur_char_array_2_p;
|
||||
const ecma_char_t *cur_char_array_1_end_p, *cur_char_array_2_end_p;
|
||||
ecma_collection_chunk_t *string1_chunk_p, *string2_chunk_p;
|
||||
const ecma_char_t *cur_char_buffer_1_iter_p, *cur_char_buffer_2_iter_p;
|
||||
const ecma_char_t *cur_char_buffer_1_end_p, *cur_char_buffer_2_end_p;
|
||||
if (string1_p->container == ECMA_STRING_CONTAINER_IN_DESCRIPTOR)
|
||||
{
|
||||
string1_chunk_p = NULL;
|
||||
cur_char_array_1_p = string1_p->u.chars;
|
||||
cur_char_array_1_end_p = cur_char_array_1_p + sizeof (string1_p->u.chars) / sizeof (ecma_char_t);
|
||||
cur_char_buffer_1_iter_p = string1_p->u.chars;
|
||||
cur_char_buffer_1_end_p = cur_char_buffer_1_iter_p + sizeof (string1_p->u.chars) / sizeof (ecma_char_t);
|
||||
}
|
||||
else
|
||||
{
|
||||
string1_chunk_p = ECMA_GET_POINTER (string1_p->u.chunk_cp);
|
||||
cur_char_array_1_p = string1_chunk_p->data;
|
||||
cur_char_array_1_end_p = cur_char_array_1_p + sizeof (string1_chunk_p->data) / sizeof (ecma_char_t);
|
||||
cur_char_buffer_1_iter_p = string1_chunk_p->data;
|
||||
cur_char_buffer_1_end_p = cur_char_buffer_1_iter_p + sizeof (string1_chunk_p->data) / sizeof (ecma_char_t);
|
||||
}
|
||||
|
||||
string2_chunk_p = ECMA_GET_POINTER (string2_p->u.chunk_cp);
|
||||
cur_char_array_2_p = string2_chunk_p->data;
|
||||
cur_char_array_2_end_p = cur_char_array_2_p + sizeof (string2_chunk_p->data) / sizeof (ecma_char_t);
|
||||
cur_char_buffer_2_iter_p = string2_chunk_p->data;
|
||||
cur_char_buffer_2_end_p = cur_char_buffer_2_iter_p + sizeof (string2_chunk_p->data) / sizeof (ecma_char_t);
|
||||
|
||||
/*
|
||||
* The assertion check allows to combine update of cur_char_array_1_p and cur_char_array_2_p pointers,
|
||||
* The assertion check allows to combine update of cur_char_buffer_1_iter_p and cur_char_buffer_2_iter_p pointers,
|
||||
* because:
|
||||
* - if we reached end of string in descriptor then we reached end of string => chars_left is zero;
|
||||
* - if we reached end of string chunk in heap then we reached end of other string's chunk too
|
||||
@@ -297,12 +297,12 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_string_t *string1_p, /* ecma
|
||||
|
||||
while (chars_left > 0)
|
||||
{
|
||||
if (cur_char_array_1_p != cur_char_array_1_end_p
|
||||
&& cur_char_array_2_p != cur_char_array_2_end_p)
|
||||
if (cur_char_buffer_1_iter_p != cur_char_buffer_1_end_p
|
||||
&& cur_char_buffer_2_iter_p != cur_char_buffer_2_end_p)
|
||||
{
|
||||
JERRY_ASSERT (cur_char_array_2_p < cur_char_array_2_end_p);
|
||||
JERRY_ASSERT (cur_char_buffer_2_iter_p < cur_char_buffer_2_end_p);
|
||||
|
||||
if (*cur_char_array_1_p++ != *cur_char_array_2_p++)
|
||||
if (*cur_char_buffer_1_iter_p++ != *cur_char_buffer_2_iter_p++)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
@@ -312,21 +312,21 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_string_t *string1_p, /* ecma
|
||||
continue;
|
||||
}
|
||||
|
||||
if (cur_char_array_1_p == cur_char_array_1_end_p)
|
||||
if (cur_char_buffer_1_iter_p == cur_char_buffer_1_end_p)
|
||||
{
|
||||
JERRY_ASSERT (string1_p->container == ECMA_STRING_CONTAINER_HEAP
|
||||
&& string2_p->container == ECMA_STRING_CONTAINER_HEAP);
|
||||
JERRY_ASSERT (cur_char_array_2_p == cur_char_array_2_end_p);
|
||||
JERRY_ASSERT (cur_char_buffer_2_iter_p == cur_char_buffer_2_end_p);
|
||||
|
||||
string1_chunk_p = ECMA_GET_POINTER (string1_chunk_p->next_chunk_cp);
|
||||
JERRY_ASSERT (string1_chunk_p != NULL);
|
||||
cur_char_array_1_p = string1_chunk_p->data;
|
||||
cur_char_array_1_end_p = cur_char_array_1_p + sizeof (string1_chunk_p->data) / sizeof (ecma_char_t);
|
||||
cur_char_buffer_1_iter_p = string1_chunk_p->data;
|
||||
cur_char_buffer_1_end_p = cur_char_buffer_1_iter_p + sizeof (string1_chunk_p->data) / sizeof (ecma_char_t);
|
||||
|
||||
string2_chunk_p = ECMA_GET_POINTER (string2_chunk_p->next_chunk_cp);
|
||||
JERRY_ASSERT (string2_chunk_p != NULL);
|
||||
cur_char_array_2_p = string2_chunk_p->data;
|
||||
cur_char_array_2_end_p = cur_char_array_2_p + sizeof (string2_chunk_p->data) / sizeof (ecma_char_t);
|
||||
cur_char_buffer_2_iter_p = string2_chunk_p->data;
|
||||
cur_char_buffer_2_end_p = cur_char_buffer_2_iter_p + sizeof (string2_chunk_p->data) / sizeof (ecma_char_t);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -366,7 +366,7 @@ ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-te
|
||||
ecma_length_t ecma_str_len = ecma_string_p->length;
|
||||
const ecma_char_t *current_chunk_chars_cur;
|
||||
const ecma_char_t *current_chunk_chars_end;
|
||||
ecma_array_non_first_chunk_t *string_chunk_p = NULL;
|
||||
ecma_collection_chunk_t *string_chunk_p = NULL;
|
||||
|
||||
if (ecma_string_p->container == ECMA_STRING_CONTAINER_IN_DESCRIPTOR)
|
||||
{
|
||||
|
||||
@@ -393,11 +393,14 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
|
||||
|
||||
switch (property_id)
|
||||
{
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
|
||||
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
|
||||
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* a collection */
|
||||
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* a collection */
|
||||
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* a collection */
|
||||
{
|
||||
ecma_free_array (ECMA_GET_POINTER(property_value));
|
||||
TODO (/* Free collection's elements */);
|
||||
JERRY_UNIMPLEMENTED();
|
||||
|
||||
ecma_free_collection (ECMA_GET_POINTER(property_value));
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -483,26 +486,26 @@ ecma_delete_property (ecma_object_t *obj_p, /**< object */
|
||||
} /* ecma_delete_property */
|
||||
|
||||
/**
|
||||
* Free all chunks of an array
|
||||
* Free all chunks of a collection
|
||||
*/
|
||||
void
|
||||
ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of the array */
|
||||
ecma_free_collection (ecma_collection_header_t *collection_header_p) /**< header of collection */
|
||||
{
|
||||
JERRY_ASSERT(first_chunk_p != NULL);
|
||||
JERRY_ASSERT(collection_header_p != NULL);
|
||||
|
||||
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER (first_chunk_p->header.next_chunk_cp);
|
||||
ecma_collection_chunk_t *non_first_chunk_p = ECMA_GET_POINTER (collection_header_p->next_chunk_cp);
|
||||
|
||||
ecma_dealloc_array_first_chunk (first_chunk_p);
|
||||
ecma_dealloc_collection_header (collection_header_p);
|
||||
|
||||
while (non_first_chunk_p != NULL)
|
||||
{
|
||||
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER (non_first_chunk_p->next_chunk_cp);
|
||||
ecma_collection_chunk_t *next_chunk_p = ECMA_GET_POINTER (non_first_chunk_p->next_chunk_cp);
|
||||
|
||||
ecma_dealloc_array_non_first_chunk (non_first_chunk_p);
|
||||
ecma_dealloc_collection_chunk (non_first_chunk_p);
|
||||
|
||||
non_first_chunk_p = next_chunk_p;
|
||||
}
|
||||
} /* ecma_free_array */
|
||||
} /* ecma_free_collection */
|
||||
|
||||
/**
|
||||
* Construct empty property descriptor.
|
||||
|
||||
@@ -139,7 +139,7 @@ extern void ecma_free_property (ecma_property_t *prop_p);
|
||||
|
||||
extern void ecma_delete_property (ecma_object_t *obj_p, ecma_property_t *prop_p);
|
||||
|
||||
extern void ecma_free_array (ecma_array_first_chunk_t *first_chunk_p);
|
||||
extern void ecma_free_collection (ecma_collection_header_t *collection_header_p);
|
||||
|
||||
extern ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user