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

Code before:
#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-number-object.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-string-object.h"
#include "ecma-symbol-object.h"
#include "jrt-libc-includes.h"

/** \addtogroup ecma ECMA
 * @{
 *
 * \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);

  return (!ecma_is_value_undefined (value) && !ecma_is_value_null (value));
} /* 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;

Review comment (suggestion):
```
@return true - if the value can be coerced to object without any exceptions
        false - otherwise
```


Code after:
#include "ecma-exceptions.h"
#include "ecma-function-object.h"
#include "ecma-gc.h"
#include "ecma-globals.h"
#include "ecma-helpers.h"
#include "ecma-number-object.h"
#include "ecma-objects.h"
#include "ecma-objects-general.h"
#include "ecma-string-object.h"
#include "ecma-symbol-object.h"
#include "jrt-libc-includes.h"

/** \addtogroup ecma ECMA
 * @{
 *
 * \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
 */
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-comparison.c (C)

Code before:

  if (!(is_px_string && is_py_string))
  {
#if ENABLED (JERRY_BUILTIN_BIGINT)
    if (JERRY_LIKELY (!ecma_is_value_bigint (px))
        && JERRY_LIKELY (!ecma_is_value_bigint (py)))
    {
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
      /* 3. */

      /* a. */

      ecma_number_t nx;
      ecma_number_t ny;

      if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx)))
      {
        ecma_free_value (prim_second_converted_value);
        ecma_free_value (prim_first_converted_value);
        return ECMA_VALUE_ERROR;
      }

      if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny)))
      {
        ecma_free_value (prim_second_converted_value);
        ecma_free_value (prim_first_converted_value);
        return ECMA_VALUE_ERROR;
      }

      /* b. */
      if (ecma_number_is_nan (nx)
          || ecma_number_is_nan (ny))
      {
        /* c., d. */
        ret_value = ECMA_VALUE_UNDEFINED;
      }
      else
      {
        bool is_x_less_than_y = (nx < ny);

#ifndef JERRY_NDEBUG
        bool is_x_less_than_y_check;

        if (nx == ny
            || (ecma_number_is_zero (nx)
                && ecma_number_is_zero (ny)))
        {
          /* e., f., g. */
          is_x_less_than_y_check = false;
        }
        else if (ecma_number_is_infinity (nx)

Review comment (suggestion):
What about setting ret_value to ECMA_VALUE_ERROR and jump to the end.
Maybe
```
ret_value = ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx));
if (ECMA_IS_VALUE_ERROR (ret_value))
{
  goto error;
}
```

Code after:

  if (!(is_px_string && is_py_string))
  {
#if ENABLED (JERRY_BUILTIN_BIGINT)
    if (JERRY_LIKELY (!ecma_is_value_bigint (px))
        && JERRY_LIKELY (!ecma_is_value_bigint (py)))
    {
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
      /* 3. */

      /* a. */

      ecma_number_t nx;
      ecma_number_t ny;

      if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx))
          || ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny)))
      {
        ret_value = ECMA_VALUE_ERROR;
        goto end;
      }

      /* b. */
      if (ecma_number_is_nan (nx)
          || ecma_number_is_nan (ny))
      {
        /* c., d. */
        ret_value = ECMA_VALUE_UNDEFINED;
      }
      else
      {
        bool is_x_less_than_y = (nx < ny);

#ifndef JERRY_NDEBUG
        bool is_x_less_than_y_check;

        if (nx == ny
            || (ecma_number_is_zero (nx)
                && ecma_number_is_zero (ny)))
        {
          /* e., f., g. */
          is_x_less_than_y_check = false;
        }
        else if (ecma_number_is_infinity (nx)
                 && !ecma_number_is_negative (nx))
        {
          /* h. */
          is_x_less_than_y_check = false;
        }
        else if (ecma_number_is_infinity (ny)
                 && !ecma_number_is_negative (ny))
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/operations/ecma-comparison.c (C)

Code before:
  }

  ecma_value_t px = left_first ? prim_first_converted_value : prim_second_converted_value;
  ecma_value_t py = left_first ? prim_second_converted_value : prim_first_converted_value;

  const bool is_px_string = ecma_is_value_string (px);
  const bool is_py_string = ecma_is_value_string (py);

  if (!(is_px_string && is_py_string))
  {
#if ENABLED (JERRY_BUILTIN_BIGINT)
    if (JERRY_LIKELY (!ecma_is_value_bigint (px))
        && JERRY_LIKELY (!ecma_is_value_bigint (py)))
    {
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
      /* 3. */

      /* a. */

      ecma_number_t nx;
      ecma_number_t ny;

      if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx)))
      {
        return ECMA_VALUE_ERROR;
      }

      if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny)))
      {
        return ECMA_VALUE_ERROR;
      }

      /* b. */
      if (ecma_number_is_nan (nx)
          || ecma_number_is_nan (ny))
      {
        /* c., d. */
        ret_value = ECMA_VALUE_UNDEFINED;
      }
      else
      {
        bool is_x_less_than_y = (nx < ny);

#ifndef JERRY_NDEBUG
        bool is_x_less_than_y_check;

        if (nx == ny
            || (ecma_number_is_zero (nx)
                && ecma_number_is_zero (ny)))
        {
          /* e., f., g. */

Review comment (suggestion):
This assignment would be no longer needed if `ret_value` would be initialized to `ECMA_VALUE_ERROR` at the variable declaration.

Code after:
  }

  ecma_value_t px = left_first ? prim_first_converted_value : prim_second_converted_value;
  ecma_value_t py = left_first ? prim_second_converted_value : prim_first_converted_value;

  const bool is_px_string = ecma_is_value_string (px);
  const bool is_py_string = ecma_is_value_string (py);

  if (!(is_px_string && is_py_string))
  {
#if ENABLED (JERRY_BUILTIN_BIGINT)
    if (JERRY_LIKELY (!ecma_is_value_bigint (px))
        && JERRY_LIKELY (!ecma_is_value_bigint (py)))
    {
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
      /* 3. */

      /* a. */

      ecma_number_t nx;
      ecma_number_t ny;

      if (ECMA_IS_VALUE_ERROR (ecma_op_to_number (px, &nx))
          || ECMA_IS_VALUE_ERROR (ecma_op_to_number (py, &ny)))
      {
        ret_value = ECMA_VALUE_ERROR;
        goto end;
      }

      /* b. */
      if (ecma_number_is_nan (nx)
          || ecma_number_is_nan (ny))
      {
        /* c., d. */
        ret_value = ECMA_VALUE_UNDEFINED;
      }
      else
      {
        bool is_x_less_than_y = (nx < ny);

#ifndef JERRY_NDEBUG
        bool is_x_less_than_y_check;

        if (nx == ny
            || (ecma_number_is_zero (nx)
                && ecma_number_is_zero (ny)))
        {
          /* e., f., g. */
          is_x_less_than_y_check = false;
        }
        else if (ecma_number_is_infinity (nx)
Repository: jerryscript-project/jerryscript
File: jerry-core/api/jerry.c (C)

Code before:

  return jerry_return (ecma_bigint_to_bigint (value, true));
#else /* !ENABLED (JERRY_BUILTIN_BIGINT) */
  JERRY_UNUSED (value);
  return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (error_bigint_not_supported_p)));
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
} /* jerry_value_to_bigint */

/**
 * Call the integer ecma builtin operation on the api value.
 *
 * @return undefined value - if success
 *         thrown error - otherwise
 */
jerry_value_t
jerry_value_as_integer (jerry_value_t value, /**< input value */
                        double *number_p)  /**< [out] double number */
{
  jerry_assert_api_available ();

  if (ecma_is_value_error_reference (value))
  {
    return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (error_value_msg_p)));
  }

  return jerry_return (ecma_op_to_integer (value, number_p));
} /* jerry_value_as_integer */

