Add jerryscript-compiler.h public header to cover compiler incompatibilities (#2313)

In general, public headers should not have compiler-specific
constructs but both the core and the port headers have attributes,
which are non-standard. It's better to factor out such constructs
to a common place (a new header) and hide them behind macros, which
can then be defined on a per-compiler basis.

This patch moves the existing definitions of function attributes and
likely/unlikely builtins to the new header. At the same time, it
unifies the names of these attribute defines and where they are
used. Moreover, it touches on jerry-main and removes the uses of
`__attribute__((unused))` entirely and replaces them with the
elsewhere used `(void) ...` pattern.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2018-05-14 02:41:26 +02:00
committed by yichoi
parent 0e131da4f7
commit 65ae949dc3
58 changed files with 433 additions and 340 deletions
+11 -11
View File
@@ -96,7 +96,7 @@
/**
* Get end of region
*/
static inline jmem_heap_free_t * __attr_always_inline___ __attr_pure___
static inline jmem_heap_free_t * JERRY_ATTR_ALWAYS_INLINE JERRY_ATTR_PURE
jmem_heap_get_region_end (jmem_heap_free_t *curr_p) /**< current region */
{
return (jmem_heap_free_t *)((uint8_t *) curr_p + curr_p->size);
@@ -193,7 +193,7 @@ jmem_heap_finalize (void)
* @return pointer to allocated memory block - if allocation is successful,
* NULL - if there is not enough memory.
*/
static __attr_hot___ void *
static void * JERRY_ATTR_HOT
jmem_heap_alloc_block_internal (const size_t size)
{
#ifndef JERRY_SYSTEM_ALLOCATOR
@@ -205,7 +205,7 @@ jmem_heap_alloc_block_internal (const size_t size)
/* Fast path for 8 byte chunks, first region is guaranteed to be sufficient. */
if (required_size == JMEM_ALIGNMENT
&& likely (JERRY_HEAP_CONTEXT (first).next_offset != JMEM_HEAP_END_OF_LIST))
&& JERRY_LIKELY (JERRY_HEAP_CONTEXT (first).next_offset != JMEM_HEAP_END_OF_LIST))
{
data_space_p = JMEM_HEAP_GET_ADDR_FROM_OFFSET (JERRY_HEAP_CONTEXT (first).next_offset);
JERRY_ASSERT (jmem_is_heap_pointer (data_space_p));
@@ -235,7 +235,7 @@ jmem_heap_alloc_block_internal (const size_t size)
VALGRIND_UNDEFINED_SPACE (data_space_p, sizeof (jmem_heap_free_t));
if (unlikely (data_space_p == JERRY_CONTEXT (jmem_heap_list_skip_p)))
if (JERRY_UNLIKELY (data_space_p == JERRY_CONTEXT (jmem_heap_list_skip_p)))
{
JERRY_CONTEXT (jmem_heap_list_skip_p) = JMEM_HEAP_GET_ADDR_FROM_OFFSET (JERRY_HEAP_CONTEXT (first).next_offset);
}
@@ -309,7 +309,7 @@ jmem_heap_alloc_block_internal (const size_t size)
VALGRIND_NOACCESS_SPACE (&JERRY_HEAP_CONTEXT (first), sizeof (jmem_heap_free_t));
if (unlikely (!data_space_p))
if (JERRY_UNLIKELY (!data_space_p))
{
return NULL;
}
@@ -341,7 +341,7 @@ jmem_heap_gc_and_alloc_block (const size_t size, /**< required memory size
bool ret_null_on_error) /**< indicates whether return null or terminate
with ERR_OUT_OF_MEMORY on out of memory */
{
if (unlikely (size == 0))
if (JERRY_UNLIKELY (size == 0))
{
return NULL;
}
@@ -359,7 +359,7 @@ jmem_heap_gc_and_alloc_block (const size_t size, /**< required memory size
void *data_space_p = jmem_heap_alloc_block_internal (size);
if (likely (data_space_p != NULL))
if (JERRY_LIKELY (data_space_p != NULL))
{
VALGRIND_FREYA_MALLOCLIKE_SPACE (data_space_p, size);
return data_space_p;
@@ -373,7 +373,7 @@ jmem_heap_gc_and_alloc_block (const size_t size, /**< required memory size
data_space_p = jmem_heap_alloc_block_internal (size);
if (likely (data_space_p != NULL))
if (JERRY_LIKELY (data_space_p != NULL))
{
VALGRIND_FREYA_MALLOCLIKE_SPACE (data_space_p, size);
return data_space_p;
@@ -400,7 +400,7 @@ jmem_heap_gc_and_alloc_block (const size_t size, /**< required memory size
* @return NULL, if the required memory is 0
* pointer to allocated memory block, otherwise
*/
inline void * __attr_hot___ __attr_always_inline___
inline void * JERRY_ATTR_HOT JERRY_ATTR_ALWAYS_INLINE
jmem_heap_alloc_block (const size_t size) /**< required memory size */
{
return jmem_heap_gc_and_alloc_block (size, false);
@@ -416,7 +416,7 @@ jmem_heap_alloc_block (const size_t size) /**< required memory size */
* also NULL, if the allocation has failed
* pointer to the allocated memory block, otherwise
*/
inline void * __attr_hot___ __attr_always_inline___
inline void * JERRY_ATTR_HOT JERRY_ATTR_ALWAYS_INLINE
jmem_heap_alloc_block_null_on_error (const size_t size) /**< required memory size */
{
return jmem_heap_gc_and_alloc_block (size, true);
@@ -425,7 +425,7 @@ jmem_heap_alloc_block_null_on_error (const size_t size) /**< required memory siz
/**
* Free the memory block.
*/
void __attr_hot___
void JERRY_ATTR_HOT
jmem_heap_free_block (void *ptr, /**< pointer to beginning of data space of the block */
const size_t size) /**< size of allocated region */
{