ronantakizawa/codereview-bench huggingface dataset:
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-bigint.c (C)

Code before:
    {
      radix = 2;
      nonws_start_p += 2;
      size -= 2;
    }
  }
  else if (size >= 2)
  {
    if (nonws_start_p[0] == LIT_CHAR_PLUS)
    {
      size--;
      nonws_start_p++;
    }
    else if (nonws_start_p[0] == LIT_CHAR_MINUS)
    {
      sign = ECMA_BIGINT_SIGN;
      size--;
      nonws_start_p++;
    }
  }
  else if (size == 0)
  {
    return ECMA_BIGINT_ZERO;
  }

  const lit_utf8_byte_t *string_end_p = nonws_start_p + size;

  while (nonws_start_p < string_end_p && *nonws_start_p == LIT_CHAR_0)
  {
    nonws_start_p++;
  }

  ecma_extended_primitive_t *result_p = NULL;

  if (nonws_start_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*nonws_start_p >= LIT_CHAR_0 && *nonws_start_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*nonws_start_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*nonws_start_p);


Review comment (refactor):
I think we don't need to introduce new variables. Just move this defintion to the beginning of the function.

```
const lit_utf8_byte_t *string_end_p = string_p + size;
string_p = ecma_string_trim_front (string_p, string_end_p);
size = (lit_utf8_size_t ) (string_end_p - string_p);
```

Code after:
    {
      radix = 2;
      string_p += 2;
      size -= 2;
    }
  }
  else if (size >= 2)
  {
    if (string_p[0] == LIT_CHAR_PLUS)
    {
      size--;
      string_p++;
    }
    else if (string_p[0] == LIT_CHAR_MINUS)
    {
      sign = ECMA_BIGINT_SIGN;
      size--;
      string_p++;
    }
  }
  else if (size == 0)
  {
    return ECMA_BIGINT_ZERO;
  }

  while (string_p < string_end_p && *string_p == LIT_CHAR_0)
  {
    string_p++;
  }

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-bigint.c (C)

Code before:

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
        digit = (ecma_bigint_digit_t) (character - (LIT_CHAR_LOWERCASE_A - 10));
      }
    }
    if (ecma_string_trim_front (string_p, string_end_p) == string_end_p)
    {
      string_p = string_end_p;
      break;
    }
    if (digit >= radix)
    {
      if (result_p != NULL)
      {
        ecma_deref_bigint (result_p);
      }

      if (options & ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR)
      {
        return ECMA_VALUE_FALSE;
      }
      return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value"));
    }

    result_p = ecma_big_uint_mul_digit (result_p, radix, digit);

    if (JERRY_UNLIKELY (result_p == NULL))
    {
      break;
    }
  }

Review comment (suggestion):
this needs to be `else if` after `if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)`, otherwise we check spaces all the time, which is a considerable perf loss.

Code after:

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
        digit = (ecma_bigint_digit_t) (character - (LIT_CHAR_LOWERCASE_A - 10));
      }
      else if (ecma_string_trim_front (string_p, string_end_p) == string_end_p)
      {
        string_p = string_end_p;
        break;
      }
    }
    if (digit >= radix)
    {
      if (result_p != NULL)
      {
        ecma_deref_bigint (result_p);
      }

      if (options & ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR)
      {
        return ECMA_VALUE_FALSE;
      }
      return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value"));
    }

    result_p = ecma_big_uint_mul_digit (result_p, radix, digit);

    if (JERRY_UNLIKELY (result_p == NULL))
    {
      break;
    }
  }
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-bigint.c (C)