/**
 * Call the uint32 ecma builtin operation on the api value.
 *
 * @return undefined value - if success
 *         thrown error - otherwise
 */
jerry_value_t
jerry_value_as_uint32 (jerry_value_t value, /**< input value */
                       uint32_t *number_p) /**< [out] double number */
{
  jerry_assert_api_available ();

  if (ecma_is_value_error_reference (value))
  {
    return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (error_value_msg_p)));
  }

  ecma_number_t number;
  value = ecma_op_to_number (value, &number);

  if (ECMA_IS_VALUE_ERROR (value))
  {
    return ECMA_VALUE_ERROR;

Review comment (suggestion):
`ecma_op_to_integer` returns `ECMA_VALUE_EMPTY` on success which is not compatible with `jerry_return`. Handle the error case separately and return with undefined otherwise.

Code after:
  }

  return jerry_return (ecma_bigint_to_bigint (value, true));
#else /* !ENABLED (JERRY_BUILTIN_BIGINT) */
  JERRY_UNUSED (value);
  return jerry_throw (ecma_raise_type_error (ECMA_ERR_MSG (error_bigint_not_supported_p)));
#endif /* ENABLED (JERRY_BUILTIN_BIGINT) */
} /* jerry_value_to_bigint */

/**
 * Convert any number to integer number.
 *
 * Note:
 *      For non-number values 0 is returned.
 *
 * @return integer representation of the number.
 */
