Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature, Use JERRY_NUMBER_TYPE_FLOAT64 to guard arithmetic with double only, always storage float as FLOAT64 #5174

Open
lygstate opened this issue Nov 22, 2024 · 6 comments
Assignees
Labels
discussion Ongoing discussion ecma core Related to core ECMA functionality feature request Requested feature

Comments

@lygstate
Copy link
Contributor

lygstate commented Nov 22, 2024

Currently, the JERRY_NUMBER_TYPE_FLOAT64 == 0 have too much drawback because it's can not represent full int32_t, so indeed
all bitwise operation is invalid when JERRY_NUMBER_TYPE_FLOAT64 == 0, if JERRY_NUMBER_TYPE_FLOAT64 is not for save memory,
then we can use float do arithmatic but use double do storage.

From my point of view, ECMA_TYPE_FLOAT = 2, /**< pointer to a 64 or 32 bit floating point number */
can not save memory memory, because the minimal alignment of pointer is 8, so the size of allocated address minimal is 8, the JERRY_NUMBER_TYPE_FLOAT64 == 0 can not save memory, only increase performance.

So my will is only use JERRY_NUMBER_TYPE_FLOAT64 == 0 to do floating arithmetic, but use double to do storage.

@ossy-szeged
Copy link
Contributor

The original goal of JERRY_NUMBER_TYPE_FLOAT64 == 0 build configuration is supporting platforms which doesn't have hardware accelerated double precision floating point support. For example ESP32 has only single precision floating point support, using double numbers can be done only with softfp, which is significantly slower. Of course, this configuration has drawbacks, for example loosing ECMAScript compatibility, many features, etc.

@lygstate
Copy link
Contributor Author

lygstate commented Nov 22, 2024

compatibility

If that's only for platforms which doesn't have hardware accelerated double precision floating point support. then we only need use float do arithmetic and use double for storage, that is when double + dobule we can convert to float + float and then save the result back to double, that will significantly simplfy the code and more ECMAScript compatibility without performance penalty on ESP32, as we won't use softfp do double + double double-double double*double double/double.
And convert double to float or convert float to double is fast without hardware fp

I have the will do sumbit a MR for that, I need to know if this is the right direction and acceptable

@lygstate lygstate changed the title Question, what's JERRY_NUMBER_TYPE_FLOAT64 for (save memory or performance or both) Feature, Use JERRY_NUMBER_TYPE_FLOAT64 to guard arithmetic with double only, always storage float as FLOAT64 Nov 22, 2024
@LaszloLango LaszloLango added feature request Requested feature ecma core Related to core ECMA functionality discussion Ongoing discussion labels Nov 25, 2024
@LaszloLango
Copy link
Contributor

Sounds good to me, but I can speak only for myself.

@LaszloLango
Copy link
Contributor

CC: @zherczeg @akosthekiss @robertsipka

@zherczeg
Copy link
Member

This is an outdated feature from ES 5.1. Since that JS become far more complex. If somebody needs float, probably an old, ES 5.1 version of the engine is enough. From newer versions, this feature could be deleted.

@lygstate
Copy link
Contributor Author

This is an outdated feature from ES 5.1. Since that JS become far more complex. If somebody needs float, probably an old, ES 5.1 version of the engine is enough. From newer versions, this feature could be deleted.

OK let's me delete it first

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
discussion Ongoing discussion ecma core Related to core ECMA functionality feature request Requested feature
Projects
None yet
Development

No branches or pull requests

4 participants