Code before:
    string_p++;
  }

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else if (ecma_string_trim_front (string_p, string_end_p) == string_end_p)
    {
      string_p = string_end_p;
      break;
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
        digit = (ecma_bigint_digit_t) (character - (LIT_CHAR_LOWERCASE_A - 10));
      }
    }
    if (digit >= radix)
    {
      if (result_p != NULL)
      {
        ecma_deref_bigint (result_p);
      }

      if (options & ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR)
      {
        return ECMA_VALUE_FALSE;
      }
      return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value"));
    }

    result_p = ecma_big_uint_mul_digit (result_p, radix, digit);

    if (JERRY_UNLIKELY (result_p == NULL))
    {
      break;

Review comment (suggestion):
Please check what I wrote. The `else if` code should be after this `}`.
So we only check spaces if the next character is not 0-9 and a-f

Code after:
    string_p++;
  }

  ecma_extended_primitive_t *result_p = NULL;

  if (string_p == string_end_p)
  {
    return ECMA_BIGINT_ZERO;
  }

  do
  {
    ecma_bigint_digit_t digit = radix;

    if (*string_p >= LIT_CHAR_0 && *string_p <= LIT_CHAR_9)
    {
      digit = (ecma_bigint_digit_t) (*string_p - LIT_CHAR_0);
    }
    else
    {
      lit_utf8_byte_t character = (lit_utf8_byte_t) LEXER_TO_ASCII_LOWERCASE (*string_p);

      if (character >= LIT_CHAR_LOWERCASE_A && character <= LIT_CHAR_LOWERCASE_F)
      {
        digit = (ecma_bigint_digit_t) (character - (LIT_CHAR_LOWERCASE_A - 10));
      }
      else if (ecma_string_trim_front (string_p, string_end_p) == string_end_p)
      {
        string_p = string_end_p;
        break;
      }
    }
    if (digit >= radix)
    {
      if (result_p != NULL)
      {
        ecma_deref_bigint (result_p);
      }

      if (options & ECMA_BIGINT_PARSE_DISALLOW_SYNTAX_ERROR)
      {
        return ECMA_VALUE_FALSE;
      }
      return ecma_raise_syntax_error (ECMA_ERR_MSG ("String cannot be converted to BigInt value"));
    }

    result_p = ecma_big_uint_mul_digit (result_p, radix, digit);

    if (JERRY_UNLIKELY (result_p == NULL))
    {
      break;
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-helpers-conversion.c (C)

Code before:
 * Number.MIN_VALUE exponent part when using 32 bit float representation.
 */
#define NUMBER_MIN_DECIMAL_EXPONENT -45

#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */

/**
 * Value of epsilon
 */
#define EPSILON 0.0000001

/**
 * ECMA-defined conversion from string to number for different radixes (2, 8, 16).
 *
 * See also:
 *          ECMA-262 v5 9.3.1
 *          ECMA-262 v6 7.1.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
static ecma_number_t
ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                                     const lit_utf8_byte_t *end_p, /**< end of utf-8 string  */
                                     uint32_t radix, /**< radix */
                                     bool allow_underscore)  /**< string can contains "_" character */
{
  JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);
  ecma_number_t num = ECMA_NUMBER_ZERO;

#if ENABLED (JERRY_ESNEXT)
  if (radix <= 8)
  {
    lit_code_point_t upper_limit = LIT_CHAR_0 + radix;

    for (const lit_utf8_byte_t * iter_p = str_p;  iter_p <= end_p; iter_p++)
    {
      int32_t digit_value;

      if (*iter_p >= LIT_CHAR_0 && *iter_p < upper_limit)
      {
        digit_value = (*iter_p - LIT_CHAR_0);
      }
      else
      {
        return ecma_number_make_nan ();
      }

      num = num * radix + (ecma_number_t) digit_value;
    }


Review comment (suggestion):
comment:
```
true - if '_' characters are allowed in the string
false - otherwise
```

Code after:
 * Number.MIN_VALUE exponent part when using 32 bit float representation.
 */
#define NUMBER_MIN_DECIMAL_EXPONENT -45

#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */

/**
 * Value of epsilon
 */
#define EPSILON 0.0000001

/**
 * ECMA-defined conversion from string to number for different radixes (2, 8, 16).
 *
 * See also:
 *          ECMA-262 v5 9.3.1
 *          ECMA-262 v6 7.1.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
static ecma_number_t
ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                                     const lit_utf8_byte_t *end_p, /**< end of utf-8 string  */
                                     uint32_t radix) /**< radix */
{
#if ENABLED (JERRY_ESNEXT)
  bool allow_underscore = (radix & ECMA_CONVERSION_ALLOW_UNDERSCORE);
  radix &= (uint32_t) ~ECMA_CONVERSION_ALLOW_UNDERSCORE;
#endif /* ENABLED (JERRY_ESNEXT) */
  JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);

  ecma_number_t num = ECMA_NUMBER_ZERO;

#if ENABLED (JERRY_ESNEXT)
  if (radix <= 8)
  {
    lit_code_point_t upper_limit = LIT_CHAR_0 + radix;

    for (const lit_utf8_byte_t * iter_p = str_p;  iter_p <= end_p; iter_p++)
    {
      int32_t digit_value;

      if (*iter_p >= LIT_CHAR_0 && *iter_p < upper_limit)
      {
        digit_value = (*iter_p - LIT_CHAR_0);
      }
      else
      {
        return ecma_number_make_nan ();
      }
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-helpers-conversion.c (C)

Code before:
#define NUMBER_MIN_DECIMAL_EXPONENT -45

#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */

/**
 * Value of epsilon
 */
#define EPSILON 0.0000001

/**
 * ECMA-defined conversion from string to number for different radixes (2, 8, 16).
 *
 * See also:
 *          ECMA-262 v5 9.3.1
 *          ECMA-262 v6 7.1.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
static ecma_number_t
ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                                     const lit_utf8_byte_t *end_p, /**< end of utf-8 string  */
                                     uint32_t radix) /**< radix */

{
  bool allow_underscore = (radix % 2) ? radix-- : false;

  JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);

  ecma_number_t num = ECMA_NUMBER_ZERO;

#if ENABLED (JERRY_ESNEXT)
  if (radix <= 8)
  {
    lit_code_point_t upper_limit = LIT_CHAR_0 + radix;

    for (const lit_utf8_byte_t * iter_p = str_p;  iter_p <= end_p; iter_p++)
    {
      int32_t digit_value;

      if (*iter_p >= LIT_CHAR_0 && *iter_p < upper_limit)
      {
        digit_value = (*iter_p - LIT_CHAR_0);
      }
      else
      {
        return ecma_number_make_nan ();
      }

      num = num * radix + (ecma_number_t) digit_value;
    }

Review comment (suggestion):
I find this strange, while it is true that it works in this case. I would prefer:

```
bool allow_underscore = (radix & 0x1);
radix &= (uint32_t) ~0x1;
```
Maybe we could add a define constant for 0x1

Furthermore guard this with JERRY_ESNEXT which makes the `JERRY_UNUSED (allow_underscore)` below unnecessary.

Code after:
#define NUMBER_MIN_DECIMAL_EXPONENT -45

#endif /* ENABLED (JERRY_NUMBER_TYPE_FLOAT64) */

/**
 * Value of epsilon
 */
#define EPSILON 0.0000001

/**
 * ECMA-defined conversion from string to number for different radixes (2, 8, 16).
 *
 * See also:
 *          ECMA-262 v5 9.3.1
 *          ECMA-262 v6 7.1.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
static ecma_number_t
ecma_utf8_string_to_number_by_radix (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                                     const lit_utf8_byte_t *end_p, /**< end of utf-8 string  */
                                     uint32_t radix) /**< radix */
{
#if ENABLED (JERRY_ESNEXT)
  bool allow_underscore = (radix & ECMA_CONVERSION_ALLOW_UNDERSCORE);
  radix &= (uint32_t) ~ECMA_CONVERSION_ALLOW_UNDERSCORE;
#endif /* ENABLED (JERRY_ESNEXT) */
  JERRY_ASSERT (radix == 2 || radix == 8 || radix == 16);

  ecma_number_t num = ECMA_NUMBER_ZERO;

#if ENABLED (JERRY_ESNEXT)
  if (radix <= 8)
  {
    lit_code_point_t upper_limit = LIT_CHAR_0 + radix;

    for (const lit_utf8_byte_t * iter_p = str_p;  iter_p <= end_p; iter_p++)
    {
      int32_t digit_value;

      if (*iter_p >= LIT_CHAR_0 && *iter_p < upper_limit)
      {
        digit_value = (*iter_p - LIT_CHAR_0);
      }
      else
      {
        return ecma_number_make_nan ();
      }

      num = num * radix + (ecma_number_t) digit_value;
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-helpers-conversion.c (C)

Code before:
    }
#endif /* ENABLED (JERRY_ESNEXT) */
    else
    {
      return ecma_number_make_nan ();
    }

    num = num * radix + (ecma_number_t) digit_value;
  }

  return num;
} /* ecma_utf8_string_to_number_by_radix */

/**
 * ECMA-defined conversion of string to Number.
 *
 * See also:
 *          ECMA-262 v5, 9.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
ecma_number_t
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                            lit_utf8_size_t str_size, /**< string size */
                            bool allow_underscore) /**< true - if '_' characters are allowed in the string
                                                        false - otherwise */
{
  /* TODO: Check license issues */

  if (str_size == 0)
  {
    return ECMA_NUMBER_ZERO;
  }

  ecma_string_trim_helper (&str_p, &str_size);
  const lit_utf8_byte_t *end_p = str_p + (str_size - 1);

  if (str_size < 1)
  {
    return ECMA_NUMBER_ZERO;
  }

  if (end_p >= str_p + 2
      && str_p[0] == LIT_CHAR_0)
  {
    switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
    {
      case LIT_CHAR_LOWERCASE_X :
      {
        return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 + (uint32_t) allow_underscore);

Review comment (suggestion):
This should be an uint32_t parameter which contains the defined flag.
Then you can:
`return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | underscore_flag);`
If you really want to keep the bool, you can create a local variable which contains the flag depending on the bool.

Code after:
#endif /* ENABLED (JERRY_ESNEXT) */
    else
    {
      return ecma_number_make_nan ();
    }

    num = num * radix + (ecma_number_t) digit_value;
  }

  return num;
} /* ecma_utf8_string_to_number_by_radix */

/**
 * ECMA-defined conversion of string to Number.
 *
 * See also:
 *          ECMA-262 v5, 9.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
ecma_number_t
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                            lit_utf8_size_t str_size, /**< string size */
                            uint32_t options) /**< allowing underscore option bit */
{
  /* TODO: Check license issues */

  if (str_size == 0)
  {
    return ECMA_NUMBER_ZERO;
  }

  ecma_string_trim_helper (&str_p, &str_size);
  const lit_utf8_byte_t *end_p = str_p + (str_size - 1);

  if (str_size < 1)
  {
    return ECMA_NUMBER_ZERO;
  }

  if (end_p >= str_p + 2
      && str_p[0] == LIT_CHAR_0)
  {
    switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
    {
      case LIT_CHAR_LOWERCASE_X :
      {
        return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
      }
      case LIT_CHAR_LOWERCASE_O :
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/base/ecma-helpers-conversion.c (C)

Code before:
    }
#endif /* ENABLED (JERRY_ESNEXT) */
    else
    {
      return ecma_number_make_nan ();
    }

    num = num * radix + (ecma_number_t) digit_value;
  }

  return num;
} /* ecma_utf8_string_to_number_by_radix */

/**
 * ECMA-defined conversion of string to Number.
 *
 * See also:
 *          ECMA-262 v5, 9.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
ecma_number_t
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                            lit_utf8_size_t str_size, /**< string size */
                            uint32_t allow_underscore_option) /**< true - if '_' characters are allowed in the string
                                                                   false - otherwise */
{
  /* TODO: Check license issues */

  if (str_size == 0)
  {
    return ECMA_NUMBER_ZERO;
  }

  ecma_string_trim_helper (&str_p, &str_size);
  const lit_utf8_byte_t *end_p = str_p + (str_size - 1);

  if (str_size < 1)
  {
    return ECMA_NUMBER_ZERO;
  }

  if (end_p >= str_p + 2
      && str_p[0] == LIT_CHAR_0)
  {
    switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
    {
      case LIT_CHAR_LOWERCASE_X :
      {
        return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | allow_underscore_option);

Review comment (suggestion):
The comment is invalid. Also the name should simply be `options` since we may add more options in the future.

Code after:
    }

    num = num * radix + (ecma_number_t) digit_value;
  }

  return num;
} /* ecma_utf8_string_to_number_by_radix */