double
jerry_value_as_integer (const jerry_value_t value) /**< input value */
{
  jerry_assert_api_available ();

  if (!ecma_is_value_number (value))
  {
    return 0;
  }

  double number = ecma_get_number_from_value (value);

  if (ecma_number_is_nan (number))
  {
    return ECMA_NUMBER_ZERO;
  }

  if (ecma_number_is_zero (number) || ecma_number_is_infinity (number))
  {
    return number;
  }

  ecma_number_t floor_fabs = (ecma_number_t) floor (fabs (number));

  return ecma_number_is_negative (number) ? -floor_fabs : floor_fabs;
} /* jerry_value_as_integer */

/**
 * Convert any number to int32 number.
 *
 * Note:
 *      For non-number values 0 is returned.
 *
 * @return int32 representation of the number.
Repository: jerryscript-project/jerryscript
File: tests/unit-core/test-number-converter.c (C)

Code before:
  test_to_int32 (-2147483648, -2147483648);
  test_to_int32 (2147483647, 2147483647);
  test_to_int32 (-2147483647, -2147483647);
  test_to_int32 (-2147483649, 2147483647);
  test_to_int32 (2147483649, -2147483647);

  // few toInteger test-cases
  test_to_interger (1.0, 1.0);
  test_to_interger (0.0, 0.0);
  test_to_interger (NAN, 0);
  test_to_interger (-NAN, 0);
  test_to_interger (INFINITY, INFINITY);
  test_to_interger (-INFINITY, -INFINITY);
  test_to_interger (0.1, 0);
  test_to_interger (-0.1, -0);
  test_to_interger (1.1, 1);
  test_to_interger (-1.1, -1);
  test_to_interger (4294967295, 4294967295);
  test_to_interger (-4294967295, -4294967295);
  test_to_interger (4294967295, 4294967295);
  test_to_interger (-4294967296, -4294967296);
  test_to_interger (4294967297, 4294967297);
  test_to_interger (-4294967297, -4294967297);

  // few test-cases which return with error
  jerry_value_t error_val =  jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error");
  double number;
  error_val = jerry_value_as_integer (error_val, &number);
  TEST_ASSERT (jerry_value_is_error (error_val));
  error_val = jerry_create_symbol (error_val);
  error_val = jerry_value_as_integer (error_val, &number);
  TEST_ASSERT (jerry_value_is_error (error_val));

  return 0;
} /* main */


