Replace vera++ with clang-format (#4518)
JerryScript-DCO-1.0-Signed-off-by: Robert Fancsik robert.fancsik@h-lab.eu
This commit is contained in:
+47
-46
@@ -28,7 +28,7 @@
|
||||
/**
|
||||
* Logarithm of required alignment for allocated units/blocks
|
||||
*/
|
||||
#define JMEM_ALIGNMENT_LOG 3
|
||||
#define JMEM_ALIGNMENT_LOG 3
|
||||
|
||||
/**
|
||||
* Representation of NULL value for compressed pointers
|
||||
@@ -55,7 +55,7 @@
|
||||
/**
|
||||
* Shift for tag part in jmem_cpointer_tag_t
|
||||
*/
|
||||
#if defined (JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY) && JERRY_CPOINTER_32_BIT
|
||||
#if defined(JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY) && JERRY_CPOINTER_32_BIT
|
||||
#define JMEM_TAG_SHIFT 0
|
||||
#else /* !JMEM_CAN_STORE_POINTER_VALUE_DIRECTLY || !JERRY_CPOINTER_32_BIT */
|
||||
#define JMEM_TAG_SHIFT 3
|
||||
@@ -66,9 +66,9 @@
|
||||
*/
|
||||
enum
|
||||
{
|
||||
JMEM_FIRST_TAG_BIT_MASK = (1u << 0), /**< first tag bit mask **/
|
||||
JMEM_SECOND_TAG_BIT_MASK = (1u << 1), /**< second tag bit mask **/
|
||||
JMEM_THIRD_TAG_BIT_MASK = (1u << 2), /**< third tag bit mask **/
|
||||
JMEM_FIRST_TAG_BIT_MASK = (1u << 0), /**< first tag bit mask **/
|
||||
JMEM_SECOND_TAG_BIT_MASK = (1u << 1), /**< second tag bit mask **/
|
||||
JMEM_THIRD_TAG_BIT_MASK = (1u << 2), /**< third tag bit mask **/
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -117,7 +117,7 @@ typedef uint32_t jmem_cpointer_tag_t;
|
||||
typedef enum
|
||||
{
|
||||
JMEM_PRESSURE_NONE, /**< no memory pressure */
|
||||
JMEM_PRESSURE_LOW, /**< low memory pressure */
|
||||
JMEM_PRESSURE_LOW, /**< low memory pressure */
|
||||
JMEM_PRESSURE_HIGH, /**< high memory pressure */
|
||||
JMEM_PRESSURE_FULL, /**< memory full */
|
||||
} jmem_pressure_t;
|
||||
@@ -189,7 +189,7 @@ void jmem_heap_stats_print (void);
|
||||
#endif /* JERRY_MEM_STATS */
|
||||
|
||||
jmem_cpointer_t JERRY_ATTR_PURE jmem_compress_pointer (const void *pointer_p);
|
||||
void * JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
void *JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
|
||||
/**
|
||||
* Define a local array variable and allocate memory for the array on the heap.
|
||||
@@ -199,33 +199,32 @@ void * JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
* Warning:
|
||||
* if there is not enough memory on the heap, shutdown engine with ERR_OUT_OF_MEMORY.
|
||||
*/
|
||||
#define JMEM_DEFINE_LOCAL_ARRAY(var_name, number, type) \
|
||||
{ \
|
||||
size_t var_name ## ___size = (size_t) (number) * sizeof (type); \
|
||||
type *var_name = (type *) (jmem_heap_alloc_block (var_name ## ___size));
|
||||
#define JMEM_DEFINE_LOCAL_ARRAY(var_name, number, type) \
|
||||
{ \
|
||||
size_t var_name##___size = (size_t) (number) * sizeof (type); \
|
||||
type *var_name = (type *) (jmem_heap_alloc_block (var_name##___size));
|
||||
|
||||
/**
|
||||
* Free the previously defined local array variable, freeing corresponding block on the heap,
|
||||
* if it was allocated (i.e. if the array's size was non-zero).
|
||||
*/
|
||||
#define JMEM_FINALIZE_LOCAL_ARRAY(var_name) \
|
||||
if (var_name != NULL) \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name ## ___size != 0); \
|
||||
\
|
||||
jmem_heap_free_block (var_name, var_name ## ___size); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name ## ___size == 0); \
|
||||
} \
|
||||
}
|
||||
#define JMEM_FINALIZE_LOCAL_ARRAY(var_name) \
|
||||
if (var_name != NULL) \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name##___size != 0); \
|
||||
\
|
||||
jmem_heap_free_block (var_name, var_name##___size); \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
JERRY_ASSERT (var_name##___size == 0); \
|
||||
} \
|
||||
}
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified non-null compressed pointer value
|
||||
*/
|
||||
#define JMEM_CP_GET_NON_NULL_POINTER(type, cp_value) \
|
||||
((type *) (jmem_decompress_pointer (cp_value)))
|
||||
#define JMEM_CP_GET_NON_NULL_POINTER(type, cp_value) ((type *) (jmem_decompress_pointer (cp_value)))
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified compressed pointer value
|
||||
@@ -245,29 +244,29 @@ void * JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
* to specified non_compressed_pointer
|
||||
*/
|
||||
#define JMEM_CP_SET_POINTER(cp_value, non_compressed_pointer) \
|
||||
do \
|
||||
{ \
|
||||
void *ptr_value = (void *) non_compressed_pointer; \
|
||||
\
|
||||
if (JERRY_UNLIKELY ((ptr_value) == NULL)) \
|
||||
{ \
|
||||
(cp_value) = JMEM_CP_NULL; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
JMEM_CP_SET_NON_NULL_POINTER (cp_value, ptr_value); \
|
||||
} \
|
||||
do \
|
||||
{ \
|
||||
void *ptr_value = (void *) non_compressed_pointer; \
|
||||
\
|
||||
if (JERRY_UNLIKELY ((ptr_value) == NULL)) \
|
||||
{ \
|
||||
(cp_value) = JMEM_CP_NULL; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
JMEM_CP_SET_NON_NULL_POINTER (cp_value, ptr_value); \
|
||||
} \
|
||||
} while (false);
|
||||
|
||||
/**
|
||||
* Set value of pointer-tag value so that it will correspond
|
||||
* to specified non_compressed_pointer along with tag
|
||||
*/
|
||||
#define JMEM_CP_SET_NON_NULL_POINTER_TAG(cp_value, pointer, tag) \
|
||||
do \
|
||||
{ \
|
||||
JERRY_ASSERT ((uintptr_t) tag < (uintptr_t) (JMEM_ALIGNMENT)); \
|
||||
jmem_cpointer_tag_t compressed_ptr = jmem_compress_pointer (pointer); \
|
||||
#define JMEM_CP_SET_NON_NULL_POINTER_TAG(cp_value, pointer, tag) \
|
||||
do \
|
||||
{ \
|
||||
JERRY_ASSERT ((uintptr_t) tag < (uintptr_t) (JMEM_ALIGNMENT)); \
|
||||
jmem_cpointer_tag_t compressed_ptr = jmem_compress_pointer (pointer); \
|
||||
(cp_value) = (jmem_cpointer_tag_t) ((compressed_ptr << JMEM_TAG_SHIFT) | tag); \
|
||||
} while (false);
|
||||
|
||||
@@ -286,12 +285,14 @@ void * JERRY_ATTR_PURE jmem_decompress_pointer (uintptr_t compressed_pointer);
|
||||
/**
|
||||
* Get value of each tag from specified pointer-tag value
|
||||
*/
|
||||
#define JMEM_CP_GET_FIRST_BIT_FROM_POINTER_TAG(cp_value) \
|
||||
(cp_value & JMEM_FIRST_TAG_BIT_MASK) /**< get first tag bit **/
|
||||
#define JMEM_CP_GET_FIRST_BIT_FROM_POINTER_TAG(cp_value) \
|
||||
(cp_value & JMEM_FIRST_TAG_BIT_MASK) /**< get first tag bit \
|
||||
**/
|
||||
#define JMEM_CP_GET_SECOND_BIT_FROM_POINTER_TAG(cp_value) \
|
||||
(cp_value & JMEM_SECOND_TAG_BIT_MASK) /**< get second tag bit **/
|
||||
#define JMEM_CP_GET_THIRD_BIT_FROM_POINTER_TAG(cp_value) \
|
||||
(cp_value & JMEM_THIRD_TAG_BIT_MASK) /**< get third tag bit **/
|
||||
#define JMEM_CP_GET_THIRD_BIT_FROM_POINTER_TAG(cp_value) \
|
||||
(cp_value & JMEM_THIRD_TAG_BIT_MASK) /**< get third tag bit \
|
||||
**/
|
||||
|
||||
/**
|
||||
* Set value of each tag to specified pointer-tag value
|
||||
|
||||
Reference in New Issue
Block a user