Fix configuration of recordset's and literal storage's parameters according to MEM_ALIGNMENT_LOG and MEM_CP_WIDTH changes.

JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
Ruben Ayrapetyan
2015-09-30 12:23:26 +03:00
parent 94cb6aec26
commit 90122d9f33
8 changed files with 182 additions and 118 deletions
+28 -27
View File
@@ -34,20 +34,12 @@
/**
* Logarithm of a dynamic storage unit alignment
*/
#define RCS_DYN_STORAGE_ALIGNMENT_LOG (2u)
/**
* Dynamic storage unit alignment
*/
#define RCS_DYN_STORAGE_ALIGNMENT (1ull << RCS_DYN_STORAGE_ALIGNMENT_LOG)
#define RCS_DYN_STORAGE_LENGTH_UNIT_LOG (2u)
/**
* Unit of length
*
* See also:
* rcs_dyn_storage_length_t
*/
#define RCS_DYN_STORAGE_LENGTH_UNIT (4u)
#define RCS_DYN_STORAGE_LENGTH_UNIT ((size_t) (1ull << RCS_DYN_STORAGE_LENGTH_UNIT_LOG))
/**
* Dynamic storage
@@ -65,7 +57,7 @@ public:
{
_chunk_list.init ();
JERRY_ASSERT (_chunk_list.get_data_space_size () % RCS_DYN_STORAGE_LENGTH_UNIT == 0);
JERRY_ASSERT (get_node_data_space_size () % RCS_DYN_STORAGE_LENGTH_UNIT == 0);
} /* init */
/* Destructor */
@@ -95,24 +87,24 @@ public:
* Dynamic storage-specific extended compressed pointer
*
* Note:
* the pointer can represent addresses aligned by RCS_DYN_STORAGE_ALIGNMENT,
* while mem_cpointer_t can only represent addressed aligned by MEM_ALIGNMENT.
* the pointer can represent addresses aligned by RCS_DYN_STORAGE_LENGTH_UNIT,
* while mem_cpointer_t can only represent addresses aligned by MEM_ALIGNMENT.
*/
struct cpointer_t
{
static const uint32_t bit_field_width = MEM_CP_WIDTH + MEM_ALIGNMENT_LOG - RCS_DYN_STORAGE_ALIGNMENT_LOG;
static const uint32_t bit_field_width = MEM_CP_WIDTH + MEM_ALIGNMENT_LOG - RCS_DYN_STORAGE_LENGTH_UNIT_LOG;
union
{
struct
{
mem_cpointer_t base_cp : MEM_CP_WIDTH; /**< pointer to base of addressed area */
#if MEM_ALIGNMENT_LOG > RCS_DYN_STORAGE_ALIGNMENT_LOG
uint16_t ext : (MEM_ALIGNMENT_LOG - RCS_DYN_STORAGE_ALIGNMENT_LOG); /**< extension of the basic
* compressed pointer
* used for more detailed
* addressing */
#endif /* MEM_ALIGNMENT_LOG > RCS_DYN_STORAGE_ALIGNMENT_LOG */
#if MEM_ALIGNMENT_LOG > RCS_DYN_STORAGE_LENGTH_UNIT_LOG
uint16_t ext : (MEM_ALIGNMENT_LOG - RCS_DYN_STORAGE_LENGTH_UNIT_LOG); /**< extension of the basic
* compressed pointer
* used for more detailed
* addressing */
#endif /* MEM_ALIGNMENT_LOG > RCS_DYN_STORAGE_LENGTH_UNIT_LOG */
} value;
uint16_t packed_value;
};
@@ -129,12 +121,12 @@ public:
/**
* Offset of 'type' field, in bits
*/
static const uint32_t _type_field_pos = 0u;
static constexpr uint32_t _type_field_pos = 0u;
/**
* Width of 'type' field, in bits
*/
static const uint32_t _type_field_width = 4u;
static constexpr uint32_t _type_field_width = 4u;
protected:
void check_this (void) const;
@@ -148,7 +140,7 @@ public:
/**
* Offset of a derived record's fields, in bits
*/
static const uint32_t _fields_offset_begin = _type_field_pos + _type_field_width;
static constexpr uint32_t _fields_offset_begin = _type_field_pos + _type_field_width;
};
record_t *get_first (void);
@@ -172,6 +164,8 @@ private:
void init_free_record (record_t *, size_t, record_t *);
bool is_record_free (record_t *);
uint8_t *get_node_data_space (rcs_chunked_list_t::node_t *) const;
static size_t get_node_data_space_size (void);
protected:
/**
* First type identifier that can be used for storage-specific record types
@@ -357,22 +351,29 @@ private:
/**
* Offset of 'length' field, in bits
*/
static const uint32_t _length_field_pos = _fields_offset_begin;
static constexpr uint32_t _length_field_pos = _fields_offset_begin;
/**
* Width of 'length' field, in bits
*/
static const uint32_t _length_field_width = 12u;
static constexpr uint32_t _length_field_width = 14u - RCS_DYN_STORAGE_LENGTH_UNIT_LOG;
/**
* Offset of 'previous record' field, in bits
*/
static const uint32_t _prev_field_pos = _length_field_pos + _length_field_width;
static constexpr uint32_t _prev_field_pos = _length_field_pos + _length_field_width;
/**
* Width of 'previous record' field, in bits
*/
static const uint32_t _prev_field_width = rcs_cpointer_t::bit_field_width;
static constexpr uint32_t _prev_field_width = rcs_cpointer_t::bit_field_width;
/**
* Free record should be be placeable at any free space unit of recordset,
* and so its size should be less than minimal size of a free space unit
* that is RCS_DYN_STORAGE_LENGTH_UNIT bytes.
*/
JERRY_STATIC_ASSERT (_prev_field_pos + _prev_field_width <= RCS_DYN_STORAGE_LENGTH_UNIT * JERRY_BITSINBYTE);
};
/**