Review comment (suggestion):
Please add tests for an object like this: `{ valueOf() { throw new TypeError("foo")}}`. You can evaluate this string to construct this object more easily. 

Code after:
  test_to_int32 (-2147483648, -2147483648);
  test_to_int32 (2147483647, 2147483647);
  test_to_int32 (-2147483647, -2147483647);
  test_to_int32 (-2147483649, 2147483647);
  test_to_int32 (2147483649, -2147483647);

  // few toInteger test-cases
  test_to_interger (1.0, 1.0);
  test_to_interger (0.0, 0.0);
  test_to_interger (NAN, 0);
  test_to_interger (-NAN, 0);
  test_to_interger (INFINITY, INFINITY);
  test_to_interger (-INFINITY, -INFINITY);
  test_to_interger (0.1, 0);
  test_to_interger (-0.1, -0);
  test_to_interger (1.1, 1);
  test_to_interger (-1.1, -1);
  test_to_interger (4294967295, 4294967295);
  test_to_interger (-4294967295, -4294967295);
  test_to_interger (4294967295, 4294967295);
  test_to_interger (-4294967296, -4294967296);
  test_to_interger (4294967297, 4294967297);
  test_to_interger (-4294967297, -4294967297);

  // few test-cases which return with error
  jerry_value_t error_val =  jerry_create_error (JERRY_ERROR_TYPE, (const jerry_char_t *) "error");
  double number = jerry_value_as_integer (error_val);
  jerry_release_value (error_val);
  TEST_ASSERT (number == 0);

  error_val = jerry_create_symbol (error_val);
  number = jerry_value_as_integer (error_val);
  TEST_ASSERT (number == 0);
  jerry_release_value (error_val);

  error_val = jerry_eval ((const jerry_char_t *) "({ valueOf() { throw new TypeError('foo')}})",
                          44, JERRY_PARSE_NO_OPTS);
  number = jerry_value_as_integer (error_val);
  TEST_ASSERT (number == 0);
  jerry_release_value (error_val);

  jerry_cleanup ();
  return 0;
} /* main */
Repository: jerryscript-project/jerryscript
File: jerry-core/ecma/builtin-objects/ecma-builtin-error.c (C)

Code before:
} /* ecma_builtin_error_dispatch_call */

/**
 * Handle calling [[Construct]] of built-in Error object
 *
 * @return ecma value
 */
ecma_value_t
ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
                                       uint32_t arguments_list_len) /**< number of arguments */
{
#if !ENABLED (JERRY_ESNEXT)
  return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
#else /* ENABLED (JERRY_ESNEXT) */
  ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
                                                                   ECMA_BUILTIN_ID_ERROR_PROTOTYPE);

  if (proto_p == NULL)
  {
    return ECMA_VALUE_ERROR;
  }

  ecma_value_t result = ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);

  if (ECMA_IS_VALUE_ERROR (result))
  {
    ecma_deref_object (proto_p);
    return result;
  }

  ecma_object_t *object_p = ecma_get_object_from_value (result);
  ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
  ecma_deref_object (proto_p);
  return result;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_builtin_error_dispatch_construct */

/**
 * @}
 * @}
 * @}
 */


Review comment (suggestion):
Just to reduce code duplication:

```c
if (!ECMA_IS_VALUE_ERROR (result))
{
  ecma_object_t *object_p = ecma_get_object_from_value (result);
  ECMA_SET_NON_NULL_POINTER (object_p ->u2.prototype_cp, proto_p);
}

ecma_deref_object (proto_p);
return result;
```

Code after:
} /* ecma_builtin_error_dispatch_call */

/**
 * Handle calling [[Construct]] of built-in Error object
 *
 * @return ecma value
 */
ecma_value_t
ecma_builtin_error_dispatch_construct (const ecma_value_t *arguments_list_p, /**< arguments list */
                                       uint32_t arguments_list_len) /**< number of arguments */
{
#if !ENABLED (JERRY_ESNEXT)
  return ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);
