mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Replace bit field manipulation functions with macros
JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
parent
5d3aa98b3b
commit
c9f5950e15
@ -94,7 +94,7 @@ ecma_gc_get_object_refs (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
return (uint32_t) jrt_extract_bit_field (object_p->container,
|
||||
return (uint32_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_GC_REFS_POS,
|
||||
ECMA_OBJECT_GC_REFS_WIDTH);
|
||||
} /* ecma_gc_get_object_refs */
|
||||
@ -108,7 +108,7 @@ ecma_gc_set_object_refs (ecma_object_t *object_p, /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
refs,
|
||||
ECMA_OBJECT_GC_REFS_POS,
|
||||
ECMA_OBJECT_GC_REFS_WIDTH);
|
||||
@ -123,7 +123,7 @@ ecma_gc_get_object_next (ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
uintptr_t next_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
uintptr_t next_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_GC_NEXT_CP_POS,
|
||||
ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
|
||||
@ -144,7 +144,7 @@ ecma_gc_set_object_next (ecma_object_t *object_p, /**< object */
|
||||
ECMA_SET_POINTER (next_cp, next_object_p);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
next_cp,
|
||||
ECMA_OBJECT_GC_NEXT_CP_POS,
|
||||
ECMA_OBJECT_GC_NEXT_CP_WIDTH);
|
||||
@ -158,7 +158,7 @@ ecma_gc_is_object_visited (ecma_object_t *object_p) /**< object */
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
bool flag_value = (bool) jrt_extract_bit_field (object_p->container,
|
||||
bool flag_value = (bool) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_GC_VISITED_POS,
|
||||
ECMA_OBJECT_GC_VISITED_WIDTH);
|
||||
|
||||
@ -179,7 +179,7 @@ ecma_gc_set_object_visited (ecma_object_t *object_p, /**< object */
|
||||
is_visited = !is_visited;
|
||||
}
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
is_visited,
|
||||
ECMA_OBJECT_GC_VISITED_POS,
|
||||
ECMA_OBJECT_GC_VISITED_WIDTH);
|
||||
|
||||
@ -39,7 +39,7 @@ JERRY_STATIC_ASSERT (sizeof (ecma_value_t) * JERRY_BITSINBYTE >= ECMA_VALUE_SIZE
|
||||
ecma_type_t __attr_pure___
|
||||
ecma_get_value_type_field (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (ecma_type_t) jrt_extract_bit_field (value,
|
||||
return (ecma_type_t) JRT_EXTRACT_BIT_FIELD (ecma_value_t, value,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_get_value_type_field */
|
||||
@ -52,7 +52,7 @@ ecma_get_value_type_field (ecma_value_t value) /**< ecma value */
|
||||
static uintptr_t __attr_pure___
|
||||
ecma_get_value_value_field (ecma_value_t value) /**< ecma value */
|
||||
{
|
||||
return (uintptr_t) jrt_extract_bit_field (value,
|
||||
return (uintptr_t) JRT_EXTRACT_BIT_FIELD (ecma_value_t, value,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_get_value_value_field */
|
||||
@ -66,10 +66,10 @@ static ecma_value_t __attr_pure___
|
||||
ecma_set_value_type_field (ecma_value_t value, /**< ecma value to set field in */
|
||||
ecma_type_t type_field) /**< new field value */
|
||||
{
|
||||
return (ecma_value_t) jrt_set_bit_field_value (value,
|
||||
type_field,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
return JRT_SET_BIT_FIELD_VALUE (ecma_value_t, value,
|
||||
type_field,
|
||||
ECMA_VALUE_TYPE_POS,
|
||||
ECMA_VALUE_TYPE_WIDTH);
|
||||
} /* ecma_set_value_type_field */
|
||||
|
||||
/**
|
||||
@ -81,10 +81,10 @@ static ecma_value_t __attr_pure___
|
||||
ecma_set_value_value_field (ecma_value_t value, /**< ecma value to set field in */
|
||||
uintptr_t value_field) /**< new field value */
|
||||
{
|
||||
return (ecma_value_t) jrt_set_bit_field_value (value,
|
||||
value_field,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
return JRT_SET_BIT_FIELD_VALUE (ecma_value_t, value,
|
||||
value_field,
|
||||
ECMA_VALUE_VALUE_POS,
|
||||
ECMA_VALUE_VALUE_WIDTH);
|
||||
} /* ecma_set_value_value_field */
|
||||
|
||||
/**
|
||||
|
||||
@ -48,19 +48,19 @@ ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe
|
||||
|
||||
ecma_init_gc_info (object_p);
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
ECMA_NULL_POINTER,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
false,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
is_extensible,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_POS,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH);
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
type,
|
||||
ECMA_OBJECT_OBJ_TYPE_POS,
|
||||
ECMA_OBJECT_OBJ_TYPE_WIDTH);
|
||||
@ -68,7 +68,7 @@ ecma_create_object (ecma_object_t *prototype_object_p, /**< pointer to prototybe
|
||||
uint64_t prototype_object_cp;
|
||||
ECMA_SET_POINTER (prototype_object_cp, prototype_object_p);
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
prototype_object_cp,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
|
||||
@ -95,23 +95,23 @@ ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
ECMA_NULL_POINTER,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
true,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_POS,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
|
||||
|
||||
uint64_t outer_reference_cp;
|
||||
ECMA_SET_POINTER (outer_reference_cp, outer_lexical_environment_p);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
outer_reference_cp,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
@ -120,7 +120,7 @@ ecma_create_decl_lex_env (ecma_object_t *outer_lexical_environment_p) /**< outer
|
||||
* Declarative lexical environments do not really have the flag,
|
||||
* but to not leave the value initialized, setting the flag to false.
|
||||
*/
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
false,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH);
|
||||
@ -150,31 +150,31 @@ ecma_create_object_lex_env (ecma_object_t *outer_lexical_environment_p, /**< out
|
||||
|
||||
ecma_init_gc_info (new_lexical_environment_p);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
true,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_POS,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
|
||||
|
||||
uint64_t outer_reference_cp;
|
||||
ECMA_SET_POINTER (outer_reference_cp, outer_lexical_environment_p);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
outer_reference_cp,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
provide_this,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH);
|
||||
|
||||
uint64_t bound_object_cp;
|
||||
ECMA_SET_NON_NULL_POINTER (bound_object_cp, binding_obj_p);
|
||||
new_lexical_environment_p->container = jrt_set_bit_field_value (new_lexical_environment_p->container,
|
||||
new_lexical_environment_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, new_lexical_environment_p->container,
|
||||
bound_object_cp,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
@ -190,7 +190,7 @@ ecma_is_lexical_environment (const ecma_object_t *object_p) /**< object or lexic
|
||||
{
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
|
||||
return (bool) jrt_extract_bit_field (object_p->container,
|
||||
return (bool) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_POS,
|
||||
ECMA_OBJECT_IS_LEXICAL_ENVIRONMENT_WIDTH);
|
||||
} /* ecma_is_lexical_environment */
|
||||
@ -204,7 +204,7 @@ ecma_get_object_extensible (const ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
return (bool) jrt_extract_bit_field (object_p->container,
|
||||
return (bool) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_POS,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH);
|
||||
} /* ecma_get_object_extensible */
|
||||
@ -219,7 +219,7 @@ ecma_set_object_extensible (ecma_object_t *object_p, /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
is_extensible,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_POS,
|
||||
ECMA_OBJECT_OBJ_EXTENSIBLE_WIDTH);
|
||||
@ -234,7 +234,7 @@ ecma_get_object_type (const ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
return (ecma_object_type_t) jrt_extract_bit_field (object_p->container,
|
||||
return (ecma_object_type_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_OBJ_TYPE_POS,
|
||||
ECMA_OBJECT_OBJ_TYPE_WIDTH);
|
||||
} /* ecma_get_object_type */
|
||||
@ -249,7 +249,7 @@ ecma_set_object_type (ecma_object_t *object_p, /**< object */
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
type,
|
||||
ECMA_OBJECT_OBJ_TYPE_POS,
|
||||
ECMA_OBJECT_OBJ_TYPE_WIDTH);
|
||||
@ -265,7 +265,7 @@ ecma_get_object_prototype (const ecma_object_t *object_p) /**< object */
|
||||
JERRY_ASSERT (!ecma_is_lexical_environment (object_p));
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
|
||||
uintptr_t prototype_object_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
uintptr_t prototype_object_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_OBJ_PROTOTYPE_OBJECT_CP_WIDTH);
|
||||
return ECMA_GET_POINTER (ecma_object_t,
|
||||
@ -288,7 +288,7 @@ ecma_get_object_is_builtin (const ecma_object_t *object_p) /**< object */
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= width);
|
||||
|
||||
uintptr_t flag_value = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
uintptr_t flag_value = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
offset,
|
||||
width);
|
||||
|
||||
@ -308,8 +308,8 @@ ecma_set_object_is_builtin (ecma_object_t *object_p, /**< object */
|
||||
const uint32_t offset = ECMA_OBJECT_OBJ_IS_BUILTIN_POS;
|
||||
const uint32_t width = ECMA_OBJECT_OBJ_IS_BUILTIN_WIDTH;
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
(uintptr_t) is_builtin,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
is_builtin,
|
||||
offset,
|
||||
width);
|
||||
} /* ecma_set_object_is_builtin */
|
||||
@ -323,7 +323,7 @@ ecma_get_lex_env_type (const ecma_object_t *object_p) /**< lexical environment *
|
||||
JERRY_ASSERT (object_p != NULL);
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
|
||||
|
||||
return (ecma_lexical_environment_type_t) jrt_extract_bit_field (object_p->container,
|
||||
return (ecma_lexical_environment_type_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_POS,
|
||||
ECMA_OBJECT_LEX_ENV_TYPE_WIDTH);
|
||||
} /* ecma_get_lex_env_type */
|
||||
@ -338,7 +338,7 @@ ecma_get_lex_env_outer_reference (const ecma_object_t *object_p) /**< lexical en
|
||||
JERRY_ASSERT (ecma_is_lexical_environment (object_p));
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
uintptr_t outer_reference_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
uintptr_t outer_reference_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_POS,
|
||||
ECMA_OBJECT_LEX_ENV_OUTER_REFERENCE_CP_WIDTH);
|
||||
return ECMA_GET_POINTER (ecma_object_t,
|
||||
@ -359,7 +359,7 @@ ecma_get_property_list (const ecma_object_t *object_p) /**< object or lexical en
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_DECLARATIVE);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
uintptr_t properties_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
uintptr_t properties_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
return ECMA_GET_POINTER (ecma_property_t,
|
||||
@ -383,7 +383,7 @@ ecma_set_property_list (ecma_object_t *object_p, /**< object or lexical environm
|
||||
uint64_t properties_cp;
|
||||
ECMA_SET_POINTER (properties_cp, property_list_p);
|
||||
|
||||
object_p->container = jrt_set_bit_field_value (object_p->container,
|
||||
object_p->container = JRT_SET_BIT_FIELD_VALUE (uint64_t, object_p->container,
|
||||
properties_cp,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
@ -400,7 +400,7 @@ ecma_get_lex_env_provide_this (const ecma_object_t *object_p) /**< object-bound
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
bool provide_this = (jrt_extract_bit_field (object_p->container,
|
||||
bool provide_this = (JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_POS,
|
||||
ECMA_OBJECT_LEX_ENV_PROVIDE_THIS_WIDTH) != 0);
|
||||
|
||||
@ -418,7 +418,7 @@ ecma_get_lex_env_binding_object (const ecma_object_t *object_p) /**< object-boun
|
||||
ecma_get_lex_env_type (object_p) == ECMA_LEXICAL_ENVIRONMENT_OBJECTBOUND);
|
||||
|
||||
JERRY_ASSERT (sizeof (uintptr_t) * JERRY_BITSINBYTE >= ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
uintptr_t object_cp = (uintptr_t) jrt_extract_bit_field (object_p->container,
|
||||
uintptr_t object_cp = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uint64_t, object_p->container,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_POS,
|
||||
ECMA_OBJECT_PROPERTIES_OR_BOUND_OBJECT_CP_WIDTH);
|
||||
return ECMA_GET_NON_NULL_POINTER (ecma_object_t, object_cp);
|
||||
|
||||
@ -111,10 +111,10 @@ ecma_builtin_global_object_print (ecma_value_t this_arg __attr_unused___, /**< t
|
||||
JERRY_STATIC_ASSERT (sizeof (code_point) == 2,
|
||||
size_of_code_point_must_be_equal_to_2_bytes);
|
||||
|
||||
uint32_t byte_high = (uint32_t) jrt_extract_bit_field (code_point,
|
||||
uint32_t byte_high = (uint32_t) JRT_EXTRACT_BIT_FIELD (ecma_char_t, code_point,
|
||||
JERRY_BITSINBYTE,
|
||||
JERRY_BITSINBYTE);
|
||||
uint32_t byte_low = (uint32_t) jrt_extract_bit_field (code_point,
|
||||
uint32_t byte_low = (uint32_t) JRT_EXTRACT_BIT_FIELD (ecma_char_t, code_point,
|
||||
0,
|
||||
JERRY_BITSINBYTE);
|
||||
|
||||
|
||||
@ -313,7 +313,7 @@ ecma_builtin_try_to_instantiate_property (ecma_object_t *object_p, /**< object *
|
||||
|
||||
JERRY_STATIC_ASSERT (sizeof (uint8_t) * JERRY_BITSINBYTE == ECMA_BUILTIN_ROUTINE_ID_LENGTH_VALUE_WIDTH,
|
||||
bits_in_uint8_t_must_be_equal_to_ECMA_BUILTIN_ROUTINE_ID_LENGTH_VALUE_WIDTH);
|
||||
uint8_t length_prop_value = (uint8_t) jrt_extract_bit_field (builtin_routine_desc,
|
||||
uint8_t length_prop_value = (uint8_t) JRT_EXTRACT_BIT_FIELD (uint64_t, builtin_routine_desc,
|
||||
ECMA_BUILTIN_ROUTINE_ID_LENGTH_VALUE_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_LENGTH_VALUE_WIDTH);
|
||||
|
||||
@ -476,15 +476,15 @@ ecma_builtin_make_function_object_for_routine (ecma_builtin_id_t builtin_id, /**
|
||||
|
||||
ecma_set_object_is_builtin (func_obj_p, true);
|
||||
|
||||
uint64_t packed_value = jrt_set_bit_field_value (0,
|
||||
uint64_t packed_value = JRT_SET_BIT_FIELD_VALUE (uint64_t, 0ull,
|
||||
builtin_id,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_OBJECT_ID_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_OBJECT_ID_WIDTH);
|
||||
packed_value = jrt_set_bit_field_value (packed_value,
|
||||
packed_value = JRT_SET_BIT_FIELD_VALUE (uint64_t, packed_value,
|
||||
routine_id,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_WIDTH);
|
||||
packed_value = jrt_set_bit_field_value (packed_value,
|
||||
packed_value = JRT_SET_BIT_FIELD_VALUE (uint64_t, packed_value,
|
||||
length_prop_value,
|
||||
ECMA_BUILTIN_ROUTINE_ID_LENGTH_VALUE_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_LENGTH_VALUE_WIDTH);
|
||||
@ -519,12 +519,12 @@ ecma_builtin_dispatch_call (ecma_object_t *obj_p, /**< built-in object */
|
||||
ECMA_INTERNAL_PROPERTY_BUILT_IN_ROUTINE_DESC);
|
||||
uint64_t builtin_routine_desc = desc_prop_p->u.internal_property.value;
|
||||
|
||||
uint64_t built_in_id_field = jrt_extract_bit_field (builtin_routine_desc,
|
||||
uint64_t built_in_id_field = JRT_EXTRACT_BIT_FIELD (uint64_t, builtin_routine_desc,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_OBJECT_ID_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_OBJECT_ID_WIDTH);
|
||||
JERRY_ASSERT (built_in_id_field < ECMA_BUILTIN_ID__COUNT);
|
||||
|
||||
uint64_t routine_id_field = jrt_extract_bit_field (builtin_routine_desc,
|
||||
uint64_t routine_id_field = JRT_EXTRACT_BIT_FIELD (uint64_t, builtin_routine_desc,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_POS,
|
||||
ECMA_BUILTIN_ROUTINE_ID_BUILT_IN_ROUTINE_ID_WIDTH);
|
||||
JERRY_ASSERT ((uint16_t) routine_id_field == routine_id_field);
|
||||
|
||||
@ -1,62 +0,0 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "jrt.h"
|
||||
#include "jrt-bit-fields.h"
|
||||
|
||||
/**
|
||||
* Extract a bit-field from the integer.
|
||||
*
|
||||
* @return bit-field's value
|
||||
*/
|
||||
uint64_t __attr_const___
|
||||
jrt_extract_bit_field (uint64_t container, /**< container to extract bit-field from */
|
||||
size_t lsb, /**< least significant bit of the value
|
||||
* to be extracted */
|
||||
size_t width) /**< width of the bit-field to be extracted */
|
||||
{
|
||||
JERRY_ASSERT (lsb < JERRY_BITSINBYTE * sizeof (uint64_t));
|
||||
JERRY_ASSERT (width < JERRY_BITSINBYTE * sizeof (uint64_t));
|
||||
JERRY_ASSERT ((lsb + width) <= JERRY_BITSINBYTE * sizeof (uint64_t));
|
||||
|
||||
uint64_t shifted_value = container >> lsb;
|
||||
uint64_t bit_field_mask = (1ull << width) - 1;
|
||||
|
||||
return (shifted_value & bit_field_mask);
|
||||
} /* jrt_extract_bit_field */
|
||||
|
||||
/**
|
||||
* Extract a bit-field from the integer.
|
||||
*
|
||||
* @return bit-field's value
|
||||
*/
|
||||
uint64_t __attr_const___
|
||||
jrt_set_bit_field_value (uint64_t container, /**< container to insert bit-field to */
|
||||
uint64_t new_bit_field_value, /**< value of bit-field to insert */
|
||||
size_t lsb, /**< least significant bit of the value
|
||||
* to be extracted */
|
||||
size_t width) /**< width of the bit-field to be extracted */
|
||||
{
|
||||
JERRY_ASSERT (lsb < JERRY_BITSINBYTE * sizeof (uint64_t));
|
||||
JERRY_ASSERT (width < JERRY_BITSINBYTE * sizeof (uint64_t));
|
||||
JERRY_ASSERT ((lsb + width) <= JERRY_BITSINBYTE * sizeof (uint64_t));
|
||||
JERRY_ASSERT (new_bit_field_value < (1ull << width));
|
||||
|
||||
uint64_t bit_field_mask = (1ull << width) - 1;
|
||||
uint64_t shifted_bit_field_mask = bit_field_mask << lsb;
|
||||
uint64_t shifted_new_bit_field_value = new_bit_field_value << lsb;
|
||||
|
||||
return (container & ~shifted_bit_field_mask) | shifted_new_bit_field_value;
|
||||
} /* jrt_set_bit_field_value */
|
||||
@ -1,4 +1,5 @@
|
||||
/* Copyright 2014-2015 Samsung Electronics Co., Ltd.
|
||||
/* Copyright 2014-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2016 University of Szeged
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -16,7 +17,29 @@
|
||||
#ifndef JERRY_BIT_FIELDS_H
|
||||
#define JERRY_BIT_FIELDS_H
|
||||
|
||||
extern uint64_t __attr_const___ jrt_extract_bit_field (uint64_t, size_t, size_t);
|
||||
extern uint64_t __attr_const___ jrt_set_bit_field_value (uint64_t, uint64_t, size_t, size_t);
|
||||
/**
|
||||
* Extract a bit-field.
|
||||
*
|
||||
* @param type type of container
|
||||
* @param container container to extract bit-field from
|
||||
* @param lsb least significant bit of the value to be extracted
|
||||
* @param width width of the bit-field to be extracted
|
||||
* @return bit-field's value
|
||||
*/
|
||||
#define JRT_EXTRACT_BIT_FIELD(type, container, lsb, width) \
|
||||
(((container) >> lsb) & ((((type) 1) << (width)) - 1))
|
||||
|
||||
/**
|
||||
* Set a bit-field.
|
||||
*
|
||||
* @param type type of container
|
||||
* @param container container to insert bit-field to
|
||||
* @param new_bit_field_value value of bit-field to insert
|
||||
* @param lsb least significant bit of the value to be inserted
|
||||
* @param width width of the bit-field to be inserted
|
||||
* @return bit-field's value
|
||||
*/
|
||||
#define JRT_SET_BIT_FIELD_VALUE(type, container, new_bit_field_value, lsb, width) \
|
||||
(((container) & ~(((((type) 1) << (width)) - 1) << (lsb))) | (((type) new_bit_field_value) << (lsb)))
|
||||
|
||||
#endif /* !JERRY_BIT_FIELDS_H */
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/* Copyright 2015 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015 University of Szeged
|
||||
/* Copyright 2015-2016 Samsung Electronics Co., Ltd.
|
||||
* Copyright 2015-2016 University of Szeged
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@ -49,9 +49,9 @@ rcs_cpointer_compress (rcs_record_t *pointer) /**< pointer to compress */
|
||||
uintptr_t diff = (uintptr_t) pointer - base_pointer;
|
||||
|
||||
JERRY_ASSERT (diff < MEM_ALIGNMENT);
|
||||
JERRY_ASSERT (jrt_extract_bit_field (diff, 0, RCS_DYN_STORAGE_LENGTH_UNIT_LOG) == 0);
|
||||
JERRY_ASSERT (JRT_EXTRACT_BIT_FIELD (uintptr_t, diff, 0, RCS_DYN_STORAGE_LENGTH_UNIT_LOG) == 0);
|
||||
|
||||
uintptr_t ext_part = (uintptr_t) jrt_extract_bit_field (diff,
|
||||
uintptr_t ext_part = (uintptr_t) JRT_EXTRACT_BIT_FIELD (uintptr_t, diff,
|
||||
RCS_DYN_STORAGE_LENGTH_UNIT_LOG,
|
||||
MEM_ALIGNMENT_LOG - RCS_DYN_STORAGE_LENGTH_UNIT_LOG);
|
||||
|
||||
|
||||
@ -35,7 +35,7 @@ rcs_record_set_field (rcs_record_t *rec_p, /**< record */
|
||||
JERRY_ASSERT (field_pos + field_width <= RCS_DYN_STORAGE_LENGTH_UNIT * JERRY_BITSINBYTE);
|
||||
|
||||
uint32_t prev_value = *(uint32_t *) rec_p;
|
||||
*(uint32_t *) rec_p = (uint32_t) jrt_set_bit_field_value (prev_value, value, field_pos, field_width);
|
||||
*(uint32_t *) rec_p = JRT_SET_BIT_FIELD_VALUE (uint32_t, prev_value, value, field_pos, field_width);
|
||||
} /* rcs_record_set_field */
|
||||
|
||||
/**
|
||||
@ -222,7 +222,7 @@ rcs_record_get_field (rcs_record_t *rec_p, /**< record */
|
||||
JERRY_ASSERT (field_pos + field_width <= RCS_DYN_STORAGE_LENGTH_UNIT * JERRY_BITSINBYTE);
|
||||
|
||||
uint32_t value = *(uint32_t *) rec_p;
|
||||
return (uint32_t) jrt_extract_bit_field (value, field_pos, field_width);
|
||||
return JRT_EXTRACT_BIT_FIELD (uint32_t, value, field_pos, field_width);
|
||||
} /* rcs_record_get_field */
|
||||
|
||||
/**
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user