Skip to content

Commit

Permalink
Introduce integer ecma-value representation to reduce the double allo…
Browse files Browse the repository at this point in the history
…cations.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
  • Loading branch information
zherczeg committed May 5, 2016
1 parent 7813801 commit b3471ff
Show file tree
Hide file tree
Showing 32 changed files with 794 additions and 588 deletions.
37 changes: 31 additions & 6 deletions jerry-core/ecma/base/ecma-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@
*/
typedef enum
{
ECMA_TYPE_SIMPLE, /**< simple value */
ECMA_TYPE_NUMBER, /**< 64-bit integer */
ECMA_TYPE_NON_PTR_VALUE, /**< directly encoded value, a 28 bit signed integer or a simple value */
ECMA_TYPE_FLOAT_NUMBER, /**< pointer to a 64 or 32 bit floating point number */
ECMA_TYPE_STRING, /**< pointer to description of a string */
ECMA_TYPE_OBJECT, /**< pointer to description of an object */
ECMA_TYPE___MAX = ECMA_TYPE_OBJECT /** highest value for ecma types */
Expand All @@ -68,10 +68,10 @@ typedef enum
typedef enum
{
/**
* Empty value is implementation defined value, used for:
* - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type);
* - values of uninitialized immutable bindings;
* - values of empty register variables.
* Empty value is implementation defined value, used for representing:
* - empty (uninitialized) values
* - immutable binding values
* - special register or stack values for vm
*/
ECMA_SIMPLE_VALUE_EMPTY,
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
Expand All @@ -90,6 +90,11 @@ typedef enum
*/
typedef uint32_t ecma_value_t;

/**
* Type for small integer numbers in JerryScript.
*/
typedef int32_t ecma_value_integer_t;

#if UINTPTR_MAX <= UINT32_MAX

/**
Expand All @@ -114,6 +119,26 @@ typedef uint32_t ecma_value_t;
*/
#define ECMA_VALUE_SHIFT 3

/**
* Flag for simple values
*/
#define ECMA_SIMPLE_VALUE_FLAG 0x8u

/**
* Shift for integer value part in ecma_value_t
*/
#define ECMA_INTEGER_NUMBER_SHIFT 4

/**
* Maximum integer number for an ecma value
*/
#define ECMA_INTEGER_NUMBER_MAX 0x7ffffff

/**
* Minimum integer number for an ecma value
*/
#define ECMA_INTEGER_NUMBER_MIN -0x8000000

/**
* Internal properties' identifiers.
*/
Expand Down
9 changes: 9 additions & 0 deletions jerry-core/ecma/base/ecma-helpers-number.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,15 @@
* @{
*/

JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_value_integer_t),
size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_value_integer_t);

JERRY_STATIC_ASSERT (ECMA_INTEGER_NUMBER_SHIFT == ECMA_VALUE_SHIFT + 1,
currently_non_ptr_values_has_one_extra_flag);

JERRY_STATIC_ASSERT ((1 << ECMA_INTEGER_NUMBER_SHIFT) == (ECMA_SIMPLE_VALUE_FLAG << 1),
currently_integer_numbers_start_after_simple_value_flag);

#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + \
ECMA_NUMBER_BIASED_EXP_WIDTH)

Expand Down
Loading

0 comments on commit b3471ff

Please sign in to comment.