#else /* ENABLED (JERRY_ESNEXT) */
  ecma_object_t *proto_p = ecma_op_get_prototype_from_constructor (JERRY_CONTEXT (current_new_target),
                                                                   ECMA_BUILTIN_ID_ERROR_PROTOTYPE);

  if (proto_p == NULL)
  {
    return ECMA_VALUE_ERROR;
  }

  ecma_value_t result = ecma_builtin_error_dispatch_call (arguments_list_p, arguments_list_len);

  if (!ECMA_IS_VALUE_ERROR (result))
  {
    ecma_object_t *object_p = ecma_get_object_from_value (result);
    ECMA_SET_NON_NULL_POINTER (object_p->u2.prototype_cp, proto_p);
  }

  ecma_deref_object (proto_p);

  return result;
#endif /* ENABLED (JERRY_ESNEXT) */
} /* ecma_builtin_error_dispatch_construct */

/**
 * @}
 * @}
 * @}
 */
Repository: jerryscript-project/jerryscript
File: tests/jerry/es.next/regression-test-issue-4341.js (JavaScript)

Code before:
  "-1n >> (2n ** 32n)",
  "-1n >> 2n",
  "-1n >> (2n ** 1n)",
  "-5n >> 3n",
  "-5n >> 4n",
  "-(2n ** 32n) >> (2n ** 31n)",
  "-(2n ** 32n) >> (2n ** 32n)",
  "-(2n ** 32n) >> (2n ** 33n)",
  "-(2n ** 32n) >> (2n ** 33000n)",
  "-(2n ** 32n) >> 32n",

  /* (xn << -yn) ==> (xn >> yn) */
  "-1n << -(2n ** 32n)",
  "-1n << -2n",
  "-1n << -(2n ** 1n)",
  "-5n << -3n",
  "-5n << -4n",
  "-(2n ** 32n) << -(2n ** 31n)",
  "-(2n ** 32n) << -(2n ** 32n)",
  "-(2n ** 32n) << -(2n ** 33n)",
  "-(2n ** 32n) << -(2n ** 33000n)",

];

for (var idx = 0; idx < test_minus_one.length; idx++) {
  run_test(test_minus_one[idx], -1n);
}

run_test("-(2n ** 32n) >> 31n", -2n);
run_test("-(2n ** 32n) >> 30n", -4n);
run_test("-(2n ** 32n) >> 29n", -8n);
run_test("-(2n ** 32n) >> 28n", -16n);
run_test("-(2n ** 32n) >> 16n", -65536n);
run_test("-(2n ** 32n) >> 2n", -1073741824n);

run_test("-5n >> 2n", -2n);
run_test("-5n >> -4n", -80n);


Review comment (performance):
What is the advantage of this loop? It feels harder to find an error from the backtrace compared to call `run_test` for each item. I don't think we need to optimize this code at all.

Code after:
assert((-(2n ** 32n) >> (2n ** 31n)) === -1n);
assert((-(2n ** 32n) >> (2n ** 32n)) === -1n);
assert((-(2n ** 32n) >> (2n ** 33n)) === -1n);
assert((-(2n ** 32n) >> (2n ** 33000n)) === -1n);
assert((-(2n ** 32n) >> 32n) === -1n);

/* (xn << -yn) ==> (xn >> yn) */
assert((-1n << -(2n ** 32n)) === -1n);
assert((-1n << -2n) === -1n);
assert((-1n << -(2n ** 1n)) === -1n);
assert((-5n << -3n) === -1n);
assert((-5n << -4n) === -1n);
assert((-(2n ** 32n) << -(2n ** 31n)) === -1n);
assert((-(2n ** 32n) << -(2n ** 32n)) === -1n);
assert((-(2n ** 32n) << -(2n ** 33n)) === -1n);
assert((-(2n ** 32n) << -(2n ** 33000n)) === -1n);

