-
Notifications
You must be signed in to change notification settings - Fork 684
Reduce Math object binary size. #1491
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
Reduce Math object binary size. #1491
Conversation
343d375
to
a66c2cc
Compare
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.
LGTM
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.
Some minor issues, also please be more verbose in the commit message (e.g. similar to the previous Date built-in code size reduction). Thanks!
{ | ||
JERRY_UNUSED (this_arg); | ||
ecma_value_t ret_value = ecma_make_simple_value (ECMA_SIMPLE_VALUE_EMPTY); | ||
/* both numbers are zeroes */ |
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.
Comment should start with uppercase letter and end with full stop. Though honestly I think you can just drop the comment :)
* | ||
* @return ecma value | ||
* Returned value must be freed with ecma_free_value. | ||
*/ | ||
static ecma_value_t | ||
ecma_builtin_math_object_exp (ecma_value_t this_arg, /**< 'this' argument */ | ||
ecma_value_t arg) /**< routine's argument */ | ||
ecma_builtin_math_object_random () /**< 'this' argument */ |
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.
Should have a void
between the parentheses and the comment removed. Or alternatively a this
parameter added :)
* | ||
* See also: | ||
* ECMA-262 v5, 15.8.2.9 | ||
* Dispatcher of the built-in's routines |
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.
of -> for
Please add a full stop as well.
a66c2cc
to
5be7bb2
Compare
Fixed all requests. |
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.
Thanks, it seems you only partially incorporated the feedback though. I highlighted the issues again.
|
||
/** | ||
* The Math object's 'atan' routine | ||
* The Math object's 'max' 'min' routines |
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.
Full stop at the line end please.
|
||
/** | ||
* The Math object's 'exp' routine | ||
* The Math object's 'random' routine |
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.
Full stop at the end of the sentence please.
* | ||
* @return ecma value | ||
* Returned value must be freed with ecma_free_value. | ||
*/ | ||
static ecma_value_t | ||
ecma_builtin_math_object_exp (ecma_value_t this_arg, /**< 'this' argument */ | ||
ecma_value_t arg) /**< routine's argument */ | ||
ecma_builtin_math_object_random () |
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.
Please replace ecma_builtin_math_object_random()
with ecma_builtin_math_object_random(void)
. In C there's quite a difference between the two, right now you can call ecma_builtin_math_object_random()
with an arbitrary number of arguments and the compiler won't complain :)
* | ||
* See also: | ||
* ECMA-262 v5, 15.8.2.9 | ||
* Dispatcher for the built-in's routines |
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.
Full stop at the end of the sentence please.
5be7bb2
to
c70613c
Compare
Thank you for the review. Issues were fixed. |
Although many Math built-in functions have a similar structure these code paths were implemented as separate C functions. After this patch only one common dispatcher remains which shares the common code paths of different built-in functions. This reduces the binary size by 1 Kbyte. JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg [email protected]
c70613c
to
d63bb4e
Compare
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.
Thank you! LGTM
Roughly one KByte saving: 141024 -> 140256