Skip to content

Commit e730ca9

Browse files
committed
Introduce integer ecma-value representation to reduce the double allocations.
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
1 parent 7813801 commit e730ca9

32 files changed

+791
-588
lines changed

jerry-core/ecma/base/ecma-globals.h

Lines changed: 33 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@
5555
*/
5656
typedef enum
5757
{
58-
ECMA_TYPE_SIMPLE, /**< simple value */
59-
ECMA_TYPE_NUMBER, /**< 64-bit integer */
58+
ECMA_TYPE_NON_PTR_VALUE, /**< directly encoded value, a 28 bit signed integer or a simple value */
59+
ECMA_TYPE_FLOAT_NUMBER, /**< pointer to a 64 or 32 bit floating point number */
6060
ECMA_TYPE_STRING, /**< pointer to description of a string */
6161
ECMA_TYPE_OBJECT, /**< pointer to description of an object */
6262
ECMA_TYPE___MAX = ECMA_TYPE_OBJECT /** highest value for ecma types */
@@ -68,10 +68,10 @@ typedef enum
6868
typedef enum
6969
{
7070
/**
71-
* Empty value is implementation defined value, used for:
72-
* - representing empty value in completion values (see also: ECMA-262 v5, 8.9 Completion specification type);
73-
* - values of uninitialized immutable bindings;
74-
* - values of empty register variables.
71+
* Empty value is implementation defined value, used for representing:
72+
* - empty (uninitialized) values
73+
* - immutable binding values
74+
* - special register or stack values for vm
7575
*/
7676
ECMA_SIMPLE_VALUE_EMPTY,
7777
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
@@ -90,6 +90,13 @@ typedef enum
9090
*/
9191
typedef uint32_t ecma_value_t;
9292

93+
/**
94+
* Type for small integer numbers in JerryScript.
95+
*
96+
* The size of ecma_value_integer_t and ecma_value_t must be the same.
97+
*/
98+
typedef int32_t ecma_value_integer_t;
99+
93100
#if UINTPTR_MAX <= UINT32_MAX
94101

95102
/**
@@ -114,6 +121,26 @@ typedef uint32_t ecma_value_t;
114121
*/
115122
#define ECMA_VALUE_SHIFT 3
116123

124+
/**
125+
* Flag for simple values
126+
*/
127+
#define ECMA_SIMPLE_VALUE_FLAG 0x8u
128+
129+
/**
130+
* Shift for integer value part in ecma_value_t
131+
*/
132+
#define ECMA_INTEGER_NUMBER_SHIFT 4
133+
134+
/**
135+
* Maximum integer number for an ecma value
136+
*/
137+
#define ECMA_INTEGER_NUMBER_MAX 0x7ffffff
138+
139+
/**
140+
* Minimum integer number for an ecma value
141+
*/
142+
#define ECMA_INTEGER_NUMBER_MIN -0x8000000
143+
117144
/**
118145
* Internal properties' identifiers.
119146
*/

jerry-core/ecma/base/ecma-helpers-number.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@
2424
* @{
2525
*/
2626

27+
JERRY_STATIC_ASSERT (sizeof (ecma_value_t) == sizeof (ecma_value_integer_t),
28+
size_of_ecma_value_t_must_be_equal_to_the_size_of_ecma_value_integer_t);
29+
30+
JERRY_STATIC_ASSERT (ECMA_INTEGER_NUMBER_SHIFT == ECMA_VALUE_SHIFT + 1,
31+
currently_non_ptr_values_has_one_extra_flag);
32+
33+
JERRY_STATIC_ASSERT ((1 << ECMA_INTEGER_NUMBER_SHIFT) == (ECMA_SIMPLE_VALUE_FLAG << 1),
34+
currently_integer_numbers_start_after_simple_value_flag);
35+
2736
#define ECMA_NUMBER_SIGN_POS (ECMA_NUMBER_FRACTION_WIDTH + \
2837
ECMA_NUMBER_BIASED_EXP_WIDTH)
2938

0 commit comments

Comments
 (0)