/* Partialy related tests. */
assert((-(2n ** 32n) >> 31n) === -2n);
assert((-(2n ** 32n) >> 30n) === -4n);
assert((-(2n ** 32n) >> 29n) === -8n);
assert((-(2n ** 32n) >> 28n) === -16n);
assert((-(2n ** 32n) >> 16n) === -65536n);
assert((-(2n ** 32n) >> 2n) === -1073741824n);

assert((-5n >> 2n) === -2n);
assert((-5n >> -4n) === -80n);
Repository: jerryscript-project/jerryscript
File: jerry-port/default/default-date.c (C)

Code before:
      && SystemTimeToFileTime (&localSystemTime, &localFileTime))
  {
    time.LowPart = fileTime.dwLowDateTime;
    time.HighPart = fileTime.dwHighDateTime;
    localTime.LowPart = localFileTime.dwLowDateTime;
    localTime.HighPart = localFileTime.dwHighDateTime;
    return (double) (((LONGLONG) localTime.QuadPart - (LONGLONG) time.QuadPart) / 10000);
  }
#endif /* _WIN32 */
  return 0.0;
#endif /* HAVE_TM_GMTOFF */
} /* jerry_port_get_local_time_zone_adjustment */

/**
 * Default implementation of jerry_port_get_current_time. Uses 'gettimeofday' if
 * available on the system, does nothing otherwise.
 *
 * @return milliseconds since Unix epoch - if 'gettimeofday' is available and
 *                                         executed successfully,
 *         0 - otherwise.
 */
double jerry_port_get_current_time (void)
{
  time_t ltime;
  time (&ltime);
  return (double) ltime * 1000.0;
} /* jerry_port_get_current_time */


Review comment (suggestion):
But `time()` has seconds granularity only! `jerry_port_get_current_time` is used by `Date.now()`, which is returns the number of _milliseconds_ elapsed since January 1, 1970 00:00:00 UTC. I think the Windows-specific code path used `time()` only as a fallback, as (non-MinGW) Windows has no `gettimeofday()`. But I don't think that we should lower precision generally.

Code after:
#else /* !HAVE_TM_GMTOFF */
  (void) unix_ms;
  (void) is_utc;
#ifdef _WIN32
  FILETIME fileTime, localFileTime;
  SYSTEMTIME systemTime, localSystemTime;
  ULARGE_INTEGER time, localTime;

  UnixTimeMsToFileTime (unix_ms, &fileTime);

  if (FileTimeToSystemTime (&fileTime, &systemTime)
      && SystemTimeToTzSpecificLocalTime (0, &systemTime, &localSystemTime)
      && SystemTimeToFileTime (&localSystemTime, &localFileTime))
  {
    time.LowPart = fileTime.dwLowDateTime;
    time.HighPart = fileTime.dwHighDateTime;
    localTime.LowPart = localFileTime.dwLowDateTime;
    localTime.HighPart = localFileTime.dwHighDateTime;
    return (double) (((LONGLONG) localTime.QuadPart - (LONGLONG) time.QuadPart) / TicksPerMs);
  }
#endif /* _WIN32 */
  return 0.0;
#endif /* HAVE_TM_GMTOFF */
} /* jerry_port_get_local_time_zone_adjustment */

/**
 * Default implementation of jerry_port_get_current_time. Uses 'gettimeofday' if
 * available on the system, does nothing otherwise.
 *
 * @return milliseconds since Unix epoch - if 'gettimeofday' is available and
 *                                         executed successfully,
 *         0 - otherwise.
 */
double jerry_port_get_current_time (void)
{
#ifdef _WIN32
  FILETIME ft;
  GetSystemTimeAsFileTime (&ft);
  return FileTimeToUnixTimeMs (ft);
#elif __GNUC__
  struct timeval tv;

  if (gettimeofday (&tv, NULL) == 0)
  {
    return ((double) tv.tv_sec) * 1000.0 + ((double) tv.tv_usec) / 1000.0;
  }
#endif /* _WIN32 */

  return 0.0;
} /* jerry_port_get_current_time */