Support of ecma-value with compressed pointer of more than 14-bit size.

This commit is contained in:
Ruben Ayrapetyan 2015-02-19 17:16:45 +03:00
parent d0c62bb507
commit 4e93ef421d
4 changed files with 35 additions and 36 deletions

View File

@ -20,7 +20,6 @@
#include "jrt.h"
#include "mem-poolman.h"
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) <= sizeof (uint16_t));
JERRY_STATIC_ASSERT (sizeof (ecma_property_t) <= sizeof (uint64_t));
JERRY_STATIC_ASSERT (sizeof (ecma_object_t) <= sizeof (uint64_t));

View File

@ -115,7 +115,7 @@ typedef enum
*
* Bit-field structure: type (2) | value (ECMA_POINTER_FIELD_WIDTH)
*/
typedef uint16_t ecma_value_t;
typedef uint32_t ecma_value_t;
/**
* Value type (ecma_type_t)
@ -131,7 +131,7 @@ typedef uint16_t ecma_value_t;
#define ECMA_VALUE_VALUE_WIDTH (ECMA_POINTER_FIELD_WIDTH)
/**
* ecma_value_t size
* Size of ecma value description, in bits
*/
#define ECMA_VALUE_SIZE (ECMA_VALUE_VALUE_POS + ECMA_VALUE_VALUE_WIDTH)
@ -146,25 +146,12 @@ typedef uint16_t ecma_value_t;
*/
typedef uint32_t ecma_completion_value_t;
/**
* Type (ecma_completion_type_t)
*/
#define ECMA_COMPLETION_VALUE_TYPE_POS (0)
#define ECMA_COMPLETION_VALUE_TYPE_WIDTH (8)
/**
* Padding (1 byte)
*/
#define ECMA_COMPLETION_VALUE_PADDING_WIDTH (8)
/**
* Value
*
* Used for normal, return, throw and exit completion types.
*/
#define ECMA_COMPLETION_VALUE_VALUE_POS (ECMA_COMPLETION_VALUE_TYPE_POS + \
ECMA_COMPLETION_VALUE_TYPE_WIDTH + \
ECMA_COMPLETION_VALUE_PADDING_WIDTH)
#define ECMA_COMPLETION_VALUE_VALUE_POS (0)
#define ECMA_COMPLETION_VALUE_VALUE_WIDTH (ECMA_VALUE_SIZE)
/**
@ -172,11 +159,26 @@ typedef uint32_t ecma_completion_value_t;
*
* Used for break and continue completion types.
*/
#define ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS (ECMA_COMPLETION_VALUE_TYPE_POS + \
ECMA_COMPLETION_VALUE_TYPE_WIDTH + \
ECMA_COMPLETION_VALUE_PADDING_WIDTH)
#define ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS (0)
#define ECMA_COMPLETION_VALUE_LABEL_DESC_CP_WIDTH (ECMA_POINTER_FIELD_WIDTH)
/**
* Type (ecma_completion_type_t)
*/
#define ECMA_COMPLETION_VALUE_TYPE_POS (JERRY_MAX (JERRY_ALIGNUP (ECMA_COMPLETION_VALUE_VALUE_POS + \
ECMA_COMPLETION_VALUE_VALUE_WIDTH, \
JERRY_BITSINBYTE), \
JERRY_ALIGNUP (ECMA_COMPLETION_VALUE_LABEL_DESC_CP_POS + \
ECMA_COMPLETION_VALUE_LABEL_DESC_CP_WIDTH, \
JERRY_BITSINBYTE)))
#define ECMA_COMPLETION_VALUE_TYPE_WIDTH (8)
/**
* Size of ecma completion value description, in bits
*/
#define ECMA_COMPLETION_VALUE_SIZE (ECMA_COMPLETION_VALUE_TYPE_POS + \
ECMA_COMPLETION_VALUE_TYPE_WIDTH)
/**
* Label
*
@ -295,9 +297,15 @@ typedef struct ecma_property_t
/** Description of named data property */
struct __attr_packed___ ecma_named_data_property_t
{
/** Value */
ecma_value_t value : ECMA_VALUE_SIZE;
/** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
/** Flag indicating whether the property is registered in LCache */
unsigned int is_lcached : 1;
/** Attribute 'Writable' (ecma_property_writable_value_t) */
unsigned int writable : 1;
@ -306,12 +314,6 @@ typedef struct ecma_property_t
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
unsigned int configurable : 1;
/** Flag indicating whether the property is registered in LCache */
unsigned int is_lcached : 1;
/** Value */
ecma_value_t value;
} named_data_property;
/** Description of named accessor property */

View File

@ -27,7 +27,8 @@
#include "jrt.h"
#include "jrt-bit-fields.h"
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE == ECMA_VALUE_SIZE);
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE >= ECMA_VALUE_SIZE);
JERRY_STATIC_ASSERT (sizeof (ecma_completion_value_t) * JERRY_BITSINBYTE >= ECMA_COMPLETION_VALUE_SIZE);
/**
* Get type field of ecma-value

View File

@ -524,7 +524,7 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
prop_p->u.named_data_property.is_lcached = false;
prop_p->u.named_data_property.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
ecma_set_named_data_property_value (prop_p, ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED));
ecma_lcache_invalidate (obj_p, name_p, NULL);
@ -698,7 +698,7 @@ ecma_free_named_data_property (ecma_object_t *object_p, /**< object the property
ecma_deref_ecma_string (ECMA_GET_NON_NULL_POINTER (ecma_string_t,
property_p->u.named_data_property.name_p));
ecma_value_t v = property_p->u.named_data_property.value;
ecma_value_t v = ecma_get_named_data_property_value (property_p);
ecma_free_value (v, false);
ecma_dealloc_property (property_p);
@ -919,10 +919,7 @@ ecma_set_named_data_property_value (ecma_property_t *prop_p, /**< property */
{
JERRY_ASSERT (prop_p->type == ECMA_PROPERTY_NAMEDDATA);
/* 'May ref younger' flag should be updated upon assignment of object value */
JERRY_ASSERT (!ecma_is_value_object (value));
prop_p->u.named_data_property.value = value;
prop_p->u.named_data_property.value = value & ((1ull << ECMA_VALUE_SIZE) - 1);
} /* ecma_set_named_data_property_value */
/**
@ -940,10 +937,10 @@ ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
ecma_assert_object_contains_the_property (obj_p, prop_p);
if (ecma_is_value_number (value)
&& ecma_is_value_number (prop_p->u.named_data_property.value))
&& ecma_is_value_number (ecma_get_named_data_property_value (prop_p)))
{
const ecma_number_t *num_src_p = ecma_get_number_from_value (value);
ecma_number_t *num_dst_p = ecma_get_number_from_value (prop_p->u.named_data_property.value);
ecma_number_t *num_dst_p = ecma_get_number_from_value (ecma_get_named_data_property_value (prop_p));
*num_dst_p = *num_src_p;
}
@ -952,7 +949,7 @@ ecma_named_data_property_assign_value (ecma_object_t *obj_p, /**< object */
ecma_value_t v = ecma_get_named_data_property_value (prop_p);
ecma_free_value (v, false);
prop_p->u.named_data_property.value = ecma_copy_value (value, false);
ecma_set_named_data_property_value (prop_p, ecma_copy_value (value, false));
}
} /* ecma_named_data_property_assign_value */