-
Notifications
You must be signed in to change notification settings - Fork 676
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
Introduce integer ecma-value representation to reduce the double allocations #1039
Introduce integer ecma-value representation to reduce the double allocations #1039
Conversation
The binary size is decreased because a lot of ecma_alloc_number () calls are eliminated. |
1830a36
to
e730ca9
Compare
|
||
return u.u64_value == 0; | ||
#endif | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing comment:
https://travis-ci.org/Samsung/jerryscript/jobs/128006828
./jerry-core/ecma/base/ecma-helpers-value.c:376: error: missing comment at the end of function: /* ecma_is_number_equals_to_positive_zero */
e730ca9
to
b3471ff
Compare
Thank you, fixed. |
LGTM |
ECMA_TYPE_SIMPLE, /**< simple value */ | ||
ECMA_TYPE_NUMBER, /**< 64-bit integer */ | ||
ECMA_TYPE_NON_PTR_VALUE, /**< directly encoded value, a 28 bit signed integer or a simple value */ | ||
ECMA_TYPE_FLOAT_NUMBER, /**< pointer to a 64 or 32 bit floating point number */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Terminology: to me, simpler is better. I'd suggest using ECMA_TYPE_DIRECT
and perhaps even ECMA_TYPE_FLOAT
. Even the comment of "non-ptr" starts explaining the type as "DIRECTly encoded"; and we haven't used "VALUE" suffices at the other labels (OBJECT, STRING) either. And its better to name something what it is than what it isn't.
We could argue that terminology is unimportant enough not to worry about -- but using the right terms helps understanding IMHO.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ok. I used this name first, but I didn't particularly like it. But I am not against it either.
b3471ff
to
b4625ce
Compare
Patch updated |
b4625ce
to
af33305
Compare
{ | ||
return ecma_make_integer_value (integer_value); | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To remove the need for code duplication, the above if could/should be written as
if (((ecma_number_t) integer_value == ecma_num)
&& (((integer_value == 0) && ecma_is_number_equals_to_positive_zero (ecma_num))
|| (ECMA_INTEGER_NUMBER_MIN <= integer_value && integer_value <= ECMA_INTEGER_NUMBER_MAX)))
{
// do something (only once)
}
(The above is still within line length limits.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The above is incorrect, because the ECMA_INTEGER_NUMBER_MIN <= integer_value && integer_value <= ECMA_INTEGER_NUMBER_MAX part includes the integer_value == 0
That is, it is the same as:
if (((ecma_number_t) integer_value == ecma_num)
&& (ECMA_INTEGER_NUMBER_MIN <= integer_value && integer_value <= ECMA_INTEGER_NUMBER_MAX)))
probably a ?: is better
Changes are added as a separate commit, but I plan to squash it. Please review. |
{ | ||
JERRY_ASSERT (ECMA_IS_INTEGER_NUMBER (integer_value)); | ||
|
||
return (ecma_value_t) ((integer_value << ECMA_DIRECT_SHIFT) | ECMA_TYPE_DIRECT); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should rather end with | ECMA_DIRECT_TYPE_INTEGER_VALUE
5eae47c
to
a7d196b
Compare
…cations. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
a7d196b
to
00f759e
Compare
Since only NaNs are created now, I made a ecma_make_nan_value function. If we ever need other constants we could continue this discussion. |
LGTM |
The patch is an initial patch to store 28 bit integer values in ecma_values. This is a first patch in a series of patches which exploits these integer numbers to accelerate math performance, since most numbers are small integer numbers in JavaScript. The memory saving is resulted by not allocating doubles for these integer numbers. The follow-up patches will likely not affect memory.
RPi2 results