Introducing MEM_CP_{GET_[NON_NULL_]POINTER, SET_[NON_NULL_]POINTER} getters / setters for compressed pointers.
JerryScript-DCO-1.0-Signed-off-by: Ruben Ayrapetyan r.ayrapetyan@samsung.com
This commit is contained in:
@@ -38,12 +38,12 @@
|
||||
* The offset is shifted right by MEM_ALIGNMENT_LOG.
|
||||
* Least significant MEM_ALIGNMENT_LOG bits of non-shifted offset are zeroes.
|
||||
*/
|
||||
#define ECMA_POINTER_FIELD_WIDTH MEM_COMPRESSED_POINTER_WIDTH
|
||||
#define ECMA_POINTER_FIELD_WIDTH MEM_CP_WIDTH
|
||||
|
||||
/**
|
||||
* The NULL value for compressed pointers
|
||||
*/
|
||||
#define ECMA_NULL_POINTER MEM_COMPRESSED_POINTER_NULL
|
||||
#define ECMA_NULL_POINTER MEM_CP_NULL
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
||||
@@ -27,44 +27,27 @@
|
||||
#include "mem-allocator.h"
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified non-null compressed pointer field.
|
||||
* Get value of pointer from specified non-null compressed pointer.
|
||||
*/
|
||||
#define ECMA_GET_NON_NULL_POINTER(type, field) \
|
||||
((type *) mem_decompress_pointer (field))
|
||||
#define ECMA_GET_NON_NULL_POINTER(type, field) MEM_CP_GET_NON_NULL_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Get value of pointer from specified compressed pointer field.
|
||||
* Get value of pointer from specified compressed pointer.
|
||||
*/
|
||||
#define ECMA_GET_POINTER(type, field) \
|
||||
(((unlikely (field == ECMA_NULL_POINTER)) ? NULL : ECMA_GET_NON_NULL_POINTER (type, field)))
|
||||
#define ECMA_GET_POINTER(type, field) MEM_CP_GET_POINTER (type, field)
|
||||
|
||||
/**
|
||||
* Set value of non-null compressed pointer field so that it will correspond
|
||||
* Set value of non-null compressed pointer 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) & \
|
||||
((((mem_cpointer_t) 1u) << ECMA_POINTER_FIELD_WIDTH) - 1))
|
||||
#define ECMA_SET_NON_NULL_POINTER(field, non_compressed_pointer) MEM_CP_SET_NON_NULL_POINTER (field, \
|
||||
non_compressed_pointer)
|
||||
|
||||
/**
|
||||
* Set value of compressed pointer field so that it will correspond
|
||||
* Set value of compressed pointer so that it will correspond
|
||||
* to specified non_compressed_pointer.
|
||||
*/
|
||||
#define ECMA_SET_POINTER(field, non_compressed_pointer) \
|
||||
do \
|
||||
{ \
|
||||
auto __temp_pointer = non_compressed_pointer; \
|
||||
non_compressed_pointer = __temp_pointer; \
|
||||
} while (0); \
|
||||
\
|
||||
if (unlikely ((non_compressed_pointer) == NULL)) \
|
||||
{ \
|
||||
(field) = ECMA_NULL_POINTER; \
|
||||
} \
|
||||
else \
|
||||
{ \
|
||||
ECMA_SET_NON_NULL_POINTER (field, non_compressed_pointer); \
|
||||
}
|
||||
#define ECMA_SET_POINTER(field, non_compressed_pointer) MEM_CP_SET_POINTER (field, non_compressed_pointer)
|
||||
|
||||
/* ecma-helpers-value.c */
|
||||
extern bool ecma_is_value_empty (ecma_value_t value);
|
||||
|
||||
Reference in New Issue
Block a user