Skip to content

Commit

Permalink
Remove all usage of JERRY_NUMBER_TYPE_FLOAT64, only leave the config …
Browse files Browse the repository at this point in the history
…behind

JerryScript-DCO-1.0-Signed-off-by: Yonggang Luo [email protected]
  • Loading branch information
lygstate committed Dec 17, 2024
1 parent 0339cec commit d66a705
Show file tree
Hide file tree
Showing 19 changed files with 8 additions and 225 deletions.
4 changes: 0 additions & 4 deletions jerry-core/api/jerry-snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,7 @@ snapshot_write_to_buffer_by_offset (uint8_t *buffer_p, /**< buffer */
/**
* Maximum snapshot write buffer offset.
*/
#if !JERRY_NUMBER_TYPE_FLOAT64
#define JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET (0x7fffff >> 1)
#else /* JERRY_NUMBER_TYPE_FLOAT64 */
#define JERRY_SNAPSHOT_MAXIMUM_WRITE_OFFSET (UINT32_MAX >> 1)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Save snapshot helper.
Expand Down
2 changes: 0 additions & 2 deletions jerry-core/api/jerryscript.c
Original file line number Diff line number Diff line change
Expand Up @@ -6587,9 +6587,7 @@ static jerry_typedarray_mapping_t jerry_typedarray_mappings[] = {
TYPEDARRAY_ENTRY (INT8, INT8, 0), TYPEDARRAY_ENTRY (UINT16, UINT16, 1),
TYPEDARRAY_ENTRY (INT16, INT16, 1), TYPEDARRAY_ENTRY (UINT32, UINT32, 2),
TYPEDARRAY_ENTRY (INT32, INT32, 2), TYPEDARRAY_ENTRY (FLOAT32, FLOAT32, 2),
#if JERRY_NUMBER_TYPE_FLOAT64
TYPEDARRAY_ENTRY (FLOAT64, FLOAT64, 3),
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
#if JERRY_BUILTIN_BIGINT
TYPEDARRAY_ENTRY (BIGINT64, BIGINT64, 3), TYPEDARRAY_ENTRY (BIGUINT64, BIGUINT64, 3),
#endif /* JERRY_BUILTIN_BIGINT */
Expand Down
7 changes: 0 additions & 7 deletions jerry-core/config.h
Original file line number Diff line number Diff line change
Expand Up @@ -666,13 +666,6 @@
* Cross component requirements check.
*/

/**
* The date module can only use the float 64 number types.
*/
#if JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64
#error "Date does not support float32"
#endif /* JERRY_BUILTIN_DATE && !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Source name related types into a single guard
*/
Expand Down
4 changes: 1 addition & 3 deletions jerry-core/ecma/base/ecma-error-messages.inc.h
Original file line number Diff line number Diff line change
Expand Up @@ -472,10 +472,8 @@ ECMA_ERROR_DEF (ECMA_ERR_ARGUMENT_THIS_NOT_BOOLEAN_OBJECT, "Argument 'this' is n
ECMA_ERROR_DEF (ECMA_ERR_CANNOT_DECLARE_SAME_PRIVATE_FIELD_TWICE, "Cannot declare same private field twice")
#if JERRY_BUILTIN_TYPEDARRAY
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT32_ARRAY_REQUIRES_NEW, "Constructor Float32Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY */
#if JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64
ECMA_ERROR_DEF (ECMA_ERR_CONSTRUCTOR_FLOAT64_ARRAY_REQUIRES_NEW, "Constructor Float64Array requires 'new'")
#endif /* JERRY_BUILTIN_TYPEDARRAY && JERRY_NUMBER_TYPE_FLOAT64 */
#endif /* JERRY_BUILTIN_TYPEDARRAY */
ECMA_ERROR_DEF (ECMA_ERR_FUNCTION_PROTOTYPE_NOT_A_CONSTRUCTOR, "Function.prototype is not a constructor")
#if JERRY_MODULE_SYSTEM
ECMA_ERROR_DEF (ECMA_ERR_IMPORTED_BINDING_SHADOWS_LOCAL_VARIABLE, "Imported binding shadows local variable")
Expand Down
34 changes: 2 additions & 32 deletions jerry-core/ecma/base/ecma-globals.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,45 +218,23 @@ enum
#endif /* JERRY_BUILTIN_GLOBAL_THIS */
};

#if !JERRY_NUMBER_TYPE_FLOAT64
/**
* Maximum integer number for an ecma value
*/
#define ECMA_INTEGER_NUMBER_MAX 0x7fffff
/**
* Maximum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
*/
#define ECMA_INTEGER_NUMBER_MAX_SHIFTED 0x7fffff0
#else /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Maximum integer number for an ecma value
*/
#define ECMA_INTEGER_NUMBER_MAX 0x7ffffff
#define ECMA_INTEGER_NUMBER_MAX 0x7ffffff
/**
* Maximum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
*/
#define ECMA_INTEGER_NUMBER_MAX_SHIFTED 0x7ffffff0
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

#if !JERRY_NUMBER_TYPE_FLOAT64
/**
* Minimum integer number for an ecma value
*/
#define ECMA_INTEGER_NUMBER_MIN -0x7fffff
/**
* Minimum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
*/
#define ECMA_INTEGER_NUMBER_MIN_SHIFTED -0x7fffff0
#else /* JERRY_NUMBER_TYPE_FLOAT64 */
/**
* Minimum integer number for an ecma value
*/
#define ECMA_INTEGER_NUMBER_MIN -0x8000000
#define ECMA_INTEGER_NUMBER_MIN -0x8000000
/**
* Minimum integer number for an ecma value (shifted left with ECMA_DIRECT_SHIFT)
*/
#define ECMA_INTEGER_NUMBER_MIN_SHIFTED (-0x7fffffff - 1) /* -0x80000000 */
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

#if ECMA_DIRECT_SHIFT != 4
#error "Please update ECMA_INTEGER_NUMBER_MIN/MAX_SHIFTED according to the new value of ECMA_DIRECT_SHIFT."
Expand All @@ -270,11 +248,7 @@ enum
/**
* Maximum integer number, which if squared, still fits in ecma_integer_value_t
*/
#if !JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_INTEGER_MULTIPLY_MAX 0xb50
#else /* JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_INTEGER_MULTIPLY_MAX 0x2d41
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Checks whether the error flag is set.
Expand Down Expand Up @@ -1333,11 +1307,7 @@ typedef struct
/**
* Description of an ecma-number
*/
#if JERRY_NUMBER_TYPE_FLOAT64
typedef double ecma_number_t;
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
typedef float ecma_number_t;
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Convert double to an ecma-number.
Expand Down
44 changes: 0 additions & 44 deletions jerry-core/ecma/base/ecma-helpers-conversion.c
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@
* @{
*/

#if JERRY_NUMBER_TYPE_FLOAT64

/**
* \addtogroup ecmahelpersbigintegers Helpers for operations intermediate 128-bit integers
* @{
Expand Down Expand Up @@ -253,28 +251,6 @@ ecma_uint64_normalize_shift (uint64_t n) /**< integer to count leading zeros in
* @}
*/

/**
* Number.MAX_VALUE exponent part when using 64 bit float representation.
*/
#define NUMBER_MAX_DECIMAL_EXPONENT 308
/**
* Number.MIN_VALUE exponent part when using 64 bit float representation.
*/
#define NUMBER_MIN_DECIMAL_EXPONENT -324

#elif !JERRY_NUMBER_TYPE_FLOAT64

/**
* Number.MAX_VALUE exponent part when using 32 bit float representation.
*/
#define NUMBER_MAX_DECIMAL_EXPONENT 38
/**
* Number.MIN_VALUE exponent part when using 32 bit float representation.
*/
#define NUMBER_MIN_DECIMAL_EXPONENT -45

#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Value of epsilon
*/
Expand Down Expand Up @@ -535,7 +511,6 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
return sign ? -ECMA_NUMBER_ZERO : ECMA_NUMBER_ZERO;
}

#if JERRY_NUMBER_TYPE_FLOAT64
/*
* 128-bit mantissa storage
*
Expand Down Expand Up @@ -628,25 +603,6 @@ ecma_utf8_string_to_number (const lit_utf8_byte_t *str_p, /**< utf-8 string */
JERRY_ASSERT (significand < (1ull << ECMA_NUMBER_FRACTION_WIDTH));

return ecma_number_create (sign, (uint32_t) binary_exponent, significand);
#elif !JERRY_NUMBER_TYPE_FLOAT64
/* Less precise conversion */
ecma_number_t num = (ecma_number_t) (uint32_t) fraction_uint64;

ecma_number_t m = e_sign ? (ecma_number_t) 0.1 : (ecma_number_t) 10.0;

while (e)
{
if (e % 2)
{
num *= m;
}

m *= m;
e /= 2;
}

return num;
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
} /* ecma_utf8_string_to_number */

/**
Expand Down
60 changes: 0 additions & 60 deletions jerry-core/ecma/base/ecma-helpers-number.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,7 @@
/**
* Binary representation of an ecma-number
*/
#if JERRY_NUMBER_TYPE_FLOAT64
typedef uint64_t ecma_binary_num_t;
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
typedef uint32_t ecma_binary_num_t;
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Makes it possible to read/write the binary representation of an ecma_number_t
Expand All @@ -50,11 +46,7 @@ ecma_number_t ecma_number_create (bool sign, uint32_t biased_exp, uint64_t fract
/**
* Maximum number of significant decimal digits that an ecma-number can store
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MAX_DIGITS (19)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MAX_DIGITS (9)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Width of sign field
Expand All @@ -70,59 +62,35 @@ ecma_number_t ecma_number_create (bool sign, uint32_t biased_exp, uint64_t fract
* See also:
* IEEE-754 2008, 3.6, Table 3.5
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_BIASED_EXP_WIDTH (11)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_BIASED_EXP_WIDTH (8)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Exponent bias
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_EXPONENT_BIAS (1023)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_EXPONENT_BIAS (127)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Width of fraction field
*
* See also:
* IEEE-754 2008, 3.6, Table 3.5
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_FRACTION_WIDTH (52)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_FRACTION_WIDTH (23)
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Sign bit in ecma-numbers
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_SIGN_BIT 0x8000000000000000ull
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_SIGN_BIT 0x7f800000u;
#endif /* !JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Binary representation of an IEEE-754 QNaN value.
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_BINARY_QNAN 0x7ff8000000000000ull
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_BINARY_QNAN 0x7fc00000u
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Binary representation of an IEEE-754 Infinity value.
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_BINARY_INF 0x7ff0000000000000ull
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_BINARY_INF 0x7f800000u
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Binary representation of an IEEE-754 zero value.
Expand All @@ -134,73 +102,45 @@ ecma_number_t ecma_number_create (bool sign, uint32_t biased_exp, uint64_t fract
*
* See also: ECMA_262 v5, 15.7.3.3
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MIN_VALUE ((ecma_number_t) 5e-324)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MIN_VALUE (FLT_MIN)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Number.MAX_VALUE (i.e., the maximum value of ecma-number)
*
* See also: ECMA_262 v5, 15.7.3.2
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MAX_VALUE ((ecma_number_t) 1.7976931348623157e+308)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MAX_VALUE (FLT_MAX)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Number.EPSILON
*
* See also: ECMA_262 v6, 20.1.2.1
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 2.2204460492503130808472633361816e-16)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_EPSILON ((ecma_number_t) 1.1920928955078125e-7)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Number.MAX_SAFE_INTEGER
*
* See also: ECMA_262 v6, 20.1.2.6
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0x1FFFFFFFFFFFFF)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MAX_SAFE_INTEGER ((ecma_number_t) 0xFFFFFF)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Number.MIN_SAFE_INTEGER
*
* See also: ECMA_262 v6, 20.1.2.8
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0x1FFFFFFFFFFFFF)
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define ECMA_NUMBER_MIN_SAFE_INTEGER ((ecma_number_t) -0xFFFFFF)
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Number.MAX_VALUE exponent part
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define NUMBER_MAX_DECIMAL_EXPONENT 308
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define NUMBER_MAX_DECIMAL_EXPONENT 38
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Number.MIN_VALUE exponent part
*/
#if JERRY_NUMBER_TYPE_FLOAT64
#define NUMBER_MIN_DECIMAL_EXPONENT -324
#else /* !JERRY_NUMBER_TYPE_FLOAT64 */
#define NUMBER_MIN_DECIMAL_EXPONENT -45
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */

/**
* Euler number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ enum
ECMA_DATAVIEW_PROTOTYPE_GET_INT32,
ECMA_DATAVIEW_PROTOTYPE_GET_UINT32,
ECMA_DATAVIEW_PROTOTYPE_GET_FLOAT32,
#if JERRY_NUMBER_TYPE_FLOAT64
ECMA_DATAVIEW_PROTOTYPE_GET_FLOAT64,
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
#if JERRY_BUILTIN_BIGINT
ECMA_DATAVIEW_PROTOTYPE_GET_BIGINT64,
ECMA_DATAVIEW_PROTOTYPE_GET_BIGUINT64,
Expand All @@ -64,9 +62,7 @@ enum
ECMA_DATAVIEW_PROTOTYPE_SET_INT32,
ECMA_DATAVIEW_PROTOTYPE_SET_UINT32,
ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32,
#if JERRY_NUMBER_TYPE_FLOAT64
ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64,
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
#if JERRY_BUILTIN_BIGINT
ECMA_DATAVIEW_PROTOTYPE_SET_BIGINT64,
ECMA_DATAVIEW_PROTOTYPE_SET_BIGUINT64,
Expand Down Expand Up @@ -162,9 +158,7 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
return ecma_builtin_dataview_prototype_object_getters (this_arg, builtin_routine_id);
}
case ECMA_DATAVIEW_PROTOTYPE_GET_FLOAT32:
#if JERRY_NUMBER_TYPE_FLOAT64
case ECMA_DATAVIEW_PROTOTYPE_GET_FLOAT64:
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
case ECMA_DATAVIEW_PROTOTYPE_GET_INT16:
case ECMA_DATAVIEW_PROTOTYPE_GET_INT32:
case ECMA_DATAVIEW_PROTOTYPE_GET_UINT16:
Expand All @@ -183,9 +177,7 @@ ecma_builtin_dataview_prototype_dispatch_routine (uint8_t builtin_routine_id, /*
id);
}
case ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT32:
#if JERRY_NUMBER_TYPE_FLOAT64
case ECMA_DATAVIEW_PROTOTYPE_SET_FLOAT64:
#endif /* JERRY_NUMBER_TYPE_FLOAT64 */
case ECMA_DATAVIEW_PROTOTYPE_SET_INT16:
case ECMA_DATAVIEW_PROTOTYPE_SET_INT32:
case ECMA_DATAVIEW_PROTOTYPE_SET_UINT16:
Expand Down
Loading

0 comments on commit d66a705

Please sign in to comment.