Refactor object properties to become real fields.

The positive side effect is that the maximum Jerry memory is increased to 512K.
Furthermore a slight (1.3%) performance improvement was measured on RPi2 with
SunSpider.

JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
Zoltan Herczeg
2016-04-05 23:37:15 -07:00
parent 2f661f9509
commit d674b92f26
7 changed files with 246 additions and 386 deletions
-4
View File
@@ -26,10 +26,6 @@ JERRY_STATIC_ASSERT (sizeof (ecma_property_t) <= sizeof (uint64_t),
JERRY_STATIC_ASSERT (sizeof (ecma_object_t) <= sizeof (uint64_t), JERRY_STATIC_ASSERT (sizeof (ecma_object_t) <= sizeof (uint64_t),
size_of_ecma_object_t_must_be_less_than_or_equal_to_8_bytes); size_of_ecma_object_t_must_be_less_than_or_equal_to_8_bytes);
JERRY_STATIC_ASSERT (ECMA_OBJECT_OBJ_TYPE_SIZE <= sizeof (uint64_t) * JERRY_BITSINBYTE,
ECMA_OBJECT_OBJ_TYPE_SIZE_must_be_less_than_or_equal_to_64_bits);
JERRY_STATIC_ASSERT (ECMA_OBJECT_LEX_ENV_TYPE_SIZE <= sizeof (uint64_t) * JERRY_BITSINBYTE,
ECMA_OBJECT_LEX_ENV_TYPE_SIZE_must_be_less_than_or_equal_to_64_bits);
JERRY_STATIC_ASSERT (sizeof (ecma_collection_header_t) == sizeof (uint64_t), JERRY_STATIC_ASSERT (sizeof (ecma_collection_header_t) == sizeof (uint64_t),
size_of_ecma_collection_header_t_must_be_less_than_or_equal_to_8_bytes); size_of_ecma_collection_header_t_must_be_less_than_or_equal_to_8_bytes);
+26 -71
View File
@@ -87,109 +87,65 @@ static size_t ecma_gc_new_objects_since_last_gc = 0;
static void ecma_gc_mark (ecma_object_t *object_p); static void ecma_gc_mark (ecma_object_t *object_p);
static void ecma_gc_sweep (ecma_object_t *object_p); static void ecma_gc_sweep (ecma_object_t *object_p);
/**
* Get GC reference counter of the object.
*/
static uint32_t
ecma_gc_get_object_refs (ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT (object_p != NULL);
return (uint32_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
ECMA_OBJECT_GC_REFS_POS,
ECMA_OBJECT_GC_REFS_WIDTH);
} /* ecma_gc_get_object_refs */
/**
* Set GC reference counter of the object.
*/
static void
ecma_gc_set_object_refs (ecma_object_t *object_p, /**< object */
uint32_t refs) /**< new reference counter */
{
JERRY_ASSERT (object_p != NULL);
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
refs,
ECMA_OBJECT_GC_REFS_POS,
ECMA_OBJECT_GC_REFS_WIDTH);
} /* ecma_gc_set_object_refs */
/** /**
* Get next object in list of objects with same generation. * Get next object in list of objects with same generation.
*/ */
static ecma_object_t * static inline ecma_object_t *
ecma_gc_get_object_next (ecma_object_t *object_p) /**< object */ ecma_gc_get_object_next (ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH); return ECMA_GET_POINTER (ecma_object_t, object_p->gc_next_cp);
uintptr_t next_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
ECMA_OBJECT_GC_NEXT_CP_POS,
ECMA_OBJECT_GC_NEXT_CP_WIDTH);
return ECMA_GET_POINTER (ecma_object_t,
next_cp);
} /* ecma_gc_get_object_next */ } /* ecma_gc_get_object_next */
/** /**
* Set next object in list of objects with same generation. * Set next object in list of objects with same generation.
*/ */
static void static inline void
ecma_gc_set_object_next (ecma_object_t *object_p, /**< object */ ecma_gc_set_object_next (ecma_object_t *object_p, /**< object */
ecma_object_t *next_object_p) /**< next object */ ecma_object_t *next_object_p) /**< next object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
uintptr_t next_cp; ECMA_SET_POINTER (object_p->gc_next_cp, next_object_p);
ECMA_SET_POINTER (next_cp, next_object_p);
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH);
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
next_cp,
ECMA_OBJECT_GC_NEXT_CP_POS,
ECMA_OBJECT_GC_NEXT_CP_WIDTH);
} /* ecma_gc_set_object_next */ } /* ecma_gc_set_object_next */
/** /**
* Get visited flag of the object. * Get visited flag of the object.
*/ */
static bool static inline bool
ecma_gc_is_object_visited (ecma_object_t *object_p) /**< object */ ecma_gc_is_object_visited (ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
bool flag_value = (bool) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container, bool flag_value = (object_p->type_flags_refs & ECMA_OBJECT_FLAG_GC_VISITED) != 0;
ECMA_OBJECT_GC_VISITED_POS,
ECMA_OBJECT_GC_VISITED_WIDTH);
return (flag_value != ecma_gc_visited_flip_flag); return flag_value != ecma_gc_visited_flip_flag;
} /* ecma_gc_is_object_visited */ } /* ecma_gc_is_object_visited */
/** /**
* Set visited flag of the object. * Set visited flag of the object.
*/ */
static void static inline void
ecma_gc_set_object_visited (ecma_object_t *object_p, /**< object */ ecma_gc_set_object_visited (ecma_object_t *object_p, /**< object */
bool is_visited) /**< flag value */ bool is_visited) /**< flag value */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
if (ecma_gc_visited_flip_flag) if (is_visited != ecma_gc_visited_flip_flag)
{ {
is_visited = !is_visited; object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_FLAG_GC_VISITED);
}
else
{
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs & ~ECMA_OBJECT_FLAG_GC_VISITED);
} }
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
is_visited,
ECMA_OBJECT_GC_VISITED_POS,
ECMA_OBJECT_GC_VISITED_WIDTH);
} /* ecma_gc_set_object_visited */ } /* ecma_gc_set_object_visited */
/** /**
* Initialize GC information for the object * Initialize GC information for the object
*/ */
void inline void
ecma_init_gc_info (ecma_object_t *object_p) /**< object */ ecma_init_gc_info (ecma_object_t *object_p) /**< object */
{ {
ecma_gc_objects_number++; ecma_gc_objects_number++;
@@ -197,7 +153,8 @@ ecma_init_gc_info (ecma_object_t *object_p) /**< object */
JERRY_ASSERT (ecma_gc_new_objects_since_last_gc <= ecma_gc_objects_number); JERRY_ASSERT (ecma_gc_new_objects_since_last_gc <= ecma_gc_objects_number);
ecma_gc_set_object_refs (object_p, 1); JERRY_ASSERT (object_p->type_flags_refs < ECMA_OBJECT_REF_ONE);
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_REF_ONE);
ecma_gc_set_object_next (object_p, ecma_gc_objects_lists[ECMA_GC_COLOR_WHITE_GRAY]); ecma_gc_set_object_next (object_p, ecma_gc_objects_lists[ECMA_GC_COLOR_WHITE_GRAY]);
ecma_gc_objects_lists[ECMA_GC_COLOR_WHITE_GRAY] = object_p; ecma_gc_objects_lists[ECMA_GC_COLOR_WHITE_GRAY] = object_p;
@@ -212,11 +169,9 @@ ecma_init_gc_info (ecma_object_t *object_p) /**< object */
void void
ecma_ref_object (ecma_object_t *object_p) /**< object */ ecma_ref_object (ecma_object_t *object_p) /**< object */
{ {
uint32_t ref_cnt = ecma_gc_get_object_refs (object_p); if (object_p->type_flags_refs < ECMA_OBJECT_MAX_REF)
if (ref_cnt < (uint32_t) CONFIG_ECMA_REFERENCE_COUNTER_LIMIT)
{ {
ecma_gc_set_object_refs (object_p, ref_cnt + 1); object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs + ECMA_OBJECT_REF_ONE);
} }
else else
{ {
@@ -230,8 +185,8 @@ ecma_ref_object (ecma_object_t *object_p) /**< object */
void void
ecma_deref_object (ecma_object_t *object_p) /**< object */ ecma_deref_object (ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (ecma_gc_get_object_refs (object_p) > 0); JERRY_ASSERT (object_p->type_flags_refs >= ECMA_OBJECT_REF_ONE);
ecma_gc_set_object_refs (object_p, ecma_gc_get_object_refs (object_p) - 1); object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs - ECMA_OBJECT_REF_ONE);
} /* ecma_deref_object */ } /* ecma_deref_object */
/** /**
@@ -266,7 +221,7 @@ ecma_gc_mark (ecma_object_t *object_p) /**< object to mark from */
ecma_gc_set_object_visited (lex_env_p, true); ecma_gc_set_object_visited (lex_env_p, true);
} }
if (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND) if (ecma_get_lex_env_type (object_p) != ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
{ {
ecma_object_t *binding_object_p = ecma_get_lex_env_binding_object (object_p); ecma_object_t *binding_object_p = ecma_get_lex_env_binding_object (object_p);
ecma_gc_set_object_visited (binding_object_p, true); ecma_gc_set_object_visited (binding_object_p, true);
@@ -421,7 +376,7 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
{ {
JERRY_ASSERT (object_p != NULL JERRY_ASSERT (object_p != NULL
&& !ecma_gc_is_object_visited (object_p) && !ecma_gc_is_object_visited (object_p)
&& ecma_gc_get_object_refs (object_p) == 0); && object_p->type_flags_refs < ECMA_OBJECT_REF_ONE);
if (!ecma_is_lexical_environment (object_p)) if (!ecma_is_lexical_environment (object_p))
{ {
@@ -444,8 +399,8 @@ ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
} }
} }
if (!ecma_is_lexical_environment (object_p) || if (!ecma_is_lexical_environment (object_p)
ecma_get_lex_env_type (object_p) != ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND) || ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE)
{ {
for (ecma_property_t *property = ecma_get_property_list (object_p), *next_property_p; for (ecma_property_t *property = ecma_get_property_list (object_p), *next_property_p;
property != NULL; property != NULL;
@@ -481,7 +436,7 @@ ecma_gc_run (void)
{ {
JERRY_ASSERT (!ecma_gc_is_object_visited (obj_iter_p)); JERRY_ASSERT (!ecma_gc_is_object_visited (obj_iter_p));
if (ecma_gc_get_object_refs (obj_iter_p) > 0) if (obj_iter_p->type_flags_refs >= ECMA_OBJECT_REF_ONE)
{ {
ecma_gc_set_object_visited (obj_iter_p, true); ecma_gc_set_object_visited (obj_iter_p, true);
} }
+74 -125
View File
@@ -278,36 +278,76 @@ typedef struct ecma_property_t
} v; } v;
} ecma_property_t; } ecma_property_t;
/**
* Internal object types
*/
typedef enum
{
ECMA_OBJECT_TYPE_GENERAL = 0, /**< all objects that are not String (15.5), Function (15.3),
Arguments (10.6), Array (15.4) specification-defined objects */
ECMA_OBJECT_TYPE_FUNCTION = 1, /**< Function objects (15.3), created through 13.2 routine */
ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION = 2, /** One of built-in functions described in section 15
* of ECMA-262 v5 specification */
ECMA_OBJECT_TYPE_ARRAY = 3, /**< Array object (15.4) */
ECMA_OBJECT_TYPE_STRING = 4, /**< String objects (15.5) */
ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION = 5, /**< External (host) function object */
ECMA_OBJECT_TYPE_BOUND_FUNCTION = 6, /**< Function objects (15.3), created through 15.3.4.5 routine */
ECMA_OBJECT_TYPE_ARGUMENTS = 7, /**< Arguments object (10.6) */
ECMA_OBJECT_TYPE__MAX = ECMA_OBJECT_TYPE_ARGUMENTS /**< maximum value */
} ecma_object_type_t;
/** /**
* Types of lexical environments * Types of lexical environments
*/ */
typedef enum typedef enum
{ {
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */ /* ECMA_OBJECT_TYPE_GENERAL (0) with built-in flag. */
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */ /* ECMA_OBJECT_TYPE_FUNCTION (1) with built-in flag. */
/* ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION (2) with built-in flag. */
/* ECMA_OBJECT_TYPE_ARRAY (3) with built-in flag. */
/* ECMA_OBJECT_TYPE_STRING (4) with built-in flag. */
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE = 5, /**< declarative lexical environment */
ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND = 6, /**< object-bound lexical environment */
ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND = 7, /**< object-bound lexical environment
* with provideThis flag */
ECMA_LEXICAL_ENVIRONMENT_TYPE_START = ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< first lexical
* environment type */
ECMA_LEXICAL_ENVIRONMENT_TYPE__MAX = ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND /**< maximum value */
} ecma_lexical_environment_type_t; } ecma_lexical_environment_type_t;
/** /**
* Internal object types * Ecma object type mask for getting the object type.
*
* Warning:
* definition order is significant (see also dispatch tables in libecmaobjects/ecma-objects.c)
*/ */
typedef enum #define ECMA_OBJECT_TYPE_MASK 0x07u
{
ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3), /**
Arguments (10.6), Array (15.4) specification-defined objects * Ecma object is built-in or lexical environment.
and not host objects */ * - built-in, if object type is less than ECMA_LEXICAL_ENVIRONMENT_TYPES_START
ECMA_OBJECT_TYPE_STRING, /**< String objects (15.5) */ * - lexical environment, if object type is greater or equal than ECMA_LEXICAL_ENVIRONMENT_TYPES_START
ECMA_OBJECT_TYPE_FUNCTION, /**< Function objects (15.3), created through 13.2 routine */ */
ECMA_OBJECT_TYPE_EXTERNAL_FUNCTION, /**< External (host) function object */ #define ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV 0x08
ECMA_OBJECT_TYPE_BOUND_FUNCTION, /**< Function objects (15.3), created through 15.3.4.5 routine */
ECMA_OBJECT_TYPE_BUILT_IN_FUNCTION, /** One of built-in functions described in section 15 /**
of ECMA-262 v5 specification */ * This object is visited by the garbage collector.
ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */ */
ECMA_OBJECT_TYPE_ARRAY /**< Array object (15.4) */ #define ECMA_OBJECT_FLAG_GC_VISITED 0x10
// ECMA_OBJECT_TYPE_HOST /**< Host object */
} ecma_object_type_t; /**
* Extensible object.
*/
#define ECMA_OBJECT_FLAG_EXTENSIBLE 0x20
/**
* Value for increasing or decreasing the object reference counter.
*/
#define ECMA_OBJECT_REF_ONE (1u << 6)
/**
* Maximum value of the object reference counter (1023).
*/
#define ECMA_OBJECT_MAX_REF (0x3ffu << 6)
/** /**
* Description of ECMA-object or lexical environment * Description of ECMA-object or lexical environment
@@ -315,115 +355,24 @@ typedef enum
*/ */
typedef struct ecma_object_t typedef struct ecma_object_t
{ {
/* Common part for objects and lexical environments */ /** type : 3 bit : ecma_object_type_t or ecma_lexical_environment_type_t
depending on ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV
flags : 3 bit : ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV,
ECMA_OBJECT_FLAG_GC_VISITED,
ECMA_OBJECT_FLAG_EXTENSIBLE
refs : 10 bit (max 1023) */
uint16_t type_flags_refs;
/** /** next in the object chain maintained by the garbage collector */
* Compressed pointer to property list mem_cpointer_t gc_next_cp;
*/
#define ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS (0)
#define ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH (ECMA_POINTER_FIELD_WIDTH)
/** /** compressed pointer to property list or bound object */
* Flag indicating whether it is a general object (false) mem_cpointer_t property_list_or_bound_object_cp;
* or a lexical environment (true)
*/
#define ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS (ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS + \
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH)
#define ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH (1)
/** /** object prototype or outer reference */
* Reference counter of the object, i.e. number of references mem_cpointer_t prototype_or_outer_reference_cp;
* to the object from stack variables.
*/
#define ECMA_OBJECT_GC_REFS_POS (ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS + \
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH)
#define ECMA_OBJECT_GC_REFS_WIDTH (CONFIG_ECMA_REFERENCE_COUNTER_WIDTH)
/**
* Compressed pointer to next object in the global list of objects with same generation.
*/
#define ECMA_OBJECT_GC_NEXT_CP_POS (ECMA_OBJECT_GC_REFS_POS + \
ECMA_OBJECT_GC_REFS_WIDTH)
#define ECMA_OBJECT_GC_NEXT_CP_WIDTH (ECMA_POINTER_FIELD_WIDTH)
/**
* Marker that is set if the object was visited during graph traverse.
*/
#define ECMA_OBJECT_GC_VISITED_POS (ECMA_OBJECT_GC_NEXT_CP_POS + \
ECMA_OBJECT_GC_NEXT_CP_WIDTH)
#define ECMA_OBJECT_GC_VISITED_WIDTH (1)
/* Objects' only part */
/**
* Attribute 'Extensible'
*/
#define ECMA_OBJECT_OBJ_EXTENSIBLE_POS (ECMA_OBJECT_GC_VISITED_POS + \
ECMA_OBJECT_GC_VISITED_WIDTH)
#define ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH (1)
/**
* Implementation internal object type (ecma_object_type_t)
*/
#define ECMA_OBJECT_OBJ_TYPE_POS (ECMA_OBJECT_OBJ_EXTENSIBLE_POS + \
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH)
#define ECMA_OBJECT_OBJ_TYPE_WIDTH (3)
/**
* Compressed pointer to prototype object (ecma_object_t)
*/
#define ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS (ECMA_OBJECT_OBJ_TYPE_POS + \
ECMA_OBJECT_OBJ_TYPE_WIDTH)
#define ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH (ECMA_POINTER_FIELD_WIDTH)
/**
* Flag indicating whether the object is a built-in object
*/
#define ECMA_OBJECT_OBJ_IS_BUILTIN_POS (ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS + \
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH)
#define ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH (1)
/**
* Size of structure for objects
*/
#define ECMA_OBJECT_OBJ_TYPE_SIZE (ECMA_OBJECT_OBJ_IS_BUILTIN_POS + \
ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH)
/* Lexical environments' only part */
/**
* Type of lexical environment (ecma_lexical_environment_type_t).
*/
#define ECMA_OBJECT_LEX_ENV_TYPE_POS (ECMA_OBJECT_GC_VISITED_POS + \
ECMA_OBJECT_GC_VISITED_WIDTH)
#define ECMA_OBJECT_LEX_ENV_TYPE_WIDTH (1)
/**
* Compressed pointer to outer lexical environment
*/
#define ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS (ECMA_OBJECT_LEX_ENV_TYPE_POS + \
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH)
#define ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH (ECMA_POINTER_FIELD_WIDTH)
/**
* 'provideThis' property of object-bound lexical environments
*/
#define ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS (ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS + \
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH)
#define ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH (1)
/**
* Size of structure for lexical environments
*/
#define ECMA_OBJECT_LEX_ENV_TYPE_SIZE (ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS + \
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH)
uint64_t container; /**< container for fields described above */
} ecma_object_t; } ecma_object_t;
/** /**
* Description of ECMA property descriptor * Description of ECMA property descriptor
* *
+131 -177
View File
@@ -30,6 +30,48 @@
#include "byte-code.h" #include "byte-code.h"
#include "re-compiler.h" #include "re-compiler.h"
/**
* The ecma object types must be lower than the container mask.
*/
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK >= ECMA_OBJECT_TYPE__MAX,
ecma_object_types_must_be_lower_than_the_container_mask);
/**
* The ecma lexical environment types must be lower than the container mask.
*/
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK >= ECMA_LEXICAL_ENVIRONMENT_TYPE__MAX,
ecma_lexical_environment_types_must_be_lower_than_the_container_mask);
/**
* The ecma built in flag must follow the object type.
*/
JERRY_STATIC_ASSERT (ECMA_OBJECT_TYPE_MASK + 1 == ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV,
ecma_built_in_flag_must_follow_the_object_type);
/**
* The ecma gc visited flag must follow the built in flag.
*/
JERRY_STATIC_ASSERT (ECMA_OBJECT_FLAG_GC_VISITED == (ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV << 1),
ecma_gc_visited_flag_must_follow_the_built_in_flag);
/**
* The ecma extensible flag must follow the gc visited flag.
*/
JERRY_STATIC_ASSERT (ECMA_OBJECT_FLAG_EXTENSIBLE == (ECMA_OBJECT_FLAG_GC_VISITED << 1),
ecma_extensible_flag_must_follow_the_gc_visited_flag);
/**
* The ecma object ref one must follow the extensible flag.
*/
JERRY_STATIC_ASSERT (ECMA_OBJECT_REF_ONE == (ECMA_OBJECT_FLAG_EXTENSIBLE << 1),
ecma_object_ref_one_must_follow_the_extensible_flag);
/**
* The ecma object max ref does not fill the remaining bits.
*/
JERRY_STATIC_ASSERT ((ECMA_OBJECT_MAX_REF | (ECMA_OBJECT_REF_ONE - 1)) == UINT16_MAX,
ecma_object_max_ref_does_not_fill_the_remaining_bits);
/** /**
* Create an object with specified prototype object * Create an object with specified prototype object
* (or NULL prototype if there is not prototype for the object) * (or NULL prototype if there is not prototype for the object)
@@ -44,38 +86,25 @@ ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe
bool is_extensible, /**< value of extensible attribute */ bool is_extensible, /**< value of extensible attribute */
ecma_object_type_t type) /**< object type */ ecma_object_type_t type) /**< object type */
{ {
ecma_object_t *object_p = ecma_alloc_object (); ecma_object_t *new_object_p = ecma_alloc_object ();
ecma_init_gc_info (object_p); uint16_t type_flags = (uint16_t) type;
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container, if (is_extensible)
ECMA_NULL_POINTER, {
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS, type_flags = (uint16_t) (type_flags | ECMA_OBJECT_FLAG_EXTENSIBLE);
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH); }
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
false,
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
is_extensible,
ECMA_OBJECT_OBJ_EXTENSIBLE_POS,
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH);
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
type,
ECMA_OBJECT_OBJ_TYPE_POS,
ECMA_OBJECT_OBJ_TYPE_WIDTH);
uint64_t prototype_object_cp; new_object_p->type_flags_refs = type_flags;
ECMA_SET_POINTER (prototype_object_cp, prototype_object_p);
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container, ecma_init_gc_info (new_object_p);
prototype_object_cp,
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
ecma_set_object_is_builtin (object_p, false); new_object_p->property_list_or_bound_object_cp = MEM_CP_NULL;
return object_p; ECMA_SET_POINTER (new_object_p->prototype_or_outer_reference_cp,
prototype_object_p);
return new_object_p;
} /* ecma_create_object */ } /* ecma_create_object */
/** /**
@@ -93,37 +122,15 @@ ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer
{ {
ecma_object_t *new_lexical_environment_p = ecma_alloc_object (); ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
uint16_t type = ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE;
new_lexical_environment_p->type_flags_refs = type;
ecma_init_gc_info (new_lexical_environment_p); ecma_init_gc_info (new_lexical_environment_p);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container, new_lexical_environment_p->property_list_or_bound_object_cp = MEM_CP_NULL;
ECMA_NULL_POINTER,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
true,
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container, ECMA_SET_POINTER (new_lexical_environment_p->prototype_or_outer_reference_cp,
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, outer_lexical_environment_p);
ECMA_OBJECT_LEX_ENV_TYPE_POS,
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
uint64_t outer_reference_cp;
ECMA_SET_POINTER (outer_reference_cp, outer_lexical_environment_p);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
outer_reference_cp,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
/*
* Declarative lexical environments do not really have the flag,
* but to not leave the value initialized, setting the flag to false.
*/
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
false,
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH);
return new_lexical_environment_p; return new_lexical_environment_p;
} /* ecma_create_decl_lex_env */ } /* ecma_create_decl_lex_env */
@@ -148,36 +155,26 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
ecma_object_t *new_lexical_environment_p = ecma_alloc_object (); ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
uint16_t type;
if (provide_this)
{
type = ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND;
}
else
{
type = ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND;
}
new_lexical_environment_p->type_flags_refs = type;
ecma_init_gc_info (new_lexical_environment_p); ecma_init_gc_info (new_lexical_environment_p);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container, ECMA_SET_NON_NULL_POINTER (new_lexical_environment_p->property_list_or_bound_object_cp,
true, binding_obj_p);
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container, ECMA_SET_POINTER (new_lexical_environment_p->prototype_or_outer_reference_cp,
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND, outer_lexical_environment_p);
ECMA_OBJECT_LEX_ENV_TYPE_POS,
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
uint64_t outer_reference_cp;
ECMA_SET_POINTER (outer_reference_cp, outer_lexical_environment_p);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
outer_reference_cp,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
provide_this,
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH);
uint64_t bound_object_cp;
ECMA_SET_NON_NULL_POINTER (bound_object_cp, binding_obj_p);
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
bound_object_cp,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
return new_lexical_environment_p; return new_lexical_environment_p;
} /* ecma_create_object_lex_env */ } /* ecma_create_object_lex_env */
@@ -185,91 +182,84 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
/** /**
* Check if the object is lexical environment. * Check if the object is lexical environment.
*/ */
bool __attr_pure___ inline bool __attr_pure___
ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */ ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
return (bool) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container, uint32_t full_type = object_p->type_flags_refs & (ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_OBJECT_TYPE_MASK);
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH); return full_type >= (ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV | ECMA_LEXICAL_ENVIRONMENT_TYPE_START);
} /* ecma_is_lexical_environment */ } /* ecma_is_lexical_environment */
/** /**
* Get value of [[Extensible]] object's internal property. * Get value of [[Extensible]] object's internal property.
*/ */
bool __attr_pure___ inline bool __attr_pure___
ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */ ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
return (bool) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container, return (object_p->type_flags_refs & ECMA_OBJECT_FLAG_EXTENSIBLE) != 0;
ECMA_OBJECT_OBJ_EXTENSIBLE_POS,
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH);
} /* ecma_get_object_extensible */ } /* ecma_get_object_extensible */
/** /**
* Set value of [[Extensible]] object's internal property. * Set value of [[Extensible]] object's internal property.
*/ */
void inline void
ecma_set_object_extensible (ecma_object_t *object_p, /**< object */ ecma_set_object_extensible (ecma_object_t *object_p, /**< object */
bool is_extensible) /**< value of [[Extensible]] */ bool is_extensible) /**< value of [[Extensible]] */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container, if (is_extensible)
is_extensible, {
ECMA_OBJECT_OBJ_EXTENSIBLE_POS, object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_FLAG_EXTENSIBLE);
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH); }
else
{
object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs & ~ECMA_OBJECT_FLAG_EXTENSIBLE);
}
} /* ecma_set_object_extensible */ } /* ecma_set_object_extensible */
/** /**
* Get object's internal implementation-defined type. * Get object's internal implementation-defined type.
*/ */
ecma_object_type_t __attr_pure___ inline ecma_object_type_t __attr_pure___
ecma_get_object_type (const ecma_object_t *object_p) /**< object */ ecma_get_object_type (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
return (ecma_object_type_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container, return (ecma_object_type_t) (object_p->type_flags_refs & ECMA_OBJECT_TYPE_MASK);
ECMA_OBJECT_OBJ_TYPE_POS,
ECMA_OBJECT_OBJ_TYPE_WIDTH);
} /* ecma_get_object_type */ } /* ecma_get_object_type */
/** /**
* Set object's internal implementation-defined type. * Set object's internal implementation-defined type.
*/ */
void inline void
ecma_set_object_type (ecma_object_t *object_p, /**< object */ ecma_set_object_type (ecma_object_t *object_p, /**< object */
ecma_object_type_t type) /**< type */ ecma_object_type_t type) /**< type */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!(object_p->type_flags_refs & ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV));
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container, object_p->type_flags_refs = (uint16_t) ((object_p->type_flags_refs & ~ECMA_OBJECT_TYPE_MASK) | type);
type,
ECMA_OBJECT_OBJ_TYPE_POS,
ECMA_OBJECT_OBJ_TYPE_WIDTH);
} /* ecma_set_object_type */ } /* ecma_set_object_type */
/** /**
* Get object's prototype. * Get object's prototype.
*/ */
ecma_object_t *__attr_pure___ inline ecma_object_t *__attr_pure___
ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */ ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
uintptr_t prototype_object_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
return ECMA_GET_POINTER (ecma_object_t, return ECMA_GET_POINTER (ecma_object_t,
prototype_object_cp); object_p->prototype_or_outer_reference_cp);
} /* ecma_get_object_prototype */ } /* ecma_get_object_prototype */
/** /**
@@ -277,72 +267,51 @@ ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
* *
* @return true / false * @return true / false
*/ */
bool __attr_pure___ inline bool __attr_pure___
ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */ ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
const uint32_t offset = ECMA_OBJECT_OBJ_IS_BUILTIN_POS; return (object_p->type_flags_refs & ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV) != 0;
const uint32_t width = ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH;
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= width);
uintptr_t flag_value = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
offset,
width);
return (bool) flag_value;
} /* ecma_get_object_is_builtin */ } /* ecma_get_object_is_builtin */
/** /**
* Set flag indicating whether the object is a built-in object * Set flag indicating whether the object is a built-in object
*/ */
void inline void
ecma_set_object_is_builtin (ecma_object_t *object_p, /**< object */ ecma_set_object_is_builtin (ecma_object_t *object_p) /**< object */
bool is_builtin) /**< value of flag */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p)); JERRY_ASSERT (!(object_p->type_flags_refs & ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV));
JERRY_ASSERT ((object_p->type_flags_refs & ECMA_OBJECT_TYPE_MASK) < ECMA_LEXICAL_ENVIRONMENT_TYPE_START);
const uint32_t offset = ECMA_OBJECT_OBJ_IS_BUILTIN_POS; object_p->type_flags_refs = (uint16_t) (object_p->type_flags_refs | ECMA_OBJECT_FLAG_BUILT_IN_OR_LEXICAL_ENV);
const uint32_t width = ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH;
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
is_builtin,
offset,
width);
} /* ecma_set_object_is_builtin */ } /* ecma_set_object_is_builtin */
/** /**
* Get type of lexical environment. * Get type of lexical environment.
*/ */
ecma_lexical_environment_type_t __attr_pure___ inline ecma_lexical_environment_type_t __attr_pure___
ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p)); JERRY_ASSERT (ecma_is_lexical_environment (object_p));
return (ecma_lexical_environment_type_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container, return (ecma_lexical_environment_type_t) (object_p->type_flags_refs & ECMA_OBJECT_TYPE_MASK);
ECMA_OBJECT_LEX_ENV_TYPE_POS,
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
} /* ecma_get_lex_env_type */ } /* ecma_get_lex_env_type */
/** /**
* Get outer reference of lexical environment. * Get outer reference of lexical environment.
*/ */
ecma_object_t *__attr_pure___ inline ecma_object_t *__attr_pure___
ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical environment */ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p)); JERRY_ASSERT (ecma_is_lexical_environment (object_p));
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
uintptr_t outer_reference_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
return ECMA_GET_POINTER (ecma_object_t, return ECMA_GET_POINTER (ecma_object_t,
outer_reference_cp); object_p->prototype_or_outer_reference_cp);
} /* ecma_get_lex_env_outer_reference */ } /* ecma_get_lex_env_outer_reference */
/** /**
@@ -351,19 +320,15 @@ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical en
* See also: * See also:
* ecma_op_object_get_property_names * ecma_op_object_get_property_names
*/ */
ecma_property_t *__attr_pure___ inline ecma_property_t *__attr_pure___
ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical environment */ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p) || JERRY_ASSERT (!ecma_is_lexical_environment (object_p)
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE); || ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
uintptr_t properties_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
return ECMA_GET_POINTER (ecma_property_t, return ECMA_GET_POINTER (ecma_property_t,
properties_cp); object_p->property_list_or_bound_object_cp);
} /* ecma_get_property_list */ } /* ecma_get_property_list */
/** /**
@@ -372,56 +337,45 @@ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical en
* See also: * See also:
* ecma_op_object_get_property_names * ecma_op_object_get_property_names
*/ */
static void static inline void
ecma_set_property_list (ecma_object_t *object_p, /**< object or lexical environment */ ecma_set_property_list (ecma_object_t *object_p, /**< object or lexical environment */
ecma_property_t *property_list_p) /**< properties' list */ ecma_property_t *property_list_p) /**< properties' list */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (!ecma_is_lexical_environment (object_p) || JERRY_ASSERT (!ecma_is_lexical_environment (object_p)
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE); || ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
uint64_t properties_cp; ECMA_SET_POINTER (object_p->property_list_or_bound_object_cp,
ECMA_SET_POINTER (properties_cp, property_list_p); property_list_p);
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
properties_cp,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
} /* ecma_set_property_list */ } /* ecma_set_property_list */
/** /**
* Get lexical environment's 'provideThis' property * Get lexical environment's 'provideThis' property
*/ */
bool __attr_pure___ inline bool __attr_pure___
ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound lexical environment */ ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p) && JERRY_ASSERT (ecma_is_lexical_environment (object_p));
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH); return ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND;
bool provide_this = (JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH) != 0);
return provide_this;
} /* ecma_get_lex_env_provide_this */ } /* ecma_get_lex_env_provide_this */
/** /**
* Get lexical environment's bound object. * Get lexical environment's bound object.
*/ */
ecma_object_t *__attr_pure___ inline ecma_object_t *__attr_pure___
ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-bound lexical environment */
{ {
JERRY_ASSERT (object_p != NULL); JERRY_ASSERT (object_p != NULL);
JERRY_ASSERT (ecma_is_lexical_environment (object_p) && JERRY_ASSERT (ecma_is_lexical_environment (object_p));
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH); return ECMA_GET_NON_NULL_POINTER (ecma_object_t,
uintptr_t object_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container, object_p->property_list_or_bound_object_cp);
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
return ECMA_GET_NON_NULL_POINTER (ecma_object_t, object_cp);
} /* ecma_get_lex_env_binding_object */ } /* ecma_get_lex_env_binding_object */
/** /**
+1 -1
View File
@@ -180,7 +180,7 @@ extern ecma_object_type_t ecma_get_object_type (const ecma_object_t *) __attr_pu
extern void ecma_set_object_type (ecma_object_t *, ecma_object_type_t); extern void ecma_set_object_type (ecma_object_t *, ecma_object_type_t);
extern ecma_object_t *ecma_get_object_prototype (const ecma_object_t *) __attr_pure___; extern ecma_object_t *ecma_get_object_prototype (const ecma_object_t *) __attr_pure___;
extern bool ecma_get_object_is_builtin (const ecma_object_t *) __attr_pure___; extern bool ecma_get_object_is_builtin (const ecma_object_t *) __attr_pure___;
extern void ecma_set_object_is_builtin (ecma_object_t *, bool); extern void ecma_set_object_is_builtin (ecma_object_t *);
extern ecma_lexical_environment_type_t ecma_get_lex_env_type (const ecma_object_t *) __attr_pure___; extern ecma_lexical_environment_type_t ecma_get_lex_env_type (const ecma_object_t *) __attr_pure___;
extern ecma_object_t *ecma_get_lex_env_outer_reference (const ecma_object_t *) __attr_pure___; extern ecma_object_t *ecma_get_lex_env_outer_reference (const ecma_object_t *) __attr_pure___;
extern ecma_property_t *ecma_get_property_list (const ecma_object_t *) __attr_pure___; extern ecma_property_t *ecma_get_property_list (const ecma_object_t *) __attr_pure___;
@@ -113,7 +113,7 @@ ecma_builtin_init_object (ecma_builtin_id_t obj_builtin_id, /**< built-in ID */
ECMA_INTERNAL_PROPERTY_BUILT_IN_ID); ECMA_INTERNAL_PROPERTY_BUILT_IN_ID);
built_in_id_prop_p->v.internal_property.value = obj_builtin_id; built_in_id_prop_p->v.internal_property.value = obj_builtin_id;
ecma_set_object_is_builtin (object_obj_p, true); ecma_set_object_is_builtin (object_obj_p);
/** Initializing [[PrimitiveValue]] properties of built-in prototype objects */ /** Initializing [[PrimitiveValue]] properties of built-in prototype objects */
switch (obj_builtin_id) switch (obj_builtin_id)
@@ -474,7 +474,7 @@ ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**
ecma_deref_object (prototype_obj_p); ecma_deref_object (prototype_obj_p);
ecma_set_object_is_builtin (func_obj_p, true); ecma_set_object_is_builtin (func_obj_p);
uint64_t packed_value = JRT_SET_BIT_FIELD_VALUE (uint64_t, 0ull, uint64_t packed_value = JRT_SET_BIT_FIELD_VALUE (uint64_t, 0ull,
builtin_id, builtin_id,
+12 -6
View File
@@ -126,7 +126,8 @@ ecma_op_has_binding (ecma_object_t *lex_env_p, /**< lexical environment */
} }
else else
{ {
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
@@ -159,7 +160,8 @@ ecma_op_create_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environme
} }
else else
{ {
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
@@ -218,7 +220,8 @@ ecma_op_set_mutable_binding (ecma_object_t *lex_env_p, /**< lexical environment
} }
else else
{ {
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
@@ -282,7 +285,8 @@ ecma_op_get_binding_value (ecma_object_t *lex_env_p, /**< lexical environment */
} }
else else
{ {
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
@@ -349,7 +353,8 @@ ecma_op_delete_binding (ecma_object_t *lex_env_p, /**< lexical environment */
} }
else else
{ {
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p); ecma_object_t *binding_obj_p = ecma_get_lex_env_binding_object (lex_env_p);
@@ -377,7 +382,8 @@ ecma_op_implicit_this_value (ecma_object_t *lex_env_p) /**< lexical environment
} }
else else
{ {
JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND); JERRY_ASSERT (ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECT_BOUND
|| ecma_get_lex_env_type (lex_env_p) == ECMA_LEXICAL_ENVIRONMENT_THIS_OBJECT_BOUND);
if (ecma_get_lex_env_provide_this (lex_env_p)) if (ecma_get_lex_env_provide_this (lex_env_p))
{ {