/**
 * ECMA-defined conversion of string to Number.
 *
 * See also:
 *          ECMA-262 v5, 9.3.1
 *
 * @return NaN - if the conversion fails
 *         converted number - otherwise
 */
ecma_number_t
ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
                            lit_utf8_size_t str_size, /**< string size */
                            uint32_t options) /**< allowing underscore option bit */
{
  /* TODO: Check license issues */

  if (str_size == 0)
  {
    return ECMA_NUMBER_ZERO;
  }

  ecma_string_trim_helper (&str_p, &str_size);
  const lit_utf8_byte_t *end_p = str_p + (str_size - 1);

  if (str_size < 1)
  {
    return ECMA_NUMBER_ZERO;
  }

  if (end_p >= str_p + 2
      && str_p[0] == LIT_CHAR_0)
  {
    switch (LEXER_TO_ASCII_LOWERCASE (str_p[1]))
    {
      case LIT_CHAR_LOWERCASE_X :
      {
        return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 16 | options);
      }
      case LIT_CHAR_LOWERCASE_O :
      {
        return ecma_utf8_string_to_number_by_radix (str_p + 2, end_p, 8 | options);
      }
      case LIT_CHAR_LOWERCASE_B :
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-conversion.c (C)

Code before:
 *
 * \addtogroup ecmaconversion ECMA conversion routines
 * @{
 */

/**
 * RequireObjectCoercible operation.
 *
 * See also:
 *          ECMA-262 v11, 7.2.1
 *
 * @return bool
 */
bool
ecma_op_require_object_coercible (ecma_value_t value) /**< ecma value */
{
  ecma_check_value_type_is_spec_defined (value);

  if (ecma_is_value_undefined (value)
      || ecma_is_value_null (value))
  {
    return false;
  }

  return true;
} /* ecma_op_require_object_coercible */

/**
 * SameValue operation.
 *
 * See also:
 *          ECMA-262 v5, 9.12
 *
 * @return true - if the value are same according to ECMA-defined SameValue algorithm,
 *         false - otherwise
 */
bool
ecma_op_same_value (ecma_value_t x, /**< ecma value */
                    ecma_value_t y) /**< ecma value */
{
  if (x == y)
  {
    return true;
  }

  ecma_type_t type_of_x = ecma_get_value_type_field (x);

  if (type_of_x != ecma_get_value_type_field (y)
      || type_of_x == ECMA_TYPE_DIRECT)
  {
    return false;

Review comment (suggestion):
```c 
return (!ecma_is_value_undefined (value) && !ecma_is_value_null (value));
```

Code after:
 *
 * \addtogroup ecmaconversion ECMA conversion routines
 * @{
 */

/**
 * RequireObjectCoercible operation.
 *
 * See also:
 *          ECMA-262 v11, 7.2.1
 *
 * @return true - if the value can be coerced to object without any exceptions
 *         false - otherwise
 */
bool
ecma_op_require_object_coercible (ecma_value_t value) /**< ecma value */
{
  ecma_check_value_type_is_spec_defined (value);

  if (ecma_is_value_undefined (value) || ecma_is_value_null (value))
  {
    ecma_raise_type_error (ECMA_ERR_MSG ("Argument cannot be converted to an object."));
    return false;
  }

  return true;
} /* ecma_op_require_object_coercible */

/**
 * SameValue operation.
 *
 * See also:
 *          ECMA-262 v5, 9.12
 *
 * @return true - if the value are same according to ECMA-defined SameValue algorithm,
 *         false - otherwise
 */
bool
ecma_op_same_value (ecma_value_t x, /**< ecma value */
                    ecma_value_t y) /**< ecma value */
{
  if (x == y)
  {
    return true;
  }

  ecma_type_t type_of_x = ecma_get_value_type_field (x);

  if (type_of_x != ecma_get_value_type_field (y)
      || type_of_x == ECMA_TYPE_DIRECT)
  {