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
@@ -171,7 +171,7 @@ ecma_is_arraybuffer (ecma_value_t target) /**< the target value */
*
* @return ecma_length_t, the length of the arraybuffer
*/
ecma_length_t __attr_pure___
ecma_length_t JERRY_ATTR_PURE
ecma_arraybuffer_get_length (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */
{
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
@@ -185,7 +185,7 @@ ecma_arraybuffer_get_length (ecma_object_t *object_p) /**< pointer to the ArrayB
*
* @return pointer to the data buffer
*/
inline lit_utf8_byte_t * __attr_pure___ __attr_always_inline___
inline lit_utf8_byte_t * JERRY_ATTR_PURE JERRY_ATTR_ALWAYS_INLINE
ecma_arraybuffer_get_buffer (ecma_object_t *object_p) /**< pointer to the ArrayBuffer object */
{
JERRY_ASSERT (ecma_object_class_is (object_p, LIT_MAGIC_STRING_ARRAY_BUFFER_UL));
@@ -38,10 +38,10 @@ ecma_object_t *
ecma_arraybuffer_new_object_external (ecma_length_t length,
void *buffer_p,
ecma_object_native_free_callback_t free_cb);
lit_utf8_byte_t *
ecma_arraybuffer_get_buffer (ecma_object_t *obj_p) __attr_pure___;
ecma_length_t
ecma_arraybuffer_get_length (ecma_object_t *obj_p) __attr_pure___;
lit_utf8_byte_t * JERRY_ATTR_PURE
ecma_arraybuffer_get_buffer (ecma_object_t *obj_p);
ecma_length_t JERRY_ATTR_PURE
ecma_arraybuffer_get_length (ecma_object_t *obj_p);
bool
ecma_is_arraybuffer (ecma_value_t val);
+1 -1
View File
@@ -372,7 +372,7 @@ ecma_op_to_string (ecma_value_t value) /**< ecma value */
{
ecma_check_value_type_is_spec_defined (value);
if (unlikely (ecma_is_value_object (value)))
if (JERRY_UNLIKELY (ecma_is_value_object (value)))
{
ecma_value_t ret_value = ECMA_VALUE_EMPTY;
+1 -1
View File
@@ -282,7 +282,7 @@ ecma_raise_standard_error_with_format (ecma_standard_error_t error_type, /**< er
ecma_string_t *arg_string_p;
const ecma_value_t arg_val = va_arg (args, ecma_value_t);
if (unlikely (ecma_is_value_object (arg_val)))
if (JERRY_UNLIKELY (ecma_is_value_object (arg_val)))
{
ecma_object_t *arg_object_p = ecma_get_object_from_value (arg_val);
lit_magic_string_id_t class_name = ecma_object_get_class_name (arg_object_p);
@@ -40,7 +40,7 @@
* @return true - if the type is a normal or arrow function;
* false - otherwise
*/
inline bool __attr_always_inline___
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_normal_or_arrow_function (ecma_object_type_t type)
{
#ifndef CONFIG_DISABLE_ES2015_ARROW_FUNCTION
@@ -282,7 +282,7 @@ ecma_op_create_external_function_object (ecma_external_handler_t handler_cb) /**
*
* @return compiled code
*/
inline const ecma_compiled_code_t * __attr_always_inline___
inline const ecma_compiled_code_t * JERRY_ATTR_ALWAYS_INLINE
ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p) /**< function pointer */
{
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
@@ -308,7 +308,7 @@ ecma_op_function_get_compiled_code (ecma_extended_object_t *function_p) /**< fun
*
* @return compiled code
*/
inline const ecma_compiled_code_t * __attr_always_inline___
inline const ecma_compiled_code_t * JERRY_ATTR_ALWAYS_INLINE
ecma_op_arrow_function_get_compiled_code (ecma_arrow_function_t *arrow_function_p) /**< arrow function pointer */
{
#ifdef JERRY_ENABLE_SNAPSHOT_EXEC
@@ -434,7 +434,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
{
if (unlikely (ecma_get_object_is_builtin (func_obj_p)))
if (JERRY_UNLIKELY (ecma_get_object_is_builtin (func_obj_p)))
{
ret_value = ecma_builtin_dispatch_call (func_obj_p,
this_arg_value,
@@ -561,7 +561,7 @@ ecma_op_function_call (ecma_object_t *func_obj_p, /**< Function object */
arguments_list_p,
arguments_list_len);
if (unlikely (ecma_is_value_error_reference (ret_value)))
if (JERRY_UNLIKELY (ecma_is_value_error_reference (ret_value)))
{
JERRY_CONTEXT (error_value) = ecma_clear_error_reference (ret_value, true);
ret_value = ECMA_VALUE_ERROR;
@@ -741,7 +741,7 @@ ecma_op_function_construct (ecma_object_t *func_obj_p, /**< Function object */
if (ecma_get_object_type (func_obj_p) == ECMA_OBJECT_TYPE_FUNCTION)
{
if (unlikely (ecma_get_object_is_builtin (func_obj_p)
if (JERRY_UNLIKELY (ecma_get_object_is_builtin (func_obj_p)
&& !ecma_builtin_function_is_routine (func_obj_p)))
{
ret_value = ecma_builtin_dispatch_construct (func_obj_p,
@@ -50,7 +50,7 @@ ecma_op_get_value_lex_env_base (ecma_object_t *ref_base_lex_env_p, /**< referenc
const bool is_unresolvable_reference = (ref_base_lex_env_p == NULL);
/* 3. */
if (unlikely (is_unresolvable_reference))
if (JERRY_UNLIKELY (is_unresolvable_reference))
{
#ifdef JERRY_ENABLE_ERROR_MESSAGES
ecma_value_t var_name_val = ecma_make_string_value (var_name_string_p);
@@ -151,7 +151,7 @@ ecma_op_put_value_lex_env_base (ecma_object_t *ref_base_lex_env_p, /**< referenc
const bool is_unresolvable_reference = (ref_base_lex_env_p == NULL);
/* 3. */
if (unlikely (is_unresolvable_reference))
if (JERRY_UNLIKELY (is_unresolvable_reference))
{
/* 3.a. */
if (is_strict)
@@ -431,10 +431,10 @@ ecma_op_general_object_define_own_property (ecma_object_t *object_p, /**< the ob
{
/* No action required. */
}
else if (likely (property_desc_type == current_property_type))
else if (JERRY_LIKELY (property_desc_type == current_property_type))
{
/* If property is configurable, there is no need for checks. */
if (unlikely (!is_current_configurable))
if (JERRY_UNLIKELY (!is_current_configurable))
{
if (property_desc_type == ECMA_PROPERTY_TYPE_NAMEDDATA)
{
+5 -5
View File
@@ -353,7 +353,7 @@ ecma_op_object_get_property (ecma_object_t *object_p, /**< the object */
* @return true - if property is found
* false - otherwise
*/
inline bool __attr_always_inline___
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_op_object_has_own_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
@@ -371,7 +371,7 @@ ecma_op_object_has_own_property (ecma_object_t *object_p, /**< the object */
* @return true - if property is found
* false - otherwise
*/
inline bool __attr_always_inline___
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_op_object_has_property (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
@@ -639,7 +639,7 @@ ecma_op_object_find (ecma_object_t *object_p, /**< the object */
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
inline ecma_value_t __attr_always_inline___
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_op_object_get_own_data_prop (ecma_object_t *object_p, /**< the object */
ecma_string_t *property_name_p) /**< property name */
{
@@ -718,7 +718,7 @@ ecma_op_object_get (ecma_object_t *object_p, /**< the object */
* @return ecma value
* Returned value must be freed with ecma_free_value
*/
inline ecma_value_t __attr_always_inline___
inline ecma_value_t JERRY_ATTR_ALWAYS_INLINE
ecma_op_object_get_by_magic_id (ecma_object_t *object_p, /**< the object */
lit_magic_string_id_t property_id) /**< property magic string id */
{
@@ -1872,7 +1872,7 @@ ecma_object_get_class_name (ecma_object_t *obj_p) /**< object */
* @return value of the object if the class matches
* ECMA_VALUE_NOT_FOUND otherwise
*/
inline bool __attr_always_inline___
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_object_class_is (ecma_object_t *object_p, /**< object */
uint32_t class_id) /**< class id */
{
@@ -41,7 +41,7 @@
* @return true - if the object is a promise.
* false - otherwise.
*/
inline bool __attr_always_inline___
inline bool JERRY_ATTR_ALWAYS_INLINE
ecma_is_promise (ecma_object_t *obj_p) /**< points to object */
{
return ecma_object_class_is (obj_p, LIT_MAGIC_STRING_PROMISE_UL);
@@ -66,7 +66,7 @@ ecma_promise_get_result (ecma_object_t *obj_p) /**< points to promise object */
/**
* Set the PromiseResult of promise.
*/
inline void __attr_always_inline___
inline void JERRY_ATTR_ALWAYS_INLINE
ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */
ecma_value_t result) /**< the result value */
{
@@ -84,7 +84,7 @@ ecma_promise_set_result (ecma_object_t *obj_p, /**< points to promise object */
*
* @return the state's enum value
*/
inline uint8_t __attr_always_inline___
inline uint8_t JERRY_ATTR_ALWAYS_INLINE
ecma_promise_get_state (ecma_object_t *obj_p) /**< points to promise object */
{
JERRY_ASSERT (ecma_is_promise (obj_p));
@@ -95,7 +95,7 @@ ecma_promise_get_state (ecma_object_t *obj_p) /**< points to promise object */
/**
* Set the PromiseState of promise.
*/
inline void __attr_always_inline___
inline void JERRY_ATTR_ALWAYS_INLINE
ecma_promise_set_state (ecma_object_t *obj_p, /**< points to promise object */
uint8_t state) /**< the state */
{
@@ -302,7 +302,7 @@ ecma_op_create_regexp_object (ecma_string_t *pattern_p, /**< input pattern */
*
* @return ecma_char_t canonicalized character
*/
inline ecma_char_t __attr_always_inline___
inline ecma_char_t JERRY_ATTR_ALWAYS_INLINE
re_canonicalize (ecma_char_t ch, /**< character */
bool is_ignorecase) /**< IgnoreCase flag */
{
@@ -69,7 +69,7 @@
ecma_number_t num_var; \
return_value = ecma_get_number (value, &num_var); \
\
if (likely (ecma_is_value_empty (return_value))) \
if (JERRY_LIKELY (ecma_is_value_empty (return_value))) \
{
/**
@@ -490,7 +490,7 @@ ecma_op_typedarray_from (ecma_value_t items_val, /**< the source array-like obje
*
* @return the pointer to the internal arraybuffer
*/
inline ecma_object_t * __attr_always_inline___
inline ecma_object_t * JERRY_ATTR_ALWAYS_INLINE
ecma_typedarray_get_arraybuffer (ecma_object_t *typedarray_p) /**< the pointer to the typedarray object */
{
JERRY_ASSERT (ecma_is_typedarray (ecma_make_object_value (typedarray_p)));