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
+3 -3
View File
@@ -33,7 +33,7 @@
*
* @return configuration flags
*/
static inline uint32_t __attr_always_inline___
static inline uint32_t JERRY_ATTR_ALWAYS_INLINE
snapshot_get_global_flags (bool has_regex) /**< regex literal is present */
{
JERRY_UNUSED (has_regex);
@@ -55,7 +55,7 @@ snapshot_get_global_flags (bool has_regex) /**< regex literal is present */
*
* @return true if global_flags accepted, false otherwise
*/
static inline bool __attr_always_inline___
static inline bool JERRY_ATTR_ALWAYS_INLINE
snapshot_check_global_flags (uint32_t global_flags) /**< global flags */
{
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
@@ -92,7 +92,7 @@ typedef struct
* @return true - if write was successful, i.e. offset + data_size doesn't exceed buffer size,
* false - otherwise
*/
static inline bool __attr_always_inline___
static inline bool JERRY_ATTR_ALWAYS_INLINE
snapshot_write_to_buffer_by_offset (uint8_t *buffer_p, /**< buffer */
size_t buffer_size, /**< size of buffer */
size_t *in_out_buffer_offset_p, /**< [in,out] offset to write to
+12 -12
View File
@@ -97,10 +97,10 @@ static const char * const wrong_args_msg_p = "wrong type of argument";
* - before jerry_init and after jerry_cleanup
* - between enter to and return from a native free callback
*/
static inline void __attr_always_inline___
static inline void JERRY_ATTR_ALWAYS_INLINE
jerry_assert_api_available (void)
{
if (unlikely (!(JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE)))
if (JERRY_UNLIKELY (!(JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE)))
{
/* Terminates the execution. */
JERRY_UNREACHABLE ();
@@ -110,7 +110,7 @@ jerry_assert_api_available (void)
/**
* Turn on API availability
*/
static inline void __attr_always_inline___
static inline void JERRY_ATTR_ALWAYS_INLINE
jerry_make_api_available (void)
{
JERRY_CONTEXT (status_flags) |= ECMA_STATUS_API_AVAILABLE;
@@ -119,7 +119,7 @@ jerry_make_api_available (void)
/**
* Turn off API availability
*/
static inline void __attr_always_inline___
static inline void JERRY_ATTR_ALWAYS_INLINE
jerry_make_api_unavailable (void)
{
JERRY_CONTEXT (status_flags) &= (uint32_t) ~ECMA_STATUS_API_AVAILABLE;
@@ -133,10 +133,10 @@ jerry_make_api_unavailable (void)
*
* @return return value for Jerry API functions
*/
static inline jerry_value_t __attr_always_inline___
static inline jerry_value_t JERRY_ATTR_ALWAYS_INLINE
jerry_get_arg_value (jerry_value_t value) /**< return value */
{
if (unlikely (ecma_is_value_error_reference (value)))
if (JERRY_UNLIKELY (ecma_is_value_error_reference (value)))
{
value = ecma_get_error_reference_from_value (value)->value;
}
@@ -165,7 +165,7 @@ jerry_return (jerry_value_t value) /**< return value */
*
* @return return value for Jerry API functions
*/
static inline jerry_value_t __attr_always_inline___
static inline jerry_value_t JERRY_ATTR_ALWAYS_INLINE
jerry_throw (jerry_value_t value) /**< return value */
{
JERRY_ASSERT (ECMA_IS_VALUE_ERROR (value));
@@ -178,7 +178,7 @@ jerry_throw (jerry_value_t value) /**< return value */
void
jerry_init (jerry_init_flag_t flags) /**< combination of Jerry flags */
{
if (unlikely (JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE))
if (JERRY_UNLIKELY (JERRY_CONTEXT (status_flags) & ECMA_STATUS_API_AVAILABLE))
{
/* This function cannot be called twice unless jerry_cleanup is called. */
JERRY_UNREACHABLE ();
@@ -947,7 +947,7 @@ jerry_value_set_error_flag (jerry_value_t *value_p)
{
jerry_assert_api_available ();
if (unlikely (ecma_is_value_error_reference (*value_p)))
if (JERRY_UNLIKELY (ecma_is_value_error_reference (*value_p)))
{
/* This is a rare case so it is optimized for
* binary size rather than performance. */
@@ -970,7 +970,7 @@ jerry_value_set_abort_flag (jerry_value_t *value_p)
{
jerry_assert_api_available ();
if (unlikely (ecma_is_value_error_reference (*value_p)))
if (JERRY_UNLIKELY (ecma_is_value_error_reference (*value_p)))
{
/* This is a rare case so it is optimized for
* binary size rather than performance. */
@@ -1182,7 +1182,7 @@ jerry_acquire_value (jerry_value_t value) /**< API value */
{
jerry_assert_api_available ();
if (unlikely (ecma_is_value_error_reference (value)))
if (JERRY_UNLIKELY (ecma_is_value_error_reference (value)))
{
ecma_ref_error_reference (ecma_get_error_reference_from_value (value));
return value;
@@ -1199,7 +1199,7 @@ jerry_release_value (jerry_value_t value) /**< API value */
{
jerry_assert_api_available ();
if (unlikely (ecma_is_value_error_reference (value)))
if (JERRY_UNLIKELY (ecma_is_value_error_reference (value)))
{
ecma_deref_error_reference (ecma_get_error_reference_from_value (value));
return;