mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Introducing mem_cpointer_t type for compressed pointers.
This commit is contained in:
parent
3da56908aa
commit
c81651dbe9
@ -279,20 +279,20 @@ typedef enum
|
||||
*/
|
||||
typedef struct
|
||||
{
|
||||
uintptr_t getter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to getter object */
|
||||
uintptr_t setter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to setter object */
|
||||
mem_cpointer_t getter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to getter object */
|
||||
mem_cpointer_t setter_p : ECMA_POINTER_FIELD_WIDTH; /**< pointer to setter object */
|
||||
} ecma_getter_setter_pointers_t;
|
||||
|
||||
/**
|
||||
* Description of ecma-property
|
||||
*/
|
||||
typedef struct ecma_property_t
|
||||
typedef struct __attr_packed___ ecma_property_t
|
||||
{
|
||||
/** Property's type (ecma_property_type_t) */
|
||||
unsigned int type : 2;
|
||||
|
||||
/** Compressed pointer to next property */
|
||||
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t next_property_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Property's details (depending on Type) */
|
||||
union
|
||||
@ -304,7 +304,7 @@ typedef struct ecma_property_t
|
||||
ecma_value_t value : ECMA_VALUE_SIZE;
|
||||
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Flag indicating whether the property is registered in LCache */
|
||||
unsigned int is_lcached : 1;
|
||||
@ -323,7 +323,7 @@ typedef struct ecma_property_t
|
||||
struct __attr_packed___ ecma_named_accessor_property_t
|
||||
{
|
||||
/** Compressed pointer to property's name (pointer to String) */
|
||||
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t name_p : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
|
||||
unsigned int enumerable : 1;
|
||||
@ -335,7 +335,7 @@ typedef struct ecma_property_t
|
||||
unsigned int is_lcached : 1;
|
||||
|
||||
/** Compressed pointer to pair of pointers - to property's getter and setter */
|
||||
unsigned int getter_setter_pair_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t getter_setter_pair_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
} named_accessor_property;
|
||||
|
||||
/** Description of internal property */
|
||||
@ -695,13 +695,13 @@ typedef uint16_t ecma_length_t;
|
||||
typedef struct
|
||||
{
|
||||
/** Compressed pointer to next chunk with collection's data */
|
||||
uint16_t next_chunk_cp;
|
||||
mem_cpointer_t next_chunk_cp;
|
||||
|
||||
/** Number of elements in the collection */
|
||||
ecma_length_t unit_number;
|
||||
|
||||
/** Place for the collection's data */
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (uint32_t) ];
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (mem_cpointer_t) - sizeof (ecma_length_t) ];
|
||||
} ecma_collection_header_t;
|
||||
|
||||
/**
|
||||
@ -710,10 +710,10 @@ typedef struct
|
||||
typedef struct
|
||||
{
|
||||
/** Compressed pointer to next chunk */
|
||||
uint16_t next_chunk_cp;
|
||||
mem_cpointer_t next_chunk_cp;
|
||||
|
||||
/** Characters */
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
|
||||
uint8_t data[ sizeof (uint64_t) - sizeof (mem_cpointer_t) ];
|
||||
} ecma_collection_chunk_t;
|
||||
|
||||
/**
|
||||
@ -787,10 +787,10 @@ typedef struct ecma_string_t
|
||||
literal_index_t lit_index;
|
||||
|
||||
/** Compressed pointer to an ecma_collection_header_t */
|
||||
unsigned int collection_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t collection_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** Compressed pointer to an ecma_number_t */
|
||||
unsigned int number_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t number_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** UInt32-represented number placed locally in the descriptor */
|
||||
uint32_t uint32_number;
|
||||
@ -798,8 +798,8 @@ typedef struct ecma_string_t
|
||||
/** Representation of concatenation */
|
||||
struct
|
||||
{
|
||||
unsigned int string1_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
unsigned int string2_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t string1_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t string2_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
} concatenation;
|
||||
|
||||
/** Identifier of magic string */
|
||||
|
||||
@ -83,7 +83,7 @@ ecma_new_chars_collection (const ecma_char_t chars_buffer[], /**< ecma-chars */
|
||||
|
||||
collection_p->unit_number = chars_number;
|
||||
|
||||
uint16_t* next_chunk_cp_p = &collection_p->next_chunk_cp;
|
||||
mem_cpointer_t* next_chunk_cp_p = &collection_p->next_chunk_cp;
|
||||
ecma_char_t* cur_char_buf_iter_p = (ecma_char_t*) collection_p->data;
|
||||
ecma_char_t* cur_char_buf_end_p = cur_char_buf_iter_p + sizeof (collection_p->data) / sizeof (ecma_char_t);
|
||||
|
||||
@ -135,8 +135,8 @@ ecma_compare_chars_collection (const ecma_collection_header_t* header1_p, /**< f
|
||||
const ecma_char_t* cur_char_buf2_iter_p = (ecma_char_t*) header2_p->data;
|
||||
const ecma_char_t* cur_char_buf2_end_p = cur_char_buf2_iter_p + sizeof (header2_p->data) / sizeof (ecma_char_t);
|
||||
|
||||
uint16_t next_chunk1_cp = header1_p->next_chunk_cp;
|
||||
uint16_t next_chunk2_cp = header2_p->next_chunk_cp;
|
||||
mem_cpointer_t next_chunk1_cp = header1_p->next_chunk_cp;
|
||||
mem_cpointer_t next_chunk2_cp = header2_p->next_chunk_cp;
|
||||
|
||||
for (ecma_length_t char_index = 0;
|
||||
char_index < chars_number;
|
||||
@ -183,7 +183,7 @@ ecma_copy_chars_collection (const ecma_collection_header_t* collection_p) /**< c
|
||||
ecma_collection_header_t *new_header_p = ecma_alloc_collection_header ();
|
||||
*new_header_p = *collection_p;
|
||||
|
||||
uint16_t* next_chunk_cp_p = &new_header_p->next_chunk_cp;
|
||||
mem_cpointer_t* next_chunk_cp_p = &new_header_p->next_chunk_cp;
|
||||
|
||||
ecma_collection_chunk_t *chunk_p = ECMA_GET_POINTER (ecma_collection_chunk_t,
|
||||
collection_p->next_chunk_cp);
|
||||
@ -219,7 +219,7 @@ ecma_copy_chars_collection_to_buffer (const ecma_collection_header_t *collection
|
||||
|
||||
const ecma_length_t chars_number = collection_p->unit_number;
|
||||
|
||||
uint16_t next_chunk_cp = collection_p->next_chunk_cp;
|
||||
mem_cpointer_t next_chunk_cp = collection_p->next_chunk_cp;
|
||||
const ecma_char_t* cur_char_buf_iter_p = (ecma_char_t*) collection_p->data;
|
||||
const ecma_char_t* cur_char_buf_end_p = cur_char_buf_iter_p + sizeof (collection_p->data) / sizeof (ecma_char_t);
|
||||
|
||||
|
||||
@ -228,7 +228,7 @@ ecma_make_number_value (ecma_number_t* num_p) /**< number to reference in value
|
||||
{
|
||||
JERRY_ASSERT(num_p != NULL);
|
||||
|
||||
uint16_t num_cp;
|
||||
mem_cpointer_t num_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (num_cp, num_p);
|
||||
|
||||
ecma_value_t ret_value = 0;
|
||||
@ -247,7 +247,7 @@ ecma_make_string_value (ecma_string_t* ecma_string_p) /**< string to reference i
|
||||
{
|
||||
JERRY_ASSERT(ecma_string_p != NULL);
|
||||
|
||||
uint16_t string_cp;
|
||||
mem_cpointer_t string_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (string_cp, ecma_string_p);
|
||||
|
||||
ecma_value_t ret_value = 0;
|
||||
@ -266,7 +266,7 @@ ecma_make_object_value (ecma_object_t* object_p) /**< object to reference in val
|
||||
{
|
||||
JERRY_ASSERT(object_p != NULL);
|
||||
|
||||
uint16_t object_cp;
|
||||
mem_cpointer_t object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (object_cp, object_p);
|
||||
|
||||
ecma_value_t ret_value = 0;
|
||||
|
||||
@ -43,7 +43,7 @@ ecma_new_values_collection (const ecma_value_t values_buffer[], /**< ecma-values
|
||||
|
||||
header_p->unit_number = values_number;
|
||||
|
||||
uint16_t* next_chunk_cp_p = &header_p->next_chunk_cp;
|
||||
mem_cpointer_t* next_chunk_cp_p = &header_p->next_chunk_cp;
|
||||
ecma_value_t* cur_value_buf_iter_p = (ecma_value_t*) header_p->data;
|
||||
ecma_value_t* cur_value_buf_end_p = cur_value_buf_iter_p + sizeof (header_p->data) / sizeof (ecma_value_t);
|
||||
|
||||
|
||||
@ -43,7 +43,8 @@
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
|
||||
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
|
||||
(field) = (mem_compress_pointer (non_compressed_pointer) & \
|
||||
((((mem_cpointer_t) 1u) << ECMA_POINTER_FIELD_WIDTH) - 1))
|
||||
|
||||
/**
|
||||
* Set value of compressed pointer field so that it will correspond
|
||||
@ -56,9 +57,14 @@
|
||||
non_compressed_pointer = __temp_pointer; \
|
||||
} while (0); \
|
||||
\
|
||||
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
|
||||
: (mem_compress_pointer (non_compressed_pointer) \
|
||||
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)))
|
||||
if (unlikely ((non_compressed_pointer) == NULL)) \
|
||||
{ \
|
||||
(field) = ECMA_NULL_POINTER; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ECMA_SET_NON_NULL_POINTER (field, non_compressed_pointer); \
|
||||
}
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
extern bool ecma_is_value_empty (const ecma_value_t& value);
|
||||
@ -209,7 +215,7 @@ extern ecma_collection_header_t *ecma_new_strings_collection (ecma_string_t* str
|
||||
typedef struct
|
||||
{
|
||||
ecma_collection_header_t *header_p; /**< collection header */
|
||||
uint16_t next_chunk_cp; /**< compressed pointer to next chunk */
|
||||
mem_cpointer_t next_chunk_cp; /**< compressed pointer to next chunk */
|
||||
ecma_length_t current_index; /**< index of current element */
|
||||
const ecma_value_t *current_value_p; /**< pointer to current element */
|
||||
const ecma_value_t *current_chunk_beg_p; /**< pointer to beginning of current chunk's data */
|
||||
|
||||
@ -32,13 +32,13 @@
|
||||
typedef struct
|
||||
{
|
||||
/** Compressed pointer to object (ECMA_NULL_POINTER marks record empty) */
|
||||
uint16_t object_cp;
|
||||
mem_cpointer_t object_cp;
|
||||
|
||||
/** Compressed pointer to property's name */
|
||||
uint16_t prop_name_cp;
|
||||
mem_cpointer_t prop_name_cp;
|
||||
|
||||
/** Compressed pointer to a property of the object */
|
||||
uint16_t prop_cp;
|
||||
mem_cpointer_t prop_cp;
|
||||
|
||||
/** Padding structure to 8 bytes size */
|
||||
uint16_t padding;
|
||||
@ -159,7 +159,7 @@ ecma_lcache_insert (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
if (unlikely (ecma_is_property_lcached (prop_p)))
|
||||
{
|
||||
uint16_t prop_cp;
|
||||
mem_cpointer_t prop_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (prop_cp, prop_p);
|
||||
|
||||
int32_t entry_index;
|
||||
|
||||
@ -37,7 +37,7 @@ typedef struct
|
||||
ecma_value_t base;
|
||||
|
||||
/** referenced name */
|
||||
unsigned int referenced_name_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
mem_cpointer_t referenced_name_cp : ECMA_POINTER_FIELD_WIDTH;
|
||||
|
||||
/** strict reference flag */
|
||||
unsigned int is_strict : 1;
|
||||
|
||||
@ -28,6 +28,11 @@
|
||||
#include "mem-heap.h"
|
||||
#include "mem-poolman.h"
|
||||
|
||||
/**
|
||||
* Compressed pointer
|
||||
*/
|
||||
typedef uint16_t mem_cpointer_t;
|
||||
|
||||
/**
|
||||
* Representation of NULL value for compressed pointers
|
||||
*/
|
||||
|
||||
@ -65,7 +65,7 @@ typedef struct __attribute__ ((aligned (MEM_ALIGNMENT))) mem_pool_state_t
|
||||
unsigned int free_chunks_number : MEM_POOL_MAX_CHUNKS_NUMBER_LOG;
|
||||
|
||||
/** Pointer to the next pool with same chunk size */
|
||||
unsigned int next_pool_cp : MEM_COMPRESSED_POINTER_WIDTH;
|
||||
mem_cpointer_t next_pool_cp : MEM_COMPRESSED_POINTER_WIDTH;
|
||||
} mem_pool_state_t;
|
||||
|
||||
extern void mem_pool_init (mem_pool_state_t *pool_p, size_t pool_size);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user