Style fixes in liballocator, libecmaobjects, libecmaoperations: space between function name and opening parenthesis, no space after opening parenthesis/before closing parenthesis.

This commit is contained in:
Ruben Ayrapetyan
2014-08-11 19:27:07 +04:00
parent e53be2b441
commit b02eefd4ae
16 changed files with 761 additions and 761 deletions
+22 -22
View File
@@ -38,43 +38,43 @@
#include "ecma-gc.h"
#include "mem-poolman.h"
JERRY_STATIC_ASSERT( sizeof (ecma_value_t) <= sizeof (uint16_t) );
JERRY_STATIC_ASSERT( sizeof (ecma_property_t) <= sizeof (uint64_t) );
JERRY_STATIC_ASSERT(sizeof (ecma_value_t) <= sizeof (uint16_t));
JERRY_STATIC_ASSERT(sizeof (ecma_property_t) <= sizeof (uint64_t));
FIXME( Pack ecma_object_t )
JERRY_STATIC_ASSERT( sizeof (ecma_object_t) <= 2 * sizeof (uint64_t) );
FIXME(Pack ecma_object_t)
JERRY_STATIC_ASSERT(sizeof (ecma_object_t) <= 2 * sizeof (uint64_t));
JERRY_STATIC_ASSERT( sizeof (ecma_array_header_t) <= sizeof (uint32_t) );
JERRY_STATIC_ASSERT( sizeof (ecma_array_first_chunk_t) == sizeof(uint64_t) );
JERRY_STATIC_ASSERT( sizeof (ecma_array_non_first_chunk_t) == sizeof(uint64_t) );
JERRY_STATIC_ASSERT( sizeof (ecma_completion_value_t) == sizeof(uint32_t) );
JERRY_STATIC_ASSERT(sizeof (ecma_array_header_t) <= sizeof (uint32_t));
JERRY_STATIC_ASSERT(sizeof (ecma_array_first_chunk_t) == sizeof (uint64_t));
JERRY_STATIC_ASSERT(sizeof (ecma_array_non_first_chunk_t) == sizeof (uint64_t));
JERRY_STATIC_ASSERT(sizeof (ecma_completion_value_t) == sizeof (uint32_t));
/**
* Template of an allocation routine.
*
* FIXME: Run GC only if allocation failed.
*/
#define ALLOC( ecma_type) ecma_ ## ecma_type ## _t * \
#define ALLOC(ecma_type) ecma_ ## ecma_type ## _t * \
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 ) ) \
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
\
for ( ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0; \
gen_id < ECMA_GC_GEN_COUNT; \
gen_id++ ) \
gen_id++) \
{ \
ecma_gc_run( gen_id ); \
ecma_gc_run (gen_id); \
\
p ## ecma_type = (ecma_ ## ecma_type ## _t *) \
mem_pools_alloc(); \
mem_pools_alloc (); \
\
if ( likely( p ## ecma_type != NULL ) ) \
if (likely (p ## ecma_type != NULL)) \
{ \
return p ## ecma_type; \
} \
@@ -85,18 +85,18 @@ ecma_alloc_ ## ecma_type (void) \
/**
* Deallocation routine template
*/
#define DEALLOC( ecma_type) void \
ecma_dealloc_ ## ecma_type( ecma_ ## ecma_type ## _t *p ## ecma_type) \
#define DEALLOC(ecma_type) void \
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)
#define DECLARE_ROUTINES_FOR(ecma_type) \
ALLOC(ecma_type) \
DEALLOC(ecma_type)
DECLARE_ROUTINES_FOR (object)
DECLARE_ROUTINES_FOR (property)
+11 -11
View File
@@ -21,7 +21,7 @@
*/
#ifndef JERRY_ECMA_ALLOC_H
#define JERRY_ECMA_ALLOC_H
#define JERRY_ECMA_ALLOC_H
#include "ecma-globals.h"
@@ -30,60 +30,60 @@
*
* @return pointer to allocated memory
*/
extern ecma_object_t *ecma_alloc_object(void);
extern ecma_object_t *ecma_alloc_object (void);
/**
* Dealloc memory from an ecma-object
*/
extern void ecma_dealloc_object( ecma_object_t *object_p);
extern void ecma_dealloc_object (ecma_object_t *object_p);
/**
* Allocate memory for ecma-property
*
* @return pointer to allocated memory
*/
extern ecma_property_t *ecma_alloc_property(void);
extern ecma_property_t *ecma_alloc_property (void);
/**
* Dealloc memory from an ecma-property
*/
extern void ecma_dealloc_property( ecma_property_t *property_p);
extern void ecma_dealloc_property (ecma_property_t *property_p);
/**
* Allocate memory for ecma-number
*
* @return pointer to allocated memory
*/
extern ecma_number_t *ecma_alloc_number(void);
extern ecma_number_t *ecma_alloc_number (void);
/**
* Dealloc memory from an ecma-number
*/
extern void ecma_dealloc_number( ecma_number_t *number_p);
extern void ecma_dealloc_number (ecma_number_t *number_p);
/**
* Allocate memory for first chunk of an ecma-array
*
* @return pointer to allocated memory
*/
extern ecma_array_first_chunk_t *ecma_alloc_array_first_chunk(void);
extern ecma_array_first_chunk_t *ecma_alloc_array_first_chunk (void);
/**
* Dealloc memory from first chunk of an ecma-array
*/
extern void ecma_dealloc_array_first_chunk( ecma_array_first_chunk_t *first_chunk_p);
extern void ecma_dealloc_array_first_chunk (ecma_array_first_chunk_t *first_chunk_p);
/**
* Allocate memory for non-first chunk of an ecma-array
*
* @return pointer to allocated memory
*/
extern ecma_array_non_first_chunk_t *ecma_alloc_array_non_first_chunk(void);
extern ecma_array_non_first_chunk_t *ecma_alloc_array_non_first_chunk (void);
/**
* Dealloc memory from non-first chunk of an ecma-array
*/
extern void ecma_dealloc_array_non_first_chunk( ecma_array_non_first_chunk_t *number_p);
extern void ecma_dealloc_array_non_first_chunk (ecma_array_non_first_chunk_t *number_p);
#endif /* JERRY_ECMA_ALLOC_H */
+99 -99
View File
@@ -36,19 +36,19 @@
*/
static ecma_object_t *ecma_gc_objects_lists[ ECMA_GC_GEN_COUNT ];
static void ecma_gc_mark( ecma_object_t *object_p, ecma_gc_gen_t maximum_gen_to_traverse);
static void ecma_gc_sweep( ecma_object_t *object_p);
static void ecma_gc_mark (ecma_object_t *object_p, ecma_gc_gen_t maximum_gen_to_traverse);
static void ecma_gc_sweep (ecma_object_t *object_p);
/**
* Initialize GC information for the object
*/
void
ecma_init_gc_info(ecma_object_t *object_p) /**< object */
ecma_init_gc_info (ecma_object_t *object_p) /**< object */
{
object_p->gc_info.refs = 1;
object_p->gc_info.generation = ECMA_GC_GEN_0;
ECMA_SET_POINTER( object_p->gc_info.next, ecma_gc_objects_lists[ ECMA_GC_GEN_0 ]);
ECMA_SET_POINTER(object_p->gc_info.next, ecma_gc_objects_lists[ ECMA_GC_GEN_0 ]);
ecma_gc_objects_lists[ ECMA_GC_GEN_0 ] = object_p;
/* Should be set to false at the beginning of garbage collection */
@@ -61,7 +61,7 @@ ecma_init_gc_info(ecma_object_t *object_p) /**< object */
* Increase reference counter of an object
*/
void
ecma_ref_object(ecma_object_t *object_p) /**< object */
ecma_ref_object (ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT(object_p != NULL);
object_p->gc_info.refs++;
@@ -71,7 +71,7 @@ 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 ) )
if (unlikely (object_p->gc_info.refs == 0))
{
JERRY_UNREACHABLE();
}
@@ -81,7 +81,7 @@ ecma_ref_object(ecma_object_t *object_p) /**< object */
* Decrease reference counter of an object
*/
void
ecma_deref_object(ecma_object_t *object_p) /**< object */
ecma_deref_object (ecma_object_t *object_p) /**< object */
{
JERRY_ASSERT(object_p != NULL);
JERRY_ASSERT(object_p->gc_info.refs > 0);
@@ -95,31 +95,31 @@ ecma_deref_object(ecma_object_t *object_p) /**< object */
* is less than generation of object specified by obj_p.
*/
void
ecma_gc_update_may_ref_younger_object_flag_by_value( ecma_object_t *obj_p, /**< object */
ecma_gc_update_may_ref_younger_object_flag_by_value (ecma_object_t *obj_p, /**< object */
ecma_value_t value) /**< value */
{
if ( value.value_type != ECMA_TYPE_OBJECT )
if (value.value_type != ECMA_TYPE_OBJECT)
{
return;
}
ecma_object_t *ref_obj_p = ECMA_GET_POINTER( value.value);
JERRY_ASSERT( ref_obj_p != NULL );
ecma_object_t *ref_obj_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(ref_obj_p != NULL);
ecma_gc_update_may_ref_younger_object_flag_by_object( obj_p, ref_obj_p);
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, ref_obj_p);
} /* ecma_gc_update_may_ref_younger_object_flag_by_value */
void
ecma_gc_update_may_ref_younger_object_flag_by_object( ecma_object_t *obj_p, /**< object */
ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, /**< object */
ecma_object_t *ref_obj_p) /**< referenced object
or NULL */
{
if ( ref_obj_p == NULL )
if (ref_obj_p == NULL)
{
return;
}
if ( ref_obj_p->gc_info.generation < obj_p->gc_info.generation )
if (ref_obj_p->gc_info.generation < obj_p->gc_info.generation)
{
obj_p->gc_info.may_ref_younger_objects = true;
}
@@ -129,9 +129,9 @@ ecma_gc_update_may_ref_younger_object_flag_by_object( ecma_object_t *obj_p, /**<
* Initialize garbage collector
*/
void
ecma_gc_init( void)
ecma_gc_init (void)
{
__memset( ecma_gc_objects_lists, 0, sizeof( ecma_gc_objects_lists));
__memset (ecma_gc_objects_lists, 0, sizeof (ecma_gc_objects_lists));
} /* ecma_gc_init */
/**
@@ -139,26 +139,26 @@ ecma_gc_init( void)
* if referenced object's generation is less or equal to maximum_gen_to_traverse.
*/
void
ecma_gc_mark( ecma_object_t *object_p, /**< start object */
ecma_gc_mark (ecma_object_t *object_p, /**< start object */
ecma_gc_gen_t maximum_gen_to_traverse) /**< start recursive traverse
if referenced object generation
is less or equal to maximum_gen_to_traverse */
{
JERRY_ASSERT( object_p != NULL );
JERRY_ASSERT(object_p != NULL);
object_p->gc_info.visited = true;
bool does_reference_object_to_traverse = false;
if ( object_p->is_lexical_environment )
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 )
if (!lex_env_p->gc_info.visited)
{
ecma_gc_mark( lex_env_p, ECMA_GC_GEN_COUNT);
ecma_gc_mark (lex_env_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
@@ -166,40 +166,40 @@ ecma_gc_mark( ecma_object_t *object_p, /**< start object */
}
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 )
if (!proto_p->gc_info.visited)
{
ecma_gc_mark( proto_p, ECMA_GC_GEN_COUNT);
ecma_gc_mark (proto_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
}
}
for ( ecma_property_t *property_p = ECMA_GET_POINTER( object_p->properties_p), *next_property_p;
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 = next_property_p)
{
next_property_p = ECMA_GET_POINTER( property_p->next_property_p);
next_property_p = ECMA_GET_POINTER(property_p->next_property_p);
switch ( (ecma_property_type_t) property_p->type )
switch ((ecma_property_type_t) property_p->type)
{
case ECMA_PROPERTY_NAMEDDATA:
{
ecma_value_t value = property_p->u.named_data_property.value;
if ( value.value_type == ECMA_TYPE_OBJECT )
if (value.value_type == ECMA_TYPE_OBJECT)
{
ecma_object_t *value_obj_p = ECMA_GET_POINTER( value.value);
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.generation <= maximum_gen_to_traverse)
{
if ( !value_obj_p->gc_info.visited )
if (!value_obj_p->gc_info.visited)
{
ecma_gc_mark( value_obj_p, ECMA_GC_GEN_COUNT);
ecma_gc_mark (value_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
@@ -211,29 +211,29 @@ ecma_gc_mark( ecma_object_t *object_p, /**< start object */
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);
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 != NULL)
{
if ( getter_obj_p->gc_info.generation <= maximum_gen_to_traverse )
if (getter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if ( !getter_obj_p->gc_info.visited )
if (!getter_obj_p->gc_info.visited)
{
ecma_gc_mark( getter_obj_p, ECMA_GC_GEN_COUNT);
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 != NULL)
{
if ( setter_obj_p->gc_info.generation <= maximum_gen_to_traverse )
if (setter_obj_p->gc_info.generation <= maximum_gen_to_traverse)
{
if ( !setter_obj_p->gc_info.visited )
if (!setter_obj_p->gc_info.visited)
{
ecma_gc_mark( setter_obj_p, ECMA_GC_GEN_COUNT);
ecma_gc_mark (setter_obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
@@ -248,7 +248,7 @@ ecma_gc_mark( ecma_object_t *object_p, /**< start object */
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 )
switch (property_id)
{
case ECMA_INTERNAL_PROPERTY_NUMBER_INDEXED_ARRAY_VALUES: /* an array */
case ECMA_INTERNAL_PROPERTY_STRING_INDEXED_ARRAY_VALUES: /* an array */
@@ -265,13 +265,13 @@ ecma_gc_mark( ecma_object_t *object_p, /**< start object */
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);
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.generation <= maximum_gen_to_traverse)
{
if ( !obj_p->gc_info.visited )
if (!obj_p->gc_info.visited)
{
ecma_gc_mark( obj_p, ECMA_GC_GEN_COUNT);
ecma_gc_mark (obj_p, ECMA_GC_GEN_COUNT);
}
does_reference_object_to_traverse = true;
@@ -286,7 +286,7 @@ ecma_gc_mark( ecma_object_t *object_p, /**< start object */
}
}
if ( !does_reference_object_to_traverse )
if (!does_reference_object_to_traverse)
{
object_p->gc_info.may_ref_younger_objects = false;
}
@@ -296,39 +296,39 @@ ecma_gc_mark( ecma_object_t *object_p, /**< start object */
* Free specified object
*/
void
ecma_gc_sweep( ecma_object_t *object_p) /**< object to free */
ecma_gc_sweep (ecma_object_t *object_p) /**< object to free */
{
JERRY_ASSERT( object_p != NULL
JERRY_ASSERT(object_p != NULL
&& !object_p->gc_info.visited
&& object_p->gc_info.refs == 0 );
&& object_p->gc_info.refs == 0);
for ( ecma_property_t *property = ECMA_GET_POINTER( object_p->properties_p),
for (ecma_property_t *property = ECMA_GET_POINTER(object_p->properties_p),
*next_property_p;
property != NULL;
property = next_property_p )
property = next_property_p)
{
next_property_p = ECMA_GET_POINTER( 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_dealloc_object (object_p);
} /* ecma_gc_sweep */
/**
* Run garbage collecting
*/
void
ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run collection on */
ecma_gc_run (ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run collection on */
{
JERRY_ASSERT( max_gen_to_collect < ECMA_GC_GEN_COUNT );
JERRY_ASSERT(max_gen_to_collect < ECMA_GC_GEN_COUNT);
/* 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_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 ];
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 = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
obj_iter_p->gc_info.visited = false;
}
@@ -336,16 +336,16 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
/* 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_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 ];
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 = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
if ( obj_iter_p->gc_info.refs > 0
&& !obj_iter_p->gc_info.visited )
if (obj_iter_p->gc_info.refs > 0
&& !obj_iter_p->gc_info.visited)
{
ecma_gc_mark( obj_iter_p, ECMA_GC_GEN_COUNT);
ecma_gc_mark (obj_iter_p, ECMA_GC_GEN_COUNT);
}
}
}
@@ -353,42 +353,42 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
/* 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_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 ];
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 = ECMA_GET_POINTER(obj_iter_p->gc_info.next))
{
if ( obj_iter_p->gc_info.may_ref_younger_objects > 0 )
if (obj_iter_p->gc_info.may_ref_younger_objects > 0)
{
ecma_gc_mark( obj_iter_p, max_gen_to_collect);
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
__memset( gen_last_obj_p, 0, sizeof(gen_last_obj_p) );
__memset (gen_last_obj_p, 0, sizeof (gen_last_obj_p));
#endif /* !JERRY_NDEBUG */
for ( ecma_gc_gen_t gen_id = 0; gen_id <= max_gen_to_collect; gen_id++ )
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 ],
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 )
obj_iter_p = obj_next_p)
{
obj_next_p = ECMA_GET_POINTER( obj_iter_p->gc_info.next);
obj_next_p = ECMA_GET_POINTER(obj_iter_p->gc_info.next);
if ( !obj_iter_p->gc_info.visited )
if (!obj_iter_p->gc_info.visited)
{
ecma_gc_sweep( obj_iter_p);
ecma_gc_sweep (obj_iter_p);
if ( likely( obj_prev_p != NULL ) )
if (likely (obj_prev_p != NULL))
{
ECMA_SET_POINTER( obj_prev_p->gc_info.next, obj_next_p);
ECMA_SET_POINTER(obj_prev_p->gc_info.next, obj_next_p);
}
else
{
@@ -399,7 +399,7 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
{
obj_prev_p = obj_iter_p;
if ( obj_iter_p->gc_info.generation != ECMA_GC_GEN_COUNT - 1 )
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++;
@@ -411,38 +411,38 @@ ecma_gc_run( ecma_gc_gen_t max_gen_to_collect) /**< maximum generation to run co
}
ecma_gc_gen_t gen_to_promote = max_gen_to_collect;
if ( unlikely( gen_to_promote == ECMA_GC_GEN_COUNT - 1 ) )
if (unlikely (gen_to_promote == ECMA_GC_GEN_COUNT - 1))
{
/* not promoting last generation */
gen_to_promote--;
}
/* promoting to next generation */
if ( gen_last_obj_p[ gen_to_promote ] != NULL )
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_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;
for (int32_t gen_id = (int32_t)gen_to_promote - 1;
gen_id >= 0;
gen_id-- )
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;
for (ecma_gc_gen_t gen_id = ECMA_GC_GEN_0;
gen_id < ECMA_GC_GEN_COUNT;
gen_id++ )
gen_id++)
{
for ( ecma_object_t *obj_iter_p = ecma_gc_objects_lists[ 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) )
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 */
+7 -7
View File
@@ -36,13 +36,13 @@ typedef enum
ECMA_GC_GEN_COUNT /**< generations' number */
} ecma_gc_gen_t;
extern void ecma_gc_init( void);
extern void ecma_init_gc_info(ecma_object_t *object_p);
extern void ecma_ref_object(ecma_object_t *object_p);
extern void ecma_deref_object(ecma_object_t *object_p);
extern void ecma_gc_update_may_ref_younger_object_flag_by_value( ecma_object_t *obj_p, ecma_value_t value);
extern void ecma_gc_update_may_ref_younger_object_flag_by_object( ecma_object_t *obj_p, ecma_object_t *ref_obj_p);
extern void ecma_gc_run( ecma_gc_gen_t max_gen_to_collect);
extern void ecma_gc_init (void);
extern void ecma_init_gc_info (ecma_object_t *object_p);
extern void ecma_ref_object (ecma_object_t *object_p);
extern void ecma_deref_object (ecma_object_t *object_p);
extern void ecma_gc_update_may_ref_younger_object_flag_by_value (ecma_object_t *obj_p, ecma_value_t value);
extern void ecma_gc_update_may_ref_younger_object_flag_by_object (ecma_object_t *obj_p, ecma_object_t *ref_obj_p);
extern void ecma_gc_run (ecma_gc_gen_t max_gen_to_collect);
#endif /* !ECMA_GC_H */
+6 -6
View File
@@ -21,7 +21,7 @@
*/
#ifndef JERRY_ECMA_GLOBALS_H
#define JERRY_ECMA_GLOBALS_H
#define JERRY_ECMA_GLOBALS_H
#include "globals.h"
#include "mem-allocator.h"
@@ -372,8 +372,8 @@ typedef struct ecma_object_t {
/** GC's information */
ecma_gc_info_t gc_info;
FIXME( Remove aligned attribute after packing the struct )
} __packed __attribute__((aligned(16))) ecma_object_t;
FIXME(Remove aligned attribute after packing the struct)
} __packed __attribute__ ((aligned (16))) ecma_object_t;
/**
* Description of ECMA property descriptor
@@ -467,7 +467,7 @@ typedef struct {
ecma_array_header_t header;
/** Elements */
uint8_t data[ sizeof(uint64_t) - sizeof (ecma_array_header_t) ];
uint8_t data[ sizeof (uint64_t) - sizeof (ecma_array_header_t) ];
} ecma_array_first_chunk_t;
/**
@@ -478,7 +478,7 @@ typedef struct {
uint16_t next_chunk_p;
/** Characters */
uint8_t data[ sizeof(uint64_t) - sizeof (uint16_t) ];
uint8_t data[ sizeof (uint64_t) - sizeof (uint16_t) ];
} ecma_array_non_first_chunk_t;
/**
@@ -505,7 +505,7 @@ typedef struct
* @}
*/
#endif /* JERRY_ECMA_GLOBALS_H */
#endif /* JERRY_ECMA_GLOBALS_H */
/**
* @}
+79 -79
View File
@@ -33,9 +33,9 @@
* false - otherwise.
*/
bool
ecma_is_value_empty( ecma_value_t value) /**< ecma-value */
ecma_is_value_empty (ecma_value_t value) /**< ecma-value */
{
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_EMPTY );
return (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_EMPTY);
} /* ecma_is_value_empty */
/**
@@ -45,9 +45,9 @@ ecma_is_value_empty( ecma_value_t value) /**< ecma-value */
* false - otherwise.
*/
bool
ecma_is_value_undefined( ecma_value_t value) /**< ecma-value */
ecma_is_value_undefined (ecma_value_t value) /**< ecma-value */
{
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_UNDEFINED );
return (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_UNDEFINED);
} /* ecma_is_value_undefined */
/**
@@ -57,9 +57,9 @@ ecma_is_value_undefined( ecma_value_t value) /**< ecma-value */
* false - otherwise.
*/
bool
ecma_is_value_null( ecma_value_t value) /**< ecma-value */
ecma_is_value_null (ecma_value_t value) /**< ecma-value */
{
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_NULL );
return (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_NULL);
} /* ecma_is_value_null */
/**
@@ -69,10 +69,10 @@ ecma_is_value_null( ecma_value_t value) /**< ecma-value */
* false - otherwise.
*/
bool
ecma_is_value_boolean( ecma_value_t value) /**< ecma-value */
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 ) );
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));
} /* ecma_is_value_boolean */
/**
@@ -85,18 +85,18 @@ ecma_is_value_boolean( ecma_value_t value) /**< ecma-value */
* false - otherwise.
*/
bool
ecma_is_value_true( ecma_value_t value) /**< ecma-value */
ecma_is_value_true (ecma_value_t value) /**< ecma-value */
{
JERRY_ASSERT( ecma_is_value_boolean( value) );
JERRY_ASSERT(ecma_is_value_boolean (value));
return ( value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE );
return (value.value_type == ECMA_TYPE_SIMPLE && value.value == ECMA_SIMPLE_VALUE_TRUE);
} /* ecma_is_value_true */
/**
* Simple value constructor
*/
ecma_value_t
ecma_make_simple_value( ecma_simple_value_t value) /**< simple value */
ecma_make_simple_value (ecma_simple_value_t value) /**< simple value */
{
return (ecma_value_t) { .value_type = ECMA_TYPE_SIMPLE, .value = value };
} /* ecma_make_simple_value */
@@ -105,14 +105,14 @@ ecma_make_simple_value( ecma_simple_value_t value) /**< simple value */
* Number value constructor
*/
ecma_value_t
ecma_make_number_value( ecma_number_t* num_p) /**< number to reference in value */
ecma_make_number_value (ecma_number_t* num_p) /**< number to reference in value */
{
JERRY_ASSERT( num_p != NULL );
JERRY_ASSERT(num_p != NULL);
ecma_value_t number_value;
number_value.value_type = ECMA_TYPE_NUMBER;
ECMA_SET_POINTER( number_value.value, num_p);
ECMA_SET_POINTER(number_value.value, num_p);
return number_value;
} /* ecma_make_number_value */
@@ -121,14 +121,14 @@ ecma_make_number_value( ecma_number_t* num_p) /**< number to reference in value
* String value constructor
*/
ecma_value_t
ecma_make_string_value( ecma_array_first_chunk_t* ecma_string_p) /**< string to reference in value */
ecma_make_string_value (ecma_array_first_chunk_t* ecma_string_p) /**< string to reference in value */
{
JERRY_ASSERT( ecma_string_p != NULL );
JERRY_ASSERT(ecma_string_p != NULL);
ecma_value_t string_value;
string_value.value_type = ECMA_TYPE_STRING;
ECMA_SET_POINTER( string_value.value, ecma_string_p);
ECMA_SET_POINTER(string_value.value, ecma_string_p);
return string_value;
} /* ecma_make_string_value */
@@ -137,14 +137,14 @@ ecma_make_string_value( ecma_array_first_chunk_t* ecma_string_p) /**< string to
* object value constructor
*/
ecma_value_t
ecma_make_object_value( ecma_object_t* object_p) /**< object to reference in value */
ecma_make_object_value (ecma_object_t* object_p) /**< object to reference in value */
{
JERRY_ASSERT( object_p != NULL );
JERRY_ASSERT(object_p != NULL);
ecma_value_t object_value;
object_value.value_type = ECMA_TYPE_OBJECT;
ECMA_SET_POINTER( object_value.value, object_p);
ECMA_SET_POINTER(object_value.value, object_p);
return object_value;
} /* ecma_make_object_value */
@@ -171,13 +171,13 @@ ecma_make_object_value( ecma_object_t* object_p) /**< object to reference in val
* @return See note.
*/
ecma_value_t
ecma_copy_value( const ecma_value_t value, /**< ecma-value */
ecma_copy_value (const ecma_value_t value, /**< ecma-value */
bool do_ref_if_object) /**< if the value is object value,
increment reference counter of object */
{
ecma_value_t value_copy;
switch ( (ecma_type_t)value.value_type )
switch ((ecma_type_t)value.value_type)
{
case ECMA_TYPE_SIMPLE:
{
@@ -187,37 +187,37 @@ ecma_copy_value( const ecma_value_t value, /**< ecma-value */
}
case ECMA_TYPE_NUMBER:
{
ecma_number_t *num_p = ECMA_GET_POINTER( value.value);
JERRY_ASSERT( num_p != NULL );
ecma_number_t *num_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(num_p != NULL);
ecma_number_t *number_copy_p = ecma_alloc_number();
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);
ECMA_SET_NON_NULL_POINTER(value_copy.value, number_copy_p);
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_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);
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);
ECMA_SET_POINTER(value_copy.value, string_copy_p);
break;
}
case ECMA_TYPE_OBJECT:
{
ecma_object_t *obj_p = ECMA_GET_POINTER( value.value);
JERRY_ASSERT( obj_p != NULL );
ecma_object_t *obj_p = ECMA_GET_POINTER(value.value);
JERRY_ASSERT(obj_p != NULL);
if ( do_ref_if_object )
if (do_ref_if_object)
{
ecma_ref_object( obj_p);
ecma_ref_object (obj_p);
}
value_copy = value;
@@ -237,11 +237,11 @@ ecma_copy_value( const ecma_value_t value, /**< ecma-value */
* Free the ecma-value
*/
void
ecma_free_value( ecma_value_t value, /**< value description */
ecma_free_value (ecma_value_t value, /**< value description */
bool do_deref_if_object) /**< if the value is object value,
decrement reference counter of object */
{
switch ( (ecma_type_t) value.value_type )
switch ((ecma_type_t) value.value_type)
{
case ECMA_TYPE_SIMPLE:
{
@@ -251,23 +251,23 @@ ecma_free_value( ecma_value_t value, /**< value description */
case ECMA_TYPE_NUMBER:
{
ecma_number_t *number_p = ECMA_GET_POINTER( value.value);
ecma_dealloc_number( number_p);
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);
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));
ecma_deref_object (ECMA_GET_POINTER(value.value));
}
break;
}
@@ -285,7 +285,7 @@ ecma_free_value( ecma_value_t value, /**< value description */
* @return completion value
*/
ecma_completion_value_t
ecma_make_completion_value(ecma_completion_type_t type, /**< type */
ecma_make_completion_value (ecma_completion_type_t type, /**< type */
ecma_value_t value, /**< value */
uint8_t target) /**< target */
{
@@ -298,15 +298,15 @@ ecma_make_completion_value(ecma_completion_type_t type, /**< type */
* @return completion value
*/
ecma_completion_value_t
ecma_make_simple_completion_value( ecma_simple_value_t simple_value) /**< simple ecma-value */
ecma_make_simple_completion_value (ecma_simple_value_t simple_value) /**< simple ecma-value */
{
JERRY_ASSERT( simple_value == ECMA_SIMPLE_VALUE_UNDEFINED
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_TRUE);
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value( simple_value),
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (simple_value),
ECMA_TARGET_ID_RESERVED);
} /* ecma_make_simple_completion_value */
@@ -316,13 +316,13 @@ ecma_make_simple_completion_value( ecma_simple_value_t simple_value) /**< simple
* @return 'throw' completion value
*/
ecma_completion_value_t
ecma_make_throw_value( ecma_object_t *exception_p) /**< an object */
ecma_make_throw_value (ecma_object_t *exception_p) /**< an object */
{
JERRY_ASSERT( exception_p != NULL && !exception_p->is_lexical_environment );
JERRY_ASSERT(exception_p != NULL && !exception_p->is_lexical_environment);
ecma_value_t exception = ecma_make_object_value( exception_p);
ecma_value_t exception = ecma_make_object_value (exception_p);
return ecma_make_completion_value(ECMA_COMPLETION_TYPE_THROW,
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_THROW,
exception,
ECMA_TARGET_ID_RESERVED);
} /* ecma_make_throw_value */
@@ -333,23 +333,23 @@ ecma_make_throw_value( ecma_object_t *exception_p) /**< an object */
* @return (normal, empty, reserved) completion value.
*/
ecma_completion_value_t
ecma_make_empty_completion_value( void)
ecma_make_empty_completion_value (void)
{
return ecma_make_completion_value( ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value( ECMA_SIMPLE_VALUE_EMPTY),
return ecma_make_completion_value (ECMA_COMPLETION_TYPE_NORMAL,
ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY),
ECMA_TARGET_ID_RESERVED);
} /* ecma_make_empty_completion_value */
/**
* Copy ecma-completion value.
*
* @return (source.type, ecma_copy_value( source.value), source.target).
* @return (source.type, ecma_copy_value (source.value), source.target).
*/
ecma_completion_value_t
ecma_copy_completion_value( ecma_completion_value_t value) /**< completion value */
ecma_copy_completion_value (ecma_completion_value_t value) /**< completion value */
{
return ecma_make_completion_value( value.type,
ecma_copy_value( value.value, true),
return ecma_make_completion_value (value.type,
ecma_copy_value (value.value, true),
value.target);
} /* ecma_copy_completion_value */
@@ -357,19 +357,19 @@ ecma_copy_completion_value( ecma_completion_value_t value) /**< completion value
* Free the completion value.
*/
void
ecma_free_completion_value( ecma_completion_value_t completion_value) /**< completion value */
ecma_free_completion_value (ecma_completion_value_t completion_value) /**< completion value */
{
switch ( completion_value.type )
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);
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 );
JERRY_ASSERT(completion_value.value.value_type == ECMA_TYPE_SIMPLE);
break;
}
} /* ecma_free_completion_value */
@@ -381,9 +381,9 @@ ecma_free_completion_value( ecma_completion_value_t completion_value) /**< compl
* false - otherwise.
*/
bool
ecma_is_completion_value_normal( ecma_completion_value_t value) /**< completion value */
ecma_is_completion_value_normal (ecma_completion_value_t value) /**< completion value */
{
return ( value.type == ECMA_COMPLETION_TYPE_NORMAL );
return (value.type == ECMA_COMPLETION_TYPE_NORMAL);
} /* ecma_is_completion_value_normal */
/**
@@ -393,9 +393,9 @@ ecma_is_completion_value_normal( ecma_completion_value_t value) /**< completion
* false - otherwise.
*/
bool
ecma_is_completion_value_throw( ecma_completion_value_t value) /**< completion value */
ecma_is_completion_value_throw (ecma_completion_value_t value) /**< completion value */
{
return ( value.type == ECMA_COMPLETION_TYPE_THROW );
return (value.type == ECMA_COMPLETION_TYPE_THROW);
} /* ecma_is_completion_value_throw */
/**
@@ -406,12 +406,12 @@ ecma_is_completion_value_throw( ecma_completion_value_t value) /**< completion v
* false - otherwise.
*/
bool
ecma_is_completion_value_normal_simple_value(ecma_completion_value_t value, /**< completion value */
ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, /**< completion value */
ecma_simple_value_t simple_value) /**< simple value to check for equality with */
{
return ( value.type == ECMA_COMPLETION_TYPE_NORMAL
return (value.type == ECMA_COMPLETION_TYPE_NORMAL
&& value.value.value_type == ECMA_TYPE_SIMPLE
&& value.value.value == simple_value );
&& value.value.value == simple_value);
} /* ecma_is_completion_value_normal_simple_value */
/**
@@ -422,9 +422,9 @@ ecma_is_completion_value_normal_simple_value(ecma_completion_value_t value, /**<
* false - otherwise.
*/
bool
ecma_is_completion_value_normal_true( ecma_completion_value_t value) /**< completion value */
ecma_is_completion_value_normal_true (ecma_completion_value_t value) /**< completion value */
{
return ecma_is_completion_value_normal_simple_value( value, ECMA_SIMPLE_VALUE_TRUE);
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_TRUE);
} /* ecma_is_completion_value_normal_true */
/**
@@ -435,9 +435,9 @@ ecma_is_completion_value_normal_true( ecma_completion_value_t value) /**< comple
* false - otherwise.
*/
bool
ecma_is_completion_value_normal_false( ecma_completion_value_t value) /**< completion value */
ecma_is_completion_value_normal_false (ecma_completion_value_t value) /**< completion value */
{
return ecma_is_completion_value_normal_simple_value( value, ECMA_SIMPLE_VALUE_FALSE);
return ecma_is_completion_value_normal_simple_value (value, ECMA_SIMPLE_VALUE_FALSE);
} /* ecma_is_completion_value_normal_false */
/**
@@ -448,10 +448,10 @@ ecma_is_completion_value_normal_false( ecma_completion_value_t value) /**< compl
* false - otherwise.
*/
bool
ecma_is_empty_completion_value( ecma_completion_value_t value) /**< completion value */
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) );
return (ecma_is_completion_value_normal (value)
&& ecma_is_value_empty (value.value));
} /* ecma_is_empty_completion_value */
/**
+157 -157
View File
@@ -36,18 +36,18 @@
* @return pointer to the object's descriptor
*/
ecma_object_t*
ecma_create_object( ecma_object_t *prototype_object_p, /**< pointer to prototybe of the object (or NULL) */
ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe of the object (or NULL) */
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->u.object.extensible = is_extensible;
ECMA_SET_POINTER( object_p->u.object.prototype_object_p, prototype_object_p);
ECMA_SET_POINTER(object_p->u.object.prototype_object_p, prototype_object_p);
object_p->u.object.type = type;
return object_p;
@@ -64,17 +64,17 @@ ecma_create_object( ecma_object_t *prototype_object_p, /**< pointer to prototybe
* @return pointer to the descriptor of lexical environment
*/
ecma_object_t*
ecma_create_decl_lex_env(ecma_object_t *outer_lexical_environment_p) /**< outer lexical environment */
ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer lexical environment */
{
ecma_object_t *new_lexical_environment_p = ecma_alloc_object();
ecma_init_gc_info( new_lexical_environment_p);
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
ecma_init_gc_info (new_lexical_environment_p);
new_lexical_environment_p->is_lexical_environment = true;
new_lexical_environment_p->u.lexical_environment.type = ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE;
new_lexical_environment_p->properties_p = ECMA_NULL_POINTER;
ECMA_SET_POINTER( new_lexical_environment_p->u.lexical_environment.outer_reference_p, outer_lexical_environment_p);
ECMA_SET_POINTER(new_lexical_environment_p->u.lexical_environment.outer_reference_p, outer_lexical_environment_p);
return new_lexical_environment_p;
} /* ecma_create_decl_lex_env */
@@ -90,29 +90,29 @@ ecma_create_decl_lex_env(ecma_object_t *outer_lexical_environment_p) /**< outer
* @return pointer to the descriptor of lexical environment
*/
ecma_object_t*
ecma_create_object_lex_env(ecma_object_t *outer_lexical_environment_p, /**< outer lexical environment */
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 */
{
JERRY_ASSERT( binding_obj_p != NULL );
JERRY_ASSERT(binding_obj_p != NULL);
ecma_object_t *new_lexical_environment_p = ecma_alloc_object();
ecma_init_gc_info( new_lexical_environment_p);
ecma_object_t *new_lexical_environment_p = ecma_alloc_object ();
ecma_init_gc_info (new_lexical_environment_p);
new_lexical_environment_p->is_lexical_environment = true;
new_lexical_environment_p->u.lexical_environment.type = ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND;
new_lexical_environment_p->properties_p = ECMA_NULL_POINTER;
ECMA_SET_POINTER( new_lexical_environment_p->u.lexical_environment.outer_reference_p, outer_lexical_environment_p);
ECMA_SET_POINTER(new_lexical_environment_p->u.lexical_environment.outer_reference_p, outer_lexical_environment_p);
ecma_property_t *provide_this_prop_p = ecma_create_internal_property( new_lexical_environment_p, ECMA_INTERNAL_PROPERTY_PROVIDE_THIS);
ecma_property_t *provide_this_prop_p = ecma_create_internal_property (new_lexical_environment_p, ECMA_INTERNAL_PROPERTY_PROVIDE_THIS);
provide_this_prop_p->u.internal_property.value = provide_this;
ecma_property_t *binding_object_prop_p = ecma_create_internal_property( new_lexical_environment_p, ECMA_INTERNAL_PROPERTY_BINDING_OBJECT);
ECMA_SET_POINTER( binding_object_prop_p->u.internal_property.value, binding_obj_p);
ecma_property_t *binding_object_prop_p = ecma_create_internal_property (new_lexical_environment_p, ECMA_INTERNAL_PROPERTY_BINDING_OBJECT);
ECMA_SET_POINTER(binding_object_prop_p->u.internal_property.value, binding_obj_p);
ecma_gc_update_may_ref_younger_object_flag_by_object( new_lexical_environment_p, binding_obj_p);
ecma_gc_update_may_ref_younger_object_flag_by_object (new_lexical_environment_p, binding_obj_p);
return new_lexical_environment_p;
} /* ecma_create_object_lex_env */
@@ -124,16 +124,16 @@ ecma_create_object_lex_env(ecma_object_t *outer_lexical_environment_p, /**< oute
* @return pointer to newly created property
*/
ecma_property_t*
ecma_create_internal_property(ecma_object_t *object_p, /**< the object */
ecma_create_internal_property (ecma_object_t *object_p, /**< the object */
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;
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;
@@ -148,21 +148,21 @@ ecma_create_internal_property(ecma_object_t *object_p, /**< the object */
* NULL - otherwise.
*/
ecma_property_t*
ecma_find_internal_property(ecma_object_t *object_p, /**< object descriptor */
ecma_find_internal_property (ecma_object_t *object_p, /**< object descriptor */
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);
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) )
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 )
if (property_p->u.internal_property.type == property_id)
{
return property_p;
}
@@ -181,12 +181,12 @@ ecma_find_internal_property(ecma_object_t *object_p, /**< object descriptor */
* @return pointer to the property
*/
ecma_property_t*
ecma_get_internal_property(ecma_object_t *object_p, /**< object descriptor */
ecma_get_internal_property (ecma_object_t *object_p, /**< object descriptor */
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;
} /* ecma_get_internal_property */
@@ -198,30 +198,30 @@ ecma_get_internal_property(ecma_object_t *object_p, /**< object descriptor */
* @return pointer to newly created property
*/
ecma_property_t*
ecma_create_named_data_property(ecma_object_t *obj_p, /**< object */
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 */
{
JERRY_ASSERT( obj_p != NULL && name_p != NULL );
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
ecma_property_t *prop_p = ecma_alloc_property();
ecma_property_t *prop_p = ecma_alloc_property ();
prop_p->type = ECMA_PROPERTY_NAMEDDATA;
ECMA_SET_NON_NULL_POINTER( prop_p->u.named_data_property.name_p, ecma_new_ecma_string( name_p));
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_data_property.name_p, ecma_new_ecma_string (name_p));
prop_p->u.named_data_property.writable = writable;
prop_p->u.named_data_property.enumerable = enumerable;
prop_p->u.named_data_property.configurable = configurable;
prop_p->u.named_data_property.value = ecma_make_simple_value( ECMA_SIMPLE_VALUE_UNDEFINED);
prop_p->u.named_data_property.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED);
ecma_property_t *list_head_p = ECMA_GET_POINTER( obj_p->properties_p);
ecma_property_t *list_head_p = ECMA_GET_POINTER(obj_p->properties_p);
ECMA_SET_POINTER( prop_p->next_property_p, list_head_p);
ECMA_SET_NON_NULL_POINTER( obj_p->properties_p, prop_p);
ECMA_SET_POINTER(prop_p->next_property_p, list_head_p);
ECMA_SET_NON_NULL_POINTER(obj_p->properties_p, prop_p);
return prop_p;
} /* ecma_create_named_data_property */
@@ -232,33 +232,33 @@ ecma_create_named_data_property(ecma_object_t *obj_p, /**< object */
* @return pointer to newly created property
*/
ecma_property_t*
ecma_create_named_accessor_property(ecma_object_t *obj_p, /**< object */
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 */
{
JERRY_ASSERT( obj_p != NULL && name_p != NULL );
JERRY_ASSERT(obj_p != NULL && name_p != NULL);
ecma_property_t *prop_p = ecma_alloc_property();
ecma_property_t *prop_p = ecma_alloc_property ();
prop_p->type = ECMA_PROPERTY_NAMEDACCESSOR;
ECMA_SET_NON_NULL_POINTER( prop_p->u.named_accessor_property.name_p, ecma_new_ecma_string( name_p));
ECMA_SET_NON_NULL_POINTER(prop_p->u.named_accessor_property.name_p, ecma_new_ecma_string (name_p));
ECMA_SET_POINTER( prop_p->u.named_accessor_property.get_p, get_p);
ecma_gc_update_may_ref_younger_object_flag_by_object( obj_p, get_p);
ECMA_SET_POINTER(prop_p->u.named_accessor_property.get_p, get_p);
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, get_p);
ECMA_SET_POINTER( prop_p->u.named_accessor_property.set_p, set_p);
ecma_gc_update_may_ref_younger_object_flag_by_object( obj_p, set_p);
ECMA_SET_POINTER(prop_p->u.named_accessor_property.set_p, set_p);
ecma_gc_update_may_ref_younger_object_flag_by_object (obj_p, set_p);
prop_p->u.named_accessor_property.enumerable = enumerable;
prop_p->u.named_accessor_property.configurable = configurable;
ecma_property_t *list_head_p = ECMA_GET_POINTER( obj_p->properties_p);
ECMA_SET_POINTER( prop_p->next_property_p, list_head_p);
ECMA_SET_NON_NULL_POINTER( obj_p->properties_p, prop_p);
ecma_property_t *list_head_p = ECMA_GET_POINTER(obj_p->properties_p);
ECMA_SET_POINTER(prop_p->next_property_p, list_head_p);
ECMA_SET_NON_NULL_POINTER(obj_p->properties_p, prop_p);
return prop_p;
} /* ecma_create_named_accessor_property */
@@ -270,32 +270,32 @@ ecma_create_named_accessor_property(ecma_object_t *obj_p, /**< object */
* NULL - otherwise.
*/
ecma_property_t*
ecma_find_named_property(ecma_object_t *obj_p, /**< object to find property in */
ecma_find_named_property (ecma_object_t *obj_p, /**< object to find property in */
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);
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) )
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 )
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_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);
property_name_p = ECMA_GET_POINTER(property_p->u.named_accessor_property.name_p);
} else
{
continue;
}
JERRY_ASSERT( property_name_p != NULL );
JERRY_ASSERT(property_name_p != NULL);
if ( ecma_compare_zt_string_to_ecma_string( name_p, property_name_p) )
if (ecma_compare_zt_string_to_ecma_string (name_p, property_name_p))
{
return property_p;
}
@@ -314,15 +314,15 @@ ecma_find_named_property(ecma_object_t *obj_p, /**< object to find property in *
* NULL - otherwise.
*/
ecma_property_t*
ecma_get_named_property(ecma_object_t *obj_p, /**< object to find property in */
ecma_get_named_property (ecma_object_t *obj_p, /**< object to find property in */
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;
} /* ecma_get_named_property */
@@ -337,15 +337,15 @@ ecma_get_named_property(ecma_object_t *obj_p, /**< object to find property in */
* NULL - otherwise.
*/
ecma_property_t*
ecma_get_named_data_property(ecma_object_t *obj_p, /**< object to find property in */
ecma_get_named_data_property (ecma_object_t *obj_p, /**< object to find property in */
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;
} /* ecma_get_named_data_property */
@@ -354,47 +354,47 @@ ecma_get_named_data_property(ecma_object_t *obj_p, /**< object to find property
* Free the named data property and values it references.
*/
void
ecma_free_named_data_property( ecma_property_t *property_p) /**< the property */
ecma_free_named_data_property (ecma_property_t *property_p) /**< the property */
{
JERRY_ASSERT( property_p->type == ECMA_PROPERTY_NAMEDDATA );
JERRY_ASSERT(property_p->type == ECMA_PROPERTY_NAMEDDATA);
ecma_free_array( ECMA_GET_POINTER( property_p->u.named_data_property.name_p));
ecma_free_value( property_p->u.named_data_property.value, false);
ecma_free_array (ECMA_GET_POINTER(property_p->u.named_data_property.name_p));
ecma_free_value (property_p->u.named_data_property.value, false);
ecma_dealloc_property( property_p);
ecma_dealloc_property (property_p);
} /* ecma_free_named_data_property */
/**
* Free the named accessor property and values it references.
*/
void
ecma_free_named_accessor_property( ecma_property_t *property_p) /**< the property */
ecma_free_named_accessor_property (ecma_property_t *property_p) /**< the property */
{
JERRY_ASSERT( property_p->type == ECMA_PROPERTY_NAMEDACCESSOR );
JERRY_ASSERT(property_p->type == ECMA_PROPERTY_NAMEDACCESSOR);
ecma_free_array( ECMA_GET_POINTER( property_p->u.named_accessor_property.name_p));
ecma_free_array (ECMA_GET_POINTER(property_p->u.named_accessor_property.name_p));
ecma_dealloc_property( property_p);
ecma_dealloc_property (property_p);
} /* ecma_free_named_accessor_property */
/**
* Free the internal property and values it references.
*/
void
ecma_free_internal_property( ecma_property_t *property_p) /**< the property */
ecma_free_internal_property (ecma_property_t *property_p) /**< the property */
{
JERRY_ASSERT( property_p->type == ECMA_PROPERTY_INTERNAL );
JERRY_ASSERT(property_p->type == 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 )
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 */
{
ecma_free_array( ECMA_GET_POINTER( property_value));
ecma_free_array (ECMA_GET_POINTER(property_value));
break;
}
@@ -410,34 +410,34 @@ ecma_free_internal_property( ecma_property_t *property_p) /**< the property */
}
}
ecma_dealloc_property( property_p);
ecma_dealloc_property (property_p);
} /* ecma_free_internal_property */
/**
* Free the property and values it references.
*/
void
ecma_free_property(ecma_property_t *prop_p) /**< property */
ecma_free_property (ecma_property_t *prop_p) /**< property */
{
switch ( (ecma_property_type_t) prop_p->type )
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;
}
case ECMA_PROPERTY_NAMEDACCESSOR:
{
ecma_free_named_accessor_property( prop_p);
ecma_free_named_accessor_property (prop_p);
break;
}
case ECMA_PROPERTY_INTERNAL:
{
ecma_free_internal_property( prop_p);
ecma_free_internal_property (prop_p);
break;
}
@@ -450,25 +450,25 @@ ecma_free_property(ecma_property_t *prop_p) /**< property */
* Warning: specified property must be owned by specified object.
*/
void
ecma_delete_property(ecma_object_t *obj_p, /**< object */
ecma_delete_property (ecma_object_t *obj_p, /**< object */
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;
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 )
prev_prop_p = cur_prop_p, cur_prop_p = next_prop_p)
{
next_prop_p = ECMA_GET_POINTER( cur_prop_p->next_property_p);
next_prop_p = ECMA_GET_POINTER(cur_prop_p->next_property_p);
if ( cur_prop_p == prop_p )
if (cur_prop_p == prop_p)
{
ecma_free_property( prop_p);
ecma_free_property (prop_p);
if ( prev_prop_p == NULL )
if (prev_prop_p == NULL)
{
ECMA_SET_POINTER( obj_p->properties_p, next_prop_p);
ECMA_SET_POINTER(obj_p->properties_p, next_prop_p);
} else
{
ECMA_SET_POINTER( prev_prop_p->next_property_p, next_prop_p);
ECMA_SET_POINTER(prev_prop_p->next_property_p, next_prop_p);
}
return;
@@ -484,47 +484,47 @@ ecma_delete_property(ecma_object_t *obj_p, /**< object */
* @return Pointer to first chunk of an array, containing allocated string
*/
ecma_array_first_chunk_t*
ecma_new_ecma_string(const ecma_char_t *string_p) /**< zero-terminated string of ecma-characters */
ecma_new_ecma_string (const ecma_char_t *string_p) /**< zero-terminated string of ecma-characters */
{
ecma_length_t length = 0;
/*
* TODO: Do not precalculate length.
*/
if ( string_p != NULL )
if (string_p != NULL)
{
const ecma_char_t *iter_p = string_p;
while ( *iter_p++ )
while (*iter_p++)
{
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));
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 );
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 )
while (chars_left > 0)
{
string_non_first_chunk_p = ecma_alloc_array_non_first_chunk();
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));
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);
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;
}
@@ -543,16 +543,16 @@ ecma_new_ecma_string(const ecma_char_t *string_p) /**< zero-terminated string of
* to hold the string's content (in case size of buffer is insuficcient).
*/
ssize_t
ecma_copy_ecma_string_chars_to_buffer(ecma_array_first_chunk_t *first_chunk_p, /**< first chunk of ecma-string */
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 */
{
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 )
if (required_buffer_size > buffer_size)
{
return -(ssize_t) required_buffer_size;
return - (ssize_t) required_buffer_size;
}
*(ecma_length_t*) buffer_p = string_length;
@@ -561,23 +561,23 @@ ecma_copy_ecma_string_chars_to_buffer(ecma_array_first_chunk_t *first_chunk_p, /
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);
ecma_array_non_first_chunk_t *non_first_chunk_p = ECMA_GET_POINTER(first_chunk_p->header.next_chunk_p);
while ( chars_left > 0 )
while (chars_left > 0)
{
JERRY_ASSERT( chars_left < string_length );
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));
__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);
non_first_chunk_p = ECMA_GET_POINTER(non_first_chunk_p->next_chunk_p);
}
return (ssize_t) required_buffer_size;
@@ -589,26 +589,26 @@ ecma_copy_ecma_string_chars_to_buffer(ecma_array_first_chunk_t *first_chunk_p, /
* @return pointer to new ecma-string's first chunk
*/
ecma_array_first_chunk_t*
ecma_duplicate_ecma_string( ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of string to duplicate */
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);
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 )
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);
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;
@@ -623,10 +623,10 @@ ecma_duplicate_ecma_string( ecma_array_first_chunk_t *first_chunk_p) /**< first
* false - otherwise.
*/
bool
ecma_compare_ecma_string_to_ecma_string(const ecma_array_first_chunk_t *string1_p, /* ecma-string */
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 */
{
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS( string1_p, string2_p);
JERRY_UNIMPLEMENTED_REF_UNUSED_VARS(string1_p, string2_p);
} /* ecma_compare_ecma_string_to_ecma_string */
/**
@@ -636,41 +636,41 @@ ecma_compare_ecma_string_to_ecma_string(const ecma_array_first_chunk_t *string1_
* false - otherwise.
*/
bool
ecma_compare_zt_string_to_ecma_string(const ecma_char_t *string_p, /**< zero-terminated string */
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 */
{
JERRY_ASSERT( string_p != NULL );
JERRY_ASSERT( ecma_string_p != NULL );
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));
+ sizeof (ecma_string_p->data));
JERRY_STATIC_ASSERT( ECMA_POINTER_FIELD_WIDTH <= sizeof(uint16_t) * JERRY_BITSINBYTE );
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;
for (ecma_length_t str_index = 0;
str_index < ecma_str_len;
str_index++, str_iter_p++, current_chunk_chars_cur++ )
str_index++, str_iter_p++, current_chunk_chars_cur++)
{
JERRY_ASSERT( current_chunk_chars_cur <= current_chunk_chars_end );
JERRY_ASSERT(current_chunk_chars_cur <= current_chunk_chars_end);
if ( current_chunk_chars_cur == current_chunk_chars_end )
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);
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_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 )
if (*str_iter_p != *current_chunk_chars_cur)
{
/*
* Either *str_iter_p is 0 (zero-terminated string is shorter),
@@ -688,26 +688,26 @@ ecma_compare_zt_string_to_ecma_string(const ecma_char_t *string_p, /**< zero-ter
* If we have also reached end of zero-terminated string, than strings are equal.
* Otherwise zero-terminated string is longer.
*/
return ( *str_iter_p == 0 );
return (*str_iter_p == 0);
} /* ecma_compare_zt_string_to_ecma_string */
/**
* Free all chunks of an array
*/
void
ecma_free_array( ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of the array */
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 )
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_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;
}
@@ -720,11 +720,11 @@ ecma_free_array( ecma_array_first_chunk_t *first_chunk_p) /**< first chunk of th
* and rest properties set to default values (ECMA-262 v5, Table 7).
*/
ecma_property_descriptor_t
ecma_make_empty_property_descriptor( void)
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),
.value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_UNDEFINED),
.is_writable_defined = false,
.writable = ECMA_PROPERTY_NOT_WRITABLE,
+55 -55
View File
@@ -29,88 +29,88 @@
/**
* Get value of pointer from specified compressed pointer field.
*/
#define ECMA_GET_POINTER( field) \
( ( unlikely( field == ECMA_NULL_POINTER ) ) ? NULL : mem_decompress_pointer( field) )
#define ECMA_GET_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) \
#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) )
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) )
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) \
(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);
extern bool ecma_is_value_undefined( ecma_value_t value);
extern bool ecma_is_value_null( ecma_value_t value);
extern bool ecma_is_value_boolean( ecma_value_t value);
extern bool ecma_is_value_true( ecma_value_t value);
extern bool ecma_is_value_empty (ecma_value_t value);
extern bool ecma_is_value_undefined (ecma_value_t value);
extern bool ecma_is_value_null (ecma_value_t value);
extern bool ecma_is_value_boolean (ecma_value_t value);
extern bool ecma_is_value_true (ecma_value_t value);
extern ecma_value_t ecma_make_simple_value( ecma_simple_value_t value);
extern ecma_value_t ecma_make_number_value( ecma_number_t* num_p);
extern ecma_value_t ecma_make_string_value( ecma_array_first_chunk_t* ecma_string_p);
extern ecma_value_t ecma_make_object_value( ecma_object_t* object_p);
extern ecma_value_t ecma_copy_value( const ecma_value_t value, bool do_ref_if_object);
extern void ecma_free_value( const ecma_value_t value, bool do_deref_if_object);
extern ecma_value_t ecma_make_simple_value (ecma_simple_value_t value);
extern ecma_value_t ecma_make_number_value (ecma_number_t* num_p);
extern ecma_value_t ecma_make_string_value (ecma_array_first_chunk_t* ecma_string_p);
extern ecma_value_t ecma_make_object_value (ecma_object_t* object_p);
extern ecma_value_t ecma_copy_value (const ecma_value_t value, bool do_ref_if_object);
extern void ecma_free_value (const ecma_value_t value, bool do_deref_if_object);
extern ecma_completion_value_t ecma_make_completion_value( ecma_completion_type_t type, ecma_value_t value, uint8_t target);
extern ecma_completion_value_t ecma_make_simple_completion_value( ecma_simple_value_t simple_value);
extern ecma_completion_value_t ecma_make_throw_value( ecma_object_t *exception_p);
extern ecma_completion_value_t ecma_make_empty_completion_value( void);
extern ecma_completion_value_t ecma_copy_completion_value( ecma_completion_value_t value);
extern void ecma_free_completion_value( ecma_completion_value_t completion_value);
extern ecma_completion_value_t ecma_make_completion_value (ecma_completion_type_t type, ecma_value_t value, uint8_t target);
extern ecma_completion_value_t ecma_make_simple_completion_value (ecma_simple_value_t simple_value);
extern ecma_completion_value_t ecma_make_throw_value (ecma_object_t *exception_p);
extern ecma_completion_value_t ecma_make_empty_completion_value (void);
extern ecma_completion_value_t ecma_copy_completion_value (ecma_completion_value_t value);
extern void ecma_free_completion_value (ecma_completion_value_t completion_value);
extern bool ecma_is_completion_value_normal( ecma_completion_value_t value);
extern bool ecma_is_completion_value_throw( ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_simple_value( ecma_completion_value_t value, ecma_simple_value_t simple_value);
extern bool ecma_is_completion_value_normal_true( ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_false( ecma_completion_value_t value);
extern bool ecma_is_empty_completion_value( ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal (ecma_completion_value_t value);
extern bool ecma_is_completion_value_throw (ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_simple_value (ecma_completion_value_t value, ecma_simple_value_t simple_value);
extern bool ecma_is_completion_value_normal_true (ecma_completion_value_t value);
extern bool ecma_is_completion_value_normal_false (ecma_completion_value_t value);
extern bool ecma_is_empty_completion_value (ecma_completion_value_t value);
/* ecma-helpers.c */
extern ecma_object_t* ecma_create_object( ecma_object_t *prototype_object_p, bool is_extensible, ecma_object_type_t type);
extern ecma_object_t* ecma_create_decl_lex_env( ecma_object_t *outer_lexical_environment_p);
extern ecma_object_t* ecma_create_object_lex_env( ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p, bool provide_this);
extern ecma_object_t* ecma_create_object (ecma_object_t *prototype_object_p, bool is_extensible, ecma_object_type_t type);
extern ecma_object_t* ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p);
extern ecma_object_t* ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, ecma_object_t *binding_obj_p, bool provide_this);
extern ecma_property_t* ecma_create_internal_property(ecma_object_t *object_p, ecma_internal_property_id_t property_id);
extern ecma_property_t* ecma_find_internal_property(ecma_object_t *object_p, ecma_internal_property_id_t property_id);
extern ecma_property_t* ecma_get_internal_property(ecma_object_t *object_p, ecma_internal_property_id_t property_id);
extern ecma_property_t* ecma_create_internal_property (ecma_object_t *object_p, ecma_internal_property_id_t property_id);
extern ecma_property_t* ecma_find_internal_property (ecma_object_t *object_p, ecma_internal_property_id_t property_id);
extern ecma_property_t* ecma_get_internal_property (ecma_object_t *object_p, ecma_internal_property_id_t property_id);
extern ecma_property_t *ecma_create_named_data_property(ecma_object_t *obj_p, const ecma_char_t *name_p, ecma_property_writable_value_t writable, ecma_property_enumerable_value_t enumerable, ecma_property_configurable_value_t configurable);
extern ecma_property_t *ecma_create_named_accessor_property(ecma_object_t *obj_p, const ecma_char_t *name_p, ecma_object_t *get_p, ecma_object_t *set_p, ecma_property_enumerable_value_t enumerable, ecma_property_configurable_value_t configurable);
extern ecma_property_t *ecma_find_named_property(ecma_object_t *obj_p, const ecma_char_t *name_p);
extern ecma_property_t *ecma_get_named_property(ecma_object_t *obj_p, const ecma_char_t *name_p);
extern ecma_property_t *ecma_get_named_data_property(ecma_object_t *obj_p, const ecma_char_t *name_p);
extern ecma_property_t *ecma_create_named_data_property (ecma_object_t *obj_p, const ecma_char_t *name_p, ecma_property_writable_value_t writable, ecma_property_enumerable_value_t enumerable, ecma_property_configurable_value_t configurable);
extern ecma_property_t *ecma_create_named_accessor_property (ecma_object_t *obj_p, const ecma_char_t *name_p, ecma_object_t *get_p, ecma_object_t *set_p, ecma_property_enumerable_value_t enumerable, ecma_property_configurable_value_t configurable);
extern ecma_property_t *ecma_find_named_property (ecma_object_t *obj_p, const ecma_char_t *name_p);
extern ecma_property_t *ecma_get_named_property (ecma_object_t *obj_p, const ecma_char_t *name_p);
extern ecma_property_t *ecma_get_named_data_property (ecma_object_t *obj_p, const ecma_char_t *name_p);
extern void ecma_free_internal_property(ecma_property_t *prop_p);
extern void ecma_free_named_data_property(ecma_property_t *prop_p);
extern void ecma_free_named_accessor_property(ecma_property_t *prop_p);
extern void ecma_free_property(ecma_property_t *prop_p);
extern void ecma_free_internal_property (ecma_property_t *prop_p);
extern void ecma_free_named_data_property (ecma_property_t *prop_p);
extern void ecma_free_named_accessor_property (ecma_property_t *prop_p);
extern void ecma_free_property (ecma_property_t *prop_p);
extern void ecma_delete_property( ecma_object_t *obj_p, ecma_property_t *prop_p);
extern void ecma_delete_property (ecma_object_t *obj_p, ecma_property_t *prop_p);
extern ecma_array_first_chunk_t* ecma_new_ecma_string( const ecma_char_t *string_p);
extern ssize_t ecma_copy_ecma_string_chars_to_buffer( ecma_array_first_chunk_t *first_chunk_p, uint8_t *buffer_p, size_t buffer_size);
extern ecma_array_first_chunk_t* ecma_duplicate_ecma_string( ecma_array_first_chunk_t *first_chunk_p);
extern bool ecma_compare_zt_string_to_ecma_string( const ecma_char_t *string_p, const ecma_array_first_chunk_t *ecma_string_p);
extern bool ecma_compare_ecma_string_to_ecma_string(const ecma_array_first_chunk_t *string1_p, const ecma_array_first_chunk_t *string2_p);
extern void ecma_free_array( ecma_array_first_chunk_t *first_chunk_p);
extern ecma_array_first_chunk_t* ecma_new_ecma_string (const ecma_char_t *string_p);
extern ssize_t ecma_copy_ecma_string_chars_to_buffer (ecma_array_first_chunk_t *first_chunk_p, uint8_t *buffer_p, size_t buffer_size);
extern ecma_array_first_chunk_t* ecma_duplicate_ecma_string (ecma_array_first_chunk_t *first_chunk_p);
extern bool ecma_compare_zt_string_to_ecma_string (const ecma_char_t *string_p, const ecma_array_first_chunk_t *ecma_string_p);
extern bool ecma_compare_ecma_string_to_ecma_string (const ecma_array_first_chunk_t *string1_p, const ecma_array_first_chunk_t *string2_p);
extern void ecma_free_array (ecma_array_first_chunk_t *first_chunk_p);
extern ecma_property_descriptor_t ecma_make_empty_property_descriptor( void);
extern ecma_property_descriptor_t ecma_make_empty_property_descriptor (void);
#endif /* !JERRY_ECMA_HELPERS_H */