Styles fixes in libecmaobjects, libecmaoperations: indentation and braces rules.

This commit is contained in:
Ruben Ayrapetyan
2014-08-11 22:04:53 +04:00
parent 38c6c2357d
commit 48cff24f08
15 changed files with 1676 additions and 1632 deletions
+21 -21
View File
@@ -55,30 +55,30 @@ JERRY_STATIC_ASSERT(sizeof (ecma_completion_value_t) == sizeof (uint32_t));
* FIXME: Run GC only if allocation failed.
*/
#define ALLOC(ecma_type) ecma_ ## ecma_type ## _t * \
ecma_alloc_ ## ecma_type (void) \
ecma_alloc_ ## ecma_type (void) \
{ \
ecma_ ## ecma_type ## _t *p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
mem_pools_alloc (); \
mem_pools_alloc (); \
\
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
\
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
gen_id < ECMA_GC_GEN_COUNT; \
gen_id++) \
{ \
ecma_gc_run (gen_id); \
\
p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
mem_pools_alloc (); \
\
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
\
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
gen_id < ECMA_GC_GEN_COUNT; \
gen_id++) \
{ \
ecma_gc_run (gen_id); \
\
p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
mem_pools_alloc (); \
\
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
} \
} \
JERRY_UNREACHABLE(); \
}
@@ -86,17 +86,17 @@ ecma_alloc_ ## ecma_type (void) \
* Deallocation routine template
*/
#define DEALLOC(ecma_type) void \
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *p ## ecma_type) \
ecma_dealloc_ ## ecma_type (ecma_ ## ecma_type ## _t *p ## ecma_type) \
{ \
mem_pools_free ((uint8_t*) p ## ecma_type); \
mem_pools_free ((uint8_t*) p ## ecma_type); \
}
/**
* Declaration of alloc/free routine for specified ecma-type.
*/
#define DECLARE_ROUTINES_FOR(ecma_type) \
ALLOC(ecma_type) \
DEALLOC(ecma_type)
ALLOC(ecma_type) \
DEALLOC(ecma_type)
DECLARE_ROUTINES_FOR (object)
DECLARE_ROUTINES_FOR (property)
+220 -220
View File
@@ -72,9 +72,9 @@ ecma_ref_object (ecma_object_t *object_p) /**< object */
JERRY_ASSERT(object_p->gc_info.refs > 0);
if (unlikely (object_p->gc_info.refs == 0))
{
JERRY_UNREACHABLE();
}
{
JERRY_UNREACHABLE();
}
} /* ecma_ref_object */
/**
@@ -99,9 +99,9 @@ ecma_gc_update_may_ref_younger_object_flag_by_value (ecma_object_t *obj_p, /**<
ecma_value_t value) /**< value */
{
if (value.value_type != ECMA_TYPE_OBJECT)
{
return;
}
{
return;
}
ecma_object_t *ref_obj_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(ref_obj_p != NULL);
@@ -115,14 +115,14 @@ ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, /**<
or NULL */
{
if (ref_obj_p == NULL)
{
return;
}
{
return;
}
if (ref_obj_p->gc_info.generation < obj_p->gc_info.generation)
{
obj_p->gc_info.may_ref_younger_objects = true;
}
{
obj_p->gc_info.may_ref_younger_objects = true;
}
} /* ecma_gc_update_may_ref_younger_object_flag_by_object */
/**
@@ -151,145 +151,145 @@ ecma_gc_mark (ecma_object_t *object_p, /**< start object */
bool does_reference_object_to_traverse = false;
if (object_p->is_lexical_environment)
{
ecma_object_t *lex_env_p = ECMA_GET_POINTER(object_p->u.lexical_environment.outer_reference_p);
if (lex_env_p != NULL
&& lex_env_p->gc_info.generation <= maximum_gen_to_traverse)
{
ecma_object_t *lex_env_p = ECMA_GET_POINTER(object_p->u.lexical_environment.outer_reference_p);
if (lex_env_p != NULL
&& lex_env_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!lex_env_p->gc_info.visited)
{
ecma_gc_mark (lex_env_p, ECMA_GC_GEN_COUNT);
}
if (!lex_env_p->gc_info.visited)
{
ecma_gc_mark (lex_env_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
does_reference_object_to_traverse = true;
}
}
else
{
ecma_object_t *proto_p = ECMA_GET_POINTER(object_p->u.object.prototype_object_p);
if (proto_p != NULL
&& proto_p->gc_info.generation <= maximum_gen_to_traverse)
{
ecma_object_t *proto_p = ECMA_GET_POINTER(object_p->u.object.prototype_object_p);
if (proto_p != NULL
&& proto_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!proto_p->gc_info.visited)
{
ecma_gc_mark (proto_p, ECMA_GC_GEN_COUNT);
}
if (!proto_p->gc_info.visited)
{
ecma_gc_mark (proto_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
does_reference_object_to_traverse = true;
}
}
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p), *next_property_p;
property_p != NULL;
property_p = next_property_p)
property_p != NULL;
property_p = next_property_p)
{
next_property_p = ECMA_GET_POINTER(property_p->next_property_p);
switch ((ecma_property_type_t) property_p->type)
{
next_property_p = ECMA_GET_POINTER(property_p->next_property_p);
case ECMA_PROPERTY_NAMEDDATA:
{
ecma_value_t value = property_p->u.named_data_property.value;
switch ((ecma_property_type_t) property_p->type)
if (value.value_type == ECMA_TYPE_OBJECT)
{
case ECMA_PROPERTY_NAMEDDATA:
ecma_object_t *value_obj_p = ECMA_GET_POINTER(value.value);
if (value_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!value_obj_p->gc_info.visited)
{
ecma_value_t value = property_p->u.named_data_property.value;
if (value.value_type == ECMA_TYPE_OBJECT)
{
ecma_object_t *value_obj_p = ECMA_GET_POINTER(value.value);
if (value_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!value_obj_p->gc_info.visited)
{
ecma_gc_mark (value_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
}
break;
ecma_gc_mark (value_obj_p, ECMA_GC_GEN_COUNT);
}
case ECMA_PROPERTY_NAMEDACCESSOR:
{
ecma_object_t *getter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.get_p);
ecma_object_t *setter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.set_p);
if (getter_obj_p != NULL)
{
if (getter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!getter_obj_p->gc_info.visited)
{
ecma_gc_mark (getter_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
}
if (setter_obj_p != NULL)
{
if (setter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!setter_obj_p->gc_info.visited)
{
ecma_gc_mark (setter_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
}
break;
}
case ECMA_PROPERTY_INTERNAL:
{
ecma_internal_property_id_t property_id = property_p->u.internal_property.type;
uint32_t property_value = property_p->u.internal_property.value;
switch (property_id)
{
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
case ECMA_INTERNAL_PROPERTY_PROTOTYPE: /* the property's value is located in ecma_object_t */
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t */
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
{
break;
}
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
{
ecma_object_t *obj_p = ECMA_GET_POINTER(property_value);
if (obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!obj_p->gc_info.visited)
{
ecma_gc_mark (obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
break;
}
}
break;
}
does_reference_object_to_traverse = true;
}
}
break;
}
case ECMA_PROPERTY_NAMEDACCESSOR:
{
ecma_object_t *getter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.get_p);
ecma_object_t *setter_obj_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.set_p);
if (getter_obj_p != NULL)
{
if (getter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!getter_obj_p->gc_info.visited)
{
ecma_gc_mark (getter_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
}
if (setter_obj_p != NULL)
{
if (setter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!setter_obj_p->gc_info.visited)
{
ecma_gc_mark (setter_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
}
break;
}
case ECMA_PROPERTY_INTERNAL:
{
ecma_internal_property_id_t property_id = property_p->u.internal_property.type;
uint32_t property_value = property_p->u.internal_property.value;
switch (property_id)
{
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
case ECMA_INTERNAL_PROPERTY_PROTOTYPE: /* the property's value is located in ecma_object_t */
case ECMA_INTERNAL_PROPERTY_EXTENSIBLE: /* the property's value is located in ecma_object_t */
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
{
break;
}
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
{
ecma_object_t *obj_p = ECMA_GET_POINTER(property_value);
if (obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if (!obj_p->gc_info.visited)
{
ecma_gc_mark (obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
break;
}
}
break;
}
}
}
if (!does_reference_object_to_traverse)
{
object_p->gc_info.may_ref_younger_objects = false;
}
{
object_p->gc_info.may_ref_younger_objects = false;
}
} /* ecma_gc_mark */
/**
@@ -299,18 +299,18 @@ void
ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
{
JERRY_ASSERT(object_p != NULL
&& !object_p->gc_info.visited
&& object_p->gc_info.refs == 0);
&& !object_p->gc_info.visited
&& object_p->gc_info.refs == 0);
for (ecma_property_t *property = ECMA_GET_POINTER(object_p->properties_p),
*next_property_p;
property != NULL;
property = next_property_p)
{
next_property_p = ECMA_GET_POINTER(property->next_property_p);
*next_property_p;
property != NULL;
property = next_property_p)
{
next_property_p = ECMA_GET_POINTER(property->next_property_p);
ecma_free_property (property);
}
ecma_free_property (property);
}
ecma_dealloc_object (object_p);
} /* ecma_gc_sweep */
@@ -325,46 +325,46 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
/* clearing visited flags for all objects of generations to be processed */
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
obj_iter_p->gc_info.visited = false;
}
obj_iter_p->gc_info.visited = false;
}
}
/* if some object is referenced from stack or globals (i.e. it is root),
* start recursive marking traverse from the object */
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
if (obj_iter_p->gc_info.refs > 0
&& !obj_iter_p->gc_info.visited)
{
ecma_gc_mark (obj_iter_p, ECMA_GC_GEN_COUNT);
}
}
if (obj_iter_p->gc_info.refs > 0
&& !obj_iter_p->gc_info.visited)
{
ecma_gc_mark (obj_iter_p, ECMA_GC_GEN_COUNT);
}
}
}
/* if some object from generations that are not processed during current session may reference
* younger generations, start recursive marking traverse from the object, but one the first level
* consider only references to object of at most max_gen_to_collect generation */
for (ecma_gc_gen_t gen_id = max_gen_to_collect + 1; gen_id < ECMA_GC_GEN_COUNT; gen_id++)
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
if (obj_iter_p->gc_info.may_ref_younger_objects > 0)
{
ecma_gc_mark (obj_iter_p, max_gen_to_collect);
}
}
if (obj_iter_p->gc_info.may_ref_younger_objects > 0)
{
ecma_gc_mark (obj_iter_p, max_gen_to_collect);
}
}
}
ecma_object_t *gen_last_obj_p[ max_gen_to_collect + 1 ];
#ifndef JERRY_NDEBUG
@@ -372,79 +372,79 @@ ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
#endif /* !JERRY_NDEBUG */
for (ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++)
{
ecma_object_t *obj_prev_p = NULL;
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ],
*obj_next_p;
obj_iter_p != NULL;
obj_iter_p = obj_next_p)
{
ecma_object_t *obj_prev_p = NULL;
obj_next_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next);
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ],
*obj_next_p;
obj_iter_p != NULL;
obj_iter_p = obj_next_p)
if (!obj_iter_p->gc_info.visited)
{
ecma_gc_sweep (obj_iter_p);
if (likely (obj_prev_p != NULL))
{
obj_next_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next);
if (!obj_iter_p->gc_info.visited)
{
ecma_gc_sweep (obj_iter_p);
if (likely (obj_prev_p != NULL))
{
ECMA_SET_POINTER(obj_prev_p->gc_info.next, obj_next_p);
}
else
{
ecma_gc_objects_lists[ gen_id ] = obj_next_p;
}
}
else
{
obj_prev_p = obj_iter_p;
if (obj_iter_p->gc_info.generation != ECMA_GC_GEN_COUNT - 1)
{
/* the object will be promoted to next generation */
obj_iter_p->gc_info.generation++;
}
}
ECMA_SET_POINTER(obj_prev_p->gc_info.next, obj_next_p);
}
else
{
ecma_gc_objects_lists[ gen_id ] = obj_next_p;
}
}
else
{
obj_prev_p = obj_iter_p;
gen_last_obj_p[ gen_id ] = obj_prev_p;
if (obj_iter_p->gc_info.generation != ECMA_GC_GEN_COUNT - 1)
{
/* the object will be promoted to next generation */
obj_iter_p->gc_info.generation++;
}
}
}
gen_last_obj_p[ gen_id ] = obj_prev_p;
}
ecma_gc_gen_t gen_to_promote = max_gen_to_collect;
if (unlikely (gen_to_promote == ECMA_GC_GEN_COUNT - 1))
{
/* not promoting last generation */
gen_to_promote--;
}
{
/* not promoting last generation */
gen_to_promote--;
}
/* promoting to next generation */
if (gen_last_obj_p[ gen_to_promote ] != NULL)
{
ECMA_SET_POINTER(gen_last_obj_p[ gen_to_promote ]->gc_info.next, ecma_gc_objects_lists[ gen_to_promote + 1 ]);
ecma_gc_objects_lists[ gen_to_promote + 1 ] = ecma_gc_objects_lists[ gen_to_promote ];
ecma_gc_objects_lists[ gen_to_promote ] = NULL;
}
{
ECMA_SET_POINTER(gen_last_obj_p[ gen_to_promote ]->gc_info.next, ecma_gc_objects_lists[ gen_to_promote + 1 ]);
ecma_gc_objects_lists[ gen_to_promote + 1 ] = ecma_gc_objects_lists[ gen_to_promote ];
ecma_gc_objects_lists[ gen_to_promote ] = NULL;
}
for (int32_t gen_id = (int32_t)gen_to_promote - 1;
gen_id >= 0;
gen_id--)
{
ecma_gc_objects_lists[ gen_id + 1 ] = ecma_gc_objects_lists[ gen_id ];
ecma_gc_objects_lists[ gen_id ] = NULL;
}
gen_id >= 0;
gen_id--)
{
ecma_gc_objects_lists[ gen_id + 1 ] = ecma_gc_objects_lists[ gen_id ];
ecma_gc_objects_lists[ gen_id ] = NULL;
}
#ifndef JERRY_NDEBUG
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0;
gen_id < ECMA_GC_GEN_COUNT;
gen_id++)
gen_id < ECMA_GC_GEN_COUNT;
gen_id++)
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
for (ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ gen_id ];
obj_iter_p != NULL;
obj_iter_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
JERRY_ASSERT(obj_iter_p->gc_info.generation == gen_id);
}
JERRY_ASSERT(obj_iter_p->gc_info.generation == gen_id);
}
}
#endif /* !JERRY_NDEBUG */
} /* ecma_gc_run */
+229 -207
View File
@@ -51,42 +51,45 @@
/**
* Type of ecma-value
*/
typedef enum {
ECMA_TYPE_SIMPLE, /**< simple value */
ECMA_TYPE_NUMBER, /**< 64-bit integer */
ECMA_TYPE_STRING, /**< pointer to description of a string */
ECMA_TYPE_OBJECT, /**< pointer to description of an object */
ECMA_TYPE__COUNT /**< count of types */
typedef enum
{
ECMA_TYPE_SIMPLE, /**< simple value */
ECMA_TYPE_NUMBER, /**< 64-bit integer */
ECMA_TYPE_STRING, /**< pointer to description of a string */
ECMA_TYPE_OBJECT, /**< pointer to description of an object */
ECMA_TYPE__COUNT /**< count of types */
} ecma_type_t;
/**
* Simple ecma-values
*/
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.
*/
ECMA_SIMPLE_VALUE_EMPTY,
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
ECMA_SIMPLE_VALUE_NULL, /**< null value */
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exists,
but is stored directly in the array's property list
(used for array elements with non-default attribute values) */
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
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.
*/
ECMA_SIMPLE_VALUE_EMPTY,
ECMA_SIMPLE_VALUE_UNDEFINED, /**< undefined value */
ECMA_SIMPLE_VALUE_NULL, /**< null value */
ECMA_SIMPLE_VALUE_FALSE, /**< boolean false */
ECMA_SIMPLE_VALUE_TRUE, /**< boolean true */
ECMA_SIMPLE_VALUE_ARRAY_REDIRECT, /**< implementation defined value for an array's elements that exists,
but is stored directly in the array's property list
(used for array elements with non-default attribute values) */
ECMA_SIMPLE_VALUE__COUNT /** count of simple ecma-values */
} ecma_simple_value_t;
/**
* Type of ecma-property
*/
typedef enum {
ECMA_PROPERTY_NAMEDDATA, /**< named data property */
ECMA_PROPERTY_NAMEDACCESSOR, /**< named accessor property */
ECMA_PROPERTY_INTERNAL /**< internal property */
typedef enum
{
ECMA_PROPERTY_NAMEDDATA, /**< named data property */
ECMA_PROPERTY_NAMEDACCESSOR, /**< named accessor property */
ECMA_PROPERTY_INTERNAL /**< internal property */
} ecma_property_type_t;
/**
@@ -94,27 +97,29 @@ typedef enum {
*
* See also: ECMA-262 v5, 8.9.
*/
typedef enum {
ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */
ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */
ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */
ECMA_COMPLETION_TYPE_CONTINUE, /**< block completed with continue */
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
ECMA_COMPLETION_TYPE_EXIT /**< implementation-defined completion type
for finishing script execution */
typedef enum
{
ECMA_COMPLETION_TYPE_NORMAL, /**< default block completion */
ECMA_COMPLETION_TYPE_RETURN, /**< block completed with return */
ECMA_COMPLETION_TYPE_BREAK, /**< block completed with break */
ECMA_COMPLETION_TYPE_CONTINUE, /**< block completed with continue */
ECMA_COMPLETION_TYPE_THROW, /**< block completed with throw */
ECMA_COMPLETION_TYPE_EXIT /**< implementation-defined completion type
for finishing script execution */
} ecma_completion_type_t;
/**
* Description of an ecma-value
*/
typedef struct {
/** Value type (ecma_type_t) */
unsigned int value_type : 2;
typedef struct
{
/** Value type (ecma_type_t) */
unsigned int value_type : 2;
/**
* Simple value (ecma_simple_value_t) or compressed pointer to value (depending on value_type)
*/
unsigned int value : ECMA_POINTER_FIELD_WIDTH;
/**
* Simple value (ecma_simple_value_t) or compressed pointer to value (depending on value_type)
*/
unsigned int value : ECMA_POINTER_FIELD_WIDTH;
} __packed ecma_value_t;
/**
@@ -122,15 +127,16 @@ typedef struct {
*
* See also: ECMA-262 v5, 8.9.
*/
typedef struct {
/** Type (ecma_completion_type_t) */
unsigned int type : 3;
typedef struct
{
/** Type (ecma_completion_type_t) */
unsigned int type : 3;
/** Value */
ecma_value_t value;
/** Value */
ecma_value_t value;
/** Target */
unsigned int target : 8;
/** Target */
unsigned int target : 8;
} __packed ecma_completion_value_t;
/**
@@ -142,25 +148,26 @@ typedef struct {
/**
* Internal properties' identifiers.
*/
typedef enum {
ECMA_INTERNAL_PROPERTY_CLASS, /**< [[Class]] */
ECMA_INTERNAL_PROPERTY_PROTOTYPE, /**< [[Prototype]] */
ECMA_INTERNAL_PROPERTY_EXTENSIBLE, /**< [[Extensible]] */
ECMA_INTERNAL_PROPERTY_SCOPE, /**< [[Scope]] */
ECMA_INTERNAL_PROPERTY_CODE, /**< [[Code]] */
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS, /**< [[FormalParameters]] */
typedef enum
{
ECMA_INTERNAL_PROPERTY_CLASS, /**< [[Class]] */
ECMA_INTERNAL_PROPERTY_PROTOTYPE, /**< [[Prototype]] */
ECMA_INTERNAL_PROPERTY_EXTENSIBLE, /**< [[Extensible]] */
ECMA_INTERNAL_PROPERTY_SCOPE, /**< [[Scope]] */
ECMA_INTERNAL_PROPERTY_CODE, /**< [[Code]] */
ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS, /**< [[FormalParameters]] */
/** provideThis property of lexical environment */
ECMA_INTERNAL_PROPERTY_PROVIDE_THIS,
/** provideThis property of lexical environment */
ECMA_INTERNAL_PROPERTY_PROVIDE_THIS,
/** binding object of lexical environment */
ECMA_INTERNAL_PROPERTY_BINDING_OBJECT,
/** binding object of lexical environment */
ECMA_INTERNAL_PROPERTY_BINDING_OBJECT,
/** Part of an array, that is indexed by numbers */
ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES,
/** Part of an array, that is indexed by numbers */
ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES,
/** Part of an array, that is indexed by strings */
ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES
/** Part of an array, that is indexed by strings */
ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES
} ecma_internal_property_id_t;
/**
@@ -193,186 +200,198 @@ typedef enum
/**
* Description of ecma-property
*/
typedef struct ecma_property_t {
/** Property's type (ecma_property_type_t) */
unsigned int type : 2;
typedef struct ecma_property_t
{
/** Property's type (ecma_property_type_t) */
unsigned int type : 2;
/** Compressed pointer to next property */
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
/** Compressed pointer to next property */
unsigned int next_property_p : ECMA_POINTER_FIELD_WIDTH;
/** Property's details (depending on Type) */
union {
/** Property's details (depending on Type) */
union
{
/** Description of named data property */
struct __packed ecma_named_data_property_t
{
/** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
/** Description of named data property */
struct __packed ecma_named_data_property_t {
/** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
/** Attribute 'Writable' (ecma_property_writable_value_t) */
unsigned int writable : 1;
/** Attribute 'Writable' (ecma_property_writable_value_t) */
unsigned int writable : 1;
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
unsigned int enumerable : 1;
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
unsigned int enumerable : 1;
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
unsigned int configurable : 1;
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
unsigned int configurable : 1;
/** Value */
ecma_value_t value;
} named_data_property;
/** Value */
ecma_value_t value;
} named_data_property;
/** Description of named accessor property */
struct __packed ecma_named_accessor_property_t
{
/** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
/** Description of named accessor property */
struct __packed ecma_named_accessor_property_t {
/** Compressed pointer to property's name (pointer to String) */
unsigned int name_p : ECMA_POINTER_FIELD_WIDTH;
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
unsigned int enumerable : 1;
/** Attribute 'Enumerable' (ecma_property_enumerable_value_t) */
unsigned int enumerable : 1;
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
unsigned int configurable : 1;
/** Attribute 'Configurable' (ecma_property_configurable_value_t) */
unsigned int configurable : 1;
/** Compressed pointer to property's getter */
unsigned int get_p : ECMA_POINTER_FIELD_WIDTH;
/** Compressed pointer to property's getter */
unsigned int get_p : ECMA_POINTER_FIELD_WIDTH;
/** Compressed pointer to property's setter */
unsigned int set_p : ECMA_POINTER_FIELD_WIDTH;
} named_accessor_property;
/** Compressed pointer to property's setter */
unsigned int set_p : ECMA_POINTER_FIELD_WIDTH;
} named_accessor_property;
/** Description of internal property */
struct __packed ecma_internal_property_t
{
/** Internal property's type */
unsigned int type : 4;
/** Description of internal property */
struct __packed ecma_internal_property_t {
/** Internal property's type */
unsigned int type : 4;
/** Value (may be a compressed pointer) */
uint32_t value;
} internal_property;
} u;
/** Value (may be a compressed pointer) */
uint32_t value;
} internal_property;
} u;
} ecma_property_t;
/**
* Description of GC's information layout
*/
typedef struct {
/**
* Reference counter of the object.
*
* Number of references to the object from stack variables.
*/
unsigned int refs : CONFIG_ECMA_REFERENCE_COUNTER_WIDTH;
typedef struct
{
/**
* Reference counter of the object.
*
* Number of references to the object from stack variables.
*/
unsigned int refs : CONFIG_ECMA_REFERENCE_COUNTER_WIDTH;
/**
* Identifier of GC generation.
*/
unsigned int generation : 2;
/**
* Identifier of GC generation.
*/
unsigned int generation : 2;
/**
* Compressed pointer to next object in the global list of objects with same generation.
*/
unsigned int next : ECMA_POINTER_FIELD_WIDTH;
/**
* Compressed pointer to next object in the global list of objects with same generation.
*/
unsigned int next : ECMA_POINTER_FIELD_WIDTH;
/**
* Marker that is set if the object was visited during graph traverse.
*/
unsigned int visited : 1;
/**
* Marker that is set if the object was visited during graph traverse.
*/
unsigned int visited : 1;
/**
* Flag indicating that the object may reference objects of younger generations in its properties.
*/
unsigned int may_ref_younger_objects : 1;
/**
* Flag indicating that the object may reference objects of younger generations in its properties.
*/
unsigned int may_ref_younger_objects : 1;
} __packed ecma_gc_info_t;
/**
* Types of lexical environments
*/
typedef enum {
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */
typedef enum
{
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE, /**< declarative lexical environment */
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND /**< object-bound lexical environment */
} ecma_lexical_environment_type_t;
/**
* Internal object types
*/
typedef enum {
ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3),
Arguments (10.6), Array (15.4) specification-defined objects
and not host objects */
ECMA_OBJECT_TYPE_STRING, /**< String objects (15.5) */
ECMA_OBJECT_TYPE_FUNCTION, /**< Function objects (15.3), created through 13.2 routine */
ECMA_OBJECT_TYPE_BOUND_FUNCTION, /**< Function objects (15.3), created through 15.3.4.5 routine */
ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */
ECMA_OBJECT_TYPE_ARRAY, /**< Array object (15.4) */
ECMA_OBJECT_TYPE_HOST /**< Host object */
typedef enum
{
ECMA_OBJECT_TYPE_GENERAL, /**< all objects that are not String (15.5), Function (15.3),
Arguments (10.6), Array (15.4) specification-defined objects
and not host objects */
ECMA_OBJECT_TYPE_STRING, /**< String objects (15.5) */
ECMA_OBJECT_TYPE_FUNCTION, /**< Function objects (15.3), created through 13.2 routine */
ECMA_OBJECT_TYPE_BOUND_FUNCTION, /**< Function objects (15.3), created through 15.3.4.5 routine */
ECMA_OBJECT_TYPE_ARGUMENTS, /**< Arguments object (10.6) */
ECMA_OBJECT_TYPE_ARRAY, /**< Array object (15.4) */
ECMA_OBJECT_TYPE_HOST /**< Host object */
} ecma_object_type_t;
/**
* ECMA-defined object classes
*/
typedef enum {
ECMA_OBJECT_CLASS_OBJECT, /**< "Object" */
ECMA_OBJECT_CLASS_FUNCTION, /**< "Function" */
ECMA_OBJECT_CLASS_ARGUMENTS, /**< "Arguments" */
ECMA_OBJECT_CLASS_ARRAY, /**< "Array" */
ECMA_OBJECT_CLASS_BOOLEAN, /**< "Boolean" */
ECMA_OBJECT_CLASS_DATE, /**< "Date" */
ECMA_OBJECT_CLASS_ERROR, /**< "Error" */
ECMA_OBJECT_CLASS_JSON, /**< "JSON" */
ECMA_OBJECT_CLASS_MATH, /**< "Math" */
ECMA_OBJECT_CLASS_NUMBER, /**< "Number" */
ECMA_OBJECT_CLASS_REGEXP, /**< "RegExp" */
ECMA_OBJECT_CLASS_STRING /**< "String" */
typedef enum
{
ECMA_OBJECT_CLASS_OBJECT, /**< "Object" */
ECMA_OBJECT_CLASS_FUNCTION, /**< "Function" */
ECMA_OBJECT_CLASS_ARGUMENTS, /**< "Arguments" */
ECMA_OBJECT_CLASS_ARRAY, /**< "Array" */
ECMA_OBJECT_CLASS_BOOLEAN, /**< "Boolean" */
ECMA_OBJECT_CLASS_DATE, /**< "Date" */
ECMA_OBJECT_CLASS_ERROR, /**< "Error" */
ECMA_OBJECT_CLASS_JSON, /**< "JSON" */
ECMA_OBJECT_CLASS_MATH, /**< "Math" */
ECMA_OBJECT_CLASS_NUMBER, /**< "Number" */
ECMA_OBJECT_CLASS_REGEXP, /**< "RegExp" */
ECMA_OBJECT_CLASS_STRING /**< "String" */
} ecma_object_class_t;
/**
* Description of ECMA-object or lexical environment
* (depending on is_lexical_environment).
*/
typedef struct ecma_object_t {
/** Compressed pointer to property list */
unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH;
typedef struct ecma_object_t
{
/** Compressed pointer to property list */
unsigned int properties_p : ECMA_POINTER_FIELD_WIDTH;
/** Flag indicating whether it is a general object (false)
or a lexical environment (true) */
unsigned int is_lexical_environment : 1;
/** Flag indicating whether it is a general object (false)
or a lexical environment (true) */
unsigned int is_lexical_environment : 1;
/**
* Attributes of either general object or lexical environment
* (depending on is_lexical_environment)
*/
union
{
/**
* A general object's attributes (if !is_lexical_environment)
*/
struct
{
/** Attribute 'Extensible' */
unsigned int extensible : 1;
/** Implementation internal object type (ecma_object_type_t) */
unsigned int type : 3;
/** Compressed pointer to prototype object (ecma_object_t) */
unsigned int prototype_object_p : ECMA_POINTER_FIELD_WIDTH;
} __packed object;
/**
* Attributes of either general object or lexical environment
* (depending on is_lexical_environment)
* A lexical environment's attribute (if is_lexical_environment)
*/
union {
/**
* A general object's attributes (if !is_lexical_environment)
*/
struct {
/** Attribute 'Extensible' */
unsigned int extensible : 1;
struct
{
/**
* Type of lexical environment (ecma_lexical_environment_type_t).
*/
unsigned int type : 1;
/** Implementation internal object type (ecma_object_type_t) */
unsigned int type : 3;
/** Compressed pointer to outer lexical environment */
unsigned int outer_reference_p : ECMA_POINTER_FIELD_WIDTH;
} __packed lexical_environment;
/** Compressed pointer to prototype object (ecma_object_t) */
unsigned int prototype_object_p : ECMA_POINTER_FIELD_WIDTH;
} __packed object;
} __packed u;
/**
* A lexical environment's attribute (if is_lexical_environment)
*/
struct {
/**
* Type of lexical environment (ecma_lexical_environment_type_t).
*/
unsigned int type : 1;
/** GC's information */
ecma_gc_info_t gc_info;
/** Compressed pointer to outer lexical environment */
unsigned int outer_reference_p : ECMA_POINTER_FIELD_WIDTH;
} __packed lexical_environment;
} __packed u;
/** GC's information */
ecma_gc_info_t gc_info;
FIXME(Remove aligned attribute after packing the struct)
FIXME(Remove aligned attribute after packing the struct)
} __packed __attribute__ ((aligned (16))) ecma_object_t;
/**
@@ -451,34 +470,37 @@ typedef uint16_t ecma_length_t;
/**
* Description of an Array's header
*/
typedef struct {
/** Compressed pointer to next chunk */
uint16_t next_chunk_p;
typedef struct
{
/** Compressed pointer to next chunk */
uint16_t next_chunk_p;
/** Number of elements in the Array */
ecma_length_t unit_number;
/** Number of elements in the Array */
ecma_length_t unit_number;
} ecma_array_header_t;
/**
* Description of first chunk in a chain of chunks that contains an Array.
*/
typedef struct {
/** Array's header */
ecma_array_header_t header;
typedef struct
{
/** Array's header */
ecma_array_header_t header;
/** Elements */
uint8_t data[ sizeof (uint64_t) - sizeof (ecma_array_header_t) ];
/** Elements */
uint8_t data[ sizeof (uint64_t) - sizeof (ecma_array_header_t) ];
} ecma_array_first_chunk_t;
/**
* Description of non-first chunk in a chain of chunks that contains an Array
*/
typedef struct {
/** Compressed pointer to next chunk */
uint16_t next_chunk_p;
typedef struct
{
/** Compressed pointer to next chunk */
uint16_t next_chunk_p;
/** Characters */
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
/** Characters */
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
} ecma_array_non_first_chunk_t;
/**
+93 -78
View File
@@ -72,7 +72,7 @@ bool
ecma_is_value_boolean (ecma_value_t value) /**< ecma-value */
{
return ((value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_FALSE)
|| (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE));
|| (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE));
} /* ecma_is_value_boolean */
/**
@@ -98,7 +98,11 @@ ecma_is_value_true (ecma_value_t value) /**< ecma-value */
ecma_value_t
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
{
return (ecma_value_t) { .value_type = ECMA_TYPE_SIMPLE, .value = value };
return (ecma_value_t)
{
.value_type = ECMA_TYPE_SIMPLE,
.value = value
};
} /* ecma_make_simple_value */
/**
@@ -180,54 +184,60 @@ ecma_copy_value (const ecma_value_t value, /**< ecma-value */
switch ((ecma_type_t)value.value_type)
{
case ECMA_TYPE_SIMPLE:
{
value_copy = value;
{
value_copy = value;
break;
}
break;
}
case ECMA_TYPE_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(num_p != NULL);
ecma_number_t *number_copy_p = ecma_alloc_number ();
*number_copy_p = *num_p;
value_copy = (ecma_value_t)
{
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(num_p != NULL);
.value_type = ECMA_TYPE_NUMBER
};
ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p);
ecma_number_t *number_copy_p = ecma_alloc_number ();
*number_copy_p = *num_p;
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_NUMBER };
ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p);
break;
}
break;
}
case ECMA_TYPE_STRING:
{
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(string_p != NULL);
ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string (string_p);
value_copy = (ecma_value_t)
{
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(string_p != NULL);
.value_type = ECMA_TYPE_STRING
};
ECMA_SET_POINTER(value_copy.value, string_copy_p);
ecma_array_first_chunk_t *string_copy_p = ecma_duplicate_ecma_string (string_p);
value_copy = (ecma_value_t) { .value_type = ECMA_TYPE_STRING };
ECMA_SET_POINTER(value_copy.value, string_copy_p);
break;
}
break;
}
case ECMA_TYPE_OBJECT:
{
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(obj_p != NULL);
if (do_ref_if_object)
{
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(obj_p != NULL);
if (do_ref_if_object)
{
ecma_ref_object (obj_p);
}
value_copy = value;
break;
ecma_ref_object (obj_p);
}
value_copy = value;
break;
}
case ECMA_TYPE__COUNT:
{
JERRY_UNREACHABLE();
}
{
JERRY_UNREACHABLE();
}
}
return value_copy;
@@ -244,38 +254,38 @@ ecma_free_value (ecma_value_t value, /**< value description */
switch ((ecma_type_t) value.value_type)
{
case ECMA_TYPE_SIMPLE:
{
/* doesn't hold additional memory */
break;
}
{
/* doesn't hold additional memory */
break;
}
case ECMA_TYPE_NUMBER:
{
ecma_number_t *number_p = ECMA_GET_POINTER(value.value);
ecma_dealloc_number (number_p);
break;
}
{
ecma_number_t *number_p = ECMA_GET_POINTER(value.value);
ecma_dealloc_number (number_p);
break;
}
case ECMA_TYPE_STRING:
{
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
ecma_free_array (string_p);
break;
}
{
ecma_array_first_chunk_t *string_p = ECMA_GET_POINTER(value.value);
ecma_free_array (string_p);
break;
}
case ECMA_TYPE_OBJECT:
{
if (do_deref_if_object)
{
if (do_deref_if_object)
{
ecma_deref_object (ECMA_GET_POINTER(value.value));
}
break;
ecma_deref_object (ECMA_GET_POINTER(value.value));
}
break;
}
case ECMA_TYPE__COUNT:
{
JERRY_UNREACHABLE();
}
{
JERRY_UNREACHABLE();
}
}
} /* ecma_free_value */
@@ -286,10 +296,15 @@ ecma_free_value (ecma_value_t value, /**< value description */
*/
ecma_completion_value_t
ecma_make_completion_value (ecma_completion_type_t type, /**< type */
ecma_value_t value, /**< value */
uint8_t target) /**< target */
ecma_value_t value, /**< value */
uint8_t target) /**< target */
{
return (ecma_completion_value_t) { .type = type, .value = value, .target = target };
return (ecma_completion_value_t)
{
.type = type,
.value = value,
.target = target
};
} /* ecma_make_completion_value */
/**
@@ -301,9 +316,9 @@ ecma_completion_value_t
ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */
{
JERRY_ASSERT(simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|| simple_value == ECMA_SIMPLE_VALUE_TRUE);
|| simple_value == ECMA_SIMPLE_VALUE_NULL
|| simple_value == ECMA_SIMPLE_VALUE_FALSE
|| simple_value == ECMA_SIMPLE_VALUE_TRUE);
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (simple_value),
@@ -323,8 +338,8 @@ ecma_make_throw_value (ecma_object_t *exception_p) /**< an object */
ecma_value_t exception = ecma_make_object_value (exception_p);
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW,
exception,
ECMA_TARGET_ID_RESERVED);
exception,
ECMA_TARGET_ID_RESERVED);
} /* ecma_make_throw_value */
/**
@@ -360,18 +375,18 @@ void
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
{
switch (completion_value.type)
{
{
case ECMA_COMPLETION_TYPE_NORMAL:
case ECMA_COMPLETION_TYPE_THROW:
case ECMA_COMPLETION_TYPE_RETURN:
ecma_free_value (completion_value.value, true);
break;
ecma_free_value (completion_value.value, true);
break;
case ECMA_COMPLETION_TYPE_CONTINUE:
case ECMA_COMPLETION_TYPE_BREAK:
case ECMA_COMPLETION_TYPE_EXIT:
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
break;
}
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
break;
}
} /* ecma_free_completion_value */
/**
@@ -411,8 +426,8 @@ ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**
for equality with */
{
return (value.type == ECMA_COMPLETION_TYPE_NORMAL
&& value.value.value_type == ECMA_TYPE_SIMPLE
&& value.value.value == simple_value);
&& value.value.value_type == ECMA_TYPE_SIMPLE
&& value.value.value == simple_value);
} /* ecma_is_completion_value_normal_simple_value */
/**
@@ -452,7 +467,7 @@ bool
ecma_is_empty_completion_value (ecma_completion_value_t value) /**< completion value */
{
return (ecma_is_completion_value_normal (value)
&& ecma_is_value_empty (value.value));
&& ecma_is_value_empty (value.value));
} /* ecma_is_empty_completion_value */
/**
+238 -237
View File
@@ -40,17 +40,17 @@ ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe
bool is_extensible, /**< value of extensible attribute */
ecma_object_type_t type) /**< object type */
{
ecma_object_t *object_p = ecma_alloc_object ();
ecma_init_gc_info (object_p);
ecma_object_t *object_p = ecma_alloc_object ();
ecma_init_gc_info (object_p);
object_p->properties_p = ECMA_NULL_POINTER;
object_p->is_lexical_environment = false;
object_p->properties_p = ECMA_NULL_POINTER;
object_p->is_lexical_environment = false;
object_p->u.object.extensible = is_extensible;
ECMA_SET_POINTER(object_p->u.object.prototype_object_p, prototype_object_p);
object_p->u.object.type = type;
object_p->u.object.extensible = is_extensible;
ECMA_SET_POINTER(object_p->u.object.prototype_object_p, prototype_object_p);
object_p->u.object.type = type;
return object_p;
return object_p;
} /* ecma_create_object */
/**
@@ -91,8 +91,8 @@ ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer
*/
ecma_object_t*
ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
ecma_object_t *binding_obj_p, /**< binding object */
bool provide_this) /**< provideThis flag */
ecma_object_t *binding_obj_p, /**< binding object */
bool provide_this) /**< provideThis flag */
{
JERRY_ASSERT(binding_obj_p != NULL);
@@ -127,20 +127,20 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
*/
ecma_property_t*
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
ecma_internal_property_id_t property_id) /**< internal property identifier */
ecma_internal_property_id_t property_id) /**< internal property identifier */
{
ecma_property_t *new_property_p = ecma_alloc_property ();
ecma_property_t *new_property_p = ecma_alloc_property ();
new_property_p->type = ECMA_PROPERTY_INTERNAL;
new_property_p->type = ECMA_PROPERTY_INTERNAL;
ecma_property_t *list_head_p = ECMA_GET_POINTER(object_p->properties_p);
ECMA_SET_POINTER(new_property_p->next_property_p, list_head_p);
ECMA_SET_NON_NULL_POINTER(object_p->properties_p, new_property_p);
ecma_property_t *list_head_p = ECMA_GET_POINTER(object_p->properties_p);
ECMA_SET_POINTER(new_property_p->next_property_p, list_head_p);
ECMA_SET_NON_NULL_POINTER(object_p->properties_p, new_property_p);
new_property_p->u.internal_property.type = property_id;
new_property_p->u.internal_property.value = ECMA_NULL_POINTER;
new_property_p->u.internal_property.type = property_id;
new_property_p->u.internal_property.value = ECMA_NULL_POINTER;
return new_property_p;
return new_property_p;
} /* ecma_create_internal_property */
/**
@@ -151,27 +151,27 @@ ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
*/
ecma_property_t*
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
ecma_internal_property_id_t property_id) /**< internal property identifier */
ecma_internal_property_id_t property_id) /**< internal property identifier */
{
JERRY_ASSERT(object_p != NULL);
JERRY_ASSERT(object_p != NULL);
JERRY_ASSERT(property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE);
JERRY_ASSERT(property_id != ECMA_INTERNAL_PROPERTY_PROTOTYPE
&& property_id != ECMA_INTERNAL_PROPERTY_EXTENSIBLE);
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p);
property_p != NULL;
property_p = ECMA_GET_POINTER(property_p->next_property_p))
for (ecma_property_t *property_p = ECMA_GET_POINTER(object_p->properties_p);
property_p != NULL;
property_p = ECMA_GET_POINTER(property_p->next_property_p))
{
if (property_p->type == ECMA_PROPERTY_INTERNAL)
{
if (property_p->type == ECMA_PROPERTY_INTERNAL)
{
if (property_p->u.internal_property.type == property_id)
{
return property_p;
}
}
if (property_p->u.internal_property.type == property_id)
{
return property_p;
}
}
}
return NULL;
return NULL;
} /* ecma_find_internal_property */
/**
@@ -184,13 +184,13 @@ ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
*/
ecma_property_t*
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
ecma_internal_property_id_t property_id) /**< internal property identifier */
ecma_internal_property_id_t property_id) /**< internal property identifier */
{
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
ecma_property_t *property_p = ecma_find_internal_property (object_p, property_id);
JERRY_ASSERT(property_p != NULL);
JERRY_ASSERT(property_p != NULL);
return property_p;
return property_p;
} /* ecma_get_internal_property */
/**
@@ -201,10 +201,10 @@ ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
*/
ecma_property_t*
ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
const ecma_char_t *name_p, /**< property name */
ecma_property_writable_value_t writable, /**< 'writable' attribute */
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
const ecma_char_t *name_p, /**< property name */
ecma_property_writable_value_t writable, /**< 'writable' attribute */
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
{
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
@@ -235,11 +235,11 @@ ecma_create_named_data_property (ecma_object_t *obj_p, /**< object */
*/
ecma_property_t*
ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
const ecma_char_t *name_p, /**< property name */
ecma_object_t *get_p, /**< getter */
ecma_object_t *set_p, /**< setter */
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
const ecma_char_t *name_p, /**< property name */
ecma_object_t *get_p, /**< getter */
ecma_object_t *set_p, /**< setter */
ecma_property_enumerable_value_t enumerable, /**< 'enumerable' attribute */
ecma_property_configurable_value_t configurable) /**< 'configurable' attribute */
{
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
@@ -273,37 +273,37 @@ ecma_create_named_accessor_property (ecma_object_t *obj_p, /**< object */
*/
ecma_property_t*
ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in */
const ecma_char_t *name_p) /**< property's name */
const ecma_char_t *name_p) /**< property's name */
{
JERRY_ASSERT(obj_p != NULL);
JERRY_ASSERT(name_p != NULL);
JERRY_ASSERT(obj_p != NULL);
JERRY_ASSERT(name_p != NULL);
for (ecma_property_t *property_p = ECMA_GET_POINTER(obj_p->properties_p);
property_p != NULL;
property_p = ECMA_GET_POINTER(property_p->next_property_p))
for (ecma_property_t *property_p = ECMA_GET_POINTER(obj_p->properties_p);
property_p != NULL;
property_p = ECMA_GET_POINTER(property_p->next_property_p))
{
ecma_array_first_chunk_t *property_name_p;
if (property_p->type == ECMA_PROPERTY_NAMEDDATA)
{
ecma_array_first_chunk_t *property_name_p;
if (property_p->type == ECMA_PROPERTY_NAMEDDATA)
{
property_name_p = ECMA_GET_POINTER(property_p->u.named_data_property.name_p);
} else if (property_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
property_name_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.name_p);
} else
{
continue;
}
JERRY_ASSERT(property_name_p != NULL);
if (ecma_compare_zt_string_to_ecma_string (name_p, property_name_p))
{
return property_p;
}
property_name_p = ECMA_GET_POINTER(property_p->u.named_data_property.name_p);
} else if (property_p->type == ECMA_PROPERTY_NAMEDACCESSOR)
{
property_name_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.name_p);
} else
{
continue;
}
return NULL;
JERRY_ASSERT(property_name_p != NULL);
if (ecma_compare_zt_string_to_ecma_string (name_p, property_name_p))
{
return property_p;
}
}
return NULL;
} /* ecma_find_named_property */
/**
@@ -317,16 +317,16 @@ ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in
*/
ecma_property_t*
ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in */
const ecma_char_t *name_p) /**< property's name */
const ecma_char_t *name_p) /**< property's name */
{
JERRY_ASSERT(obj_p != NULL);
JERRY_ASSERT(name_p != NULL);
JERRY_ASSERT(obj_p != NULL);
JERRY_ASSERT(name_p != NULL);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
JERRY_ASSERT(property_p != NULL);
JERRY_ASSERT(property_p != NULL);
return property_p;
return property_p;
} /* ecma_get_named_property */
/**
@@ -340,16 +340,16 @@ ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in *
*/
ecma_property_t*
ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property in */
const ecma_char_t *name_p) /**< property's name */
const ecma_char_t *name_p) /**< property's name */
{
JERRY_ASSERT(obj_p != NULL);
JERRY_ASSERT(name_p != NULL);
JERRY_ASSERT(obj_p != NULL);
JERRY_ASSERT(name_p != NULL);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
ecma_property_t *property_p = ecma_find_named_property (obj_p, name_p);
JERRY_ASSERT(property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDDATA);
JERRY_ASSERT(property_p != NULL && property_p->type == ECMA_PROPERTY_NAMEDDATA);
return property_p;
return property_p;
} /* ecma_get_named_data_property */
/**
@@ -395,10 +395,10 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_FORMAL_PARAMETERS: /* an array */
{
ecma_free_array (ECMA_GET_POINTER(property_value));
break;
}
{
ecma_free_array (ECMA_GET_POINTER(property_value));
break;
}
case ECMA_INTERNAL_PROPERTY_SCOPE: /* a lexical environment */
case ECMA_INTERNAL_PROPERTY_BINDING_OBJECT: /* an object */
@@ -407,9 +407,9 @@ ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
case ECMA_INTERNAL_PROPERTY_PROVIDE_THIS: /* a boolean */
case ECMA_INTERNAL_PROPERTY_CLASS: /* an enum */
case ECMA_INTERNAL_PROPERTY_CODE: /* an integer */
{
break;
}
{
break;
}
}
ecma_dealloc_property (property_p);
@@ -424,25 +424,25 @@ ecma_free_property (ecma_property_t *prop_p) /**< property */
switch ((ecma_property_type_t) prop_p->type)
{
case ECMA_PROPERTY_NAMEDDATA:
{
ecma_free_named_data_property (prop_p);
{
ecma_free_named_data_property (prop_p);
break;
}
break;
}
case ECMA_PROPERTY_NAMEDACCESSOR:
{
ecma_free_named_accessor_property (prop_p);
{
ecma_free_named_accessor_property (prop_p);
break;
}
break;
}
case ECMA_PROPERTY_INTERNAL:
{
ecma_free_internal_property (prop_p);
{
ecma_free_internal_property (prop_p);
break;
}
break;
}
}
} /* ecma_free_property */
@@ -453,11 +453,11 @@ ecma_free_property (ecma_property_t *prop_p) /**< property */
*/
void
ecma_delete_property (ecma_object_t *obj_p, /**< object */
ecma_property_t *prop_p) /**< property */
ecma_property_t *prop_p) /**< property */
{
for (ecma_property_t *cur_prop_p = ECMA_GET_POINTER(obj_p->properties_p), *prev_prop_p = NULL, *next_prop_p;
cur_prop_p != NULL;
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
cur_prop_p != NULL;
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
{
next_prop_p = ECMA_GET_POINTER(cur_prop_p->next_property_p);
@@ -488,51 +488,51 @@ ecma_delete_property (ecma_object_t *obj_p, /**< object */
ecma_array_first_chunk_t*
ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string of ecma-characters */
{
ecma_length_t length = 0;
ecma_length_t length = 0;
/*
* TODO: Do not precalculate length.
*/
if (string_p != NULL)
/*
* TODO: Do not precalculate length.
*/
if (string_p != NULL)
{
const ecma_char_t *iter_p = string_p;
while (*iter_p++)
{
const ecma_char_t *iter_p = string_p;
while (*iter_p++)
{
length++;
}
length++;
}
}
ecma_array_first_chunk_t *string_first_chunk_p = ecma_alloc_array_first_chunk ();
ecma_array_first_chunk_t *string_first_chunk_p = ecma_alloc_array_first_chunk ();
string_first_chunk_p->header.unit_number = length;
uint8_t *copy_pointer = (uint8_t*) string_p;
size_t chars_left = length;
size_t chars_to_copy = JERRY_MIN(length, sizeof (string_first_chunk_p->data) / sizeof (ecma_char_t));
__memcpy (string_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
string_first_chunk_p->header.unit_number = length;
uint8_t *copy_pointer = (uint8_t*) string_p;
size_t chars_left = length;
size_t chars_to_copy = JERRY_MIN(length, sizeof (string_first_chunk_p->data) / sizeof (ecma_char_t));
__memcpy (string_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
chars_left -= chars_to_copy;
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
ecma_array_non_first_chunk_t *string_non_first_chunk_p;
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
uint16_t *next_chunk_compressed_pointer_p = &string_first_chunk_p->header.next_chunk_p;
while (chars_left > 0)
{
string_non_first_chunk_p = ecma_alloc_array_non_first_chunk ();
size_t chars_to_copy = JERRY_MIN(chars_left, sizeof (string_non_first_chunk_p->data) / sizeof (ecma_char_t));
__memcpy (string_non_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
chars_left -= chars_to_copy;
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
ecma_array_non_first_chunk_t *string_non_first_chunk_p;
ECMA_SET_NON_NULL_POINTER(*next_chunk_compressed_pointer_p, string_non_first_chunk_p);
next_chunk_compressed_pointer_p = &string_non_first_chunk_p->next_chunk_p;
}
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
uint16_t *next_chunk_compressed_pointer_p = &string_first_chunk_p->header.next_chunk_p;
*next_chunk_compressed_pointer_p = ECMA_NULL_POINTER;
while (chars_left > 0)
{
string_non_first_chunk_p = ecma_alloc_array_non_first_chunk ();
size_t chars_to_copy = JERRY_MIN(chars_left, sizeof (string_non_first_chunk_p->data) / sizeof (ecma_char_t));
__memcpy (string_non_first_chunk_p->data, copy_pointer, chars_to_copy * sizeof (ecma_char_t));
chars_left -= chars_to_copy;
copy_pointer += chars_to_copy * sizeof (ecma_char_t);
ECMA_SET_NON_NULL_POINTER(*next_chunk_compressed_pointer_p, string_non_first_chunk_p);
next_chunk_compressed_pointer_p = &string_non_first_chunk_p->next_chunk_p;
}
*next_chunk_compressed_pointer_p = ECMA_NULL_POINTER;
return string_first_chunk_p;
return string_first_chunk_p;
} /* ecma_new_ecma_string */
/**
@@ -546,43 +546,43 @@ ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string o
*/
ssize_t
ecma_copy_ecma_string_chars_to_buffer (ecma_array_first_chunk_t *first_chunk_p, /**< first chunk of ecma-string */
uint8_t *buffer_p, /**< destination buffer */
size_t buffer_size) /**< size of buffer */
uint8_t *buffer_p, /**< destination buffer */
size_t buffer_size) /**< size of buffer */
{
ecma_length_t string_length = first_chunk_p->header.unit_number;
size_t required_buffer_size = sizeof (ecma_length_t) + sizeof (ecma_char_t) * string_length;
ecma_length_t string_length = first_chunk_p->header.unit_number;
size_t required_buffer_size = sizeof (ecma_length_t) + sizeof (ecma_char_t) * string_length;
if (required_buffer_size > buffer_size)
{
return - (ssize_t) required_buffer_size;
}
if (required_buffer_size > buffer_size)
{
return - (ssize_t) required_buffer_size;
}
*(ecma_length_t*) buffer_p = string_length;
*(ecma_length_t*) buffer_p = string_length;
size_t chars_left = string_length;
uint8_t *dest_pointer = buffer_p + sizeof (ecma_length_t);
size_t copy_chunk_chars = JERRY_MIN(sizeof (first_chunk_p->data) / sizeof (ecma_char_t),
size_t chars_left = string_length;
uint8_t *dest_pointer = buffer_p + sizeof (ecma_length_t);
size_t copy_chunk_chars = JERRY_MIN(sizeof (first_chunk_p->data) / sizeof (ecma_char_t),
chars_left);
__memcpy (dest_pointer, first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
__memcpy (dest_pointer, first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
chars_left -= copy_chunk_chars;
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
while (chars_left > 0)
{
JERRY_ASSERT(chars_left < string_length);
copy_chunk_chars = JERRY_MIN(sizeof (non_first_chunk_p->data) / sizeof (ecma_char_t),
chars_left);
__memcpy (dest_pointer, non_first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
chars_left -= copy_chunk_chars;
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
}
while (chars_left > 0)
{
JERRY_ASSERT(chars_left < string_length);
copy_chunk_chars = JERRY_MIN(sizeof (non_first_chunk_p->data) / sizeof (ecma_char_t),
chars_left);
__memcpy (dest_pointer, non_first_chunk_p->data, copy_chunk_chars * sizeof (ecma_char_t));
dest_pointer += copy_chunk_chars * sizeof (ecma_char_t);
chars_left -= copy_chunk_chars;
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
}
return (ssize_t) required_buffer_size;
return (ssize_t) required_buffer_size;
} /* ecma_copy_ecma_string_chars_to_buffer */
/**
@@ -593,29 +593,29 @@ ecma_copy_ecma_string_chars_to_buffer (ecma_array_first_chunk_t *first_chunk_p,
ecma_array_first_chunk_t*
ecma_duplicate_ecma_string (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of string to duplicate */
{
JERRY_ASSERT(first_chunk_p != NULL);
JERRY_ASSERT(first_chunk_p != NULL);
ecma_array_first_chunk_t *first_chunk_copy_p = ecma_alloc_array_first_chunk ();
__memcpy (first_chunk_copy_p, first_chunk_p, sizeof (ecma_array_first_chunk_t));
ecma_array_first_chunk_t *first_chunk_copy_p = ecma_alloc_array_first_chunk ();
__memcpy (first_chunk_copy_p, first_chunk_p, sizeof (ecma_array_first_chunk_t));
ecma_array_non_first_chunk_t *non_first_chunk_p, *non_first_chunk_copy_p;
non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
uint16_t *next_pointer_p = &first_chunk_copy_p->header.next_chunk_p;
ecma_array_non_first_chunk_t *non_first_chunk_p, *non_first_chunk_copy_p;
non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
uint16_t *next_pointer_p = &first_chunk_copy_p->header.next_chunk_p;
while (non_first_chunk_p != NULL)
{
non_first_chunk_copy_p = ecma_alloc_array_non_first_chunk ();
ECMA_SET_POINTER(*next_pointer_p, non_first_chunk_copy_p);
next_pointer_p = &non_first_chunk_copy_p->next_chunk_p;
while (non_first_chunk_p != NULL)
{
non_first_chunk_copy_p = ecma_alloc_array_non_first_chunk ();
ECMA_SET_POINTER(*next_pointer_p, non_first_chunk_copy_p);
next_pointer_p = &non_first_chunk_copy_p->next_chunk_p;
__memcpy (non_first_chunk_copy_p, non_first_chunk_p, sizeof (ecma_array_non_first_chunk_t));
__memcpy (non_first_chunk_copy_p, non_first_chunk_p, sizeof (ecma_array_non_first_chunk_t));
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
}
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
}
*next_pointer_p = ECMA_NULL_POINTER;
*next_pointer_p = ECMA_NULL_POINTER;
return first_chunk_copy_p;
return first_chunk_copy_p;
} /* ecma_duplicate_ecma_string */
/**
@@ -626,7 +626,7 @@ ecma_duplicate_ecma_string (ecma_array_first_chunk_t *first_chunk_p) /**< first
*/
bool
ecma_compare_ecma_string_to_ecma_string (const ecma_array_first_chunk_t *string1_p, /* ecma-string */
const ecma_array_first_chunk_t *string2_p) /* ecma-string */
const ecma_array_first_chunk_t *string2_p) /* ecma-string */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(string1_p, string2_p);
} /* ecma_compare_ecma_string_to_ecma_string */
@@ -639,51 +639,51 @@ ecma_compare_ecma_string_to_ecma_string (const ecma_array_first_chunk_t *string1
*/
bool
ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-terminated string */
const ecma_array_first_chunk_t *ecma_string_p) /* ecma-string */
const ecma_array_first_chunk_t *ecma_string_p) /* ecma-string */
{
JERRY_ASSERT(string_p != NULL);
JERRY_ASSERT(ecma_string_p != NULL);
const ecma_char_t *str_iter_p = string_p;
ecma_length_t ecma_str_len = ecma_string_p->header.unit_number;
const ecma_char_t *current_chunk_chars_cur = (const ecma_char_t*) ecma_string_p->data,
*current_chunk_chars_end = (const ecma_char_t*) (ecma_string_p->data
+ sizeof (ecma_string_p->data));
const ecma_char_t *current_chunk_chars_cur = (const ecma_char_t*) ecma_string_p->data;
const ecma_char_t *current_chunk_chars_end = (const ecma_char_t*) (ecma_string_p->data +
sizeof (ecma_string_p->data));
JERRY_STATIC_ASSERT(ECMA_POINTER_FIELD_WIDTH <= sizeof (uint16_t) * JERRY_BITSINBYTE);
const uint16_t *next_chunk_compressed_pointer_p = &ecma_string_p->header.next_chunk_p;
for (ecma_length_t str_index = 0;
str_index < ecma_str_len;
str_index++, str_iter_p++, current_chunk_chars_cur++)
str_index < ecma_str_len;
str_index++, str_iter_p++, current_chunk_chars_cur++)
{
JERRY_ASSERT(current_chunk_chars_cur <= current_chunk_chars_end);
if (current_chunk_chars_cur == current_chunk_chars_end)
{
JERRY_ASSERT(current_chunk_chars_cur <= current_chunk_chars_end);
/* switching to next chunk */
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(*next_chunk_compressed_pointer_p);
if (current_chunk_chars_cur == current_chunk_chars_end)
{
/* switching to next chunk */
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(*next_chunk_compressed_pointer_p);
JERRY_ASSERT(next_chunk_p != NULL);
JERRY_ASSERT(next_chunk_p != NULL);
current_chunk_chars_cur = (const ecma_char_t*) next_chunk_p->data;
current_chunk_chars_end = (const ecma_char_t*) (next_chunk_p->data + sizeof (next_chunk_p->data));
current_chunk_chars_cur = (const ecma_char_t*) next_chunk_p->data;
current_chunk_chars_end = (const ecma_char_t*) (next_chunk_p->data + sizeof (next_chunk_p->data));
next_chunk_compressed_pointer_p = &next_chunk_p->next_chunk_p;
}
if (*str_iter_p != *current_chunk_chars_cur)
{
/*
* Either *str_iter_p is 0 (zero-terminated string is shorter),
* or the character is just different.
*
* In both cases strings are not equal.
*/
return false;
}
next_chunk_compressed_pointer_p = &next_chunk_p->next_chunk_p;
}
if (*str_iter_p != *current_chunk_chars_cur)
{
/*
* Either *str_iter_p is 0 (zero-terminated string is shorter),
* or the character is just different.
*
* In both cases strings are not equal.
*/
return false;
}
}
/*
* Now, we have reached end of ecma-string.
*
@@ -699,20 +699,20 @@ ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, /**< zero-te
void
ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of the array */
{
JERRY_ASSERT(first_chunk_p != NULL);
JERRY_ASSERT(first_chunk_p != NULL);
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
ecma_dealloc_array_first_chunk (first_chunk_p);
ecma_dealloc_array_first_chunk (first_chunk_p);
while (non_first_chunk_p != NULL)
{
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
while (non_first_chunk_p != NULL)
{
ecma_array_non_first_chunk_t *next_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
ecma_dealloc_array_non_first_chunk (non_first_chunk_p);
ecma_dealloc_array_non_first_chunk (non_first_chunk_p);
non_first_chunk_p = next_chunk_p;
}
non_first_chunk_p = next_chunk_p;
}
} /* ecma_free_array */
/**
@@ -724,24 +724,25 @@ ecma_free_array (ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of th
ecma_property_descriptor_t
ecma_make_empty_property_descriptor (void)
{
ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t) {
.is_value_defined = false,
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
ecma_property_descriptor_t prop_desc = (ecma_property_descriptor_t)
{
.is_value_defined = false,
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
.is_writable_defined = false,
.writable = ECMA_PROPERTY_NOT_WRITABLE,
.is_writable_defined = false,
.writable = ECMA_PROPERTY_NOT_WRITABLE,
.is_enumerable_defined = false,
.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE,
.is_enumerable_defined = false,
.enumerable = ECMA_PROPERTY_NOT_ENUMERABLE,
.is_configurable_defined = false,
.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE,
.is_configurable_defined = false,
.configurable = ECMA_PROPERTY_NOT_CONFIGURABLE,
.is_get_defined = false,
.get_p = NULL,
.is_get_defined = false,
.get_p = NULL,
.is_set_defined = false,
.set_p = NULL
.is_set_defined = false,
.set_p = NULL
};
return prop_desc;
+11 -10
View File
@@ -30,28 +30,29 @@
* Get value of pointer from specified compressed pointer field.
*/
#define ECMA_GET_POINTER(field) \
((unlikely (field == ECMA_NULL_POINTER)) ? NULL : mem_decompress_pointer (field))
((unlikely (field == ECMA_NULL_POINTER)) ? NULL : mem_decompress_pointer (field))
/**
* Set value of compressed pointer field so that it will correspond
* to specified non_compressed_pointer.
*/
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
do { \
void *__temp_pointer = non_compressed_pointer; \
non_compressed_pointer = __temp_pointer; \
} \
while (0); \
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
: mem_compress_pointer (non_compressed_pointer) \
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
do \
{ \
void *__temp_pointer = non_compressed_pointer; \
non_compressed_pointer = __temp_pointer; \
} while (0); \
\
(field) = (unlikely ((non_compressed_pointer) == NULL) ? ECMA_NULL_POINTER \
: (mem_compress_pointer (non_compressed_pointer) \
& ((1u << ECMA_POINTER_FIELD_WIDTH) - 1)))
/**
* Set value of non-null compressed pointer field so that it will correspond
* to specified non_compressed_pointer.
*/
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
(field) = (mem_compress_pointer (non_compressed_pointer) & ((1u << ECMA_POINTER_FIELD_WIDTH) - 1))
/* ecma-helpers-value.c */
extern bool ecma_is_value_empty (ecma_value_t value);